123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <template>
- <view class="container" v-show="show">
- <prodnum-06 v-if="detail.miniapppath == 'prodnum-06'" :control="control" />
- <prodnum-MT01
- v-else-if="detail.miniapppath == 'prodnum-MT01'"
- :control="control"
- />
- <prodnum-MT02
- v-else-if="detail.miniapppath == 'prodnum-MT02'"
- :control="control"
- />
- <prodnum-MT03
- v-else-if="detail.miniapppath == 'prodnum-MT03'"
- :control="control"
- />
- <prodnum-YK01
- v-else-if="detail.miniapppath == 'prodnum-YK01'"
- :control="control"
- />
- <block v-else-if="detail.miniapppath == 'prodnum-FW01'">
- <prodnum-FW01 v-if="mode == 0" :control="control" />
- <prodnum-FW01B v-else :control="control" />
- </block>
- <block v-else>
- <view style="height: 50px" />
- <u-empty mode="data" />
- </block>
- </view>
- </template>
- <script>
- let monitoring = null;
- export default {
- name: "control",
- props: {
- detail: Object,
- onUpdate: Function,
- mode: {
- type: Number,
- default: 0,
- },
- },
- data() {
- return {
- show: false,
- uninitialized: true,
- control: {},
- };
- },
- methods: {
- initialize(init = false) {
- if (init) this.getControl(true);
- },
- getControl(init) {
- if (init) this.control = null;
- this.$Http
- .basic({
- id: "20230628084901",
- content: {
- w_deviceid: this.detail.w_deviceid,
- mode: this.mode,
- },
- })
- .then((res) => {
- console.log("设备控制", res);
- if (this.cutoff(res.msg)) return;
- this.uninitialized = false;
- this.control = res.data;
- this.$Http.setControlItem = this.setControlItem.bind(this);
- this.setMonitoring();
- });
- },
- setControlItem(w_functionid, params, title = "已发送修改指令") {
- return this.$Http
- .basic({
- id: "20230627163701",
- content: {
- w_deviceid: this.detail.w_deviceid,
- w_functionid,
- params,
- },
- })
- .then((res) => {
- if (this.cutoff(res.msg, title)) return;
- console.log("更新设备控制", res);
- this.getControl(true);
- return res.msg == "成功";
- });
- },
- setMonitoring() {
- clearInterval(monitoring);
- monitoring = setInterval(() => {
- this.$Http
- .devicevaluecheck({
- w_deviceid: this.detail.w_deviceid,
- })
- .then((res) => {
- if (res == true) {
- this.$emit("onUpdate", true);
- this.$Http.updateFacilityList && this.$Http.updateFacilityList();
- }
- });
- }, 5000);
- },
- },
- beforeDestroy() {
- clearInterval(monitoring);
- },
- };
- </script>
- <style lang="scss" scoped>
- .container {
- width: 355px;
- margin: 0 auto;
- }
- </style>
|