From 6896e8f3aa1e2b5a20eb430792e0e74112c5a44c Mon Sep 17 00:00:00 2001
From: Crunchy <3114200645@qq.com>
Date: 星期一, 22 七月 2024 17:15:02 +0800
Subject: [PATCH] 设备数采配置 调整

---
 src/components/do/b6-device-management/b6-data-acquisition-config.vue |  126 +++++++++++++++++++++++++++++++++++++----
 1 files changed, 112 insertions(+), 14 deletions(-)

diff --git a/src/components/do/b6-device-management/b6-data-acquisition-config.vue b/src/components/do/b6-device-management/b6-data-acquisition-config.vue
index a37163d..7ffe061 100644
--- a/src/components/do/b6-device-management/b6-data-acquisition-config.vue
+++ b/src/components/do/b6-device-management/b6-data-acquisition-config.vue
@@ -4,6 +4,7 @@
       <el-row class="title">
         <el-col :span="6" style="padding-left: 20px;text-align: left;">鏁伴噰閰嶇疆</el-col>
         <el-col :span="18" style="text-align: right;">
+          <el-button size="medium" type="primary" @click="fileConfiguration">鏂囦欢閰嶇疆</el-button>
           <el-button size="medium" @click="$parent.closeDataVue()">
             <span style="color: #3A7BFA;">杩斿洖</span>
           </el-button>
@@ -14,9 +15,18 @@
       <el-table :data="tableList.slice((page.current - 1) * page.size, page.current * page.size)"
                 border tooltip-effect="dark" style="width: 100%;" height="100%">
         <el-table-column type="index" label="搴忓彿" align="center" width="65"></el-table-column>
-        <el-table-column prop="inspectionItemSubclass" align="center" label="妫�楠岄」"></el-table-column>
-        <el-table-column prop="insProductItem" align="center" label="妫�楠岄」瀛愰」">
-        </el-table-column>
+        <el-table-column prop="deviceName" align="center" min-width="100" label="璁惧鍚嶇О"></el-table-column>
+        <el-table-column prop="fileType" align="center" label="鏂囦欢鍚庣紑"></el-table-column>
+        <el-table-column prop="collectUrl" align="center" min-width="100" show-overflow-tooltip label="閲囬泦鍦板潃"></el-table-column>
+        <el-table-column prop="storageUrl" align="center" min-width="100" show-overflow-tooltip label="瀛樺偍鍦板潃"></el-table-column>
+        <el-table-column prop="ip" align="center" label="IP鍦板潃"></el-table-column>
+        <el-table-column prop="inspectionItem" align="center" label="妫�楠岄」" min-width="100"></el-table-column>
+        <el-table-column prop="inspectionItemSubClass" align="center" label="妫�楠岄」瀛愰」" min-width="100"></el-table-column>
+        <el-table-column prop="referx" align="center" label="鍙傜収X"></el-table-column>
+        <el-table-column prop="x" align="center" label="X"></el-table-column>
+        <el-table-column prop="refery" align="center" label="鍙傜収Y"></el-table-column>
+        <el-table-column prop="y" align="center" label="Y"></el-table-column>
+        <el-table-column prop="formula" align="center" label="鍏紡"></el-table-column>
         <el-table-column prop="section" label="鎿嶄綔" width="120">
           <template slot-scope="scope">
             <el-button type="text" @click="dataConfig(scope.row)">鏁伴噰閰嶇疆</el-button>
@@ -84,6 +94,40 @@
 				</el-row>
 			</span>
     </el-dialog>
+    <el-dialog title="鏁伴噰閰嶇疆" :visible.sync="dialogVisible4" width="400px">
+      <div class="search_thing" style="margin-bottom: 14px;">
+				<div class="search_label"><span style="color:red;margin-right: 4px;">*</span>IP锛�</div>
+				<el-input size="small" placeholder="璇疯緭鍏�" clearable
+						v-model="configForm.ip"></el-input>
+			</div>
+      <div class="search_thing" style="margin-bottom: 14px;">
+				<div class="search_label"><span style="color:red;margin-right: 4px;">*</span>閲囬泦鍦板潃锛�</div>
+				<el-input size="small" placeholder="璇疯緭鍏�" clearable
+						v-model="configForm.collectUrl"></el-input>
+			</div>
+      <div class="search_thing" style="margin-bottom: 14px;">
+				<div class="search_label">鍌ㄥ瓨鍦板潃锛�</div>
+				<el-input size="small" placeholder="璇疯緭鍏�" clearable
+						v-model="configForm.storageUrl"></el-input>
+			</div>
+      <div class="search_thing" style="margin-bottom: 14px;">
+				<div class="search_label"><span style="color:red;margin-right: 4px;">*</span>鏂囦欢鍚庣紑锛�</div>
+        <el-select v-model="configForm.fileType" size="small" placeholder="璇烽�夋嫨" style="width: 100%;">
+          <el-option
+            v-for="item in fileTypeOptions"
+            :key="item.value"
+            :label="item.label"
+            :value="item.value">
+          </el-option>
+        </el-select>
+			</div>
+      <span slot="footer" class="dialog-footer">
+				<el-row>
+					<el-button @click="dialogVisible4=false">鍙� 娑�</el-button>
+					<el-button type="primary" @click="submitForm4" :loading="upLoad4">纭� 瀹�</el-button>
+				</el-row>
+			</span>
+    </el-dialog>
   </div>
 </template>
 
@@ -93,21 +137,19 @@
   // import 寮曞叆鐨勭粍浠堕渶瑕佹敞鍏ュ埌瀵硅薄涓墠鑳戒娇鐢�
   components: {},
   props: {
-    tableList: {
-      type: Array,
+    deviceId: {
+      type: Number,
       default: () => []
     }
   },
   mounted() {
-    this.tableList.forEach(i => {
-      let data = i.insProductItem.split(',')
-      i.insProductItem = data[data.length - 1]
-      i.inspectionItemSubclass = data[data.length - 2]
-    })
+    this.init()
   },
   data() {
     // 杩欓噷瀛樻斁鏁版嵁
     return {
+      dialogVisible4: false,
+      tableList: [],
       page: {
         current: 1,
         size: 20,
@@ -125,6 +167,7 @@
         }
       ],
       upLoad3:false,
+      upLoad4:false,
       fileTypeOptions: [
         {label: 'csv', value: '.csv'},
         {label: 'db', value: '.db'},
@@ -138,13 +181,56 @@
   },
   // 鏂规硶闆嗗悎
   methods: {
+    fileConfiguration() {
+      this.dialogVisible4 = true
+      if(this.tableList[0]) {
+          this.$set(this.configForm, 'fileType', this.tableList[0].fileType)
+          this.$set(this.configForm, 'collectUrl', this.tableList[0].collectUrl)
+          this.$set(this.configForm, 'storageUrl', this.tableList[0].storageUrl)
+          this.$set(this.configForm, 'ip', this.tableList[0].ip)
+        }
+    },
+    init() {
+      this.tableList = []
+      this.$axios.get(this.$api.deviceScope.queryDataAcquisitionConfiguration + "?deviceId=" + this.deviceId + "&isDevice=" + false).then(res => {
+        this.tableList = res.data
+        if(this.tableList[0]) {
+          this.$set(this.configForm, 'fileType', this.tableList[0].fileType)
+          this.$set(this.configForm, 'collectUrl', this.tableList[0].collectUrl)
+          this.$set(this.configForm, 'storageUrl', this.tableList[0].storageUrl)
+          this.$set(this.configForm, 'ip', this.tableList[0].ip)
+        }
+      })
+    },
+    submitForm4() {
+      const obj = Object.assign({
+        deviceId: this.deviceId,
+        fileType: this.configForm.fileType,
+        collectUrl: this.configForm.collectUrl,
+        storageUrl: this.configForm.storageUrl,
+        ip: this.configForm.ip,
+        isDevice: true
+      })
+      this.upLoad4 = true
+      this.$axios.post(this.$api.deviceScope.saveDataAcquisitionConfiguration + "?deviceId=" + this.deviceId, obj, {headers: {
+            'Content-Type': 'application/json'
+          }}).then(res => {
+        this.tableList = res.data
+        this.dialogVisible4 = false
+        this.upLoad4 = false
+        this.init()
+        this.$message.success('鎿嶄綔鎴愬姛')
+      }).catch(err => {
+        this.upLoad4 = false
+      })
+    },
     dataConfig (row) {
       this.configForm = {
         deviceId: row.deviceId,
-        insProductItem: row.insProductItem.trim()
+        insProductItem: row.inspectionItemSubClass.trim()
       }
       this.dialogVisible3 = true
-      this.$axios.get(this.$api.deviceScope.queryDataAcquisitionConfiguration + "?deviceId=" + row.deviceId + "&insProductItem=" + row.insProductItem.trim()).then(res => {
+      this.$axios.get(this.$api.deviceScope.queryDataAcquisitionConfiguration + "?deviceId=" + this.deviceId + "&insProductItem=" + row.inspectionItemSubClass.trim()  + "&isDevice=" + true).then(res => {
         const data = res.data
         if(data[0]) {
           this.domains.splice(0, 1)
@@ -178,10 +264,10 @@
               i.y = null
             }
             i.formula = this.configForm.formula
-            i.deviceId = this.configForm.deviceId
+            i.deviceId = this.deviceId
             i.insProductItem = this.configForm.insProductItem
           })
-          this.$axios.post(this.$api.deviceScope.saveDataAcquisitionConfiguration, {dataConfigList: this.domains},{headers: {
+          this.$axios.post(this.$api.deviceScope.saveDataAcquisitionConfiguration + "?deviceId=" + this.deviceId, {dataConfigList: this.domains, isDevice: false},{headers: {
             'Content-Type': 'application/json'
           }}).then(res => {
             this.dialogVisible3 = false
@@ -194,6 +280,7 @@
                 id: ''
               }
             ]
+            this.init()
             this.$message.success('娣诲姞鎴愬姛')
           })
         } else {
@@ -253,6 +340,17 @@
 </script>
 
 <style scoped>
+.search_thing {
+		width: 350px;
+		display: flex;
+		align-items: center;
+	}
+  .search_label {
+		width: 110px;
+
+		font-size: 14px;
+		text-align: right;
+	}
 .data-acquisition-config {
   width: 100%;
   height: 100%;

--
Gitblit v1.9.3