xiaohaizhao 1 rok temu
rodzic
commit
9a8a157384

+ 87 - 0
control/components/prodnum-MT02/modules/basics.vue

@@ -0,0 +1,87 @@
+<template>
+    <view class="control">
+        <view class="update-line">
+            <view class="label">
+                {{ ctrlModel.funcname }}
+            </view>
+            <view class="content">
+                {{ ctrlModel.showValue }}
+                <view class="control-updata-but" hover-class="navigator-hover" @click="onClick(ctrlModel)">{{
+                    ctrlModel.isfeedback ? '待更新' : '更新' }}</view>
+            </view>
+        </view>
+
+        <view v-if="subcontrol" class="update-line">
+            <view class="label">
+                {{ subcontrol.funcname }}
+            </view>
+            <view class="content">
+                {{ subcontrol.showValue || subcontrol.params.lastvalue }}
+                <view class="control-updata-but" hover-class="navigator-hover" @click="onClick(subcontrol)">{{
+                    subcontrol.isfeedback ? '待更新' : '更新' }}</view>
+            </view>
+        </view>
+
+        <view class="list-box">
+            <view class="item" v-for="item in list" :key="item.param">
+                <view class="label">
+                    {{ item.paramname }}
+                </view>
+                <view class="value">
+                    {{ item.lastvalue }}
+                    <text class="">
+                        {{ item.unit }}
+                    </text>
+                </view>
+            </view>
+        </view>
+        <My_input ref="MyInput" />
+    </view>
+</template>
+<script>
+let model = null;
+export default {
+    name: "basics",
+    data() {
+        return {
+            ctrlModel: {},
+            list: [],
+            subcontrol: null
+        }
+    },
+    methods: {
+        onClick(item) {
+            if (!model) model = this.$refs.MyInput;
+            model.openInput(item)
+        }
+    }
+}
+</script>
+
+<style lang="scss" scoped>
+.list-box {
+    width: 100%;
+    display: flex;
+    flex-wrap: wrap;
+    background: #fff;
+    border-radius: 4px;
+    padding: 6px;
+    box-sizing: border-box;
+    padding-bottom: 0;
+
+    .item {
+        width: 50%;
+
+        .label {
+            margin-bottom: 6px;
+        }
+
+        .value {
+            margin-bottom: 6px;
+            font-weight: bold;
+            padding-left: 2px;
+        }
+    }
+
+}
+</style>

+ 254 - 0
control/components/prodnum-MT02/modules/division.vue

@@ -0,0 +1,254 @@
+<template>
+    <view class="control">
+        <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)">{{
+                    timeControl.isfeedback ? '待更新' : '更新' }}</view>
+            </view>
+        </view>
+        <view class="item" hover-class="navigator-hover" v-for="item in list" :key="item.index" @click="onClick(item)">
+            <view class="title">
+                {{ item.funcname }}
+            </view>
+            <view class="row">
+                <view class="box">
+                    <view class="">
+                        开始时间
+                    </view>
+                    <view class="content">
+                        <view class="value">{{ item.showValue.begin || '--' }}</view>
+                    </view>
+                </view>
+                <view class="box">
+                    <view class="">
+                        结束时间
+                    </view>
+                    <view class="content">
+                        <view class="value">{{ item.showValue.end || '--' }}</view>
+                    </view>
+                </view>
+                <view class="box">
+                    <view class="">
+                        压力设置
+                    </view>
+                    <view class="content">
+                        <view class="value">{{ item.showValue.value || '--' }}</view>
+                        <view class="unit">{{ item.params[item.keyList[4]].unit || '' }}</view>
+                    </view>
+                </view>
+            </view>
+            <view v-if="item.isfeedback" class="dot" />
+        </view>
+        <My_input ref="MyInput" @customMethod="customMethod">
+            <view class="change-item" v-if="changeItem.funcname">
+                <picker mode="time" :value="changeItem.showValue.begin" :end="changeItem.showValue.end" data-name="begin"
+                    @change="timeChange">
+                    <view class="row">
+                        <view class="label">
+                            开始时间:
+                        </view>
+                        <view class="value">{{ changeItem.showValue.begin || ' --' }}
+                        </view>
+                    </view>
+                </picker>
+                <picker class="row" mode="time" :start="changeItem.showValue.begin" :value="changeItem.showValue.end"
+                    data-name="end" @change="timeChange">
+                    <view class="row">
+                        <view class="label">
+                            结束时间:
+                        </view>
+                        <view class="value">{{ changeItem.showValue.end || ' --' }}</view>
+                    </view>
+                </picker>
+                <view class="row">
+                    <view class="label">
+                        压力设置:
+                    </view>
+                    <view class="value">
+                        <u-input :placeholder="changeItem.showValue.value || '压力设置'" v-model="changeItem.showValue.value"
+                            :type="changeItem.params[`T${changeItem.index}_P`].num_scale == 0 ? 'number' : 'digit'">
+                            <template slot="suffix">
+                                {{ changeItem.params[`T${changeItem.index}_P`].unit || '' }}
+                            </template>
+                        </u-input>
+                    </view>
+                </view>
+            </view>
+        </My_input>
+    </view>
+</template>
+
+<script>
+let model = null;
+export default {
+    name: "division",
+    data() {
+        return {
+            list: [],
+            changeItem: {},
+            timeControl: {}
+        }
+    },
+    methods: {
+        loadData(newVal) {
+            let reg = /^T\d{1,5}$/,
+                count = 0,
+                list = [];
+            for (const key in newVal.function) {
+                if (reg.test(key)) count++
+            }
+            for (let i = 1; i <= count; i++) {
+                let obj = newVal.function[`T${i}`],
+                    keyList = [
+                        `T${i}H`,//开始小时
+                        `T${i}M`,//开始分钟
+                        `T${i}H1`,//结束小时
+                        `T${i}M1`,//结束分钟
+                        `T${i}_P`,//压力设置
+                    ],
+                    item = {
+                        keyList,
+                        index: i,
+                        inputType: "slot",
+                        paramValue: {
+                            begin: newVal.paramcmdvalues[`T${i}H`] + newVal.paramcmdvalues[`T${i}M`] ? newVal.paramcmdvalues[`T${i}H`] + ":" + newVal.paramcmdvalues[`T${i}M`] : "",
+                            end: newVal.paramcmdvalues[`T${i}H1`] + newVal.paramcmdvalues[`T${i}M1`] ? newVal.paramcmdvalues[`T${i}H1`] + ":" + newVal.paramcmdvalues[`T${i}M1`] : "",
+                            value: newVal.paramcmdvalues[`T${i}_P`]
+                        },
+                        showValue: {
+                            begin: newVal.paramvalues[`T${i}H`] + newVal.paramvalues[`T${i}M`] ? newVal.paramvalues[`T${i}H`] + ":" + newVal.paramvalues[`T${i}M`] : "",
+                            end: newVal.paramvalues[`T${i}H1`] + newVal.paramvalues[`T${i}M1`] ? newVal.paramvalues[`T${i}H1`] + ":" + newVal.paramvalues[`T${i}M1`] : "",
+                            value: newVal.paramvalues[`T${i}_P`]
+                        },
+                        params: {}
+                    };
+
+                keyList.forEach(key => {
+                    item.params[key] = newVal.params[key];
+                });
+                item.isfeedback = (newVal.isfeedback && (obj.paramValue.begin || obj.paramValue.end || obj.paramValue.value)) ? true : false;
+                list.push(Object.assign(obj, item))
+            }
+            this.list = list;
+            this.timeControl = this.__proto__.getControlItem(["TimeCon"], newVal)[0]
+        },
+        onClick(item) {
+            if (!model) model = this.$refs.MyInput;
+            model.openInput(item, true)
+            if (this.changeItem.funcname != item.funcname) this.changeItem = JSON.parse(JSON.stringify(item));
+            let toBeUpdated = [];
+            if (item.paramValue.begin) toBeUpdated.push(`开始时间:${item.paramValue.begin}`);
+            if (item.paramValue.end) toBeUpdated.push(`结束时间:${item.paramValue.begin}`);
+            if (item.paramValue.value) toBeUpdated.push(`压力设置:${item.paramValue.value}`);
+            if (toBeUpdated.length) {
+                model.toBeUpdated = '待更新记录:' + toBeUpdated.join(",")
+            }
+        },
+        timeChange(e) {
+            const name = e.currentTarget.dataset.name;
+            this.changeItem.showValue[name] = e.detail.value;
+        },
+        customMethod() {
+            const {
+                showValue,
+                w_functionid,
+                params,
+                index
+            } = this.changeItem,
+                MyInput = this.$refs.MyInput;
+            if (!showValue.begin) return MyInput.submitBreak("还未填写开始时间")
+            if (!showValue.end) return MyInput.submitBreak("还未填写结束时间")
+            if ((showValue.value + '').length == 0) return MyInput.submitBreak("还未设定压力")
+            showValue.value = (showValue.value - 0).toFixed(params[`T${index}_P`].num_scale)
+            MyInput.submit(w_functionid, {
+                [`T${index}H`]: showValue.begin.split(":")[1],
+                [`T${index}M`]: showValue.begin.split(":")[0],
+                [`T${index}H1`]: showValue.end.split(":")[1],
+                [`T${index}M1`]: showValue.end.split(":")[0],
+                [`T${index}_P`]: showValue.value,
+            })
+        }
+    }
+}
+</script>
+
+<style lang="scss" scoped>
+.item {
+    position: relative;
+    padding: 4px 6px 6px;
+    box-sizing: border-box;
+    background: #fff;
+    border-radius: 4px;
+    margin-bottom: 5px;
+
+    .title {
+        margin-bottom: 6px;
+        font-weight: bold;
+    }
+
+    .row {
+        display: flex;
+
+        .box {
+            width: 33.33%;
+
+            .content {
+                display: flex;
+                margin-top: 6px;
+                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;
+                }
+            }
+        }
+
+
+    }
+
+    .dot {
+        position: absolute;
+        right: 2px;
+        top: 2px;
+        width: 10px;
+        height: 10px;
+        background: #D9001B;
+        border-radius: 50%;
+    }
+}
+
+.change-item {
+
+    .row {
+        display: flex;
+        align-items: center;
+        line-height: 35px;
+        width: 100%;
+
+        .label {
+            width: 80px;
+            flex-shrink: 0;
+        }
+    }
+
+}
+</style>

+ 59 - 0
control/components/prodnum-MT02/prodnum-MT02.vue

@@ -0,0 +1,59 @@
+<template>
+    <view>
+        <view class="control-title">控制面板</view>
+        <basics ref="basics" />
+        <division ref="division" />
+    </view>
+</template>
+
+<script>
+import basics from "./modules/basics"
+import division from "./modules/division"
+export default {
+    name: 'prodnum-MT02',
+    components: { basics, division },
+    props: {
+        control: Object
+    },
+    watch: {
+        control: function (newVal) {
+            if (newVal) {
+                try {
+                    this.$refs.basics.ctrlModel = this.__proto__.getControlItem(['Control'], newVal, { Control: "radioNum" })[0];
+                    this.$refs.basics.list = ["MostBad", "FaWei", "NowFlow", "CumFlow"].map(v => newVal.params[v])
+                    switch (this.$refs.basics.ctrlModel.paramValue) {
+                        case '远程不利点模式':
+                            this.$refs.basics.subcontrol = this.__proto__.getControlItem(['Tarb'], newVal)[0];
+                            break;
+                        case '远程开关阀模式':
+                            this.$refs.basics.subcontrol = this.__proto__.getControlItem(['RC'], newVal)[0];
+                            break;
+                        case '恒压控制':
+                            this.$refs.basics.subcontrol = this.__proto__.getControlItem(['DownTar'], newVal)[0];
+                            break;
+                        default:
+                            this.$refs.basics.subcontrol = null;
+                            break;
+                    }
+                } catch (error) {
+                    console.error("MT02控制模式", error)
+                }
+                try {
+                    let division = this.$refs.division;
+                    division && division.loadData(newVal)
+                } catch (error) {
+                    console.error("MT02分时控制", error)
+                }
+            } else {
+            }
+        }
+    },
+    data() {
+        return {
+
+        }
+    },
+}
+</script>
+
+<style></style>

+ 24 - 0
control/modules/My_input.vue

@@ -83,6 +83,18 @@
                         </view>
                     </view>
                 </block>
+                <!-- 特殊选择 -->
+                <block v-else-if="item.inputType == 'radioNum'">
+                    <view class="title u-line-1">
+                        {{ item.funcname }}{{ item.params.unit || '' }}
+                    </view>
+                    <view class="select-box">
+                        <view class="item" @click="onSelected(op, item.inputType)" :class="op.value == 1 ? 'active' : ''"
+                            v-for="op in item.params.options" :key="op.key" hover-class="navigator-hover">
+                            {{ op.label }}
+                        </view>
+                    </view>
+                </block>
                 <!-- slot -->
                 <block v-else-if="isSlot">
                     <view class="title u-line-1">
@@ -192,6 +204,8 @@ export default {
                     if (paramValue.length && paramValue != item.params.lastvalue) {
                         toBeUpdated = `查询到“${item.funcname}”有待更新记录,待更新值为“${params.options.find(v => v.value == item.paramValue).label}”`
                     }
+                } if (item.inputType == "radioNum") {
+                    if (item.paramValue) toBeUpdated = `查询到“${item.funcname}”有待更新记录,待更新值为“${item.paramValue}”`
                 } else if (item.inputType == "step") {
                     this.value = params.lastvalue;
                     if (this.value > params.num_maxvalue) this.value = params.num_maxvalue;
@@ -213,6 +227,11 @@ export default {
         onSelected(option, mode) {
             if (mode == "radio") {
                 this.item.params.lastvalue = option.value;
+            } else if (mode == 'radioNum') {
+                this.item.params.options = this.item.params.options.map(v => {
+                    v.value = v.key == option.key ? 1 : 0
+                    return v
+                })
             }
         },
         stepChange(e) {
@@ -268,6 +287,11 @@ export default {
                 })
             } else if (item.inputType == "radio") {
                 value = params.lastvalue;
+            } else if (item.inputType == "radioNum") {
+                value = {};
+                params.options.forEach(v => {
+                    value[`${v.key}`] = v.value
+                });
             }
             this.submit(item.w_functionid, {
                 [item.paramName]: value

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

@@ -2,6 +2,7 @@
     <view class="container" v-show="show">
         <prodnum-06 v-if="detail.prodnum == '06'" :control="control" />
         <prodnum-MT03 v-else-if="detail.prodnum == 'MT03'" :control="control" />
+        <prodnum-MT02 v-else-if="detail.prodnum == 'MT02'" :control="control" />
     </view>
 </template>
 

+ 20 - 6
utils/tool.js

@@ -66,21 +66,35 @@ function mount() {
         let list = nameList.map(v => detail.function[v])
         for (const key in list) {
             try {
-                const name = Object.entries(list[key].params)[0][0]
+                let original = list[key].params,
+                    name = Object.entries(original)[0][0];
                 list[key].paramName = name;
                 list[key].params = detail.params[name];
                 list[key].paramValue = detail.paramcmdvalues[name]
                 list[key].isfeedback = (detail.isfeedback == 1 && (detail.paramcmdvalues[name] != detail.paramvalues[name])) ? true : false;
-                if (list[key].params.datatype == "boolean") {
-                    list[key].inputType = 'switch';
-                    list[key].showValue = "";
-                    if (list[key].params.lastvalue + '') list[key].showValue = list[key].params.options.find(v => v.value == list[key].params.lastvalue).label || ""
-                } else if (specialType[nameList[key]] || false) {
+                if (specialType[nameList[key]] || false) {
                     list[key].inputType = specialType[nameList[key]];
                     if (["radio"].includes(specialType[nameList[key]])) {
                         list[key].showValue = "";
                         if (list[key].params.lastvalue + '') list[key].showValue = list[key].params.options.find(v => v.value == list[key].params.lastvalue).label || ""
+                    } else if (["radioNum"].includes(specialType[nameList[key]])) {
+                        //MTO2 控制模式使用
+                        list[key].params.options = [];
+                        for (const oKey in original) {
+                            let item = detail.params[oKey];
+                            if (original[oKey] == 1) list[key].showValue = item.paramname;
+                            list[key].paramValue = item.paramname;
+                            list[key].params.options.push({
+                                label: item.paramname,
+                                value: item.lastvalue,
+                                key: oKey
+                            })
+                        };
                     }
+                } else if (list[key].params.datatype == "boolean") {
+                    list[key].inputType = 'switch';
+                    list[key].showValue = "";
+                    if (list[key].params.lastvalue + '') 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';
                 }