From 2b2310c50c0a45b2a8fe9964492ee3a96e0f465d Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期二, 22 四月 2025 09:46:45 +0800
Subject: [PATCH] 检验任务调整

---
 src/views/business/inspectionTask/components/NetworkAnalyzerDataAcquisition.vue |  286 +++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 files changed, 268 insertions(+), 18 deletions(-)

diff --git a/src/views/business/inspectionTask/components/NetworkAnalyzerDataAcquisition.vue b/src/views/business/inspectionTask/components/NetworkAnalyzerDataAcquisition.vue
index c1b881f..58c234d 100644
--- a/src/views/business/inspectionTask/components/NetworkAnalyzerDataAcquisition.vue
+++ b/src/views/business/inspectionTask/components/NetworkAnalyzerDataAcquisition.vue
@@ -1,7 +1,26 @@
 <template>
   <div class="btns">
-    <el-button type="primary" size="small" @click="getMetadata()">杩涘彛缃戝垎浠暟閲�</el-button>
-    <el-button type="primary" size="small">鍥戒骇缃戝垎浠暟閲�</el-button>
+    <el-button type="primary" size="small" @click="getMetadata()" v-if="isShowBtn">杩涘彛缃戝垎浠暟閲�</el-button>
+    <el-button type="primary" size="small" @click="getMetadata0" v-if="isShowBtn">鍥戒骇缃戝垎浠暟閲�</el-button>
+    <el-dialog title="鍥戒骇缃戝垎" :visible.sync="dialogVisible" width="30%">
+      <el-form ref="form" :model="form" label-width="50px" :rules="rules">
+        <el-form-item label="IP">
+          <el-input v-model="form.serverIp" disabled></el-input>
+        </el-form-item>
+        <el-form-item label="绔彛">
+          <el-input v-model="form.serverPort" disabled></el-input>
+        </el-form-item>
+        <el-form-item label="閫氶亾" prop="memoryDir">
+          <el-select v-model="form.memoryDir" placeholder="璇烽�夋嫨">
+            <el-option :label="item" :value="item" v-for="(item, index) in channel" :key="index"></el-option>
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <span slot="footer" class="dialog-footer">
+        <el-button @click="dialogVisible = false">鍙� 娑�</el-button>
+        <el-button type="primary" @click="saveForm">纭� 瀹�</el-button>
+      </span>
+    </el-dialog>
   </div>
 </template>
 
@@ -14,25 +33,34 @@
   data() {
     return {
       itemConfig: [],
-      itemListNew: []
+      itemListNew: [],
+      dialogVisible: false,
+      form: {},
+      channel: [],
+      rules: {
+        memoryDir: [
+          { required: true, message: '璇烽�夋嫨閫氶亾', trigger: 'change' }
+        ],
+      },
+      isShowBtn: false,//鏄惁灞曠ず鎸夐挳
     }
   },
-  mounted() {
-    // console.log(this.param, this.itemList)
-
-  },
   methods: {
-    async getMetadata() {
-      console.log(this.param, this.itemList)
+    init() {
       this.itemListNew = this.HaveJson(this.itemList)
-
       let equip = null;
       for (let n in this.param) {
-        let obj = this.equipOptions.find(m => m.value == this.param[n].equipValue[0].v.v)
+        let obj = this.equipOptions.find(m => this.param[n].equipValue && this.param[n].equipValue.length > 0 && (m.value == this.param[n].equipValue[0].v.v))
         if (obj && obj.label && obj.label.indexOf('缃戠粶鍒嗘瀽浠�') > -1) {
           equip = obj
+          this.isShowBtn = true
         }
       }
+      return equip
+    },
+    // 杩涘彛缃戝垎浠暟閲�
+    async getMetadata() {
+      let equip = this.init()
       if (equip) {
         await this.getItemConfig(equip)
         this.itemListNew.forEach(item => {
@@ -45,6 +73,19 @@
           }
         })
         this.gatherNetworkAnalyzerSampleItem()
+      }
+    },
+    // 鍥戒骇缃戝垎浠暟閲�
+    getMetadata0() {
+      let equip = this.init()
+      if (equip) {
+        this.form = {
+          serverIp: equip.ip,
+          serverPort: equip.port,
+          memoryDir: null
+        }
+        this.channel = equip.channel ? equip.channel.split(',') : []
+        this.dialogVisible = true
       }
     },
     async getItemConfig(param) {
@@ -73,6 +114,7 @@
       if (temperatureItem) {
         temperatureItem.itemValue = this.param[temperatureItem.id].resValue.v.v
       }
+      console.log('temperatureItem', temperatureItem)
       const temperature = temperatureItem ? temperatureItem.itemValue : null
 
       const cdItem = this.itemListNew.find(m => m.inspectionItem == '鐢电紗闀垮害')
@@ -137,7 +179,7 @@
               ) {
                 dataItem = {
                   Column1: item.inspectionItem,
-                  Column2: item.itemReference,// TODO: 鐩镐綅宸�-鍛ㄦ湡鏁�
+                  // Column2: item.itemReference,// TODO: 鐩镐綅宸�-鍛ㄦ湡鏁�
                   TD: item.aisle == null ? '0' : item.aisle,
                   BW: item.position == null ? '0' : item.position
                 }
@@ -151,12 +193,13 @@
                   flag = false
                   flagMsg = flagMsg + item.inspectionItem + ',閮ㄤ綅鍊间负绌猴紱'
                 }
-                if (
-                  item.itemReference == null ||
-                  item.itemReference.indexOf('鏁�') < 0
-                ) {
-                  phaseDifferenceFlag = false
-                }
+                // TODO: 
+                // if (
+                //   item.itemReference == null ||
+                //   item.itemReference.indexOf('鏁�') < 0
+                // ) {
+                //   phaseDifferenceFlag = false
+                // }
               } else if (item.inspectionItem.indexOf('鐗规�ч樆鎶�') > -1 && item.inspectionItemType == 1
               ) {
                 dataItem = {
@@ -193,6 +236,7 @@
                       if (flag) {
                         const dataArrStr = JSON.stringify(dataArr)
                         requireData = preStr + dataArrStr + ednStr
+                        console.log(3333, requireData)
                         this.gatherLoadingShow = true
                         $.ajax({
                           type: 'post',
@@ -266,6 +310,212 @@
         this.$message.error('鐢电紗闀垮害鍜岄�佹闀垮害杞崲绯绘暟涓嶈兘涓虹┖')
       }
     },
+    saveForm() {
+      this.$refs.form.validate((valid) => {
+        if (valid) {
+          // alert('submit!');
+          this.GuochanNetworkAnalyzer()
+        } else {
+          console.log('error submit!!');
+          return false;
+        }
+      });
+    },
+    // 鍥戒骇缃戝垎浠�
+    GuochanNetworkAnalyzer(type) {
+      const { findFromCL } = this
+      const temperture = findFromCL('娓╁害')
+      const num = findFromCL('鐢电紗闀垮害') * findFromCL('閫佹闀垮害杞崲绯绘暟')
+      const length = num ? this.roundFun(num, 6) : undefined
+      const capacity = findFromCL('鐢靛锛堟祴璇曞�硷級')
+      const Xiangweicha = this.itemListNew.find(m => m.inspectionItem.indexOf('鐩镐綅宸�') > -1)
+      let cycle
+      if (
+        Xiangweicha &&
+        Xiangweicha.itemReference &&
+        Xiangweicha.itemReference.match(/鍛ㄦ湡鏁�(\d+)/)
+      ) {
+        cycle = Xiangweicha.itemReference.match(/鍛ㄦ湡鏁�(\d+)/)[1]
+      }
+      const index1 = this.itemListNew.findIndex(m => m.inspectionItem.indexOf('鐗规�ч樆鎶�') > -1)
+
+      // 鍥戒骇
+      //   娓╁害
+      //   鐢电紗闀垮害鍜岄�佹闀垮害杞崲绯绘暟
+      //      鐢靛锛堟祴璇曞�硷級-- 鐢靛鏍囧噯涓嶈兘涓虹┖
+      //      鐩镐綅宸�  瀛樺湪
+      //   鐗规�ч樆鎶�  瀛樺湪
+      //      鐩镐綅宸殑鍛ㄦ湡
+      // 杞х汗
+      //   鐗规�ч樆鎶�  瀛樺湪
+      // 楂樻俯
+      //   娓╁害
+      //   鐢电紗闀垮害鍜岄�佹闀垮害杞崲绯绘暟
+      //   鐗规�ч樆鎶�  瀛樺湪
+      // 浜俊
+      //   娓╁害
+      //   鐢电紗闀垮害鍜岄�佹闀垮害杞崲绯绘暟
+      //   鐗规�ч樆鎶�  瀛樺湪
+
+      if (index1 < 0) {
+        this.$message.error('鏃犲钩鍧囩壒鎬ч樆鎶�')
+        return
+      }
+      if (type === '鍥戒骇') {
+        if (!capacity) {
+          this.$message.error('鐢靛鏍囧噯涓嶈兘涓虹┖')
+          return
+        }
+        if (!Xiangweicha) {
+          this.$message.error('鏃犵浉浣嶅樊')
+          return
+        }
+        if (!cycle) {
+          this.$message.error('鏃犵浉浣嶅樊鍛ㄦ湡鏁�')
+          return
+        }
+      }
+      if (type === '鍥戒骇' || type === '楂樻俯' || type === '浜俊') {
+        if (!temperture) {
+          this.$message.error('娓╁害涓嶈兘涓虹┖')
+          return
+        }
+        if (!length) {
+          this.$message.error('鐢电紗闀垮害鍜岄�佹闀垮害杞崲绯绘暟涓嶈兘涓虹┖')
+          return
+        }
+      }
+
+      const loading = this.$loading({
+        lock: true,
+        text: '鏁版嵁閲囬泦涓�',
+        spinner: 'el-icon-loading',
+        background: 'rgba(0, 0, 0, 0.7)'
+      })
+      const params = {
+        ...this.form,
+        temperture,
+        length,
+        cycle,
+        capacity
+      }
+      getTCPValuesNew(params)
+        .then((res) => {
+          if (res.data.code === 0) {
+            // 娴嬭瘯鍊糰cqItemValue -- decimalVal
+            // 璁$畻鍊糲alItemValue -- measureValue
+            // 閫氶亾aisle -- channel 绐楀彛
+            // 閮ㄤ綅position -- trace 鍚屼竴绐楀彛涓嬬殑涓嶅悓杞ㄨ抗绾�
+            // 鍊糹temValue --
+            const data = res.data.data.filter((e) => e.ifLegal)
+            data.forEach((e) => {
+              if (e.decimalVal) {
+                e.decimalVal = Math.abs(e.decimalVal)
+              }
+              if (e.measureValue) {
+                e.measureValue = Math.abs(e.measureValue)
+              }
+            })
+
+            this.dataList['閲囬泦椤�'].forEach((e) => {
+              if (e.itemName.indexOf('琛板噺') > -1) {
+                const d = data.find((d) => {
+                  const match = d.label.match(/decay_(\d+)m/)
+                  return (
+                    match &&
+                    (match[1] + 'MHz琛板噺' === e.itemName ||
+                      match[1] + 'MHZ琛板噺' === e.itemName ||
+                      +match[1] / 1000 + 'GHz琛板噺' === e.itemName ||
+                      +match[1] / 1000 + 'GHZ琛板噺' === e.itemName) &&
+                    d.channel === +e.aisle
+                  )
+                })
+                if (d) {
+                  e.acqItemValue = this.roundFun(d.decimalVal, 3)
+                  e.calItemValue = this.roundFun(d.measureValue, 3)
+                  // e.itemValue = Math.min(e.acqItemValue, e.calItemValue)
+                  e.itemValue = e.calItemValue
+                }
+              } else if (e.itemName.indexOf('椹绘尝姣�') > -1) {
+                const trace1 = data.find((d) => {
+                  const match = d.label.match(/swr_(\d+)m/)
+                  return match && d.channel === +e.aisle && d.trace === 1
+                })
+                const trace2 = data.find((d) => {
+                  const match = d.label.match(/swr_(\d+)m/)
+                  if (type === '杞х汗' && d.trace === 5) {
+                    d.trace = 2
+                    // 杞х汗缃戝垎浠厤缃笉姝g‘锛屾墜鍔ㄤ慨姝�
+                  }
+                  return match && d.channel === +e.aisle && d.trace === 2
+                })
+                let [value1, value2, match1, match2] = [null, null, null, null]
+                if (trace1) {
+                  value1 = this.roundFun(trace1.decimalVal, 3)
+                  match1 = this.roundFun(trace1.label.match(/swr_(\d+)m/)[1], 3)
+                  e.acqItemValue = `${value1}|${match1}`
+                }
+                if (trace2) {
+                  value2 = this.roundFun(trace2.decimalVal, 3)
+                  match2 = this.roundFun(trace2.label.match(/swr_(\d+)m/)[1], 3)
+                  e.calItemValue = `${value2}|${match2}`
+                }
+                if (trace1 || trace2) {
+                  e.itemValue = Math.max(value1, value2)
+                }
+              } else if (e.itemName.indexOf('鐩镐綅宸�') > -1) {
+                const d = data.find((d) => {
+                  return d.channel === +e.aisle && d.label === 'pha_mean'
+                })
+                if (d) {
+                  e.acqItemValue = this.roundFun(d.decimalVal, 3)
+                }
+              } else if (e.itemName.indexOf('鐗规�ч樆鎶�') > -1) {
+                const trace1 = data.find((d) => {
+                  return (
+                    d.channel === +e.aisle &&
+                    d.trace === 1 &&
+                    d.label === 'impedance_mean'
+                  )
+                })
+                const trace2 = data.find((d) => {
+                  return (
+                    d.channel === +e.aisle &&
+                    d.trace === 2 &&
+                    d.label === 'impedance_mean'
+                  )
+                })
+                let [value1, value2] = [null, null]
+                if (trace1) {
+                  value1 = this.roundFun(trace1.decimalVal, 3)
+                  e.calItemValue = this.roundFun(trace1.calculateValue, 3)
+                  e.itemValue = e.calItemValue
+                }
+                if (trace2) {
+                  value2 = this.roundFun(trace2.decimalVal, 3)
+                  e.calItemValue = this.roundFun(trace2.calculateValue, 3)
+                  e.itemValue = e.calItemValue
+                }
+                if (trace1 || trace2) {
+                  e.acqItemValue = `${value1}${value1 && value2 ? '|' : ''
+                    }${value2}`
+                }
+              }
+            })
+          }
+        })
+        .finally(() => {
+          loading.close()
+        })
+    },
+    findFromCL(type) {
+      const obj = this.itemListNew.find(m => m.inspectionItem == type)
+      if (obj) {
+        return this.param[obj.id].resValue.v.v
+      } else {
+        return ''
+      }
+    },
     roundFun(value, n) {
       if (value === null) {
         return null

--
Gitblit v1.9.3