|
@@ -4,12 +4,12 @@
|
|
|
|
|
|
<div style="flex-grow: 1;height: 66vh;overflow-y: auto;overflow-x: hidden">
|
|
|
<el-radio-group v-model="radio1">
|
|
|
- <el-radio-button label="人工" :value="0" plain />
|
|
|
<el-radio-button label="自动" :value="1" plain />
|
|
|
+ <el-radio-button label="人工" :value="2" plain />
|
|
|
</el-radio-group>
|
|
|
<!-- 表格主体 -->
|
|
|
<div class="table-box" style="margin-top: 20px;height: 57vh">
|
|
|
- <el-table stripe ref="tableRef" :border="true" :data="radio1===0?certData:certData2" size="small">
|
|
|
+ <el-table stripe ref="tableRef" :border="true" :data="radio1 === 1 ? certData : certData2" size="small">
|
|
|
<el-table-column align="left" label="序号" width="80px" :show-overflow-tooltip="true">
|
|
|
<template #default="scope">
|
|
|
{{ scope.$index + 1 }}
|
|
@@ -19,19 +19,21 @@
|
|
|
<el-table-column v-bind="item" :align="item.align ?? 'left'"
|
|
|
:reserve-selection="item.type == 'selection'">
|
|
|
<template #default="scope">
|
|
|
- <template v-if="item.prop === 'c'">
|
|
|
- <el-date-picker class="no-border" v-model="scope.row.c" type="date" placeholder="请选择日期" />
|
|
|
+ <template v-if="item.prop === 'cal_date_i'">
|
|
|
+ <!-- <el-date-picker class="no-border" v-model="scope.row.c" type="date" placeholder="请选择日期" /> -->
|
|
|
+ <div>{{ scope.row.cal_date_i ? formatDate(scope.row.cal_date_i) : '' }}</div>
|
|
|
</template>
|
|
|
- <template v-if="item.prop === 'd'">
|
|
|
- <div style="min-height: 20px" @dblclick="editCell(scope.row, 'd')">
|
|
|
+ <template v-if="item.prop === 'cal_period'">
|
|
|
+ <!-- <div style="min-height: 20px" @dblclick="editCell(scope.row, 'd')">
|
|
|
<el-input v-if="isEditing(scope.row, 'd')" ref="inputRef" v-model="scope.row.d"
|
|
|
@blur="saveEdit(scope.row, 'd')" />
|
|
|
<span v-else>{{ scope.row.d }}</span>
|
|
|
- </div>
|
|
|
+ </div> -->
|
|
|
+ {{ scope.row.cal_period }}
|
|
|
</template>
|
|
|
<template v-if="item.prop === 'operation'">
|
|
|
<el-tooltip class="box-item" effect="dark" content="编辑" placement="top">
|
|
|
- <el-button type="primary" link @click="handleUpdate">
|
|
|
+ <el-button type="primary" link @click="handleUpdate(scope.row)">
|
|
|
<el-icon>
|
|
|
<Edit />
|
|
|
</el-icon>
|
|
@@ -55,9 +57,9 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="disposition-bottom">
|
|
|
- <el-button> 取消 </el-button>
|
|
|
- <el-button type="primary" plain> 上一步 </el-button>
|
|
|
- <el-button type="primary"> 下一步 </el-button>
|
|
|
+ <el-button disabled > 取消 </el-button>
|
|
|
+ <el-button disabled type="primary" plain> 上一步 </el-button>
|
|
|
+ <el-button disabled type="primary"> 下一步 </el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
<!-- 添加或修改对话框 -->
|
|
@@ -65,65 +67,75 @@
|
|
|
<el-form ref="formRef" :model="instrumentForm" :rules="rules" label-width="110px">
|
|
|
<el-row :gutter="20">
|
|
|
<el-col :span="20">
|
|
|
- <el-radio-group v-model="instrumentForm.type">
|
|
|
- <el-radio-button label="PWS" value="PWS" plain />
|
|
|
- <el-radio-button label="PWD" value="PWD" plain />
|
|
|
+ <el-radio-group v-model="instrumentForm.type" @change="changeTop">
|
|
|
+ <template v-if="seTypeList.length > 0">
|
|
|
+ <el-radio-button v-for="(item, index) in seTypeList" :key="index" :label="item.name" :value="item.name"
|
|
|
+ plain />
|
|
|
+ </template>
|
|
|
+ <el-radio-button label="p" value="p" disabled
|
|
|
+ plain />
|
|
|
+
|
|
|
</el-radio-group>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
- <el-row :gutter="20">
|
|
|
+ <!-- <el-row :gutter="20">
|
|
|
<el-col :span="20" style="margin-top: 10px">
|
|
|
<el-button type="primary" plain>新增</el-button>
|
|
|
<el-button plain>删除</el-button>
|
|
|
</el-col>
|
|
|
- </el-row>
|
|
|
+ </el-row> -->
|
|
|
<el-row :gutter="20">
|
|
|
<el-col :span="20" style="margin-top: 10px">
|
|
|
- <el-button type="primary">NA</el-button>
|
|
|
+ <el-radio-group v-model="instrumentForm.element" @change="changeElement">
|
|
|
+ <el-radio-button v-for="(item, index) in selectInfo?.list" :key="index" :value="item.cal_condition"
|
|
|
+ plain>{{
|
|
|
+ item.cal_condition && item.cal_condition != '' && item.cal_condition != ' ' ? item.cal_condition : 'NA'
|
|
|
+ }}</el-radio-button>
|
|
|
+ </el-radio-group>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<el-row :gutter="20" style="margin-top: 10px">
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="检定条件" prop="verification">
|
|
|
- <el-input v-model="instrumentForm.verification" clearable />
|
|
|
+ <el-input disabled v-model="selectTable.cal_condition" clearable />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="证书编号" prop="certificate">
|
|
|
- <el-input v-model="instrumentForm.certificate" clearable />
|
|
|
+ <el-input disabled v-model="selectTable.cal_calsn" clearable />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<el-row :gutter="20">
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="检定员编号" prop="inspector">
|
|
|
- <el-input v-model="instrumentForm.inspector" clearable />
|
|
|
+ <el-input disabled v-model="selectTable.cal_calman" clearable />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="检定参数类型" prop="typeParameter" style="display: flex; align-items: center">
|
|
|
- <el-radio-group v-model="instrumentForm.typeParameter">
|
|
|
- <el-radio value="1" size="large">校准系数</el-radio>
|
|
|
- <el-radio value="2" size="large">多点校准系数</el-radio>
|
|
|
+ <el-radio-group disabled v-model="selectTable.cal_type">
|
|
|
+ <el-radio :value="1" size="large">校准系数</el-radio>
|
|
|
+ <el-radio :value="2" size="large">多点校准系数</el-radio>
|
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
- <el-row :gutter="20" v-if="instrumentForm.type === 'PWD'">
|
|
|
+ <el-row :gutter="20" v-if="selectTable.cal_type === 1">
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="校准系数" prop="coefficient">
|
|
|
- <el-input v-model="instrumentForm.coefficient" clearable />
|
|
|
+ <el-input disabled v-model="selectTable.cal_param" clearable />
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
- <div v-if="instrumentForm.typeParameter === '2'" class="table-box" style="margin-top: 10px;height: 160px">
|
|
|
- <el-table stripe ref="tableRef" :border="true" :data="processTableData2" size="small">
|
|
|
+ <div v-if="selectTable.cal_type === 2" class="table-box" style="margin-top: 10px;height: 200px">
|
|
|
+ <el-table stripe ref="tableRef" :border="true" :data="selectTable.cal_param_list" size="small">
|
|
|
<template v-for="item in columns2" :key="item">
|
|
|
<el-table-column v-bind="item" :align="item.align ?? 'left'" :reserve-selection="item.type == 'selection'"
|
|
|
:show-overflow-tooltip="true">
|
|
|
<template v-if="item.prop === 'operation'">
|
|
|
<el-tooltip class="box-item" effect="dark" content="删除" placement="top">
|
|
|
- <el-button type="primary" link>
|
|
|
+ <el-button type="primary" disabled link>
|
|
|
<el-icon>
|
|
|
<Delete />
|
|
|
</el-icon>
|
|
@@ -148,8 +160,8 @@
|
|
|
</el-form>
|
|
|
<template #footer>
|
|
|
<div class="dialog-footer">
|
|
|
- <el-button @click="cancel">取 消</el-button>
|
|
|
- <el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
+ <el-button @click="cancel" disabled>取 消</el-button>
|
|
|
+ <el-button type="primary" @click="submitForm" disabled>确 定</el-button>
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-dialog>
|
|
@@ -160,7 +172,8 @@
|
|
|
import { defineProps, reactive, ref, onMounted } from "vue";
|
|
|
import { ColumnProps } from "@/components/ProTable/interface";
|
|
|
import { getQuerCertList } from "@/api/modules/allData";
|
|
|
-const props = defineProps(['selectData'])
|
|
|
+const props = defineProps(['selectData','sensorList'])
|
|
|
+
|
|
|
|
|
|
// 获取检定证书
|
|
|
const certData = ref<any>([]);
|
|
@@ -169,20 +182,78 @@ const querCert = ref<any>({
|
|
|
pageSize: 1000,
|
|
|
pageNum: 1,
|
|
|
})
|
|
|
+
|
|
|
+const stationCal = ref<any>([])
|
|
|
const getCertList = async () => {
|
|
|
const { data } = await getQuerCertList({ ...querCert.value, asCode: props.selectData?.as_code });
|
|
|
- console.log(data, '检定证书')
|
|
|
- certData.value = data.list.map(item=>{
|
|
|
- return item.se_mode===0
|
|
|
- })
|
|
|
- certData2.value = data.list.map(item=>{
|
|
|
- return item.se_mode===1
|
|
|
- })
|
|
|
+ stationCal.value = data?.list
|
|
|
+
|
|
|
+
|
|
|
+ certData.value = props.sensorList?.filter(item =>
|
|
|
+ item.se_state == 1
|
|
|
+ )
|
|
|
+ certData.value.forEach(obj1 => {
|
|
|
+ const matchingObj2 = data?.list?.find(obj2 => obj2.se_type === obj1.se_type);
|
|
|
+ if (matchingObj2) {
|
|
|
+ obj1.cal_sn = matchingObj2.cal_sn;
|
|
|
+ obj1.cal_date_i = matchingObj2.cal_date_i;
|
|
|
+ obj1.cal_period = matchingObj2.cal_period;
|
|
|
+ obj1.next_period = addMonthsToTimestamp(matchingObj2.cal_date_i, matchingObj2.cal_period)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ certData2.value = props.sensorList?.filter(item =>
|
|
|
+ item.se_state == 2
|
|
|
+ )
|
|
|
+ certData2.value.forEach(obj1 => {
|
|
|
+ const matchingObj2 = data?.list?.find(obj2 => obj2.se_type === obj1.se_type);
|
|
|
+ if (matchingObj2) {
|
|
|
+ obj1.cal_sn = matchingObj2.cal_sn;
|
|
|
+ obj1.cal_date_i = matchingObj2.cal_date_i;
|
|
|
+ obj1.cal_period = matchingObj2.cal_period;
|
|
|
+ obj1.next_period = addMonthsToTimestamp(matchingObj2.cal_date_i, matchingObj2.cal_period)
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
-const radio1 = ref<any>(0) //检定参数类型
|
|
|
+const changeTop = (val: any) => {
|
|
|
+ selectInfo.value = seTypeList.value?.find(obj => obj.name === val);
|
|
|
+ // instrumentForm.value.type = selectInfo?.value.name
|
|
|
+ instrumentForm.value.element = selectInfo.value?.list[0].cal_condition
|
|
|
+
|
|
|
+ selectTable.value = selectInfo.value?.list[0]
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+const changeElement = (val: any) => {
|
|
|
+ selectTable.value = selectInfo.value?.list?.find(obj => obj.cal_condition === val);
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+//时间戳转换为指定格式的日期字符串
|
|
|
+function formatDate(timestamp) {
|
|
|
+ const date = new Date(timestamp * 1000); // 将时间戳转换为毫秒
|
|
|
+ const year = date.getFullYear();
|
|
|
+ const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
|
+ const day = String(date.getDate()).padStart(2, '0');
|
|
|
+ return `${year}-${month}-${day}`;
|
|
|
+}
|
|
|
+
|
|
|
+// 获取指定月份之后的日期
|
|
|
+function addMonthsToTimestamp(timestampInSeconds, months) {
|
|
|
+ const date = new Date(timestampInSeconds * 1000); // 乘以1000将秒转换为毫秒
|
|
|
+ // 例如,设置月份为13会将年份增加1并将月份设置为1
|
|
|
+ date.setMonth(date.getMonth() + months);
|
|
|
+ // 格式化日期为yyyy-mm-dd字符串
|
|
|
+ const year = date.getFullYear();
|
|
|
+ const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,所以需要加1,并用padStart确保是两位数
|
|
|
+ const day = String(date.getDate()).padStart(2, '0'); // 用padStart确保是两位数
|
|
|
+ return `${year}-${month}-${day}`;
|
|
|
+}
|
|
|
+
|
|
|
+const radio1 = ref<any>(1) //检定参数类型
|
|
|
|
|
|
|
|
|
|
|
@@ -205,6 +276,7 @@ const rules = ref<any>(
|
|
|
const initFormData = ref<any>(
|
|
|
{
|
|
|
type: 'PWS',
|
|
|
+ element: '',
|
|
|
verification: '',
|
|
|
certificate: '',
|
|
|
inspector: '',
|
|
@@ -216,6 +288,7 @@ const initFormData = ref<any>(
|
|
|
|
|
|
const instrumentForm = ref<any>({
|
|
|
type: 'PWS',
|
|
|
+ element: '',
|
|
|
verification: '',
|
|
|
certificate: '',
|
|
|
inspector: '',
|
|
@@ -232,8 +305,60 @@ const handleAdd = () => {
|
|
|
}
|
|
|
|
|
|
/** 修改按钮操作 */
|
|
|
+
|
|
|
+const seTypeList = ref<any>([])
|
|
|
+const selectInfo = ref<any>({})
|
|
|
+const selectTable = ref<any>({
|
|
|
+ cal_condition: '',
|
|
|
+ cal_calsn: '',
|
|
|
+ cal_calman: '',
|
|
|
+ cal_type: 1,
|
|
|
+ cal_param: '',
|
|
|
+ cal_param_list: [],
|
|
|
+})
|
|
|
+const list = ref<any>([])
|
|
|
const handleUpdate = async (row?: any) => {
|
|
|
reset();
|
|
|
+ list.value = stationCal.value?.filter(obj => obj.se_type === row.se_type);
|
|
|
+ const groupedData = list.value?.reduce((acc, item) => {
|
|
|
+ const { cal_probeid } = item;
|
|
|
+ if (!acc[cal_probeid]) {
|
|
|
+ acc[cal_probeid] = [];
|
|
|
+ }
|
|
|
+ acc[cal_probeid].push(item);
|
|
|
+ return acc;
|
|
|
+ }, {});
|
|
|
+
|
|
|
+ if (groupedData) {
|
|
|
+ seTypeList.value = Object.keys(groupedData).map(key => ({
|
|
|
+ name: key,
|
|
|
+ list: groupedData[key]
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ seTypeList.value.forEach(item => {
|
|
|
+ item.list?.forEach(obj => {
|
|
|
+ obj.cal_param_list = obj.cal_param.split(',').map(pair => {
|
|
|
+ const [checkKey, changeKey] = pair.split('/');
|
|
|
+ return { checkKey, changeKey };
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+ selectInfo.value = seTypeList.value[0]
|
|
|
+ instrumentForm.value.type = seTypeList?.value[0]?.name
|
|
|
+ instrumentForm.value.element = seTypeList?.value[0]?.list[0].cal_condition
|
|
|
+ selectTable.value = seTypeList.value.length > 0 ? seTypeList.value[0]?.list[0] : {
|
|
|
+ cal_condition: '',
|
|
|
+ cal_calsn: '',
|
|
|
+ cal_calman: '',
|
|
|
+ cal_type: 1,
|
|
|
+ cal_param: '',
|
|
|
+ cal_param_list: [],
|
|
|
+ }
|
|
|
+
|
|
|
+ // instrumentForm.value = { ...instrumentForm.value, ...seTypeList.value[0].list[0] }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
dialog.visible = true;
|
|
|
dialog.title = "编辑";
|
|
|
dialog.isMode = false;
|
|
@@ -282,11 +407,11 @@ const processTableData = ref([
|
|
|
|
|
|
// 表格配置项
|
|
|
const columns = reactive<ColumnProps[]>([
|
|
|
- { prop: "a", label: "检定项目" },
|
|
|
- { prop: "b", label: "传感器序列号" },
|
|
|
- { prop: "c", label: "检定日期" },
|
|
|
- { prop: "d", label: "检定周期(月)" },
|
|
|
- { prop: "e", label: "下一次检定日期" },
|
|
|
+ { prop: "se_name", label: "检定项目" },
|
|
|
+ { prop: "cal_sn", label: "传感器序列号" },
|
|
|
+ { prop: "cal_date_i", label: "检定日期" },
|
|
|
+ { prop: "cal_period", label: "检定周期(月)" },
|
|
|
+ { prop: "next_period", label: "下一次检定日期" },
|
|
|
{ prop: "operation", label: "操作", width: 150, align: 'center' }
|
|
|
]);
|
|
|
|
|
@@ -301,8 +426,8 @@ const processTableData2 = ref([
|
|
|
|
|
|
// 表格配置项
|
|
|
const columns2 = reactive<ColumnProps[]>([
|
|
|
- { prop: "a", label: "检定值" },
|
|
|
- { prop: "b", label: "修正值" },
|
|
|
+ { prop: "checkKey", label: "检定值" },
|
|
|
+ { prop: "changeKey", label: "修正值" },
|
|
|
{ prop: "operation", label: "操作", width: 150, align: 'center' }
|
|
|
]);
|
|
|
|