章志文 hai 2 semanas
pai
achega
cf7ae3fc8d

+ 2 - 2
src/views/system/stations/components/strategySafeguard.vue

@@ -762,7 +762,7 @@ const getItemValue=(itemValue)=>{
 }
 
 const operatorDataName = (id) => {
-  const item = operatorList.find(item => item.value == parseInt(id));
+  const item = operatorList?.find(item => item.value == parseInt(id));
   if (item) {
     return  item.label;
   } else {
@@ -796,7 +796,7 @@ const getAllRgDataList = async () => {
   elementList.value = data.list
 };
 const findDataName = (id) => {
-  const item = elementList.value.find(item => item.data_id == parseInt(id));
+  const item = elementList.value?.find(item => item.data_id == parseInt(id));
   if (item) {
     return  item.data_name;
   } else {

+ 45 - 33
src/views/system/stations/components/translation.vue

@@ -125,9 +125,9 @@
 
       </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 type="primary" plain disabled> 上一步 </el-button>
+        <el-button type="primary" disabled> 下一步 </el-button>
       </div>
     </div>
   </div>
@@ -138,7 +138,7 @@ import { defineProps, reactive, ref, onMounted } from "vue";
 import { ColumnProps } from "@/components/ProTable/interface";
 import { getYassensorlist, getUserList, getYallSensorList, getPlatformList, getAllpartlist } from "@/api/modules/allData";
 
-const props = defineProps(['selectData'])
+const props = defineProps(['selectData','sensorList'])
 
 const elements = ref<any>([])
 const pageable = ref<any>({
@@ -152,40 +152,52 @@ const getInfo = async () => {
   processTableData.value = data[props.selectData?.as_code]
 }
 
-const platformInfo=ref<any>({})
+const platformInfo=ref<any>({
+  fybsjjgList:['',''],
+  mfbqytjList:['',''],
+  mfsdbdxhgxsList:['',''],
+  fxcgqzbpcList:['',''],
+  lbszdfxhqx:'',
+  jyyszdfxhqx:'',
+  ljszdfxhqx:'',
+  bdy300mdyszdfxhqx:'',
+  typeList:[{
+    
+  }]
+})
 const getPlatformListInfo = async () => {
   let { data } = await getPlatformList({ pageNum: 1, pageSize: 20, asCode: props.selectData?.as_code })
-  const dataInfo = data.list[0]
+  const dataInfo = data?.list?data.list[0]:{}
   platformInfo.value={
-    fybsjjgList:dataInfo.fybsjjg.split('|'),
-    mfbqytjList:dataInfo.mfbqytj.split('|'),
-    mfsdbdxhgxsList:dataInfo.mfsdbdxhgxs.split('|'),
-    fxcgqzbpcList:dataInfo.fxcgqzbpc.split('|'),
-    lbszdfxhqx:dataInfo.lbszdfxhqs,
-    jyyszdfxhqx:dataInfo.jyyszdfxhqs,
-    ljszdfxhqx:dataInfo.ljszdfxhqs,
-    bdy300mdyszdfxhqx:dataInfo.bdy300mdyszdfxhqs,
+    fybsjjgList:dataInfo?.fybsjjg?.split('|'),
+    mfbqytjList:dataInfo?.mfbqytj?.split('|'),
+    mfsdbdxhgxsList:dataInfo?.mfsdbdxhgxs?.split('|'),
+    fxcgqzbpcList:dataInfo?.fxcgqzbpc?.split('|'),
+    lbszdfxhqx:dataInfo?.lbszdfxhqs,
+    jyyszdfxhqx:dataInfo?.jyyszdfxhqs,
+    ljszdfxhqx:dataInfo?.ljszdfxhqs,
+    bdy300mdyszdfxhqx:dataInfo?.bdy300mdyszdfxhqs,
     typeList:[{
       name:'球状干湿表(自然通风速度)',
-      nofrozen:dataInfo.qzgsb_zrtfsd.split('|')[1],
+      nofrozen:dataInfo?.qzgsb_zrtfsd?.split('|')[1],
 
-      frozen:dataInfo.qzgsb_zrtfsd.split('|')[2],
+      frozen:dataInfo?.qzgsb_zrtfsd?.split('|')[2],
     },{
       name:'通风干湿表(通风速度0.8m/s)',
-      nofrozen:dataInfo.tfgsb_0_8.split('|')[1],
-      frozen:dataInfo.tfgsb_0_8.split('|')[2],
+      nofrozen:dataInfo?.tfgsb_0_8?.split('|')[1],
+      frozen:dataInfo?.tfgsb_0_8?.split('|')[2],
     },{
       name:'通风干湿表(通风速度0.5m/s)',
-      nofrozen:dataInfo.tfgsb_0_5.split('|')[1],
-      frozen:dataInfo.tfgsb_0_5.split('|')[2],
+      nofrozen:dataInfo?.tfgsb_0_5?.split('|')[1],
+      frozen:dataInfo?.tfgsb_0_5?.split('|')[2],
     },{
       name:'球状干湿表(自然通风)*',
-      nofrozen:dataInfo.qzgsb_zrtf.split('|')[1],
-      frozen:dataInfo.qzgsb_zrtf.split('|')[2],
+      nofrozen:dataInfo?.qzgsb_zrtf?.split('|')[1],
+      frozen:dataInfo?.qzgsb_zrtf?.split('|')[2],
     },{
       name:'柱状干湿表(自然通风)*',
-      nofrozen:dataInfo.zzgsb_zrtf.split('|')[1],
-      frozen:dataInfo.zzgsb_zrtf.split('|')[2],
+      nofrozen:dataInfo?.zzgsb_zrtf?.split('|')[1],
+      frozen:dataInfo?.zzgsb_zrtf?.split('|')[2],
     }]
   }
 }
@@ -197,12 +209,12 @@ const getAllPart = async () => {
   allPart.value = data.list
 }
 
-// 获取传感器字典
-const sensorList = ref<any>([]);
-const getSensorList = async () => {
-  const { data } = await getYallSensorList();
-  sensorList.value = data.list
-};
+// // 获取传感器字典
+// const sensorList = ref<any>([]);
+// const getSensorList = async () => {
+//   const { data } = await getYallSensorList();
+//   sensorList.value = data.list
+// };
 
 const handleUpdate = () => {
 }
@@ -224,10 +236,10 @@ const handleSelectionChange = (val: []) => {
 // 通过给定的type去查照
 function findNameByType(check, type) {
   if (check === 1) {
-    let foundObject = allPart.value.find(obj => obj.part_type === type);
+    let foundObject = allPart.value?.find(obj => obj.part_type === type);
     return foundObject ? foundObject.part_name : '参数错误'; // 如果找到了对象,返回其name属性,否则返回null
   } else {
-    let foundObject = sensorList.value.find(obj => obj.se_type === type);
+    let foundObject = props.sensorList?.find(obj => obj.se_type === type);
     return foundObject ? foundObject.se_name : '参数错误'; // 如果找到了对象,返回其name属性,否则返回null
   }
 }
@@ -278,7 +290,7 @@ const columns2 = reactive<ColumnProps[]>([
 
 onMounted(() => {
   getAllPart()
-  getSensorList()
+  // getSensorList()
   getInfo()
   getPlatformListInfo()
 });

+ 171 - 46
src/views/system/stations/components/verificationCertificate.vue

@@ -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' }
 ]);
 

+ 13 - 2
src/views/system/stations/index.vue

@@ -89,10 +89,10 @@
           <ParametersBasic :select-data="rowItem"></ParametersBasic>
         </el-tab-pane>
         <el-tab-pane label="观测要素">
-         <Translation :select-data="rowItem"></Translation>
+         <Translation :select-data="rowItem" :sensorList="sensorList"></Translation>
         </el-tab-pane>
         <el-tab-pane label="仪器检定证">
-          <VerificationCertificate :select-data="rowItem"></VerificationCertificate>
+          <VerificationCertificate :select-data="rowItem" :sensorList="sensorList"></VerificationCertificate>
         </el-tab-pane>
         <el-tab-pane label="阈值设置">
           <Threshold :select-data="rowItem"></Threshold>
@@ -121,8 +121,18 @@ import {ref, reactive, computed, onMounted} from "vue";
 import { ColumnProps } from "@/components/ProTable/interface";
 import { ElMessageBox } from 'element-plus'
 import {useUserStore} from "@/stores/modules/user";
+import { getYallSensorList } from "@/api/modules/allData";
 
 
+
+
+
+// 获取传感器字典
+const sensorList = ref<any>([]);
+const getSensorList = async () => {
+  const { data } = await getYallSensorList();
+  sensorList.value = data.list
+};
 //搜索站号
 const selectedData= ref([])
 const userStore = useUserStore();
@@ -312,6 +322,7 @@ const typeList= [
   }
 ]
 onMounted(() => {
+  getSensorList()
   // 在组件挂载时,将计算属性 initList 的值赋值给 showList
   showList.value = [...initList.value];
 });