From 1d96f473a0ef4c7331a39ed0daee9273af795414 Mon Sep 17 00:00:00 2001 From: zhangzhen <525765282@qq.com> Date: Mon, 8 Sep 2025 11:08:57 +0800 Subject: [PATCH] 优化指令集可视化功能; --- src/components/Common/CommonBase.js | 9 +++++++++ src/components/Common/InstructSetSetting/index.js | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 72 insertions(+), 2 deletions(-) diff --git a/src/components/Common/CommonBase.js b/src/components/Common/CommonBase.js index d5755aa..23557a2 100644 --- a/src/components/Common/CommonBase.js +++ b/src/components/Common/CommonBase.js @@ -92,6 +92,11 @@ export default (ChildComponent) => { localStorage.setItem('oeeModelData', JSON.stringify(sModelData)); } + try { + const { key } = this.props.app.currentPane; + window[`getPropsByPanelKey${key}`] = () => ({ ...this.props, ...this.state }); + } catch (e) {} + /* 关闭浏览器前进行提示 */ } @@ -152,6 +157,10 @@ export default (ChildComponent) => { window.removeEventListener('beforeunload', this.beforeunload); window.removeEventListener('unload', this.unload); window.removeEventListener('keydown', this.handleF9KeyPress); + try { + const { key } = this.props.app.currentPane; + delete window[`getPropsByPanelKey${key}`]; + } catch (e) {} } // 页面加载完成后执行一次指令集 diff --git a/src/components/Common/InstructSetSetting/index.js b/src/components/Common/InstructSetSetting/index.js index d8c09c9..6f7e7f2 100644 --- a/src/components/Common/InstructSetSetting/index.js +++ b/src/components/Common/InstructSetSetting/index.js @@ -1,6 +1,8 @@ import { useEffect, useState, useRef } from "react"; import AntDraggableModal from "../AntdDraggableModal"; import * as commonUtils from "@/utils/utils"; +import commonConfig from "@/utils/config"; +import * as commonServices from "@/services/services"; import styles from "./index.less"; import { Input, Button, Space } from "antd-v4"; import { MinusOutlined, CloseOutlined } from "@ant-design/icons"; @@ -12,8 +14,64 @@ const InstructSetSetting = (props = {}) => { const { instructSetSettingVisible } = props; if (!instructSetSettingVisible) return ""; - const { onCancelInstructSetSettingModal, showConfig, dataValue, instructSetSettingId, slave0Data } = props; + const { onCancelInstructSetSettingModal, showConfig, dataValue, instructSetSettingId, slave0Data, app } = props; const { showName, sName } = showConfig; + const { currentPane } = app; + const { key, parentPaneKey } = currentPane; + + const getSqlDropDownData = async ({ sId, sSqlCondition = {} }, cb) => { + const url = `${commonConfig.server_host}business/getSelectLimit/${sId}`; + const body = { + sKeyUpFilterName: "", + pageNum: 1, + pageSize: 10000, + sSqlCondition, + }; + const retrunData = await commonServices.postValueService(props.app.token, body, url); + const dropDownData = retrunData.data?.dataset?.rows; + cb(dropDownData); + }; + + const configList = useRef([]); + const srcModelsList = useRef([]); + useEffect(() => { + const parentProps = window[`getPropsByPanelKey${parentPaneKey}`] ? window[`getPropsByPanelKey${parentPaneKey}`]() : {}; + const { formData = [] } = parentProps; + const tempData = Object.keys(parentProps).filter( + key => + key?.endsWith("Config") + && (key === 'masterConfig' || key?.startsWith('slave') || parentProps[key]?.bGrdVisible) + && formData.some(item => item.sId === parentProps[key]?.sId) + ) + .filter(key => parentProps.formRoute?.includes("commonList") ? !key.includes('master') : true) + .reduce((pre, cur) => { + pre[cur.replace('Config', '')] = parentProps[cur]; + return pre; + }, {}) + + const tempConfig = formData.reduce((pre, config) => { + const iIndex = Object.values(tempData).findIndex(item => item.sId === config.sId); + if (iIndex !== -1) { + pre.push({ ...config, tableName: Object.keys(tempData)[iIndex] }); + } + return pre; + }, []); + + configList.current = tempConfig; + + const currentProps = window[`getPropsByPanelKey${key}`] ? window[`getPropsByPanelKey${key}`]() : {}; + const sActiveNameConfig = currentProps.slaveConfig?.gdsconfigformslave?.find(item => item.sName === 'sActiveName'); + if (sActiveNameConfig) { + const { sId } = sActiveNameConfig; + getSqlDropDownData({ sId }, (data) => { + srcModelsList.current = data; + }) + } + + }, []); + + + const instructSet = commonUtils.convertStrToObj(dataValue, {}); const { bConfigured } = instructSet; @@ -27,7 +85,7 @@ const InstructSetSetting = (props = {}) => { try { const newValue = JSON.stringify(JSON.parse(value.replace(/[\r\n]/g, "")), null, 2); setValue(newValue); - } catch (e) {} + } catch (e) { } }, [formatFlag]); const onReceiveData = event => { @@ -40,11 +98,14 @@ const InstructSetSetting = (props = {}) => { if (command === "initData") { if (!bConfigured && props.name !== "master") return; + iframeRef.current.contentWindow.postMessage( { command: "initData", value: instructSet.change || instructSet.blur || (instructSet ? [instructSet] : []), slave0Data, + configList: configList.current, + srcModelsList: srcModelsList.current, }, IFRAMEURL ); -- libgit2 0.22.2