初始化
parent
726078fdef
commit
b632834b07
@ -0,0 +1,79 @@
|
|||||||
|
<template>
|
||||||
|
<div class="vue-characters"></div>
|
||||||
|
</template>
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, watch } from 'vue';
|
||||||
|
import { useNodeByModelsStore } from '@/components/mt-edit/store/nodeByModels';
|
||||||
|
const nodeByModelsStore = useNodeByModelsStore();
|
||||||
|
const double = ref(-1);
|
||||||
|
const boolean = ref(false);
|
||||||
|
const alarms = ref(false);
|
||||||
|
const text = ref('正常');
|
||||||
|
const props = defineProps({
|
||||||
|
moduleType: {
|
||||||
|
type: String,
|
||||||
|
default: '--'
|
||||||
|
},
|
||||||
|
moduleId: {
|
||||||
|
type: String,
|
||||||
|
default: '--'
|
||||||
|
},
|
||||||
|
definitionItemJson: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({})
|
||||||
|
},
|
||||||
|
location: {
|
||||||
|
type: String,
|
||||||
|
default: 'bottom'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
const getSting = (data: any) => {
|
||||||
|
|
||||||
|
};
|
||||||
|
function getModuleById(moduleId: string) {
|
||||||
|
const globalData = (window as any).globalData;
|
||||||
|
if (!globalData || moduleId == undefined || moduleId == '' || props.moduleId == '--') {
|
||||||
|
console.warn('globalData 未初始化');
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 根据实际类型访问
|
||||||
|
if (globalData instanceof Map) {
|
||||||
|
// 如果是 Map 类型
|
||||||
|
return globalData.get(moduleId);
|
||||||
|
} else {
|
||||||
|
// 如果是普通对象
|
||||||
|
return globalData[moduleId];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function loadingModuleById() {
|
||||||
|
let module = getModuleById(props.moduleId);
|
||||||
|
if (props.moduleId !== '' && props.moduleId !== undefined && props.moduleId !== '--' && module) {
|
||||||
|
if (module) {
|
||||||
|
console.log('当前的module', module);
|
||||||
|
double.value = module.double;
|
||||||
|
boolean.value = module.double;
|
||||||
|
getSting({
|
||||||
|
double: double.value,
|
||||||
|
boolean: boolean.value,
|
||||||
|
alarms: alarms.value,
|
||||||
|
...module
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
watch(
|
||||||
|
() => props.moduleId,
|
||||||
|
(newVal, oldVal) => {
|
||||||
|
loadingModuleById();
|
||||||
|
nodeByModelsStore.change(newVal, oldVal, props.definitionItemJson.id);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.vue-characters {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@ -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<RecIn>={};
|
||||||
|
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})?$/
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue