Browse Source

中台层级

Rgx 1 year ago
parent
commit
d9b015ebda
2 changed files with 707 additions and 362 deletions
  1. 398 184
      src/views/modules/visi/create1.vue
  2. 309 178
      src/views/modules/visi/create2.vue

+ 398 - 184
src/views/modules/visi/create1.vue

@@ -1,24 +1,29 @@
 <!--  -->
 <template>
   <div>
+<!--    面包屑,用来管理 首页>数据集管理>静态数据集,separator-class是设置面包屑中的分隔符>-->
     <el-breadcrumb class="divi2" separator-class="el-icon-arrow-right">
       <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
       <el-breadcrumb-item :to="{ path: '/visi-dataset'}">数据集管理</el-breadcrumb-item>
       <el-breadcrumb-item>静态数据集</el-breadcrumb-item>
     </el-breadcrumb>
+<!--    el-divider是分割线-->
     <el-divider class="divi"></el-divider>
     <div class="title_score">
       <!--   el-form 中添加   status-icon  可检测状态-->
+<!--      el-form-item是表单-->
       <el-form :inline="true" ref="dataInfo" :model="dataInfo" :rules="datarules" class="demo-form-inline">
         <el-form-item label="数据集名称" prop="datasetName">
           <el-input style="width: 260px;" v-model="dataInfo.datasetName" placeholder="请输入数据集内容"></el-input>
         </el-form-item>
         <el-form-item label="类别" prop="classificationtag" style="margin-left: 20px">
+<!--          el-select是选择器-->
           <el-select v-model="dataInfo.classificationtag"
                      filterable
                      allow-create
                      ref='classfi'
                      @change="demo1()">
+<!--            el-option下拉框绑定-->
             <el-option style="width: 260px;" v-for="data in classification" :key="data.categoryId"
                        :label="data.categoryName" :value="data.categoryId">
             </el-option>
@@ -29,9 +34,9 @@
           <el-input style="width: 300px;" v-model="dataInfo.remarks" ref='remarks' clearable
                     placeholder="备注"></el-input>
         </el-form-item>
-        <el-form-item>
-          <el-button type="primary" @click="getPythonKafkaTmp()">获得代码模板</el-button>
-        </el-form-item>
+<!--        <el-form-item>-->
+<!--          <el-button type="primary" @click="getPythonKafkaTmp()">获得代码模板</el-button>-->
+<!--        </el-form-item>-->
       </el-form>
     </div>
     <div class="body">  <!-- 数据框整体大小 -->
@@ -39,13 +44,22 @@
         <div class="leftDiv">  <!-- 控制左边树形区域的div -->
           <div style="height: 60%">
             <div class="leftDivTitle"><!-- 控制左边树形区域的上方的div -->
+<!--              el-tag创建一个标签-->
               <el-tag style="  width: 100%;text-align: center;height: 31px">系统数据</el-tag>
             </div>
             <div class="leftDivTree"> <!-- 控制左边树形区域的下方的div -->
+<!--              node-key是树节点的唯一标识,每棵树都是唯一的
+                  :props配置选项,具体看下表
+                  lazy是否懒加载子节点,需与 load 方法结合使用
+                  draggable 属性可让节点变为可拖拽
+                  allow-drag判断节点能否被拖拽
+                  allow-drop拖拽时判定目标节点能否被放置
+                  @node-drag-end拖拽结束时(可能未成功)触发的事件
+                  -->
               <el-tree
                 v-if="showTree"
                 id='tree'
-                node-key="subEquipmentid"
+                node-key="coalid"
                 :props="treeDefaultProps"
                 ref="tree"
                 :load="loadTreeNode"
@@ -56,10 +70,10 @@
                 @node-drag-end="treeNodeDragEnd">
                 <!--            @node-click="treeNodeClick">-->
                 <span class="custom-tree-node" slot-scope="{ node, data }">
-                <span>
-                    <i :class="data.icon" style="margin-right: 4px"></i>{{ node.label }}
+                  <span>
+                      <i :class="data.icon" style="margin-right: 4px"></i>{{ node.label }}
+                  </span>
                 </span>
-            </span>
               </el-tree>
             </div>
           </div>
@@ -89,6 +103,7 @@
         <div class="midDiv"> <!-- 控制中间区域的div -->
           <div class="midDivTop">
             <div class="midDivTopImg">
+<!--              el-tooltip鼠标放上去会显示文字-->
               <el-tooltip content="运行" placement="bottom-end" effect="dark">
                 <i @mouseover="yunXingMouseOver"
                    @mouseleave="yunXingMouseLeave" id='yunXing' @click="yunXingClick"
@@ -113,6 +128,7 @@
           </div> <!-- 控制中间区域的上方div -->
           <div class="midDivData">
             <div class="dy_datasourceDiv" id="dy_drag" @dragover="dragDragOver" @dragleave="dragDragLeave">
+<!--              divider是分割线,分割线中有张图片-->
               <el-divider><i class=" icon iconfont icon-xitong2"></i></el-divider>
               <div v-for="subEquipment in subEquipments" :key="subEquipment.key" style="display: inline-block">
                 <div style="margin-left: 10px; margin-top:10px" @mouseover="subEquipment.quXiao = true"
@@ -506,7 +522,7 @@ export default {
             data: this.$http.adornData(this.imsql[j], false)
           }).then(subresult => {
             var context = subresult.data
-
+            console.log('subresult.data:', subresult.data)
             this.soutRizhi = '  ' + context.info + '\n\n' + this.soutRizhi
           })
           onlyStatic = false
@@ -625,7 +641,7 @@ export default {
 
         if (id === this.subEquipments[i].id) {
           this.$refs.tree.getNode(this.subEquipments[i].sql.subEquipmentID).data.icon = 'iconfont icon-xitong3'
-          this.$refs.tree.getNode(this.subEquipments[i].sql.subEquipmentID).data.limit = 'children'
+          this.$refs.tree.getNode(this.subEquipments[i].sql.subEquipmentID).data.flag = 'subEquipment'
           // 看当前左侧属性栏显示的数据 ,是否为该设备 ,如果是,进行清除
           if (this.detailTitle.worldName === this.subEquipments[i].imageTable.tableName) {
             this.detailTitle.worldName = '属性信息'
@@ -671,7 +687,7 @@ export default {
     },
 
     allowdrag (node) {
-      if (node.data.limit === 'children') {
+      if (node.data.flag === 'subEquipment') {
         return true
       }
     },
@@ -757,7 +773,7 @@ export default {
       }
     },
     treeNodeDragEnd (node) {
-      if (this.dragFlg === 1 && node.data.limit === 'children') {
+      if (this.dragFlg === 1 && node.data.flag === 'subEquipment') {
         // 修改属性值,表示该节点已经拖拽过
         node.data.limit = 'children-1'
         node.data.icon = 'iconfont icon-xitong4'
@@ -798,27 +814,61 @@ export default {
         subEquipment.imageTable.tableName = node.data.name
         subEquipment.imageTable.tableDB = node.parent.data.name
         subEquipment.sql.hbaseTableName = node.data.hbaseTableName
-        subEquipment.sql.subEquipmentID = node.data.subEquipmentid
-
-        // 获取hbase 表头信息
-        this.$http({
-          url: this.$http.adornUrl('/dataset/dynamic/getheads'),
-          method: 'post',
-          data: this.$http.adornData(subEquipment.sql, false)
-        }).then(tablists => {
-          var headers = tablists.data.hbaseTableHeaders
-          if (headers) {
-            for (let i = 0; i < headers.length; i++) {
-              var list = {
-                key: i + 1,
-                measurepointId: headers[i].measurepointId,
-                prop: headers[i].name_en,
-                label: headers[i].name_zh
+        subEquipment.sql.subEquipmentID = node.data.coalid
+        console.log(subEquipment.sql.hbaseTableName + 'and' + subEquipment.sql.subEquipmentID)
+        if (node.level === 1) {
+          this.$http({
+            url: this.$http.adornUrl('/universaltable/getRootLevel' + node.data.coalid),
+            method: 'post'
+          }).then(tablists => {
+            let headers = tablists.data.data
+            console.log('第二层headers:' + JSON.stringify(headers))
+            if (headers) {
+              console.log('xxxxxxxheaders', headers)
+              for (let i = 0; i < headers.length; i++) {
+                var list = {
+                  key: i + 1,
+                  label: headers[i].name,
+                  type: headers[i].type,
+                  // fieldId: response.data[i].fieldId,
+                  measurepointId: headers[i].id,
+                  flag: '未选中',
+                  prop: headers[i].name,
+                  seen: false
+                }
+                console.log('list:' + list)
+                subEquipment.filedList.push(list)
               }
-              subEquipment.filedList.push(list)
             }
-          }
-        })
+          })
+        }
+        if (node.level > 1) {
+          // 获取hbase 表头信息
+          this.$http({
+            url: this.$http.adornUrl('/universaltable/getOtherLeafItem?tableId=' + node.data.levelId + '&id=' + node.data.coalid),
+            method: 'post'
+          }).then(tablists => {
+            let headers = tablists.data.data
+            console.log('第三层及之后headers:' + JSON.stringify(headers))
+            if (headers) {
+              console.log('xxxxxxxheaders', headers)
+              for (let i = 0; i < headers.length; i++) {
+                var list = {
+                  key: i + 1,
+                  label: headers[i].name,
+                  type: headers[i].type,
+                  // fieldId: response.data[i].fieldId,
+                  measurepointId: headers[i].id,
+                  flag: '未选中',
+                  seen: false,
+                  prop: headers[i].name
+                }
+                console.log('list:' + list)
+                subEquipment.filedList.push(list)
+              }
+            }
+          })
+        }
         //
         // // 拖拽结束后,如果属性区域没显示数据,自动显示拖拽的设备
         // if (this.tablelists.length === 0) {
@@ -839,7 +889,7 @@ export default {
       }
     },
     treeNodeClick (data, node) {
-      if (node.data.limit === 'children') {
+      if (node.data.flag === 'subEquipment') {
         this.detailTitle.worldName = node.data.name
         this.equimentClick()
       }
@@ -865,22 +915,34 @@ export default {
           // 处理两次单击同一个设备
           console.log(this.subEquipments[i])
           if (this.detailTitle.worldName !== this.subEquipments[i].imageTable.tableName) {
-            this.tablelists = this.subEquipments[i].filedList
-
+            let l = []
+            for (let j = 0; j < this.subEquipments[i].filedList.length; j++) {
+              let o = this.subEquipments[i].filedList[j]
+              if(o.prop!="time"){
+                o.prop = o.prop + '_after'
+              }
+              l.push(o)
+            }
+            // this.tablelists = this.subEquipments[i].filedList
+            console.log(this.tablelists)
+            this.tablelists = l
+            console.log('tablelists', this.tablelists)
             this.detailTitle.worldName = this.subEquipments[i].imageTable.tableName
             this.tableData = []
             // 获取右侧表格数据
+            console.log('-----' + this.subEquipments[i].sql.hbaseTableName + ' and ' + this.subEquipments[i].sql.subEquipmentID)
             this.$http({
               url: this.$http.adornUrl('/dataset/dynamic/getContent'),
               method: 'post',
               data: this.$http.adornData(this.subEquipments[i].sql, false)
             }).then(contextResponse => {
+              console.log('数据-----', JSON.parse(JSON.stringify(contextResponse.data.equmentAll)))
               if (contextResponse.data.code === 500) {
                 this.tableData = []
               } else {
                 const subeqpmContent = JSON.parse(JSON.stringify(contextResponse.data.equmentAll))
-
                 this.tableData = subeqpmContent
+                console.log('tabledata:', this.tableData)
               }
               this.dataListLoading = false
             })
@@ -891,6 +953,9 @@ export default {
       }
       if (this.tableData.length > 0) {
         this.dataListLoading = false
+        console.log('tableData的长度不为空')
+      } else {
+        console.log('tableData的长度为空')
       }
     },
     equimentDoubleClick (id) {
@@ -1018,6 +1083,7 @@ export default {
               data: this.$http.adornData(info, false)
             }).then(res => {
               var resContent = res.data
+              console.log('res.data:', res.data)
               if (resContent && resContent.code === 0) {
                 Message({
                   message: '数据集' + this.dataInfo.datasetName + '创建成功',
@@ -1124,7 +1190,8 @@ export default {
     getPythonKafkaTmp () {
       this.pythonKafkaVisible = true
       var info = []
-      for (const meas of this.measurepoint) {
+      for (let meas of this.measurepoint) {
+        console.log('meas.indexOf(\'time\'):', meas.indexOf('time'))
         if (meas.indexOf('time') === -1) {
           info.push(meas)
         }
@@ -1133,166 +1200,313 @@ export default {
         this.$refs.pythonKafkaTmp.init(info.join())
       })
     },
-    getCoal (resolve) {
-      var coalData = {
-        userID: this.userID
-      }
+    loadTreeNode (node, resolve) {
       let coalAll = []
-      this.$http({
-        url: this.$http.adornUrl('/dataset/tree/getcoal'),
-        method: 'post',
-        data: this.$http.adornData(coalData, false)
-      }).then(({data}) => {
-        if (!(data && data.code === 0)) {
-          Message.error(data.msg)
-        } else {
-          const coalContent = data.info
-          for (let sign = 0; sign < coalContent.length; sign++) {
-            var coal = {
-              name: coalContent[sign].name,
-              coalid: coalContent[sign].id,
-              limit: 'coal',
-              hbaseTableName: '',
-              icon: 'iconfont icon-xitongfuwu',
-              leaf: false
-            }
-            coalAll.push(coal)
-          }
-        }
-        return resolve(coalAll)
-        // console.log('***************')
-        // console.log(coalAll)
-      })
-    },
-    getSystem (coalId, resolve) {
-      var coalData = {
-        userID: this.userID,
-        coalid: coalId
-      }
-      this.$http({
-        url: this.$http.adornUrl('/dataset/tree/getfisystem'),
-        method: 'post',
-        data: this.$http.adornData(coalData, false)
-      }).then(systemRespond => {
-        let systemAll = []
-        if (systemRespond.data.length <= 0) {
-          Message.error(systemRespond.msg)
-        } else {
-          const systemContent = systemRespond.data
-          for (let i = 0; i < systemContent.length; i++) {
-            var system = {
-              name: systemContent[i].name,
-              systemid: systemContent[i].id,
-              limit: 'system',
-              icon: 'icon iconfont icon-xitongfuwu',
-              hbaseTableName: '',
-              leaf: false
-            }
-            systemAll.push(system)
-          }
-        }
-        return resolve(systemAll)
-      })
-    },
-    getSubSystem (systemid, resolve) {
-      const systemData = {
-        systemid: systemid,
-        userID: this.userID
-      }
-      this.$http({
-        url: this.$http.adornUrl('/dataset/tree/getsubSystem'),
-        method: 'post',
-        data: this.$http.adornData(systemData, false)
-      }).then(subrespond => {
-        let subSystemAll = []
-        let subSystemContent = subrespond.data
-        if (subSystemContent.length !== 0) {
-          for (let j = 0; j < subSystemContent.length; j++) {
-            var subSystem = {
-              name: subSystemContent[j].name,
-              subSustemid: subSystemContent[j].id,
-              limit: 'subSystem',
-              icon: 'iconfont icon-xitongfuwu',
-              leaf: false
+      console.log('loadTreeNode')
+      if (node.level === 0) {
+        this.$http({
+          url: this.$http.adornUrl('/levelManage/projectattributes/getAllProject'),
+          method: 'post'
+        }).then(({data}) => {
+          console.log('后端返回的项目信息:' + JSON.stringify(data))
+          if (!(data && data.code === 0)) {
+            Message.error(data.msg)
+          } else {
+            let coalContent = data.data
+            for (let sign = 0; sign < coalContent.length; sign++) {
+              var coal = {
+                name: coalContent[sign].name,
+                coalid: coalContent[sign].id,
+                limit: 'coal',
+                hbaseTableName: '',
+                icon: 'iconfont icon-xitongfuwu',
+                leaf: false
+              }
+              if (data.data[sign].disabled === 0) {
+                coal.isdisabled = 1
+              } else {
+                coal.isdisabled = 0
+              }
+              coal.treeNodeDeep = 1
+              coalAll.push(coal)
             }
-            subSystemAll.push(subSystem)
           }
-        }
-        return resolve(subSystemAll)
-      })
-    },
-    getEquipment (subSustemid, resolve) {
-      const subSystemData = {
-        subSystemid: subSustemid,
-        userID: this.userID
+          console.log(coalAll)
+          return resolve(coalAll)
+        })
       }
-      this.$http({
-        url: this.$http.adornUrl('/dataset/tree/getequipment'),
-        method: 'post',
-        data: this.$http.adornData(subSystemData, false)
-      }).then(eqprespond => {
-        let equipmentAll = []
-        const eqpSystemContent = eqprespond.data
-        if (eqpSystemContent.length !== 0) {
-          for (let k = 0; k < eqpSystemContent.length; k++) {
-            var equipment = {
-              name: eqpSystemContent[k].name,
-              equipmentid: eqpSystemContent[k].id,
-              limit: 'equipment',
-              hbaseTableName: '',
-              icon: 'iconfont icon-xitongfuwu',
-              leaf: false
+      if (node.level === 1) {
+        if (node.data.isdisabled === 1) return resolve([])
+        else {
+          this.$http({
+            url: this.$http.adornUrl('/universaltable/getRootLevel?id=' + node.data.coalid),
+            method: 'post'
+          }).then(({data}) => {
+            console.log('第二层非叶子节点信息:' + JSON.stringify(data))
+            let data1 = []
+            let coalContent = data.data
+            for (let j = 0; j < coalContent.length; j++) {
+              let coal = {
+                name: coalContent[j].name,
+                coalid: coalContent[j].id,
+                limit: 'coal',
+                hbaseTableName: coalContent[j].hbaseTableName,
+                icon: 'icon iconfont icon-xitongfuwu',
+                // leaf: true,
+                levelId: data.levelId,
+                flag: 'subEquipment'
+              }
+              coal.treeNodeDeep = 2
+              data1.push(coal)
             }
-            equipmentAll.push(equipment)
-          }
+            return resolve(data1)
+          })
         }
-        return resolve(equipmentAll)
-      })
-    },
-    getSubEquipment (equipmentid, resolve) {
-      const equimentData = {
-        userID: this.userID,
-        equipment: equipmentid
       }
-      this.$http({
-        url: this.$http.adornUrl('/dataset/tree/getsubequipment'),
-        method: 'post',
-        data: this.$http.adornData(equimentData, false)
-      }).then(subEqpRespond => {
-        let subEquimentAll = []
-        const subEqpSystemContent = subEqpRespond.data
-        if (subEqpSystemContent.length === 0) {
-          Message.error(subEqpRespond.msg)
-        } else {
-          for (let m = 0; m < subEqpSystemContent.length; m++) {
-            var subEquiment = {
-              name: subEqpSystemContent[m].name,
-              subEquipmentid: subEqpSystemContent[m].id,
-              hbaseTableName: subEqpSystemContent[m].hbaseTableName,
-              limit: 'children',
-              icon: 'iconfont icon-xitong3',
-              leaf: true
-            }
-            subEquimentAll.push(subEquiment)
+      if (node.level > 1) {
+        for (let i = 2; i < 50; i++) {
+          if (node.level === i) {
+            this.$http({
+              url: this.$http.adornUrl('/universaltable/getSonLevel?tableId=' + node.data.levelId + '&id=' + node.data.coalid),
+              method: 'post'
+            }).then(({data}) => {
+              console.log('第三次非叶子节点信息:' + JSON.stringify(data.data))
+              let data2 = []
+              let coalContent = data.data
+              for (let j = 0; j < coalContent.length; j++) {
+                let coal = {
+                  name: coalContent[j].name,
+                  coalid: coalContent[j].id,
+                  limit: 'coal',
+                  hbaseTableName: coalContent[j].hbaseTableName,
+                  icon: 'icon iconfont icon-xitongfuwu',
+                  // leaf: true,
+                  levelId: data.levelId,
+                  flag: 'subEquipment'
+                }
+                coal.treeNodeDeep = i + 1
+                data2.push(coal)
+              }
+              return resolve(data2)
+            })
           }
         }
-        return resolve(subEquimentAll)
-      })
-    },
-    // 左侧树的懒加载 五层结构
-    loadTreeNode (node, resolve) {
-      if (node.level === 0) {
-        this.getCoal(resolve)
-      } else if (node.level === 1) {
-        this.getSystem(node.data.coalid, resolve)
-      } else if (node.level === 2) {
-        this.getSubSystem(node.data.systemid, resolve)
-      } else if (node.level === 3) {
-        this.getEquipment(node.data.subSustemid, resolve)
-      } else {
-        this.getSubEquipment(node.data.equipmentid, resolve)
       }
     }
+        //   this.postRequest('/levelManage/projectattributes/getAllProject').then(response => {
+        //     console.log('后端返回的项目信息:' + JSON.stringify(response.data))
+        //     for (let i = 0; i < response.data.data.length; i++) {
+        //       response.data.data[i].icon = 'iconfont icon-xuanze2'
+        //       console.log(response.data.data[i].name + ' ' + response.data.data[i].disabled)
+        //       if (response.data.data[i].disabled === 0) {
+        //         response.data.data[i].isdisabled = 1
+        //       } else {
+        //         response.data.data[i].isdisabled = 0
+        //       }
+        //       response.data.data[i].treeNodeDeep = 1
+        //       data.push(response.data.data[i])
+        //     }
+        //     return resolve(data);
+        //   })
+        // }
+        // if (node.level === 1) {
+        //   console.log('node.data.data.isdisabled:' + node.data.isdisabled)
+        //   if (node.data.isdisabled === 1) return resolve([])
+        //   else {
+        //     let data = []
+        //     this.postRequest('universaltable/getRootLevel?id=' + node.data.id).then(response => {
+        //       console.log('第二层非叶子节点信息:' + JSON.stringify(response.data))
+        //       for (let j = 0; j < response.data.data.length; j++) {
+        //         response.data.data[j].icon = 'iconfont icon-xuanze2'
+        //         response.data.data[j].levelId = response.data.levelId
+        //         response.data.data[i].treeNodeDeep = 2
+        //         response.data.data[j].flag = 'subEquipment'
+        //         response.data.data[j].leaf = true
+        //         data.push(response.data.data[j])
+        //       }
+        //       console.log('testPoint1 data:' + data)
+        //       return resolve(data);
+        //     })
+        //   }
+        // }
+        // if (node.level > 1) {
+        //   for (let i = 2; i < 50; i++) {
+        //     if (node.level === i) {
+        //       let data = []
+        //       this.postRequest('/universaltable/getSonLevel?tableId=' + node.data.levelId + '&id=' + node.data.id).then(response => {
+        //         console.log('第三次非叶子节点信息:' + JSON.stringify(response.data))
+        //         for (let j = 0; j < response.data.data.length; j++) {
+        //           response.data.data[j].icon = 'iconfont icon-xuanze2'
+        //           response.data.data[j].flag = 'subEquipment'
+        //           response.data.data[j].leaf = true
+        //           response.data.data[j].levelId = response.data.levelId
+        //           response.data.data[i].treeNodeDeep = i + 1
+        //           data.push(response.data.data[j])
+        //         }
+        //       })
+        //     }
+        //   }
+        // }
+    // getCoal (resolve) {
+    //   var coalData = {
+    //     userID: this.userID
+    //   }
+    //   let coalAll = []
+    //   this.$http({
+    //     url: this.$http.adornUrl('/dataset/tree/getcoal'),
+    //     method: 'post',
+    //     data: this.$http.adornData(coalData, false)
+    //   }).then(({data}) => {
+    //     if (!(data && data.code === 0)) {
+    //       Message.error(data.msg)
+    //     } else {
+    //       const coalContent = data.info
+    //       for (let sign = 0; sign < coalContent.length; sign++) {
+    //         var coal = {
+    //           name: coalContent[sign].name,
+    //           coalid: coalContent[sign].id,
+    //           limit: 'coal',
+    //           hbaseTableName: '',
+    //           icon: 'iconfont icon-xitongfuwu',
+    //           leaf: false
+    //         }
+    //         coalAll.push(coal)
+    //       }
+    //     }
+    //     return resolve(coalAll)
+    //     // console.log('***************')
+    //     // console.log(coalAll)
+    //   })
+    // },
+    // getSystem (coalId, resolve) {
+    //   var coalData = {
+    //     userID: this.userID,
+    //     coalid: coalId
+    //   }
+    //   this.$http({
+    //     url: this.$http.adornUrl('/dataset/tree/getfisystem'),
+    //     method: 'post',
+    //     data: this.$http.adornData(coalData, false)
+    //   }).then(systemRespond => {
+    //     let systemAll = []
+    //     if (systemRespond.data.length <= 0) {
+    //       Message.error(systemRespond.msg)
+    //     } else {
+    //       const systemContent = systemRespond.data
+    //       for (let i = 0; i < systemContent.length; i++) {
+    //         var system = {
+    //           name: systemContent[i].name,
+    //           systemid: systemContent[i].id,
+    //           limit: 'system',
+    //           icon: 'icon iconfont icon-xitongfuwu',
+    //           hbaseTableName: '',
+    //           leaf: false
+    //         }
+    //         systemAll.push(system)
+    //       }
+    //     }
+    //     return resolve(systemAll)
+    //   })
+    // },
+    // getSubSystem (systemid, resolve) {
+    //   const systemData = {
+    //     systemid: systemid,
+    //     userID: this.userID
+    //   }
+    //   this.$http({
+    //     url: this.$http.adornUrl('/dataset/tree/getsubSystem'),
+    //     method: 'post',
+    //     data: this.$http.adornData(systemData, false)
+    //   }).then(subrespond => {
+    //     let subSystemAll = []
+    //     let subSystemContent = subrespond.data
+    //     if (subSystemContent.length !== 0) {
+    //       for (let j = 0; j < subSystemContent.length; j++) {
+    //         var subSystem = {
+    //           name: subSystemContent[j].name,
+    //           subSustemid: subSystemContent[j].id,
+    //           limit: 'subSystem',
+    //           icon: 'iconfont icon-xitongfuwu',
+    //           leaf: false
+    //         }
+    //         subSystemAll.push(subSystem)
+    //       }
+    //     }
+    //     return resolve(subSystemAll)
+    //   })
+    // },
+    // getEquipment (subSustemid, resolve) {
+    //   const subSystemData = {
+    //     subSystemid: subSustemid,
+    //     userID: this.userID
+    //   }
+    //   this.$http({
+    //     url: this.$http.adornUrl('/dataset/tree/getequipment'),
+    //     method: 'post',
+    //     data: this.$http.adornData(subSystemData, false)
+    //   }).then(eqprespond => {
+    //     let equipmentAll = []
+    //     const eqpSystemContent = eqprespond.data
+    //     if (eqpSystemContent.length !== 0) {
+    //       for (let k = 0; k < eqpSystemContent.length; k++) {
+    //         var equipment = {
+    //           name: eqpSystemContent[k].name,
+    //           equipmentid: eqpSystemContent[k].id,
+    //           limit: 'equipment',
+    //           hbaseTableName: '',
+    //           icon: 'iconfont icon-xitongfuwu',
+    //           leaf: false
+    //         }
+    //         equipmentAll.push(equipment)
+    //       }
+    //     }
+    //     return resolve(equipmentAll)
+    //   })
+    // },
+    // getSubEquipment (equipmentid, resolve) {
+    //   const equimentData = {
+    //     userID: this.userID,
+    //     equipment: equipmentid
+    //   }
+    //   this.$http({
+    //     url: this.$http.adornUrl('/dataset/tree/getsubequipment'),
+    //     method: 'post',
+    //     data: this.$http.adornData(equimentData, false)
+    //   }).then(subEqpRespond => {
+    //     let subEquimentAll = []
+    //     const subEqpSystemContent = subEqpRespond.data
+    //     if (subEqpSystemContent.length === 0) {
+    //       Message.error(subEqpRespond.msg)
+    //     } else {
+    //       for (let m = 0; m < subEqpSystemContent.length; m++) {
+    //         var subEquiment = {
+    //           name: subEqpSystemContent[m].name,
+    //           subEquipmentid: subEqpSystemContent[m].id,
+    //           hbaseTableName: subEqpSystemContent[m].hbaseTableName,
+    //           limit: 'children',
+    //           icon: 'iconfont icon-xitong3',
+    //           leaf: true
+    //         }
+    //         subEquimentAll.push(subEquiment)
+    //       }
+    //     }
+    //     return resolve(subEquimentAll)
+    //   })
+    // },
+    // 左侧树的懒加载 五层结构
+    // loadTreeNode (node, resolve) {
+    //   if (node.level === 0) {
+    //     this.getCoal(resolve)
+    //   } else if (node.level === 1) {
+    //     this.getSystem(node.data.coalid, resolve)
+    //   } else if (node.level === 2) {
+    //     this.getSubSystem(node.data.systemid, resolve)
+    //   } else if (node.level === 3) {
+    //     this.getEquipment(node.data.subSustemid, resolve)
+    //   } else {
+    //     this.getSubEquipment(node.data.equipmentid, resolve)
+    //   }
+    // }
     // // 左侧树的懒加载
     // loadTreeNode (node, resolve) {
     //   if (node.level === 0) {

+ 309 - 178
src/views/modules/visi/create2.vue

@@ -46,9 +46,9 @@
         </el-form-item>
 
         <!-- 测试一下获得python-kafka模板 -->
-        <el-form-item>
-          <el-button type="primary" @click="getPythonKafkaTmp()">获得代码模板</el-button>
-        </el-form-item>
+<!--        <el-form-item>-->
+<!--          <el-button type="primary" @click="getPythonKafkaTmp()">获得代码模板</el-button>-->
+<!--        </el-form-item>-->
       </el-form>
     </div>
     <div class="body">  <!-- 数据框整体大小 -->
@@ -64,8 +64,8 @@
               node-key="subEquipmentid"
               :props="treeDefaultProps"
               ref="tree"
-                :load="loadTreeNode"
-                lazy
+              :load="loadTreeNode"
+              lazy
               draggable
               :allow-drag="allowdrag"
               :allow-drop="allowDrop"
@@ -508,7 +508,7 @@ export default {
 
         if (id === this.subEquipments[i].id) {
           this.$refs.tree.getNode(this.subEquipments[i].sql.subEquipmentID).data.icon = 'iconfont icon-xitong3'
-          this.$refs.tree.getNode(this.subEquipments[i].sql.subEquipmentID).data.limit = 'children'
+          this.$refs.tree.getNode(this.subEquipments[i].sql.subEquipmentID).data.flag = 'subEquipment'
           // 看当前左侧属性栏显示的数据 ,是否为该设备 ,如果是,进行清除
           if (this.detailTitle.worldName === this.subEquipments[i].imageTable.tableName) {
             this.detailTitle.worldName = '属性信息'
@@ -535,7 +535,7 @@ export default {
       }
     },
     allowdrag (node) {
-      if (node.data.limit === 'children') { return true }
+      if (node.data.flag === 'subEquipment') { return true }
     },
     allowDrop () {
       return false // 设置树节点内不可拖拽
@@ -548,7 +548,7 @@ export default {
       this.dragFlg = 0
     },
     treeNodeDragEnd (node) {
-      if (this.dragFlg === 1 && node.data.limit === 'children') {
+      if (this.dragFlg === 1 && node.data.flag === 'subEquipment') {
         // 修改属性值,表示该节点已经拖拽过
         node.data.limit = 'children-1'
         node.data.icon = 'iconfont icon-xitong4'
@@ -591,26 +591,58 @@ export default {
         subEquipment.imageTable.tableDB = node.parent.data.name
         subEquipment.sql.hbaseTableName = node.data.hbaseTableName
         subEquipment.sql.subEquipmentID = node.data.subEquipmentid
-
-        // 获取hbase 表头信息
-        this.$http({
-          url: this.$http.adornUrl('/dataset/dynamic/getheads'),
-          method: 'post',
-          data: this.$http.adornData(subEquipment.sql, false)
-        }).then(tablists => {
-          var headers = tablists.data.hbaseTableHeaders
-          if (headers) {
-            for (let i = 0; i < headers.length; i++) {
-              var list = {
-                key: i + 1,
-                measurepointId: headers[i].measurepointId,
-                prop: headers[i].name_en,
-                label: headers[i].name_zh
+        console.log(subEquipment.sql.hbaseTableName + 'and' + subEquipment.sql.subEquipmentID)
+        if (node.level === 1) {
+          this.$http({
+            url: this.$http.adornUrl('/universaltable/getRootLevel' + node.data.subEquipmentid),
+            method: 'post'
+          }).then(tablists => {
+            let headers = tablists.data.data
+            console.log('第二层headers:' + JSON.stringify(headers))
+            if (headers) {
+              for (let i = 0; i < headers.length; i++) {
+                var list = {
+                  key: i + 1,
+                  label: headers[i].name,
+                  type: headers[i].type,
+                  // fieldId: response.data[i].fieldId,
+                  measurepointId: headers[i].id,
+                  flag: '未选中',
+                  prop: headers[i].name,
+                  seen: false
+                }
+                console.log('list:' + list)
+                subEquipment.filedList.push(list)
               }
-              subEquipment.filedList.push(list)
             }
-          }
-        })
+          })
+        }
+        if (node.level > 1) {
+          // 获取hbase 表头信息
+          this.$http({
+            url: this.$http.adornUrl('/universaltable/getOtherLeafItem?tableId=' + node.data.levelId + '&id=' + node.data.subEquipmentid),
+            method: 'post'
+          }).then(tablists => {
+            let headers = tablists.data.data
+            console.log('第三层及之后headers:' + JSON.stringify(headers))
+            if (headers) {
+              for (let i = 0; i < headers.length; i++) {
+                var list = {
+                  key: i + 1,
+                  label: headers[i].name,
+                  type: headers[i].type,
+                  // fieldId: response.data[i].fieldId,
+                  measurepointId: headers[i].id,
+                  flag: '未选中',
+                  prop: headers[i].name,
+                  seen: false
+                }
+                console.log('list:' + list)
+                subEquipment.filedList.push(list)
+              }
+            }
+          })
+        }
         //
         // // 拖拽结束后,如果属性区域没显示数据,自动显示拖拽的设备
         // if (this.tablelists.length === 0) {
@@ -631,7 +663,7 @@ export default {
       }
     },
     treeNodeClick (data, node) {
-      if (node.data.limit === 'children') {
+      if (node.data.flag === 'subEquipment') {
         this.detailTitle.worldName = node.data.name
         this.equimentClick()
       }
@@ -657,7 +689,13 @@ export default {
         if (id === this.subEquipments[i].id) {
           // 处理两次单击同一个设备
           if (this.detailTitle.worldName !== this.subEquipments[i].imageTable.tableName) {
-            this.tablelists = this.subEquipments[i].filedList
+            let l = []
+            for (let j = 0; j < this.subEquipments[i].filedList.length; j++) {
+              let o = this.subEquipments[i].filedList[j] + '_after'
+              l.push(o)
+            }
+            // this.tablelists = this.subEquipments[i].filedList
+            this.tablelists = l
             this.detailTitle.worldName = this.subEquipments[i].imageTable.tableName
             this.tableData = []
             // 获取右侧表格数据
@@ -840,168 +878,261 @@ export default {
         this.$refs.pythonKafkaTmp.init(info.join())
       })
     },
-
-    getCoal (resolve) {
-      var coalData = {
-        userID: this.userID
-      }
+    loadTreeNode (node, resolve) {
       let coalAll = []
-      this.$http({
-        url: this.$http.adornUrl('/dataset/tree/getcoal'),
-        method: 'post',
-        data: this.$http.adornData(coalData, false)
-      }).then(({data}) => {
-        if (!(data && data.code === 0)) {
-          Message.error(data.msg)
-        } else {
-          const coalContent = data.info
-          for (let sign = 0; sign < coalContent.length; sign++) {
-            var coal = {
-              name: coalContent[sign].name,
-              coalid: coalContent[sign].id,
-              limit: 'coal',
-              hbaseTableName: '',
-              icon: 'iconfont icon-xitongfuwu',
-              leaf: false
-            }
-            coalAll.push(coal)
-          }
-        }
-        return resolve(coalAll)
-        // console.log('***************')
-        // console.log(coalAll)
-      })
-    },
-    getSystem (coalId, resolve) {
-      var coalData = {
-        userID: this.userID,
-        coalid: coalId
-      }
-      this.$http({
-        url: this.$http.adornUrl('/dataset/tree/getfisystem'),
-        method: 'post',
-        data: this.$http.adornData(coalData, false)
-      }).then(systemRespond => {
-        let systemAll = []
-        if (systemRespond.data.length <= 0) {
-          Message.error(systemRespond.msg)
-        } else {
-          const systemContent = systemRespond.data
-          for (let i = 0; i < systemContent.length; i++) {
-            var system = {
-              name: systemContent[i].name,
-              systemid: systemContent[i].id,
-              limit: 'system',
-              icon: 'icon iconfont icon-xitongfuwu',
-              hbaseTableName: '',
-              leaf: false
-            }
-            systemAll.push(system)
-          }
-        }
-        return resolve(systemAll)
-      })
-    },
-    getSubSystem (systemid, resolve) {
-      const systemData = {
-        systemid: systemid,
-        userID: this.userID
-      }
-      this.$http({
-        url: this.$http.adornUrl('/dataset/tree/getsubSystem'),
-        method: 'post',
-        data: this.$http.adornData(systemData, false)
-      }).then(subrespond => {
-        let subSystemAll = []
-        let subSystemContent = subrespond.data
-        if (subSystemContent.length !== 0) {
-          for (let j = 0; j < subSystemContent.length; j++) {
-            var subSystem = {
-              name: subSystemContent[j].name,
-              subSustemid: subSystemContent[j].id,
-              limit: 'subSystem',
-              icon: 'iconfont icon-xitongfuwu',
-              leaf: false
+      console.log('loadTreeNode')
+      if (node.level === 0) {
+        this.$http({
+          url: this.$http.adornUrl('/levelManage/projectattributes/getAllProject'),
+          method: 'post'
+        }).then(({data}) => {
+          console.log('后端返回的项目信息:' + JSON.stringify(data))
+          if (!(data && data.code === 0)) {
+            Message.error(data.msg)
+          } else {
+            let coalContent = data.data
+            for (let sign = 0; sign < coalContent.length; sign++) {
+              var coal = {
+                name: coalContent[sign].name,
+                subEquipmentid: coalContent[sign].id,
+                limit: 'coal',
+                hbaseTableName: '',
+                icon: 'iconfont icon-xitongfuwu',
+                leaf: false
+              }
+              if (data.data[sign].disabled === 0) {
+                coal.isdisabled = 1
+              } else {
+                coal.isdisabled = 0
+              }
+              coal.treeNodeDeep = 1
+              coalAll.push(coal)
             }
-            subSystemAll.push(subSystem)
           }
-        }
-        return resolve(subSystemAll)
-      })
-    },
-    getEquipment (subSustemid, resolve) {
-      const subSystemData = {
-        subSystemid: subSustemid,
-        userID: this.userID
+          console.log(coalAll)
+          return resolve(coalAll)
+        })
       }
-      this.$http({
-        url: this.$http.adornUrl('/dataset/tree/getequipment'),
-        method: 'post',
-        data: this.$http.adornData(subSystemData, false)
-      }).then(eqprespond => {
-        let equipmentAll = []
-        const eqpSystemContent = eqprespond.data
-        if (eqpSystemContent.length !== 0) {
-          for (let k = 0; k < eqpSystemContent.length; k++) {
-            var equipment = {
-              name: eqpSystemContent[k].name,
-              equipmentid: eqpSystemContent[k].id,
-              limit: 'equipment',
-              hbaseTableName: '',
-              icon: 'iconfont icon-xitongfuwu',
-              leaf: false
+      if (node.level === 1) {
+        if (node.data.isdisabled === 1) return resolve([])
+        else {
+          this.$http({
+            url: this.$http.adornUrl('/universaltable/getRootLevel?id=' + node.data.subEquipmentid),
+            method: 'post'
+          }).then(({data}) => {
+            console.log('第二层非叶子节点信息:' + JSON.stringify(data))
+            let data1 = []
+            let coalContent = data.data
+            for (let j = 0; j < coalContent.length; j++) {
+              let coal = {
+                name: coalContent[j].name,
+                subEquipmentid: coalContent[j].id,
+                limit: 'coal',
+                hbaseTableName: coalContent[j].hbaseTableName,
+                icon: 'icon iconfont icon-xitongfuwu',
+                // leaf: true,
+                levelId: data.levelId,
+                flag: 'subEquipment'
+              }
+              coal.treeNodeDeep = 2
+              data1.push(coal)
             }
-            equipmentAll.push(equipment)
-          }
+            return resolve(data1)
+          })
         }
-        return resolve(equipmentAll)
-      })
-    },
-    getSubEquipment (equipmentid, resolve) {
-      const equimentData = {
-        userID: this.userID,
-        equipment: equipmentid
       }
-      this.$http({
-        url: this.$http.adornUrl('/dataset/tree/getsubequipment'),
-        method: 'post',
-        data: this.$http.adornData(equimentData, false)
-      }).then(subEqpRespond => {
-        let subEquimentAll = []
-        const subEqpSystemContent = subEqpRespond.data
-        if (subEqpSystemContent.length === 0) {
-          Message.error(subEqpRespond.msg)
-        } else {
-          for (let m = 0; m < subEqpSystemContent.length; m++) {
-            var subEquiment = {
-              name: subEqpSystemContent[m].name,
-              subEquipmentid: subEqpSystemContent[m].id,
-              hbaseTableName: subEqpSystemContent[m].hbaseTableName,
-              limit: 'children',
-              icon: 'iconfont icon-xitong3',
-              leaf: true
-            }
-            subEquimentAll.push(subEquiment)
+      if (node.level > 1) {
+        for (let i = 2; i < 50; i++) {
+          if (node.level === i) {
+            this.$http({
+              url: this.$http.adornUrl('/universaltable/getSonLevel?tableId=' + node.data.levelId + '&id=' + node.data.subEquipmentid),
+              method: 'post'
+            }).then(({data}) => {
+              console.log('第三次非叶子节点信息:' + JSON.stringify(data.data))
+              let data2 = []
+              let coalContent = data.data
+              for (let j = 0; j < coalContent.length; j++) {
+                let coal = {
+                  name: coalContent[j].name,
+                  subEquipmentid: coalContent[j].id,
+                  limit: 'coal',
+                  hbaseTableName: coalContent[j].hbaseTableName,
+                  icon: 'icon iconfont icon-xitongfuwu',
+                  // leaf: true,
+                  levelId: data.levelId,
+                  flag: 'subEquipment'
+                }
+                coal.treeNodeDeep = i + 1
+                data2.push(coal)
+              }
+              return resolve(data2)
+            })
           }
         }
-        return resolve(subEquimentAll)
-      })
-    },
-    // 左侧树的懒加载 五层结构
-    loadTreeNode (node, resolve) {
-      if (node.level === 0) {
-        this.getCoal(resolve)
-      } else if (node.level === 1) {
-        this.getSystem(node.data.coalid, resolve)
-      } else if (node.level === 2) {
-        this.getSubSystem(node.data.systemid, resolve)
-      } else if (node.level === 3) {
-        this.getEquipment(node.data.subSustemid, resolve)
-      } else {
-        this.getSubEquipment(node.data.equipmentid, resolve)
       }
     }
 
+    // getCoal (resolve) {
+    //   var coalData = {
+    //     userID: this.userID
+    //   }
+    //   let coalAll = []
+    //   this.$http({
+    //     url: this.$http.adornUrl('/dataset/tree/getcoal'),
+    //     method: 'post',
+    //     data: this.$http.adornData(coalData, false)
+    //   }).then(({data}) => {
+    //     if (!(data && data.code === 0)) {
+    //       Message.error(data.msg)
+    //     } else {
+    //       const coalContent = data.info
+    //       for (let sign = 0; sign < coalContent.length; sign++) {
+    //         var coal = {
+    //           name: coalContent[sign].name,
+    //           coalid: coalContent[sign].id,
+    //           limit: 'coal',
+    //           hbaseTableName: '',
+    //           icon: 'iconfont icon-xitongfuwu',
+    //           leaf: false
+    //         }
+    //         coalAll.push(coal)
+    //       }
+    //     }
+    //     return resolve(coalAll)
+    //     // console.log('***************')
+    //     // console.log(coalAll)
+    //   })
+    // },
+    // getSystem (coalId, resolve) {
+    //   var coalData = {
+    //     userID: this.userID,
+    //     coalid: coalId
+    //   }
+    //   this.$http({
+    //     url: this.$http.adornUrl('/dataset/tree/getfisystem'),
+    //     method: 'post',
+    //     data: this.$http.adornData(coalData, false)
+    //   }).then(systemRespond => {
+    //     let systemAll = []
+    //     if (systemRespond.data.length <= 0) {
+    //       Message.error(systemRespond.msg)
+    //     } else {
+    //       const systemContent = systemRespond.data
+    //       for (let i = 0; i < systemContent.length; i++) {
+    //         var system = {
+    //           name: systemContent[i].name,
+    //           systemid: systemContent[i].id,
+    //           limit: 'system',
+    //           icon: 'icon iconfont icon-xitongfuwu',
+    //           hbaseTableName: '',
+    //           leaf: false
+    //         }
+    //         systemAll.push(system)
+    //       }
+    //     }
+    //     return resolve(systemAll)
+    //   })
+    // },
+    // getSubSystem (systemid, resolve) {
+    //   const systemData = {
+    //     systemid: systemid,
+    //     userID: this.userID
+    //   }
+    //   this.$http({
+    //     url: this.$http.adornUrl('/dataset/tree/getsubSystem'),
+    //     method: 'post',
+    //     data: this.$http.adornData(systemData, false)
+    //   }).then(subrespond => {
+    //     let subSystemAll = []
+    //     let subSystemContent = subrespond.data
+    //     if (subSystemContent.length !== 0) {
+    //       for (let j = 0; j < subSystemContent.length; j++) {
+    //         var subSystem = {
+    //           name: subSystemContent[j].name,
+    //           subSustemid: subSystemContent[j].id,
+    //           limit: 'subSystem',
+    //           icon: 'iconfont icon-xitongfuwu',
+    //           leaf: false
+    //         }
+    //         subSystemAll.push(subSystem)
+    //       }
+    //     }
+    //     return resolve(subSystemAll)
+    //   })
+    // },
+    // getEquipment (subSustemid, resolve) {
+    //   const subSystemData = {
+    //     subSystemid: subSustemid,
+    //     userID: this.userID
+    //   }
+    //   this.$http({
+    //     url: this.$http.adornUrl('/dataset/tree/getequipment'),
+    //     method: 'post',
+    //     data: this.$http.adornData(subSystemData, false)
+    //   }).then(eqprespond => {
+    //     let equipmentAll = []
+    //     const eqpSystemContent = eqprespond.data
+    //     if (eqpSystemContent.length !== 0) {
+    //       for (let k = 0; k < eqpSystemContent.length; k++) {
+    //         var equipment = {
+    //           name: eqpSystemContent[k].name,
+    //           equipmentid: eqpSystemContent[k].id,
+    //           limit: 'equipment',
+    //           hbaseTableName: '',
+    //           icon: 'iconfont icon-xitongfuwu',
+    //           leaf: false
+    //         }
+    //         equipmentAll.push(equipment)
+    //       }
+    //     }
+    //     return resolve(equipmentAll)
+    //   })
+    // },
+    // getSubEquipment (equipmentid, resolve) {
+    //   const equimentData = {
+    //     userID: this.userID,
+    //     equipment: equipmentid
+    //   }
+    //   this.$http({
+    //     url: this.$http.adornUrl('/dataset/tree/getsubequipment'),
+    //     method: 'post',
+    //     data: this.$http.adornData(equimentData, false)
+    //   }).then(subEqpRespond => {
+    //     let subEquimentAll = []
+    //     const subEqpSystemContent = subEqpRespond.data
+    //     if (subEqpSystemContent.length === 0) {
+    //       Message.error(subEqpRespond.msg)
+    //     } else {
+    //       for (let m = 0; m < subEqpSystemContent.length; m++) {
+    //         var subEquiment = {
+    //           name: subEqpSystemContent[m].name,
+    //           subEquipmentid: subEqpSystemContent[m].id,
+    //           hbaseTableName: subEqpSystemContent[m].hbaseTableName,
+    //           limit: 'children',
+    //           icon: 'iconfont icon-xitong3',
+    //           leaf: true
+    //         }
+    //         subEquimentAll.push(subEquiment)
+    //       }
+    //     }
+    //     return resolve(subEquimentAll)
+    //   })
+    // },
+    // // 左侧树的懒加载 五层结构
+    // loadTreeNode (node, resolve) {
+    //   if (node.level === 0) {
+    //     this.getCoal(resolve)
+    //   } else if (node.level === 1) {
+    //     this.getSystem(node.data.coalid, resolve)
+    //   } else if (node.level === 2) {
+    //     this.getSubSystem(node.data.systemid, resolve)
+    //   } else if (node.level === 3) {
+    //     this.getEquipment(node.data.subSustemid, resolve)
+    //   } else {
+    //     this.getSubEquipment(node.data.equipmentid, resolve)
+    //   }
+    // }
+
     // getSubSystem (resolve) {
     //   this.$http({
     //     url: this.$http.adornUrl('/dataset/tree/getsubSystem'),