Explorar el Código

添加数据运行操作

FinalYu hace 2 años
padre
commit
bbb5512e92

+ 30 - 0
chuanyi_client2/src/api/datasource.js

@@ -149,3 +149,33 @@ export function saveOrUpdateItemGroup(data) {
         data
     })
 }
+
+/**
+ * 运行组配置
+ * @param data
+ * @returns {AxiosPromise}
+ */
+export function runGroupById(data) {
+    return request({
+        url: '/itemGroup/runItemGroupById?id=' + data.id + '&runState=' + data.status,
+        headers: {
+            isToken: true
+        },
+        method: 'post'
+    })
+}
+
+/**
+ * 获取数据项值
+ * @param id
+ * @returns {AxiosPromise}
+ */
+export function getItemValueById(id) {
+    return request({
+        url: '/itemGroup/getItemValueById/' + id,
+        headers: {
+            isToken: true
+        },
+        method: 'get'
+    })
+}

+ 1 - 0
chuanyi_client2/src/assets/icons/svg/report.svg

@@ -0,0 +1 @@
+<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1670317701573" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3587" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16"><path d="M798.72 962.56H225.28c-90.112 0-163.84-73.728-163.84-163.84V81.92c0-12.288 8.192-20.48 20.48-20.48h737.28c12.288 0 20.48 8.192 20.48 20.48v675.84h102.4c12.288 0 20.48 8.192 20.48 20.48v20.48c0 90.112-73.728 163.84-163.84 163.84zM102.4 102.4v696.32c0 67.584 55.296 122.88 122.88 122.88h573.44c67.584 0 122.88-55.296 122.88-122.88h-102.4c-12.288 0-20.48-8.192-20.48-20.48V102.4H102.4z" fill="#1C2754" p-id="3588"></path><path d="M798.72 921.6H266.24c-90.112 0-163.84-73.728-163.84-163.84V102.4h696.32v819.2z" fill="#50BFFF" p-id="3589"></path><path d="M798.72 921.6H225.28v-122.88h696.32c0 67.584-55.296 122.88-122.88 122.88z" fill="#B1E2FF" p-id="3590"></path><path d="M225.28 675.84c67.584 0 122.88 55.296 122.88 122.88s-55.296 122.88-122.88 122.88-122.88-55.296-122.88-122.88 55.296-122.88 122.88-122.88z" fill="#50BFFF" p-id="3591"></path><path d="M184.32 245.76h266.24v225.28H184.32z" fill="#A5DEFF" p-id="3592"></path><path d="M450.56 245.76h266.24v225.28H450.56z" fill="#93D0FF" p-id="3593"></path><path d="M184.32 471.04h266.24v225.28H184.32z" fill="#FFFFFF" p-id="3594"></path><path d="M450.56 471.04h266.24v225.28H450.56z" fill="#D7E9FF" p-id="3595"></path></svg>

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 0
chuanyi_client2/src/assets/icons/svg/reports.svg


+ 75 - 3
chuanyi_client2/src/components/HeaderMain/index.vue

@@ -7,7 +7,20 @@
       </div>
       <div>
         <el-tree node-key="id"
-                 class="cy-group-tree"></el-tree>
+                 ref="reportTree"
+                 class="cy-group-tree"
+                 :indent="10"
+                 :load="loadReportNode"
+                 :props="groupProps"
+                 lazy
+                 @node-contextmenu="rightReportNodeEvent"
+                 :expand-on-click-node="false">
+              <span class="custom-tree-node" slot-scope="{ node, data }">
+                <svg-icon v-if="data.id == -1" icon-class="reports"/>
+                <svg-icon v-else icon-class="report"/>
+                <span :title='data.reportName || data.itemName' style="margin-left: 2px;">{{ data.reportName || data.itemName }}</span>
+              </span>
+        </el-tree>
       </div>
     </el-tab-pane>
     <el-tab-pane>
@@ -16,7 +29,6 @@
         <div class="nav-title">数据组配置</div>
       </div>
       <div>
-<!--        :data="groupDataList"-->
         <el-tree class="cy-group-tree"
                  ref="groupTree"
                  :indent="10"
@@ -37,6 +49,13 @@
       </div>
     </el-tab-pane>
 
+    <!-- 报表模版配置列表右键操作 -->
+    <ul v-show="visibleReportMenu"
+        :style="{ left: menuLeft + 'px', top: menuTop + 'px' }"
+        class="contextmenu contextmenu-black">
+      <li @click="addReportEvent">添加模板</li>
+    </ul>
+
     <!-- 数据组列表右键操作 -->
     <ul v-show="visibleGroupMenu"
         :style="{ left: menuLeft + 'px', top: menuTop + 'px' }"
@@ -118,6 +137,7 @@
               <el-form-item label="模式值" prop="modeValue">
                 <el-input v-model="groupRateForm.modeValue" placeholder="请输入模式值"
                           oninput="value=value.replace(/[^0-9.]/g,'')">
+                  <template slot="append">秒</template>
                 </el-input>
               </el-form-item>
             </el-form>
@@ -243,11 +263,17 @@ export default {
       labelPosition: 'top',
       // 组配置右键布局显示状态
       visibleGroupMenu: false,
+      visibleReportMenu: false,
       visibleGroupChildMenu: false,
       // 右键布局显示位置
       menuLeft: 0,
       // 右键布局显示位置
       menuTop: 0,
+      reportDataList: [{
+        id: -1,
+        reportName: '报表配置列表',
+        children: []
+      }],
       groupDataList: [{
         id: -1,
         groupName: '数据组列表',
@@ -303,6 +329,14 @@ export default {
         document.body.removeEventListener('click', this.closeMenu)
       }
     },
+    /** 报表配置添加右键值监听 */
+    visibleReportMenu(value) {
+      if (value) {
+        document.body.addEventListener('click', this.closeMenu)
+      } else {
+        document.body.removeEventListener('click', this.closeMenu)
+      }
+    },
     visibleGroupChildMenu(value) {
       if (value) {
         document.body.addEventListener('click', this.closeMenu)
@@ -348,7 +382,24 @@ export default {
         }
       })
     },
-    /** 懒加载查询组配置文件 */
+    /** 懒加载查询组配置文件:报表配置列表 */
+    loadReportNode(node, resolve) {
+      if (node.level === 0) {
+        return resolve(this.reportDataList)
+      }
+      resolve([{
+        id: 1,
+        reportName: 'AAA',
+        leaf: true,
+        children: []
+      },{
+        id: 2,
+        reportName: 'BBB',
+        leaf: true,
+        children: []
+      }])
+    },
+    /** 懒加载查询组配置文件:组配置列表 */
     loadGroupNode(node, resolve) {
       if (node.level === 0) {
         return resolve(this.groupDataList)
@@ -376,6 +427,15 @@ export default {
         })
       }
     },
+    /** 报表配置右键菜单事件 */
+    rightReportNodeEvent(event, data, node, target) {
+      this.closeMenu()
+      this.menuLeft = 80
+      if (data.id == -1) {
+        this.menuTop = 30
+        this.visibleReportMenu = true
+      }
+    },
     /** 数据组配置右键菜单事件 */
     rightNodeEvent(event, data, node, target) {
       this.closeMenu()
@@ -393,6 +453,10 @@ export default {
         this.chooseGroupParentNode = node.parent
       }
     },
+    /** 添加报表配置事件 */
+    addReportEvent() {
+      this.closeMenu()
+    },
     /** 添加数据组事件 */
     createGroupEvent() {
       this.closeMenu()
@@ -609,6 +673,13 @@ export default {
         })
         return false
       }
+      if (parseInt(this.groupRateForm.modeValue) <= 0) {
+        this.$message({
+          message: '频率设置中读取模式值必须大于0!',
+          type: 'warning'
+        })
+        return false
+      }
       if (!this.groupBasicForm.dataSourceId) {
         this.$message({
           message: '请选择数据源!',
@@ -745,6 +816,7 @@ export default {
     closeMenu() {
       this.visibleGroupMenu = false
       this.visibleGroupChildMenu = false
+      this.visibleReportMenu = false
     },
     /** 弹出层取消事件 */
     handleCancel() {

+ 8 - 3
chuanyi_client2/src/components/LeftMenu/index.vue

@@ -14,7 +14,7 @@
     </el-col>
     <el-col class="cy-conn">
       <el-image :src="require('@/assets/images/report.png')" fit="contain"></el-image>
-      <span>报表配置</span>
+      <span>我的报表</span>
     </el-col>
 
     <!-- 数据源配置弹出层 -->
@@ -332,7 +332,9 @@ export default {
         if (valid) {
           this.connDialogVisible = true
           if (this.chooseConnServer) {
-            this.connForm = JSON.parse(JSON.stringify(this.chooseConnServer))
+            this.$nextTick(() => {
+              this.connForm = JSON.parse(JSON.stringify(this.chooseConnServer))
+            })
           }
         }
       })
@@ -349,7 +351,10 @@ export default {
             params.ipPassword = ''
             params.ipUserName = ''
           } else {
-            params.ipPassword = encrypt(this.connForm.ipPassword, getPubKey())
+            if (!this.chooseConnServer || (this.chooseConnServer
+                && this.connForm.ipPassword != this.chooseConnServer.ipPassword)) {
+              params.ipPassword = encrypt(this.connForm.ipPassword, getPubKey())
+            }
           }
           if (this.chooseConnServer) {
             params.typeId = this.chooseConnServer.typeId

+ 6 - 6
chuanyi_client2/src/permission.js

@@ -4,16 +4,16 @@ import NProgress from 'nprogress'
 import 'nprogress/nprogress.css'
 import {getToken} from '@/utils/auth'
 
-NProgress.configure({showSpinner: false})
+// NProgress.configure({showSpinner: false})
 
 const whiteList = ['/login']
 
 router.beforeEach(async (to, from, next) => {
-    NProgress.start()
+    // NProgress.start()
     if (getToken()) {
         if (to.path === '/login') {
             next({path: '/'})
-            NProgress.done()
+            // NProgress.done()
         } else {
             if (to.matched.length === 0) {
                 // next('/404')
@@ -32,7 +32,7 @@ router.beforeEach(async (to, from, next) => {
                     console.log(error)
                     await store.dispatch('user/resetToken')
                     next(`/login?redirect=${to.fullPath}`)
-                    NProgress.done()
+                    // NProgress.done()
                 }
             }
         }
@@ -43,11 +43,11 @@ router.beforeEach(async (to, from, next) => {
             next()
         } else {
             next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页
-            NProgress.done()
+            // NProgress.done()
         }
     }
 })
 
 router.afterEach(() => {
-    NProgress.done()
+    // NProgress.done()
 })

+ 45 - 10
chuanyi_client2/src/views/group_item/index.vue

@@ -9,7 +9,8 @@
             :value="dict.id"
         ></el-option>
       </el-select>
-      <el-checkbox v-model="groupRunStatus" size="mini" style="margin-left: 20px;" @change="groupRunCheckboxEvent">运行</el-checkbox>
+      <el-checkbox v-model="groupRunStatus" size="mini" style="margin-left: 20px;"
+                   @change="groupRunCheckboxEvent">实时数据</el-checkbox>
     </div>
     <el-table
         :data="itemDataList"
@@ -21,21 +22,20 @@
       </el-table-column>
       <el-table-column prop="itemName" label="数据项名称" align="center">
       </el-table-column>
-      <el-table-column prop="val" label="数据项值" align="center" width="120">
+      <el-table-column prop="dataType" label="数据项类型" align="center" width="100">
       </el-table-column>
-      <el-table-column prop="dataSourceName" label="数据源名称" align="center" width="200">
+      <el-table-column prop="dataValue" label="数据项值" align="center" width="120">
       </el-table-column>
-      <el-table-column prop="runState" label="运行状态" align="center" width="100">
+      <el-table-column prop="dataSourceName" label="数据源名称" align="center" width="200">
       </el-table-column>
-      <el-table-column prop="time" label="运行时间" align="center" width="120">
+      <el-table-column prop="createTime" label="运行时间" align="center" width="120">
       </el-table-column>
     </el-table>
   </div>
 </template>
 
 <script>
-
-import {getItemGroupById} from "@/api/datasource";
+import {getItemGroupById, getItemValueById, runGroupById} from "@/api/datasource";
 import {showLoading} from "@/utils/cqcy";
 
 export default {
@@ -48,7 +48,8 @@ export default {
       groupDataList: [],
       chooseGroup: null,
       chooseGroupId: null,
-      groupRunStatus: false
+      groupRunStatus: false,
+      timeInterval: null
     }
   },
   watch: {
@@ -56,6 +57,12 @@ export default {
       this.readParams()
     },
   },
+  beforeDestroy() {
+    if (this.timeInterval) {
+      clearInterval(this.timeInterval)
+      this.timeInterval = null
+    }
+  },
   methods: {
     /** 读取参数 */
     readParams() {
@@ -63,15 +70,43 @@ export default {
       this.groupDataList = JSON.parse(groupListStorage)
       let groupId = sessionStorage.getItem('GROUP_ID') ? sessionStorage.getItem('GROUP_ID') : '-1'
       this.chooseGroupId = parseInt(groupId)
+      this.groupRunStatus = false
       this.getGroupById(this.chooseGroupId)
+      this.getItemValueById()
     },
     /** 运行状态值 */
     groupRunCheckboxEvent(val) {
-      console.log(val)
-      console.log(this.chooseGroup)
+      this.groupRunStatus = val
+      this.getItemValueById()
+    },
+    /** 获取数据项值信息 */
+    getItemValueById() {
+      if (!this.groupRunStatus || !this.chooseGroup) {
+        if (this.timeInterval) {
+          clearInterval(this.timeInterval)
+          this.timeInterval = null
+        }
+        return
+      }
+      getItemValueById(this.chooseGroup.id).then(res => {
+        this.itemDataList = res.data
+      }).catch((e) => {
+      })
+      let temp = setInterval(() => {
+        getItemValueById(this.chooseGroup.id).then(res => {
+          this.itemDataList = res.data
+        }).catch((e) => {
+        })
+      }, 5 * 1000)
+      this.timeInterval = temp
     },
     /** 获取组详细信息 */
     getGroupById(id) {
+      console.log(this.timeInterval)
+      if (this.timeInterval) {
+        clearInterval(this.timeInterval)
+        this.timeInterval = null
+      }
       if (!id) {
         return
       }

+ 112 - 15
chuanyi_client2/src/views/run_config/index.vue

@@ -1,5 +1,5 @@
 <template>
-  <div class="cqcy-content" style="margin: 0;">
+  <div class="cqcy-content" style="margin: 0;height: calc(100% - 70px);">
     <breadcrumb-view :breadcrumbList="breadcrumbList" :show-index="false"></breadcrumb-view>
     <el-divider></el-divider>
     <div class="cy-main">
@@ -9,27 +9,40 @@
             v-for="dict in groupDataList"
             :key="dict.id"
             :label="dict.groupName"
-            :value="dict.id"
-        ></el-option>
+            :value="dict.id">
+          <span>
+            <div v-if="dict.runState == 0" class="cy-run-status" style="background-color: red;"></div>
+            <div v-if="dict.runState == 1" class="cy-run-status" style="background-color: green;"></div>
+          </span>
+          <span>{{ dict.groupName }}</span>
+        </el-option>
       </el-select>
     </div>
     <div class="cy-main cy-data-main">
-      <div class="cy-item-main">
+      <div class="cy-item-main" style="overflow: hidden;">
         <div class="cy-btn">
-          <el-button v-if="runStatus == 0" size="mini" type="primary" plain icon="el-icon-video-play">运行</el-button>
-          <el-button v-if="runStatus == 1" size="mini" type="danger" plain icon="el-icon-video-pause">停止</el-button>
+          <el-button v-if="runStatus == 0"
+                     @click="runningEvent"
+                     size="mini" type="primary" plain icon="el-icon-video-play">运行</el-button>
+          <el-button v-if="runStatus == 1"
+                     @click="stopRunningEvent"
+                     size="mini" type="danger" plain icon="el-icon-video-pause">停止</el-button>
         </div>
-        <div style="overflow: auto;height: 100%;">
+        <div style="overflow: auto;height: 100%;height: calc(100% - 40px);">
           <ul>
             <li v-for="item in itemDataList">
               <div class="cy-item-name">{{ item.itemName }}</div>
               <div style="display: flex;">
-                <div class="cy-item-val" style="width: 60px;">实时数据</div>
+                <div class="cy-item-val" style="width: 60px;">状态</div>
                 <div class="cy-item-val">实时数据</div>
               </div>
               <div style="display: flex;">
-                <div class="cy-item-val" style="width: 60px;">频率</div>
-                <div class="cy-item-val">频率</div>
+                <div class="cy-item-val" style="width: 60px;">数据类型</div>
+                <div class="cy-item-val">{{ item.dataType }}</div>
+              </div>
+              <div style="display: flex;">
+                <div class="cy-item-val" style="width: 60px;">值</div>
+                <div class="cy-item-val">{{ item.dataValue }}</div>
               </div>
             </li>
           </ul>
@@ -41,7 +54,7 @@
 
 <script>
 import BreadcrumbView from '@/components/BreadcrumbView'
-import {getAllItemGroup, getItemGroupById} from "@/api/datasource";
+import {getAllItemGroup, getItemGroupById, getItemValueById, runGroupById} from "@/api/datasource";
 import {showLoading} from "@/utils/cqcy";
 
 export default {
@@ -56,7 +69,8 @@ export default {
       itemDataList: [],
       runStatus: -1,
       chooseGroup: null,
-      chooseGroupId: null
+      chooseGroupId: null,
+      timeInterval: null
     }
   },
   watch: {
@@ -64,6 +78,12 @@ export default {
       this.getGroupList()
     },
   },
+  beforeDestroy() {
+    if (this.timeInterval) {
+      clearInterval(this.timeInterval)
+      this.timeInterval = null
+    }
+  },
   created() {
     this.getGroupList()
   },
@@ -80,16 +100,85 @@ export default {
     },
     /** 根据ID查询组信息 */
     getGroupById(val) {
+      if (this.timeInterval) {
+        clearInterval(this.timeInterval)
+        this.timeInterval = null
+      }
       const loading = showLoading(this, '加载中,请稍候···')
       getItemGroupById(val).then(res => {
         loading.close()
+        this.chooseGroup = res.data
+        this.chooseGroupId = res.data.id
         this.runStatus = res.data.runState
+        if (this.runStatus == 1) {
+          this.getItemValueById()
+        }
         this.itemDataList = res.data.itemList
-        console.log(res)
       }).catch((e) => {
         loading.close()
       })
-    }
+    },
+    /** 修改数据状态 */
+    changeDataList(status) {
+      for (let i in this.groupDataList) {
+        let data = this.groupDataList[i]
+        if (data.id == this.chooseGroupId) {
+          data.runState = status
+        }
+      }
+    },
+    /** 运行、停止运行接口 */
+    runGroupById(status) {
+      let params = {
+        'id': this.chooseGroupId,
+        'status': status
+      }
+      const loading = showLoading(this, params.status == 1 ? '正在运行,请稍候···' : '正在停止,请稍候···')
+      runGroupById(params).then(res => {
+        loading.close()
+        this.runStatus = status
+        this.changeDataList(this.runStatus)
+        if (this.runStatus == 1) {
+          this.getItemValueById()
+        } else {
+          if (this.timeInterval) {
+            clearInterval(this.timeInterval)
+            this.timeInterval = null
+          }
+        }
+        this.$message({
+          message: res.data,
+          type: 'success'
+        })
+      }).catch((e) => {
+        loading.close()
+      })
+    },
+    /** 运行事件 */
+    runningEvent() {
+      this.runGroupById(1)
+    },
+    /** 停止运行事件 */
+    stopRunningEvent() {
+      this.runGroupById(0)
+    },
+    /** 获取数据项值信息 */
+    getItemValueById() {
+      if (!this.chooseGroup) {
+        if (this.timeInterval) {
+          clearInterval(this.timeInterval)
+          this.timeInterval = null
+        }
+        return
+      }
+      let temp = setInterval(() => {
+        getItemValueById(this.chooseGroupId).then(res => {
+          this.itemDataList = res.data
+        }).catch((e) => {
+        })
+      }, this.chooseGroup.modeValue * 1000)
+      this.timeInterval = temp
+    },
   }
 }
 </script>
@@ -143,7 +232,7 @@ export default {
           text-overflow: ellipsis;
           white-space: nowrap;
           overflow: hidden;
-          margin-bottom: 20px;
+          margin-bottom: 10px;
         }
 
         .cy-item-val {
@@ -153,4 +242,12 @@ export default {
     }
   }
 }
+
+.cy-run-status {
+  width: 10px;
+  height: 10px;
+  display: inline-block;
+  margin-right: 10px;
+  border-radius: 5px;
+}
 </style>

Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio