<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>
        <el-button type="danger" @click="handleDelete">删除 </el-button>
      </template>
      <template #menu-right>
        <el-button type="primary" @click="handleImport">导入 </el-button>
      </template>
      <template #menu="scope"> </template>
    </avue-crud>
    <basic-import
      v-if="isShowImport"
      title="导入"
      :isShow="isShowImport"
      templateUrl="/blade-desk/QA/CycleTestItem/download-excel-template"
      templateName="试验项目模板.xlsx"
      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,
      loading: false,
      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: true,
        viewBtn: false,
        delBtn: true,
        addBtn: true,
        editBtnText: '修改',
        addBtnIcon: ' ',
        viewBtnIcon: ' ',
        delBtnIcon: ' ',
        editBtnIcon: ' ',
        viewBtnText: '详情',
        labelWidth: 120,
        menuWidth: 180,
        dialogWidth: 1040,
        dialogClickModal: false,
        searchEnter: true,
        excelBtn: false,
        filterBtn: true,
        searchShowBtn: false,
        columnSort: true,
        excelBtn: true,
        columnSort: true,
        index: false,
        showOverflowTooltip: true,
        gridBtn: false,
        searchMenuPosition: 'right',
        searchLabelPosition: 'left',
        searchLabelPosition: 'left',
        searchGutter: 24,
        searchSpan: 6,
        menuAlign: 'left',
        gridBtn: false,
        searchMenuPosition: 'right',
        addBtnIcon: ' ',
        viewBtnIcon: ' ',
        delBtnIcon: ' ',
        editBtnIcon: ' ',
        align: 'center',
        column: [
          {
            label: '作业中心',
            prop: 'bsWorkCenter.wcName',
            search: false,
            sortable: true,
            filter: true,
            span: 12,
            headerAlign: 'center',
            align: 'left',
          },
          {
            label: '产线',
            prop: 'bsWorkCenter.wcName',
            search: false,
            sortable: true,
            filter: true,
            span: 12,
            headerAlign: 'center',
            align: 'left',
          },
          {
            label: '确认名称',
            prop: 'condition',
            search: false,
            sortable: true,
            filter: true,
            span: 12,
            headerAlign: 'center',
            align: 'left',
          },
          {
            label: '确认编号',
            prop: 'condition',
            search: false,
            sortable: true,
            filter: true,
            span: 12,
            headerAlign: 'center',
            align: 'left',
          },
          {
            label: '确认到期日期',
            prop: 'lastTime',
            search: false,
            sortable: true,
            filter: true,
            span: 12,
            headerAlign: 'center',
            align: 'center',
          },
          {
            label: '提醒天数',
            prop: 'remDays',
            search: false,
            sortable: true,
            filter: true,
            span: 12,
            headerAlign: 'center',
            align: 'center',
          },
          {
            label: '工艺员',
            prop: 'proMan.userName',
            bind: 'proMan.userName',
            search: false,
            sortable: true,
            filter: true,
            span: 12,
            headerAlign: 'center',
            align: 'center',
          },
          {
            label: '备注',
            prop: 'memo',
            search: false,
            sortable: true,
            filter: true,
            span: 12,
            headerAlign: 'center',
            align: 'left',
          },
        ],
      },
      form: {},
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
    };
  },
  methods: {
    // 点击导入按钮
    handleImport() {
      this.isShowImport = true
    },
    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 = [];
      this.page.total = this.data.length;
      this.loading = false;
      setTimeout(() => {
        this.selectionClear();
      }, 500);
    },
  },
};
</script>
<style lang="scss" scoped></style>
