Browse Source

通过配置匹配控制页

xiaohaizhao 1 year ago
parent
commit
2705398801
3 changed files with 32 additions and 12 deletions
  1. 12 0
      control/pages.js
  2. 12 7
      pages/facility/detail.vue
  3. 8 5
      pages/facility/modules/control.vue

+ 12 - 0
control/pages.js

@@ -0,0 +1,12 @@
+module.exports = {
+    getPageName: (prodnum) => {
+        let obj = {
+            "06": 'prodnum-06',
+            "MT02": "prodnum-MT02",
+            'MT03': "prodnum-MT03",
+            'MT04': "prodnum-MT03",
+            'YK01': "prodnum-YK01",
+        };
+        return obj[prodnum] || ''
+    }
+}

+ 12 - 7
pages/facility/detail.vue

@@ -87,7 +87,16 @@ export default {
             }).then(res => {
                 console.log("设备详情", res)
                 if (this.cutoff(res.msg)) return;
-                this.setTabs(res.data.prodnum)
+
+                if (!res.data.miniapppath) {
+                    res.data.miniapppath = require("../../control/pages").getPageName(res.data.prodnum);
+                    if (!res.data.miniapppath) {
+                        //未匹配到设备控制页
+                        this.showTab = '设备日志';
+                        this.tabs.shift()
+                    }
+                }
+
                 switch (res.data.status) {
                     case '在线':
                         res.data.bgColor = "#007aff";
@@ -99,19 +108,15 @@ export default {
                         res.data.bgColor = "#F9AE3D";
                         break;
                 }
+
                 this.detail = res.data;
+                
                 if (init) {
                     this.$refs.hd.getList(this.w_deviceid, res.data.prodnum).then(num => this.tabsTop = num)
                     setTimeout(() => { this.changeTab({ name: this.showTab }, true) }, 100)
                 }
             })
         },
-        setTabs(prodnum) {
-            if (['FW01', '01'].includes(prodnum)) {
-                this.showTab = '设备日志';
-                this.tabs.shift()
-            }
-        },
         changeTab({ name }, init = false) {
             this.showTab = name;
             page.show = false;

+ 8 - 5
pages/facility/modules/control.vue

@@ -1,16 +1,19 @@
 <template>
     <view class="container" v-show="show">
-        <prodnum-06 v-if="detail.prodnum == '06'" :control="control" />
-        <prodnum-MT03 v-else-if="detail.prodnum == 'MT03' || detail.prodnum == 'MT04'" :control="control" />
-        <prodnum-MT02 v-else-if="detail.prodnum == 'MT02'" :control="control" />
-        <prodnum-YK01 v-if="detail.prodnum == 'YK01'" :control="control" />
+        <prodnum-06 v-if="detail.miniapppath == 'prodnum-06'" :control="control" />
+        <prodnum-MT03 v-else-if="detail.miniapppath == 'prodnum-MT03'" :control="control" />
+        <prodnum-MT02 v-else-if="detail.miniapppath == 'prodnum-MT02'" :control="control" />
+        <prodnum-YK01 v-else-if="detail.miniapppath == 'prodnum-YK01'" :control="control" />
+        <block v-else>
+            <view style="height: 50px;" />
+            <u-empty mode="data" />
+        </block>
     </view>
 </template>
 
 <script>
 let monitoring = null;
 export default {
-    components: {},
     name: "control",
     props: {
         detail: Object