<!-- 第8套:E2砝码标准装置 -->
<script lang="ts" setup name="TemplateDetailEighth">
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'
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 standardQualityUnitList = ref<dictType[]>([]) // 质量相关单位
/**
* 获取字典
*/
function getDict() {
// 质量相关单位
getDictByCode('standardQualityUnit').then((response) => {
standardQualityUnitList.value = response.data
})
}
getDict()
// --------------------------------------质量比较仪---------------------------------------------------------
const form = ref({
ptOne: '', // 实验载荷Pt1
ptOneUnit: '', // 实验载荷Pt1单位
ptTwo: '', // 实验载荷Pt2
ptTwoUnit: '', // 实验载荷Pt2单位
actualDivisionValue: '', // 实际分度值d
actualDivisionValueUnit: 'mg', // 实际分度值d单位
repeatability: 1, // 重复性
localIndicationError: 1, // 局部示值误差
partialLoadError: 1, // 偏载误差
appearanceFunctionCheck: 1, // 外观检查
})
// 保存前的校验
const checkList = () => {
if (`${form.value.ptOne}` === '' || form.value.ptOne === undefined) {
ElMessage.warning('实验载荷Pt1不能为空')
return false
}
if (`${form.value.ptOneUnit}` === '' || form.value.ptOneUnit === undefined) {
ElMessage.warning('实验载荷Pt1单位不能为空')
return false
}
if (`${form.value.ptTwo}` === '' || form.value.ptTwo === undefined) {
ElMessage.warning('实验载荷Pt2不能为空')
return false
}
if (`${form.value.ptTwoUnit}` === '' || form.value.ptTwoUnit === undefined) {
ElMessage.warning('实验载荷Pt2单位不能为空')
return false
}
if (`${form.value.actualDivisionValue}` === '' || form.value.actualDivisionValue === undefined) {
ElMessage.warning('实际分度值d不能为空')
return false
}
if (`${form.value.actualDivisionValueUnit}` === '' || form.value.actualDivisionValueUnit === undefined) {
ElMessage.warning('实际分度值d单位不能为空')
return false
}
return true
}
// --------------------------------------------钩子----------------------------------------------------
const $route = useRoute()
watch(() => props.list, (newVal) => { // 检定项表格
const updataOld = $route.query.updataOld as string
if (newVal.length && updataOld !== 'true') {
form.value.ptOne = newVal[0].ptOne // 实验载荷Pt1
form.value.ptOneUnit = newVal[0].ptOneUnit // 实验载荷Pt1单位
form.value.ptTwo = newVal[0].ptTwo // 实验载荷Pt2
form.value.ptTwoUnit = newVal[0].ptTwoUnit // 实验载荷Pt2单位
form.value.actualDivisionValue = newVal[0].actualDivisionValue // 实际分度值d
form.value.actualDivisionValueUnit = newVal[0].actualDivisionValueUnit // 实际分度值d单位
}
})
watch(() => props.form, (newValue) => {
const updataOld = $route.query.updataOld as string
if (updataOld !== 'true') {
form.value.repeatability = newValue.repeatability // 重复性
form.value.localIndicationError = newValue.localIndicationError// 局部示值误差
form.value.partialLoadError = newValue.partialLoadError // 偏载误差
form.value.appearanceFunctionCheck = newValue.appearanceFunctionCheck // 外观检查
}
}, { deep: true, immediate: true })
defineExpose({ checkList, form })
</script>
<template>
<div style="padding: 0 10px;">
<el-checkbox v-model="form.appearanceFunctionCheck" :true-label="1" :false-label="0" :disabled="pageType === 'detail'">
外观检查
</el-checkbox>
<el-checkbox v-model="form.repeatability" :true-label="1" :false-label="0" :disabled="pageType === 'detail'">
重复性
</el-checkbox>
<el-checkbox v-model="form.partialLoadError" :true-label="1" :false-label="0" :disabled="pageType === 'detail'">
偏载误差
</el-checkbox>
<el-checkbox v-model="form.localIndicationError" :true-label="1" :false-label="0" :disabled="pageType === 'detail'">
局部示值误差
</el-checkbox>
<el-form
ref="ruleFormRef"
:model="form"
label-width="130"
label-position="right"
style="margin-top: 20px;"
>
<el-row :gutter="24">
<!-- 实验载荷Pt1 -->
<el-col :span="12" style="display: flex;justify-content: flex-start;">
<el-form-item label="实验载荷Pt1:" prop="ptOne">
<precision-input-number
v-model="form.ptOne"
class="full-width-input"
placeholder="实验载荷Pt1"
:disabled="props.pageType === 'detail'"
style="flex: 1;"
/>
</el-form-item>
<el-form-item label-width="10" prop="ptOneUnit">
<el-select
v-model="form.ptOneUnit"
placeholder="单位"
:disabled="props.pageType === 'detail'"
filterable
style="width: 90px;"
>
<el-option v-for="item in standardQualityUnitList" :key="item.id" :label="item.name" :value="item.name" />
</el-select>
</el-form-item>
</el-col>
<!-- 实验载荷Pt2 -->
<el-col :span="12" style="display: flex;justify-content: flex-start;">
<el-form-item label="实验载荷Pt2:" prop="ptTwo">
<precision-input-number
v-model="form.ptTwo"
class="full-width-input"
placeholder="实验载荷Pt2"
:disabled="props.pageType === 'detail'"
style="flex: 1;"
/>
</el-form-item>
<el-form-item label-width="10" prop="ptTwoUnit">
<el-select
v-model="form.ptTwoUnit"
placeholder="单位"
:disabled="props.pageType === 'detail'"
filterable
style="width: 90px;"
>
<el-option v-for="item in standardQualityUnitList" :key="item.id" :label="item.name" :value="item.name" />
</el-select>
</el-form-item>
</el-col>
<!-- 实际分度值d -->
<el-col :span="12" style="display: flex;justify-content: flex-start;">
<el-form-item label="实际分度值d:" prop="actualDivisionValue">
<precision-input-number
v-model="form.actualDivisionValue"
class="full-width-input"
placeholder="实际分度值d"
:disabled="props.pageType === 'detail'"
style="flex: 1;"
/>
</el-form-item>
<el-form-item label-width="10" prop="actualDivisionValueUnit">
<el-select
v-model="form.actualDivisionValueUnit"
placeholder="单位"
disabled
filterable
style="width: 90px;"
>
<el-option v-for="item in standardQualityUnitList" :key="item.id" :label="item.name" :value="item.name" />
</el-select>
</el-form-item>
</el-col>
</el-row>
</el-form>
</div>
</template>