<!-- 参照标准、工作标准和关键测量设备表列表页 --> <script name="EquipmentInfoTableList" lang="ts" setup> import { onMounted, ref, watch } from 'vue' import type { DateModelType } from 'element-plus' import { ElLoading, ElMessage } from 'element-plus' import dayjs from 'dayjs' import type { IList, IListQuery } from '../book/book-interface' import type { deptType, dictType } from '@/global' import type { TableColumn } from '@/components/NormalTable/table_interface' import { getDictByCode } from '@/api/system/dict' import { getDeptTreeList } from '@/api/system/dept' import { getStaffList } from '@/api/resource/register' import { toTreeList } from '@/utils/structure' import { exportFile } from '@/utils/exportUtils' import { SCHEDULE } from '@/utils/scheduleDict' import { exportEquipmentExcel, getEquipmentList, getStream } from '@/api/equipment/info/book' const $router = useRouter() const operateWidth = ref('90') // 操作栏的宽度 // 查询条件 const listQuery = ref({ approvalStatus: '0', // 审批状态类型code,导出接口不用传 groupCode: '', // 部门--后台定义用此字段筛选部门(刘翔) directorId: '', // 负责人id equipmentName: '', // 设备名称 equipmentNo: '', // 设备编号 formId: SCHEDULE.EQUIPMENT_BOOK_APPROVAL, // 表单id(流程定义对应的表单id,等价于业务id),导出接口不用传 labCode: '', // 实验室 labName: '', // 实验室名称 manufactureNo: '', // 出厂编号 measureValidDateStart: '', // 检定有效期开始 measureValidDateEnd: '', // 检定有效期结束 meterStandardName: '', // 所属标准装置名称 model: '', // 规格型号 manufacturer: '', // 生产厂家 partType: '1', // 参照标准、工作标准和关键测量设备表必传,固定值1 standardType: '', // 标准类型(字典code) traceCompany: '', // 溯源单位 offset: 1, limit: 20, }) const total = ref(0) // 数据条数 const loadingTable = ref(false) // 表格loading // 表头 const columns = ref<TableColumn[]>([ { text: '设备名称', value: 'equipmentName', align: 'center' }, { text: '规格型号', value: 'model', align: 'center' }, { text: '出厂编号', value: 'manufactureNo', align: 'center' }, { text: '生产厂家', value: 'manufacturer', align: 'center' }, { text: '实验室', value: 'labCodeName', align: 'center' }, { text: '部门', value: 'groupCodeName', align: 'center' }, { text: '设备单价(万元)', value: 'unitPrice', align: 'center' }, { text: '负责人', value: 'directorName', align: 'center', width: '120' }, { text: '使用状态', value: 'usageStatusName', align: 'center', width: '90' }, { text: '溯源单位', value: 'traceCompany', align: 'center' }, { text: '检定有效期', value: 'measureValidDate', align: 'center', width: '120' }, { text: '所属标准装置', value: 'meterStandardName', align: 'center', width: '120' }, ]) const list = ref<IList[]>([]) // 表格数据 const dateRange = ref<[DateModelType, DateModelType]>(['', ''])// 筛选时间段数据 const checkoutList = ref<string[]>([])// 选中的内容 // -----------------------------------------字典-------------------------------------------------------------- const useDeptList = ref<deptType[]>([]) // 所属部门列表 const userList = ref<{ [key: string]: string }[]>([]) // 用户列表 const labDeptList = ref<deptType[]>([]) // 实验室 // 查询字典 const getDict = async () => { // 获取用户列表 getStaffList({ offset: 1, limit: 999999 }).then((res: any) => { userList.value = res.data.rows }) // 实验室 getDictByCode('bizGroupCodeEquipment').then((response) => { labDeptList.value = response.data }) // 部门 getDictByCode('bizGroupCode').then((response) => { useDeptList.value = response.data }) } // ------------------------------------------------------------------------------------------------------- // 数据查询 function fetchData(isNowPage = false) { loadingTable.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.value.offset = 1 } getEquipmentList(listQuery.value).then((response) => { list.value = response.data.rows.map((item: { estimateSignDate: string; agreementAmount: number; measureValidDate: string }) => { return { ...item, measureValidDate: item.measureValidDate ? dayjs(item.measureValidDate).format('YYYY-MM-DD') : item.measureValidDate, } }) total.value = parseInt(response.data.total) loadingTable.value = false }).catch(() => { loadingTable.value = false }) } // 搜索 const searchList = () => { fetchData(true) } // 重置 const clearList = () => { listQuery.value = { approvalStatus: '0', // 审批状态类型code,导出接口不用传 groupCode: '', // 部门--后台定义用此字段筛选部门(刘翔) directorId: '', // 负责人id equipmentName: '', // 设备名称 equipmentNo: '', // 设备编号 formId: SCHEDULE.EQUIPMENT_BOOK_APPROVAL, // 表单id(流程定义对应的表单id,等价于业务id),导出接口不用传 labCode: '', // 实验室 labName: '', // 实验室名称 manufactureNo: '', // 出厂编号 measureValidDateStart: '', // 检定有效期开始 measureValidDateEnd: '', // 检定有效期结束 meterStandardName: '', // 所属标准装置名称 model: '', // 规格型号 manufacturer: '', // 生产厂家 partType: '1', // 参照标准、工作标准和关键测量设备表功能该参数传1(同时approvalStatus参数传0),其余情况不用传该参数 standardType: '', // 标准类型(字典code) traceCompany: '', // 溯源单位 offset: 1, limit: 20, } dateRange.value = ['', ''] fetchData(true) } // 多选发生改变时 function handleSelectionChange(e: any) { checkoutList.value = e.map((item: { id: string }) => item.id) } // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 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) } // -------------------------------------表格上方工具栏----------------------------------- // 导出word const exportWord = () => { // if (!checkoutList.value.length) { // ElMessage.warning('请先选中数据') // return false // } const loading = ElLoading.service({ lock: true, text: '加载中...', background: 'rgba(255, 255, 255, 0.6)', }) getStream({ ids: checkoutList.value, pdf: false, approvalStatus: listQuery.value.approvalStatus, // 审批状态类型code,导出接口不用传 groupCode: listQuery.value.groupCode, // 部门--后台定义用此字段筛选部门(刘翔) directorId: listQuery.value.directorId, // 负责人id equipmentName: listQuery.value.equipmentName, // 设备名称 equipmentNo: listQuery.value.equipmentNo, // 设备编号 formId: listQuery.value.formId, // 表单id(流程定义对应的表单id,等价于业务id),导出接口不用传 labCode: listQuery.value.labCode, // 实验室 labName: listQuery.value.labName, // 实验室名称 manufactureNo: listQuery.value.manufactureNo, // 出厂编号 measureValidDateStart: listQuery.value.measureValidDateStart, // 检定有效期开始 measureValidDateEnd: listQuery.value.measureValidDateEnd, // 检定有效期结束 meterStandardName: listQuery.value.meterStandardName, // 所属标准装置名称 model: listQuery.value.model, // 规格型号 manufacturer: listQuery.value.manufacturer, // 生产厂家 partType: listQuery.value.partType, // 参照标准、工作标准和关键测量设备表功能该参数传1(同时approvalStatus参数传0),其余情况不用传该参数 standardType: listQuery.value.standardType, // 标准类型(字典code) traceCompany: listQuery.value.traceCompany, // 溯源单位 }).then((res) => { exportFile(res.data, '参照标准、工作标准和关键测量设备表.doc') loading.close() }) } // 导出excel const exportExcel = () => { // 导出 const loading = ElLoading.service({ lock: true, text: '下载中请稍后', background: 'rgba(255, 255, 255, 0.8)', }) if (list.value.length > 0) { const params = { approvalStatus: listQuery.value.approvalStatus, // 审批状态类型code,导出接口不用传 groupCode: listQuery.value.groupCode, // 部门--后台定义用此字段筛选部门(刘翔) directorId: listQuery.value.directorId, // 负责人id equipmentName: listQuery.value.equipmentName, // 设备名称 equipmentNo: listQuery.value.equipmentNo, // 设备编号 formId: listQuery.value.formId, // 表单id(流程定义对应的表单id,等价于业务id),导出接口不用传 labCode: listQuery.value.labCode, // 实验室 labName: listQuery.value.labName, // 实验室名称 manufactureNo: listQuery.value.manufactureNo, // 出厂编号 measureValidDateStart: listQuery.value.measureValidDateStart, // 检定有效期开始 measureValidDateEnd: listQuery.value.measureValidDateEnd, // 检定有效期结束 meterStandardName: listQuery.value.meterStandardName, // 所属标准装置名称 model: listQuery.value.model, // 规格型号 manufacturer: listQuery.value.manufacturer, // 生产厂家 // partType: listQuery.value., // 参照标准、工作标准和关键测量设备表功能该参数传1(同时approvalStatus参数传0),其余情况不用传该参数 standardType: listQuery.value.standardType, // 标准类型(字典code) traceCompany: listQuery.value.traceCompany, // 溯源单位 usageStatus: listQuery.value.usageStatus, // 使用状态 offset: 1, limit: 20, ids: checkoutList.value, } exportEquipmentExcel(params).then((res) => { const blob = new Blob([res.data]) loading.close() exportFile(blob, '设备台账.xlsx') }) loading.close() } else { loading.close() ElMessage.warning('无数据可导出数据') } } // ----------------------------------------------操作--------------------------------------------------- const handleEdit = (row: IList, type: string) => { $router.push({ path: `/equipmentInfo/tableList/detail/${row.id}`, query: { approvalStatusName: '全部', equipmentNo: row.equipmentNo, // 设备编号 }, }) } // ----------------------------------------------钩子------------------------------------------------------ watch(dateRange, (val) => { if (val) { listQuery.value.measureValidDateStart = `${val[0]}` listQuery.value.measureValidDateEnd = `${val[1]}` } else { listQuery.value.measureValidDateStart = '' listQuery.value.measureValidDateEnd = '' } }) onMounted(async () => { await getDict() fetchData(true) }) </script> <template> <app-container> <search-area :need-clear="true" @search="searchList" @clear="clearList"> <search-item> <el-input v-model.trim="listQuery.equipmentName" placeholder="设备名称" class="short-input" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.model" placeholder="规格型号" class="short-input" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.manufactureNo" placeholder="出厂编号" class="short-input" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.manufacturer" 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 labDeptList" :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 useDeptList" :key="item.id" :label="item.name" :value="item.value" /> </el-select> </search-item> <search-item> <el-select v-model="listQuery.directorId" placeholder="负责人" class="short-input" filterable clearable > <el-option v-for="item in userList" :key="item.id" :label="item.staffName" :value="item.id" /> </el-select> </search-item> <search-item> <el-input v-model.trim="listQuery.traceCompany" placeholder="溯源单位" class="short-input" clearable /> </search-item> <search-item> <el-date-picker v-model="dateRange" class="short-input" type="daterange" range-separator="至" format="YYYY-MM-DD" value-format="YYYY-MM-DD" start-placeholder="检定有效期(开始)" end-placeholder="检定有效期(结束)" /> </search-item> <search-item> <el-input v-model.trim="listQuery.meterStandardName" placeholder="所属标准装置" class="short-input" clearable /> </search-item> </search-area> <table-container> <template #btns-right> <icon-button icon="icon-word" title="导出word" type="primary" @click="exportWord" /> <icon-button icon="icon-excel" title="导出excel" type="primary" @click="exportExcel" /> </template> <normal-table :data="list" :total="total" :columns="columns" :query="listQuery" :list-loading="loadingTable" is-showmulti-select @change="changePage" @multi-select="handleSelectionChange" > <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> </template> </el-table-column> </template> </normal-table> </table-container> </app-container> </template> <style lang="ts" scoped> </style>