feat: 上位机远程控制完成

This commit is contained in:
pengqiao1993
2026-03-13 17:33:00 +08:00
parent 0fcb882e5d
commit 878101ceb3
11 changed files with 262 additions and 206 deletions

View File

@ -271,6 +271,7 @@ export default {
cancel: 'الغاء', cancel: 'الغاء',
messageDetail: 'تفاصيل الرسالة', messageDetail: 'تفاصيل الرسالة',
operateSuccess: 'نجح العملية', operateSuccess: 'نجح العملية',
operateFail: 'فشل العملية',
messageReaded: 'تمت قراءة هذه الرسالة، لا داعي لتكرار الإجراء' messageReaded: 'تمت قراءة هذه الرسالة، لا داعي لتكرار الإجراء'
}, },
device: { device: {
@ -469,56 +470,57 @@ export default {
second: 'ثانية' second: 'ثانية'
}, },
policy: { policy: {
planCurve: 'منحنى الجدول الزمني', planCurve: 'منحنى الجدول الزمني',
planCurveTem: 'قالب منحنى الجدول الزمني', planCurveTem: 'قالب منحنى الجدول الزمني',
IssueDevice: 'جهاز إصدار الأوامر', IssueDevice: 'جهاز إصدار الأوامر',
operateOrNot: 'سواء في التشغيل', operateOrNot: 'سواء في التشغيل',
socUplimit: 'الحد الأعلى لـ SOC', socUplimit: 'الحد الأعلى لـ SOC',
socDownlimit: 'الحد الأدنى لـ SOC', socDownlimit: 'الحد الأدنى لـ SOC',
effectiveTime: 'وقت السريان', effectiveTime: 'وقت السريان',
selectEffectiveTime: 'يرجى تحديد وقت السريان', selectEffectiveTime: 'يرجى تحديد وقت السريان',
distributeResult: 'نتيجة الإصدار', distributeResult: 'نتيجة الإصدار',
notDelivered: 'لم يتم الإصدار', notDelivered: 'لم يتم الإصدار',
commandDistribution: 'إصدار الأوامر', commandDistribution: 'إصدار الأوامر',
controlDistribution: 'إصدار التحكم', controlDistribution: 'إصدار التحكم',
genSetting: 'الإعدادات العامة', genSetting: 'الإعدادات العامة',
save: 'حفظ', save: 'حفظ',
pleaseInputValue: 'يرجى إدخال القيمة', pleaseInputValue: 'يرجى إدخال القيمة',
pleaseInputPassword: 'يرجى إدخال كلمة المرور', pleaseInputPassword: 'يرجى إدخال كلمة المرور',
password: 'كلمة المرور', password: 'كلمة المرور',
policyTypeList: [ policyTypeList: [
{ {
name: 'إصدار الأوامر' name: 'إصدار الأوامر'
}, },
{ {
name: 'الإعدادات العامة' name: 'الإعدادات العامة'
} }
], ],
radioList: [ radioList: [
{ {
name: 'تشغيل', name: 'تشغيل',
disabled: false disabled: false
}, },
{ {
name: 'عدم تشغيل', name: 'عدم تشغيل',
disabled: false disabled: false
} }
], ],
selectIssueDevice: 'يرجى تحديد جهاز إصدار الأوامر', selectIssueDevice: 'يرجى تحديد جهاز إصدار الأوامر',
deliverErrorNewTip: 'خطأ في تكوين التعيين أو لم يتم التكوين، يرجى التحقق وإعادة المحاولة!', deliverErrorNewTip: 'خطأ في تكوين التعيين أو لم يتم التكوين، يرجى التحقق وإعادة المحاولة!',
passwordSuccess: 'كلمة المرور صحيحة', passwordSuccess: 'كلمة المرور صحيحة',
passwordError: 'كلمة المرور غير صحيحة', passwordError: 'كلمة المرور غير صحيحة',
isOpen: 'سواء تمكين', isOpen: 'سواء تمكين',
isClose: 'سواء تعطيل', isClose: 'سواء تعطيل',
distributeSuccess: 'نجح الإصدار', distributeSuccess: 'نجح الإصدار',
distributeFail: 'فشل الإصدار', distributeFail: 'فشل الإصدار',
isNum: 'يرجى التحقق من أن قيمة الإدخال رقمية', isNum: 'يرجى التحقق من أن قيمة الإدخال رقمية',
saveSuccess: 'نجح الحفظ', saveSuccess: 'نجح الحفظ',
saveError: 'فشل الحفظ', saveError: 'فشل الحفظ',
delivered: 'اكتمل الإصدار', delivered: 'اكتمل الإصدار',
selectPlanCurveTem: 'يرجى تحديد قالب منحنى الجدول الزمني', selectPlanCurveTem: 'يرجى تحديد قالب منحنى الجدول الزمني',
deliverErrorTip: 'تجاوز طاقة الشحن والتفريغ الطاقة المقدرة، يرجى التحقق من إعدادات منحنى الجدول الزمني!', deliverErrorTip: 'تجاوز طاقة الشحن والتفريغ الطاقة المقدرة، يرجى التحقق من إعدادات منحنى الجدول الزمني!',
deliverTip: 'سواء تأكيد إصدار الأمر?' deliverTip: 'سواء تأكيد إصدار الأمر?',
policyTitle: 'إصدار الاستراتيجية'
} }
} }

View File

@ -272,6 +272,7 @@ export default {
cancel: 'Abbrechen', cancel: 'Abbrechen',
messageDetail: 'Nachrichtendetails', messageDetail: 'Nachrichtendetails',
operateSuccess: 'Aktion erfolgreich', operateSuccess: 'Aktion erfolgreich',
operateFail: 'Aktion fehlgeschlagen',
messageReaded: 'Diese Nachricht wurde bereits gelesen, keine Wiederholung der Aktion erforderlich' messageReaded: 'Diese Nachricht wurde bereits gelesen, keine Wiederholung der Aktion erforderlich'
}, },
device: { device: {
@ -506,55 +507,56 @@ export default {
confirmTime: 'Bestätigungszeit' confirmTime: 'Bestätigungszeit'
}, },
policy: { policy: {
planCurve: 'Plan-Kurve', planCurve: 'Plan-Kurve',
planCurveTem: 'Plan-Kurvenvorlage', planCurveTem: 'Plan-Kurvenvorlage',
IssueDevice: 'Befehlszielgerät', IssueDevice: 'Befehlszielgerät',
operateOrNot: 'In Betrieb', operateOrNot: 'In Betrieb',
socUplimit: 'SOC-Obergrenze', socUplimit: 'SOC-Obergrenze',
socDownlimit: 'SOC-Untergrenze', socDownlimit: 'SOC-Untergrenze',
effectiveTime: 'Gültigkeitszeit', effectiveTime: 'Gültigkeitszeit',
selectEffectiveTime: 'Bitte wählen Sie die Gültigkeitszeit', selectEffectiveTime: 'Bitte wählen Sie die Gültigkeitszeit',
distributeResult: 'Übertragungsergebnis', distributeResult: 'Übertragungsergebnis',
notDelivered: 'Nicht übertragen', notDelivered: 'Nicht übertragen',
commandDistribution: 'Befehlssendung', commandDistribution: 'Befehlssendung',
controlDistribution: 'Steuerungssendung', controlDistribution: 'Steuerungssendung',
genSetting: 'Allgemeine Einstellungen', genSetting: 'Allgemeine Einstellungen',
save: 'Speichern', save: 'Speichern',
pleaseInputValue: 'Bitte Wert eingeben', pleaseInputValue: 'Bitte Wert eingeben',
pleaseInputPassword: 'Bitte geben Sie Ihr Passwort ein', pleaseInputPassword: 'Bitte geben Sie Ihr Passwort ein',
password: 'Passwort', password: 'Passwort',
policyTypeList: [ policyTypeList: [
{ {
name: 'Befehlssendung' name: 'Befehlssendung'
}, },
{ {
name: 'Allgemeine Einstellungen' name: 'Allgemeine Einstellungen'
} }
], ],
radioList: [ radioList: [
{ {
name: 'In Betrieb', name: 'In Betrieb',
disabled: false disabled: false
}, },
{ {
name: 'Außer Betrieb', name: 'Außer Betrieb',
disabled: false disabled: false
} }
], ],
selectIssueDevice: 'Bitte wählen Sie das Befehlssendegerät', selectIssueDevice: 'Bitte wählen Sie das Befehlssendegerät',
deliverErrorNewTip: 'Zuordnungskonfiguration fehlerhaft oder nicht konfiguriert, bitte überprüfen und erneut versuchen!', deliverErrorNewTip: 'Zuordnungskonfiguration fehlerhaft oder nicht konfiguriert, bitte überprüfen und erneut versuchen!',
passwordSuccess: 'Passwort korrekt', passwordSuccess: 'Passwort korrekt',
passwordError: 'Passwort falsch', passwordError: 'Passwort falsch',
isOpen: 'Aktivieren', isOpen: 'Aktivieren',
isClose: 'Deaktivieren', isClose: 'Deaktivieren',
distributeSuccess: 'Sendung erfolgreich', distributeSuccess: 'Sendung erfolgreich',
distributeFail: 'Sendung fehlgeschlagen', distributeFail: 'Sendung fehlgeschlagen',
isNum: 'Bitte überprüfen Sie, ob der eingegebene Wert eine Zahl ist', isNum: 'Bitte überprüfen Sie, ob der eingegebene Wert eine Zahl ist',
saveSuccess: 'Speichern erfolgreich', saveSuccess: 'Speichern erfolgreich',
saveError: 'Speichern fehlgeschlagen', saveError: 'Speichern fehlgeschlagen',
delivered: 'Bereits gesendet', delivered: 'Bereits gesendet',
selectPlanCurveTem: 'Bitte wählen Sie eine Plan-Kurvenvorlage', selectPlanCurveTem: 'Bitte wählen Sie eine Plan-Kurvenvorlage',
deliverErrorTip: 'Lade-/Entladeleistung größer als Nennleistung, bitte überprüfen Sie die Plan-Kurven-Einstellungen!', deliverErrorTip: 'Lade-/Entladeleistung größer als Nennleistung, bitte überprüfen Sie die Plan-Kurven-Einstellungen!',
deliverTip: 'Befehlssendung wirklich bestätigen?' deliverTip: 'Befehlssendung wirklich bestätigen?',
policyTitle: 'Strategieübertragung'
} }
}; };

View File

@ -257,6 +257,7 @@ export default {
sureRead: 'Confirm as read', sureRead: 'Confirm as read',
cancel: 'Cancel', cancel: 'Cancel',
operateSuccess: 'Operation successful', operateSuccess: 'Operation successful',
operateFail: 'Operation failed',
messageReaded: 'This message has been read. No need to repeat the' messageReaded: 'This message has been read. No need to repeat the'
}, },
device: { device: {
@ -479,49 +480,50 @@ export default {
confirmTime: 'Confirmation time' confirmTime: 'Confirmation time'
}, },
policy: { policy: {
planCurve: 'Planned curve', planCurve: 'Planned curve',
planCurveTem: 'Planned curve template', planCurveTem: 'Planned curve template',
IssueDevice: 'Command issuance equipment', IssueDevice: 'Command issuance equipment',
operateOrNot: 'Commission or not', operateOrNot: 'Commission or not',
socUplimit: 'SOC upper limit', socUplimit: 'SOC upper limit',
socDownlimit: 'SOC lower limit', socDownlimit: 'SOC lower limit',
effectiveTime: 'Effective time', effectiveTime: 'Effective time',
selectEffectiveTime: 'Please select effective time', selectEffectiveTime: 'Please select effective time',
distributeResult: 'Issuance result', distributeResult: 'Issuance result',
notDelivered: 'Not issued', notDelivered: 'Not issued',
commandDistribution: 'Command issuance', commandDistribution: 'Command issuance',
controlDistribution: 'Control issuance', controlDistribution: 'Control issuance',
genSetting: 'General settings', genSetting: 'General settings',
save: 'Save', save: 'Save',
pleaseInputValue: 'Please enter value', pleaseInputValue: 'Please enter value',
pleaseInputPassword: 'Please enter password', pleaseInputPassword: 'Please enter password',
password: 'Password', password: 'Password',
policyTypeList: [{ policyTypeList: [{
name: 'Command Issuance' name: 'Command Issuance'
}, { }, {
name: 'General Settings' name: 'General Settings'
}], }],
radioList: [{ radioList: [{
name: "In Operation", name: "In Operation",
disabled: false disabled: false
}, { }, {
name: "Not In Operation", name: "Not In Operation",
disabled: false disabled: false
}], }],
selectIssueDevice: 'Please select command issuance equipment', selectIssueDevice: 'Please select command issuance equipment',
deliverErrorNewTip: 'Mapping configuration error or not configured. Please confirm and try again!', deliverErrorNewTip: 'Mapping configuration error or not configured. Please confirm and try again!',
passwordSuccess: 'Password correct', passwordSuccess: 'Password correct',
passwordError: 'Password incorrect', passwordError: 'Password incorrect',
isOpen: 'Enable or not', isOpen: 'Enable or not',
isClose: 'Disable or not', isClose: 'Disable or not',
distributeSuccess: 'Issuance successful', distributeSuccess: 'Issuance successful',
distributeFail: 'Issuance failed', distributeFail: 'Issuance failed',
isNum: 'Please check if the input value is a number', isNum: 'Please check if the input value is a number',
saveSuccess: 'Save successful', saveSuccess: 'Save successful',
saveError: 'Save failed', saveError: 'Save failed',
delivered: 'Issued', delivered: 'Issued',
selectPlanCurveTem: 'Please select planned curve template', selectPlanCurveTem: 'Please select planned curve template',
deliverErrorTip: 'Charging/discharging power exceeds rated power. Please confirm the planned curve.', deliverErrorTip: 'Charging/discharging power exceeds rated power. Please confirm the planned curve.',
deliverTip: 'Confirm command issuance?' deliverTip: 'Confirm command issuance?',
policyTitle: 'Strategy Issuance'
} }
} }

View File

@ -257,6 +257,7 @@ export default {
sureRead: 'Confirmar como leído', sureRead: 'Confirmar como leído',
cancel: 'Cancelar', cancel: 'Cancelar',
operateSuccess: 'Operación realizada con éxito', operateSuccess: 'Operación realizada con éxito',
operateFail: 'Operación fallida',
messageReaded: 'Este mensaje ya fue leído; no es necesario repetir la operación' messageReaded: 'Este mensaje ya fue leído; no es necesario repetir la operación'
}, },
device: { device: {
@ -479,6 +480,7 @@ export default {
confirmTime: 'Hora de confirmación' confirmTime: 'Hora de confirmación'
}, },
policy: { policy: {
policyTitle: 'Estrategia de envío',
planCurve: 'Curva planificada', planCurve: 'Curva planificada',
planCurveTem: 'Plantilla de curva planificada', planCurveTem: 'Plantilla de curva planificada',
IssueDevice: 'Equipo para emitir el comando', IssueDevice: 'Equipo para emitir el comando',

View File

@ -257,6 +257,7 @@ export default {
sureRead: 'Confirmer la lecture', sureRead: 'Confirmer la lecture',
cancel: 'Annuler', cancel: 'Annuler',
operateSuccess: 'Opération réussie', operateSuccess: 'Opération réussie',
operateFail: 'Opération échouée',
messageReaded: "La lecture du message a été effectuée. Aucune répétition n'est nécessaire !" messageReaded: "La lecture du message a été effectuée. Aucune répétition n'est nécessaire !"
}, },
device: { device: {
@ -479,6 +480,7 @@ export default {
confirmTime: 'Heure de confirmation' confirmTime: 'Heure de confirmation'
}, },
policy: { policy: {
policyTitle: 'Stratégie de distribution',
planCurve: 'Courbe programmée', planCurve: 'Courbe programmée',
planCurveTem: 'Modèle de courbe programmée', planCurveTem: 'Modèle de courbe programmée',
IssueDevice: "Équipement cable d'envoi d'ordre", IssueDevice: "Équipement cable d'envoi d'ordre",

View File

@ -271,6 +271,7 @@ export default {
cancel: 'Anuluj', cancel: 'Anuluj',
messageDetail: 'Szczegóły wiadomości', messageDetail: 'Szczegóły wiadomości',
operateSuccess: 'Operacja zakończona sukcesem', operateSuccess: 'Operacja zakończona sukcesem',
operateFail: 'Operacja nie powiodła się',
messageReaded: 'Wiadomość została odczytana, nie ma potrzeby powtarzania akcji.' messageReaded: 'Wiadomość została odczytana, nie ma potrzeby powtarzania akcji.'
}, },
device: { device: {
@ -505,6 +506,7 @@ export default {
confirmTime: 'Czas potwierdzenia' confirmTime: 'Czas potwierdzenia'
}, },
policy: { policy: {
policyTitle: 'Strategia dystrybucji',
planCurve: 'Krzywa planowania', planCurve: 'Krzywa planowania',
planCurveTem: 'Szablon krzywej planowania', planCurveTem: 'Szablon krzywej planowania',
IssueDevice: 'Polecenie wydane urządzeniu', IssueDevice: 'Polecenie wydane urządzeniu',

View File

@ -264,8 +264,9 @@ export default {
sureRead: '确认已读', sureRead: '确认已读',
cancel: '取消', cancel: '取消',
messageDetail: '消息详情', messageDetail: '消息详情',
operateSuccess: '操作成功', operateSuccess: '操作成功',
messageReaded: '该消息已读,无需重复操作' operateFail: '操作失败',
messageReaded: '该消息已读,无需重复操作'
}, },
device: { device: {
inputNameQuery: '输入名称搜索', inputNameQuery: '输入名称搜索',
@ -549,5 +550,6 @@ export default {
selectPlanCurveTem: '请选择计划曲线模板', selectPlanCurveTem: '请选择计划曲线模板',
deliverErrorTip: '充放电功率大于额定功率,请确认计划曲线设置!', deliverErrorTip: '充放电功率大于额定功率,请确认计划曲线设置!',
deliverTip: '是否确定下发命令?', deliverTip: '是否确定下发命令?',
policyTitle: '策略下发',
} }
}; };

View File

@ -6,7 +6,7 @@ Vue.config.productionTip = false
App.mpType = 'app' App.mpType = 'app'
// 引入全局 uView 框架 // 引入全局 uView 框架
import uView from 'uview-ui' import uView from './uview-ui'
Vue.use(uView) Vue.use(uView)
@ -18,7 +18,7 @@ let vuexStore = require('@/store/$u.mixin.js')
Vue.mixin(vuexStore) Vue.mixin(vuexStore)
// 引入 uView 对小程序分享的 mixin 封装 // 引入 uView 对小程序分享的 mixin 封装
let mpShare = require('uview-ui/libs/mixin/mpShare.js') let mpShare = require('./uview-ui/libs/mixin/mpShare.js')
Vue.mixin(mpShare) Vue.mixin(mpShare)
// Vue i18n 国际化 // Vue i18n 国际化

View File

@ -97,6 +97,7 @@
"navigationStyle": "custom" "navigationStyle": "custom"
} }
} }
] ]
}, },

View File

@ -1,36 +1,40 @@
<template> <template>
<view style="height: 100vh"> <view style="height: 100vh">
<view class=""> <view class="">
<u-navbar title="策略下发" :is-back="true" :background="background" :border-bottom="false" <u-navbar :title="$t('homePage.policy.policyTitle')" :is-back="true" title-color="#FFF"
:custom-back="toback"> :background="background" :border-bottom="false" :custom-back="toback">
</u-navbar> </u-navbar>
</view> </view>
<view class="policeForm"> <view class="policeForm">
<view class="" v-for="(item, index) in smallArr" :key="index"> <u-form ref="form" labelPosition="top">
<view class="" v-if="item.type == 'Input'"> <view class="" v-for="(item, index) in smallArr" :key="index">
<u-form-item :label="item[`label_${lang}`]" :prop="item.prop"> <view class="" v-if="item.type == 'Input'">
<u-input :min="item.min" :max="item.max" v-model.number="item.value" type="number" <u-form-item :label="item[`label_${lang}`]" :prop="item.prop">
:placeholder="item[`place_${lang}`]" @input="handleInput(item, $event)" /> <u-input :key="'input_' + item.prop + '_' + item.inputKey" :min="item.min" :max="item.max"
</u-form-item> :value="item.value" type="number" :placeholder="item[`place_${lang}`]"
@input="handleInput(item, $event)" />
</u-form-item>
</view>
<view class="" v-if="item.type == 'Switch'">
<u-form-item :label="item[`label_${lang}`]" :prop="item.prop">
<u-switch :size="40" v-model="item.value"></u-switch>
</u-form-item>
</view>
<view class="" v-if="item.type == 'Select'" @click="selectShow(item, index)">
<u-form-item :label="item[`label_${lang}`]" :prop="item.prop">
<view class="" v-show="false">
<u-input v-model="item.value" disabled @click="selectShow(item, index)" />
</view>
<view class="">
{{ item.selectLabel || $t("homePage.alarm.placeSelect") }}
</view>
<u-select :key="item.prop" @confirm="confirm($event, item)" v-model="item.isShow"
:list="getSelectList(item)"></u-select>
</u-form-item>
</view>
</view> </view>
<view class="" v-if="item.type == 'Switch'"> </u-form>
<u-form-item :label="item[`label_${lang}`]" :prop="item.prop">
<u-switch :size="40" v-model="item.value"></u-switch>
</u-form-item>
</view>
<view class="" v-if="item.type == 'Select'" @click="selectShow(item, index)">
<u-form-item :label="item[`label_${lang}`]" :prop="item.prop">
<view class="" v-show="false">
<u-input v-model="item.value" disabled @click="selectShow(item, index)" />
</view>
<view class="">
{{ item.selectLabel || $t("homePage.alarm.placeSelect") }}
</view>
<u-select :key="item.prop" @confirm="confirm($event, item)" v-model="item.isShow"
:list="getSelectList(item)"></u-select>
</u-form-item>
</view>
</view>
<button @click="submitDevice" type="success" size="mini" style=" <button @click="submitDevice" type="success" size="mini" style="
background-color: #009458; background-color: #009458;
@ -42,6 +46,7 @@
{{ $t("homePage.mine.submit") }} {{ $t("homePage.mine.submit") }}
</button> </button>
</view> </view>
<u-toast ref="uToast" />
</view> </view>
</template> </template>
@ -53,6 +58,7 @@
Langlist Langlist
} from "@/common/lang"; } from "@/common/lang";
import mqtt from "@/uni_modules/leliven-mqtt/index.js"; import mqtt from "@/uni_modules/leliven-mqtt/index.js";
import pako from "pako";
export default { export default {
data() { data() {
@ -61,7 +67,7 @@
background: { background: {
backgroundColor: "#0EA17E", backgroundColor: "#0EA17E",
}, },
lang: 'en',
mqttClient: null, mqttClient: null,
backData: {}, backData: {},
smallArr: [], smallArr: [],
@ -73,12 +79,11 @@
}; };
}, },
computed: { computed: {
language() { lang() {
return this.$store.state.vuex_language return Langlist.find(v => v.value == this.$store.state.vuex_language).prop || 'en'
}, },
currentStation() { currentStation() {
console.log(this.vuex_currentStation) return this.$store.state.vuex_currentStation;
return this.vuex_currentStation;
}, },
}, },
@ -88,30 +93,31 @@
methods: { methods: {
initmqttClient() { initmqttClient() {
// 初始化客户端连接地址 // 初始化客户端连接地址
// #ifdef H5 // #ifdef H5
let mqttClient = mqtt.connect('ws://13.39.200.14:8083/mqtt', { let mqttClient = mqtt.connect('ws://1.95.170.86:8083/mqtt', {
...this.user ...this.user
}) })
// #endif // #endif
// #ifdef MP-WEIXIN||APP-PLUS // #ifdef MP-WEIXIN||APP-PLUS
let mqttClient = mqtt.connect('wx://13.39.200.14:8083/mqtt', { let mqttClient = mqtt.connect('wx://1.95.170.86:8083/mqtt', {
...this.user ...this.user
}) })
// #endif // #endif
console.log(mqttClient,'888')
this.mqttClient = mqttClient this.mqttClient = mqttClient
// 连接MQ服务 // 连接MQ服务
mqttClient.on('connect', function(res) { mqttClient.on('connect', function(res) {
console.log('连接成功') console.log('连接成功')
console.log(res)
// 订阅主题 // 订阅主题
mqttClient.subscribe('presence', function(err) { mqttClient.subscribe(`1/ems/zzkj0002/control/response`, function(err) {
if (!err) { if (!err) {
// 订阅成功 // 订阅成功
mqttClient.publish('presence', 'hello mqtt') mqttClient.publish('1/app/zzkj0002/control/request', JSON.stringify({
fun: 'GET',
type: 'WJ_Get_NewControlSystem',
content: 0
}))
} }
}) })
}).on('reconnect', function() { }).on('reconnect', function() {
@ -120,15 +126,28 @@
console.log('连接失败') console.log('连接失败')
}).on('end', function() { }).on('end', function() {
console.log('连接End') console.log('连接End')
}).on('message', function(topic, message) { }).on('message', (topic, message) => {
// 收到MQ消息 console.log(this.decodeGzipBase64(message.toString()))
console.log(message.toString()) let data = this.decodeGzipBase64(message.toString())
if (data.content && data.content.params) {
this.control(data.content)
} else
if (data.content == 1) {
this.$refs.uToast.show({
title: this.$t('homePage.mine.operateSuccess'),
type: 'success',
})
} else {
uni.showToast({
title: this.$t('homePage.mine.operateFail'),
icon: 'none'
})
}
}) })
}, },
decodeGzipBase64(base64Str) { decodeGzipBase64(base64Str) {
// 1. base64 → Uint8Array // 1. base64 → Uint8Array
const binaryStr = atob(base64Str); const binaryStr = atob(base64Str);
@ -156,12 +175,16 @@
return [] return []
}, },
control(NewControlSystemShow_data) { control(NewControlSystemShow_data) {
console.log(NewControlSystemShow_data)
this.formList.forEach(item => { this.formList.forEach(item => {
if (item.type == "Switch") { if (item.type == "Switch") {
item.value = NewControlSystemShow_data?.params[item.prop] ? true : false item.value = NewControlSystemShow_data?.params[item.prop] ? true : false
} else { }
if (item.type == "Input") {
item.value = NewControlSystemShow_data?.params[item.prop] || item.default item.value = NewControlSystemShow_data?.params[item.prop] || item.default
} }
if (item.type == 'Select') { if (item.type == 'Select') {
item.selectLabel = item.selectArr.find(v => v.value == item.value)?.[`label_${this.lang}`] item.selectLabel = item.selectArr.find(v => v.value == item.value)?.[`label_${this.lang}`]
} }
@ -177,10 +200,10 @@
} }
item.isShow = false item.isShow = false
}, },
handleInput(item, event) { handleInput(item, value) {
try { try {
let inputValue = event.detail.value; // u-input 组件 @input 事件直接传递 value 值,不是 event 对象
let iptval = String(inputValue).replace(/[^0-9.]/g, ''); let iptval = String(value || '').replace(/[^0-9.]/g, '');
const parts = iptval.split('.'); const parts = iptval.split('.');
if (parts.length > 2) { if (parts.length > 2) {
iptval = parts[0] + '.' + parts.slice(1).join(''); iptval = parts[0] + '.' + parts.slice(1).join('');
@ -190,14 +213,25 @@
return; return;
} }
let numVal = Number(iptval); let numVal = Number(iptval);
if (item.min !== undefined && item.min !== null) {
numVal = Math.max(numVal, item.min);
}
if (item.max !== undefined && item.max !== null) {
numVal = Math.min(numVal, item.max);
}
numVal = isNaN(numVal) ? 0 : numVal; numVal = isNaN(numVal) ? 0 : numVal;
// 检查是否需要强制更新(值被限制)
let needForceUpdate = false;
if (item.min !== undefined && item.min !== null && numVal < item.min) {
numVal = item.min;
needForceUpdate = true;
}
if (item.max !== undefined && item.max !== null && numVal > item.max) {
numVal = item.max;
needForceUpdate = true;
}
item.value = numVal; item.value = numVal;
// 如果值被限制,强制重新渲染输入框
if (needForceUpdate) {
this.$set(item, 'inputKey', (item.inputKey || 0) + 1);
}
} catch (error) { } catch (error) {
console.log('handleInput方法错误:', error); console.log('handleInput方法错误:', error);
} }
@ -215,8 +249,8 @@
pre[cur.prop] = Number(pre[cur.prop]) pre[cur.prop] = Number(pre[cur.prop])
return pre return pre
}, {}) }, {})
console.log(this.mqttClient)
this.mqttClient.publish('presence', JSON.stringify({ this.mqttClient.publish(`1/app/zzkj0002/control/request`, JSON.stringify({
fun: 'SET', fun: 'SET',
type: 'WJ_Set_NewControlSystem', type: 'WJ_Set_NewControlSystem',
content: { content: {

View File

@ -84,6 +84,8 @@
{{ $t('homePage.home.emsControl') }} {{ $t('homePage.home.emsControl') }}
</button> </button>
</view> </view>
</view> </view>
@ -283,11 +285,16 @@
}, },
methods: { methods: {
toDeviceControl() { toDeviceControl() {
console.log(123)
uni.navigateTo({ uni.navigateTo({
url:'/pages/home-page/policy-Config/index' url:'/pages/home-page/policy-Config/index'
}) })
}, },
toStrategy(){
uni.navigateTo({
url:'/pages/home-page/strategy/index'
})
},
confirmTime(val) { confirmTime(val) {
this.formInfo.effectiveTime = val.hour + ':' + val.minute this.formInfo.effectiveTime = val.hour + ':' + val.minute
this.formInfo.planRefreshH = val.hour this.formInfo.planRefreshH = val.hour