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
521e13e1
Commit
521e13e1
authored
Sep 04, 2023
by
李纪文
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 组态修改,解决dom不存在问题
parent
7be9fba7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
21 deletions
+29
-21
RealModel.js
...s/extend-components/EC_ConfigurationView/src/RealModel.js
+29
-21
No files found.
packages/extend-components/EC_ConfigurationView/src/RealModel.js
View file @
521e13e1
/* eslint-disable */
/* eslint-disable */
import
React
,
{
useState
,
useEffect
,
useRef
,
useContext
}
from
'react'
;
import
React
,
{
useState
,
useEffect
,
useRef
,
useContext
,
useMemo
,
useCallback
}
from
'react'
;
import
classNames
from
'classnames'
;
import
classNames
from
'classnames'
;
import
moment
from
'moment'
;
import
moment
from
'moment'
;
import
axios
from
'axios'
;
import
axios
from
'axios'
;
...
@@ -64,11 +64,10 @@ let historyInfoParams = [];
...
@@ -64,11 +64,10 @@ let historyInfoParams = [];
let
statisticalInfoParams
=
{};
let
statisticalInfoParams
=
{};
let
nodeData
=
null
;
// 选中节点的数据
let
nodeData
=
null
;
// 选中节点的数据
let
twoID
=
''
;
let
twoID
=
''
;
let
myDiagram
=
null
;
const
waterFlow
=
new
WaterFlowControlView
();
const
waterFlow
=
new
WaterFlowControlView
();
const
ConfigurationView
=
(
props
)
=>
{
const
ConfigurationView
=
(
props
)
=>
{
//
let myDiagram = null;
let
myDiagram
=
null
;
let
mqttView
=
null
;
let
mqttView
=
null
;
let
editionArr
=
[];
let
editionArr
=
[];
let
globalControl
=
false
;
let
globalControl
=
false
;
...
@@ -92,12 +91,18 @@ const ConfigurationView = (props) => {
...
@@ -92,12 +91,18 @@ const ConfigurationView = (props) => {
const
[
videoTitle
,
setVideoTitle
]
=
useState
(
''
);
const
[
videoTitle
,
setVideoTitle
]
=
useState
(
''
);
const
[
viewType
,
setViewType
]
=
useState
(
false
);
const
[
viewType
,
setViewType
]
=
useState
(
false
);
const
[
currentUser
,
setCurrentUser
]
=
useState
(
false
);
const
[
currentUser
,
setCurrentUser
]
=
useState
(
false
);
const
[
noInitial
,
setNoInitial
]
=
useState
(
false
);
const
[
domFlag
,
setDomFlag
]
=
useState
(
true
);
const
[
numerals
,
setNumerals
]
=
useState
(
1
);
twoID
=
`TDG
${
Date
.
now
().
toString
(
36
)}
`
;
//
twoID = `TDG${Date.now().toString(36)}`;
const
navigatorAgent
=
/
(
iPhone|iOS|Android|Windows Phone
)
/i
.
test
(
navigator
.
userAgent
);
const
navigatorAgent
=
/
(
iPhone|iOS|Android|Windows Phone
)
/i
.
test
(
navigator
.
userAgent
);
const
AdjustControlInput
=
useRef
();
const
AdjustControlInput
=
useRef
();
const
AuthorFrom
=
useRef
();
const
AuthorFrom
=
useRef
();
const
ConfigurationRef
=
useRef
();
const
ConfigurationRef
=
useRef
();
const
ConfigurationViewRef
=
useCallback
((
dom
)
=>
{
setDomFlag
(
!!
dom
);
});
const
customBack
=
props
.
customBack
?
props
.
customBack
:
()
=>
{};
const
customBack
=
props
.
customBack
?
props
.
customBack
:
()
=>
{};
const
{
devices
=
[],
config
,
isZoom
=
false
,
flowShow
=
true
,
deviceName
=
[]
}
=
props
;
const
{
devices
=
[],
config
,
isZoom
=
false
,
flowShow
=
true
,
deviceName
=
[]
}
=
props
;
let
devicesCode
=
[];
let
devicesCode
=
[];
...
@@ -454,6 +459,7 @@ const ConfigurationView = (props) => {
...
@@ -454,6 +459,7 @@ const ConfigurationView = (props) => {
/** *********************************MQTT请求数据回调****************************** */
/** *********************************MQTT请求数据回调****************************** */
const
refreshData
=
(
mqttDatas
,
code
)
=>
{
const
refreshData
=
(
mqttDatas
,
code
)
=>
{
if
(
isClose
||
!
myDiagram
)
return
false
;
const
bindList
=
bindData
.
find
((
item
)
=>
{
const
bindList
=
bindData
.
find
((
item
)
=>
{
return
item
.
code
===
code
;
return
item
.
code
===
code
;
});
});
...
@@ -837,16 +843,13 @@ const ConfigurationView = (props) => {
...
@@ -837,16 +843,13 @@ const ConfigurationView = (props) => {
};
};
useEffect
(()
=>
{
useEffect
(()
=>
{
diagramInit
();
if
(
noInitial
&&
domFlag
)
{
return
()
=>
{
setNumerals
(
numerals
+
1
);
if
(
myDiagram
)
{
}
myDiagram
.
div
=
null
;
},
[
noInitial
,
domFlag
]);
myDiagram
=
null
;
}
};
},
[]);
useEffect
(()
=>
{
useEffect
(()
=>
{
twoID
=
`TDG
${
Date
.
now
().
toString
(
36
)}
`
;
if
(
!
props
.
name
)
{
if
(
!
props
.
name
)
{
setDescription
(
'咦~工艺图配置信息不全哦~'
);
setDescription
(
'咦~工艺图配置信息不全哦~'
);
setIsEmpty
(
true
);
setIsEmpty
(
true
);
...
@@ -860,12 +863,12 @@ const ConfigurationView = (props) => {
...
@@ -860,12 +863,12 @@ const ConfigurationView = (props) => {
isClose
=
true
;
isClose
=
true
;
mqttView
&&
mqttView
.
disSaveWaconnect
();
mqttView
&&
mqttView
.
disSaveWaconnect
();
mqttView
=
null
;
mqttView
=
null
;
//
if (myDiagram) {
if
(
myDiagram
)
{
//
myDiagram.div = null;
myDiagram
.
div
=
null
;
//
myDiagram = null;
myDiagram
=
null
;
//
}
}
};
};
},
[
props
.
name
]);
},
[
props
.
name
,
numerals
]);
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
!
isModalVisible
)
{
if
(
!
isModalVisible
)
{
...
@@ -903,6 +906,7 @@ const ConfigurationView = (props) => {
...
@@ -903,6 +906,7 @@ const ConfigurationView = (props) => {
nodeDataArray: [],
nodeDataArray: [],
linkDataArray: [],
linkDataArray: [],
};
};
if (!ConfigurationRef.current) return setNoInitial(true);
mqttView = devicesCode.length
mqttView = devicesCode.length
? new MqttView({
? new MqttView({
mqttIP: globalConfig.mqtt_iotIP,
mqttIP: globalConfig.mqtt_iotIP,
...
@@ -915,6 +919,7 @@ const ConfigurationView = (props) => {
...
@@ -915,6 +919,7 @@ const ConfigurationView = (props) => {
})
})
: null;
: null;
diagramRender(typeof fromJson === '
string
' ? fromJson : JSON.stringify(fromJson), list);
diagramRender(typeof fromJson === '
string
' ? fromJson : JSON.stringify(fromJson), list);
setNoInitial(false);
try {
try {
mqttView && mqttView.saveWaterMqtt();
mqttView && mqttView.saveWaterMqtt();
} catch (e) {
} catch (e) {
...
@@ -1536,7 +1541,7 @@ const ConfigurationView = (props) => {
...
@@ -1536,7 +1541,7 @@ const ConfigurationView = (props) => {
};
};
/** **********************************画布渲染************************************ */
/** **********************************画布渲染************************************ */
const diagram
Init
= (jsonStr, chartInfo) => {
const diagram
Render
= (jsonStr, chartInfo) => {
myDiagram = goJS(
myDiagram = goJS(
go.Diagram,
go.Diagram,
twoID, // must name or refer to the DIV HTML element
twoID, // must name or refer to the DIV HTML element
...
@@ -2978,8 +2983,7 @@ const ConfigurationView = (props) => {
...
@@ -2978,8 +2983,7 @@ const ConfigurationView = (props) => {
// }),
// }),
// ),
// ),
// );
// );
};
const diagramRender = (jsonStr, chartInfo) => {
const fromJson = JSON.parse(jsonStr);
const fromJson = JSON.parse(jsonStr);
myTimeout(() => {
myTimeout(() => {
loop();
loop();
...
@@ -3027,6 +3031,10 @@ const ConfigurationView = (props) => {
...
@@ -3027,6 +3031,10 @@ const ConfigurationView = (props) => {
if (item.category == 'timeCase') {
if (item.category == 'timeCase') {
item.timeStr = item.text;
item.timeStr = item.text;
}
}
if (item.category === 'bgCase') {
myDiagram.defaultScale = item.scale || item.scale === 0 ? item.scale : 1;
}
// 兼容V1之前版本(部分展示可支持)
// 兼容V1之前版本(部分展示可支持)
if (chartInfo.version === 'V1') return false;
if (chartInfo.version === 'V1') return false;
item.shName = item.showName || '';
item.shName = item.showName || '';
...
@@ -3040,7 +3048,7 @@ const ConfigurationView = (props) => {
...
@@ -3040,7 +3048,7 @@ const ConfigurationView = (props) => {
return (
return (
<div className={classNames(prefixCls)} ref={ConfigurationRef}>
<div className={classNames(prefixCls)} ref={ConfigurationRef}>
<div id={twoID} className={classNames('configurationView')}>
<div id={twoID}
ref={ConfigurationViewRef}
className={classNames('configurationView')}>
{/* <LoadBox spinning={spinning} /> */}
{/* <LoadBox spinning={spinning} /> */}
{isEmpty && <Empty theme={'dark'} description={description} />}
{isEmpty && <Empty theme={'dark'} description={description} />}
</div>
</div>
...
...
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