From 0b67fd879ccd4fb6319dc016babd3bb8ea79dff0 Mon Sep 17 00:00:00 2001
From: shikeying <pxzsky@163.com>
Date: 星期二, 25 四月 2023 18:47:35 +0800
Subject: [PATCH] 修改列表组件,支持属性子属性

---
 src/views/tcp/connection/index.vue |  115 +++++++++++++++++++
 src/store/modules/user.js          |   10 +
 src/api/tcp/equip.js               |   10 +
 src/views/components/myTableV3.vue |   40 +++++-
 src/views/tcp/equip/index.vue      |  126 +++++++++++++++++++++
 5 files changed, 291 insertions(+), 10 deletions(-)

diff --git a/src/api/tcp/equip.js b/src/api/tcp/equip.js
new file mode 100644
index 0000000..99b237c
--- /dev/null
+++ b/src/api/tcp/equip.js
@@ -0,0 +1,10 @@
+import request from "@/utils/request";
+
+// 娣诲姞璁惧
+export function addEquip(data) {
+  return request({
+    url: '/tcp/equip/add',
+    method: 'post',
+    data: data
+  })
+}
diff --git a/src/store/modules/user.js b/src/store/modules/user.js
index d9b29c6..b45847f 100644
--- a/src/store/modules/user.js
+++ b/src/store/modules/user.js
@@ -41,8 +41,11 @@
     SET_CONNECTION: (state, data) => {
       // var webConnection = new WebConnection();
       // if(state.webConnection == null){
-        state.webConnection = new WebConnection(data.uri, data.uid);
-        state.webConnection.startConnect();
+      if(data.uri == '-1'){
+        return;
+      }
+      state.webConnection = new WebConnection(data.uri, data.uid);
+      state.webConnection.startConnect();
       // }
     },
     SET_CONNECTION_CLEAR: (state, data) => {
@@ -56,6 +59,9 @@
       state.webSocketMsg = data;
     },
     SET_WS_INFO: (state, data)=>{
+      if(data.uri == '-1'){
+        return;
+      }
       state.uri = data.uri;
       state.uid = data.uid;
     }
diff --git a/src/views/components/myTableV3.vue b/src/views/components/myTableV3.vue
index ec86898..6c38590 100644
--- a/src/views/components/myTableV3.vue
+++ b/src/views/components/myTableV3.vue
@@ -122,7 +122,8 @@
             <template v-else>
               <!--鐐瑰嚮寮瑰嚭鍗曞厓鏍煎唴瀹�-->
               <el-popover placement="top-start" trigger="click" :content="getPopoverContent(scope.row, column)">
-                <span slot="reference" class="content-text">{{ scope.row[column.field] }}</span>
+<!--                <span slot="reference" class="content-text">{{ scope.row[column.field] }}</span>-->
+                <span slot="reference" class="content-text">{{ splitField(scope.row, column.field) }}</span>
               </el-popover>
             </template>
           </template>
@@ -187,13 +188,14 @@
 </template>
 
 <script>
-import myButtonV2 from '@/views/components/myButtonV2'
-import myButton from '@/views/components/myButton'
-import mySwitch from './mySwitch'
-import request from '@/utils/request'
-import * as valid from '@/utils/validate'
-import previewPicture from '@/views/components/previewPicture'
-export default {
+  import myButtonV2 from '@/views/components/myButtonV2'
+  import myButton from '@/views/components/myButton'
+  import mySwitch from './mySwitch'
+  import request from '@/utils/request'
+  import * as valid from '@/utils/validate'
+  import previewPicture from '@/views/components/previewPicture'
+
+  export default {
   components: { myButtonV2, myButton, mySwitch, previewPicture },
   props: {
     table: {
@@ -348,6 +350,28 @@
     this.initTable()
   },
   methods: {
+    /**
+     * 瑙e喅锛歠ield涓睘鎬у灞炴�х殑鎯呭喌銆�2023-04-25
+     * @param row
+     * @param field
+     */
+    splitField(row, field){
+      if(field.indexOf('.') > -1){
+        const arr = field.split('.');
+        let fieldStr = '';
+        for(let i=0, len=arr.length; i<len; i++){
+          if(i == len - 1){
+            fieldStr += arr[i];
+          } else {
+            fieldStr += arr[i] + '.';
+          }
+        }
+        return eval('row.' + fieldStr);
+      } else {
+        return row[field];
+      }
+    },
+
     initTable() {
       if (this.table !== null) {
         Object.assign(this.myTable, this.table)
diff --git a/src/views/tcp/connection/index.vue b/src/views/tcp/connection/index.vue
new file mode 100644
index 0000000..4ba3122
--- /dev/null
+++ b/src/views/tcp/connection/index.vue
@@ -0,0 +1,115 @@
+<template>
+  <div class="app-main">
+    <div class="base-container">
+      <my-table-v3 ref="myTable" :filter="filterForm" :table="table" />
+    </div>
+  </div>
+</template>
+
+<script>
+  import myTableV3 from '@/views/components/myTableV3';
+  // import myButtonV2 from "@/views/components/myButtonV2";
+  // import edit from "@/views/system/config/edit";
+
+  export default {
+    name: "Connection",
+    components: {myTableV3},
+    data(){
+      return {
+
+        /** 鎼滅储鏉′欢*/
+        filterForm: {
+
+        },
+
+        table: {
+          showIndex: false, // 鏄惁鏄剧ず搴忓彿
+          expand: false, // 鏄惁鏄剧ず璇︽儏鏁版嵁
+          checkBox: false, // 鏄惁鏄剧ず澶嶉�夋
+          url: globalConf.baseUrl + '/tcp/connection/list', // 璇锋眰鍦板潃
+          // 宸ュ叿鏉�
+          tools: {
+            columnsCtrl: {// 鍒楁帶鍒舵寜閽�
+              show: false
+            },
+            generalExport: {// 閫氱敤瀵煎嚭鎸夐挳
+              show: false
+            }
+          },
+          columns: [
+            { title: '閫氶亾ID', field: 'id', align: 'left', width: 260 },
+            { title: '缁戝畾缁堢', field: 'name', align: 'left', width: 200 },
+            { title: '杩炴帴鍒涘缓', field: 'createTimeMills', align: 'left', width: 170 },
+            { title: '鏈�鍚庢椿璺�', field: 'lastTime', align: 'left', width: 170},
+            { title: '鎵�灞炲紩鎿�', field: 'engineId', align: 'left', width: 130, formatter: row => {
+                let title = '';
+                switch (row.engineId) {
+                  case 1:
+                    title = 'TCP'
+                    break
+                  case 2:
+                    title = 'WEBSOCKET'
+                    break
+                }
+                return { value: title, type: 'primary' }
+              }
+            }
+          ],
+          // 鎿嶄綔淇℃伅
+          operation: {
+            show: true, // 鏄剧ず鎿嶄綔鍒�
+            width: '200', // 鍒楀
+            attr: [
+              {
+                title: '寮哄埗鏂紑',
+                checkPermission: 'tcp:connection:broken',
+                events: row => {
+                  this.broken(row)
+                }
+              }
+            ]
+          },
+          paging: {
+            show: true, // 鏄剧ず鍒嗛〉
+            // 鍒嗛〉淇℃伅
+            page: {
+              small: false,
+              pageNum: 1,
+              pageSize: 256,
+              total: 0
+            }
+          }
+        }
+
+      }
+    },
+
+    methods: {
+      // 鏌ヨtable鍒楄〃
+      search(pageNum) {
+        if (pageNum != undefined) {
+          this.$refs.myTable.search({ pageNum: pageNum })
+        } else {
+          this.$refs.myTable.search()
+        }
+      },
+      // 琛ㄥ崟閲嶇疆
+      reset() {
+        this.filterForm = {
+          // configName: null,
+          // configKey: null,
+          // configType: null
+        }
+        this.search(1)
+      },
+
+      broken(row) {
+
+      }
+    }
+  }
+</script>
+
+<style scoped>
+
+</style>
diff --git a/src/views/tcp/equip/index.vue b/src/views/tcp/equip/index.vue
new file mode 100644
index 0000000..9662bda
--- /dev/null
+++ b/src/views/tcp/equip/index.vue
@@ -0,0 +1,126 @@
+<template>
+  <div class="app-main">
+    <div class="base-container">
+      <my-table-v3 ref="myTable" :filter="filterForm" :table="table" />
+    </div>
+  </div>
+</template>
+
+<script>
+  import myTableV3 from '@/views/components/myTableV3';
+  // import {addEquip} from '@/api/tcp/equip'
+  // import myButtonV2 from "@/views/components/myButtonV2";
+  // import edit from "@/views/system/config/edit";
+
+  export default {
+    name: "Connection",
+    components: {myTableV3},
+    data(){
+      return {
+
+        /** 鎼滅储鏉′欢*/
+        filterForm: {
+          name: null
+        },
+
+        table: {
+          showIndex: false, // 鏄惁鏄剧ず搴忓彿
+          expand: false, // 鏄惁鏄剧ず璇︽儏鏁版嵁
+          checkBox: false, // 鏄惁鏄剧ず澶嶉�夋
+          url: globalConf.baseUrl + '/tcp/equip/list', // 璇锋眰鍦板潃
+          // 宸ュ叿鏉�
+          tools: {
+            columnsCtrl: {// 鍒楁帶鍒舵寜閽�
+              show: false
+            },
+            generalExport: {// 閫氱敤瀵煎嚭鎸夐挳
+              show: false
+            }
+          },
+          columns: [
+            { title: '璁惧缂栧彿', field: 'num', align: 'left', width: 220 },
+            { title: '鍒涘缓鏃堕棿', field: 'createTime', align: 'left', width: 170 },
+            { title: '鍚嶇О', field: 'name', align: 'left', width: 220 },
+            { title: '鏁版嵁鍗忚', field: 'parameter.protocolResolverName', align: 'left', width: 120},
+            { title: '鎵�灞炴満鏋�', field: 'parameter.deptName', align: 'left', width: 170},
+            { title: '澶囨敞', field: 'summary', align: 'left', width: 120},
+            { title: '鐘舵��', field: 'status', align: 'left', width: 120, formatter: row => {
+                let title = '';
+                switch (row.status) {
+                  case 1:
+                    title = '鍦ㄧ敤'
+                    break
+                  case 0:
+                    title = '绂佺敤'
+                    break
+                  default:
+                    title = '宸插垹闄�'
+                }
+                return { value: title, type: 'primary' }
+              }
+            }
+          ],
+          // 鎿嶄綔淇℃伅
+          operation: {
+            show: true, // 鏄剧ず鎿嶄綔鍒�
+            width: '120', // 鍒楀
+            attr: [
+              {
+                title: '缁戝畾鐢ㄦ埛',
+                checkPermission: 'tcp:connection:broken',
+                events: row => {
+                  this.broken(row)
+                }
+              },
+              {
+                title: '鍒犻櫎璁惧',
+                checkPermission: 'tcp:connection:broken',
+                events: row => {
+                  this.broken(row)
+                }
+              }
+            ]
+          },
+          paging: {
+            show: true, // 鏄剧ず鍒嗛〉
+            // 鍒嗛〉淇℃伅
+            page: {
+              small: false,
+              pageNum: 1,
+              pageSize: platformPageSize,
+              total: 0
+            }
+          }
+        }
+
+      }
+    },
+
+    methods: {
+      // 鏌ヨtable鍒楄〃
+      search(pageNum) {
+        if (pageNum != undefined) {
+          this.$refs.myTable.search({ pageNum: pageNum })
+        } else {
+          this.$refs.myTable.search()
+        }
+      },
+      // 琛ㄥ崟閲嶇疆
+      reset() {
+        this.filterForm = {
+          name: null
+        }
+        this.search(1)
+      },
+
+      broken(row) {
+
+      },
+
+    }
+  }
+</script>
+
+<style scoped>
+
+</style>

--
Gitblit v1.9.1