<!--
 * @Author: Liugh
 * @Date: 2021-05-18 11:34:15
 * @LastEditTime: 2021-05-18 14:24:33
 * @LastEditors: Do not edit
 * @FilePath: \auth-web\src\pages\data-auth-module\auth-subject-manage\application-management\application-properties.vue
 * @Description: 
-->
<template>
  <main class="application-properties">
    <!-- 搜索项 -->
    <search-bar ref="searchbar" :conditionForm="conditionForm" @submitSearch="receiveSearch"></search-bar>
    <!-- 操作栏 -->
    <operate-bar :pageOptList="pageOptList" @submitPageOpt="receviceOpt"></operate-bar>
    <!-- 表格 -->
    <new-table
      ref="table"
      :tableUrl="tableUrl"
      :tableHeader="appTableHeader"
      :condition="condition"
      :tableOptList="tableOptList"
      @submitTableOpt="receviceOpt"
    >
    </new-table>
  </main>
</template>

<script>
import newTable from '@/components/new-table';
import { appTableHeader, appConditionForm, pageOptList } from '../DataConfig';
import FormDetail from '@/components/form-detail';
import { appForm } from '@/pages/auth-object-manage/appfun-resource-manage/DataConfig';
import { appRestApi } from '@/api/application';
import { appSyncUrl } from '@/api/sync';
import { appImportUrl } from '@/api/import';
import searchBar from '@/components/search-bar';
import operateBar from '@/components/operate-bar';
import { searchOpt, importOpt, syncOpt } from '@/mixins/page-opt';
export default {
  name: 'application-properties', // 组件名称
  props: {
    // 接收父组件的数据
  },
  data() {
    // 组件内部参数
    return {
      appTableHeader,
      conditionForm: appConditionForm,
      tableUrl: appRestApi.table,
      pageOptList,
      tableOptList: ['详情']
    };
  },
  computed: {}, // 计算属性
  watch: {}, // 侦听器（扩展的计算属性）
  components: { newTable, searchBar, operateBar }, // 注册局部组件
  mixins: [searchOpt, importOpt, syncOpt],
  methods: {
    receviceOpt(opt, row) {
      if (opt == '导入') {
        this.handleImport(appImportUrl, 'apply');
      } else if (opt == '同步') {
        this.handleSync(appSyncUrl);
      } else if (opt == '详情') {
        this.handleViewDetail(row);
      }
    },
    /**
     * @description:详情
     */
    async handleViewDetail(row) {
      const detailInfo = await this.getDetail(row.id);
      this.$dgLayer({
        title: '详情',
        content: FormDetail,
        props: {
          detailInfo,
          config: appForm,
          labelWidth: '180px'
        },
        area: ['800px', '600px']
      });
    },
    /**
     * 获取详情
     */
    getDetail(id) {
      return new Promise((resolve) => {
        appRestApi.detail(id).then((res) => {
          resolve(res);
        });
      });
    }
  },
  created() {}, // 组件创建完成后
  mounted() {} // 组件挂载完成后
};
</script>

