From 77adc61b7aee1c9c115177c99b848c1a1c5d3069 Mon Sep 17 00:00:00 2001 From: chenxt <10125295+chen-xintao97@user.noreply.gitee.com> Date: Tue, 23 Dec 2025 09:48:28 +0800 Subject: [PATCH] 产量上报主表id查询 --- src/mes/common/commonModelComponent/index.js | 34 ++++++++++------------------------ src/mes/common/commonOperationBarComponent/MesToolbar.js | 26 +++++++++++++++++--------- src/mes/common/commonOperationBarComponent/index.js | 162 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------ src/mes/indexMes/index.js | 2 +- 4 files changed, 178 insertions(+), 46 deletions(-) diff --git a/src/mes/common/commonModelComponent/index.js b/src/mes/common/commonModelComponent/index.js index 1505116..0e3c5d4 100644 --- a/src/mes/common/commonModelComponent/index.js +++ b/src/mes/common/commonModelComponent/index.js @@ -33,7 +33,6 @@ const useCommonModelEvent = props => { noGetData, // 不要加载数据,根据另一张表选中行加载时用 currentId, } = props; - let formData = props.parentProps?.btnConfig?.sActiveId === "12710101117087374661080" ? formDataOld.filter(item => item.sGrd === "Knifetable") @@ -491,9 +490,9 @@ const useCommonModelEvent = props => { // 获取数据集 const handleGetData = async (tableList = [], isWait, bInit) => { - const { btnConfig = {}, copyToConfig = [], record = {} } = props?.parentProps || {} let addState = {}; - let copy = {} + const currentIds = currentId ? currentId : props?.parentProps?.record?.sId + console.log("🚀 ~ handleGetData ~ currentIds:", currentIds, props?.parentProps?.record ) for (let i = 0; i < tableList.length; i++) { const tableName = tableList[i]; const config = formData.find(item => item.sGrd === tableName); @@ -607,25 +606,27 @@ const useCommonModelEvent = props => { } const masterState = {}; - if (currentId && tableName === 'master') { + if (currentIds && tableName === 'master') { masterState.sId = currentId; + } + if (currentIds && tableName !== 'master') { + conditonValues.sParentId = currentIds; } - if (currentId && tableName !== 'master') { - conditonValues.sParentId = currentId; - } + const result = (await props.onGetDataSet({ name: tableName, configData: config, condition: { ...masterState, - sId: props.parentProps?.record?.sId, + sId: currentIds, sSqlCondition: { ...conditonValues, ...sFilterConditions, }, bFilter }, sModelTypes: props.parentProps, isWait: true })) || {}; + props.setTempRef(result); if (tableName?.includes("master")) { @@ -673,22 +674,7 @@ const useCommonModelEvent = props => { } } } - // if (copyToConfig && copyToConfig.length) { - // copyToConfig.forEach(item => { - // const name = item.sControlName.split('.').pop() - // if (name === tableName) { - // const data = commonFunc.getAssignFieldValue(item.sAssignField, record) - // copy[`${tableName}Data`] = { - // ...commonFunc.getDefaultData(name + 'Config'), - // handleType: "add", - // sId: commonUtils.createSid(), - // sFormId: sModelsId, - // ...data - // } - // } - // }) - // } - addState = { ...addState, ...result, ...copy }; + addState = { ...addState, ...result, }; if (tableName === "tableS0" && props.sSReserve1) { addState.sSReserve1 = undefined; diff --git a/src/mes/common/commonOperationBarComponent/MesToolbar.js b/src/mes/common/commonOperationBarComponent/MesToolbar.js index 40c259d..428e941 100644 --- a/src/mes/common/commonOperationBarComponent/MesToolbar.js +++ b/src/mes/common/commonOperationBarComponent/MesToolbar.js @@ -73,7 +73,9 @@ const ToolbarFun = async (props) => { } } } else { - props.onBtnExamine(); + console.log(props, 'masterData'); + + // props.onBtnExamine(); } } @@ -181,14 +183,20 @@ const handleScanFace = (props) => { const copyConfig = config?.gdsconfigformslave?.find(item => item.sControlName.toLowerCase().includes('btnscanface')) proData.forEach(item => { const data = commonFunc.getAssignFieldValue(copyConfig?.sAssignField, item) - tableData.push({ - ...item, - ...data, - sId: commonUtils.createSid(), - handleType: "add", - sParentId: props.masterData.sId, - slaveId: props?.slaveData ? props?.slaveData[0].sId : '' - }) + const index = tableData.findIndex(x => x.sEmployeeNo === item.sEmployeeNo) + if (index !== -1) { + message.error('人员重复,请重新添加', 5) + } else { + tableData.push({ + ...item, + ...data, + sId: commonUtils.createSid(), + handleType: "add", + sParentId: props.masterData.sId, + slaveId: props?.slaveData ? props?.slaveData[0].sId : '' + }) + } + }); props.onSaveState({ diff --git a/src/mes/common/commonOperationBarComponent/index.js b/src/mes/common/commonOperationBarComponent/index.js index ac4e3db..fa5d7a3 100644 --- a/src/mes/common/commonOperationBarComponent/index.js +++ b/src/mes/common/commonOperationBarComponent/index.js @@ -1,5 +1,6 @@ import React, { useEffect, useRef, useState } from "react"; import moment from "moment"; +import { message } from 'antd'; import ShowType from "@/components/Common/CommonComponent"; import { operationFetch } from "../../productionExec/productionExecMain/operationFetch"; import * as commonUtils from "@/utils/utils"; @@ -9,7 +10,7 @@ import StaticEditTable from "@/components/Common/CommonTable"; import costomPageFun from "@/mes/costomPageFun"; import * as commonConfig from "@/utils/config"; import MesToolbar from "./MesToolbar"; - +import * as commonServices from "@/services/services"; import styles from "./index.less"; import { Button, Space, Input, Modal, Dropdown, Popconfirm } from "antd"; import { ScanOutlined } from "@ant-design/icons"; @@ -85,7 +86,6 @@ const useCommonOperationBarComponentEvent = props => { setTimeout(() => { clickRef.current = false; }, 500); - await props.awaitPromiseReturn(); const { sName } = props; const { sActiveId, sButtonParam, sInstruct, sControlName } = config; @@ -96,7 +96,6 @@ const useCommonOperationBarComponentEvent = props => { if (await MesToolbar({ ...props, btnConfig: config })) { return; } - // 自定义按钮事件 if ( costomPageFun({ @@ -271,6 +270,8 @@ const useCommonOperationBarComponentEvent = props => { }); } + + // 处理特殊按钮 const btnType = sControlName.split(".")[0].toLowerCase(); const btnName = sControlName.split(".")[1].toLowerCase(); @@ -331,7 +332,148 @@ const useCommonOperationBarComponentEvent = props => { handleProcedureCall(config); } }; + /* 调用后台配置的接口 */ + const handleInterfaceCall = async (obj, showTip, key, ids, slaveSelectedRowKeysOld) => { + let bResult = false; + const { app, sModelsId, masterData, slaveData, masterConfig, slaveFilterCondition } = props; + const slaveSelectedRowKeys = slaveSelectedRowKeysOld || props.slaveSelectedRowKeys; + const sInterfaceName = obj.sInterfaceName; + /* 如果key是BtnSendList 传从表的主键集合 */ + let idArr = ""; + /* 如果有对应字段 则取对应字段 ,否则 取默认值 */ + const btnConfig = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => item.sControlName === key)) + ? masterConfig.gdsconfigformslave.filter(item => item.sControlName === key)[0] + : {}; + + let sActiveKey = ""; + if (commonUtils.isNotEmptyObject(btnConfig)) { + sActiveKey = btnConfig.sActiveKey; + } + if (sActiveKey) { + if (sActiveKey.includes("master.sId")) { + idArr = masterData.sId; + } + } else if (key && (key.includes("BtnSendList") || key.includes("BtnBatchExamine"))) { + if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) { + slaveSelectedRowKeys.forEach(item => { + if (commonUtils.isNotEmptyObject(item)) { + idArr += `${item},`; + } + }); + idArr = commonUtils.isNotEmptyObject(idArr) ? idArr.substr(0, idArr.length - 1) : ""; + } + } else if (location.pathname.includes("commonList")) { + const { slaveSelectedRowKeys, slaveData } = props; + let { slaveSelectedData } = props; + if (commonUtils.isEmptyArr(slaveSelectedData) && commonUtils.isNotEmptyArr(slaveData)) { + slaveSelectedData = slaveData.filter(item => slaveSelectedRowKeys.includes(item.sId) || slaveSelectedRowKeys.includes(item.sSlaveId)); + } + const slaveSelectedDataNew = deteleObject(slaveSelectedData); // 删除sid重复的数据 + if (commonUtils.isNotEmptyArr(slaveSelectedDataNew)) { + slaveSelectedDataNew.forEach(item => { + if (commonUtils.isNotEmptyObject(item)) { + idArr += `${item.sId},`; + } + }); + idArr = commonUtils.isNotEmptyObject(idArr) ? idArr.substr(0, idArr.length - 1) : ""; + } + if (commonUtils.isNotEmptyObject(ids)) { + /* 如果是勾选多行 则sId为循环的每一条 */ + idArr = ids; + } + } else { + idArr = masterData.sId; + } + const value = { + sId: commonUtils.isNotEmptyObject(idArr) ? idArr : commonUtils.isNotEmptyObject(ids) ? ids : masterData.sId, + sSlaveId: slaveSelectedRowKeys?.toString(), + masterData, + userInfo: app.userinfo, + }; + if (location.pathname.includes("commonList") && commonUtils.isNotEmptyArr(slaveFilterCondition)) { + value.bFilter = JSON.stringify(slaveFilterCondition); + } + const url = `${commonConfig.interface_host}interfaceDefine/callthirdparty/${sInterfaceName}?sModelsId=${sModelsId}`; + const returnData = (await commonServices.postValueService(app.token, value, url, app)).data; + if (showTip) { + if (!returnData || returnData.code < 0) { + if (commonUtils.isNotEmptyObject(returnData) && returnData.code === -8) { + Modal.info({ + title: "温馨提示:", + content:
{handleGetMsg(returnData.msg)}
, + okText: "确认", + onOk() { }, + }); + } else { + Modal.info({ + title: "温馨提示:", + content:
{handleGetMsg(returnData.msg)}
, + okText: "确认", + onOk() { }, + }); + return; + } + return; + } else { + // message.success('同步INFOR成功!'); + } + } + if (!returnData) { + message.error("接口调用失败!"); + return false; + } + if (returnData.code === 1) { + bResult = true; + // message.success(returnData.msg); + } else if (returnData.code === 2) { + bResult = true; + } else if (returnData.code === -8) { + Modal.info({ + title: "温馨提示:", + content:
{handleGetMsg(returnData.msg)}
, + okText: "确认", + onOk() { }, + }); + bResult = false; + } else { + bResult = false; + props.getServiceError(returnData); + } + /* 若配置的是按钮后调用第三方, 则调用成功后 需要重新回刷一次数据 */ + if (commonUtils.isNotEmptyObject(obj) && obj.sInterfaceCallMethod === "2") { + if (bResult) { + props.onButtonClick("BtnRefresh"); + } + } + return bResult; + }; + const deteleObject = (obj = []) => { + // eslint-disable-next-line camelcase + const replace_data = obj; + const result = []; // 去重后的数组对象集合 + const hash = {}; + // eslint-disable-next-line no-plusplus + for (let i = 0; i < replace_data.length; i++) { + const elem = replace_data[i].sId; + if (!hash[elem]) { + result.push(replace_data[i]); + hash[elem] = true; + } + } + return result; + }; + /* 解析消息 */ + const handleGetMsg = str => { + const msgArr = commonUtils.isNotEmptyObject(str) ? str.split("xpm") : ""; + const divStr = []; + if (commonUtils.isNotEmptyArr(msgArr)) { + for (let i = 0; i < msgArr.length; i++) { + divStr.push(

{msgArr[i]}

); + } + } + return divStr; + }; // const handleSearchValueChange = (name, sFieldName, changeValue) => { setSearchValue(changeValue[sFieldName]); @@ -423,7 +565,7 @@ const useCommonOperationBarComponentEvent = props => { sActiveId, title: sActiveName, copyTo, - sModelType:'/indexPage/commonBill', + sModelType: '/indexPage/commonBill', sParentConditions, parentProps: props, onOk: data => { @@ -781,7 +923,7 @@ const CommonOperationBarComponent = basProps => { const btnLeftConfig = gdsconfigformslave.filter( item => item.bVisible && item.sControlName.includes("BtnLeft.") ); - console.log(btnLeftConfig,gdsconfigformslave, 'btnLeftConfig'); + console.log(btnLeftConfig, gdsconfigformslave, 'btnLeftConfig'); // 将扫码上料放到最后 const scanCodeToLoadMaterialsIndex = btnLeftConfig.findIndex( @@ -815,13 +957,9 @@ const CommonOperationBarComponent = basProps => { btnLeftConfig[0].btnBgColor = "red"; } - const bManual = props.bManual; - const btnRightConfig = gdsconfigformslave.filter(item => { - // 排除条件:sControlName是BtnRight.BtnEnventInsertWork且bManual=1的项 - const isExcludeItem = item.sControlName === 'BtnRight.BtnEnventInsertWork' && !bManual; - // 保留条件:不是排除项,且满足原有过滤规则 - return !isExcludeItem && item.bVisible && item.sControlName.includes('BtnRight.'); - }); + const btnRightConfig = gdsconfigformslave.filter( + item => item.bVisible && item.sControlName.includes("BtnRight.") + ); if (!searchField && !btnRightConfig.length) return ""; diff --git a/src/mes/indexMes/index.js b/src/mes/indexMes/index.js index e61c190..2fd3fae 100644 --- a/src/mes/indexMes/index.js +++ b/src/mes/indexMes/index.js @@ -172,7 +172,7 @@ const useIndexMesEvent = props => { sParentConditions, copyTo, parentProps, - modalCallback + modalCallback, }) => { if (!type) return; -- libgit2 0.22.2