Commit 46534cc19d95e611d3bc5bb992fbe2fcd41f335d

Authored by chenxt
1 parent a224b286

弹窗关闭后刷新组件

Showing 1 changed file with 13 additions and 3 deletions
src/mes/indexMes/index.js
... ... @@ -1133,6 +1133,13 @@ const ContentComponent = () => {
1133 1133 onOpenFilePreviewModal: handleOpenfilePreviewModal,
1134 1134 onOpenCommonModal: rest.onOpenCommonModal,
1135 1135 };
  1136 + const [key, setKey] = useState(Date.now());
  1137 +
  1138 + useEffect(() => {
  1139 + if (!hooksProps.refresh) return
  1140 + setKey(Date.now());
  1141 + dispatch(["saveState", { refresh: false }]);
  1142 + }, [hooksProps.refresh]);
1136 1143  
1137 1144 let viewComponent = {
1138 1145 // 班组信息
... ... @@ -1152,8 +1159,10 @@ const ContentComponent = () => {
1152 1159 return (
1153 1160 <>
1154 1161 {currentContent ? (
1155   - <div className="content" id="xlyMesContent">
1156   - {viewComponent[currentContent]()}
  1162 + <div className="content" id="xlyMesContent" >
  1163 + <React.Fragment key={key}>
  1164 + {viewComponent[currentContent]()}
  1165 + </React.Fragment>
1157 1166 </div>
1158 1167 ) : (
1159 1168 ""
... ... @@ -1184,7 +1193,8 @@ const CommonModal = () =&gt; {
1184 1193 onCancel: () => {
1185 1194 window.bXingchejiluModal = false;
1186 1195 window.deviceTargetInfoModal = false;
1187   - dispatch(["saveState", { [`${sName}Visible`]: false, refresh: true}]);
  1196 + dispatch(["saveState", { [`${sName}Visible`]: false, refresh: true }]);
  1197 +
1188 1198 },
1189 1199 parentProps: hooksProps[`${sName}parentProps`],
1190 1200 modalCallback: hooksProps[`${sName}modalCallback`]
... ...