From 798610ea27080fbc416997ad573cb1f1f1ab1ae2 Mon Sep 17 00:00:00 2001
From: licp <lichunping@guanfang.com.cn>
Date: 星期二, 30 七月 2024 11:08:52 +0800
Subject: [PATCH] 修改温度循环bug

---
 src/components/view/a6-device.vue |  154 +++++++++++++++++++++++++++++++++++---------------
 1 files changed, 107 insertions(+), 47 deletions(-)

diff --git a/src/components/view/a6-device.vue b/src/components/view/a6-device.vue
index 2ea9f0b..b904515 100644
--- a/src/components/view/a6-device.vue
+++ b/src/components/view/a6-device.vue
@@ -1,12 +1,24 @@
 <template>
   <div class="device-page">
     <div class="device-left">
-      <el-input placeholder="杈撳叆璁惧鍚嶇О" suffix-icon="el-icon-search" v-model="search" size="small"
-      @keyup.enter="handleSearch"
-      style="margin-bottom: 5px;" clearable @change="handleSearch"></el-input>
-      <ul v-loading="loading">
-        <li v-for="(item,index) in 28" :title="item" :class="{active:index==current}" @click="getCurrentDevice(item,index)">璁惧鍒楄〃璁惧鍒楄〃璁惧鍒楄〃璁惧鍒楄〃</li>
-      </ul>
+      <el-input placeholder="杈撳叆璁惧鍚嶇О" suffix-icon="el-icon-search" v-model="deviceName" size="small"
+      @keyup.enter="geList"
+      style="margin-bottom: 5px;" clearable @change="geList"></el-input>
+      <el-tree :data="list" ref="tree" :props="{ children: 'children', label: 'label' }" node-key="id" @node-click="handleNodeClick" highlight-current @node-expand="nodeOpen"
+        @node-collapse="nodeClose" v-loading="loading" :expand-on-click-node="false"
+        :default-expanded-keys="expandedKeys"
+        style="height:calc(100% - 46px);overflow-y: scroll;scrollbar-width: none;">
+        <div class="custom-tree-node" slot-scope="{ node, data }">
+          <el-row style="width: 100%;">
+            <el-col :span="21" :title="data.label">
+              <span class="single-line-ellipsis" style="width: 100%;display: inline-block;">
+                <i :class="`node_i ${data.children != undefined ? (data.code==='[1]'?'el-icon-folder-opened':'el-icon-folder') : 'el-icon-tickets'}`"></i>
+                {{ data.label }}
+              </span>
+            </el-col>
+          </el-row>
+        </div>
+      </el-tree>
     </div>
     <div class="device-right">
       <el-radio-group v-model="currentPage" size="small">
@@ -22,14 +34,31 @@
 
 <script>
 import operationOverview from '../do/a6-device/operation-overview.vue';
+import files from '../do/a6-device/files.vue';
+import checkAndAccept from '../do/a6-device/check-and-accept.vue';
+import calibration from '../do/a6-device/calibration.vue';
+import check from '../do/a6-device/check.vue';
+import maintenance from '../do/a6-device/maintenance.vue';
+import borrow from "../do/a6-device/borrow.vue";
+import fault from "../do/a6-device/fault.vue";
+import record from '../do/a6-device/record.vue';
+import state from '../do/a6-device/state.vue';
 export default {
   components:{
     operationOverview,
+    files,
+    checkAndAccept,
+    calibration,
+    check,
+    maintenance,
+    borrow,
+    fault,
+    record,
+    state,
   },
   data(){
     return {
-      search:'',
-      current:0,
+      deviceName:'',
       loading:false,
       tabList:[
         {
@@ -37,53 +66,96 @@
           title:'璁惧杩愯鎬昏',
         },
         {
-          id:1,
+          id:'files',
           title:'璁惧妗f',
         },
         {
-          id:2,
+          id:'checkAndAccept',
           title:'璁惧楠屾敹',
         },
         {
-          id:3,
+          id:'calibration',
           title:'璁惧鏍″噯',
         },
         {
-          id:4,
+          id:'check',
           title:'璁惧鏍告煡',
         },
         {
-          id:5,
+          id:'maintenance',
           title:'璁惧缁存姢',
         },
         {
-          id:6,
+          id:'borrow',
           title:'璁惧鍊熺敤',
         },
         {
-          id:7,
+          id:'fault',
           title:'璁惧鏁呴殰',
         },
         {
-          id:8,
+          id:'record',
           title:'浣跨敤璁板綍',
         },
         {
-          id:9,
+          id:'state',
           title:'璁惧鍋滅敤/鍚敤',
         },
       ],
-      currentPage:'operationOverview'
+      currentPage:'operationOverview',
+      expandedKeys:[],
+      selectTree:'',
+      list:[]
     }
   },
+  mounted(){
+    this.geList()
+  },
   methods:{
-    handleSearch(m){
-      // this.loading = true;
+    geList(){
+      this.loading = true;
+      this.$axios.get(this.$api.deviceScope.treeDevice+'?deviceName='+this.deviceName).then(res => {
+        this.loading = false;
+          let data = res.data
+          data.forEach((item,index) => {
+            item.id = index +1
+            item.label = item.largeCategory
+            item.children.forEach((m,i)=>{
+              m.label = m.deviceName
+            })
+          })
+          this.list = data
+        })
     },
-    getCurrentDevice(item,index){
-      this.current = index;
+    handleNodeClick(val, node, el) { //鏍戠殑鍊�
+      this.selectTree = ''
+      this.getNodeParent(node)
+      this.selectTree = this.selectTree.replace(' - ', '')
+      let data = this.selectTree.split(' - ')
+      let data2 = ''
+      for (let index = data.length - 1; index >= 0; index--) {
+        data2 += " - " + data[index]
+      }
+      this.selectTree = data2.replace(' - ', '')
+
       this.currentPage = 'operationOverview';
-    }
+    },
+    getNodeParent(val) {
+      if (val.parent != null) {
+        if(val.data.children === null){
+          this.selectTree += ' - ' + val.label + ' - ' + 'null'
+        }else{
+          this.selectTree += ' - ' + val.label
+        }
+        this.getNodeParent(val.parent)
+      }
+    },
+    nodeOpen(data, node, el) {
+      $($(el.$el).find('.node_i')[0]).attr('class', 'node_i el-icon-folder-opened')
+    },
+    nodeClose(data, node, el) {
+      $($(el.$el).find('.node_i')[0]).attr('class', 'node_i el-icon-folder')
+    },
   }
 }
 </script>
@@ -94,6 +166,7 @@
   padding-top: 10px;
   padding-bottom: 10px;
   box-sizing: border-box;
+  width: 100%;
 }
 .device-left{
   width: 200px;
@@ -103,30 +176,6 @@
   border-radius: 16px;
   box-sizing: border-box;
   padding: 10px 16px;
-}
-.device-left ul{
-  list-style-type: none;
-  padding: 0;
-  margin: 0;
-  font-size: 14px;
-  color: #999999;
-  cursor: pointer;
-  margin-top: 10px;
-  height: calc(100% - 46px);
-  overflow-y: scroll;
-}
-.device-left ul li{
-  white-space: nowrap;         /* 绂佹鎹㈣ */
-  overflow: hidden;            /* 闅愯棌婧㈠嚭鐨勬枃鏈� */
-  text-overflow: ellipsis;     /* 鐢ㄧ渷鐣ュ彿琛ㄧず婧㈠嚭鐨勬枃鏈� */
-  padding: 3px 0;
-
-}
-.device-left ul li:hover{
-  color: #3A7BFA;
-}
-.device-left ul li.active{
-  color: #3A7BFA;
 }
 .device-right{
   background: #fff;
@@ -138,5 +187,16 @@
 .device-right-content{
   margin-top: 10px;
   height: calc(100% - 42px);
+  width: 100%;
+}
+.custom-tree-node {
+  width: 100%;
+  /* line-height: 32px; */
+  font-size: 14px;
+}
+
+.node_i {
+  color: orange;
+  font-size: 18px;
 }
 </style>

--
Gitblit v1.9.3