Parcourir la source

添加配置保存

FinalYu il y a 2 ans
Parent
commit
c46bc95145

+ 16 - 0
chuanyi_client/src/api/opc.js

@@ -187,3 +187,19 @@ export function saveConfigChannelSetting(data) {
         data
     })
 }
+
+/**
+ * 获取配置信息
+ * @param params
+ * @returns {AxiosPromise}
+ */
+export function getConfigList(params) {
+    return request({
+        url: '/channelSetting/getConfigList',
+        headers: {
+            isToken: true
+        },
+        method: 'get',
+        params
+    })
+}

BIN
chuanyi_client/src/assets/images/configur.png


BIN
chuanyi_client/src/assets/images/running.png


+ 147 - 35
chuanyi_client/src/components/LeftMenu/index.vue

@@ -17,7 +17,7 @@
           <ul class="el-menu el-menu--inline" v-show="server.conn">
             <li :class="'el-submenu ' + (child.open ? 'is-opened' : '')"
                 v-for="(child, j) in server.children">
-              <div v-if="child.id.indexOf('config_') > -1"
+              <div v-if="child.id.indexOf(prefixConfigId) > -1"
                    class="el-submenu__title"
                    style="padding-left: 40px;"
                    @contextmenu.prevent="rightEventConnConfig($event, server, i)"
@@ -34,15 +34,25 @@
                 <span>{{ child.name }}</span>
                 <i class="el-submenu__icon-arrow el-icon-arrow-down"></i>
               </div>
-              <div class="custom-tree" v-show="child.open">
+              <div v-if="child.id.indexOf(prefixChannelId) > -1"
+                   class="custom-tree"
+                   v-show="child.open">
                 <el-tree class="filter-tree"
                          :data="child.channelList"
                          :indent="0"
                          node-key="id"
-                         :props="defaultProps"
                          @node-contextmenu="rightEventChannel"
                          @node-click="handleNodeClick"></el-tree>
               </div>
+              <div v-else v-show="child.open">
+                <el-tree :class="'filter-tree ' + child.clz"
+                         :data="child.dataList"
+                         :indent="0"
+                         :props="customProps"
+                         :nodeId="child.id"
+                         node-key="id"
+                         @node-contextmenu="rightEventSecondMenu"></el-tree>
+              </div>
             </li>
           </ul>
         </li>
@@ -71,6 +81,22 @@
           class="contextmenu contextmenu-black">
         <li @click="createConfig">新建配置</li>
       </ul>
+      <!-- 服务连接配置列表右键操作 -->
+      <ul v-show="visibleServerConfigListMenu"
+          :style="{ left: serverMenuLeft + 'px', top: serverMenuTop + 'px' }"
+          class="contextmenu contextmenu-black">
+        <li>查看配置</li>
+        <li>修改配置名称</li>
+        <li>编辑配置</li>
+        <li>删除配置</li>
+      </ul>
+      <!-- 服务连接运行列表右键操作 -->
+      <ul v-show="visibleServerRunListMenu"
+          :style="{ left: serverMenuLeft + 'px', top: serverMenuTop + 'px' }"
+          class="contextmenu contextmenu-black">
+        <li>启用</li>
+        <li>停用</li>
+      </ul>
     </el-col>
   </el-row>
 </template>
@@ -93,6 +119,10 @@ export default {
       visibleChannelMenu: false,
       // 通道右键配置管理显示状态
       visibleServerConfigMenu: false,
+      // 通道右键配置列表显示状态
+      visibleServerConfigListMenu: false,
+      // 通道右键运行列表显示状态
+      visibleServerRunListMenu: false,
       // 右键布局显示位置
       serverMenuTop: 0,
       // 右键布局显示位置
@@ -108,40 +138,25 @@ export default {
       // 本地存储的名字
       sessionName: this.$store.getters.sessionName,
       serverList: [],
-      secondMenuList: [
-        {
-          id: 'channel_',
-          name: '通道',
-          open: false
-        },
-        {
-          id: 'config_',
-          name: '配置',
-          open: false
-        },
-        {
-          id: 'running_',
-          name: '运行',
-          open: false
-        },
-        {
-          id: 'datasource_',
-          name: '数据源配置',
-          open: false
-        },
-        {
-          id: 'report_',
-          name: '报表',
-          open: false
-        }
-      ],
-      defaultProps: {
+      prefixChannelId: 'channel_',
+      prefixConfigId: 'config_',
+      prefixRunningId: 'running_',
+      prefixDatasourceId: 'datasource_',
+      prefixReportId: 'report_',
+      secondMenuList: [],
+      customProps: {
         children: 'children',
-        label: 'label'
+        label: 'configurationName'
       }
     }
   },
   created() {
+    this.secondMenuList = []
+    this.secondMenuList.push({ id: this.prefixChannelId, name: '通道', open: false })
+    this.secondMenuList.push({ id: this.prefixConfigId, name: '配置', open: false })
+    this.secondMenuList.push({ id: this.prefixRunningId, name: '运行', open: false })
+    this.secondMenuList.push({ id: this.prefixDatasourceId, name: '数据源配置', open: false })
+    this.secondMenuList.push({ id: this.prefixReportId, name: '报表', open: false })
     this.getConnInfo()
   },
   mounted() {
@@ -171,12 +186,57 @@ export default {
         document.body.removeEventListener('click', this.closeMenu)
       }
     },
+    /** 通道右键配置列表显示状态 */
+    visibleServerConfigListMenu(value) {
+      if (value) {
+        document.body.addEventListener('click', this.closeMenu)
+      } else {
+        document.body.removeEventListener('click', this.closeMenu)
+      }
+    },
+    /** 通道右键运行列表显示状态 */
+    visibleServerRunListMenu(value) {
+      if (value) {
+        document.body.addEventListener('click', this.closeMenu)
+      } else {
+        document.body.removeEventListener('click', this.closeMenu)
+      }
+    },
   },
   methods: {
     /** 刷新左侧连接信息 */
     refreshConnServer() {
       this.getConnInfo()
     },
+    /** 刷新左侧连接信息 */
+    refreshConfigList(data) {
+      if (!data || data.length == 0) {
+        return
+      }
+      let serverId = data[0].serverId
+      let index = this.getServerIndexById(serverId)
+      let server = this.serverList[index]
+      for (let i in server.children) {
+        let child = server.children[i]
+        // 配置
+        if (child.id.indexOf(this.prefixConfigId) > -1) {
+          child.dataList = data
+        }
+        // 运行
+        else if (child.id.indexOf(this.prefixRunningId) > -1) {
+          child.dataList = data
+        }
+      }
+      this.$set(this.serverList, index, server)
+    },
+    getServerIndexById(serverId) {
+      for (let i in this.serverList) {
+        if (serverId == this.serverList[i].id) {
+          return i
+        }
+      }
+      return null
+    },
     /** 获取当前用户的连接信息 */
     getConnInfo() {
       getConnInfo().then(res => {
@@ -204,13 +264,33 @@ export default {
           'id': server.id
         }).then(response => {
           loading.close()
-          // 通道(默认取第0个)
+          // 通道
           let treeList = response.data.tree
           for (let i in treeList) {
             treeList[i].serverId = server.id
             treeList[i].index = index
           }
-          server.children[0].channelList = treeList
+          // 配置
+          let configList = response.data.config
+          // 运行
+          let runList = response.data.run
+          for (let i in server.children) {
+            let child = server.children[i]
+            // 通道
+            if (child.id.indexOf(this.prefixChannelId) > -1) {
+              child.channelList = treeList
+            }
+            // 配置
+            else if (child.id.indexOf(this.prefixConfigId) > -1) {
+              child.dataList = configList
+              child.clz = 'cy-configure'
+            }
+            // 运行
+            else if (child.id.indexOf(this.prefixRunningId) > -1) {
+              child.dataList = runList
+              child.clz = 'cy-running'
+            }
+          }
           server.conn = true
           this.$set(this.serverList, index, server)
         }).catch((e) => {
@@ -406,6 +486,22 @@ export default {
       this.saveChannelSessionStorage(1)
       this.gotoPageByName('/config')
     },
+    /** 右键菜单事件:二级菜单 */
+    rightEventSecondMenu(event, data, node, target) {
+      this.closeMenu()
+      this.serverMenuLeft = 60
+      const y = event.pageY
+      this.serverMenuTop = y - 60
+      let nodeId = target.$parent.$attrs.nodeId
+      console.log(data)
+      console.log(nodeId)
+
+      if (nodeId.indexOf(this.prefixConfigId) > -1) {
+        this.visibleServerConfigListMenu = true
+      } else if (nodeId.indexOf(this.prefixRunningId) > -1) {
+        this.visibleServerRunListMenu = true
+      }
+    },
     /** 关闭右键菜单事件 */
     closeMenu() {
       if (this.chooseServerIndex != null) {
@@ -421,6 +517,8 @@ export default {
       this.visibleServerMenu = false
       this.visibleChannelMenu = false
       this.visibleServerConfigMenu = false
+      this.visibleServerConfigListMenu = false
+      this.visibleServerRunListMenu = false
     },
     /** 保存通道页面数据 */
     saveChannelSessionStorage(type) {
@@ -544,7 +642,7 @@ export default {
   }
 
   .el-tree-node__expand-icon.is-leaf {
-    background: url("~@/assets/images/file-text-fill.png") no-repeat;;
+    background: url("~@/assets/images/file-text-fill.png") no-repeat;
   }
 
   .el-tree-node__expand-icon.expanded {
@@ -616,6 +714,20 @@ export default {
   }
 }
 
+.cy-configure {
+  .el-tree-node__expand-icon.is-leaf {
+    background: url("~@/assets/images/configur.png") no-repeat center;
+    margin-left: 15px;
+  }
+}
+
+.cy-running {
+  .el-tree-node__expand-icon.is-leaf {
+    background: url("~@/assets/images/running.png") no-repeat center;
+    margin-left: 15px;
+  }
+}
+
 .el-menu::-webkit-scrollbar {
   width: 8px;
   height: 6px;

+ 4 - 1
chuanyi_client/src/views/channel/index.vue

@@ -39,7 +39,10 @@
                 </el-select>
               </el-form-item>
               <el-form-item label="策略值:" prop="policyValue">
-                <el-input v-model="formChannel.policyValue" placeholder="请输入策略值"></el-input>
+                <el-input v-model="formChannel.policyValue" placeholder="请输入策略值"
+                          oninput="value=value.replace(/[^0-9.]/g,'')">
+                  <template slot="append">秒</template>
+                </el-input>
               </el-form-item>
             </template>
           </el-form>

+ 12 - 2
chuanyi_client/src/views/config/index.vue

@@ -43,7 +43,7 @@
 
 <script>
 import BreadcrumbView from '@/components/BreadcrumbView'
-import {getConnectServerChannel, saveConfigChannelSetting} from "@/api/opc";
+import {getConfigList, getConnectServerChannel, saveConfigChannelSetting} from "@/api/opc";
 import {showLoading} from "@/utils/cqcy";
 
 export default {
@@ -157,7 +157,6 @@ export default {
         let channelName = this.treeFindPath(this.channelList, data => data.$treeNodeId === nodeId, "label")
         chooseChannelNameList.push(channelName.join('.'))
       }
-      console.log(chooseChannelNameList)
       this.$prompt('请输入配置名称', '提示', {
         confirmButtonText: '确定',
         cancelButtonText: '取消',
@@ -180,6 +179,7 @@ export default {
           loading.close()
           if (response.code == 200) {
             this.handleCancel()
+            this.getConfigList()
             this.$message({
               message: response.data,
               type: 'success'
@@ -200,6 +200,16 @@ export default {
       }).catch((e) => {
       })
     },
+    /** 获取配置信息 */
+    getConfigList() {
+      getConfigList({
+        'serverId': this.serverId
+      }).then(response => {
+        console.log(response)
+        this.$emit('refreshConfigList', response.data)
+      }).catch((e) => {
+      })
+    },
     /** 弹出层关闭事件 */
     handleCancel() {
       this.$refs.tree.setCheckedKeys([])

+ 4 - 1
chuanyi_client/src/views/index.vue

@@ -12,7 +12,7 @@
           <header-main></header-main>
         </el-header>
         <el-main>
-          <router-view></router-view>
+          <router-view @refreshConfigList="refreshConfigList"></router-view>
         </el-main>
       </template>
     </split-pane>
@@ -53,6 +53,9 @@ export default {
     refreshConnServer() {
       this.$refs.connServer.refreshConnServer()
     },
+    refreshConfigList(data) {
+      this.$refs.connServer.refreshConfigList(data)
+    },
     getConnServer(server) {
       this.$refs.createServer.getConnServer(server)
     },