<style>
  .minimenuDiv {
    padding: 20px;
  }

  .minimenuDiv .query-box {
    width: 100%;
    padding: 0 0 20px;
    border-bottom: 1px solid #ccc;
    position: relative;
    text-align: right;
  }

  .minimenuDiv .normalBtn {
    color: #fff;
    padding: 0 15px;
    height: 30px;
    background: #e95252;
    border: 1px solid #e95252;
    cursor: pointer;
    border-radius: 15px;
    margin-left: 10px;
    outline: none;
  }

</style>
<template>
  <div class="minimenuDiv">
    <div class="query-box">

      <button type="button" class="normalBtn" >保存</button>
    </div>
    <table class="commonTable" border="0" cellspacing="0" cellpadding="0" v-loading="loading">
      <tr>
        <th>菜单类型</th>
        <th>菜单</th>
      </tr>
      <tr v-for="(item,index) in dataList" :key="index">
        <td>{{item.PageId}}</td>
        <td>{{item.PageName}}</td>
        <td>{{item.PageUrl}}</td>
        <td>{{item.PageTypeStr}}</td>
        <td>{{item.StatusStr}}</td>
        <td>
          <el-tooltip class="item" effect="dark" content="修改" placement="top-start">
            <el-button type="primary" icon="el-icon-edit" @click="getMenu(item.PageId)" circle style="padding:6px;">
            </el-button>
          </el-tooltip>
          <el-tooltip class="item" effect="dark" content="删除" placement="top-start">
            <el-button v-if="item.Status==0" type="danger" icon="el-icon-delete" @click="delMenu(item.PageId)" circle
              style="padding:6px;"></el-button>
          </el-tooltip>
          <el-tooltip class="item" effect="dark" content="恢复" placement="top-start">
            <el-button v-if="item.Status==1" type="primary" icon="iconfont icon-icon_huifu"
              @click="recoverMenu(item.PageId)" circle style="padding:5px;"></el-button>
          </el-tooltip>
        </td>
      </tr>
    </table>
  

 
  </div>
</template>
<script>
  export default {
    data() {
      return {
        loading: false,
        menuDialog: false,

  
        dataList: [],
        addMsg: {
          PageId: 0, //页面编号
          PageType: 1, //页面类型(1-基础页面,2-营销页面，3-订单页面，4-插件页面，5-diy页面
          PageName: '', //页面名称
          PageUrl: "", //页面地址
          PageSort: 0, //页面排序
          IsParameter: 0, //是否有参数(0-无参数，1-有参数)
          ParameterValue: "", //参数值
        },
        pageType: [],
        menurules: {
          PageName: [{
            required: true,
            message: '请填写菜单名称。',
            trigger: 'blur'
          }],
        }
      };
    },
    created() {

    },
    methods: {
     
      //获取分页数据
      getPageList() {
        this.apipost("/api/Tenant/GetMiniProgramePageManageList", {}, res => {
          if (res.data.resultCode == 1) {
            this.dataList = res.data.data;

          } else {
            this.Info(res.data.message);
          }
        })
      },
      //添加修改菜单
      setMenu() {
        this.apipost("/api/Tenant/SetMiniProgramePageManage", this.addMsg, res => {
          if (res.data.resultCode == 1) {
            this.getPageList();
            this.menuDialog = false;
            this.resetMsg();
          } else {
            this.Info(res.data.message);
          }
        })
      },
      //根据编号获取菜单
      getMenu(Id) {
        this.apipost("/api/Tenant/GetMiniProgramePageManage", {
          PageId: Id
        }, res => {
          if (res.data.resultCode == 1) {
            this.addMsg = res.data.data;
            this.menuDialog = true;
          } else {
            this.Info(res.data.message);
          }
        })
      },
    },
    mounted() {
 
      this.getPageList();
    }
  };

</script>
