Commit 29f73553 by zhaochengxiang

代码优化

parent 1245dced
...@@ -288,11 +288,11 @@ const ModelTable = (props) => { ...@@ -288,11 +288,11 @@ const ModelTable = (props) => {
useEffect(() => { useEffect(() => {
if ((modelId||'') !== '') { if ((modelId||'') !== '') {
window?.addEventListener("storage", (e) => { window?.addEventListener("storage", modelEventChange);
if (e.key === 'modelChange') {
getCheckoutDataModel(); return () => {
} window?.removeEventListener("storage", modelEventChange);
}); }
} }
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
...@@ -435,6 +435,12 @@ const ModelTable = (props) => { ...@@ -435,6 +435,12 @@ const ModelTable = (props) => {
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, [ tableWidth ]) }, [ tableWidth ])
const modelEventChange = (e) => {
if (e.key === 'modelChange') {
getCheckoutDataModel();
}
}
const getCheckoutDataModel = () => { const getCheckoutDataModel = () => {
dispatch({ dispatch({
type: 'datamodel.getCheckoutDataModel', type: 'datamodel.getCheckoutDataModel',
......
...@@ -61,11 +61,17 @@ class Model extends React.Component { ...@@ -61,11 +61,17 @@ class Model extends React.Component {
componentDidMount() { componentDidMount() {
this.getModelStates(); this.getModelStates();
window?.addEventListener("storage", (e) => { window?.addEventListener("storage", this.modelEventChange);
if (e.key === 'modelChange') { }
this.onTableChange();
} componentWillUnmount() {
}); window?.removeEventListener("storage", this.modelEventChange);
}
modelEventChange = (e) => {
if (e.key === 'modelChange') {
this.onTableChange();
}
} }
getModelStates = () => { getModelStates = () => {
......
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