Commit 1d96f473a0ef4c7331a39ed0daee9273af795414
1 parent
04a302b6
优化指令集可视化功能;
Showing
2 changed files
with
72 additions
and
2 deletions
src/components/Common/CommonBase.js
| @@ -92,6 +92,11 @@ export default (ChildComponent) => { | @@ -92,6 +92,11 @@ export default (ChildComponent) => { | ||
| 92 | localStorage.setItem('oeeModelData', JSON.stringify(sModelData)); | 92 | localStorage.setItem('oeeModelData', JSON.stringify(sModelData)); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | + try { | ||
| 96 | + const { key } = this.props.app.currentPane; | ||
| 97 | + window[`getPropsByPanelKey${key}`] = () => ({ ...this.props, ...this.state }); | ||
| 98 | + } catch (e) {} | ||
| 99 | + | ||
| 95 | /* 关闭浏览器前进行提示 */ | 100 | /* 关闭浏览器前进行提示 */ |
| 96 | } | 101 | } |
| 97 | 102 | ||
| @@ -152,6 +157,10 @@ export default (ChildComponent) => { | @@ -152,6 +157,10 @@ export default (ChildComponent) => { | ||
| 152 | window.removeEventListener('beforeunload', this.beforeunload); | 157 | window.removeEventListener('beforeunload', this.beforeunload); |
| 153 | window.removeEventListener('unload', this.unload); | 158 | window.removeEventListener('unload', this.unload); |
| 154 | window.removeEventListener('keydown', this.handleF9KeyPress); | 159 | window.removeEventListener('keydown', this.handleF9KeyPress); |
| 160 | + try { | ||
| 161 | + const { key } = this.props.app.currentPane; | ||
| 162 | + delete window[`getPropsByPanelKey${key}`]; | ||
| 163 | + } catch (e) {} | ||
| 155 | } | 164 | } |
| 156 | 165 | ||
| 157 | // 页面加载完成后执行一次指令集 | 166 | // 页面加载完成后执行一次指令集 |
src/components/Common/InstructSetSetting/index.js
| 1 | import { useEffect, useState, useRef } from "react"; | 1 | import { useEffect, useState, useRef } from "react"; |
| 2 | import AntDraggableModal from "../AntdDraggableModal"; | 2 | import AntDraggableModal from "../AntdDraggableModal"; |
| 3 | import * as commonUtils from "@/utils/utils"; | 3 | import * as commonUtils from "@/utils/utils"; |
| 4 | +import commonConfig from "@/utils/config"; | ||
| 5 | +import * as commonServices from "@/services/services"; | ||
| 4 | import styles from "./index.less"; | 6 | import styles from "./index.less"; |
| 5 | import { Input, Button, Space } from "antd-v4"; | 7 | import { Input, Button, Space } from "antd-v4"; |
| 6 | import { MinusOutlined, CloseOutlined } from "@ant-design/icons"; | 8 | import { MinusOutlined, CloseOutlined } from "@ant-design/icons"; |
| @@ -12,8 +14,64 @@ const InstructSetSetting = (props = {}) => { | @@ -12,8 +14,64 @@ const InstructSetSetting = (props = {}) => { | ||
| 12 | const { instructSetSettingVisible } = props; | 14 | const { instructSetSettingVisible } = props; |
| 13 | if (!instructSetSettingVisible) return ""; | 15 | if (!instructSetSettingVisible) return ""; |
| 14 | 16 | ||
| 15 | - const { onCancelInstructSetSettingModal, showConfig, dataValue, instructSetSettingId, slave0Data } = props; | 17 | + const { onCancelInstructSetSettingModal, showConfig, dataValue, instructSetSettingId, slave0Data, app } = props; |
| 16 | const { showName, sName } = showConfig; | 18 | const { showName, sName } = showConfig; |
| 19 | + const { currentPane } = app; | ||
| 20 | + const { key, parentPaneKey } = currentPane; | ||
| 21 | + | ||
| 22 | + const getSqlDropDownData = async ({ sId, sSqlCondition = {} }, cb) => { | ||
| 23 | + const url = `${commonConfig.server_host}business/getSelectLimit/${sId}`; | ||
| 24 | + const body = { | ||
| 25 | + sKeyUpFilterName: "", | ||
| 26 | + pageNum: 1, | ||
| 27 | + pageSize: 10000, | ||
| 28 | + sSqlCondition, | ||
| 29 | + }; | ||
| 30 | + const retrunData = await commonServices.postValueService(props.app.token, body, url); | ||
| 31 | + const dropDownData = retrunData.data?.dataset?.rows; | ||
| 32 | + cb(dropDownData); | ||
| 33 | + }; | ||
| 34 | + | ||
| 35 | + const configList = useRef([]); | ||
| 36 | + const srcModelsList = useRef([]); | ||
| 37 | + useEffect(() => { | ||
| 38 | + const parentProps = window[`getPropsByPanelKey${parentPaneKey}`] ? window[`getPropsByPanelKey${parentPaneKey}`]() : {}; | ||
| 39 | + const { formData = [] } = parentProps; | ||
| 40 | + const tempData = Object.keys(parentProps).filter( | ||
| 41 | + key => | ||
| 42 | + key?.endsWith("Config") | ||
| 43 | + && (key === 'masterConfig' || key?.startsWith('slave') || parentProps[key]?.bGrdVisible) | ||
| 44 | + && formData.some(item => item.sId === parentProps[key]?.sId) | ||
| 45 | + ) | ||
| 46 | + .filter(key => parentProps.formRoute?.includes("commonList") ? !key.includes('master') : true) | ||
| 47 | + .reduce((pre, cur) => { | ||
| 48 | + pre[cur.replace('Config', '')] = parentProps[cur]; | ||
| 49 | + return pre; | ||
| 50 | + }, {}) | ||
| 51 | + | ||
| 52 | + const tempConfig = formData.reduce((pre, config) => { | ||
| 53 | + const iIndex = Object.values(tempData).findIndex(item => item.sId === config.sId); | ||
| 54 | + if (iIndex !== -1) { | ||
| 55 | + pre.push({ ...config, tableName: Object.keys(tempData)[iIndex] }); | ||
| 56 | + } | ||
| 57 | + return pre; | ||
| 58 | + }, []); | ||
| 59 | + | ||
| 60 | + configList.current = tempConfig; | ||
| 61 | + | ||
| 62 | + const currentProps = window[`getPropsByPanelKey${key}`] ? window[`getPropsByPanelKey${key}`]() : {}; | ||
| 63 | + const sActiveNameConfig = currentProps.slaveConfig?.gdsconfigformslave?.find(item => item.sName === 'sActiveName'); | ||
| 64 | + if (sActiveNameConfig) { | ||
| 65 | + const { sId } = sActiveNameConfig; | ||
| 66 | + getSqlDropDownData({ sId }, (data) => { | ||
| 67 | + srcModelsList.current = data; | ||
| 68 | + }) | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + }, []); | ||
| 72 | + | ||
| 73 | + | ||
| 74 | + | ||
| 17 | 75 | ||
| 18 | const instructSet = commonUtils.convertStrToObj(dataValue, {}); | 76 | const instructSet = commonUtils.convertStrToObj(dataValue, {}); |
| 19 | const { bConfigured } = instructSet; | 77 | const { bConfigured } = instructSet; |
| @@ -27,7 +85,7 @@ const InstructSetSetting = (props = {}) => { | @@ -27,7 +85,7 @@ const InstructSetSetting = (props = {}) => { | ||
| 27 | try { | 85 | try { |
| 28 | const newValue = JSON.stringify(JSON.parse(value.replace(/[\r\n]/g, "")), null, 2); | 86 | const newValue = JSON.stringify(JSON.parse(value.replace(/[\r\n]/g, "")), null, 2); |
| 29 | setValue(newValue); | 87 | setValue(newValue); |
| 30 | - } catch (e) {} | 88 | + } catch (e) { } |
| 31 | }, [formatFlag]); | 89 | }, [formatFlag]); |
| 32 | 90 | ||
| 33 | const onReceiveData = event => { | 91 | const onReceiveData = event => { |
| @@ -40,11 +98,14 @@ const InstructSetSetting = (props = {}) => { | @@ -40,11 +98,14 @@ const InstructSetSetting = (props = {}) => { | ||
| 40 | 98 | ||
| 41 | if (command === "initData") { | 99 | if (command === "initData") { |
| 42 | if (!bConfigured && props.name !== "master") return; | 100 | if (!bConfigured && props.name !== "master") return; |
| 101 | + | ||
| 43 | iframeRef.current.contentWindow.postMessage( | 102 | iframeRef.current.contentWindow.postMessage( |
| 44 | { | 103 | { |
| 45 | command: "initData", | 104 | command: "initData", |
| 46 | value: instructSet.change || instructSet.blur || (instructSet ? [instructSet] : []), | 105 | value: instructSet.change || instructSet.blur || (instructSet ? [instructSet] : []), |
| 47 | slave0Data, | 106 | slave0Data, |
| 107 | + configList: configList.current, | ||
| 108 | + srcModelsList: srcModelsList.current, | ||
| 48 | }, | 109 | }, |
| 49 | IFRAMEURL | 110 | IFRAMEURL |
| 50 | ); | 111 | ); |