From c80cb6fbac24b1d9c437ed7005256e1caf8e9484 Mon Sep 17 00:00:00 2001
From: pengm <674192343@qq.com>
Date: Fri, 14 Nov 2025 15:35:27 +0800
Subject: [PATCH] 1.AJT-MES添加叫料按钮调用API
---
src/components/Common/CommonHooks/useCommonBase.js | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
src/components/Common/CommonTable/index.js | 45 +++++++++++++++++++++++++++++++++++++++++++--
src/components/Common/commonBusiness.js | 1 +
src/mes/common/commonModelComponent/index.js | 1 +
src/utils/config.js | 4 ++--
5 files changed, 139 insertions(+), 4 deletions(-)
diff --git a/src/components/Common/CommonHooks/useCommonBase.js b/src/components/Common/CommonHooks/useCommonBase.js
index 593b84c..105f470 100644
--- a/src/components/Common/CommonHooks/useCommonBase.js
+++ b/src/components/Common/CommonHooks/useCommonBase.js
@@ -1935,6 +1935,97 @@ const useCommonBase = props => {
message.error(msg, 5);
}
};
+ const handleSendApiRow = async (name, isWait, tableSelectedRowKeys, record) => {
+ const { [`${name}Config`]: tableConfig ,[`${name}Data`]: tableData } = state;
+ const btnConfig = tableConfig?.gdsconfigformslave.find(item => item.sControlName?.includes('BtnTable.SendApi'));
+ const interfaceArr = btnConfig.interface;
+ if(commonUtils.isNotEmptyArr(interfaceArr)) {
+ const sendInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "0" ); /* 独立调用 */
+ if(commonUtils.isNotEmptyArr(sendInterfaceArr)) { /* 之前调用 */
+ const asyncFunc = async () => {
+ for (let i = 0; i < sendInterfaceArr.length; i ++) {
+ await handleInterfaceCall(sendInterfaceArr[i], false, btnConfig.sControlName, record.sId);
+ }
+ }
+ await asyncFunc();
+ }
+
+ }
+ }
+
+
+ /* 调用后台配置的接口 */
+ const handleInterfaceCall = async (obj, showTip, key, idArr) => {
+ let bResult = false;
+ const { app, sModelsId} = props;
+ const sInterfaceName = obj.sInterfaceName;
+ const value = { sId: idArr, userInfo: app.userinfo };
+ const url = `${commonConfig.interface_host}interfaceDefine/callthirdparty/${sInterfaceName}?sModelsId=${sModelsId}`;
+ const returnData = (await commonServices.postValueService(app.token, value, url)).data;
+ if (showTip) {
+ if ((!returnData || returnData.code != 1)) {
+ if (commonUtils.isNotEmptyObject(returnData) && returnData.code === -8) {
+ Modal.info({
+ title: 'FriendlyReminder:',
+ content: (
+
+ {handleGetMsg(returnData.msg)}
+
+ ),
+ okText: 'Sure',
+ onOk() {},
+ });
+ }
+ // message.error('同步INFOR失败!');
+ return;
+ } else {
+ message.success(returnData.msg);
+ }
+ }
+ let inforEvent = ['itemiss', 'jobmatliss', 'jobmatliss-bz', 'jobmatliss-tl', 'jobmatliss-cx'];
+ if (obj && inforEvent.indexOf(obj.sInterfaceName) !== -1) {
+ if ((!returnData || returnData.code != 1)) {
+ if (returnData) {
+ if (returnData.code === -8) {
+ Modal.info({
+ title: 'FriendlyReminder:',
+ content: (
+
+ {handleGetMsg(returnData.msg)}
+
+ ),
+ okText: 'Sure',
+ onOk() {},
+ });
+ } else {
+ message.error(returnData.erroMsg);
+ }
+ } else {
+ message.error('审核失败!');
+ }
+ return false;
+ }
+ }
+
+ if (returnData.code === 1) {
+ bResult = true;
+ }else if (returnData.code === -8) {
+ Modal.info({
+ title: 'FriendlyReminder:',
+ content: (
+
+ {handleGetMsg(returnData.msg)}
+
+ ),
+ okText: 'Sure',
+ onOk() {},
+ });
+ } else {
+ bResult = false;
+ getServiceError(returnData);
+ }
+ return bResult;
+ }
// 调用通用过程
const handleProcedureCall = async (params, iFlag) => {
@@ -2679,6 +2770,7 @@ const useCommonBase = props => {
onMesTableLineAdd: handleMesTableLineAdd, // 表格行新增
onMesTableLineDel: handleMesTableLineDel, // 表格行删除
onMesTableLineCopy: handleMesTableLineCopy, // 表格行复制
+ onSendApiRow: handleSendApiRow, /* 操作栏按钮调用Api接口 */
onCopyTo: handleCopyTo, // 复制到
onMergeTableConfig: handleMergeTableConfig, // 合并config配置和所有sButtonEnabled配置
awaitPromiseReturn: awaitPromiseReturn
diff --git a/src/components/Common/CommonTable/index.js b/src/components/Common/CommonTable/index.js
index f7b6c16..056a569 100644
--- a/src/components/Common/CommonTable/index.js
+++ b/src/components/Common/CommonTable/index.js
@@ -4670,9 +4670,9 @@ class CommonTableRc extends React.Component {
) {
CheckBoxWidth = 37;
}
- const bHasMesBtn =
- props.mesAdd || props.mesCopy || props.mesDel || props.mesSave;
+ const bHasMesBtn = props.mesAdd || props.mesCopy || props.mesDel || props.mesSave;
const bEmptyTableBtnsConfig = commonUtils.isEmptyArr(props.tableBtnsConfig);
+ const btnSendApiConfig = config?.gdsconfigformslave?.find(item => item.sControlName?.includes('SendApi'));
if (!bEmptyTableBtnsConfig || bHasMesBtn) {
let tableBtnsWidth = "150px";
if (props.tableBtnsWidth) {
@@ -4720,6 +4720,9 @@ class CommonTableRc extends React.Component {
}
tableBtnsWidth += "px";
}
+ if(commonUtils.isNotEmptyObject(btnSendApiConfig)) {
+ tableBtnsWidth = '280px';
+ }
const setOperation = commonFunc.showMessage(props.app.commonConst, 'operation') || '操作';
const setCopy = commonFunc.showMessage(props.app.commonConst, 'setCopy') || '复制';
const copyDivingRecorder = commonFunc.showMessage(props.app.commonConst, 'copyDivingRecorder') || '复制';
@@ -4729,6 +4732,15 @@ class CommonTableRc extends React.Component {
const BtnSave = commonFunc.showLocalMessage(props, 'BtnSave', '保存');
const copyFirst = commonFunc.showLocalMessage(props, 'copyFirst', '请先选择要复制的数据');
const splitFirst = commonFunc.showLocalMessage(props, 'splitFirst', '请先保存新拆分数据 ');
+ const shouldDisableButton = (config, record) =>{
+ const { showName, btnBgColor, sDefault: str } = config;
+ const disabled = props.getBtnDisabled({
+ str,
+ defaultValue: false,
+ record
+ });
+ return disabled;
+ }
const operationCol = {
dataIndex: "operation",
@@ -4819,6 +4831,27 @@ class CommonTableRc extends React.Component {
) : (
""
)}
+ {btnSendApiConfig ? (
+
+ ) : (
+ ""
+ )}
{props.mesCopy
? props.mesCopy({
tableName: props.name,
@@ -7042,6 +7075,9 @@ class CommonTableRc extends React.Component {
downloadTbRow = (index, record) => {
this.handleDownloadRow(index, record);
};
+ sendApiTbRow = (index, record) => {
+ this.handleSendApiRow(index, record);
+ };
popupModalTbRow = (index, record) => {
this.handlePopupRow(index, record);
};
@@ -8196,6 +8232,11 @@ class CommonTableRc extends React.Component {
tableSelectedRowKeys.push(record.sId);
this.props.onDownloadRow(this.props.name, false, tableSelectedRowKeys);
};
+ handleSendApiRow = (index, record) => {
+ const tableSelectedRowKeys = [];
+ tableSelectedRowKeys.push(record.sId);
+ this.props.onSendApiRow(this.props.name, false, tableSelectedRowKeys, record);
+ };
/** 通用弹窗新增行 */
handlePopupRow = () => {
const { name, config } = this.props;
diff --git a/src/components/Common/commonBusiness.js b/src/components/Common/commonBusiness.js
index 68ea31b..6903642 100644
--- a/src/components/Common/commonBusiness.js
+++ b/src/components/Common/commonBusiness.js
@@ -244,6 +244,7 @@ export function getTableTypes(name, props) {
onCopyAllRow: props.onDataRowCopyAll,
onDelRow: props.onDataRowDel,
onDownloadRow: props.onDataRowDownload,
+ onSendApiRow: props.onSendApiRow,
onShowParamRow: props.onDataRowShowParam,
onSelectRowChange: props.onTableSelectRowChange,
onDoubleClick: props.onDoubleClick,
diff --git a/src/mes/common/commonModelComponent/index.js b/src/mes/common/commonModelComponent/index.js
index fa67e21..af6e487 100644
--- a/src/mes/common/commonModelComponent/index.js
+++ b/src/mes/common/commonModelComponent/index.js
@@ -1067,6 +1067,7 @@ const useCommonModelEvent = props => {
onGetColumnData: handleGetColumnData,
onRefresh: handleRefresh, // 刷新页面
onTableBtnClick: handleTableBtnClick, // 表格按钮事件
+ onSendApiRow: props.onSendApiRow, // 表格按钮事件
handleUpdateProductionplan,
handleStartWork,
onViewChoose: handleViewChoose
diff --git a/src/utils/config.js b/src/utils/config.js
index 0d06520..0c622ea 100644
--- a/src/utils/config.js
+++ b/src/utils/config.js
@@ -7,7 +7,7 @@ export const webSite = {
fileAddress: isDev ? '//127.0.0.1:8080/xlyEntry/' : '//' + '172.19.18.21:9181' + '/xlyEntry/', // 接口地址
faceAddress: isDev ? '//172.19.18.26:8080/xlyFace' : '//' + location.host + '/xlyFace',
ipAddress: localStorage.ipAddress ? localStorage.ipAddress : isDev ? '//172.19.18.21:9543/xlyEntry/' : '//' + location.host + '/xlyEntry/',
- interfaceAddress: isDev ? '//127.0.0.1:8088/xlyApi/' : '//' + location.host + '/xlyApi/', // 接口地址1
+ interfaceAddress: isDev ? '//172.19.18.21:9181/xlyApi/' : '//' + location.host + '/xlyApi/', // 接口地址1
// ipAddress: isDev ? '//ebc.jinjia.com:8091/xlyEntry/' : '//' + location.host + '/xlyEntry/',
// interfaceAddress: isDev ? '//ebc.jinjia.com:8091/xlyApi/' : '//' + location.host + '/xlyApi/', // 接口地址1111
// ipAddress: isDev ? '//192.168.11.26:8080/xlyEntry/' : '//' + location.host + '/xlyEntry/',
@@ -30,7 +30,7 @@ module.exports = {
face_host: bHttps ? `https:${webSite.faceAddress}` : `http:${webSite.faceAddress}`, /* 外网连内网服务器地址 */
feedback_host: bHttps? 'https://project.xlyprint.cn/xlyEntry/' : 'http://s10.xlyprint.cn:8000/xlyEntry/', // 问题反馈接口前缀
feedback_ws_host: bHttps? 'wss://project.xlyprint.cn/xlyEntry/' : 'ws://s10.xlyprint.cn:8000/xlyEntry/', // 问题反馈接口前缀
- interface_host: `http${bHttps ? 's' : ''}:${webSite.interfaceAddress}`, /* 接口地址 */
+ interface_host: bHttps ? `https:${webSite.interfaceAddress}` : `http:${webSite.interfaceAddress}`, /* 接口地址*/
btnData: [{
sName: 'BtnRefresh', sControlName: 'BtnRefresh', showName: '刷新', bVisible: true, sActiveId: '', iconName: 'reload', disabled: false,
}, {
--
libgit2 0.22.2