Commit c80cb6fbac24b1d9c437ed7005256e1caf8e9484

Authored by Min
1 parent 34ab149d

1.AJT-MES添加叫料按钮调用API

src/components/Common/CommonHooks/useCommonBase.js
... ... @@ -1935,6 +1935,97 @@ const useCommonBase = props => {
1935 1935 message.error(msg, 5);
1936 1936 }
1937 1937 };
  1938 + const handleSendApiRow = async (name, isWait, tableSelectedRowKeys, record) => {
  1939 + const { [`${name}Config`]: tableConfig ,[`${name}Data`]: tableData } = state;
  1940 + const btnConfig = tableConfig?.gdsconfigformslave.find(item => item.sControlName?.includes('BtnTable.SendApi'));
  1941 + const interfaceArr = btnConfig.interface;
  1942 + if(commonUtils.isNotEmptyArr(interfaceArr)) {
  1943 + const sendInterfaceArr = interfaceArr.filter(item => item.sInterfaceCallMethod === "0" ); /* 独立调用 */
  1944 + if(commonUtils.isNotEmptyArr(sendInterfaceArr)) { /* 之前调用 */
  1945 + const asyncFunc = async () => {
  1946 + for (let i = 0; i < sendInterfaceArr.length; i ++) {
  1947 + await handleInterfaceCall(sendInterfaceArr[i], false, btnConfig.sControlName, record.sId);
  1948 + }
  1949 + }
  1950 + await asyncFunc();
  1951 + }
  1952 +
  1953 + }
  1954 + }
  1955 +
  1956 +
  1957 + /* 调用后台配置的接口 */
  1958 + const handleInterfaceCall = async (obj, showTip, key, idArr) => {
  1959 + let bResult = false;
  1960 + const { app, sModelsId} = props;
  1961 + const sInterfaceName = obj.sInterfaceName;
  1962 + const value = { sId: idArr, userInfo: app.userinfo };
  1963 + const url = `${commonConfig.interface_host}interfaceDefine/callthirdparty/${sInterfaceName}?sModelsId=${sModelsId}`;
  1964 + const returnData = (await commonServices.postValueService(app.token, value, url)).data;
  1965 + if (showTip) {
  1966 + if ((!returnData || returnData.code != 1)) {
  1967 + if (commonUtils.isNotEmptyObject(returnData) && returnData.code === -8) {
  1968 + Modal.info({
  1969 + title: 'FriendlyReminder:',
  1970 + content: (
  1971 + <div>
  1972 + {handleGetMsg(returnData.msg)}
  1973 + </div>
  1974 + ),
  1975 + okText: 'Sure',
  1976 + onOk() {},
  1977 + });
  1978 + }
  1979 + // message.error('同步INFOR失败!');
  1980 + return;
  1981 + } else {
  1982 + message.success(returnData.msg);
  1983 + }
  1984 + }
  1985 + let inforEvent = ['itemiss', 'jobmatliss', 'jobmatliss-bz', 'jobmatliss-tl', 'jobmatliss-cx'];
  1986 + if (obj && inforEvent.indexOf(obj.sInterfaceName) !== -1) {
  1987 + if ((!returnData || returnData.code != 1)) {
  1988 + if (returnData) {
  1989 + if (returnData.code === -8) {
  1990 + Modal.info({
  1991 + title: 'FriendlyReminder:',
  1992 + content: (
  1993 + <div>
  1994 + {handleGetMsg(returnData.msg)}
  1995 + </div>
  1996 + ),
  1997 + okText: 'Sure',
  1998 + onOk() {},
  1999 + });
  2000 + } else {
  2001 + message.error(returnData.erroMsg);
  2002 + }
  2003 + } else {
  2004 + message.error('审核失败!');
  2005 + }
  2006 + return false;
  2007 + }
  2008 + }
  2009 +
  2010 + if (returnData.code === 1) {
  2011 + bResult = true;
  2012 + }else if (returnData.code === -8) {
  2013 + Modal.info({
  2014 + title: 'FriendlyReminder:',
  2015 + content: (
  2016 + <div>
  2017 + {handleGetMsg(returnData.msg)}
  2018 + </div>
  2019 + ),
  2020 + okText: 'Sure',
  2021 + onOk() {},
  2022 + });
  2023 + } else {
  2024 + bResult = false;
  2025 + getServiceError(returnData);
  2026 + }
  2027 + return bResult;
  2028 + }
1938 2029  
1939 2030 // 调用通用过程
1940 2031 const handleProcedureCall = async (params, iFlag) => {
... ... @@ -2679,6 +2770,7 @@ const useCommonBase = props =&gt; {
2679 2770 onMesTableLineAdd: handleMesTableLineAdd, // 表格行新增
2680 2771 onMesTableLineDel: handleMesTableLineDel, // 表格行删除
2681 2772 onMesTableLineCopy: handleMesTableLineCopy, // 表格行复制
  2773 + onSendApiRow: handleSendApiRow, /* 操作栏按钮调用Api接口 */
2682 2774 onCopyTo: handleCopyTo, // 复制到
2683 2775 onMergeTableConfig: handleMergeTableConfig, // 合并config配置和所有sButtonEnabled配置
2684 2776 awaitPromiseReturn: awaitPromiseReturn
... ...
src/components/Common/CommonTable/index.js
... ... @@ -4670,9 +4670,9 @@ class CommonTableRc extends React.Component {
4670 4670 ) {
4671 4671 CheckBoxWidth = 37;
4672 4672 }
4673   - const bHasMesBtn =
4674   - props.mesAdd || props.mesCopy || props.mesDel || props.mesSave;
  4673 + const bHasMesBtn = props.mesAdd || props.mesCopy || props.mesDel || props.mesSave;
4675 4674 const bEmptyTableBtnsConfig = commonUtils.isEmptyArr(props.tableBtnsConfig);
  4675 + const btnSendApiConfig = config?.gdsconfigformslave?.find(item => item.sControlName?.includes('SendApi'));
4676 4676 if (!bEmptyTableBtnsConfig || bHasMesBtn) {
4677 4677 let tableBtnsWidth = "150px";
4678 4678 if (props.tableBtnsWidth) {
... ... @@ -4720,6 +4720,9 @@ class CommonTableRc extends React.Component {
4720 4720 }
4721 4721 tableBtnsWidth += "px";
4722 4722 }
  4723 + if(commonUtils.isNotEmptyObject(btnSendApiConfig)) {
  4724 + tableBtnsWidth = '280px';
  4725 + }
4723 4726 const setOperation = commonFunc.showMessage(props.app.commonConst, 'operation') || '操作';
4724 4727 const setCopy = commonFunc.showMessage(props.app.commonConst, 'setCopy') || '复制';
4725 4728 const copyDivingRecorder = commonFunc.showMessage(props.app.commonConst, 'copyDivingRecorder') || '复制';
... ... @@ -4729,6 +4732,15 @@ class CommonTableRc extends React.Component {
4729 4732 const BtnSave = commonFunc.showLocalMessage(props, 'BtnSave', '保存');
4730 4733 const copyFirst = commonFunc.showLocalMessage(props, 'copyFirst', '请先选择要复制的数据');
4731 4734 const splitFirst = commonFunc.showLocalMessage(props, 'splitFirst', '请先保存新拆分数据 ');
  4735 + const shouldDisableButton = (config, record) =>{
  4736 + const { showName, btnBgColor, sDefault: str } = config;
  4737 + const disabled = props.getBtnDisabled({
  4738 + str,
  4739 + defaultValue: false,
  4740 + record
  4741 + });
  4742 + return disabled;
  4743 + }
4732 4744  
4733 4745 const operationCol = {
4734 4746 dataIndex: "operation",
... ... @@ -4819,6 +4831,27 @@ class CommonTableRc extends React.Component {
4819 4831 ) : (
4820 4832 ""
4821 4833 )}
  4834 + {btnSendApiConfig ? (
  4835 + <Button
  4836 + disabled={shouldDisableButton(btnSendApiConfig, record)}
  4837 + size="large"
  4838 + style={{
  4839 + width: 90,
  4840 + height: 36,
  4841 + borderRadius: 5,
  4842 + backgroundColor: shouldDisableButton(btnSendApiConfig, record) ? "#AAA" : btnSendApiConfig.btnBgColor || '#1890FF',
  4843 + color: "#FFF"
  4844 + }}
  4845 + // loading={bLoading}
  4846 + onClick={e => {
  4847 + this.sendApiTbRow(record, record);
  4848 + }}
  4849 + >
  4850 + {btnSendApiConfig.showName}
  4851 + </Button>
  4852 + ) : (
  4853 + ""
  4854 + )}
4822 4855 {props.mesCopy
4823 4856 ? props.mesCopy({
4824 4857 tableName: props.name,
... ... @@ -7042,6 +7075,9 @@ class CommonTableRc extends React.Component {
7042 7075 downloadTbRow = (index, record) => {
7043 7076 this.handleDownloadRow(index, record);
7044 7077 };
  7078 + sendApiTbRow = (index, record) => {
  7079 + this.handleSendApiRow(index, record);
  7080 + };
7045 7081 popupModalTbRow = (index, record) => {
7046 7082 this.handlePopupRow(index, record);
7047 7083 };
... ... @@ -8196,6 +8232,11 @@ class CommonTableRc extends React.Component {
8196 8232 tableSelectedRowKeys.push(record.sId);
8197 8233 this.props.onDownloadRow(this.props.name, false, tableSelectedRowKeys);
8198 8234 };
  8235 + handleSendApiRow = (index, record) => {
  8236 + const tableSelectedRowKeys = [];
  8237 + tableSelectedRowKeys.push(record.sId);
  8238 + this.props.onSendApiRow(this.props.name, false, tableSelectedRowKeys, record);
  8239 + };
8199 8240 /** 通用弹窗新增行 */
8200 8241 handlePopupRow = () => {
8201 8242 const { name, config } = this.props;
... ...
src/components/Common/commonBusiness.js
... ... @@ -244,6 +244,7 @@ export function getTableTypes(name, props) {
244 244 onCopyAllRow: props.onDataRowCopyAll,
245 245 onDelRow: props.onDataRowDel,
246 246 onDownloadRow: props.onDataRowDownload,
  247 + onSendApiRow: props.onSendApiRow,
247 248 onShowParamRow: props.onDataRowShowParam,
248 249 onSelectRowChange: props.onTableSelectRowChange,
249 250 onDoubleClick: props.onDoubleClick,
... ...
src/mes/common/commonModelComponent/index.js
... ... @@ -1067,6 +1067,7 @@ const useCommonModelEvent = props =&gt; {
1067 1067 onGetColumnData: handleGetColumnData,
1068 1068 onRefresh: handleRefresh, // 刷新页面
1069 1069 onTableBtnClick: handleTableBtnClick, // 表格按钮事件
  1070 + onSendApiRow: props.onSendApiRow, // 表格按钮事件
1070 1071 handleUpdateProductionplan,
1071 1072 handleStartWork,
1072 1073 onViewChoose: handleViewChoose
... ...
src/utils/config.js
... ... @@ -7,7 +7,7 @@ export const webSite = {
7 7 fileAddress: isDev ? '//127.0.0.1:8080/xlyEntry/' : '//' + '172.19.18.21:9181' + '/xlyEntry/', // 接口地址
8 8 faceAddress: isDev ? '//172.19.18.26:8080/xlyFace' : '//' + location.host + '/xlyFace',
9 9 ipAddress: localStorage.ipAddress ? localStorage.ipAddress : isDev ? '//172.19.18.21:9543/xlyEntry/' : '//' + location.host + '/xlyEntry/',
10   - interfaceAddress: isDev ? '//127.0.0.1:8088/xlyApi/' : '//' + location.host + '/xlyApi/', // 接口地址1
  10 + interfaceAddress: isDev ? '//172.19.18.21:9181/xlyApi/' : '//' + location.host + '/xlyApi/', // 接口地址1
11 11 // ipAddress: isDev ? '//ebc.jinjia.com:8091/xlyEntry/' : '//' + location.host + '/xlyEntry/',
12 12 // interfaceAddress: isDev ? '//ebc.jinjia.com:8091/xlyApi/' : '//' + location.host + '/xlyApi/', // 接口地址1111
13 13 // ipAddress: isDev ? '//192.168.11.26:8080/xlyEntry/' : '//' + location.host + '/xlyEntry/',
... ... @@ -30,7 +30,7 @@ module.exports = {
30 30 face_host: bHttps ? `https:${webSite.faceAddress}` : `http:${webSite.faceAddress}`, /* 外网连内网服务器地址 */
31 31 feedback_host: bHttps? 'https://project.xlyprint.cn/xlyEntry/' : 'http://s10.xlyprint.cn:8000/xlyEntry/', // 问题反馈接口前缀
32 32 feedback_ws_host: bHttps? 'wss://project.xlyprint.cn/xlyEntry/' : 'ws://s10.xlyprint.cn:8000/xlyEntry/', // 问题反馈接口前缀
33   - interface_host: `http${bHttps ? 's' : ''}:${webSite.interfaceAddress}`, /* 接口地址 */
  33 + interface_host: bHttps ? `https:${webSite.interfaceAddress}` : `http:${webSite.interfaceAddress}`, /* 接口地址*/
34 34 btnData: [{
35 35 sName: 'BtnRefresh', sControlName: 'BtnRefresh', showName: '刷新', bVisible: true, sActiveId: '', iconName: 'reload', disabled: false,
36 36 }, {
... ...