<!--
字段关系分类表码列表
@Author: linqian
@Date: 2022-09-29 13:57
-->
<template>
    <div>
      <!-- 搜索栏 -->
      <search-bar :conditionForm="conditionForm" @submitSearch="receiveSearch"></search-bar>
      <!-- 操作栏 -->
      <operate-bar :pageOptList="pageOptList" @submitPageOpt="receviceOpt"></operate-bar>
      <!-- 列表 -->
      <new-table
        ref="table"
        :tableUrl="tableUrl"
        :tableHeader="tableHeader"
        :condition="condition"
        :tableOptList="tableOptList"
        @submitTableOpt="receviceOpt"
      >
      </new-table>
    </div>
  </template>
  <script>
  import searchBar from '@/components/search-bar';
  import operateBar from '@/components/operate-bar';
  import newTable from '@/components/new-table';
  import { fieldRelSyncUrl } from '@/api/sync';
  import { searchOpt, syncOpt } from '@/mixins/page-opt';
  import { fieldRelTabelUrl, delFieldRel } from "@/api/data-auth"
  export default {
    components: { searchBar, operateBar, newTable },
    mixins: [searchOpt, syncOpt],
    data() {
      return {
        tableUrl: fieldRelTabelUrl,
        tableHeader: [{
           label: "字段关系分类",
           prop: "columnRelation"
        },{
           label: "代码",
           prop: "codeValue"
        }],
        tableOptList: ["修改", "删除"],
        pageOptList: ["新增", "同步"],
        conditionForm: [
          {
           label: '字段关系分类',
            name: 'columnRelation',
            op: 'like',
           value: '',
           component: 'ElInput'
  },
        ]
      };
    },
    computed: {},
    methods: {
       receviceOpt(opt, row) {    
        if (opt == '新增') {
            this.handleEdit({});
        } else if (opt == '修改') {
            this.handleEdit(row);
        } else if (opt == '删除') {
          this.handleDelete(row);
        } else if (opt == '同步') {
          this.handleSync(fieldRelSyncUrl);
        } 
      },
      handleEdit(row) {
        const vm = this;
        const layer = this.$dgLayer({
            title: '修改',
            area: ['700px', '500px'],
            content: require("./filed-rel-sort-form.vue"),
            props: {
              id: row.id
            },
            on: {
              success() {
                layer.close(layer.dialogIndex);
                vm.handleSearch();
               
              }
            }
          });

      },
      handleDelete(row) {
        this.$dgConfirm(`是否确定删除这条数据！`, '提示', {}).then(() => {
          delFieldRel(row.id).then(res => {
             this.$message.success("删除成功！");
             this.handleSearch();
          })
        });
      }
   
    },
    created() {},
    mounted() {}
  };
  </script>
  
  <style lang='scss'>
  </style>