yizai 3 年之前
父节点
当前提交
4025a84fcc

+ 57 - 45
src/views/bridge/device-manage/device-work.vue

@@ -5,7 +5,23 @@
     </div>
     <el-container class="content-height-fit">
       <inner-sidebar>
-        <DeviceTree @node-click="handleTreeClick" />
+        <div id="project-section-tree">
+          <el-tree
+            ref="tree"
+            style="margin-top:5px;"
+            class="filter-tree"
+            :props="treeProps"
+            :highlight-current="true"
+            :data="treeData"
+            @node-click="nodeClick"
+          >
+            <span slot-scope="{ data }" class="custom-tree-node">
+              <el-tag v-if="data.isDevice && data.deviceType===0" size="mini" type="danger">架桥机</el-tag>
+              <el-tag v-if="data.isDevice && data.deviceType===1" size="mini" type="danger">运梁车</el-tag>
+              <span>{{ data.name }}</span>
+            </span>
+          </el-tree>
+        </div>
       </inner-sidebar>
       <el-container class="resize-fit-container">
         <div>
@@ -22,8 +38,6 @@
 <script>
 import * as interfaceApi from '@/api/device-manage.js'
 import * as griderApi from '@/api/grider-erection'
-import * as areaApi from '@/api/backbone/section-area'
-import * as dictEntryApi from '@/api/dict-entry.js'
 const defaultSettings = require('@/settings.js')
 // import ProjectSectionTree from '@/views/projects/components/ProjectSectionTree'
 import DeviceTree from '@/views/projects/components/DeviceTree.vue'
@@ -50,40 +64,61 @@ export default {
       },
       dialogFormVisible: false,
       dialogStatus: '',
-      node: {},
       griders: [],
+      treeFilterText: '',
+      treeData: [],
+      treeProps: {
+        children: 'children',
+        label: 'name',
+        isLeaf: 'isDevice'
+      },
+      tkySectionId: this.$route.query.token,
       formLoading: false
     }
   },
   watch: {
+    treeFilterText(val) {
+      this.$refs.tree.filter(val)
+    }
   },
   created() {
     try {
       this.$store.dispatch('user/clientCredentials')
+        .then(res => {
+          this.loadTreeNode()
+        })
       this.loading = false
     } catch (ex) {
       console.log(ex)
     }
   },
   methods: {
-    getJQJTypes() {
-      dictEntryApi.getJQJTypes().then(res => {
-        res.forEach(t => {
-          t.code = t.code - 0
-        })
-        this.jqjTypes = res
-      })
+    filterTree(value, data) {
+      if (!value) return true
+      return data.name.indexOf(value) !== -1
     },
-    getYLCTypes() {
-      dictEntryApi.getYLCTypes().then(res => {
-        res.forEach(t => {
-          t.code = t.code - 0
+    loadTreeNode(node, resolve) {
+      griderApi.getDeviceList(this.tkySectionId)
+        .then(res => {
+          res.forEach(t => {
+            t.isDevice = true
+            t.code = t.deviceNo
+            t.name = t.tkySectionName + t.deviceName
+            t.children = []
+          })
+          this.treeData = res
+          if (this.treeData.length > 0) {
+            this.$nextTick(() => {
+              document
+                .querySelector('.custom-tree-node')
+                .click()
+            })
+            // this.nodeClick(this.treeData[0])
+          }
         })
-        this.ylcTypes = res
-      })
     },
     // 树形事件
-    handleTreeClick(data) {
+    nodeClick(data) {
       this.node = data
       if (data.isDevice) {
         this.listQuery.deviceCode = data.deviceNo
@@ -97,29 +132,6 @@ export default {
           })
       }
     },
-    getArea() {
-      this.areas = []
-      areaApi.lookupBySection(this.listQuery.sectionId).then(res => {
-        res.forEach(t => {
-          this.areas.push({
-            id: t.id,
-            name: t.name
-          })
-        })
-      })
-    },
-    getAreaName(areaId) {
-      const area = this.areas.find(t => t.id === areaId)
-      if (area) {
-        return area.name
-      } else {
-        return ''
-      }
-    },
-    // 清空下拉
-    delValue(parameter) {
-      this.listQuery[parameter] = undefined
-    },
     // 获取数据列表
     getList() {
       this.listLoading = true
@@ -138,10 +150,10 @@ export default {
           this.listLoading = false
         })
     },
-    nodeClick(beamCode) {
-      this.listQuery.beamCode = beamCode
-      this.getList()
-    },
+    // nodeClick(beamCode) {
+    //   this.listQuery.beamCode = beamCode
+    //   this.getList()
+    // },
     // 查询
     handleFilter() {
       this.listQuery.skipCount = 0

+ 12 - 12
src/views/bridge/device-manage/tky-manage.vue

@@ -173,7 +173,7 @@ import TacklingSys from '@/views/bridge/device-manage/components/tackling-sys.vu
 import LimitState from '@/views/bridge/device-manage/components//limit-state.vue'
 import Kiosk2dModel from '@/views/grider-erections/gride-work-info/components/kiosk-2d-model.vue'
 import * as griderErectionApi from '@/api/grider-erection'
-import JSWebrtc from '@/utils/webRtc'
+// import JSWebrtc from '@/utils/webRtc'
 import _ from 'lodash'
 
 export default {
@@ -238,17 +238,17 @@ export default {
     // } catch (ex) {
     //   console.log(ex)
     // }
-    this.$nextTick(() => {
-      _.forEach(this.videos, (i, index) => {
-        var id = 'video' + index
-        var video = document.getElementById(id)
-        new JSWebrtc.Player(i.webRtc, {
-          video: video,
-          autoplay: true,
-          onPlay: obj => {}
-        })
-      })
-    })
+    // this.$nextTick(() => {
+    //   _.forEach(this.videos, (i, index) => {
+    //     var id = 'video' + index
+    //     var video = document.getElementById(id)
+    //     new JSWebrtc.Player(i.webRtc, {
+    //       video: video,
+    //       autoplay: true,
+    //       onPlay: obj => {}
+    //     })
+    //   })
+    // })
   },
   methods: {
     show(data) {

+ 8 - 8
src/views/projects/components/DeviceTree.vue

@@ -55,13 +55,13 @@ export default {
       this.$refs.tree.filter(val)
     }
   },
-  mounted() {
-    // try {
-    //   this.$store.dispatch('user/clientCredentials')
-    //   this.loading = false
-    // } catch (ex) {
-    //   console.log(ex)
-    // }
+  created() {
+    try {
+      this.$store.dispatch('user/clientCredentials')
+      this.loading = false
+    } catch (ex) {
+      console.log(ex)
+    }
   },
   methods: {
     filterTree(value, data) {
@@ -69,6 +69,7 @@ export default {
       return data.name.indexOf(value) !== -1
     },
     loadTreeNode(node, resolve) {
+      console.log('asdasdsad')
       if (node.level === 0) {
         manageApi.getDeviceList(this.tkySectionId)
           .then(res => {
@@ -77,7 +78,6 @@ export default {
               t.code = t.deviceNo
               t.name = t.tkySectionName + t.deviceName
             })
-            console.log(res)
             return resolve(res)
           })
         // projectApi.lookupAll().then(projects => {