Newer
Older
xc-business-system / src / views / business / taskMeasure / measureData / list.vue
dutingting on 24 Dec 29 KB bug修复
<!-- 实验室任务列表 -->
<script name="MeasureDataList" lang="ts" setup>
import { getCurrentInstance, ref } from 'vue'
import type { Ref } from 'vue'
import type { DateModelType } from 'element-plus'
import { ElLoading, ElMessage, ElMessageBox, dayjs } from 'element-plus'
import type { IList, IListQuery } from './measureData-interface'
import { keepSearchParams } from '@/utils/keepQuery'
import type { TableColumn } from '@/components/NormalTable/table_interface'
import { getDeviceNameList, getInfo as getMesureItemDetail, getModelAllList } from '@/api/business/measure/item'
import { exportFile } from '@/utils/exportUtils'
import useUserStore from '@/store/modules/user'
import { getDictByCode } from '@/api/system/dict'
import type { dictType } from '@/global'
import { getDeptTreeList } from '@/api/system/dept'
import { toTreeList } from '@/utils/structure'
import { deleteMeasureData, exportMeasureDataList, getLocationList, getInfo as getMeasureDataDetail, getMeasureDataList } from '@/api/business/taskMeasure/measureData'

const $router = useRouter()
const user = useUserStore() // 用户信息

onBeforeRouteLeave((to: any) => {
  keepSearchParams(to.path, 'MeasureDataList')
})
// 查询条件
const dateRangeCertificateValid = ref<[DateModelType, DateModelType]>(['', ''])
const timeRange = ref<[DateModelType, DateModelType]>(['', ''])
const listQuery: Ref<IListQuery> = ref({
  certificateFile: '', // 检定证书(minio存储文件名)
  conclusion: '', //	结论
  createUserName: '', //	检定员
  customerName: '', //	委托单位
  dataNo: '', //	检定数据编号
  helpInstruction: '', //	辅助字段
  manufactureNo: '', //	出厂编号
  measureAddress: '', //	测试、校准或检定地点
  measureCategory: '', //	检校类别
  measureValidDateEnd: '', //	检定有效期结束
  measureValidDateStart: '', //	检定有效期开始
  meterIdentify: '', //	计量标识
  model: '', //	规格型号
  restrictionInstruction: '', //	限用说明
  sampleName: '', //	受检设备名称
  traceDateStart: '', //	测试、校准或检定日期开始
  traceDateEnd: '', //	测试、校准或检定日期结束
  deptId: '', // 使用部门

  labCode: '', // 实验室
  groupCode: '', // 部门
  offset: 1,
  limit: 20,
})
const operateWidth = ref('150') // 操作栏的宽度

const columns = ref<TableColumn[]>([ // 表头
  { text: '数据来源', value: 'dataSource', width: '160', align: 'center' },
  { text: '检定数据编号', value: 'dataNo', width: '160', align: 'center' },
  { text: '委托单位', value: 'customerName', align: 'center' },
  { text: '使用部门', value: 'deptName', align: 'center', width: '120' },
  { text: '检定日期', value: 'traceDate', align: 'center', width: '120' },
  { text: '检定地点', value: 'measureAddress', align: 'center' },
  { text: '受检设备名称', value: 'sampleName', align: 'center' },
  { text: '规格型号', value: 'model', align: 'center' },
  { text: '出厂编号', value: 'manufactureNo', align: 'center' },
  { text: '辅助字段', value: 'helpInstruction', align: 'center' },
  { text: '标准设备型号', value: 'equipmentModelStr', align: 'center' },
  { text: '标准设备编号', value: 'equipmentManufactureNoStr', align: 'center' },
  { text: '检定员', value: 'createUserName', align: 'center', width: '120' },
  { text: '实验室', value: 'labCodeName', align: 'center', width: '120' },
  { text: '部门', value: 'groupCodeName', align: 'center', width: '120' },
  { text: '检校类别', value: 'measureCategoryName', align: 'center', width: '120' },
  { text: '检定结论', value: 'conclusion', align: 'center', width: '120' },
  { text: '限用说明', value: 'restrictionInstruction', align: 'center', width: '120' },
  { text: '检定有效期', value: 'measureValidDate', align: 'center', width: '120' },
  { text: '计量标识', value: 'meterIdentify', align: 'center', width: '120' },
  { text: '检定证书', value: 'fileArr', align: 'center', width: '240', followLink: true },
  { text: '设备检定项分类', value: 'itemCategoryName', align: 'center' },

  // { text: '所使用的测量标准及配套设备名称', value: 'equipmentNameStr', align: 'center' },
  // { text: '所使用的测量标准及配套设备型号', value: 'equipmentModelStr', align: 'center' },
  // { text: '所使用的测量标准及配套设备编号', value: 'equipmentManufactureNoStr', align: 'center' },
])
const list = ref<IList[]>([]) // 表格数据
const total = ref(0) // 总数
const loadingTable = ref(false) // 表格加载状态
const checkoutList = ref<IList[]>([]) // 选中的内容
const checkoutListAllContent = ref<IList[]>([]) // 选中的内容
// --------------------------------------------字典--------------------------------------
const deviceNameList = ref<string[]>([]) // 设备名称
const modelList = ref<any[]>([])// 规格型号
const helpList = ref<any[]>([])// 辅助字段
const allList = ref<any[]>([])
const positionList = ref([]) as any // 测试、校准或检定地点
const measureCategoryList = ref<dictType[]>([])// 检校类别
const conclusionList = ref({}) as any // 检定结论
const meterIdentifyDict = ref({}) as any // 计量标识
const useDeptList = ref([]) as any // 使用部门
const labCodeList = ref<dictType[]>([]) // 实验室
const groupCodeList = ref<dictType[]>([]) // 部门

async function getDict() {
  // 设备名称
  getDeviceNameList().then((res) => {
    deviceNameList.value = res.data.map((item: any) => {
      return {
        value: item,
      }
    })
  })
  // 计量标识
  getDictByCode('eqptMeterIdentify').then((response) => {
    meterIdentifyDict.value = response.data
  })
  // 规格型号及辅助字段
  getModelAllList({}).then((res) => {
    allList.value = res.data
    modelList.value = Array.from(new Set(res.data.filter((item: any) => item.model).map((item: any) => item.model)))
    modelList.value = modelList.value.map((item) => {
      return {
        value: item,
      }
    })
    helpList.value = Array.from(new Set(res.data.filter((item: any) => item.helpInstruction).map((item: any) => item.helpInstruction)))
    helpList.value = helpList.value.map((item) => {
      return {
        value: item,
      }
    })
  })

  // 测试、校准或检定地点
  getLocationList({
    locationName: '', // 地点名称
    locationNo: '', // 地点编号
    labName: user.bizLabCode === 'H' ? '海口实验室' : user.bizLabCode === 'X' ? '西昌实验室' : '',
    limit: 999999,
    offset: 1,
  }).then((res) => {
    positionList.value = res.data.rows.map((item: { id: string; locationName: string; temperature: string; humidity: string }) => {
      return {
        id: item.id,
        name: item.locationName, // 地点名称
        temperature: `${item.temperature}` || '', // 温度
        humidity: `${item.humidity}` || '', // 湿度
      }
    })
  })

  // 检校类别
  getDictByCode('measureCategory').then((response) => {
    measureCategoryList.value = response.data
  })

  // 检定结论
  getDictByCode('bizConclusion').then((response) => {
    conclusionList.value = response.data
  })

  // 获取部门列表
  getDeptTreeList().then((res) => {
    // 转成树结构
    useDeptList.value = toTreeList(res.data, '0', true)
  })

  // 实验室
  getDictByCode('bizGroupCodeEquipment').then((response) => {
    labCodeList.value = response.data
  })

  // 部门
  getDictByCode('bizGroupCode').then((response) => {
    groupCodeList.value = response.data
  })
}

// -----------------------------------------表格数据--------------------------------------------

// 数据查询
function fetchData(isNowPage = false) {
  loadingTable.value = true
  if (!isNowPage) {
    // 是否显示当前页,否则跳转第一页
    listQuery.value.offset = 1
  }
  // listQuery.value.labCode = user.bizLabCode // 实验室
  // listQuery.value.groupCode = user.groupNo === 'GL' ? '' : user.groupNo // 部门
  getMeasureDataList(listQuery.value).then((res) => {
    list.value = res.data.rows.map((item: any) => {
      return {
        ...item,
        measureValidDate: dayjs(item.measureValidDate).format('YYYY-MM-DD'),
        followLinkArr: item.certificateFile ? [item.certificateFile] : item.dataSource === '康斯特自动检定系统' ? [`${item.sampleName}${item.model}${item.manufactureNo}康斯特证书`] : item.constCertificateExcelData ? [item.constCertificateExcelData] : '',
        labCodeName: item.labCodeName === '西昌' || item.labCodeName === '海口' ? `${item.labCodeName}实验室` : item.labCodeName,
      }
    })
    total.value = res.data.total
    loadingTable.value = false
  })
}

// 多选发生改变时
function handleSelectionChange(e: any) {
  checkoutList.value = e.map((item: { id: string }) => item.id)
  checkoutListAllContent.value = e
}

// 点击搜索
const searchList = () => {
  fetchData(true)
}
// 点击重置
const clearList = () => {
  listQuery.value = {
    certificateFile: '', // 检定证书(minio存储文件名)
    conclusion: '', //	结论
    createUserName: '', //	检定员
    customerName: '', //	委托单位
    dataNo: '', //	检定数据编号
    helpInstruction: '', //	辅助字段
    manufactureNo: '', //	出厂编号
    measureAddress: '', //	测试、校准或检定地点
    measureCategory: '', //	检校类别
    measureValidDateEnd: '', //	检定有效期结束
    measureValidDateStart: '', //	检定有效期开始
    meterIdentify: '', //	计量标识
    model: '', //	规格型号
    restrictionInstruction: '', //	限用说明
    sampleName: '', //	受检设备名称
    traceDateStart: '', //	测试、校准或检定日期开始
    traceDateEnd: '', //	测试、校准或检定日期结束
    deptId: '', // 使用部门

    labCode: '', // 实验室
    groupCode: '', // 部门
    offset: 1,
    limit: 20,
  }
  timeRange.value = ['', '']
  dateRangeCertificateValid.value = ['', '']
  fetchData(false)
}

// 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写
const changePage = (val: { size?: number; page?: number }) => {
  if (val && val.size) {
    listQuery.value.limit = val.size
  }
  if (val && val.page) {
    listQuery.value.offset = val.page
  }
  fetchData(true)
}

// --------------------------------------操作------------------------------------------------
// 操作
const handleEdit = (row: any, val: 'detail' | 'edit' | 'delete') => {
  if (val === 'delete') {
    ElMessageBox.confirm(
      '确认删除吗?删除操作不可逆!',
      '提示',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      },
    )
      .then(() => {
        deleteMeasureData({ id: row.id }).then(() => {
          ElMessage({
            type: 'success',
            message: '删除成功',
          })
          fetchData(true)
        })
      })
  }
  else if (val === 'detail') {
    if (row.dataSource === '康斯特自动检定系统') {
      $router.push({
        path: `measureDataConst/detail/${row.id}`,
        query: {
          dataSource: row.dataSource,	// 数据来源(若来源于“康斯特自动检定系统”,该参数必传)
          itemId: row.itemId,	//	设备检定项表id
          orderId: row.orderId,	//	任务单id
          sampleId: row.sampleId,	//	受检设备id
        },
      })
    }
    else {
      $router.push({
        path: `measureData/${val}/${row.id}`,
        query: {
          ...row,
        },
      })
    }
  }
  else { // edit
    const loading = ElLoading.service({
      lock: true,
      background: 'rgba(255, 255, 255, 0.8)',
    })
    // 此处逻辑去查看readme理解
    let itemTime = ''
    // 先获取检定项的更新时间
    const params = {
      id: row.itemId,
      itemCategoryName: row.itemCategoryName, // 检定项分类名字
      belongStandardEquipment: row.belongStandardEquipment, // 检校标准装置字典code
    }
    getMesureItemDetail(params).then((res) => {
      itemTime = res.data.updateTime
      // 检定项更新时间 > 检定数据更新时间,说明检定项有变
      console.log('检定项更新时间', itemTime)
      console.log('检定项数据时间', row.updateTime)
      if (itemTime && dayjs(itemTime).valueOf() > dayjs(row.updateTime).valueOf()) {
        ElMessageBox.confirm(
          '发现检定项发生变化,是否更新检定项?',
          '提示',
          {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning',
          },
        )
          .then(() => {
            // 先去缓存检定项之外的数据
            getMeasureDataDetail({
              id: row.id,
              belongStandardEquipment: row.belongStandardEquipment, // 检校标准装置
              // 我的任务跳转过来如果已经配置过检定项了,到编辑页面,且用一下三个字段替代传id请求详情
              itemId: row.itemId, // 检定项id
              orderId: row.orderId, // 任务单id
              sampleId: row.sampleId, // 被检设备id
            }).then((res) => {
              const cacheForm = {
                orderId: res.data.orderId, // 任务单id
                orderNo: res.data.orderNo, // 任务单编号
                name: res.data.createUserName, // 检定员
                itemId: res.data.itemId, // 检定项id
                itemCategoryId: row.itemCategoryId, // 检定项分类id
                itemCategoryName: row.itemCategoryName, // 检定项分类名称
                belongStandardEquipment: row.belongStandardEquipment, // 检校标准装置Code
                belongStandardEquipmentName: row.belongStandardEquipmentName, // 检校标准装置名称
                customerName: res.data.customerName, // 委托单位
                helpFieldInstruction: res.data.helpFieldInstruction, // 辅助字段说明
                helpInstruction: res.data.helpInstruction, // 辅助字段
                sampleId: res.data.sampleId, // 设备id
                sampleName: res.data.sampleName, // 设备名称
                sampleModel: res.data.model, // 规格型号
                manufactureNo: res.data.manufactureNo, // 出厂编号
                manufacturer: res.data.manufacturer, // 制造厂家(生产厂家)
                // form.value.measureValidDate = `${dayjs().add(Number($route.query.checkCycle), 'month').subtract(1, 'day')}`
                // 检定周期 = 检定有效期--今天 + 检定周期 - 1天
                checkCycle: dayjs(res.data.measureValidDate).diff(dayjs(), 'month') + 1, // 检定周期
              }

              // 先删除检定数据,再走新建
              deleteMeasureData({ id: row.id }).then(() => {
                $router.push({
                  path: 'measureData/add',
                  query: {
                    ...cacheForm,
                  },
                })
              })
            })
          })
      }
      else { // 检定项没变化
        $router.push({
          path: `measureData/${val}/${row.id}`,
          query: {
            ...row,
          },
        })
      }

      loading.close()
    }).catch(() => {
      loading.close()
    })
  }
}

// --------------------------------------按钮(导出)--------------------------------------------------------
// 导出
const exportAll = () => {
  const loading = ElLoading.service({
    lock: true,
    text: '下载中请稍后',
    background: 'rgba(255, 255, 255, 0.8)',
  })
  if (list.value.length > 0) {
    const param = {
      deptId: listQuery.value.deptId, // 使用部门
      certificateFile: listQuery.value.certificateFile, // 检定证书(minio存储文件名)
      conclusion: listQuery.value.conclusion, //	结论
      createUserName: listQuery.value.createUserName, //	检定员
      customerName: listQuery.value.customerName, //	委托单位
      dataNo: listQuery.value.dataNo, //	检定数据编号
      helpInstruction: listQuery.value.helpInstruction, //	辅助字段
      manufactureNo: listQuery.value.manufactureNo, //	出厂编号
      measureAddress: listQuery.value.measureAddress, //	测试、校准或检定地点
      measureCategory: listQuery.value.measureCategory, //	检校类别
      measureValidDateEnd: listQuery.value.measureValidDateEnd, //	检定有效期结束
      measureValidDateStart: listQuery.value.measureValidDateStart, //	检定有效期开始
      meterIdentify: listQuery.value.meterIdentify, //	计量标识
      model: listQuery.value.model, //	规格型号
      restrictionInstruction: listQuery.value.restrictionInstruction, //	限用说明
      sampleName: listQuery.value.sampleName, //	受检设备名称
      traceDateStart: listQuery.value.traceDateStart, //	测试、校准或检定日期开始
      traceDateEnd: listQuery.value.traceDateEnd, //	测试、校准或检定日期结束

      labCode: listQuery.value.labCode, // 实验室
      groupCode: listQuery.value.groupCode, // 部门
      offset: 1,
      limit: 20,
      ids: checkoutList.value,
    }
    exportMeasureDataList(param).then((res) => {
      exportFile(res.data, '检定数据管理')
      loading.close()
    })
      .catch((_) => {
        loading.close()
      })
  }
  else {
    loading.close()
    ElMessage.warning('无数据可导出数据')
  }
}

// --------------------------------------点击批量编辑------------------------------------------------
const batchEdit = () => {
  if (!checkoutListAllContent.value.length) {
    ElMessage.warning('请先选择需要编辑的数据')
    return false
  }
  if (checkoutListAllContent.value.length > 4) {
    ElMessage.warning('最多可编辑4个')
    return false
  }
  if (!checkoutListAllContent.value.every((item: any) => item.itemCategoryId === checkoutListAllContent.value[0].itemCategoryId)) {
    ElMessage.warning('只允许配置同一个检定项的数据')
    return false
  }
  if (!checkoutListAllContent.value.every((item: any) => item.belongStandardEquipment === '4')) {
    ElMessage.warning('仅0.02级活塞式压力计支持批量编辑')
    return false
  }
  // if (!checkoutListAllContent.value.every((item: any) => item.belongStandardEquipment === checkoutListAllContent.value[0].belongStandardEquipment)) {
  //   ElMessage.warning('只允许配置同一套标准装置')
  //   return false
  // }
  const notCompliantIndex = checkoutListAllContent.value.findIndex((item: any) => (item.certificateId || item.dataSource === '自动检定系统'))
  if (notCompliantIndex !== -1) {
    ElMessage.warning(`第${notCompliantIndex + 1}项不满足编辑条件(已生成证书或数据来源于自动检定系统)`)
    return false
  }

  const dataSourceIndex = checkoutListAllContent.value.findIndex((item: any) => (item.dataSource === '康斯特自动检定系统'))
  if (dataSourceIndex !== -1) {
    ElMessage.warning(`第${dataSourceIndex + 1}项不满足编辑条件(数据来源于康斯特自动检定系统)`)
    return false
  }
  $router.push({
    path: 'measureData/batchEdit',
    query: {
      batchEdit: 'true',
      batchEditRow: JSON.stringify(checkoutListAllContent.value),
      belongStandardEquipment: checkoutListAllContent.value[0].belongStandardEquipment,
    },
  })
}

// 点击证书
const handleClickFollowLink = (row: any, title: string) => {
  $router.push({
    path: `/businessCertificate/detail/${row.certificateId}`,
    query: {
      approvalStatusName: '全部', // 审批状态名称
      sampleName: row.sampleName, // 被检设备名称
      model: row.model, // 规格型号
      manufacturingNo: row.manufactureNo, // 出厂编号
      measureDataId: row.id, // 检定数据id
      isFromCertificateList: 'false',
    },
  })
}

// ---------------------------------------钩子-------------------------------------------------------
// 匹配设备名称输入建议
const querySearchDeviceName = (queryString: string, cb: any) => {
  const results = queryString ? deviceNameList.value.filter((item: any) => item.value.includes(queryString)) : deviceNameList.value
  // 调用 callback 返回建议列表的数据
  cb(results)
}

// 匹配型号规格输入建议
const querySearchDeviceModel = (queryString: string, cb: any) => {
  const results = queryString ? modelList.value.filter((item: any) => item.value.includes(queryString)) : modelList.value
  // 调用 callback 返回建议列表的数据
  cb(results)
}

// 匹配辅助字段输入建议
const querySearchHelpInstruction = (queryString: string, cb: any) => {
  const results = queryString ? helpList.value.filter((item: any) => item.value.includes(queryString)) : helpList.value
  // 调用 callback 返回建议列表的数据
  cb(results)
}

watch(timeRange, (val) => { // 监听检定日期变化
  if (val) {
    listQuery.value.traceDateStart = `${val[0]}`
    listQuery.value.traceDateEnd = `${val[1]}`
  }
  else {
    listQuery.value.traceDateStart = ''
    listQuery.value.traceDateEnd = ''
  }
})

// 证书有效期
watch(dateRangeCertificateValid, (val) => { // 检定有效期变化
  if (val) {
    listQuery.value.measureValidDateStart = `${val[0]}`
    listQuery.value.measureValidDateEnd = `${val[1]}`
  }
  else {
    listQuery.value.measureValidDateStart = ''
    listQuery.value.measureValidDateEnd = ''
  }
})

onMounted(async () => {
  listQuery.value.labCode = user.bizLabCode // 实验室
  listQuery.value.groupCode = user.groupNo === 'GL' ? '' : user.groupNo // 部门

  getDict().then(() => {
    fetchData(true)
  })
})

onActivated(() => {
  // 从编辑或者新增页面回来需要重新获取列表数据
  // $router.options.history.state.forward 上一次路由地址
  if (!($router.options.history.state.forward as string || '').includes('detail')) {
    console.log('需要重新获取列表')
    fetchData(false)
  }
})
</script>

<template>
  <app-container>
    <search-area
      :need-clear="true"
      @search="searchList" @clear="clearList"
    >
      <search-item>
        <el-input v-model.trim="listQuery.dataNo" placeholder="检定数据编号" class="short-input" clearable />
      </search-item>
      <search-item>
        <el-input v-model.trim="listQuery.customerName" placeholder="委托单位" class="short-input" clearable />
      </search-item>
      <search-item>
        <dept-select
          v-model="listQuery.deptId"
          :data="useDeptList"
          placeholder="使用部门"
          style="width: 220px;"
        />
      </search-item>
      <search-item>
        <el-date-picker
          v-model="timeRange"
          type="daterange"
          range-separator="至"
          format="YYYY-MM-DD"
          value-format="YYYY-MM-DD"
          start-placeholder="检定日期(开始)"
          end-placeholder="检定日期(结束)"
          style="width: 480px;"
        />
      </search-item>
      <search-item>
        <el-input v-model.trim="listQuery.measureAddress" placeholder="检定地点" clearable />
      </search-item>
      <search-item>
        <el-autocomplete
          v-model="listQuery.sampleName"
          :fetch-suggestions="querySearchDeviceName"
          placeholder="设备名称"
          clearable
        />
      </search-item>
      <search-item>
        <el-autocomplete
          v-model="listQuery.model"
          :fetch-suggestions="querySearchDeviceModel"
          placeholder="规格型号"
          clearable
        />
      </search-item>

      <search-item>
        <el-input v-model.trim="listQuery.manufactureNo" placeholder="出厂编号" class="short-input" clearable />
      </search-item>
      <search-item>
        <el-autocomplete
          v-model="listQuery.helpInstruction"
          :fetch-suggestions="querySearchHelpInstruction"
          placeholder="辅助字段"
          clearable
        />
      </search-item>
      <!-- <search-item>
        <el-input v-model.trim="listQuery.helpInstruction" placeholder="辅助字段" class="short-input" clearable />
      </search-item> -->
      <!-- <search-item>
        <el-input v-model.trim="listQuery.equipmentModelStr" placeholder="标准设备型号" class="short-input" clearable />
      </search-item>
      <search-item>
        <el-input v-model.trim="listQuery.equipmentManufactureNoStr" placeholder="标准设备编号" class="short-input" clearable />
      </search-item> -->
      <search-item>
        <el-input v-model.trim="listQuery.createUserName" placeholder="检定员" class="short-input" clearable />
      </search-item>
      <search-item>
        <el-select
          v-model="listQuery.labCode"
          placeholder="实验室"
          class="short-input"
          filterable
          clearable
        >
          <el-option v-for="item in labCodeList" :key="item.id" :label="item.name" :value="item.value" />
        </el-select>
      </search-item>
      <search-item>
        <el-select
          v-model="listQuery.groupCode"
          placeholder="部门"
          class="short-input"
          filterable
          clearable
        >
          <el-option v-for="item in groupCodeList" :key="item.id" :label="item.name" :value="item.value" />
        </el-select>
      </search-item>
      <search-item>
        <el-select
          v-model="listQuery.measureCategory"
          placeholder="检校类别"
          filterable
          clearable
          class="short-input"
        >
          <el-option v-for="item in measureCategoryList" :key="item.id" :label="item.name" :value="item.value" />
        </el-select>
      </search-item>
      <search-item>
        <el-select
          v-model="listQuery.conclusion"
          placeholder="检定结论"
          filterable
          clearable
          class="short-input"
        >
          <el-option v-for="item in conclusionList" :key="item.id" :label="item.name" :value="item.name" />
        </el-select>
      </search-item>
      <search-item>
        <el-input
          v-model.trim="listQuery.restrictionInstruction"
          placeholder="限用说明"
          class="short-input"
          clearable
        />
      </search-item>
      <search-item>
        <el-date-picker
          v-model="dateRangeCertificateValid"
          type="daterange"
          range-separator="至"
          format="YYYY-MM-DD"
          value-format="YYYY-MM-DD"
          start-placeholder="检定有效期(开始)"
          end-placeholder="检定有效期(结束)"
          class="short-input"
        />
      </search-item>
      <search-item>
        <el-select
          v-model="listQuery.meterIdentify"
          class="short-input"
          placeholder="计量标识"
          clearable
        >
          <el-option v-for="item of meterIdentifyDict" :key="item.value" :label="item.name" :value="item.name" />
        </el-select>
      </search-item>
      <search-item>
        <el-input v-model.trim="listQuery.certificateFile" placeholder="检定证书" class="short-input" clearable />
      </search-item>
    </search-area>
    <table-container>
      <template #btns-right>
        <!-- <icon-button icon="icon-rfid" title="扫描检完" type="primary" @click="batchOverScan" /> -->
        <icon-button icon="icon-edit" title="批量编辑" @click="batchEdit" />
        <icon-button icon="icon-export" title="导出" @click="exportAll" />
      </template>
      <normal-table
        :data="list" :total="total" :columns="columns" :query="listQuery"
        :list-loading="loadingTable" is-showmulti-select @change="changePage" @multi-select="handleSelectionChange"
        @handle-click-follow-link="handleClickFollowLink"
      >
        <template #preColumns>
          <el-table-column label="序号" width="55" align="center">
            <template #default="scope">
              {{ (listQuery.offset - 1) * listQuery.limit + scope.$index + 1 }}
            </template>
          </el-table-column>
        </template>
        <template #columns>
          <el-table-column
            label="操作"
            align="center"
            fixed="right"
            :width="operateWidth"
          >
            <template #default="{ row }">
              <el-button
                size="small"
                type="primary"
                link
                @click="handleEdit(row, 'detail')"
              >
                详情
              </el-button>
              <!-- 没有证书id展示编辑按钮 -->
              <el-button
                v-if="!row.certificateId && row.dataSource !== '自动检定系统' && row.dataSource !== '康斯特自动检定系统' && row.createUserId === user.id"
                size="small"
                link
                type="primary"
                @click="handleEdit(row, 'edit')"
              >
                编辑
              </el-button>
              <el-button
                v-if="!row.certificateId && row.dataSource !== '自动检定系统' && row.dataSource !== '康斯特自动检定系统' && row.createUserId === user.id"
                size="small"
                link
                type="danger"
                @click="handleEdit(row, 'delete')"
              >
                删除
              </el-button>
            </template>
          </el-table-column>
        </template>
      </normal-table>
      <!-- 退回弹窗 -->
      <rollback-dialog ref="rollbackRef" @on-success="fetchData(true)" />
      <!-- 任务分发弹窗 -->
      <distribute-dialog ref="distributeDialogRef" @close="fetchData(true)" />
    </table-container>
  </app-container>
</template>

<style lang="scss" scoped>
.short-input {
  width: 160px;
}
</style>