Commit 77adc61b7aee1c9c115177c99b848c1a1c5d3069

Authored by chenxt
1 parent 21d13042

产量上报主表id查询

src/mes/common/commonModelComponent/index.js
... ... @@ -33,7 +33,6 @@ const useCommonModelEvent = props => {
33 33 noGetData, // 不要加载数据,根据另一张表选中行加载时用
34 34 currentId,
35 35 } = props;
36   -
37 36 let formData =
38 37 props.parentProps?.btnConfig?.sActiveId === "12710101117087374661080"
39 38 ? formDataOld.filter(item => item.sGrd === "Knifetable")
... ... @@ -491,9 +490,9 @@ const useCommonModelEvent = props => {
491 490  
492 491 // 获取数据集
493 492 const handleGetData = async (tableList = [], isWait, bInit) => {
494   - const { btnConfig = {}, copyToConfig = [], record = {} } = props?.parentProps || {}
495 493 let addState = {};
496   - let copy = {}
  494 + const currentIds = currentId ? currentId : props?.parentProps?.record?.sId
  495 + console.log("🚀 ~ handleGetData ~ currentIds:", currentIds, props?.parentProps?.record )
497 496 for (let i = 0; i < tableList.length; i++) {
498 497 const tableName = tableList[i];
499 498 const config = formData.find(item => item.sGrd === tableName);
... ... @@ -607,25 +606,27 @@ const useCommonModelEvent = props =&gt; {
607 606 }
608 607  
609 608 const masterState = {};
610   - if (currentId && tableName === 'master') {
  609 + if (currentIds && tableName === 'master') {
611 610 masterState.sId = currentId;
  611 + }
  612 + if (currentIds && tableName !== 'master') {
  613 + conditonValues.sParentId = currentIds;
612 614 }
613   - if (currentId && tableName !== 'master') {
614   - conditonValues.sParentId = currentId;
615   - }
  615 +
616 616 const result =
617 617 (await props.onGetDataSet({
618 618 name: tableName,
619 619 configData: config,
620 620 condition: {
621 621 ...masterState,
622   - sId: props.parentProps?.record?.sId,
  622 + sId: currentIds,
623 623 sSqlCondition: { ...conditonValues, ...sFilterConditions, },
624 624 bFilter
625 625 },
626 626 sModelTypes: props.parentProps,
627 627 isWait: true
628 628 })) || {};
  629 +
629 630 props.setTempRef(result);
630 631  
631 632 if (tableName?.includes("master")) {
... ... @@ -673,22 +674,7 @@ const useCommonModelEvent = props =&gt; {
673 674 }
674 675 }
675 676 }
676   - // if (copyToConfig && copyToConfig.length) {
677   - // copyToConfig.forEach(item => {
678   - // const name = item.sControlName.split('.').pop()
679   - // if (name === tableName) {
680   - // const data = commonFunc.getAssignFieldValue(item.sAssignField, record)
681   - // copy[`${tableName}Data`] = {
682   - // ...commonFunc.getDefaultData(name + 'Config'),
683   - // handleType: "add",
684   - // sId: commonUtils.createSid(),
685   - // sFormId: sModelsId,
686   - // ...data
687   - // }
688   - // }
689   - // })
690   - // }
691   - addState = { ...addState, ...result, ...copy };
  677 + addState = { ...addState, ...result, };
692 678  
693 679 if (tableName === "tableS0" && props.sSReserve1) {
694 680 addState.sSReserve1 = undefined;
... ...
src/mes/common/commonOperationBarComponent/MesToolbar.js
... ... @@ -73,7 +73,9 @@ const ToolbarFun = async (props) =&gt; {
73 73 }
74 74 }
75 75 } else {
76   - props.onBtnExamine();
  76 + console.log(props, 'masterData');
  77 +
  78 + // props.onBtnExamine();
77 79 }
78 80 }
79 81  
... ... @@ -181,14 +183,20 @@ const handleScanFace = (props) =&gt; {
181 183 const copyConfig = config?.gdsconfigformslave?.find(item => item.sControlName.toLowerCase().includes('btnscanface'))
182 184 proData.forEach(item => {
183 185 const data = commonFunc.getAssignFieldValue(copyConfig?.sAssignField, item)
184   - tableData.push({
185   - ...item,
186   - ...data,
187   - sId: commonUtils.createSid(),
188   - handleType: "add",
189   - sParentId: props.masterData.sId,
190   - slaveId: props?.slaveData ? props?.slaveData[0].sId : ''
191   - })
  186 + const index = tableData.findIndex(x => x.sEmployeeNo === item.sEmployeeNo)
  187 + if (index !== -1) {
  188 + message.error('人员重复,请重新添加', 5)
  189 + } else {
  190 + tableData.push({
  191 + ...item,
  192 + ...data,
  193 + sId: commonUtils.createSid(),
  194 + handleType: "add",
  195 + sParentId: props.masterData.sId,
  196 + slaveId: props?.slaveData ? props?.slaveData[0].sId : ''
  197 + })
  198 + }
  199 +
192 200 });
193 201  
194 202 props.onSaveState({
... ...
src/mes/common/commonOperationBarComponent/index.js
1 1 import React, { useEffect, useRef, useState } from "react";
2 2 import moment from "moment";
  3 +import { message } from 'antd';
3 4 import ShowType from "@/components/Common/CommonComponent";
4 5 import { operationFetch } from "../../productionExec/productionExecMain/operationFetch";
5 6 import * as commonUtils from "@/utils/utils";
... ... @@ -9,7 +10,7 @@ import StaticEditTable from &quot;@/components/Common/CommonTable&quot;;
9 10 import costomPageFun from "@/mes/costomPageFun";
10 11 import * as commonConfig from "@/utils/config";
11 12 import MesToolbar from "./MesToolbar";
12   -
  13 +import * as commonServices from "@/services/services";
13 14 import styles from "./index.less";
14 15 import { Button, Space, Input, Modal, Dropdown, Popconfirm } from "antd";
15 16 import { ScanOutlined } from "@ant-design/icons";
... ... @@ -85,7 +86,6 @@ const useCommonOperationBarComponentEvent = props =&gt; {
85 86 setTimeout(() => {
86 87 clickRef.current = false;
87 88 }, 500);
88   -
89 89 await props.awaitPromiseReturn();
90 90 const { sName } = props;
91 91 const { sActiveId, sButtonParam, sInstruct, sControlName } = config;
... ... @@ -96,7 +96,6 @@ const useCommonOperationBarComponentEvent = props =&gt; {
96 96 if (await MesToolbar({ ...props, btnConfig: config })) {
97 97 return;
98 98 }
99   -
100 99 // 自定义按钮事件
101 100 if (
102 101 costomPageFun({
... ... @@ -271,6 +270,8 @@ const useCommonOperationBarComponentEvent = props =&gt; {
271 270 });
272 271 }
273 272  
  273 +
  274 +
274 275 // 处理特殊按钮
275 276 const btnType = sControlName.split(".")[0].toLowerCase();
276 277 const btnName = sControlName.split(".")[1].toLowerCase();
... ... @@ -331,7 +332,148 @@ const useCommonOperationBarComponentEvent = props =&gt; {
331 332 handleProcedureCall(config);
332 333 }
333 334 };
  335 + /* 调用后台配置的接口 */
  336 + const handleInterfaceCall = async (obj, showTip, key, ids, slaveSelectedRowKeysOld) => {
  337 + let bResult = false;
  338 + const { app, sModelsId, masterData, slaveData, masterConfig, slaveFilterCondition } = props;
  339 + const slaveSelectedRowKeys = slaveSelectedRowKeysOld || props.slaveSelectedRowKeys;
  340 + const sInterfaceName = obj.sInterfaceName;
  341 + /* 如果key是BtnSendList 传从表的主键集合 */
  342 + let idArr = "";
  343 + /* 如果有对应字段 则取对应字段 ,否则 取默认值 */
  344 + const btnConfig = commonUtils.isNotEmptyArr(masterConfig.gdsconfigformslave.filter(item => item.sControlName === key))
  345 + ? masterConfig.gdsconfigformslave.filter(item => item.sControlName === key)[0]
  346 + : {};
  347 +
  348 + let sActiveKey = "";
  349 + if (commonUtils.isNotEmptyObject(btnConfig)) {
  350 + sActiveKey = btnConfig.sActiveKey;
  351 + }
  352 + if (sActiveKey) {
  353 + if (sActiveKey.includes("master.sId")) {
  354 + idArr = masterData.sId;
  355 + }
  356 + } else if (key && (key.includes("BtnSendList") || key.includes("BtnBatchExamine"))) {
  357 + if (commonUtils.isNotEmptyArr(slaveSelectedRowKeys)) {
  358 + slaveSelectedRowKeys.forEach(item => {
  359 + if (commonUtils.isNotEmptyObject(item)) {
  360 + idArr += `${item},`;
  361 + }
  362 + });
  363 + idArr = commonUtils.isNotEmptyObject(idArr) ? idArr.substr(0, idArr.length - 1) : "";
  364 + }
  365 + } else if (location.pathname.includes("commonList")) {
  366 + const { slaveSelectedRowKeys, slaveData } = props;
  367 + let { slaveSelectedData } = props;
  368 + if (commonUtils.isEmptyArr(slaveSelectedData) && commonUtils.isNotEmptyArr(slaveData)) {
  369 + slaveSelectedData = slaveData.filter(item => slaveSelectedRowKeys.includes(item.sId) || slaveSelectedRowKeys.includes(item.sSlaveId));
  370 + }
  371 + const slaveSelectedDataNew = deteleObject(slaveSelectedData); // 删除sid重复的数据
334 372  
  373 + if (commonUtils.isNotEmptyArr(slaveSelectedDataNew)) {
  374 + slaveSelectedDataNew.forEach(item => {
  375 + if (commonUtils.isNotEmptyObject(item)) {
  376 + idArr += `${item.sId},`;
  377 + }
  378 + });
  379 + idArr = commonUtils.isNotEmptyObject(idArr) ? idArr.substr(0, idArr.length - 1) : "";
  380 + }
  381 + if (commonUtils.isNotEmptyObject(ids)) {
  382 + /* 如果是勾选多行 则sId为循环的每一条 */
  383 + idArr = ids;
  384 + }
  385 + } else {
  386 + idArr = masterData.sId;
  387 + }
  388 + const value = {
  389 + sId: commonUtils.isNotEmptyObject(idArr) ? idArr : commonUtils.isNotEmptyObject(ids) ? ids : masterData.sId,
  390 + sSlaveId: slaveSelectedRowKeys?.toString(),
  391 + masterData,
  392 + userInfo: app.userinfo,
  393 + };
  394 + if (location.pathname.includes("commonList") && commonUtils.isNotEmptyArr(slaveFilterCondition)) {
  395 + value.bFilter = JSON.stringify(slaveFilterCondition);
  396 + }
  397 + const url = `${commonConfig.interface_host}interfaceDefine/callthirdparty/${sInterfaceName}?sModelsId=${sModelsId}`;
  398 + const returnData = (await commonServices.postValueService(app.token, value, url, app)).data;
  399 + if (showTip) {
  400 + if (!returnData || returnData.code < 0) {
  401 + if (commonUtils.isNotEmptyObject(returnData) && returnData.code === -8) {
  402 + Modal.info({
  403 + title: "温馨提示:",
  404 + content: <div>{handleGetMsg(returnData.msg)}</div>,
  405 + okText: "确认",
  406 + onOk() { },
  407 + });
  408 + } else {
  409 + Modal.info({
  410 + title: "温馨提示:",
  411 + content: <div>{handleGetMsg(returnData.msg)}</div>,
  412 + okText: "确认",
  413 + onOk() { },
  414 + });
  415 + return;
  416 + }
  417 + return;
  418 + } else {
  419 + // message.success('同步INFOR成功!');
  420 + }
  421 + }
  422 + if (!returnData) {
  423 + message.error("接口调用失败!");
  424 + return false;
  425 + }
  426 + if (returnData.code === 1) {
  427 + bResult = true;
  428 + // message.success(returnData.msg);
  429 + } else if (returnData.code === 2) {
  430 + bResult = true;
  431 + } else if (returnData.code === -8) {
  432 + Modal.info({
  433 + title: "温馨提示:",
  434 + content: <div>{handleGetMsg(returnData.msg)}</div>,
  435 + okText: "确认",
  436 + onOk() { },
  437 + });
  438 + bResult = false;
  439 + } else {
  440 + bResult = false;
  441 + props.getServiceError(returnData);
  442 + }
  443 + /* 若配置的是按钮后调用第三方, 则调用成功后 需要重新回刷一次数据 */
  444 + if (commonUtils.isNotEmptyObject(obj) && obj.sInterfaceCallMethod === "2") {
  445 + if (bResult) {
  446 + props.onButtonClick("BtnRefresh");
  447 + }
  448 + }
  449 + return bResult;
  450 + };
  451 + const deteleObject = (obj = []) => {
  452 + // eslint-disable-next-line camelcase
  453 + const replace_data = obj;
  454 + const result = []; // 去重后的数组对象集合
  455 + const hash = {};
  456 + // eslint-disable-next-line no-plusplus
  457 + for (let i = 0; i < replace_data.length; i++) {
  458 + const elem = replace_data[i].sId;
  459 + if (!hash[elem]) {
  460 + result.push(replace_data[i]);
  461 + hash[elem] = true;
  462 + }
  463 + }
  464 + return result;
  465 + };
  466 + /* 解析消息 */
  467 + const handleGetMsg = str => {
  468 + const msgArr = commonUtils.isNotEmptyObject(str) ? str.split("xpm") : "";
  469 + const divStr = [];
  470 + if (commonUtils.isNotEmptyArr(msgArr)) {
  471 + for (let i = 0; i < msgArr.length; i++) {
  472 + divStr.push(<p>{msgArr[i]}</p>);
  473 + }
  474 + }
  475 + return divStr;
  476 + };
335 477 //
336 478 const handleSearchValueChange = (name, sFieldName, changeValue) => {
337 479 setSearchValue(changeValue[sFieldName]);
... ... @@ -423,7 +565,7 @@ const useCommonOperationBarComponentEvent = props =&gt; {
423 565 sActiveId,
424 566 title: sActiveName,
425 567 copyTo,
426   - sModelType:'/indexPage/commonBill',
  568 + sModelType: '/indexPage/commonBill',
427 569 sParentConditions,
428 570 parentProps: props,
429 571 onOk: data => {
... ... @@ -781,7 +923,7 @@ const CommonOperationBarComponent = basProps =&gt; {
781 923 const btnLeftConfig = gdsconfigformslave.filter(
782 924 item => item.bVisible && item.sControlName.includes("BtnLeft.")
783 925 );
784   - console.log(btnLeftConfig,gdsconfigformslave, 'btnLeftConfig');
  926 + console.log(btnLeftConfig, gdsconfigformslave, 'btnLeftConfig');
785 927  
786 928 // 将扫码上料放到最后
787 929 const scanCodeToLoadMaterialsIndex = btnLeftConfig.findIndex(
... ... @@ -815,13 +957,9 @@ const CommonOperationBarComponent = basProps =&gt; {
815 957 btnLeftConfig[0].btnBgColor = "red";
816 958 }
817 959  
818   - const bManual = props.bManual;
819   - const btnRightConfig = gdsconfigformslave.filter(item => {
820   - // 排除条件:sControlName是BtnRight.BtnEnventInsertWork且bManual=1的项
821   - const isExcludeItem = item.sControlName === 'BtnRight.BtnEnventInsertWork' && !bManual;
822   - // 保留条件:不是排除项,且满足原有过滤规则
823   - return !isExcludeItem && item.bVisible && item.sControlName.includes('BtnRight.');
824   - });
  960 + const btnRightConfig = gdsconfigformslave.filter(
  961 + item => item.bVisible && item.sControlName.includes("BtnRight.")
  962 + );
825 963  
826 964 if (!searchField && !btnRightConfig.length) return "";
827 965  
... ...
src/mes/indexMes/index.js
... ... @@ -172,7 +172,7 @@ const useIndexMesEvent = props =&gt; {
172 172 sParentConditions,
173 173 copyTo,
174 174 parentProps,
175   - modalCallback
  175 + modalCallback,
176 176 }) => {
177 177 if (!type) return;
178 178  
... ...