xiaohaizhao 1 год назад
Родитель
Сommit
5851309f05

+ 57 - 0
control/components/prodnum-YK01/modules/controlPanel.vue

@@ -0,0 +1,57 @@
+<template>
+    <view class="control">
+        <view class="control-title">
+            控制面板
+        </view>
+        <view class="current">
+            <view class="item" v-for="item in preview" :key="item.paramname">
+                <view class="label">{{ item.paramname }}</view>
+                <view class="value">{{ item.lastvalue || '' }}{{ item.unit || '' }}</view>
+            </view>
+        </view>
+        <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>
+let model = null;
+export default {
+    name: "controlPanel",
+    data() {
+        return {
+            itemList: [],
+            preview: []
+        }
+    },
+    methods: {
+        onClick(item) {
+            if (!model) model = this.$refs.MyInput;
+            model.openInput(item)
+        }
+    }
+}
+</script>
+
+<style lang="scss" scoped>
+.current {
+    display: flex;
+    justify-content: space-around;
+    color: #fff;
+    margin-bottom: 10px;
+    font-size: 12px;
+
+    .label {
+        margin-bottom: 5px;
+    }
+}
+
+.show-list {
+    display: flex;
+    flex-wrap: wrap;
+    justify-content: space-between;
+    margin-top: -5px;
+    box-sizing: border-box;
+}
+</style>

+ 55 - 0
control/components/prodnum-YK01/modules/preview.vue

@@ -0,0 +1,55 @@
+<template>
+    <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>
+</template>
+<script>
+export default {
+    name: "preview",
+    data() {
+        return {
+            list: []
+        }
+    },
+    methods: {
+    }
+}
+</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>

+ 44 - 0
control/components/prodnum-YK01/modules/state.vue

@@ -0,0 +1,44 @@
+<template>
+    <view v-if="list.length">
+        <view class="control-title">设备状态</view>
+        <u-subsection :list="list" :current="current" @change="onChange" />
+        <My_input ref="MyInput" />
+    </view>
+</template>
+<script>
+export default {
+    name: "state",
+    data() {
+        return {
+            list: [],
+            current: -1,
+            options: []
+        }
+    },
+    methods: {
+        onChange(index) {
+            if (index == this.current) return;
+            let item = this.options[index],
+                that = this;
+            uni.showModal({
+                title: '提示',
+                content: `是否确定将设备更改为${item.funcname}状态`,
+                success: ({ confirm }) => {
+                    if (confirm) that.$refs.MyInput.submit(item.w_functionid, {
+                        [item.paramName]: 1
+                    })
+                },
+            })
+
+        },
+    }
+}
+</script>
+
+<style lang="scss" scoped>
+/deep/.u-subsection__item__text {
+    span {
+        font-size: 10px;
+    }
+}
+</style>

+ 116 - 0
control/components/prodnum-YK01/prodnum-YK01.vue

@@ -0,0 +1,116 @@
+<template>
+    <view>
+        <state ref="state" />
+        <view class="control-title">设备参数</view>
+        <preview ref="preview" />
+        <control-panel ref="mpattern" />
+        <view class="control-title">设备监控</view>
+        <pilotLamp ref="pilotLamp" />
+        <view v-if="showAlarms" class="control-title">异常告警</view>
+        <pilotLamp id="pilotLamp" ref="alarms" />
+    </view>
+</template>
+
+<script>
+import controlPanel from "./modules/controlPanel.vue";
+import preview from "./modules/preview.vue";
+import state from "./modules/state.vue";
+import pilotLamp from "../prodnum-MT03/modules/pilotLamp.vue";
+export default {
+    name: 'prodnum-YK01',
+    components: { controlPanel, pilotLamp, preview, state },
+    props: {
+        control: Object
+    },
+    data() {
+        return {
+            showAlarms: false
+        }
+    },
+    watch: {
+        control: function (newVal) {
+            if (newVal) {
+                console.log('YK01', newVal)
+                //设备状态
+                try {
+                    let list = this.__proto__.getControlItem(["open", "close", 'suspend'], newVal);
+                    this.$refs.state.list = list.map(v => v.funcname)
+                    this.$refs.state.options = list;
+                    this.$refs.state.current = list.findIndex(v => v.params.lastvalue);
+                } catch (error) {
+                    console.error("YK01设备状态", error);
+                }
+                try {
+                    this.$refs.preview.list = ["oilpressure", "pipeflow", "position", "closepressure", "closetime", "kv", "flowresistance"].map(v => newVal.params[v])
+                } catch (error) {
+                    console.error("YK01设备参数", error)
+                }
+                try {
+                    this.$refs.mpattern.itemList = this.__proto__.getControlItem(['open valve', 'Quick Close', 'Slow closing', 'hydraulic', 'pressure'], newVal);
+                } catch (error) {
+                    console.error("YK01控制面板", error)
+                }
+                try {
+                    this.$refs.pilotLamp.list = [{
+                        name: "就地",
+                        value: getBoole('local')
+                    }, {
+                        name: "远程",
+                        value: getBoole('remote')
+                    }, {
+                        name: "全开",
+                        value: getBoole('vfopen')
+                    }, {
+                        name: "全关",
+                        value: getBoole('vfclose')
+                    }, {
+                        name: "无线",
+                        value: getBoole('wire')
+                    }, {
+                        name: "伺服阀",
+                        value: getBoole('sopen')
+                    }, {
+                        name: "1号电磁阀",
+                        value: getBoole('solenoid1')
+                    }, {
+                        name: "2号电磁阀",
+                        value: getBoole('solenoid2')
+                    }, {
+                        name: "3号电磁阀",
+                        value: getBoole('solenoid3')
+                    }, {
+                        name: "4号电磁阀",
+                        value: getBoole('solenoid4')
+                    }]
+                    function getBoole(name, expect = 1) {
+                        try {
+                            return newVal.paramvalues[name] == expect
+                        } catch (error) {
+                            console.log("getBoole取值出错项", name)
+                            return false
+                        }
+                    }
+                } catch (error) {
+                    console.error("YK01指示灯", error)
+                }
+                try {
+                    this.$refs.alarms.list = ['oiloverload', 'blockage', 'sopenfault', 'sofffault', 'openfault', 'shutdownfault', 'losspressure', 'hightemp', 'lowlevel', 'accumulator', 'gearpump', 'hydraulic', 'motor', 'servo'].map(key => {
+                        let data = newVal.params[key];
+                        return {
+                            name: data.paramname,
+                            value: data.lastvalue,
+                        }
+                    }).filter(v => v.value);
+                    this.showAlarms = this.$refs.alarms.list.length != 0;
+                } catch (error) {
+                    console.error("YK01异常告警", error)
+                }
+            } else {
+            }
+        }
+    },
+
+}
+</script>
+
+<style></style>

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

@@ -3,6 +3,7 @@
         <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" />
     </view>
 </template>