Commit 28bb7ad6 authored by 李纪文's avatar 李纪文

feat: 组态时间模型增加当前时间

parent 592c7c76
......@@ -570,7 +570,11 @@ const ConfigurationView = (props) => {
shName !== item.stateName
)
return false;
if (node.category === 'timeCase' && shName === item.shName) {
if (
node.category === 'timeCase' &&
shName === item.shName &&
node.shType === '更新时间'
) {
myDiagram.model.setDataProperty(node, 'text', moment(list.Time).format(node.format));
myDiagram.model.setDataProperty(
node,
......@@ -743,6 +747,25 @@ const ConfigurationView = (props) => {
diagram.skipsUndoManager = oldskips;
};
// 当前时间更新
const updateTimeCase = () => {
let data = [];
myDiagram?.nodes?.map((list) => {
const node = list?.data || {};
if (node?.category === 'timeCase' && node?.shType === '当前时间') {
myDiagram.model.setDataProperty(node, 'text', moment().format(node.format));
myDiagram.model.setDataProperty(node, 'timeStr', moment().format('YYYY-MM-DD HH:mm:ss'));
data.push(node || {});
}
});
mySetInterval(() => {
data.map((node) => {
myDiagram.model.setDataProperty(node, 'text', moment().format(node.format));
myDiagram.model.setDataProperty(node, 'timeStr', moment().format('YYYY-MM-DD HH:mm:ss'));
});
}, 1000);
};
const myTimeout = (fn, delay) => {
let timer;
const stime = +new Date();
......@@ -1255,17 +1278,9 @@ const ConfigurationView = (props) => {
try {
jsonCopy.nodeDataArray.forEach((item) => {
if (!(item.shName || item.figure === 'updateTime')) return false;
if (!(item.shName || item.category === 'timeCase')) return false;
const node = myDiagram.model.findNodeDataForKey(item.key);
mqttData.forEach((list) => {
if (node.figure === 'updateTime') {
myDiagram.model.setDataProperty(
node,
'text',
new Date(list.PT).format('yyyy-MM-dd hh:mm:ss'),
);
return false;
}
const bindList = bindData.find((arr) => {
return arr.code === list.code;
});
......@@ -1274,6 +1289,19 @@ const ConfigurationView = (props) => {
});
if (!bindList || !pvList) return false;
if (item.stationName !== bindList.name) return false;
if (
node.category === 'timeCase' &&
item.stationName === bindList.name &&
item?.shType === '更新时间'
) {
myDiagram.model.setDataProperty(node, 'text', moment(list.pt).format(node.format));
myDiagram.model.setDataProperty(
node,
'timeStr',
moment(list.pt).format('YYYY-MM-DD HH:mm:ss'),
);
return false;
}
if (
(pvList.pv === null || pvList.dName !== item.shName || item.realVal === pvList.pv) &&
pvList.dName !== item.stateName
......@@ -3463,6 +3491,7 @@ const ConfigurationView = (props) => {
rotateSvg();
blenderSvg();
animationSvg();
updateTimeCase();
}, 100);
const json = JSON.parse(JSON.stringify(fromJson));
json.linkDataArray.forEach((item) => {
......
......@@ -539,7 +539,11 @@ const ConfigurationView = (props) => {
shName !== item.stateName
)
return false;
if (node.category === 'timeCase' && shName === item.shName) {
if (
node.category === 'timeCase' &&
shName === item.shName &&
node.shType === '更新时间'
) {
myDiagram.model.setDataProperty(node, 'text', moment(list.Time).format(node.format));
myDiagram.model.setDataProperty(
node,
......@@ -686,6 +690,25 @@ const ConfigurationView = (props) => {
diagram.skipsUndoManager = oldskips;
};
// 当前时间更新
const updateTimeCase = () => {
let data = [];
myDiagram?.nodes?.map((list) => {
const node = list?.data || {};
if (node?.category === 'timeCase' && node?.shType === '当前时间') {
myDiagram.model.setDataProperty(node, 'text', moment().format(node.format));
myDiagram.model.setDataProperty(node, 'timeStr', moment().format('YYYY-MM-DD HH:mm:ss'));
data.push(node || {});
}
});
mySetInterval(() => {
data.map((node) => {
myDiagram.model.setDataProperty(node, 'text', moment().format(node.format));
myDiagram.model.setDataProperty(node, 'timeStr', moment().format('YYYY-MM-DD HH:mm:ss'));
});
}, 1000);
};
const myTimeout = (fn, delay) => {
let timer;
const stime = +new Date();
......@@ -1197,17 +1220,9 @@ const ConfigurationView = (props) => {
try {
jsonCopy.nodeDataArray.forEach((item) => {
if (!(item.shName || item.figure === 'updateTime')) return false;
if (!(item.shName || item.category === 'timeCase')) return false;
const node = myDiagram.model.findNodeDataForKey(item.key);
mqttData.forEach((list) => {
if (node.figure === 'updateTime') {
myDiagram.model.setDataProperty(
node,
'text',
new Date(list.PT).format('yyyy-MM-dd hh:mm:ss'),
);
return false;
}
const bindList = bindData.find((arr) => {
return arr.code === list.code;
});
......@@ -1216,6 +1231,19 @@ const ConfigurationView = (props) => {
});
if (!bindList || !pvList) return false;
if (item.stationName !== bindList.name) return false;
if (
node.category === 'timeCase' &&
item.stationName === bindList.name &&
item?.shType === '更新时间'
) {
myDiagram.model.setDataProperty(node, 'text', moment(list.pt).format(node.format));
myDiagram.model.setDataProperty(
node,
'timeStr',
moment(list.pt).format('YYYY-MM-DD HH:mm:ss'),
);
return false;
}
if (
(pvList.pv === null || pvList.dName !== item.shName || item.realVal === pvList.pv) &&
pvList.dName !== item.stateName
......@@ -3268,6 +3296,7 @@ const ConfigurationView = (props) => {
rotateSvg();
blenderSvg();
animationSvg();
updateTimeCase();
}, 100);
const json = JSON.parse(JSON.stringify(fromJson));
json.linkDataArray.forEach((item) => {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment