<template>
  <div>
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      v-model="form"
      v-model:page="page"
      ref="crud"
      @row-del="rowDel"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >
      <template #menu-left> </template>
      <template #menu-right>
        <el-button type="primary" icon="el-icon-upload" @click="handleImport">导入 </el-button>
      </template>
      <template #menu="scope"> </template>
      <template #produceTsTarget="scope"> </template>
    </avue-crud>
    <!-- 导入 -->
    <basic-import
      v-if="isShowImport"
      title="导入"
      :isShow="isShowImport"
      templateUrl="/blade-desk/QA/CycleTestItem/download-excel-template"
      templateName="试验项目模板.xls"
      importUrl="/blade-desk/QA/CycleTestItem/import-excel"
      @closeDialog="closeDialog"
    ></basic-import>
  </div>
</template>
<script>
import basicImport from '@/components/basic-import/main.vue';
export default {
  components: {
    basicImport,
  },
  data() {
    return {
      isShowImport: false,
      data: [],
      selectionList: [],
      option: {
        height: 'auto',
        calcHeight: 32,
        tip: false,
        size: 'medium',
        simplePage: true,
        searchShow: true,
        searchMenuSpan: 6,
        searchIcon: true,
        searchIndex: 3,
        tree: false,
        border: true,
        index: true,
        selection: false,
        viewBtn: false,
        delBtn: true,
        addBtn: true,
        editBtn: true,
        editBtnText: '修改',
        addBtnIcon: ' ',
        viewBtnIcon: ' ',
        delBtnIcon: ' ',
        editBtnIcon: ' ',
        viewBtnText: '详情',
        labelWidth: 120,
        menuWidth: 180,
        dialogWidth: 640,
        dialogClickModal: false,
        searchEnter: true,
        excelBtn: false,
        filterBtn: true,
        searchShowBtn: false,
        columnSort: true,
        excelBtn: true,
        columnSort: true,
        showOverflowTooltip: true,
        menu: true,
        gridBtn: false,
        searchLabelPosition: 'left',
        searchLabelPosition: 'left',
        searchGutter: 24,
        searchSpan: 6,
        menuAlign: 'left',
        gridBtn: false,
        searchMenuPosition: 'right',
        addBtnIcon: ' ',
        viewBtnIcon: ' ',
        delBtnIcon: ' ',
        editBtnIcon: ' ',
        align: 'center',
        column: [
          {
            label: '烧结部件',
            prop: 'partCode',
            bind: 'dsPart.partCode',
            sortable: true,
            filter: true,
            span: 24,
            search: true,
            type: 'select',
            filterable:true,
            clearable: true,
            dicData: [
              {
                label: '烧结 部件一',
                value: '1',
              },
              {
                label: '烧结 部件二',
                value: '2',
              },
              {
                label: '烧结 部件三',
                value: '3',
              },
            ],
            rules: [
              {
                required: true,
                message: '请选择',
                trigger: 'blur',
              },
            ],
          },
          {
            label: '模具号',
            prop: 'moldCode',
            sortable: true,
            filter: true,
            span: 24,
            search: true,
          },
          {
            label: '玻璃饼号',
            prop: 'partGc',
            sortable: true,
            filter: true,
            span: 24,
            search: true,
          },
          {
            label: '压饼模号',
            prop: 'partYb',
            sortable: true,
            filter: true,
            span: 24,
            search: false,
          },
          {
            label: '维护人',
            prop: 'userName',
            bind: 'keepMan.userName',
            sortable: true,
            filter: true,
            span: 24,
            search: false,
          },
          {
            label: '维护时间',
            prop: 'keepTime',
            sortable: true,
            filter: true,
            span: 24,
            search: false,
          },
          {
            label: '备注',
            prop: 'memo',
            sortable: true,
            filter: true,
            span: 24,
            search: false,
          },
        ],
      },
      form: {},
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
    };
  },
  methods: {
    // 点击导入按钮
    handleImport() {
      this.isShowImport = true
    },
    maintenanceClick() {
      //   this.$refs.myTable.fullValidate((errMap) => {
      //     if (errMap) {
      //       return;
      //     }
      //     const dataList = this.$refs.myTable.getRecordset().updateRecords;
      //     this.$ajax
      //       .post('oemMerits/maintenance', {
      //         dataList,
      //         status: 2,
      //         type: 'produce'
      //       })
      //       .then((res) => {
      //         if (res.code === 0) {
      //           this.$message.success('维护成功');
      //           this.queryTable();
      //         }
      //       });
      //   });
    },
    proofreadClick() {
      //   const dataList = this.$refs.myTable.getTableData().tableData;
      //   this.$ajax
      //     .post('oemMerits/proofread', {
      //       dataList,
      //       status: 3,
      //       type: 'produce'
      //     })
      //     .then((res) => {
      //       if (res.code === 0) {
      //         this.$message.success('校对成功');
      //         this.queryTable();
      //       }
      //     });
    },
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning('请选择至少一条数据');
        return;
      }
      this.$confirm('确定将选择数据删除?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      }).then(() => {});
    },
    // 多选
    selectionChange(list) {
      this.selectionList = list;
    },
    onLoad() {
      this.loading = true;
      this.data = [
        {
          dsPart: {
            abnormal: true,
            advanceRemind: 10,
            approvedByMan: null,
            area: 1.0,
            childPage: null,
            configNo: 'B1',
            craftWay: '4（封接）-6（电火花或磨削）-4（表）-库2',
            cruxMemo: null,
            deleted: false,
            docLink: 'XXX',
            expirationPeriod: 9999,
            formingThickness: null,
            glassCake: false,
            goldMark: false,
            hardness: null,
            keyValue: 6419,
            lastUpdateMan: null,
            lastUpdateTime: null,
            lettering: 1,
            markingsTest: false,
            material: 'XXXX',
            memo: null,
            nextDuo: '2051-03-07 09:43:33',
            partCode: '21E6-575-11732-B1',
            partId: 6419,
            partName: 'J70AHL-25封接插座部件0.38',
            pfStatus: 1,
            pfStatusText: '正常',
            plate: 'XXXX',
            plateCode: null,
            plateGoodsCode: null,
            plateThickness: '6',
            powderWeight: 1.0,
            printing: false,
            prodline: null,
            productType: 'XXX',
            psId: null,
            reviewerMan: null,
            signMemo: null,
            sinTer: true,
            technician: null,
            tjtNum: null,
            tsbNum: null,
            tsdNum: null,
            updateMan: {
              accountId: 541,
              card: null,
              createTime: '2023-05-04',
              curStatus: 1,
              deleted: false,
              deptName: null,
              dimissionTime: null,
              factoryId: 102,
              head: 0,
              jobName: 'MES开发',
              keyValue: 541,
              ldapName: 'cdl',
              mail: null,
              mobile: null,
              pfDepartment: {
                appLink: null,
                createTime: '2022-08-31',
                deleted: false,
                deptCode: '001',
                deptId: 1,
                deptName: 'MES开发部',
                deptType: 1,
                deptTypeTitle: '厂',
                keyValue: 1,
                memo: null,
                orders: '00',
                parentDeptId: null,
                parentPath: null,
                ucDeptId: null,
                updateTime: '2022-08-31 16:32:46',
              },
              pinyinIndex: 'CUIDIANLONG,CDL',
              ucUserId: null,
              updateTime: '2023-05-04 09:16:54',
              userCode: 'cdl',
              userId: 541,
              userName: '崔殿龙',
              userSex: 1,
              userSources: '崔殿龙',
              userString: '541:A:崔殿龙',
              userType: 'A',
            },
            updateTime: '2023-10-21 09:43:33',
          },
          keepMan: {
            accountId: 541,
            card: null,
            createTime: '2023-05-04',
            curStatus: 1,
            deleted: false,
            deptName: null,
            dimissionTime: null,
            factoryId: 102,
            head: 0,
            jobName: 'MES开发',
            keyValue: 541,
            ldapName: 'cdl',
            mail: null,
            mobile: null,
            pfDepartment: {
              appLink: null,
              createTime: '2022-08-31',
              deleted: false,
              deptCode: '001',
              deptId: 1,
              deptName: 'MES开发部',
              deptType: 1,
              deptTypeTitle: '厂',
              keyValue: 1,
              memo: null,
              orders: '00',
              parentDeptId: null,
              parentPath: null,
              ucDeptId: null,
              updateTime: '2022-08-31 16:32:46',
            },
            pinyinIndex: 'CUIDIANLONG,CDL',
            ucUserId: null,
            updateTime: '2023-05-04 09:16:54',
            userCode: 'cdl',
            userId: 541,
            userName: '崔殿龙',
            userSex: 1,
            userSources: '崔殿龙',
            userString: '541:A:崔殿龙',
            userType: 'A',
          },
          keepTime: '2024-01-03 15:27:56',
          keyValue: 1,
          memo: '崔点',
          moldCode: '1',
          partGc: '2',
          partYb: 'vfrd',
          smnId: 1,
        },
        {
          dsPart: {
            abnormal: true,
            advanceRemind: 10,
            approvedByMan: null,
            area: 1.0,
            childPage: null,
            configNo: 'B1',
            craftWay: '4（封接）-6（电火花或磨削）-4（表）-库2',
            cruxMemo: null,
            deleted: false,
            docLink: 'XXX',
            expirationPeriod: 9999,
            formingThickness: null,
            glassCake: false,
            goldMark: false,
            hardness: null,
            keyValue: 6419,
            lastUpdateMan: null,
            lastUpdateTime: null,
            lettering: 1,
            markingsTest: false,
            material: 'XXXX',
            memo: null,
            nextDuo: '2051-03-07 09:43:33',
            partCode: '21E6-575-11732-B1',
            partId: 6419,
            partName: 'J70AHL-25封接插座部件0.38',
            pfStatus: 1,
            pfStatusText: '正常',
            plate: 'XXXX',
            plateCode: null,
            plateGoodsCode: null,
            plateThickness: '6',
            powderWeight: 1.0,
            printing: false,
            prodline: null,
            productType: 'XXX',
            psId: null,
            reviewerMan: null,
            signMemo: null,
            sinTer: true,
            technician: null,
            tjtNum: null,
            tsbNum: null,
            tsdNum: null,
            updateMan: {
              accountId: 541,
              card: null,
              createTime: '2023-05-04',
              curStatus: 1,
              deleted: false,
              deptName: null,
              dimissionTime: null,
              factoryId: 102,
              head: 0,
              jobName: 'MES开发',
              keyValue: 541,
              ldapName: 'cdl',
              mail: null,
              mobile: null,
              pfDepartment: {
                appLink: null,
                createTime: '2022-08-31',
                deleted: false,
                deptCode: '001',
                deptId: 1,
                deptName: 'MES开发部',
                deptType: 1,
                deptTypeTitle: '厂',
                keyValue: 1,
                memo: null,
                orders: '00',
                parentDeptId: null,
                parentPath: null,
                ucDeptId: null,
                updateTime: '2022-08-31 16:32:46',
              },
              pinyinIndex: 'CUIDIANLONG,CDL',
              ucUserId: null,
              updateTime: '2023-05-04 09:16:54',
              userCode: 'cdl',
              userId: 541,
              userName: '崔殿龙',
              userSex: 1,
              userSources: '崔殿龙',
              userString: '541:A:崔殿龙',
              userType: 'A',
            },
            updateTime: '2023-10-21 09:43:33',
          },
          keepMan: {
            accountId: 541,
            card: null,
            createTime: '2023-05-04',
            curStatus: 1,
            deleted: false,
            deptName: null,
            dimissionTime: null,
            factoryId: 102,
            head: 0,
            jobName: 'MES开发',
            keyValue: 541,
            ldapName: 'cdl',
            mail: null,
            mobile: null,
            pfDepartment: {
              appLink: null,
              createTime: '2022-08-31',
              deleted: false,
              deptCode: '001',
              deptId: 1,
              deptName: 'MES开发部',
              deptType: 1,
              deptTypeTitle: '厂',
              keyValue: 1,
              memo: null,
              orders: '00',
              parentDeptId: null,
              parentPath: null,
              ucDeptId: null,
              updateTime: '2022-08-31 16:32:46',
            },
            pinyinIndex: 'CUIDIANLONG,CDL',
            ucUserId: null,
            updateTime: '2023-05-04 09:16:54',
            userCode: 'cdl',
            userId: 541,
            userName: '崔殿龙',
            userSex: 1,
            userSources: '崔殿龙',
            userString: '541:A:崔殿龙',
            userType: 'A',
          },
          keepTime: '2024-01-03 15:14:32',
          keyValue: 21,
          memo: '1213123',
          moldCode: null,
          partGc: '12',
          partYb: '31231214',
          smnId: 21,
        },
      ];
      this.page.total = this.data.length;
      this.loading = false;
      setTimeout(() => {
        this.selectionClear();
      }, 500);
    },
  },
};
</script>
<style lang="scss" scoped></style>
