From b632834b07f3101f188049adbda905d58a26510d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E6=94=BF?= <3443290081@qq.com> Date: Thu, 26 Mar 2026 09:27:22 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 48 +++++ .../vue-components/vue-characters.vue | 79 ++++++++ .../vue-xq-test/vue-signal-gaudy.vue | 1 - src/utils/config.ts | 176 ++++++++++++++++++ 4 files changed, 303 insertions(+), 1 deletion(-) create mode 100644 src/components/vue-components/vue-characters.vue create mode 100644 src/utils/config.ts diff --git a/src/App.vue b/src/App.vue index 28a5d3c..651f21a 100644 --- a/src/App.vue +++ b/src/App.vue @@ -73,6 +73,7 @@ import VueGuagePieChart from '@/components/vue-components/echarts-pie-chart.vue' // src\components\vue-components\vue-signal-monitoring.vue import VueSignalMonitoring from '@/components/vue-components/vue-signal-monitoring.vue'; import VueImgImmobilization from '@/components/vue-components/vue-img-immobilization.vue'; +import VueCharacters from '@/components/vue-components/vue-characters.vue'; const instance = getCurrentInstance(); instance?.appContext.app.component('vue-my-button', VueMyButton); @@ -122,6 +123,7 @@ instance?.appContext.app.component('vue-guage-bar-chart', VueGuageBarChart); instance?.appContext.app.component('vue-guage-pie-chart', VueGuagePieChart); instance?.appContext.app.component('vue-img-immobilization', VueImgImmobilization); instance?.appContext.app.component('vue-signal-monitoring', VueSignalMonitoring); +instance?.appContext.app.component('vue-characters', VueCharacters); // instance?.appContext.app.component('vue-my-grade-gauge', VueGradeGauge); @@ -181,6 +183,52 @@ leftAsideStore.registerConfig('vue四遥组件', [ thumbnail: '/svgs/info.svg', props: {} }, + { + id: 'vue-characters', + title: '遥信文字', + type: 'vue', + thumbnail: '/svgs/info.svg', + props: { + moduleType: { + type: 'inputTypeTag', + val: '遥信', + title: '四遥类型' + }, + moduleId: { + type: 'inputSelectId', + val: '', + title: '绑定ID' + }, + showInfo: { + type: 'switch', + val: true, + title: '显示详情' + }, + location: { + type: 'select', + val: 'bottom', + title: '名称位置', + options: [ + { + value: 'top', + label: '上' + }, + { + value: 'bottom', + label: '下' + }, + { + value: 'left', + label: '左' + }, + { + value: 'right', + label: '右' + } + ] + } + } + }, { id: 'vue-my-signal-gaudy', title: 'vue遥信02', diff --git a/src/components/vue-components/vue-characters.vue b/src/components/vue-components/vue-characters.vue new file mode 100644 index 0000000..f2cea8d --- /dev/null +++ b/src/components/vue-components/vue-characters.vue @@ -0,0 +1,79 @@ + + + + diff --git a/src/components/vue-xq-test/vue-signal-gaudy.vue b/src/components/vue-xq-test/vue-signal-gaudy.vue index 5bfac7d..a182e5e 100644 --- a/src/components/vue-xq-test/vue-signal-gaudy.vue +++ b/src/components/vue-xq-test/vue-signal-gaudy.vue @@ -144,7 +144,6 @@ onUnmounted(() => { emitter.off(props.definitionItemJson.id); }); - const props = defineProps({ moduleType: { type: String, diff --git a/src/utils/config.ts b/src/utils/config.ts new file mode 100644 index 0000000..f0a4fef --- /dev/null +++ b/src/utils/config.ts @@ -0,0 +1,176 @@ +import { dayjs } from 'element-plus'; + +interface RecIn{ + Node: { + InTypeIn: [number, string][], + TypeBase: [number, string][], + }, + CONST: { + STR: { + EnumType: [number, string][] + }, + UserPage:[string, string][] + }, + EnumTypeVal: [number, string][][], + EnumTypeValFun: Function[], + regex: any, + trans: (val: any, enumArr: [number, string][])=> string +} + +const Rec: Partial={}; +Rec.Node={} as RecIn['Node']; +Rec.CONST={} as RecIn['CONST']; +Rec.trans = (index, type)=> { + for (let i = 0; i < type.length; i++) { + if (type[i][0] == index) { + return type[i][1]; + } + } + return "*未知*"; +}; +// 所有输入类型 +Rec.Node.InTypeIn = [ + [1, '遥信'], + [2, '遥测'] +]; + +// 四遥基本类型 +Rec.Node.TypeBase = [ + [1, '遥信'], + [2, '遥测'], + [3, '遥控'], + [4, '遥调'], +]; + +// 定值转化的 类型 +Rec.CONST.STR.EnumType = [ + [0, '缺省'], + [1, '普通开关'], + [2, '数值'], + [3, '时间秒'], + [11, 'RY空调模式'], + [12, '空调温度'], + [13, '空调风速'], + [14, '国网空调模式'], + [21, 'KTC空调'] +]; + +Rec.EnumTypeVal = []; // 定值类型,用于编辑时的选择 +Rec.EnumTypeValFun = []; // 转换函数,用于显示与控制 + +// 缺省 +Rec.EnumTypeVal[0] = [ + [0, '关闭'], + [1, '开启'] +]; + +Rec.EnumTypeValFun[0] = function (val:any) { + return Rec.trans!(val, Rec.EnumTypeVal![0]) +} + +// 遥控 +Rec.EnumTypeVal[1] = [ + [0, '关闭'], + [1, '开启'] +]; + +Rec.EnumTypeValFun[1] = function (val:any) { + return Rec.trans!(val, Rec.EnumTypeVal![1]) +} + +// 数值 +Rec.EnumTypeVal[2] = []; +Rec.EnumTypeValFun[2] = function (val:any) { + return []; +} + +// timestamp 转换成时间 +Rec.EnumTypeValFun[3] = function (val:any) { + // Ext.Date.format(val * 1000, 'Y-m-d H:i:s') + dayjs.unix(val).format('YYYY-MM-DD HH:mm:ss') +} + +// 国网空调模式 +Rec.EnumTypeVal[14] = [ + [4, '自动'], + [0, '制冷'], + [1, '制热'], + [3, '除湿'], + [2, '送风'] +]; + +Rec.EnumTypeValFun[14] = function (val:any) { + return Rec.trans!(val, Rec.EnumTypeVal![14]) +} + +// RY空调模式 +Rec.EnumTypeVal[11] = [ + [0, '自动'], + [1, '制冷'], + [2, '制热'], + [3, '除湿'], + [4, '送风'] +]; + +Rec.EnumTypeValFun[11] = function (val:any) { + return Rec.trans!(val, Rec.EnumTypeVal![11]) +} + +// 空调温度 +Rec.EnumTypeVal[12] = [ + [16, '16℃'], + [17, '17℃'], + [18, '18℃'], + [19, '19℃'], + [20, '20℃'], + [21, '21℃'], + [22, '22℃'], + [23, '23℃'], + [24, '24℃'], + [25, '25℃'], + [26, '26℃'], + [27, '27℃'], + [28, '28℃'], + [29, '29℃'], + [30, '30℃'] +]; + +Rec.EnumTypeValFun[12] = function (val:any) { + return Rec.trans!(val, Rec.EnumTypeVal![12]) +} + +// 空调风速 +Rec.EnumTypeVal[13] = [ + [0, '自动'], + [1, '低'], + [2, '中'], + [3, '高'] +]; + +Rec.EnumTypeValFun[13] = function (val:any) { + return Rec.trans!(val, Rec.EnumTypeVal![13]) +} + +// KTC 空调 +Rec.EnumTypeVal[21] = [ + [0, '关闭'], + [1, '制冷'], + [2, '制热'] +]; + +Rec.EnumTypeValFun[21] = function (val:any) { + return Rec.trans!(val, Rec.EnumTypeVal![21]) +} + +// 用户的缺省界面 +Rec.CONST.UserPage = [ + ['Admin', 'Admin'], + ['User', 'User'], +] + +// 正则表达式 +Rec.regex = { + // Modbus 配置的正则表达式 + modbusCfg: /^(?:25[0-4]|2[0-4]\d|1\d{2}|[1-9]\d|[1-9]):(?:[1-6]|10):(?:6553[0-5]|655[0-2]\d|65[0-4]\d{2}|6[0-4]\d{3}|[1-5]\d{4}|[1-9]\d{0,3}|0)(?::[2-9])?$/, + modbusParm: /^(?:\d+(?::\d+){0,2})?$/ +} \ No newline at end of file