浏览代码

分时控制保存进度

xiaohaizhao 1 年之前
父节点
当前提交
baf6450f6b

+ 0 - 30
control/components/prodnum-06/modules/basics.vue

@@ -9,49 +9,19 @@
         <view class="show-list">
             <control-item v-for="item in itemList" :key="item.paramName" :item="item" @click.native="onClick(item)" />
         </view>
-
         <My_input ref="MyInput" />
     </view>
 </template>
-
 <script>
-import My_input from "../../../modules/My_input";
-
 let model = null;
 export default {
     name: "basics",
-    components: { My_input },
     data() {
-        /* , {
-                name: "压力控制误差宽度",
-                key: 'Ctrl'
-            } */
         return {
             itemList: []
         }
     },
     methods: {
-        loadData(funs, values, paramsList) {
-            let list = ['Flow control', 'pressure control', 'Config', 'Sleep time', 'Pilot valve', 'Minimum', 'MOP'].map(v => funs[v])
-            for (const key in list) {
-                const name = Object.entries(list[key].params)[0][0]
-                list[key].paramName = name;
-                list[key].params = paramsList[name];
-                if (list[key].params.datatype == "boolean") {
-                    list[key].inputType = 'switch';
-                    list[key].showValue = list[key].params.options.find(v => v.value == list[key].params.lastvalue).label
-                    console.log(list[key].params.options)
-                } else {
-                    list[key].inputType = list[key].params.num_step ? 'step' : 'int';
-                }
-                list[key].paramValue = values[name]
-                list[key].isfeedback = list[key].isfeedback && (list[key].paramValue != list[key].params.lastvalue)
-                // if (name == "Config") 
-            }
-            this.itemList = list;
-            model = this.$refs.MyInput;
-
-        },
         onClick(item) {
             if (!model) model = this.$refs.MyInput;
             model.openInput(item)

+ 102 - 1
control/components/prodnum-06/modules/division.vue

@@ -3,13 +3,114 @@
         <view class="control-title">
             分时控制
         </view>
+        <view class="update-line">
+            <view class="label">
+                {{ timeControl.funcname }}
+            </view>
+            <view class="content">
+                {{ timeControl.showValue }}
+                <view class="control-updata-but" hover-class="navigator-hover" @click="onClick(timeControl)">更新</view>
+            </view>
+        </view>
+        <view class="row" hover-class="navigator-hover" v-for="item in list" :key="item.key" @click="onClick(item)">
+            <view class="box">
+                <view class="label">第{{ item.index }}时段时间</view>
+                <view class="content">
+                    <view class="value">{{ item.params["T" + item.index + "_T"] || '--' }}</view>
+                </view>
+            </view>
+            <view class="box">
+                <view class="label">第{{ item.index }}时段压力</view>
+                <view class="content">
+                    <view class="value">{{ item.params["T" + item.index + "_P"] || '--' }}</view>
+                    <view class="unit">MPA</view>
+                </view>
+            </view>
+        </view>
+        <My_input ref="MyInput" />
     </view>
 </template>
 
 <script>
+let model = null;
 export default {
     name: "division",
+    data() {
+        return {
+            list: [],
+            timeControl: {}
+        }
+    },
+    methods: {
+        loadData(funs, values, paramsList) {
+            model = this.$refs.MyInput;
+            let reg = /^T\d{1,5}_P$/,
+                count = 0,
+                list = [];
+            for (const key in values) {
+                if (reg.test(key)) count++
+            }
+            for (let i = 1; i <= count; i++) {
+                let obj = funs[`T${i}`];
+                obj.params[`T${i}_T`] = obj.params[`T${i}_T`].split("_").join(":");
+                list.push(Object.assign(obj, {
+                    key: `T${i}_`,
+                    index: i,
+                    inputType: "dayParting",
+                    toBeUpdated: {
+                        time: values[`T${i}_T`],
+                        value: values[`T${i}_P`]
+                    }
+                }))
+            }
+            this.list = list;
+            this.timeControl = this.__proto__.getControlItem(["TimeControl"], funs, values, paramsList)[0]
+        },
+        onClick(item) {
+            if (!model) model = this.$refs.MyInput;
+            model.openInput(item)
+        }
+    }
 }
 </script>
 
-<style lang="scss" scoped></style>
+<style lang="scss" scoped>
+.row {
+    display: flex;
+    padding: 4px 6px 0;
+    height: 60px;
+    box-sizing: border-box;
+    background: #fff;
+    border-radius: 4px;
+    margin-bottom: 5px;
+
+    .box {
+        width: 49%;
+
+        .content {
+            display: flex;
+            margin-top: 10px;
+            align-items: flex-end;
+
+            .value {
+                width: 0;
+                flex: 1;
+                color: #333;
+                font-size: 16px;
+                flex-shrink: 0;
+                font-weight: bold;
+            }
+
+            .unit {
+                font-size: 10px;
+                color: #666;
+                flex-shrink: 0;
+                max-width: 50px;
+            }
+        }
+
+
+
+    }
+}
+</style>

+ 1 - 0
control/components/prodnum-06/modules/mpattern.vue

@@ -3,6 +3,7 @@
         <view class="control-title">
             控制模式
         </view>
+
     </view>
 </template>
 

+ 15 - 4
control/components/prodnum-06/prodnum-06.vue

@@ -5,7 +5,7 @@
         <!-- 基础控制 -->
         <basics ref="basics" />
         <!-- 分时开关 -->
-        <division ref="model" />
+        <division ref="division" />
     </view>
 </template>
 
@@ -22,15 +22,26 @@ export default {
     watch: {
         control: function (newVal) {
             if (newVal) {
-                let basics = this.$refs.basics;
-                basics && basics.loadData(newVal.function, newVal.paramcmdvalues, newVal.params)
+                console.log(newVal)
+                try {
+                    let nameList = ['Flow control', 'pressure control', 'Config', 'Sleep time', 'Pilot valve', 'Minimum', 'MOP']
+                    this.$refs.basics.itemList = this.__proto__.getControlItem(nameList, newVal.function, newVal.paramcmdvalues, newVal.params)
+                } catch (error) {
+                    console.error(error)
+                }
+                try {
+                    let division = this.$refs.division;
+                    division && division.loadData(newVal.function, newVal.paramcmdvalues, newVal.params)
+                } catch (error) {
+                    console.error(error)
+                }
             } else {
 
             }
         }
     },
     modules() {
-        
+
     },
 }
 </script>

+ 86 - 9
control/modules/My_input.vue

@@ -6,7 +6,7 @@
                 <!-- 整数类型 -->
                 <block v-if="item.inputType == 'int'">
                     <view class="title u-line-1">
-                        {{ item.funcname }}{{ item.params.unit }}
+                        {{ item.funcname }}{{ item.params.unit || '' }}
                     </view>
                     <block v-if="item.inputType == 'int'">
                         <u--input :focus="intFocus" v-model="value" :type="item.num_scale == 0 ? 'number' : 'digit'"
@@ -28,7 +28,7 @@
                 <!-- 布尔开关 -->
                 <block v-else-if="item.inputType == 'switch'">
                     <view class="title u-line-1">
-                        {{ item.funcname }}{{ item.params.unit }}
+                        {{ item.funcname }}{{ item.params.unit || '' }}
                     </view>
                     {{ tips }}
                 </block>
@@ -36,6 +36,33 @@
                 <block v-else-if="item.inputType == 'step'">
                     步进器还没写
                 </block>
+                <!-- 时段 -->
+                <block v-else-if="item.inputType == 'dayParting'">
+                    <view class="title u-line-1">
+                        {{ item.funcname }}{{ item.params.unit || '' }}
+                    </view>
+                    <view class="day-parting">
+                        <picker mode="time" :value="item.params[item.key + 'T']" @change="changeT_T">
+                            <view class="row">
+                                <view class="label">
+                                    时间:
+                                </view>
+                                {{ item.params[item.key + 'T'] }}
+                            </view>
+                        </picker>
+                        <view class="row" style="margin-top: 20px">
+                            <view class="label">压力:</view>
+                            <u--input :focus="dayPartingFocus" v-model="value" type="digit"
+                                :placeholder="item.params[item.key + 'P']" border="surround" />
+                        </view>
+                        <view class="tips" v-if="tips">
+                            <u-icon name="info-circle-fill" color="#E2201A" />
+                            <text style="margin-left: 4px;">
+                                {{ tips }}
+                            </text>
+                        </view>
+                    </view>
+                </block>
                 <!-- 其他类型 -->
                 <block v-else>
                     其他类型
@@ -53,13 +80,15 @@ export default {
             item: {},
             tips: "",
             intFocus: false,
+            dayPartingFocus: false,
             value: "",
-            confirmText: '确定'
+            confirmText: '确定',
+            loading: false
         }
     },
     methods: {
         /**
-         * @param item.inputType int:数字 step:步进器 radio:单选 switch:开关
+         * @param item.inputType int:数字 step:步进器 radio:单选 switch:开关 dayParting:分时段
          */
         openInput(item) {
             this.item = item;
@@ -86,9 +115,22 @@ export default {
                     this.confirmText = '切换'
                     tips = `是否将“${item.funcname}”${this.confirmText}为:“${params.options.find(v => v.value != item.paramValue).label}”`
                 }
+            } else if (item.inputType == "dayParting") {
+                console.log("分时段", item)
+                this.value = item.params[item.key + 'p'];
+                this.dayPartingFocus = false;
+                this.item = JSON.parse(JSON.stringify(item))
+                tips = item.toBeUpdated.time || item.toBeUpdated.value ? `查询到一条待更新指令,更新内容为时间:${item.toBeUpdated.time.split("_").join(":")},压力:${item.toBeUpdated.value}MPA` : ""
+                setTimeout(() => {
+                    this.dayPartingFocus = true
+                }, 300);
             }
             this.tips = tips;
         },
+        /* 时段修改 */
+        changeT_T(e) {
+            this.item.params[this.item.key + 'T'] = e.detail.value;
+        },
         submitBreak(content) {
             uni.showToast({
                 title: content + "",
@@ -97,6 +139,7 @@ export default {
             this.$refs.uModal.loading = false;
         },
         confirm() {
+            if (this.loading) return;
             let item = this.item,
                 params = item.params,
                 value = "";
@@ -113,17 +156,29 @@ export default {
                 } else {
                     value = item.params.lastvalue == 1 ? 0 : 1
                 }
+            } else if (item.inputType == "dayParting") {
+                value = this.value - 0;
+                return this.submit(item.w_functionid, {
+                    [item.key + 'P']: value,
+                    [item.key + 'T']: params[item.key + 'T'].split(":").join("_")
+                })
             }
             this.submit(item.w_functionid, {
                 [item.paramName]: value
             })
         },
         async submit(w_functionid, params) {
-            await this.$Http.setControlItem(w_functionid, params)
-            this.show = false;
-            setTimeout(() => {
-                this.item = null;
-            }, 200);
+            this.loading = true;
+            let res = await this.$Http.setControlItem(w_functionid, params)
+            this.loading = false;
+            if (res) {
+                this.show = false;
+                setTimeout(() => {
+                    this.item = null;
+                }, 200);
+            } else {
+                this.$refs.uModal.loading = false;
+            }
         }
     },
 }
@@ -155,6 +210,28 @@ export default {
         }
     }
 
+    .day-parting {
+
+        .row {
+            display: flex;
+            align-items: center;
+
+            .label {
+                width: 50px;
+            }
+
+        }
+
+    }
+
+    /deep/.u-input {
+        .uni-input-input {
+            font-size: 12px;
+        }
+
+    }
+
+
 
 }
 </style>

+ 1 - 0
control/modules/controlItem.vue

@@ -57,6 +57,7 @@ export default {
             color: #333;
             font-size: 16px;
             flex-shrink: 0;
+            font-weight: bold;
         }
 
         .unit {

+ 2 - 0
main.js

@@ -13,6 +13,8 @@ import timeHorizon from './components/timeHorizon'
 Vue.component('time-horizon', timeHorizon)
 import controlItem from "./control/modules/controlItem.vue"
 Vue.component('control-item', controlItem)
+import My_input from "./control/modules/My_input.vue"
+Vue.component('My_input', My_input)
 
 //自定义组件
 import My_listbox from './components/My_listbox';

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

@@ -51,6 +51,7 @@ export default {
                 if (this.cutoff(res.msg, title)) return;
                 console.log("更新设备控制", res)
                 this.getControl(true);
+                return res.msg == '成功'
             })
         },
         setMonitoring() {

+ 33 - 0
uni.scss

@@ -68,6 +68,39 @@ body {
         line-height: 40px;
         text-indent: 6px;
     }
+
+    .update-line {
+        display: flex;
+        align-items: center;
+        font-size: 12px;
+        color: #fff;
+        margin-bottom: 10px;
+
+        .label {
+            width: 0;
+            flex: 1;
+            flex-shrink: 0;
+            margin-left: 6px;
+        }
+
+        .content {
+            display: flex;
+            flex-shrink: 0;
+
+            .control-updata-but {
+                background-color: #004A92;
+                font-size: 10px;
+                padding: 2px 6px !important;
+                margin-right: 6px;
+                border-radius: 4px;
+                box-sizing: border-box;
+                margin-left: 20px;
+            }
+        }
+    }
+
+
+
 }
 
 /* 颜色变量 */

+ 19 - 1
utils/tool.js

@@ -37,7 +37,7 @@ function mount() {
                 success: res => resolve(res)
             })
         })
-    }
+    };
     Vue.prototype.cutoff = (msg, title = "", mask = false, exitTime = 0, icon = 'none', duration = 2000, ) => {
         if (msg != '成功' || title) uni.showToast({
             title: msg == '成功' ? title : msg,
@@ -61,6 +61,23 @@ function mount() {
                 uni.createSelectorQuery().in(that).select(even).boundingClientRect().exec(res => (!res[0]) ? reject('没有查询到元素') : resolve(res[0]))
             }
         })
+    };
+    Vue.prototype.getControlItem = (nameList, funs, values, paramsList) => {
+        let list = nameList.map(v => funs[v])
+        for (const key in list) {
+            const name = Object.entries(list[key].params)[0][0]
+            list[key].paramName = name;
+            list[key].params = paramsList[name];
+            list[key].paramValue = values[name]
+            list[key].isfeedback = list[key].isfeedback && (list[key].paramValue != list[key].params.lastvalue)
+            if (list[key].params.datatype == "boolean") {
+                list[key].inputType = 'switch';
+                list[key].showValue = list[key].params.options.find(v => v.value == list[key].params.lastvalue).label
+            } else {
+                list[key].inputType = list[key].params.num_step ? 'step' : 'int';
+            }
+        }
+        return list
     }
 }
 
@@ -79,6 +96,7 @@ function getCity() {
         // #endif
     })
 }
+
 module.exports = {
     mount,
     setBar,