<!-- 选择智能模型(选择的是任务分发待分发的智能模型) --> <script lang="ts" setup name="SelectEquipmentDialog"> import { ElMessage } from 'element-plus' import type { Ref } from 'vue' import { ref } from 'vue' import dayjs from 'dayjs' import type { DateModelType } from 'element-plus' import { getTaskList } from '@/api/business/manager/task' import type { TableColumn } from '@/components/NormalTable/table_interface' import { getReceivedEquipmentList } from '@/api/business/manager/order' const emits = defineEmits(['confirm']) const dialogFormVisible = ref(false) // 控制对话框显隐 const isMulti = ref(false)// 表格是否多选 // 查询条件 const listQuery = ref({ sampleNo: '', // 样品编号 sampleName: '', // 样品名称 orderNo: '', // 委托书编号 customerNo: '', // 委托方代码 customerName: '', // 委托方名称 isUrgent: '', // 是否加急 sampleBelong: '', // 样品属性 startTime: '', // 应检完时间-开始 endTime: '', // 应检完时间-结束 sampleStatus: '2', // 样品状态:默认待分发 offset: 1, limit: 20, }) const timeRange = ref<[DateModelType, DateModelType]>(['', ''])// 筛选时间段数据 const checkoutList = ref([]) // 多选选中的内容 const loadingTable = ref(false) // 表格loading const list = ref([]) as any // 表格数据 const total = ref(0) // 数组总数 const columns = ref<TableColumn[]>([ // { text: '统一编号', value: 'sampleNo', width: '160', align: 'center' }, { text: '受检智能模型名称', value: 'sampleName', align: 'center' }, { text: '规格型号', value: 'sampleModel', align: 'center' }, { text: '出厂编号', value: 'manufactureNo', align: 'center' }, { text: '厂商', value: 'manufacturer', align: 'center' }, { text: '辅助字段', value: 'helpInstruction', align: 'center' }, { text: '任务单编号', value: 'orderNo', align: 'center', width: '160' }, { text: '要求检完时间', value: 'requireOverTime', align: 'center', width: '180' }, { text: '是否加急', value: 'isUrgentName', align: 'center', width: '55', styleFilter: (row: { isUrgentName: string }) => { return row.isUrgentName == '是' ? 'color: red' : '' } }, { text: '当前检定环节', value: 'currentSegment', align: 'center' }, { text: '证书出具', value: 'certificationState', align: 'center', width: '90' }, ]) // 数据查询 function fetchData(isNowPage = false) { // listQuery.value.limit = isMulti.value ? 20 : 5 loadingTable.value = true if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQuery.value.offset = 1 } getTaskList(listQuery.value).then((response) => { list.value = response.data.rows.map((item: { certificationState: string; isUrgentName: string; isUrgent: number; alreadyCertifications: number; requireCertifications: number }) => { item.isUrgentName = item.isUrgent == 1 ? '是' : '否' item.certificationState = `${item.alreadyCertifications}/${item.requireCertifications}` return item }) total.value = response.data.total loadingTable.value = false }) } // 重置 const clearList = () => { listQuery.value = { sampleNo: '', // 样品编号 sampleName: '', // 样品名称 orderNo: '', // 委托书编号 customerNo: '', // 委托方代码 customerName: '', // 委托方名称 isUrgent: '', // 是否加急 sampleBelong: '', // 样品属性 startTime: '', // 应检完时间-开始 endTime: '', // 应检完时间-结束 sampleStatus: '2', // 样品状态:默认待分发 offset: 1, limit: 20, } timeRange.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() } /** * 初始化 * @param isMultiParam 是否多选 * @param getCustomerId 委托方id */ const initDialog = (isMultiParam: boolean, getCustomerId: string) => { isMulti.value = isMultiParam // 是否多选 dialogFormVisible.value = true // 显示对话框 fetchData() } // ----------------------------------------------钩子------------------------------------------------------ watch(timeRange, (val: any) => { // 监听时间变化 if (val) { listQuery.value.startTime = val[0] listQuery.value.endTime = val[1] } else { listQuery.value.startTime = '' listQuery.value.endTime = '' } }) 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.sampleNo" placeholder="统一编号" class="short-input" clearable /> </search-item> --> <search-item> <el-input v-model.trim="listQuery.sampleName" placeholder="受检智能模型名称" clearable class="short-input" /> </search-item> <search-item> <el-input v-model.trim="listQuery.customerName" placeholder="委托方" class="short-input" clearable /> </search-item> <search-item> <el-input v-model.trim="listQuery.orderNo" placeholder="任务单编号" clearable class="short-input" /> </search-item> <search-item> <el-date-picker v-model="timeRange" type="datetimerange" range-separator="至" format="YYYY-MM-DD HH:mm:ss" value-format="YYYY-MM-DD HH:mm:ss" start-placeholder="要求检完时间(开始)" end-placeholder="要求检完时间(结束)" /> </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="320" @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>