<!-- 核查项分类管理详情 --> <script lang="ts" setup name="checkDataDetail"> import { ref } from 'vue' import { ElLoading, ElMessage } from 'element-plus' import dayjs from 'dayjs' import type { IDetailCheckData, IEquipmentList, IForm } from './checkData-interface' import selectStandardEquipmentDialog from './dialog/selectStandardEquipmentDialog.vue' import type { TableColumn } from '@/components/NormalTable/table_interface' import useUserStore from '@/store/modules/user' import { getDictByCode } from '@/api/system/dict' import type { dictType } from '@/global' import { getJobInstructionList } from '@/api/equipment/standard/book' import SelectEquipmentDialog from '@/views/business/fieldTest/approve/dialog/selectEquipmentDialog.vue' import { addCheckItemClassification, updateCheckItemClassification } from '@/api/equipment/standard/checkItemClassification' const user = useUserStore() // 用户信息 const textMap: { [key: string]: string } = { edit: '编辑', add: '新建', detail: '详情', }// 字典 const $router = useRouter() // 关闭页面使用 const $route = useRoute() // 路由参数 const pageType = ref('add') // 页面类型: add, edit, detail const infoId = ref('') // 列表id const ruleFormRef = ref() // 表单ref const form = ref<IForm>({ dataNo: '', // 核查数据编号 checkDate: '', // 核查日期 checkAddress: '', // 核查地点 temperature: '', // 环境温度 humidity: '', // 环境湿度 checkAccord: '', // 核查依据(即标准装置的作业指导书文件minio文件名,多个分号分割) createUserName: '', // 核查员 stabilityExamine: '', // 是否用于稳定性考核(1/0) }) // 校验规则 const formRules = ref({ checkDate: [{ required: true, message: '核查日期不能为空', trigger: ['blur', 'change'] }], checkAddress: [{ required: true, message: '核查地点不能为空', trigger: ['blur', 'change'] }], temperature: [{ required: true, message: '温度不能为空', trigger: ['blur', 'change'] }, { pattern: /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/, message: '温度只能为数字', trigger: ['blur', 'change'] }], humidity: [{ required: true, message: '相对湿度不能为空', trigger: ['blur', 'change'] }, { pattern: /(^-?\d\d*\.\d*$)|(^-?\d\d*$)|(^-?\.\d\d*$)/, message: '相对湿度只能为数字', trigger: ['blur', 'change'] }], createUserName: [{ required: true, message: '核查员不能为空', trigger: ['blur', 'change'] }], stabilityExamine: [{ required: true, message: '是否用于稳定性考核不能为空', trigger: ['blur', 'change'] }], }) // -------------------------------------------字典------------------------------------------ const deviceTypeList = ref<dictType[]>([])// 设备分类 const standardList = ref<dictType[]>([])// 检校标准装置 const positionList = ref<dictType[]>([]) // 核查地点 const stabilityExamineList = [ // 是否用于稳定性考核 { id: '1', name: '是', }, { id: '2', name: '否', }, ] // 核查地点 positionList.value = [ { id: '1', name: '地点1', value: '1', }, { id: '2', name: '地点2', value: '2', }, ] function getDict() { // 设备分类 getDictByCode('bizEquipmentCategory').then((response) => { deviceTypeList.value = response.data }) // 检校标准装置 getDictByCode('bizStandardEquipmentType').then((response) => { standardList.value = response.data }) } // ----------------------------------路由参数------------------------------------------------ if ($route.params && $route.params.type) { pageType.value = $route.params.type as string console.log(pageType.value) if ($route.params.id) { infoId.value = $route.params.id as string } } // --------------------------------核查标准设备----------------------------------------------- const equipmentColumns = [ // 表头 { text: '设备名称', value: 'equipmentName', align: 'center', width: '240' }, { text: '型号规格', value: 'model', align: 'center' }, { text: '出厂编号', value: 'manufactureNo', align: 'center' }, { text: '准确度等级', value: 'accuracyLevel', align: 'center' }, { text: '测量范围', value: 'measureRange', align: 'center' }, { text: '制造厂家', value: 'manufacturer', align: 'center' }, { text: '证书有效期', value: 'certificateValid', align: 'center', width: '120' }, { text: '备注', value: 'remark', align: 'center' }, ] const equipmentList = ref<IEquipmentList[]>([])// 表格数据 const checkoutEquipmentList = ref([]) as any // 选中数据 const selectEquipmentDialogRef = ref() // 选择设备组件ref // 选中 const handleSelectionEquipmentChange = (e: any) => { checkoutEquipmentList.value = e } // 批量添加 const multiAddEquipment = () => { selectEquipmentDialogRef.value.initDialog() } // 确定选择设备 const confirmSelectEquipment = (list = []) => { list.forEach((item: IEquipmentList) => { // 只添加列表里不存在的 const index = equipmentList.value.findIndex((i: { id: string }) => item.id === i.id) if (index === -1) { item.certificateValid = item.certificateValid ? dayjs(item.certificateValid).format('YYYY-MM-DD') : item.certificateValid equipmentList.value.push(item) } }) } // 删除 const delEquipmentRow = () => { if (!checkoutEquipmentList.value.length) { ElMessage.warning('请选中要删除的行') } else { equipmentList.value = equipmentList.value.filter((item: any) => { return !checkoutEquipmentList.value.includes(item) }) } } // ------------------------------------------被核查设备--------------------------------------- const selectStandardId = ref('') // 被核查设备选择的标准装置id const chekedEquipmentList = ref<IEquipmentList[]>([{ id: '', equipmentNo: '', // 设备编号 equipmentName: '', // 设备名称 model: '', // 型号规格 manufactureNo: '', // 出厂编号 accuracyLevel: '', // 准确度等级 measureRange: '', // 测量范围 manufacturer: '', // 制造厂(生产厂家) certificateValid: '', // 证书有效期 remark: '', // 备注 }])// 表格数据 const selectStandardEquipmentDialogRef = ref() // 选择标准装置组件ref // 点击选择被核查设备 const selectStandardEquipment = () => { selectStandardEquipmentDialogRef.value.initDialog() } // 选好配套设备 const confirmSelectedStandardEquipmentDialog = (val: any, standardId: string) => { selectStandardId.value = standardId // 被核查设备选择的标准装置id chekedEquipmentList.value = [{ id: val[0].id, equipmentNo: val[0].equipmentNo, // 设备编号 equipmentName: val[0].equipmentName, // 设备名称 model: val[0].model, // 型号规格 manufactureNo: val[0].manufactureNo, // 出厂编号 accuracyLevel: val[0].accuracyLevel, // 准确度等级 measureRange: val[0].measureRange, // 测量范围 manufacturer: val[0].manufacturer, // 制造厂(生产厂家) certificateValid: val[0].certificateValid, // 证书有效期 remark: val[0].remark, // 备注 }] } // ------------------------------------------------------------------------------------------ // 关闭新增页面的回调 const close = () => { $router.back() } // 保存 const save = () => { // ruleFormRef.value!.validate((valid: boolean) => { // if (valid) { // const loading = ElLoading.service({ // lock: true, // background: 'rgba(255, 255, 255, 0.8)', // }) // if (pageType.value === 'add') { // 新建 // addCheckItemClassification({ ...form.value }).then((res) => { // ElMessage.success('保存成功') // form.value.categoryNo = res.data.categoryNo // 检定项分类编号 // pageType.value = 'detail' // loading.close() // }).catch(() => { // loading.close() // }) // } // // 保存 // else if (pageType.value === 'edit') { // 编辑 // updateCheckItemClassification({ ...form.value, id: infoId.value }).then((res) => { // ElMessage.success('保存成功') // pageType.value = 'detail' // loading.close() // }).catch(() => { // loading.close() // }) // } // } // else { // console.log('表单校验不通过') // } // }) } // 点击编辑 const edit = () => { pageType.value = 'edit' } // -------------------------------------------请求核查依据(作业指导书)---------------------------------------- const technologyFile = ref([]) // 核查依据 // 查询条件(作业指导书列表) const listQueryJobInstruction = ref({ id: '1715180588993212417', offset: 1, limit: 999999, }) // // 请求作业指导书列表 function fetchJobInstruction(isNowPage = false, StandardId = '') { if (!isNowPage) { // 是否显示当前页,否则跳转第一页 listQueryJobInstruction.value.offset = 1 } listQueryJobInstruction.value.id = StandardId // 标准装置id getJobInstructionList(listQueryJobInstruction.value).then((response) => { technologyFile.value = response.data.rows.map((item: { file: string }) => item.file) }) } // ----------------------------------------核查数据---------------------------------------------- const radioMenus = ref([ // 标签内容 { name: '最佳点', value: 'best' }, { name: '最差点', value: 'worst' }, { name: '典型点', value: 'model' }, ]) const current = ref('best') // 选择的tab 默认基本信息 const checkDataColumns = ref<TableColumn[]>([ // 表头 { text: '核查项目', value: 'params', align: 'center', required: true }, { text: '核查点', value: 'checkPoint', align: 'center', required: true }, { text: '单位', value: 'unit', align: 'center', required: true }, { text: '频率', value: 'frequency', align: 'center' }, { text: '单位', value: 'frequencyUnit', align: 'center' }, { text: '循环次数', value: 'cycleNumber', align: 'center', required: true }, { text: '算数平均值', value: 'averageValue', align: 'center', required: true }, { text: '标准偏差S(X)', value: 'standardDeviation', align: 'center', required: true }, { text: '相对重复性', value: 'relativeRepeatability', align: 'center' }, { text: '历次核查Sn(x)', value: 'previousCheck', align: 'center' }, { text: 'Urel', value: 'urel', align: 'center' }, { text: '相对重复性是否小于相对扩展不确定度Urel', value: 'lessThan', align: 'center' }, { text: '稳定性考核是否合格', value: 'flit', align: 'center' }, ]) const bestList = ref<IDetailCheckData[]>([]) // 最佳点 const worstList = ref<IDetailCheckData[]>([]) // 最差点 const modelList = ref<IDetailCheckData[]>([]) // 典型点 // 获取配置详情 const fetchCheckItemDetail = () => { // const params = { // belongStandardEquipment: form.value.belongStandardEquipment, // 检校标准装置code // itemCategoryId: form.value.itemCategoryId, // 核查项分类id // itemCategoryName: form.value.itemCategoryName, // 核查项分类名称 // } // getCheckItemDetail(params).then((res) => { // // 最佳点 // bestList.value = res.data.checkItemDataCalibratorList.filter((item: { testType: string }) => item.testType === '最佳点') // if (pageType.value === 'edit') { // bestList.value = bestList.value.map((e: any) => { // return { // ...e, // checkType: e.checkType ? e.checkType.split(',') : [], // 核查类型 // thoroughfare: e.thoroughfare ? e.thoroughfare.split(',') : [], // 通道 // } // }) // } // // 最差点 // worstList.value = res.data.checkItemDataCalibratorList.filter((item: { testType: string }) => item.testType === '最差点') // if (pageType.value === 'edit') { // worstList.value = worstList.value.map((e: any) => { // return { // ...e, // checkType: e.checkType ? e.checkType.split(',') : [], // 核查类型 // thoroughfare: e.thoroughfare ? e.thoroughfare.split(',') : [], // 通道 // } // }) // } // // 典型点 // modelList.value = res.data.checkItemDataCalibratorList.filter((item: { testType: string }) => item.testType === '典型点') // if (pageType.value === 'edit') { // modelList.value = modelList.value.map((e: any) => { // return { // ...e, // checkType: e.checkType ? e.checkType.split(',') : [], // 核查类型 // thoroughfare: e.thoroughfare ? e.thoroughfare.split(',') : [], // 通道 // } // }) // } // }) } // -------------------------------------钩子----------------------------------------------------- watch(() => selectStandardId.value, (newValue) => { if (newValue) { fetchJobInstruction(false, newValue) // 新建的时候获取核查依据 } }) onMounted(async () => { getDict() if (pageType.value === 'add') { form.value.createUserName = user.name // 核查员 } }) </script> <template> <app-container> <detail-page :title="`核查项分类管理-${textMap[pageType]}`"> <template #btns> <el-button v-if="pageType === 'detail'" type="primary" @click="edit"> 编辑 </el-button> <el-button v-if="pageType !== 'detail'" type="primary" @click="save"> 保存 </el-button> <el-button type="info" @click="close"> 关闭 </el-button> </template> <el-form ref="ruleFormRef" :model="form" label-width="130" label-position="right" :rules="formRules" > <el-row :gutter="24"> <el-col :span="6"> <el-form-item label="核查数据编号:" prop="dataNo"> <el-input v-model="form.dataNo" class="full-width-input" disabled placeholder="系统自动生成" /> </el-form-item> </el-col> <el-col :span="6"> <el-form-item label="核查日期:" prop="checkDate"> <el-date-picker v-model="form.checkDate" type="date" format="YYYY-MM-DD" value-format="YYYY-MM-DD" :placeholder="pageType === 'detail' ? ' ' : '请选择核查日期'" :disabled="pageType === 'detail'" class="full-width-input" /> </el-form-item> </el-col> <el-col :span="6"> <el-form-item label="核查地点:" prop="checkAddress"> <el-select v-model="form.checkAddress" placeholder="核查地点" filterable :disabled="pageType === 'detail'" > <el-option v-for="item in positionList" :key="item.id" :label="item.name" :value="item.value" /> </el-select> </el-form-item> </el-col> <el-col :span="6"> <el-form-item label="温度(℃):" prop="temperature"> <el-input v-model="form.temperature" :disabled="pageType === 'detail'" :placeholder="pageType === 'detail' ? ' ' : '请输入温度'" /> </el-form-item> </el-col> <el-col :span="6"> <el-form-item label="相对湿度(%):" prop="humidity"> <el-input v-model="form.humidity" :disabled="pageType === 'detail'" :placeholder="pageType === 'detail' ? ' ' : '请输入相对湿度'" /> </el-form-item> </el-col> <el-col :span="6"> <el-form-item label="核查员:" prop="dacreateUserNametaNo"> <el-input v-model="form.createUserName" disabled placeholder="检定员" /> </el-form-item> </el-col> <el-col :span="6"> <el-form-item label="是否用于稳定性考核:" label-width="160" prop="stabilityExamine"> <el-select v-model="form.stabilityExamine" placeholder="请选择" class="short-input" filterable :disabled="pageType === 'detail'" > <el-option v-for="item in stabilityExamineList" :key="item.id" :label="item.name" :value="item.id" /> </el-select> </el-form-item> </el-col> </el-row> <el-row :gutter="24" class="marg"> <el-col :span="24"> <el-form-item label="核查依据:" prop="technologyFile"> <div v-for="(item, index) in technologyFile" :key="index" style="display: flex;"> <show-photo :minio-file-name="item" style="margin-right: 10px;" /> </div> <span v-if="pageType === 'detail' && !technologyFile">无</span> </el-form-item> </el-col> </el-row> </el-form> </detail-page> <detail-block title="核查标准设备"> <template v-if="pageType !== 'detail'" #btns> <el-button type="primary" @click="multiAddEquipment"> 批量添加 </el-button> <el-button type="info" @click="delEquipmentRow"> 删除行 </el-button> </template> <el-table :data="equipmentList" border style="width: 100%;" @selection-change="handleSelectionEquipmentChange" > <el-table-column v-if="pageType !== 'detail'" type="selection" width="55" /> <el-table-column align="center" label="序号" width="80" type="index" /> <el-table-column v-for="item in equipmentColumns" :key="item.value" :prop="item.value" :label="item.text" :width="item.width" align="center" /> </el-table> </detail-block> <detail-block title="被核查设备"> <el-table :data="chekedEquipmentList" border style="width: 100%;" > <el-table-column align="center" label="序号" width="80" type="index" /> <el-table-column v-for="item in equipmentColumns" :key="item.value" :prop="item.value" :label="item.text" :width="item.width" align="center" > <template #default="scope"> <el-input v-if="pageType !== 'detail' && item.value === 'equipmentName'" v-model="scope.row[item.value]" placeholder="请选择" disabled > <template #append> <el-button size="small" @click="selectStandardEquipment"> 选择 </el-button> </template> </el-input> </template> </el-table-column> </el-table> </detail-block> <!-- 核查数据 --> <detail-block title="核查数据"> <el-radio-group v-model="current" style="margin-bottom: 20px;"> <el-radio-button v-for="item in radioMenus" :key="item.value" :label="item.value"> {{ item.name }} </el-radio-button> </el-radio-group> <el-table :data="current === 'best' ? bestList : current === 'worst' ? worstList : modelList" border style="width: 100%;" > <el-table-column align="center" label="序号" width="80" type="index" /> <el-table-column v-for="item in checkDataColumns" :key="item.value" :prop="item.value" :label="item.text" align="center" /> </el-table> </detail-block> <!-- 选择设备台账 --> <select-equipment-dialog ref="selectEquipmentDialogRef" :is-multi="true" @confirm="confirmSelectEquipment" /> <!-- 选择标准装置设备 --> <select-standard-equipment-dialog ref="selectStandardEquipmentDialogRef" @confirm="confirmSelectedStandardEquipmentDialog" /> </app-container> </template> <style lang="scss" scoped> .link { text-decoration: underline; color: #3d7eff; cursor: pointer; } .file-area { display: flex; align-items: center; font-size: 14px; color: #60627f; margin-bottom: 10px; margin-left: 40px; white-space: nowrap; .tech-file { display: flex; align-items: center; margin-left: 20px; .file-text { margin-right: 10px; } } } </style>