<!-- 选择设备的哪个检定项去配置检定数据 --> <script lang="ts" setup name="SelectItemDialog"> import { ElMessage } from 'element-plus' import type { Ref } from 'vue' import { ref } from 'vue' import type { TableColumn } from '@/components/NormalTable/table_interface' import { getDictByCode } from '@/api/system/dict' import { getMyMeasureList } from '@/api/business/manager/task' const props = defineProps({ isMulti: { // 是否多选 type: Boolean, default: false, // 默认单选 }, }) // 用户信息 const emits = defineEmits(['confirm']) const dialogFormVisible = ref(false) const checkoutList = ref([]) as any // 多选选中的内容 const loadingTable = ref(false) // 表格loading const list = ref([]) as any // 表格数据 const total = ref(0) const columns = ref<TableColumn[]>([ { text: '设备名称', value: 'deviceName', align: 'center' }, { text: '规格型号', value: 'model', align: 'center' }, { text: '辅助字段', value: 'helpInstruction', align: 'center' }, { text: '辅助字段说明', value: 'helpInstruction', align: 'center' }, { text: '设备分类', value: 'deviceTypeName', align: 'center' }, { text: '检校标准装置', value: 'belongStandardEquipmentName', align: 'center' }, { text: '设备检定项分类', value: 'itemCategoryName', align: 'center' }, { text: '检定项更新时间', value: 'updateTime', align: 'center', width: '180' }, { text: '自动检定系统数据是否同步', value: 'dataSyncStr', align: 'center' }, { text: '自动检定系统最新同步时间', value: 'updateTime', align: 'center', width: '180' }, ]) const equipmentConfigItemCategoryList = ref([]) as any // 点击编辑检定项的这条数据已经配置了几个检定项 const tableRef = ref() // -----------------------------------------字典-------------------------------------------------------------- const isSyncMap = ref({}) as any // 是否同步{1: 是} const isSyncList = ref({}) as any // 是否同步 // 查询字典 const getDict = async () => { // 是否同步 getDictByCode('bizBusinessMeasureIsSync').then((response) => { isSyncList.value = response.data response.data.forEach((item: any) => { isSyncMap.value[`${item.value}`] = item.name }) }) } // -------------------------------------------------------------------------------------------- // 多选选中 const handleSelectionChange = (val: any) => { checkoutList.value = val } // 点击确定 const confirmSelect = () => { if (!checkoutList.value.length) { ElMessage.warning('请选择设备检定项') } else { emits('confirm', checkoutList.value, list.value) dialogFormVisible.value = false } } // 取消 const resetForm = () => { dialogFormVisible.value = false } // 查点击编辑检定项的这条数据已经配置了几个检定项 const selectEquipmentConfigItemCategory = (getSampleId: string, getOrderId: string, getItemCategoryId: string, getItemCategoryName: string) => { const listQuery = { customerName: '', // 委托方名称 customerNo: '', // 委托方编号 helpInstruction: '', // 辅助字段 isUrgent: '', // 是否加急(1是0否null全部) manufactureNo: '', // 出厂编号 manufacturer: '', // 生产厂家 measureStatus: '3', // 检测状态(字典code,2:待检测,3:检测中,4:检测完成) model: '', // 规格型号 orderNo: '', // 任务单编号 sampleName: '', // 受检设备名称 sampleNo: '', // 样品编号 startTime: '', // 要求检完时间开始 endTime: '', // 要求检完时间结束 measureValidDateStart: '', // 检定有效期开始 measureValidDateEnd: '', // 检定有效期结束 meterIdentify: '', // 计量标识 traceDateStart: '', // 测试、校准或检定日期开始 traceDateEnd: '', // 测试、校准或检定日期结束 restrictionInstruction: '', // 限用说明 conclusion: '', // 结论 sampleId: getSampleId, // 设备id orderId: getOrderId, // 任务单id offset: 1, limit: 999999, } getMyMeasureList(listQuery).then((res) => { equipmentConfigItemCategoryList.value = res.data.rows equipmentConfigItemCategoryList.value = equipmentConfigItemCategoryList.value.map((item: { itemCategoryId: string }) => { return { ...item, radioDisabled: true, } }) // 把除了本条数据配置的检定项的其他已经生成检定数据的检定项给禁用 equipmentConfigItemCategoryList.value.forEach((i: { itemCategoryId: string }) => { const index = list.value.findIndex((item: { itemCategoryId: string }) => item.itemCategoryId && (item.itemCategoryId === i.itemCategoryId) && (i.itemCategoryId !== getItemCategoryId)) if (index !== -1) { list.value[index].radioDisabled = true } }) dialogFormVisible.value = true // 把本条数据配置的检定项标出来 const index = list.value.findIndex((item: { itemCategoryId: string }) => item.itemCategoryId && (item.itemCategoryId === getItemCategoryId)) if (index !== -1) { setTimeout(() => { tableRef.value.singleChecked = list.value[index].id checkoutList.value = [{ ...list.value[index] }] }) } }) } // 初始化 const initDialog = async (listParam: any, getSampleId: string, getOrderId: string, getItemCategoryId: string, getItemCategoryName: string, certificateId = '') => { getDict() list.value = listParam.map((item: { radioDisabled: boolean }) => { return { ...item, radioDisabled: false, certificateId, } }) selectEquipmentConfigItemCategory(getSampleId, getOrderId, getItemCategoryId, getItemCategoryName) } defineExpose({ initDialog }) </script> <template> <el-dialog v-if="dialogFormVisible" v-model="dialogFormVisible" title="选择设备检定项" width="65%"> <!-- 查询结果Table显示 --> <div style="padding: 12px;"> <normal-table ref="tableRef" :data="list" :total="total" :columns="columns" is-showmulti-select :list-loading="loadingTable" :is-multi="props.isMulti" :pagination="false" @multi-select="handleSelectionChange" > <!-- 序号 --> <template #preColumns> <el-table-column label="#" width="55" align="center" fixed> <template #default="scope"> {{ 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>