<!-- 第7套:精密露点仪标准装置标准装置 --> <script lang="ts" setup name="TemplateDetailSeventh"> import { ElMessage } from 'element-plus' import type { IList } from './templateDetail-interface' import type { dictType } from '@/global' import { getDictByCode } from '@/api/system/dict' import { calc } from '@/utils/useCalc' import { useCheckList } from '@/commonMethods/useCheckList' import { calculate, recalculate } from '@/api/business/measure/caculate' import type { TableColumn } from '@/components/NormalTable/table_interface' import templateTable from '@/views/business/measure/item/components/second/templateTable.vue' import { differenceArray, setSelectList } from '@/utils/Array' const props = defineProps({ pageType: { type: String, default: 'add', }, itemCategoryName: { type: String, require: true, }, // 设备检定项分类名称 belongStandardEquipment: { // 检校标准装置code type: String, require: true, }, list: { type: Array as any, }, form: { // 检定项表单 type: Object as any, }, itemId: { // 检定项id type: String, default: '', }, }) const list = ref<IList[]>([]) const checkoutList = ref<IList[]>([]) // 多选 // ------------------------------------------表头------------------------------------------------------------- const columns = ref([]) as any // 表头数据 const columns_mechanical = ref<TableColumn[]>([ // 机械式温湿度仪表 { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' }, { text: '类型', value: 'type', align: 'center', required: true, type: 'select' }, { text: '温度点/湿度点', value: 'ponint', align: 'center', required: true, type: 'number' }, { text: '单位', value: 'unit', align: 'center', required: false, type: 'text' }, { text: '最大允许误差', value: 'allowMaximum', align: 'center', required: true, type: 'number' }, ]) const columns_digital = ref<TableColumn[]>([ // 数字式/外置探头式温湿度仪表 { text: '检定项目', value: 'params', align: 'center', required: true, type: 'text' }, { text: '类型', value: 'type', align: 'center', required: true, type: 'select' }, { text: '温度点/湿度点', value: 'ponint', align: 'center', required: true, type: 'number' }, { text: '单位', value: 'unit', align: 'center', required: false, type: 'text' }, { text: '不确定度', value: 'urel', align: 'center', required: true, type: 'number' }, { text: '最大允许误差', value: 'allowMaximum', align: 'center', required: true, type: 'number' }, ]) const form = ref({ szcs: 1, appearance: 1, }) // --------------------------------------------钩子---------------------------------------------------- watch(() => props.itemCategoryName, (newValue) => { if (newValue) { switch (newValue) { case '机械式温湿度仪表': columns.value = columns_mechanical.value break case '数字式/外置探头式温湿度仪表': columns.value = columns_digital.value break } } }, { immediate: true }) watch(() => props.list, (newVal) => { // 检定项表格 if (newVal) { list.value = [...newVal] } }) defineExpose({ list }) // --------------------------------表格操作--------------------------------------------------- const addRow = (list1: IList[], title: string, index: string) => { if (useCheckList(list1, columns.value, `${title}表格`)) { let data = {} as any switch (title) { case '示值测试': // 示值测试 data = { id: '', params: '示值测试', nominalValue: '', unit: '', editable: true, type: '', ponint: '', urel: '', allowMaximum: '', } list.value.length ? list.value.push(JSON.parse(JSON.stringify(list.value[list.value.length - 1]))) : list.value.push(data) break } } } /** * 删除行公共方法 * @param checkoutList 选中的数组 * @param list 操作的数组 */ const delRow = (checkoutList: IList[], list1: IList[], title: string) => { if (!checkoutList.length) { ElMessage.warning('请选中要删除的行') } else { let data = [] as any[] data = differenceArray(list1, checkoutList) switch (title) { case '示值测试': // 衰减量 list.value = data break } } } // ---------------------------------------------校验--------------------------------------------------- // 校验表格(点击保存的时候用、生成标准器示值) function checkList(list: any[], columns: any[], title: string) { if (form.value.szcs) { if (!list.value.length) { ElMessage.warning('示值测试列表不能为空') return false } return useCheckList(list, columns, title) } else { return true } } function checkAllList() { // if (!list.value.length) { // ElMessage.warning('鉴定项列表不能为空') // return false // } return checkList(list.value, columns.value, '示值测试') } // 每个table对应的下拉框内容 字典 const tableDict = ref<{ [key: string]: { value: string;name: string;id: string }[] }>({}) tableDict.value = { 类型: [ { name: '温度示值', value: '1', id: '1', }, { name: '湿度示值', value: '2', id: '2', }, ], } const changeLoadSituationa = (value: any, index: number, text: string, type: string, list: any[], item: string) => { if (item === '示值测试') { if (text === '类型') { list[index].unit = value === '温度示值' ? '℃' : value === '湿度示值' ? '%RH' : '' } } } </script> <template> <div style="padding: 0 10px;"> <el-checkbox v-model="form.appearance" :checked="true" :disabled="pageType === 'detail'"> 外观检查 </el-checkbox> </div> <!-- 示值测试 --> <template-table :show="Boolean(form.szcs)" :data="list" :columns="columns" :page-type="pageType" title="示值测试" index="1" :show-btn="pageType !== 'detail'" :select-all-list="tableDict" @add-row="addRow" @del-row="delRow" @change-load-situationa="changeLoadSituationa" > <template #custom-check> <el-checkbox v-model="form.szcs" :checked="true" :true-label="1" :false-label="0" :disabled="pageType === 'detail'"> 示值测试 </el-checkbox> </template> <template #pre-content="{ column }"> <div v-if="column.text === '最大允许误差'" style="line-height: 30px;margin-left: 10px;"> ± </div> </template> </template-table> </template>