Commit 1237bc855d1a4f352ba690a17441b54add41353c

Authored by chenxt
1 parent 8a6d9eb1

弹窗复制到

src/mes/common/commonModelComponent/index.js
@@ -264,7 +264,6 @@ const useCommonModelEvent = props => { @@ -264,7 +264,6 @@ const useCommonModelEvent = props => {
264 // 初始化事件 264 // 初始化事件
265 useEffect( 265 useEffect(
266 async () => { 266 async () => {
267 -  
268 if (commonUtils.isNotEmptyArr(formData)) { 267 if (commonUtils.isNotEmptyArr(formData)) {
269 let pageLayout = []; 268 let pageLayout = [];
270 let addState = {}; 269 let addState = {};
@@ -285,10 +284,10 @@ const useCommonModelEvent = props => { @@ -285,10 +284,10 @@ const useCommonModelEvent = props => {
285 const [tableList, tabConfig] = pageLayout; 284 const [tableList, tabConfig] = pageLayout;
286 const colunmData = handleGetColumnData(tableList, true); 285 const colunmData = handleGetColumnData(tableList, true);
287 let result = {}; 286 let result = {};
288 - if(!noGetData && sModelsId === '17211911815017669983448000'){ 287 + if (!noGetData && sModelsId === '17211911815017669983448000') {
289 result = await handleGetDataPop(tableList, true, true) 288 result = await handleGetDataPop(tableList, true, true)
290 } else if (!commonUtils.isEmptyObject(copyTo)) { 289 } else if (!commonUtils.isEmptyObject(copyTo)) {
291 - result = await handleGetData(tableList, true, true); 290 + result = await handleGetData(tableList, true, true, copyTo);
292 } else if (noGetData) { 291 } else if (noGetData) {
293 result = await handleGetData( 292 result = await handleGetData(
294 tableList.filter( 293 tableList.filter(
@@ -785,7 +784,7 @@ const useCommonModelEvent = props => { @@ -785,7 +784,7 @@ const useCommonModelEvent = props => {
785 }; 784 };
786 785
787 // 获取数据集 786 // 获取数据集
788 - const handleGetData = async (tableList = [], isWait, bInit) => { 787 + const handleGetData = async (tableList = [], isWait, bInit, copyTo) => {
789 let addState = {}; 788 let addState = {};
790 const currentIds = currentId ? currentId : props?.parentProps?.record?.sId 789 const currentIds = currentId ? currentId : props?.parentProps?.record?.sId
791 for (let i = 0; i < tableList.length; i++) { 790 for (let i = 0; i < tableList.length; i++) {
@@ -982,6 +981,16 @@ const useCommonModelEvent = props =&gt; { @@ -982,6 +981,16 @@ const useCommonModelEvent = props =&gt; {
982 if (tableName === "tableS0" && props.sSReserve1) { 981 if (tableName === "tableS0" && props.sSReserve1) {
983 addState.sSReserve1 = undefined; 982 addState.sSReserve1 = undefined;
984 } 983 }
  984 +
  985 + }
  986 + if (!commonUtils.isEmptyObject(copyTo)) {
  987 + tableList.forEach((item, index) => {
  988 + addState = {
  989 + ...addState,
  990 + [`${tableList[index]}Data`]: index === 0 ? copyTo.masterData : copyTo['slave' + (index - 1 === 0 ? '' : index - 1) + 'Data'],
  991 + }
  992 + })
  993 +
985 } 994 }
986 995
987 props.setTempRef({}, true); 996 props.setTempRef({}, true);
@@ -1937,6 +1946,7 @@ const CommonModelComponent = props =&gt; { @@ -1937,6 +1946,7 @@ const CommonModelComponent = props =&gt; {
1937 tableBtnsConfig, // 表格按钮配置 1946 tableBtnsConfig, // 表格按钮配置
1938 bFirstComponent: level === 0 && index === -1 1947 bFirstComponent: level === 0 && index === -1
1939 }; 1948 };
  1949 +
1940 const commonDivHeight = useComputedCommonDivHeight(componentProps); 1950 const commonDivHeight = useComputedCommonDivHeight(componentProps);
1941 return ( 1951 return (
1942 <div 1952 <div
@@ -2565,40 +2575,40 @@ const CommonTableComponent = props =&gt; { @@ -2565,40 +2575,40 @@ const CommonTableComponent = props =&gt; {
2565 // showSizeChanger: !isSmall, 2575 // showSizeChanger: !isSmall,
2566 // showQuickJumper: !isSmall, 2576 // showQuickJumper: !isSmall,
2567 // }; 2577 // };
2568 - const { mesTotalCount , mesPageSize, mesPageNum, isPagination } = baseProps?.parentProps || {};  
2569 - const tableProps = {  
2570 - ...baseProps,  
2571 - tableBtnsConfig: btnsConfig,  
2572 - // tableBtnsWidth: '100px',  
2573 - // tableBtnsConfig: (params) => {  
2574 - // console.log('=====params', params);  
2575 - // return btnsConfig;  
2576 - // },  
2577 - onTableBtnClick,  
2578 - tableProps: {  
2579 - onChange: () => { },  
2580 - rowKey: baseProps?.config?.sId === "17091154460006421964039036672000" || baseProps?.config?.sName?.includes('/indexPage/commonList') ? 'sSlaveId' : 'sId',  
2581 - mesTotalCount,  
2582 - mesPageSize,  
2583 - mesPageNum,  
2584 - isPagination,  
2585 - // AutoTableHeight: 200  
2586 - },  
2587 - onViewClick: (tableName, sFieldName, record, index, config) => {  
2588 - // 异常事件提报-提报信息-事件类型字段点击事件  
2589 - if (tableName === "slave" && sFieldName === "sClassifyName") {  
2590 - props.onTableBtnClick({  
2591 - name: tableName,  
2592 - record,  
2593 - config  
2594 - });  
2595 - }  
2596 - },  
2597 - onViewChoose: (tableName, sFieldName, record, index, isColor) => {  
2598 - handleViewChoose(tableName, sFieldName, record, index, isColor);  
2599 - 2578 + const { mesTotalCount, mesPageSize, mesPageNum, isPagination } = baseProps?.parentProps || {};
  2579 + const tableProps = {
  2580 + ...baseProps,
  2581 + tableBtnsConfig: btnsConfig,
  2582 + // tableBtnsWidth: '100px',
  2583 + // tableBtnsConfig: (params) => {
  2584 + // console.log('=====params', params);
  2585 + // return btnsConfig;
  2586 + // },
  2587 + onTableBtnClick,
  2588 + tableProps: {
  2589 + onChange: () => { },
  2590 + rowKey: baseProps?.config?.sId === "17091154460006421964039036672000" || baseProps?.config?.sName?.includes('/indexPage/commonList') ? 'sSlaveId' : 'sId',
  2591 + mesTotalCount,
  2592 + mesPageSize,
  2593 + mesPageNum,
  2594 + isPagination,
  2595 + // AutoTableHeight: 200
  2596 + },
  2597 + onViewClick: (tableName, sFieldName, record, index, config) => {
  2598 + // 异常事件提报-提报信息-事件类型字段点击事件
  2599 + if (tableName === "slave" && sFieldName === "sClassifyName") {
  2600 + props.onTableBtnClick({
  2601 + name: tableName,
  2602 + record,
  2603 + config
  2604 + });
2600 } 2605 }
2601 - }; 2606 + },
  2607 + onViewChoose: (tableName, sFieldName, record, index, isColor) => {
  2608 + handleViewChoose(tableName, sFieldName, record, index, isColor);
  2609 +
  2610 + }
  2611 + };
2602 const handleViewChoose = (tableName, sFieldName, record, index, isColor) => { 2612 const handleViewChoose = (tableName, sFieldName, record, index, isColor) => {
2603 if (isColor) { 2613 if (isColor) {
2604 const { sId } = record; /* 控制表主键 */ 2614 const { sId } = record; /* 控制表主键 */
src/mes/common/commonOperationBarComponent/index.js
@@ -79,7 +79,7 @@ const useCommonOperationBarComponentEvent = props =&gt; { @@ -79,7 +79,7 @@ const useCommonOperationBarComponentEvent = props =&gt; {
79 79
80 // 按钮点击事件 80 // 按钮点击事件
81 const clickRef = useRef(null); 81 const clickRef = useRef(null);
82 - const handleBtnClick = async (config, searchField) => { 82 + const handleBtnClick = async (config, searchField, btnLeftConfig) => {
83 // 限制半秒内只能点一次 83 // 限制半秒内只能点一次
84 if (clickRef.current) return; 84 if (clickRef.current) return;
85 clickRef.current = true; 85 clickRef.current = true;
@@ -306,7 +306,7 @@ const useCommonOperationBarComponentEvent = props =&gt; { @@ -306,7 +306,7 @@ const useCommonOperationBarComponentEvent = props =&gt; {
306 306
307 // 弹窗 307 // 弹窗
308 if (sActiveId) { 308 if (sActiveId) {
309 - handleOpenCommonModal(config); 309 + handleOpenCommonModal(config, btnLeftConfig);
310 } 310 }
311 311
312 if (["BtnLeft.setUpStart"].includes(sControlName)) { 312 if (["BtnLeft.setUpStart"].includes(sControlName)) {
@@ -551,15 +551,14 @@ const useCommonOperationBarComponentEvent = props =&gt; { @@ -551,15 +551,14 @@ const useCommonOperationBarComponentEvent = props =&gt; {
551 }; 551 };
552 552
553 // 弹窗 553 // 弹窗
554 - const handleOpenCommonModal = config => { 554 + const handleOpenCommonModal = async (config, btnLeftConfig) => {
555 const { sActiveId, sActiveName } = config; 555 const { sActiveId, sActiveName } = config;
556 556
557 - const copyTo = handleGetCopyTo(config);  
558 -  
559 - // 获取sqlCondition值 557 + const copyTo = await handleGetCopyTo(config, btnLeftConfig);
  558 + // // 获取sqlCondition值
560 const sParentConditions = props.getSqlCondition(config); 559 const sParentConditions = props.getSqlCondition(config);
561 560
562 - // 弹窗展示 561 + // // 弹窗展示
563 props.onOpenCommonModal({ 562 props.onOpenCommonModal({
564 type: "commonModal", 563 type: "commonModal",
565 sActiveId, 564 sActiveId,
@@ -578,8 +577,67 @@ const useCommonOperationBarComponentEvent = props =&gt; { @@ -578,8 +577,67 @@ const useCommonOperationBarComponentEvent = props =&gt; {
578 }; 577 };
579 578
580 // 获取copyTo数据 579 // 获取copyTo数据
581 - const handleGetCopyTo = config => {  
582 - const copyTo = {}; 580 + const handleGetCopyTo = async (config, btnLeftConfig) => {
  581 + let copyTo = {};
  582 + const { sModelsId, sName, token, app } = props
  583 + const name = config?.sControlName
  584 + const copyToConfig = btnLeftConfig.filter(x => x.sControlName.includes(config?.sControlName))
  585 + const allReturnMap = {};
  586 + let copyToData = props[sName + 'Data'] || []
  587 + if (commonUtils.isNotEmptyObject(config?.sControlName) && config?.sControlName.toLowerCase().includes('btncopyto.tmpinfobysql')) {
  588 + const dataUrl = `${commonConfig.server_host}salesorder/getTmpInfoBySql/?sModelsId=${sModelsId}`;
  589 + const sConfigformId = commonUtils.isEmpty(copyToConfig) ? '' : copyToConfig[0]?.sParentId;
  590 + const sControlName = commonUtils.isNotEmptyObject(config?.sControlName) ? config?.sControlName : 'BtnCopyTo.TmpInfoBySql';
  591 + const selectedRowKeys = props[sName + 'SelectedRowKeys']?.[0] || ''
  592 + const slaveSelectedData = props[sName + 'Data'] || []
  593 + const sRowData = slaveSelectedData.filter(x => x.sId === selectedRowKeys)
  594 + /* 塞原始数据 */
  595 + if (commonUtils.isNotEmptyArr(slaveSelectedData)) {
  596 + copyTo.masterData = slaveSelectedData[0];
  597 + copyTo.slaveData = slaveSelectedData;
  598 + }
  599 + const values = { sConfigformId, sControlName, sRowData };
  600 + const dataReturn = (await commonServices.postValueService(token, values, dataUrl)).data;
  601 + if (dataReturn.code === 1) {
  602 + const returnData = dataReturn.dataset.rows[0];
  603 + if (commonUtils.isNotEmptyObject(returnData)) {
  604 + for (const key of Object.keys(returnData)) {
  605 + const sName = `${key}Data`;
  606 + const sDelName = `${key}DelData`;
  607 + const sAssignField = copyToConfig.find(x => x.sControlName.includes(key))?.sAssignField
  608 + const keyData = returnData[key];
  609 + let newData = []
  610 + if (commonUtils.isNotEmptyArr(keyData)) {
  611 + keyData.forEach(item => {
  612 + let tableRow = {};
  613 + tableRow = { ...tableRow, ...commonFunc.getAssignFieldValue(sAssignField, item) }; // 取赋值字段
  614 + tableRow.sId = commonUtils.createSid();
  615 + tableRow.sParentId = slaveSelectedData[0].sId;
  616 + tableRow.handleType = 'add';
  617 + newData.push(tableRow);
  618 + })
  619 + }
  620 + allReturnMap[sName] = newData;
  621 +
  622 + }
  623 +
  624 + if (commonUtils.isNotEmptyArr(copyTo.masterData) && Array.isArray(copyTo.masterData)) {
  625 + copyTo.masterData = copyTo.masterData[0];
  626 + }
  627 + const configName = copyToConfig[0].sControlName.split(".").pop();
  628 + copyTo = {
  629 + ...copyTo,
  630 + ...allReturnMap
  631 + }
  632 + if (configName && allReturnMap[configName]) {
  633 + copyTo.masterData = allReturnMap[configName]
  634 + }
  635 + }
  636 + } else {
  637 + message.error(dataReturn.msg);
  638 + }
  639 + }
  640 +
583 return copyTo; 641 return copyTo;
584 }; 642 };
585 643
@@ -613,11 +671,11 @@ const useCommonOperationBarComponentEvent = props =&gt; { @@ -613,11 +671,11 @@ const useCommonOperationBarComponentEvent = props =&gt; {
613 }; 671 };
614 672
615 // 获取按钮配置 673 // 获取按钮配置
616 - const handleGetBtnPropps = (config, searchField) => { 674 + const handleGetBtnPropps = (config, searchField, btnLeftConfig) => {
617 const defaultProps = { 675 const defaultProps = {
618 type: "primary", 676 type: "primary",
619 size: "large", 677 size: "large",
620 - onClick: handleBtnClick.bind(this, config, searchField) 678 + onClick: handleBtnClick.bind(this, config, searchField, btnLeftConfig)
621 }; 679 };
622 680
623 const { sDefault, sControlName } = config; 681 const { sDefault, sControlName } = config;
@@ -955,9 +1013,17 @@ const CommonOperationBarComponent = basProps =&gt; { @@ -955,9 +1013,17 @@ const CommonOperationBarComponent = basProps =&gt; {
955 props.setExtraBtns(extraBtns); 1013 props.setExtraBtns(extraBtns);
956 } 1014 }
957 1015
958 - const btnLeftConfig = gdsconfigformslave.filter( 1016 + const originalData = gdsconfigformslave.filter(
959 item => item.bVisible && item.sControlName.includes("BtnLeft.") 1017 item => item.bVisible && item.sControlName.includes("BtnLeft.")
960 ); 1018 );
  1019 + const btnLeftConfig = originalData.filter(item => {
  1020 + const str = item.sControlName;
  1021 + if (!str.includes("BtnCopyTo")) {
  1022 + return true;
  1023 + }
  1024 +
  1025 + return /BtnCopyTo\.[^.]*$/.test(str);
  1026 + });
961 1027
962 // 将扫码上料放到最后 1028 // 将扫码上料放到最后
963 const scanCodeToLoadMaterialsIndex = btnLeftConfig.findIndex( 1029 const scanCodeToLoadMaterialsIndex = btnLeftConfig.findIndex(
@@ -1408,7 +1474,7 @@ const CommonOperationBarComponent = basProps =&gt; { @@ -1408,7 +1474,7 @@ const CommonOperationBarComponent = basProps =&gt; {
1408 </div> 1474 </div>
1409 } 1475 }
1410 return ( 1476 return (
1411 - <Button {...props.onGetBtnPropps(item, searchField)}> 1477 + <Button {...props.onGetBtnPropps(item, searchField, originalData)}>
1412 {item.showName} 1478 {item.showName}
1413 </Button> 1479 </Button>
1414 ); 1480 );
@@ -1519,7 +1585,7 @@ const BarcodeComponent = props =&gt; { @@ -1519,7 +1585,7 @@ const BarcodeComponent = props =&gt; {
1519 props.onSaveState({ 1585 props.onSaveState({
1520 refreshMachineDataFlag: new Date().getTime(), 1586 refreshMachineDataFlag: new Date().getTime(),
1521 productionTableList: [sName] 1587 productionTableList: [sName]
1522 - }, ()=>{ 1588 + }, () => {
1523 props.onRefresh && props.onRefresh(); 1589 props.onRefresh && props.onRefresh();
1524 }); 1590 });
1525 } 1591 }