Commit 1d96f473a0ef4c7331a39ed0daee9273af795414

Authored by zhangzzzz
1 parent 04a302b6

优化指令集可视化功能;

src/components/Common/CommonBase.js
... ... @@ -92,6 +92,11 @@ export default (ChildComponent) => {
92 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 157 window.removeEventListener('beforeunload', this.beforeunload);
153 158 window.removeEventListener('unload', this.unload);
154 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 1 import { useEffect, useState, useRef } from "react";
2 2 import AntDraggableModal from "../AntdDraggableModal";
3 3 import * as commonUtils from "@/utils/utils";
  4 +import commonConfig from "@/utils/config";
  5 +import * as commonServices from "@/services/services";
4 6 import styles from "./index.less";
5 7 import { Input, Button, Space } from "antd-v4";
6 8 import { MinusOutlined, CloseOutlined } from "@ant-design/icons";
... ... @@ -12,8 +14,64 @@ const InstructSetSetting = (props = {}) => {
12 14 const { instructSetSettingVisible } = props;
13 15 if (!instructSetSettingVisible) return "";
14 16  
15   - const { onCancelInstructSetSettingModal, showConfig, dataValue, instructSetSettingId, slave0Data } = props;
  17 + const { onCancelInstructSetSettingModal, showConfig, dataValue, instructSetSettingId, slave0Data, app } = props;
16 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 76 const instructSet = commonUtils.convertStrToObj(dataValue, {});
19 77 const { bConfigured } = instructSet;
... ... @@ -27,7 +85,7 @@ const InstructSetSetting = (props = {}) => {
27 85 try {
28 86 const newValue = JSON.stringify(JSON.parse(value.replace(/[\r\n]/g, "")), null, 2);
29 87 setValue(newValue);
30   - } catch (e) {}
  88 + } catch (e) { }
31 89 }, [formatFlag]);
32 90  
33 91 const onReceiveData = event => {
... ... @@ -40,11 +98,14 @@ const InstructSetSetting = (props = {}) => {
40 98  
41 99 if (command === "initData") {
42 100 if (!bConfigured && props.name !== "master") return;
  101 +
43 102 iframeRef.current.contentWindow.postMessage(
44 103 {
45 104 command: "initData",
46 105 value: instructSet.change || instructSet.blur || (instructSet ? [instructSet] : []),
47 106 slave0Data,
  107 + configList: configList.current,
  108 + srcModelsList: srcModelsList.current,
48 109 },
49 110 IFRAMEURL
50 111 );
... ...