Commit 10140d0b3ae43436351f76e8f74ce70911a82277

Authored by chenxt
1 parent a011fab4

修复研发工单工艺参数点击没用的问题

src/components/Manufacture/WorkOrderPackTableTreeNew/index.js
1 1 /* eslint-disable */
2 2 import React, { useEffect, useState, useMemo, useRef } from "react";
3 3 import moment from "moment";
4   -import { Avatar, Collapse, Radio, Row, Col, Divider, message, Modal } from "antd-v4";
  4 +import { Avatar, Collapse, Radio, Row, Col, Divider, message, Modal, Button } from "antd-v4";
5 5 import { RightOutlined } from "@ant-design/icons";
6 6 import { Form } from "@ant-design/compatible";
7 7 import CommonBase from "@/components/Common/CommonBase";
... ... @@ -336,8 +336,8 @@ const WorkOrderPackTableTreeNewEvent = props => {
336 336 newCopyTo.slave = slaveItem;
337 337 const iSameIndex = commonUtils.isNotEmptyArr(slaveData)
338 338 ? slaveData.findIndex(
339   - itemCurrent => itemCurrent.sProductId === slaveItem.sProductId && itemCurrent.sCustomerId === slaveItem.sCustomerId
340   - )
  339 + itemCurrent => itemCurrent.sProductId === slaveItem.sProductId && itemCurrent.sCustomerId === slaveItem.sCustomerId
  340 + )
341 341 : -1;
342 342 if (iSameIndex > -1) {
343 343 masterData = {
... ... @@ -1396,7 +1396,7 @@ const WorkOrderPackTableTreeNewEvent = props => {
1396 1396 controlData,
1397 1397 controlDelData,
1398 1398 materialsConfig,
1399   - materials0Data : materialsData,
  1399 + materials0Data: materialsData,
1400 1400 materialsDelData,
1401 1401 processConfig,
1402 1402 processData,
... ... @@ -1634,9 +1634,8 @@ const WorkOrderPackTableTreeNewEvent = props => {
1634 1634 sId = slaveData[0].sId;
1635 1635 }
1636 1636  
1637   - const dataUrl = `${
1638   - commonConfig.server_host
1639   - }bill/billCopyToCheck/?sModelsId=${sModelsId}&sActiveId=${sActiveId}&tbSuffix=${tbSuffix}&sName=${formRoute}`;
  1637 + const dataUrl = `${commonConfig.server_host
  1638 + }bill/billCopyToCheck/?sModelsId=${sModelsId}&sActiveId=${sActiveId}&tbSuffix=${tbSuffix}&sName=${formRoute}`;
1640 1639 const values = { sSlaveId: sId };
1641 1640 const dataReturn = (await commonServices.postValueService(token, values, dataUrl)).data;
1642 1641 if (dataReturn.code === 1) {
... ... @@ -1646,7 +1645,7 @@ const WorkOrderPackTableTreeNewEvent = props => {
1646 1645 onOk() {
1647 1646 handleDispatch(copyTo, sActiveId);
1648 1647 },
1649   - onCancel() {},
  1648 + onCancel() { },
1650 1649 });
1651 1650 } else {
1652 1651 handleDispatch(copyTo, sActiveId);
... ... @@ -1699,7 +1698,7 @@ const WorkOrderPackTableTreeNewEvent = props => {
1699 1698 let materialsData = commonUtils.isEmptyArr(materialsDataOld) ? [] : materialsDataOld;
1700 1699 let processData = commonUtils.isEmptyArr(processDataOld) ? [] : processDataOld;
1701 1700 let colorData = commonUtils.isEmptyArr(colorDataOld) ? [] : colorDataOld;
1702   - let packData = commonUtils.isEmptyArr(packDataOld) ? [] : packDataOld;
  1701 + let packData = commonUtils.isEmptyArr(packDataOld) ? [] : packDataOld;
1703 1702  
1704 1703 const config = {};
1705 1704 config.masterConfig = masterConfig;
... ... @@ -1769,7 +1768,7 @@ const WorkOrderPackTableTreeNewEvent = props => {
1769 1768 const masterDetailAssignField = commonUtils.isNotEmptyArr(copyToMasterDetailConfig) ? copyToMasterDetailConfig[0].sAssignField : "";
1770 1769 const slaveDetailAssignField = commonUtils.isNotEmptyArr(copyToSlaveDetailConfig) ? copyToSlaveDetailConfig[0].sAssignField : "";
1771 1770 const copyToColorConfig = copyTo.config.filter(item => item.sControlName.toLowerCase() === `${copyTo.name}.color`.toLowerCase()
1772   - || item.sControlName.toLowerCase() === `${copyTo.name}.param`.toLowerCase());
  1771 + || item.sControlName.toLowerCase() === `${copyTo.name}.param`.toLowerCase());
1773 1772 const controlAssignField = commonUtils.isNotEmptyArr(copyToControlConfig) ? copyToControlConfig[0].sAssignField : "";
1774 1773 const materialsAssignField = commonUtils.isNotEmptyArr(copyToMaterialsConfig) ? copyToMaterialsConfig[0].sAssignField : "";
1775 1774 const processAssignField = commonUtils.isNotEmptyArr(copyToProcessConfig) ? copyToProcessConfig[0].sAssignField : "";
... ... @@ -1924,20 +1923,20 @@ const WorkOrderPackTableTreeNewEvent = props => {
1924 1923 if (commonUtils.isNotEmptyArr(returnData.slaveData)) {
1925 1924 returnData.slaveData.forEach((slaveItem, iIndex) => {
1926 1925 /* 从工艺卡数据集 找到从表相同产品ID,客户ID */
1927   - let iSameIndex = slaveData.findIndex(itemCurrent => itemCurrent.sProductId === slaveItem.sProductId && itemCurrent.sCustomerId === slaveItem.sCustomerId);
1928   - if(iSameIndex === -1){
  1926 + let iSameIndex = slaveData.findIndex(itemCurrent => itemCurrent.sProductId === slaveItem.sProductId && itemCurrent.sCustomerId === slaveItem.sCustomerId);
  1927 + if (iSameIndex === -1) {
1929 1928 /* 复制从历史工单 只要把数据赋值到选中行即可 */
1930 1929 iSameIndex = iSlaveIndex;
1931 1930 }
1932   - if(iSameIndex > -1 && iIndex === 0 ){ /* 把返回结果集的第一行数据放在选中行上 */
1933   - if(commonUtils.isNotEmptyObject(slaveDetailAssignField)) {
  1931 + if (iSameIndex > -1 && iIndex === 0) { /* 把返回结果集的第一行数据放在选中行上 */
  1932 + if (commonUtils.isNotEmptyObject(slaveDetailAssignField)) {
1934 1933 slaveData[iSameIndex] = { ...slaveData[iSameIndex], ...commonFunc.getAssignFieldValue(slaveDetailAssignField, slaveItem, newCopyTo) }; // 取赋值字段
1935 1934 }
1936 1935 slaveData[iSameIndex].sOriginalId = commonUtils.isNotEmptyObject(slaveItem.sSlaveId) ? slaveItem.sSlaveId : slaveItem.sId; /* 原始sId */
1937 1936 if (bProductQtySelf) {
1938   - dProductQty += commonUtils.isNull( slaveData[iSameIndex].dProductQty, 0);
  1937 + dProductQty += commonUtils.isNull(slaveData[iSameIndex].dProductQty, 0);
1939 1938 } else {
1940   - dProductQty += commonUtils.isNull( slaveData[iSameIndex].dProductQty, 0) + commonUtils.isNull( slaveData[iSameIndex].dGiveQty, 0) +
  1939 + dProductQty += commonUtils.isNull(slaveData[iSameIndex].dProductQty, 0) + commonUtils.isNull(slaveData[iSameIndex].dGiveQty, 0) +
1941 1940 commonUtils.isNull(slaveData[iSameIndex].dStockupQty, 0);
1942 1941 }
1943 1942 } else if (commonUtils.isNotEmptyObject(slaveDetailAssignField)) {
... ... @@ -2044,11 +2043,11 @@ const WorkOrderPackTableTreeNewEvent = props => {
2044 2043 controlData[icontrolIndex] = { ...controlData[icontrolIndex], sCombinedMemo: sCombinedMemoNew };
2045 2044 }
2046 2045 }
2047   - }else {
  2046 + } else {
2048 2047 packRowAdd.dCombineQty = 1; /* 排版数 */
2049   - if(commonUtils.isNotEmptyObject(packRowAdd) && commonUtils.isNotEmptyObject(packRowAdd.sProductId)){ /* 从表要选择产品 */
2050   - const { sId, sProductNo, dProductQty, dCombineQty, dFactProductQty,sCombinePartsName }= packRowAdd;
2051   - const tableCombineSelectedData =[];
  2048 + if (commonUtils.isNotEmptyObject(packRowAdd) && commonUtils.isNotEmptyObject(packRowAdd.sProductId)) { /* 从表要选择产品 */
  2049 + const { sId, sProductNo, dProductQty, dCombineQty, dFactProductQty, sCombinePartsName } = packRowAdd;
  2050 + const tableCombineSelectedData = [];
2052 2051 const jsonObj = {};
2053 2052 jsonObj.sId = sId;
2054 2053 jsonObj.sProductNo = sProductNo; /* 产品编号 */
... ... @@ -2058,7 +2057,7 @@ const WorkOrderPackTableTreeNewEvent = props => {
2058 2057 jsonObj.sCombinePartsName = sCombinePartsName; /* 合版部件名称 */
2059 2058 tableCombineSelectedData.push(jsonObj);
2060 2059 const sCombinedMemo = commonUtils.isNotEmptyArr(tableCombineSelectedData) ? JSON.stringify(tableCombineSelectedData) : ''; /* JSON对象转换为字符串存放到合版信息中 */
2061   - const sCombinedMemoNew =commonUtils.isNotEmptyObject(sCombinedMemo)? sCombinedMemo: '合版信息';
  2060 + const sCombinedMemoNew = commonUtils.isNotEmptyObject(sCombinedMemo) ? sCombinedMemo : '合版信息';
2062 2061 const icontrolIndex = controlData.findIndex(item => item.sId === controlRow.sId);
2063 2062 if (icontrolIndex > -1) {
2064 2063 controlData[icontrolIndex] = { ...controlData[icontrolIndex], sCombinedMemo: sCombinedMemoNew };
... ... @@ -2220,9 +2219,9 @@ const WorkOrderPackTableTreeNewEvent = props => {
2220 2219 sNewNames += `${tableDataRow.sCustomerName}-${tableDataRow.sProductName},`;
2221 2220 }
2222 2221 }
2223   - }else if(iSlaveIndex > -1) {
  2222 + } else if (iSlaveIndex > -1) {
2224 2223 sNewIds = slaveData[iSlaveIndex].sId;
2225   - sNewNames = `${slaveData[iSlaveIndex].sCustomerName}-${slaveData[iSlaveIndex].sProductName},`;
  2224 + sNewNames = `${slaveData[iSlaveIndex].sCustomerName}-${slaveData[iSlaveIndex].sProductName},`;
2226 2225 }
2227 2226 sNewIds = commonUtils.isNotEmptyObject(sNewIds) ? sNewIds.substr(0, sNewIds.length - 1) : "";
2228 2227 sNewNames = commonUtils.isNotEmptyObject(sNewNames) ? sNewNames.substr(0, sNewNames.length - 1) : "";
... ... @@ -2415,8 +2414,8 @@ const WorkOrderPackTableTreeNewEvent = props => {
2415 2414 tableDataRow.sType === "3"
2416 2415 ? tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId)
2417 2416 : tableData.findIndex(
2418   - item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlData[iControlIndex].sId
2419   - );
  2417 + item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlData[iControlIndex].sId
  2418 + );
2420 2419 if (iProcessIndex < 0 && iNewProcessIndex < 0) {
2421 2420 let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值
2422 2421 processRow = {
... ... @@ -2439,8 +2438,8 @@ const WorkOrderPackTableTreeNewEvent = props =&gt; {
2439 2438 dropDownDataProcessName[iIndex].sType === "3"
2440 2439 ? tableData.findIndex(item => item.sProcessId === itemProcessAssort.sProcessId)
2441 2440 : tableData.findIndex(
2442   - item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlTableRow.sId
2443   - );
  2441 + item => item.sProcessId === itemProcessAssort.sProcessId && item.sControlId === controlTableRow.sId
  2442 + );
2444 2443 if (iNewProcessIndex < 0) {
2445 2444 let processRow = commonFunc.getDefaultData(processConfig, newCopyTo); // 取默认值
2446 2445 processRow = {
... ... @@ -3225,7 +3224,7 @@ const controlProps = props =&gt; {
3225 3224 treeSelectedKeys = treeSelectedKeys || [];
3226 3225 const tableRow = controlData.find(item => item.sId === tableSelectedRowKeys[0]);
3227 3226 let controlChildData = [];
3228   - if(commonUtils.isNotEmptyObject(tableRow)) {
  3227 + if (commonUtils.isNotEmptyObject(tableRow)) {
3229 3228 // 使用Set来记录已处理节点,防止循环引用
3230 3229 const processedNodes = new Set();
3231 3230  
... ... @@ -3428,7 +3427,7 @@ const controlProps = props =&gt; {
3428 3427 };
3429 3428 returnProps.onTableSelectRowChange = async ({ name, selectedRowKeys }) => {
3430 3429 const addState = await props.onTableSelectRowChange(name, selectedRowKeys, true);
3431   - props.onSaveState({ addState, processSelectedRowKeys: []});
  3430 + props.onSaveState({ addState, processSelectedRowKeys: [] });
3432 3431 }
3433 3432 returnProps.onViewChoose = ({ name, sName, record }) => {
3434 3433 const { sId } = record; /* 控制表主键 */
... ... @@ -3459,7 +3458,7 @@ const controlProps = props =&gt; {
3459 3458 packData[iIndex] = { ...packData[iIndex], ...packRowAdd };
3460 3459 if (itemPack.dCombineQty !== undefined && itemPack.dCombineQty !== null && itemPack.dCombineQty !== 0
3461 3460 ) {
3462   - if(sCombinedMemo.includes(packData[iIndex].sProductNo)) {
  3461 + if (sCombinedMemo.includes(packData[iIndex].sProductNo)) {
3463 3462 packSelectedRowKeys.push(packData[iIndex].sId);
3464 3463 }
3465 3464 }
... ... @@ -3632,7 +3631,7 @@ const processProps = props =&gt; {
3632 3631 slaveData,
3633 3632 controlData,
3634 3633 controlSelectedRowKeys,
3635   - materials0Data:materialsData,
  3634 + materials0Data: materialsData,
3636 3635 processConfig,
3637 3636 token,
3638 3637 } = props;
... ... @@ -3796,7 +3795,7 @@ const processProps = props =&gt; {
3796 3795 let { packData } = props;
3797 3796 const { gdsconfigformslave = [] } = processConfig;
3798 3797 const bSWorkOrderParams = gdsconfigformslave.some(item => item.sName === "sParams" && item.sControlName === "sWorkOrder");
3799   -
  3798 + const bNotSWorkOrderParams = gdsconfigformslave.some(item => item.sName === "sParams")
3800 3799 if (["sCombinePartsNameNew", "sCombineProductNameNew"].includes(sName)) {
3801 3800 const { [`${name}Data`]: tableData } = props;
3802 3801 const iIndex = tableData.findIndex(item => item.sId === sId);
... ... @@ -3856,6 +3855,10 @@ const processProps = props =&gt; {
3856 3855 props.onSaveState({
3857 3856 sWorkParamsModalVisible: true,
3858 3857 });
  3858 + } else if (sName === "sParams" && bNotSWorkOrderParams) {
  3859 + props.onSaveState({
  3860 + sWorkParamsModalVisible: true,
  3861 + });
3859 3862 } else {
3860 3863 props.onViewChoose(name, sName, record);
3861 3864 }
... ... @@ -4312,11 +4315,11 @@ const OtherComponent = props =&gt; {
4312 4315 const dailyInfo = commonFunc.showMessage(commonConst, "dailyInfo"); // 日志信息
4313 4316 // const visionInfo = "改版记录";
4314 4317 // const colorInfo = "工艺颜色";
4315   - const visionInfo = commonUtils.isNotEmptyObject(commonFunc.showMessage(commonConst, "visionInfo")) ?
  4318 + const visionInfo = commonUtils.isNotEmptyObject(commonFunc.showMessage(commonConst, "visionInfo")) ?
4316 4319 commonFunc.showMessage(commonConst, "visionInfo") : '改版记录';
4317   - const colorInfo = commonUtils.isNotEmptyObject(colorConfig) && commonUtils.isNotEmptyObject(colorConfig.showName ) ?
  4320 + const colorInfo = commonUtils.isNotEmptyObject(colorConfig) && commonUtils.isNotEmptyObject(colorConfig.showName) ?
4318 4321 colorConfig.showName :
4319   - commonUtils.isNotEmptyObject(commonFunc.showMessage(commonConst, "colorInfo")) ?
  4322 + commonUtils.isNotEmptyObject(commonFunc.showMessage(commonConst, "colorInfo")) ?
4320 4323 commonFunc.showMessage(commonConst, "colorInfo") : '工艺颜色'; // "工艺颜色";
4321 4324  
4322 4325 const [materialsTabValue, setMaterialsTabValue] = useState(12);
... ... @@ -4785,4 +4788,115 @@ const DailyComponent = props =&gt; {
4785 4788 return <StaticEditTable {...dailyRecordTableProps} />;
4786 4789 };
4787 4790  
  4791 +
  4792 +// 工艺参数弹窗
  4793 +const ModalComponent = props => {
  4794 + const modalName = 'sWorkParamsModalVisible'; // commonParamVisible
  4795 + const sProcessParams = commonFunc.showMessage(props.app.commonConst, 'workParam') || '工单参数';
  4796 + const BtnFirst = commonFunc.showMessage(props.app.commonConst, 'BtnFirst') || '首条';
  4797 +
  4798 + const BtnLast = commonFunc.showMessage(props.app.commonConst, 'BtnLast') || '末条';
  4799 +
  4800 + const BtnPrior = commonFunc.showMessage(props.app.commonConst, 'BtnPrior') || '上一条';
  4801 +
  4802 + const BtnNext = commonFunc.showMessage(props.app.commonConst, 'BtnNext') || '下一条';
  4803 +
  4804 + const getTableBtnState = (tableName) => {
  4805 + let result = false;
  4806 + const { enabled, masterData } = props;
  4807 + result = enabled;
  4808 +
  4809 + const { sInstruct: sInstructStr } = props[`${tableName}Config`];
  4810 + const sInstruct = commonUtils.convertStrToObj(sInstructStr, {});
  4811 + const { data = [] } = sInstruct;
  4812 +
  4813 + const btnConfig = data.find(item => item && item.name === tableName && item.enabled !== undefined);
  4814 + if (btnConfig && result) {
  4815 + if (!Array.isArray(props[`${tableName}Data`]) || !Array.isArray([`${tableName}SelectedRowKeys`])) {
  4816 + return;
  4817 + }
  4818 + const { enabled: enabledContent } = btnConfig;
  4819 + if (typeof enabledContent === 'boolean') {
  4820 + result = enabledContent;
  4821 + } else if (enabledContent) {
  4822 + const tempData = {
  4823 + props: {
  4824 + enabled
  4825 + },
  4826 + masterData,
  4827 + [tableName]: props[`${tableName}Data`]?.find(i =>
  4828 + i && (props[`${tableName}SelectedRowKeys`].includes(i.sId)
  4829 + || props[`${tableName}SelectedRowKeys`].includes(i.sSlaveId)))
  4830 + || {},
  4831 + };
  4832 + let strNew = enabledContent;
  4833 + Object.keys(tempData).forEach(key => {
  4834 + const reg = new RegExp(`${key}\\.`, "g");
  4835 + strNew = strNew.replace(reg, `tempData["${key}"].`);
  4836 + });
  4837 + try {
  4838 + const evalStr = eval("`" + strNew + "`");
  4839 + result = !!eval(evalStr);
  4840 + console.log('=====表格行按钮状态结果', result, { btnName, enabledContent, tempData, strNew, evalStr });
  4841 + } catch (error) {
  4842 + console.log('=====表格行按钮状态错误', { error, enabledContent, strNew, tempData });
  4843 + }
  4844 + }
  4845 + }
  4846 + return result;
  4847 + }
  4848 + return props[modalName] ?
  4849 + <Modal
  4850 + width="80%"
  4851 + className="commonParamDrag"
  4852 + title={sProcessParams}
  4853 + visible={props[modalName]}
  4854 + onCancel={() => {
  4855 + props.onSaveState({ [modalName]: false });
  4856 + }}
  4857 + footer={
  4858 + <Button
  4859 + type="primary"
  4860 + onClick={() => {
  4861 + props.onSaveState({ [modalName]: false });
  4862 + }}
  4863 + >
  4864 + 确定
  4865 + </Button>
  4866 + }
  4867 + >
  4868 + <div>
  4869 + <div className='oper'>
  4870 + <Button type='primary' onClick={() => { props.onBtnParamPage(props, props.processTableId, 'first') }} >{BtnFirst}</Button>
  4871 + <Button type='primary' onClick={() => { props.onBtnParamPage(props, props.processTableId, 'before') }} >{BtnPrior}</Button>
  4872 + <Button type='primary' onClick={() => { props.onBtnParamPage(props, props.processTableId, 'next') }} >{BtnNext}</Button>
  4873 + <Button type='primary' onClick={() => { props.onBtnParamPage(props, props.processTableId, 'last') }} >{BtnLast}</Button>
  4874 + </div>
  4875 + {
  4876 + [''].map(() => {
  4877 + const commonViewDragableProps = {
  4878 + ...props,
  4879 + // comparedTableId: props.processTableId,
  4880 + hideTabsNav: true,
  4881 + comparedTableId: props.processTableId,
  4882 + // bSimpleMode: true,
  4883 + sParamData: [
  4884 + {
  4885 + sParamType: 'sWorkOrder',
  4886 + sParamName: '工单参数'
  4887 + },
  4888 + ],
  4889 + tableName: 'process',
  4890 + }
  4891 +
  4892 + commonViewDragableProps.enabled = getTableBtnState(commonViewDragableProps.tableName);
  4893 +
  4894 + return <CommonViewDragable {...commonViewDragableProps} />;
  4895 + })
  4896 + }
  4897 + </div>
  4898 + </Modal> : ''
  4899 +
  4900 +};
  4901 +
4788 4902 export default CommonBase(CommonSales(WorkOrderPackTableTreeNew));
... ...