瀏覽代碼

fw01设备控制页

xiaohaizhao 1 年之前
父節點
當前提交
fb12583323

+ 79 - 0
control/components/prodnum-FW01/prodnum-FW01.vue

@@ -0,0 +1,79 @@
+<template>
+  <view>
+    <view style="height: 20px" />
+    <pilotLamp ref="pilotLamp" itemW="21%" />
+    <view class="control-title">设备参数</view>
+    <preview ref="preview" />
+    <control-panel ref="mpattern" />
+  </view>
+</template>
+
+<script>
+import controlPanel from "../prodnum-YK01/modules/controlPanel.vue";
+import preview from "../prodnum-YK01/modules/preview.vue";
+import pilotLamp from "../prodnum-MT03/modules/pilotLamp.vue";
+export default {
+  name: "prodnum-FW01",
+  components: { controlPanel, pilotLamp, preview },
+  props: {
+    control: Object,
+  },
+  watch: {
+    control: function (newVal) {
+      if (newVal) {
+        try {
+          this.$refs.preview.list = [
+            newVal.params["U002"],
+            newVal.params["U003"],
+          ];
+        } catch (error) {
+          console.error("FW01设备状态", error);
+        }
+
+        try {
+          this.$refs.mpattern.itemList = this.__proto__.getControlItem(
+            ["上传时间间隔", "开度变更提醒值"],
+            newVal
+          );
+        } catch (error) {
+          console.error("FW01控制面板", error);
+        }
+        try {
+          this.$refs.pilotLamp.list = [
+            {
+              name: "开度变动提醒",
+              value: getBoole("A005"),
+            },
+            {
+              name: "低电量提醒",
+              value: getBoole("A002"),
+            },
+          ];
+          function getBoole(name, expect = 1) {
+            try {
+              return newVal.paramvalues[name] == expect;
+            } catch (error) {
+              console.log("getBoole取值出错项", name);
+              return false;
+            }
+          }
+        } catch (error) {
+          console.error("FW01指示灯", error);
+        }
+        try {
+          this.$Http.openNetwork(newVal.params.U004.lastvalue);
+        } catch (error) {
+          setTimeout(this.$Http.openNetwork(newVal.params.U004.lastvalue), 100);
+          console.error("06信号强度", error);
+        }
+      } else {
+      }
+    },
+  },
+};
+</script>
+<style lang="scss" scoped>
+/deep/.pilotLamp .item {
+  width: 21% !important;
+}
+</style>

+ 1 - 1
control/components/prodnum-MT03/modules/mpattern.vue

@@ -42,7 +42,7 @@ export default {
     props: {
         fColor: {
             type: String,
-            value: "#FFF"
+            default: "#FFF"
         }
     },
     data() {

+ 64 - 53
control/components/prodnum-MT03/modules/pilotLamp.vue

@@ -1,77 +1,88 @@
 <template>
-    <view class="pilotLamp">
-        <view class="item" v-for="item in list" :key="item.name">
-            <view class="image">
-                <image style="height: 100%;" src="/static/img/pilot-lamp.png" mode="heightFix" />
-                <view v-if="item.value" class="bg" />
-            </view>
-            <view class="name">
-                {{ item.name }}
-            </view>
-        </view>
+  <view class="pilotLamp">
+    <view
+      class="item"
+      :style="{ width: itemW }"
+      v-for="item in list"
+      :key="item.name"
+    >
+      <view class="image">
+        <image
+          style="height: 100%"
+          src="/static/img/pilot-lamp.png"
+          mode="heightFix"
+        />
+        <view v-if="item.value" class="bg" />
+      </view>
+      <view class="name">
+        {{ item.name }}
+      </view>
     </view>
+  </view>
 </template>
 
 <script>
 export default {
-    name: 'pilotLamp',
-    data() {
-        return {
-            list: []
-        }
+  name: "pilotLamp",
+  props: {
+    itemW: {
+      type: String,
+      default: "20%",
     },
-}
+  },
+  data() {
+    return {
+      list: [],
+    };
+  },
+};
 </script>
 
 <style lang="scss" scoped>
 .pilotLamp {
-    display: flex;
-    flex-wrap: wrap;
-
-    .item {
-        display: flex;
-        flex-direction: column;
-        align-items: center;
-        width: 20%;
+  display: flex;
+  flex-wrap: wrap;
 
-        .image {
-            position: relative;
-            height: 20px;
+  .item {
+    display: flex;
+    flex-direction: column;
+    align-items: center;
 
-            .bg {
-                width: 14px;
-                height: 14px;
-                border-radius: 50%;
-                background: #cccccc;
-                position: absolute;
-                top: 3px;
-                left: 3px;
-                animation: lampBackground .5s infinite alternate ease-in-out;
-            }
+    .image {
+      position: relative;
+      height: 20px;
 
-            @keyframes lampBackground {
-                from {
-                    background-color: #FF8F4A;
-                }
+      .bg {
+        width: 14px;
+        height: 14px;
+        border-radius: 50%;
+        background: #cccccc;
+        position: absolute;
+        top: 3px;
+        left: 3px;
+        animation: lampBackground 0.5s infinite alternate ease-in-out;
+      }
 
-                to {
-                    background-color: red;
-                }
-            }
+      @keyframes lampBackground {
+        from {
+          background-color: #ff8f4a;
         }
 
-        .name {
-            font-size: 12px;
-            color: #fff;
-            margin-top: 6px;
+        to {
+          background-color: red;
         }
-
-
+      }
     }
 
-    .item:nth-of-type(n+6) {
-        margin-top: 10px;
+    .name {
+      font-size: 12px;
+      color: #fff;
+      margin-top: 6px;
     }
+  }
 
+  .item:nth-of-type(n + 6) {
+    margin-top: 10px;
+  }
 }
 </style>

+ 8 - 9
control/modules/My_input.vue

@@ -49,8 +49,8 @@
             v-if="item.params.num_scale"
             :asyncChange="true"
             v-model="value"
-            :min="item.params.num_minvalue"
-            :max="item.params.num_maxvalue"
+            :min="item.params.num_minvalue || -2147483648"
+            :max="item.params.num_maxvalue || 2147483647"
             :step="item.params.num_step"
             :decimal-length="item.params.num_scale"
             @change="stepChange"
@@ -62,8 +62,8 @@
             v-else
             :asyncChange="true"
             v-model="value"
-            :min="item.params.num_minvalue"
-            :max="item.params.num_maxvalue"
+            :min="item.params.num_minvalue || -2147483648"
+            :max="item.params.num_maxvalue || 2147483647"
             :step="item.params.num_step"
             @change="stepChange"
             @focus="stepFocus"
@@ -343,8 +343,8 @@ export default {
           precision: num_scale,
         }).format()
       ).value;
-      if (this.value < num_minvalue) this.value = num_minvalue - 0;
-      if (this.value > num_maxvalue) this.value = num_maxvalue - 0;
+      if (num_minvalue && this.value < num_minvalue) this.value = num_minvalue - 0;
+      if (num_maxvalue && this.value > num_maxvalue) this.value = num_maxvalue - 0;
       this.stepIsCalculate = false;
       if (this.stagingMethod) this.confirm();
     },
@@ -367,7 +367,7 @@ export default {
         value = "";
       if (item.inputType == "int" || item.inputType == "step") {
         value = this.value - 0;
-        if (value == 0) return this.submitBreak("还未输入值");
+        // if (value == 0) return this.submitBreak("还未输入值");
         if (params.num_scale != 0) value = value.toFixed(params.num_scale);
         if (params.num_minvalue && value < params.num_minvalue)
           return this.submitBreak("输入值小于最低范围");
@@ -390,12 +390,11 @@ export default {
             value[key] = value[key] == 1 ? 0 : 1;
           }
         }
-        console.log(value);
         // value = params.options.find(v => v.value != (String(item.paramValue).length ? item.paramValue : item.params.lastvalue)).value
         return this.submit(item.w_functionid, value);
       } else if (item.inputType == "dayParting") {
         value = this.value - 0;
-        if (value == 0) return this.submitBreak("还未输入值");
+        // if (value == 0) return this.submitBreak("还未输入值");
         let p = item.params[item.key + "P"];
         if (p.num_scale != 0) value = value.toFixed(p.num_scale);
         if (p.num_minvalue && value > p.num_minvalue)

+ 1 - 0
control/pages.js

@@ -7,6 +7,7 @@ module.exports = {
             'MT03': "prodnum-MT03",
             'MT04': "prodnum-MT03",
             'YK01': "prodnum-YK01",
+            "FW01": 'prodnum-FW01',
         };
         return obj[prodnum] || ''
     }

+ 1 - 0
pages/facility/modules/control.vue

@@ -4,6 +4,7 @@
         <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" />
+        <prodnum-FW01 v-else-if="detail.miniapppath == 'prodnum-FW01'" :control="control" />
         <block v-else>
             <view style="height: 50px;" />
             <u-empty mode="data" />

+ 111 - 85
pages/facility/modules/previewImage.vue

@@ -1,104 +1,130 @@
 <template>
-    <view class="container">
-        <network v-if="network.show" :num="network.num" :tips="network.tips" />
-        <view v-if="ctrlItem" class="ctrl-but" :style="{ background: ctrlItem.background }" hover-class="navigator-hover"
-            @click.stop="changeItem(ctrlItem)">
-            {{ ctrlItem.showValue }}
-        </view>
-        <swiper v-if="list.length" class="swiper" :indicator-dots="list.length > 1" :circular="true" indicator-color="#999"
-            indicator-active-color="#fff">
-            <swiper-item v-for="(item, index) in list" @click="preview(index)" :key="item.url">
-                <image class="image" :src="item.url" mode="aspectFit" lazy-load="true" />
-            </swiper-item>
-        </swiper>
-        <My_input ref="MyInput" />
+  <view class="container">
+    <network v-if="network.show" :num="network.num" :tips="network.tips" />
+    <view
+      v-if="ctrlItem"
+      class="ctrl-but"
+      :style="{ background: ctrlItem.background }"
+      hover-class="navigator-hover"
+      @click.stop="changeItem(ctrlItem)"
+    >
+      {{ ctrlItem.showValue }}
     </view>
+    <swiper
+      v-if="list.length"
+      class="swiper"
+      :indicator-dots="list.length > 1"
+      :circular="true"
+      indicator-color="#999"
+      indicator-active-color="#fff"
+    >
+      <swiper-item
+        v-for="(item, index) in list"
+        @click="preview(index)"
+        :key="item.url"
+      >
+        <image
+          class="image"
+          :src="item.url"
+          mode="aspectFit"
+          lazy-load="true"
+        />
+      </swiper-item>
+    </swiper>
+    <My_input ref="MyInput" />
+  </view>
 </template>
 <script>
-import network from './network.vue'
+import network from "./network.vue";
 export default {
-    name: "prodnum-06",
-    components: { network },
-    props: {
-        attinfos: Array
+  name: "previewImage",
+  components: { network },
+  props: {
+    attinfos: Array,
+  },
+  data() {
+    return {
+      list: [],
+      network: {
+        show: false,
+        num: 0,
+        tips: "",
+      },
+      ctrlItem: null,
+    };
+  },
+  watch: {
+    attinfos: function (newVal) {
+      this.list = newVal.filter((v) => v.usetype == "previewImage");
     },
-    data() {
-        return {
-            list: [],
-            network: {
-                show: false,
-                num: 0,
-                tips: ""
-            },
-            ctrlItem: null
-        }
+  },
+  methods: {
+    preview(index) {
+      uni.previewImage({
+        current: index,
+        urls: this.list.map((v) => v.url),
+        indicator: "number",
+        loop: true,
+        longPressActions: {
+          itemList: ["发送给朋友", "保存图片", "收藏"],
+          success: function (data) {
+            console.log(
+              "选中了第" +
+                (data.tapIndex + 1) +
+                "个按钮,第" +
+                (data.index + 1) +
+                "张图片"
+            );
+          },
+          fail: function (err) {
+            console.log(err.errMsg);
+          },
+        },
+      });
     },
-    watch: {
-        attinfos: function (newVal) {
-            this.list = newVal.filter(v => v.usetype == "previewImage")
-        }
+    openNetwork(num = 0, tips = "信号强度:") {
+      this.network = {
+        show: true,
+        num,
+        tips,
+      };
     },
-    methods: {
-        preview(index) {
-            uni.previewImage({
-                current: index,
-                urls: this.list.map(v => v.url),
-                indicator: "number",
-                loop: true,
-                longPressActions: {
-                    itemList: ['发送给朋友', '保存图片', '收藏'],
-                    success: function (data) {
-                        console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
-                    },
-                    fail: function (err) {
-                        console.log(err.errMsg);
-                    }
-                }
-            });
-        },
-        openNetwork(num = 0, tips = '信号强度:') {
-            this.network = {
-                show: true,
-                num,
-                tips
-            }
-        },
-        setData(params) {
-            for (const key in params) {
-                this[key] = params[key]
-            }
-        },
-        changeItem(item) {
-            this.$refs.MyInput.openInput(item)
-        }
+    setData(params) {
+      for (const key in params) {
+        this[key] = params[key];
+      }
     },
-}
+    changeItem(item) {
+      this.$refs.MyInput.openInput(item);
+    },
+  },
+};
 </script>
 
 <style lang="scss" scoped>
 .container {
-    position: relative;
+  position: relative;
 
-    .swiper {
-        width: 355px;
-        height: 158px;
-        margin: 15px auto 0;
+  .swiper {
+    width: 355px;
+    height: 158px;
+    margin: 15px auto 0;
 
-        .image {
-            width: 355px;
-            height: 158px;
-        }
+    .image {
+      width: 355px;
+      height: 158px;
     }
+  }
 
-    .ctrl-but {
-        position: absolute;
-        top: 10px;
-        right: 14px;
-        font-size: 12px;
-        color: #fff;
-        padding: 4px 6px;
-        border-radius: 4px;
-        z-index: 1;
-    }
+  .ctrl-but {
+    position: absolute;
+    top: 10px;
+    right: 14px;
+    font-size: 12px;
+    color: #fff;
+    padding: 4px 6px;
+    border-radius: 4px;
+    z-index: 1;
+  }
 }
 </style>

+ 1 - 0
utils/tool.js

@@ -121,6 +121,7 @@ function mount() {
         })
     };
     Vue.prototype.getControlItem = (nameList, detail, specialType = {}) => {
+        console.log(nameList, detail)
         let list = nameList.map(v => detail.function[v]).filter((v, i) => {
             if (!v) console.log("未查找到项:", nameList[i])
             return v