<!-- 选择受检设备 --> <script lang="ts" setup name="SelectEquipment"> import { ElMessage } from 'element-plus' import { ref } from 'vue' import dayjs from 'dayjs' import type { DateModelType } from 'element-plus' import type { TableColumn } from '@/components/NormalTable/table_interface' import { getTestEquipmentList } from '@/api/resource/testEquipment' import { getDictByCode } from '@/api/system/dict' import { getEquipmentList } from '@/api/equipment/info/book' import type { deptType } from '@/global' import { getAllUserList } from '@/api/system/user' const emits = defineEmits(['confirm']) const isMulti = ref(true) const dialogFormVisible = ref(false) // 查询条件 const listQuery = ref({ certificateValidEnd: '', // 证书有效期结束时间 certificateValidStart: '', // 证书有效期开始时间 customerId: '', // 委托方id equipmentName: '', // 设备名称 equipmentNo: '', // 统一编号 equipmentType: '', // 设备类型(1受检设备;2特种设备) manufactureNo: '', // 出厂编号 model: '', // 型号‘ customerName: '', // 委托方名称 offset: 1, limit: 20, }) // 多选选中的内容 const checkoutList = ref([]) // 选中 const dateRange = ref<[DateModelType, DateModelType]>(['', ''])// 筛选时间段数据 const loadingTable = ref(false) // loading const list = ref([]) // 表格数据 const total = ref(0) // 数据条数 const columns = ref<TableColumn[]>([ { text: '设备名称', value: 'equipmentName', align: 'center' }, { text: '委托方名称', value: 'customerName', align: 'center' }, { text: '设备型号', value: 'model', align: 'center' }, { text: '出厂编号', value: 'manufacturer', align: 'center' }, // { text: '专业分类', value: 'equipmentType', align: 'center' }, // { text: '业务类型', value: 'category', align: 'center', width: '120' }, { text: '检定校准时间', value: 'createTime', align: 'center', width: '180' }, { text: '备注', value: 'remark', align: 'center' }, ]) // ------------------------------------------------------------------------------------------------------- // 数据查询 function fetchData(isNowPage = false) { loadingTable.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.value.offset = 1 } getTestEquipmentList({ ...listQuery.value }).then((response) => { list.value = response.data.rows.map((item: { estimateSignDate: string; agreementAmount: number; certificateValid: string }) => { return { ...item, certificateValid: item.certificateValid ? dayjs(item.certificateValid).format('YYYY-MM-DD') : item.certificateValid, } }) total.value = parseInt(response.data.total) loadingTable.value = false }).catch(() => { loadingTable.value = false }) } // 重置 const clearList = () => { listQuery.value = { certificateValidEnd: '', // 证书有效期结束时间 certificateValidStart: '', // 证书有效期开始时间 customerId: '', // 委托方id equipmentName: '', // 设备名称 equipmentNo: '', // 统一编号 equipmentType: '', // 设备类型(1受检设备;2特种设备) manufactureNo: '', // 出厂编号 model: '', // 型号‘ customerName: '', // 委托方名称 offset: 1, limit: 20, } dateRange.value = ['', ''] fetchData() } // 搜索 const search = () => { fetchData(true) } // 多选选中 const handleSelectionChange = (val: any) => { checkoutList.value = val } // 页数发生变化后的操作,可能是页码变化,可能是每页容量变化,此函数必写 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 } search() } // 点击确定 const confirmSelect = () => { if (!checkoutList.value.length) { ElMessage.warning('请选中') } else { emits('confirm', checkoutList.value) dialogFormVisible.value = false } } // 取消 const resetForm = () => { dialogFormVisible.value = false clearList() } // -------------------------------------------------------------------------------------------- // 初始化 const initDialog = async (isMultiParam: boolean) => { isMulti.value = isMultiParam dialogFormVisible.value = true fetchData() } defineExpose({ initDialog }) </script> <template> <el-dialog v-if="dialogFormVisible" v-model="dialogFormVisible" title="选择受检设备" width="65%"> <!-- 筛选条件 --> <search-area :need-clear="true" @search="search" @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.customerName" placeholder="委托方名称" class="short-input" clearable /> </search-item> </search-area> <!-- 查询结果Table显示 --> <div style="padding: 12px;"> <normal-table :data="list" :total="total" :columns="columns" :query="listQuery" is-showmulti-select :list-loading="loadingTable" :is-multi="isMulti" :height="520" @change="changePage" @multi-select="handleSelectionChange" > <!-- 序号 --> <template #preColumns> <el-table-column label="#" width="55" align="center" fixed> <template #default="scope"> {{ (listQuery.offset - 1) * listQuery.limit + scope.$index + 1 }} </template> </el-table-column> </template> </normal-table> </div> <template #footer> <span class="dialog-footer"> <el-button type="primary" @click="confirmSelect">确认</el-button> <el-button @click="resetForm"> 取消 </el-button> </span> </template> </el-dialog> </template> <style lang="scss" scoped> :deep(.el-radio__label) { display: none; } </style>