Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wisdom-components
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ReactWeb5
wisdom-components
Commits
619fd606
Commit
619fd606
authored
Aug 04, 2023
by
李纪文
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 组态增加源数据
parent
bc5ac076
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
141 additions
and
2 deletions
+141
-2
package.json
package.json
+2
-1
RealModel.js
...s/extend-components/EC_ConfigurationView/src/RealModel.js
+139
-1
No files found.
package.json
View file @
619fd606
...
@@ -146,7 +146,6 @@
...
@@ -146,7 +146,6 @@
},
},
"dependencies"
:
{
"dependencies"
:
{
"
@babel/plugin-proposal-private-methods
"
:
"^7.18.6"
,
"
@babel/plugin-proposal-private-methods
"
:
"^7.18.6"
,
"
@wisdom-components/VmsVideo
"
:
"1.1.13"
,
"
@wisdom-components/basictable
"
:
"^1.5.14"
,
"
@wisdom-components/basictable
"
:
"^1.5.14"
,
"
@wisdom-components/ec_historyview
"
:
"^1.4.3"
,
"
@wisdom-components/ec_historyview
"
:
"^1.4.3"
,
"
@wisdom-components/empty
"
:
"^1.3.9"
,
"
@wisdom-components/empty
"
:
"^1.3.9"
,
...
@@ -154,8 +153,10 @@
...
@@ -154,8 +153,10 @@
"
@wisdom-components/loadbox
"
:
"1.1.4"
,
"
@wisdom-components/loadbox
"
:
"1.1.4"
,
"
@wisdom-components/timerangepicker
"
:
"^1.3.4"
,
"
@wisdom-components/timerangepicker
"
:
"^1.3.4"
,
"
@wisdom-components/videoslidermodal
"
:
"1.1.2"
,
"
@wisdom-components/videoslidermodal
"
:
"1.1.2"
,
"
@wisdom-components/VmsVideo
"
:
"1.1.13"
,
"
@wisdom-utils/utils
"
:
"0.0.46"
,
"
@wisdom-utils/utils
"
:
"0.0.46"
,
"
antd-mobile
"
:
"5.10.4"
,
"
antd-mobile
"
:
"5.10.4"
,
"
axios
"
:
"^1.4.0"
,
"
classnames
"
:
"^2.2.6"
,
"
classnames
"
:
"^2.2.6"
,
"
cross-spawn
"
:
"^7.0.3"
,
"
cross-spawn
"
:
"^7.0.3"
,
"
echarts
"
:
"^5.4.0"
,
"
echarts
"
:
"^5.4.0"
,
...
...
packages/extend-components/EC_ConfigurationView/src/RealModel.js
View file @
619fd606
...
@@ -2,6 +2,7 @@
...
@@ -2,6 +2,7 @@
import
React
,
{
useState
,
useEffect
,
useRef
,
useContext
}
from
'react'
;
import
React
,
{
useState
,
useEffect
,
useRef
,
useContext
}
from
'react'
;
import
classNames
from
'classnames'
;
import
classNames
from
'classnames'
;
import
moment
from
'moment'
;
import
moment
from
'moment'
;
import
axios
from
'axios'
;
import
sha1
from
'sha1'
;
import
sha1
from
'sha1'
;
import
Empty
from
'@wisdom-components/empty'
;
import
Empty
from
'@wisdom-components/empty'
;
import
LoadBox
from
'@wisdom-components/loadbox'
;
import
LoadBox
from
'@wisdom-components/loadbox'
;
...
@@ -913,6 +914,67 @@ const ConfigurationView = (props) => {
...
@@ -913,6 +914,67 @@ const ConfigurationView = (props) => {
);
);
};
};
/** ************************************数据源模型获取******************************* */
const getDataModel = () => {
const json = JSON.parse(myDiagram.model.toJson());
const jsonCopy = JSON.parse(JSON.stringify(json));
const nodeDataArray = jsonCopy.nodeDataArray;
const dataCaseArr = nodeDataArray.filter((item) => {
return item.category === '
dataSource
' && item.url;
});
try {
dataCaseArr.forEach((item, index) => {
const time = new Date().getTime() + index;
const params =
item && item.parameters
? (isJson(item.parameters) && JSON.parse(item.parameters)) || {}
: {};
const data = item && item.body ? (isJson(item.body) && JSON.parse(item.body)) || {} : {};
axios({
method: item.method,
url: item.url,
params: {
...params,
time: time,
},
data: data,
})
.then((res) => {
realValueHandle(nodeDataArray, item, getDataFilter(item, res?.data || {}));
})
.catch((err) => {
realValueHandle(nodeDataArray, item, null);
});
});
} catch (err) {}
};
/** ************************************数据源过滤器******************************* */
const getDataFilter = (item, data) => {
try {
const script = item && item.filter ? item.filter : '';
if (!script) return data;
const list = new Function('
data
', script)(data);
return list;
} catch (err) {
return null;
}
};
/** ************************************源数据模型处理******************************* */
const realValueHandle = (nodeDataArray, list, data) => {
nodeDataArray.forEach((item) => {
if (item.category !== '
dataCase
' || item.dataSource !== list.sname || !item.shType)
return false;
try {
const script = item && item.filter ? item.filter : '';
const value = new Function('
data
', script)(data);
const node = myDiagram.model.findNodeDataForKey(item.key);
myDiagram.model.setDataProperty(node, '
showVal
', value || '
--
');
} catch (err) {}
});
};
/** ************************************图表数据处理******************************* */
/** ************************************图表数据处理******************************* */
const chartDataRender = (mqttData) => {
const chartDataRender = (mqttData) => {
const json = JSON.parse(myDiagram.model.toJson());
const json = JSON.parse(myDiagram.model.toJson());
...
@@ -1020,7 +1082,7 @@ const ConfigurationView = (props) => {
...
@@ -1020,7 +1082,7 @@ const ConfigurationView = (props) => {
/** **************************************历史模态渲染****************************************** */
/** **************************************历史模态渲染****************************************** */
const historyModalRender = (data, list) => {
const historyModalRender = (data, list) => {
if(!data.shName) return false;
if
(!data.shName) return false;
historyInfoParams = [
historyInfoParams = [
{
{
deviceCode: list.code,
deviceCode: list.code,
...
@@ -1946,6 +2008,81 @@ const ConfigurationView = (props) => {
...
@@ -1946,6 +2008,81 @@ const ConfigurationView = (props) => {
),
),
);
);
// 源数据模型
myDiagram.nodeTemplateMap.add(
'dataCase',
goJS(
go.Node,
'Auto',
nodeStyle(),
'Spot',
{ locationSpot: go.Spot.Center, zOrder: 3, cursor: 'default' },
new go.Binding('zOrder', 'zOrder').makeTwoWay(),
new go.Binding('cursor', 'cursor').makeTwoWay(),
new go.Binding('location', 'loc', go.Point.parse).makeTwoWay(go.Point.stringify),
new go.Binding('angle').makeTwoWay(),
roleVisibleBinding(), // 绑定角色可见
goJS(
go.Shape,
'RoundedRectanglePlus',
{ name: 'SHAPE', strokeWidth: 10, stroke: '#000000', parameter1: 0 },
new go.Binding('fill', 'fillColor').makeTwoWay(),
new go.Binding('stroke').makeTwoWay(),
new go.Binding('strokeWidth').makeTwoWay(),
new go.Binding('parameter1', 'radius').makeTwoWay(),
new go.Binding('desiredSize', 'size', go.Size.parse).makeTwoWay(go.Size.stringify),
),
goJS(
go.TextBlock,
textStyle(),
{
// margin: 5,
maxSize: new go.Size(NaN, NaN),
minSize: new go.Size(NaN, 1),
wrap: go.TextBlock.WrapFit,
textAlign: 'center',
editable: true,
font: 'bold 12px Helvetica, Arial, sans-serif',
stroke: '#454545',
},
new go.Binding('text', 'showVal').makeTwoWay(),
new go.Binding('font', 'fontStyle'),
new go.Binding('stroke', 'fontStroke').makeTwoWay(),
new go.Binding('textAlign', 'fontAlign'),
new go.Binding('maxSize', 'textSize'),
new go.Binding('minSize', 'textSize'),
),
{
click(e, node) {
if (navigatorAgent) return false;
const { data } = node;
nodeData = data;
const list = bindData.find((item) => {
return item.name === data.stationName;
});
if (!list) return false;
switch (data.opType) {
case '画板跳转': // 图片模型
drawBoardMethod(data);
break;
case '功能跳转': // 功能模型
menuJumpMethod(data);
break;
case '视频查看': // 视频查看
videoScanMethod(data);
break;
case '自定义交互': // 自定义交互
customBack(data);
interactiveScript(data);
break;
default:
break;
}
},
},
),
);
// 名称定义
// 名称定义
myDiagram.nodeTemplateMap.add(
myDiagram.nodeTemplateMap.add(
'nameCase',
'nameCase',
...
@@ -2709,6 +2846,7 @@ const ConfigurationView = (props) => {
...
@@ -2709,6 +2846,7 @@ const ConfigurationView = (props) => {
if (item.category === 'valCase') item.shType = '值显示';
if (item.category === 'valCase') item.shType = '值显示';
});
});
myDiagram.model = go.Model.fromJson(json);
myDiagram.model = go.Model.fromJson(json);
getDataModel();
};
};
return (
return (
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment