<!--
关联功能资源
@Author: linqian
@Date: 2021-10-18 14:08
-->
<template>
  <div>
    功能开发中暂不开放!
    <!-- <template v-if="operateType == 'detail'"> -->
      <!-- 搜索栏 -->
      <!-- <search-bar :conditionForm="conditionForm" @submitSearch="receiveSearch"></search-bar> -->
      <!-- 操作栏 -->
      <!-- <operate-bar :pageOptList="pageOptList" @submitPageOpt="receviceOpt"></operate-bar> -->
      <!-- 列表 -->
      <!-- <vxe-table-basic
        :gridOptions="gridOptions"
        :tableColumn="tableColumn"
        :tableOptList="tableOptList"
        :tableData="tableData"
        :paginationConfig="paginationConfig"
        @paginationChange="getPagination"
        @submitTableOpt="receviceOpt"
      ></vxe-table-basic> -->
    <!-- </template> -->
    <!-- <p v-else>请选择属性值</p> -->
  </div>
</template>

<script>
import operateBar from '@/components/operate-bar';
import searchBar from '@/components/search-bar';
import { searchOpt } from '@/mixins/page-opt';
import { appRestApi } from '@/api/application';
import vxeTableBasic from '@/components/vxe-table-basic';
import { getRedAppFuncList, delRedAppFunc } from '@/api/list-manage';
import addFunDialog from './add-fun-dialog.vue';
export default {
  components: { operateBar, searchBar, vxeTableBasic },
  mixins: [searchOpt],
  props: {
    parentNode: Object,
    operateType: String,
    attrBelongType: String
  },
  data() {
    return {
      conditionForm: [
        {
          label: '应用系统名称',
          name: 'appName',
          op: 'like',
          value: '',
          component: 'SelectApp',
          apiUrl: appRestApi.table,
          valueName: 'applyName',
          labelName: 'applyName'
        }
      ],
      pageOptList: ['新增'],
      gridOptions: {
        treeConfig: { children: 'child', indent: 40 }
      },
      tableColumn: [
        {
          align: 'left',
          headerAlign: 'center',
          title: '应用功能名称',
          field: 'label',
          treeNode: true
        }
      ],
      tableOptList: ['删除'],
      tableData: [],
      paginationConfig: {
        pageSize: 10,
        currentPage: 1,
        total: 0
      }
    };
  },
  computed: {},
  methods: {
    receviceOpt(opt, row) {
      if (opt == '新增') {
        this.handleAdd();
      } else if (opt == '删除') {
        this.handleRemove(row);
      }
    },
    /**
     * 新增
     */
    handleAdd() {
      const vm = this;
      const layer = this.$dgLayer({
        title: '新增',
        content: addFunDialog,
        props: {},
        on: {
          success() {
            vm.reloadTable();
            layer.close(layer.dialogIndex);
          }
        },
        cancel: function (index) {
          // 关闭对应弹窗的ID
          layer.close(index);
          return false;
        },
        area: ['900px', '800px']
      });
    },
    /**
     * 删除
     */
    handleRemove() {
      this.$dgConfirm(`是否确定删除这条数据！`, '提示', {}).then(() => {
        const params = {
          // isTreeNode: row.isTreeNode,
          // resourceId: row.id,
          // resourceType: row.type
        };
        delRedAppFunc(params).then((res) => {
          this.$message.success('删除成功！');
          this.getList();
        });
      });
    },
    getPagination({ pageSize, currentPage }) {
      this.paginationConfig.pageSize = pageSize;
      this.paginationConfig.currentPage = currentPage;
      this.getList();
    },
    /**
     * 获取列表
     */
    getList() {
      const params = {
        page: this.paginationConfig.currentPage - 1,
        size: this.paginationConfig.pageSize,
        searchCondition: this.condition
      };
      getRedAppFuncList(params).then((res) => {
        const { content, totalElements } = res.data;
        this.tableData = content;
        this.paginationConfig.total = totalElements;
      });
    },
    receiveSearch(value) {
      this.condition = value;
      this.paginationConfig.currentPage = 1;
      this.getList();
    },
    reloadTable() {}
  },
  created() {
    this.getList();
  },
  mounted() {}
};
</script>

<style lang='scss'>
</style>