<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" icon="el-icon-delete" @click="handleDelete"
        >删 除
      </el-button>
    </template>
    <template #menu-right>
      <el-button type="success" icon="el-icon-upload" @click="handleImport"
        >导入
      </el-button>
    </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: false,
        editBtnText: "修改",
        addBtnIcon: " ",
        viewBtnIcon: " ",
        delBtnIcon: " ",
        editBtnIcon: " ",
        viewBtnText: "详情",
        labelWidth: 120,
        menuWidth: 120,
        dialogWidth: 1040,
        dialogClickModal: false,
        searchEnter: true,
        excelBtn: false,
        filterBtn: true,
        searchShowBtn: false,
        columnSort: true,
        excelBtn: true,
        columnSort: true,
        index: false,
        showOverflowTooltip: true,
        searchLabelPosition: "left",
        searchLabelPosition: "left",
        searchGutter: 24,
        searchSpan: 6,
        menuAlign: "left",
        gridBtn: false,
        searchMenuPosition: "right",
        align: "center",
        column: [
          {
            label: "编码",
            prop: "btCode",
            sortable: true,
            filter: true,
            span: 12,
            search: true,
            rules: [
              {
                required: true,
                message: "请输入编码",
                trigger: "blur",
              },
            ],
          },
          {
            label: "名称",
            prop: "btName",
            search: true,
            sortable: true,
            filter: true,
            span: 12,
            rules: [
              {
                required: true,
                message: "请输入名称",
                trigger: "blur",
              },
            ],
          },
          {
            label: "药品名称",
            prop: "drug",
            search: false,
            sortable: true,
            filter: true,
            span: 12,
            rules: [
              {
                required: true,
                message: "请输入药品名称",
                trigger: "blur",
              },
            ],
          },
          {
            label: "报警阙值",
            prop: "threshold",
            search: true,
            sortable: true,
            filter: true,
            span: 12,
            rules: [
              {
                required: true,
                message: "请输入报警阙值",
                trigger: "blur",
              },
            ],
          },
          {
            label: "PH报警点位",
            prop: "phPoint",
            search: false,
            sortable: true,
            filter: true,
            span: 12,
            rules: [
              {
                required: true,
                message: "请输入PH报警点位",
                trigger: "blur",
              },
            ],
          },
          {
            label: "风机运行点位",
            prop: "fanRunPoint",
            search: false,
            sortable: true,
            filter: true,
            span: 12,
            rules: [
              {
                required: true,
                message: "请输入风机运行点位",
                trigger: "blur",
              },
            ],
          },
          {
            label: "风机报警点位",
            prop: "fanPoint",
            search: false,
            sortable: true,
            filter: true,
            span: 12,
          },
          {
            label: "循环泵报警点位",
            prop: "pumpPoint",
            search: false,
            sortable: true,
            filter: true,
            span: 12,
          },
        ],
      },
      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 = [
        {
          btCode: "s05",
          btId: 62,
          btName: "s05",
          drug: "药品5",
          fanPoint: "n",
          fanRunPoint: "mm",
          keyValue: 62,
          phPoint: "m",
          pumpPoint: "o",
          threshold: 18.0,
          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-07-03 09:08:47",
        },
        {
          btCode: "s04",
          btId: 61,
          btName: "s04",
          drug: "药品4",
          fanPoint: "k",
          fanRunPoint: "jj",
          keyValue: 61,
          phPoint: "j",
          pumpPoint: "l",
          threshold: 16.0,
          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-07-03 09:08:13",
        },
        {
          btCode: "s03",
          btId: 41,
          btName: "s03",
          drug: "药品03",
          fanPoint: "h",
          fanRunPoint: "gg",
          keyValue: 41,
          phPoint: "g",
          pumpPoint: "i",
          threshold: 14.0,
          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-07-03 09:06:33",
        },
        {
          btCode: "S02",
          btId: 8,
          btName: "S02",
          drug: "药品02",
          fanPoint: "e",
          fanRunPoint: "dd",
          keyValue: 8,
          phPoint: "d",
          pumpPoint: "f",
          threshold: 12.0,
          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-07-03 09:06:25",
        },
      ];
      this.page.total = this.data.length;
      this.loading = false;
      setTimeout(() => {
        this.selectionClear();
      }, 500);
    },
  },
};
</script>
<style lang="scss" scoped></style>
