<!-- 核查数据管理详情--核查项 -->
<script lang="ts" setup name="checkDataDetail">
import { ref } from 'vue'
import { ElLoading, ElMessage } from 'element-plus'
import saveCheckRecord from '../../dialog/saveCheckRecord.vue'
import type { IList } from './fourth-interface'
import type { TableColumn } from '@/components/NormalTable/table_interface'
import useUserStore from '@/store/modules/user'
import type { dictType } from '@/global'
import { getDictByCode } from '@/api/system/dict'
import multiTable from '@/components/MultiHeaderTable/index.vue'
import { getCheckItemDetail, getJobInstructionList } from '@/api/equipment/standard/book'
import { addCheckData, calculateHandle, getInfo, updateCheckData } from '@/api/equipment/standard/checkData'
const user = useUserStore() // 用户信息
const $router = useRouter() // 关闭页面使用
const $route = useRoute() // 路由参数
const pageType = ref('add') // 页面类型: add, edit, detail
const infoId = ref('')
const ruleFormRef = ref() // 表单ref
const form = ref({
conclusion: '1', // 结论
remark: '/', // 备注
})
const belongStandardEquipment = ref('1')
const itemCategoryId = ref('')
const itemCategoryName = ref('')
// ----------------------------------路由参数------------------------------------------------
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 conclusionList = ref<dictType[]>([]) // 结论
const checkItemElectricalSignalMap = ref({}) as any // 核查项目
const maximumErrorAbsoluteElectricalSignalMap = ref({}) as any // 最大允许误差
function getDict() {
// 结论
getDictByCode('conclusion').then((response) => {
conclusionList.value = response.data
})
// 核查项目
getDictByCode('checkItemElectricalSignal').then((response) => {
response.data.forEach((item: { value: string; name: string }) => {
checkItemElectricalSignalMap.value[`${item.value}`] = item.name
})
})
// 最大允许误差绝对值(电信号)
getDictByCode('maximumErrorAbsolutePressure').then((response) => {
response.data.forEach((item: { value: string; name: string }) => {
maximumErrorAbsoluteElectricalSignalMap.value[`${item.value}`] = item.name
})
})
}
getDict()
// ----------------------------------------核查数据----------------------------------------------
const list = ref<IList[]>([]) // 核查项数据
const columns = ref<TableColumn[]>([])
const columns_pressure = ref<TableColumn[]>([ // 压力值表头
{ text: '单位', value: 'unit', align: 'center', required: true, type: 'text' },
{ text: '核查点', value: 'checkPoint', align: 'center', required: true, type: 'text' },
{
text: '第一次',
value: 'firstStroke',
align: 'center',
required: true,
width: '180',
children: [
{ text: '正行程', value: 'firstForwardStroke', align: 'center', required: true, type: 'inputNumber' },
{ text: '反行程', value: 'firstReverseStroke', align: 'center', required: true, type: 'inputNumber' },
],
},
{
text: '第二次',
value: 'secondStroke',
align: 'center',
required: true,
width: '180',
children: [
{ text: '正行程', value: 'secondForwardStroke', align: 'center', required: true, type: 'inputNumber' },
{ text: '反行程', value: 'secondReverseStroke', align: 'center', required: true, type: 'inputNumber' },
],
},
{
text: '第三次',
value: 'thirdStroke',
align: 'center',
required: true,
width: '180',
children: [
{ text: '正行程', value: 'thirdForwardStroke', align: 'center', required: true, type: 'inputNumber' },
{ text: '反行程', value: 'thirdReverseStroke', align: 'center', required: true, type: 'inputNumber' },
],
},
{ text: '均值', value: 'averageValue', align: 'center', required: true, type: 'text' },
{ text: '最大示值误差绝对值', value: 'maxIndicatingError', align: 'center', required: true, type: 'text' },
{ text: '最大回程误差绝对值', value: 'maxReturnError', align: 'center', required: true, type: 'text' },
{ text: '最大允许误差绝对值', value: 'maximumError', align: 'center', required: true, type: 'text' },
])
const columns_electrical_signal = ref<TableColumn[]>([ // 电信号表头
{ text: '核查项目', value: 'params', align: 'center', required: true, type: 'text' },
{ text: '核查点', value: 'checkPoint', align: 'center', required: true, type: 'text' },
{ text: '单位', value: 'unit', align: 'center', required: true, type: 'text' },
{
text: '第一次',
value: 'first',
align: 'center',
required: true,
width: '180',
children: [
{ text: '核查标准示值', value: 'testValueOne', align: 'center', required: true, type: 'inputNumber' },
{ text: '测量标准示值', value: 'measureValueOne', align: 'center', required: true, type: 'inputNumber' },
],
},
{
text: '第二次',
value: 'second',
align: 'center',
required: true,
width: '180',
children: [
{ text: '核查标准示值', value: 'testValueTwo', align: 'center', required: true, type: 'inputNumber' },
{ text: '测量标准示值', value: 'measureValueTwo', align: 'center', required: true, type: 'inputNumber' },
],
},
{
text: '第三次',
value: 'third',
align: 'center',
required: true,
width: '180',
children: [
{ text: '核查标准示值', value: 'testValueThree', align: 'center', required: true, type: 'inputNumber' },
{ text: '测量标准示值', value: 'measureValueThree', align: 'center', required: true, type: 'inputNumber' },
],
},
{
text: '第四次',
value: 'fourth',
align: 'center',
required: true,
width: '180',
children: [
{ text: '核查标准示值', value: 'testValueFour', align: 'center', required: true, type: 'inputNumber' },
{ text: '测量标准示值', value: 'measureValueFour', align: 'center', required: true, type: 'inputNumber' },
],
},
{
text: '第五次',
value: 'fifth',
align: 'center',
required: true,
width: '180',
children: [
{ text: '核查标准示值', value: 'testValueFive', align: 'center', required: true, type: 'inputNumber' },
{ text: '测量标准示值', value: 'measureValueFive', align: 'center', required: true, type: 'inputNumber' },
],
},
{
text: '第六次',
value: 'sixth',
align: 'center',
required: true,
width: '180',
children: [
{ text: '核查标准示值', value: 'testValueSix', align: 'center', required: true, type: 'inputNumber' },
{ text: '测量标准示值', value: 'measureValueSix', align: 'center', required: true, type: 'inputNumber' },
],
},
{
text: '平均值',
value: 'average',
align: 'center',
required: true,
width: '180',
children: [
{ text: '核查标准示值', value: 'testValueAverage', align: 'center', required: true, type: 'text' },
{ text: '测量标准示值', value: 'measureValueAverage', align: 'center', required: true, type: 'text' },
],
},
{ text: '最大示值误差', value: 'maxIndicatingError', align: 'center', required: true, type: 'text' },
{ text: '最大允许误差', value: 'maximumError', align: 'center', required: true, type: 'text' },
])
// 获取配置详情
function fetchCheckItemDetail(equipmentId: string, belongStandardEquipmentParam: string, itemCategoryIdParam: string, itemCategoryNameParam: string) {
belongStandardEquipment.value = belongStandardEquipmentParam // 检校标准装置
itemCategoryId.value = itemCategoryIdParam // 核查分类id
itemCategoryName.value = itemCategoryNameParam // 核查分类名称
const loading = ElLoading.service({
lock: true,
background: 'rgba(255, 255, 255, 0.8)',
})
const params = {
equipmentId, // 设备id
belongStandardEquipment: belongStandardEquipment.value, // 检校标准装置code
itemCategoryId: itemCategoryId.value, // 核查项分类id
itemCategoryName: itemCategoryName.value, // 核查项分类名称
}
getCheckItemDetail(params).then((res) => {
list.value = res.data.checkItemDataPistonGaugeList.map((item: { id: string; checkItem: string; standardIndication: string; maximumErrorAbsolute: string }) => {
return {
...item,
dataId: item.id, /// / 核查数据管理基础信息表id
params: checkItemElectricalSignalMap.value[`${item.checkItem}`], // 核查项目
testValueOne: item.standardIndication, // 核查标准示值1
testValueTwo: item.standardIndication, // 核查标准示值2
testValueThree: item.standardIndication, // 核查标准示值3
testValueFour: item.standardIndication, // 核查标准示值4
testValueFive: item.standardIndication, // 核查标准示值5
testValueSix: item.standardIndication, // 核查标准示值6
measureValueFive: 0, // 测量标准示值5
measureValueFour: 0, // 测量标准示值4
measureValueOne: 0, // 测量标准示值1
measureValueSix: 0, // 测量标准示值6
measureValueThree: 0, // 测量标准示值3
measureValueTwo: 0, // 测量标准示值2
secondForwardStroke: 0, // 第二次正行程
secondReverseStroke: 0, // 第二次反行程
thirdForwardStroke: 0, // 第三次正行程
thirdReverseStroke: 0, // 第三次反行程
firstForwardStroke: 0, // 第一次正行程
firstReverseStroke: 0, // 第一次反行程
maximumError: maximumErrorAbsoluteElectricalSignalMap.value[`${item.maximumErrorAbsolute}`], // 最大允许误差绝对值
editable: pageType.value !== 'detail',
}
})
loading.close()
})
}
// 点击生成结果处理
const createResult = () => {
if (!list.value.length) {
ElMessage.warning('核查数据表格不能为空,是否未配置?请检查')
return false
}
ElMessage.info('敬请期待')
const params = {
// belongStandardEquipment: belongStandardEquipment.value, // 检校标准装置
// checkDataCalibratorList: bestList.value.concat(bestListStability.value, worstList.value, worstListStability.value, modelList.value, modelListStability.value),
// itemCategoryId: itemCategoryId.value, // 核查项分类id
}
// calculateHandle(params).then(() => {
// })
}
// ------------------------------------------------------------------------------------------
// 获取详情
function fetchInfo() {
const loading = ElLoading.service({
lock: true,
background: 'rgba(255, 255, 255, 0.8)',
})
getInfo({ id: infoId.value }).then((res) => {
form.value = { ...res.data }
list.value = res.data.checkDataPistonGaugeList.map((item: any) => {
return {
...item,
editable: pageType.value !== 'detail',
}
})
loading.close()
})
}
// -------------------------------------钩子-----------------------------------------------------
watch(() => itemCategoryName.value, (newVal) => {
if (newVal === '压力值') {
columns.value = columns_pressure.value
}
else {
columns.value = columns_electrical_signal.value
}
})
onMounted(async () => {
if (pageType.value !== 'add') {
belongStandardEquipment.value = $route.query.belongStandardEquipment as string // 检校标准装置
itemCategoryId.value = $route.query.itemCategoryId as string // 核查项分类id
itemCategoryName.value = $route.query.itemCategoryName as string // 核查项分类名称
fetchInfo()
}
})
defineExpose({ fetchCheckItemDetail, form, list })
</script>
<template>
<!-- 核查数据 -->
<detail-block title="核查数据">
<template v-if="pageType !== 'detail'" #btns>
<el-button v-if="pageType !== 'detail'" type="primary" @click="createResult">
生成结果处理
</el-button>
</template>
<!-- 表格 -->
<multi-table
:table-data="list"
:table-header="columns"
:merge-rows="[]"
:need-index="true"
/>
<!-- 结论、备注 -->
<el-form
style="margin-top: 20px;"
:model="form"
label-width="160"
label-position="right"
>
<el-row :gutter="24">
<el-col :span="12">
<el-form-item label="结论:" prop="conclusion">
<el-select v-model="form.conclusion" :placeholder="pageType === 'detail' ? ' ' : '结论'" :disabled="pageType === 'detail'" class="full-width-input">
<el-option
v-for="i in conclusionList"
:key="i.value"
:label="i.name"
:value="i.value"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="备注:" prop="remark">
<el-input v-model="form.remark" clearable class="full-width-input" :disabled="pageType === 'detail'" placeholder="备注" />
</el-form-item>
</el-col>
</el-row>
</el-form>
</detail-block>
<!-- 保存核查记录 -->
<save-check-record ref="saveCheckRecordRef" />
</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>