Commit d200fd5fc3523c1e23cccdf45775cc924cbe3bdc
1 parent
dead33a3
1.AJT-MES 纸箱需要显示工单盒型数据
Showing
3 changed files
with
501 additions
and
41 deletions
src/components/Common/CommonTable/index.js
| ... | ... | @@ -10286,7 +10286,7 @@ class CommonTableRc extends React.Component { |
| 10286 | 10286 | } |
| 10287 | 10287 | |
| 10288 | 10288 | childTitle = ( |
| 10289 | - <div style={styleObj}> | |
| 10289 | + <div style={styleObj} title={`${column.tipTitle}`}> | |
| 10290 | 10290 | {editableSpan} |
| 10291 | 10291 | {childTitleContent} |
| 10292 | 10292 | </div> | ... | ... |
src/mes/common/commonModelComponent/index.js
| ... | ... | @@ -10,7 +10,9 @@ import { |
| 10 | 10 | Radio, |
| 11 | 11 | message, |
| 12 | 12 | Badge, |
| 13 | - Spin | |
| 13 | + Spin, | |
| 14 | + Row, | |
| 15 | + Col | |
| 14 | 16 | } from "antd"; |
| 15 | 17 | import * as commonUtils from "@/utils/utils"; |
| 16 | 18 | import * as commonConfig from "@/utils/config"; |
| ... | ... | @@ -28,6 +30,7 @@ import ChoosePalletComponent from "../choosePalletComponent"; |
| 28 | 30 | import CommonViewDragable from "@/components/Common/CommonViewDragable"; |
| 29 | 31 | import costomPageFun from "@/mes/costomPageFun"; |
| 30 | 32 | import ReportInfo from "@/mes/productionExec/noticeModal/reportInfoButton"; |
| 33 | +import BoxTypeDetail from "../../scheduledTasks/boxTypeDetail/boxTypeDetail"; | |
| 31 | 34 | |
| 32 | 35 | import styles from "./index.less"; |
| 33 | 36 | |
| ... | ... | @@ -227,7 +230,7 @@ const useCommonModelEvent = props => { |
| 227 | 230 | try { |
| 228 | 231 | delete tabConfigFilter[0].configList[0].children[1].configList[2]; |
| 229 | 232 | delete tabConfigFilter[0].configList[0].children[1].configList[1]; |
| 230 | - } catch (error) {} | |
| 233 | + } catch (error) { } | |
| 231 | 234 | } else if ( |
| 232 | 235 | iTeamType === 1 |
| 233 | 236 | // [ |
| ... | ... | @@ -248,7 +251,7 @@ const useCommonModelEvent = props => { |
| 248 | 251 | delete tabConfigFilter[0].configList[0].children[1].configList[3]; |
| 249 | 252 | delete tabConfigFilter[0].configList[0].children[1].configList[1]; |
| 250 | 253 | delete tabConfigFilter[0].configList[1].children[2].configList[7]; |
| 251 | - } catch (error) {} | |
| 254 | + } catch (error) { } | |
| 252 | 255 | } else { |
| 253 | 256 | tableListFilter = tableList.filter( |
| 254 | 257 | item => |
| ... | ... | @@ -260,7 +263,7 @@ const useCommonModelEvent = props => { |
| 260 | 263 | delete tabConfigFilter[0].configList[0].children[1].configList[3]; |
| 261 | 264 | delete tabConfigFilter[0].configList[0].children[1].configList[2]; |
| 262 | 265 | delete tabConfigFilter[0].configList[1].children[2].configList[7]; |
| 263 | - } catch (error) {} | |
| 266 | + } catch (error) { } | |
| 264 | 267 | } |
| 265 | 268 | return [tableListFilter, tabConfigFilter]; |
| 266 | 269 | }; |
| ... | ... | @@ -1473,12 +1476,12 @@ const TabTitleComponent = props => { |
| 1473 | 1476 | } |
| 1474 | 1477 | |
| 1475 | 1478 | |
| 1476 | - if (sTabName.split("_")[0] === "空" || sTabName.split("_")[0] === "Empty" ) return ""; | |
| 1479 | + if (sTabName.split("_")[0] === "空" || sTabName.split("_")[0] === "Empty") return ""; | |
| 1477 | 1480 | |
| 1478 | 1481 | const costomTitle = |
| 1479 | 1482 | props.costomTitle && sTabName === "下料信息" ? props.costomTitle : ""; |
| 1480 | 1483 | |
| 1481 | - const sTip = sTabName !== sTipName ? sTabName + '-' + sTipName : sTabName; | |
| 1484 | + const sTip = sTabName !== sTipName ? sTabName + '-' + sTipName : sTabName; | |
| 1482 | 1485 | |
| 1483 | 1486 | return ( |
| 1484 | 1487 | <div className="tabTitle" title={sTip}> |
| ... | ... | @@ -1491,7 +1494,7 @@ const TabTitleComponent = props => { |
| 1491 | 1494 | |
| 1492 | 1495 | // 表单组件 |
| 1493 | 1496 | const CommonViewTableComponent = props => { |
| 1494 | - const { sTabName, showType, sName, sEnglishTabName, } = props; | |
| 1497 | + const { sTabName, showType, sName, sEnglishTabName, } = props; | |
| 1495 | 1498 | if (showType !== "form") return ""; |
| 1496 | 1499 | |
| 1497 | 1500 | const { |
| ... | ... | @@ -1598,17 +1601,17 @@ const CommonViewTableComponent = props => { |
| 1598 | 1601 | }; |
| 1599 | 1602 | |
| 1600 | 1603 | |
| 1601 | - const [reportInfoVisible, setReportInfoVisible] = useState(false); | |
| 1602 | - const reportRef = useRef(null); | |
| 1604 | + const [reportInfoVisible, setReportInfoVisible] = useState(false); | |
| 1605 | + const reportRef = useRef(null); | |
| 1603 | 1606 | |
| 1604 | - const handleReportInfo = (config = null) => { | |
| 1605 | - reportRef.current = config; | |
| 1606 | - setReportInfoVisible(!reportInfoVisible); | |
| 1607 | + const handleReportInfo = (config = null) => { | |
| 1608 | + reportRef.current = config; | |
| 1609 | + setReportInfoVisible(!reportInfoVisible); | |
| 1607 | 1610 | }; |
| 1608 | 1611 | |
| 1609 | 1612 | |
| 1610 | 1613 | const sLanguage = props.app.userinfo?.sLanguage; |
| 1611 | - const sTabLocalName = sLanguage === 'sEnglish' ? sEnglishTabName : sTabName; | |
| 1614 | + const sTabLocalName = sLanguage === 'sEnglish' ? sEnglishTabName : sTabName; | |
| 1612 | 1615 | const groupListNew = sTabLocalName?.split(",") || []; |
| 1613 | 1616 | |
| 1614 | 1617 | const groupListChinese = sTabName?.split(",") || []; |
| ... | ... | @@ -1637,8 +1640,8 @@ const CommonViewTableComponent = props => { |
| 1637 | 1640 | handleReportInfo |
| 1638 | 1641 | }; |
| 1639 | 1642 | |
| 1640 | - if(viewProps.tableS0Data && viewProps.tableS0Data.length!==0){ | |
| 1641 | - viewProps.reportPeopleSelectedRowKeys = viewProps.tableS0Data[0].sMainAssistantTransId?.split(",") | |
| 1643 | + if (viewProps.tableS0Data && viewProps.tableS0Data.length !== 0) { | |
| 1644 | + viewProps.reportPeopleSelectedRowKeys = viewProps.tableS0Data[0].sMainAssistantTransId?.split(",") | |
| 1642 | 1645 | |
| 1643 | 1646 | } |
| 1644 | 1647 | |
| ... | ... | @@ -1648,14 +1651,14 @@ const CommonViewTableComponent = props => { |
| 1648 | 1651 | |
| 1649 | 1652 | return ( |
| 1650 | 1653 | <> |
| 1651 | - <TabTitleComponent {...props} sTabName={groupListNew[index]} sTipName = {groupListChinese[index] } /> | |
| 1654 | + <TabTitleComponent {...props} sTabName={groupListNew[index]} sTipName={groupListChinese[index]} /> | |
| 1652 | 1655 | <CommonViewTable {...viewProps} /> |
| 1653 | 1656 | <ReportInfo |
| 1654 | - reportInfoVisible={reportInfoVisible} | |
| 1655 | - handleReportInfo={handleReportInfo} | |
| 1656 | - {...props} | |
| 1657 | - reportRef={reportRef.current || {}} | |
| 1658 | - hasShowInfo={viewProps.viewRow} | |
| 1657 | + reportInfoVisible={reportInfoVisible} | |
| 1658 | + handleReportInfo={handleReportInfo} | |
| 1659 | + {...props} | |
| 1660 | + reportRef={reportRef.current || {}} | |
| 1661 | + hasShowInfo={viewProps.viewRow} | |
| 1659 | 1662 | /> |
| 1660 | 1663 | |
| 1661 | 1664 | |
| ... | ... | @@ -1682,7 +1685,8 @@ const CommonTableComponent = props => { |
| 1682 | 1685 | showType, |
| 1683 | 1686 | sName, |
| 1684 | 1687 | sEnglishTabName, |
| 1685 | - tableBtnsConfig: tableBtnsConfigOld = [] | |
| 1688 | + tableBtnsConfig: tableBtnsConfigOld = [], | |
| 1689 | + app, | |
| 1686 | 1690 | } = props; |
| 1687 | 1691 | if (showType !== "table") return ""; |
| 1688 | 1692 | |
| ... | ... | @@ -1863,7 +1867,7 @@ const CommonTableComponent = props => { |
| 1863 | 1867 | // }, |
| 1864 | 1868 | onTableBtnClick, |
| 1865 | 1869 | tableProps: { |
| 1866 | - onChange: () => {} | |
| 1870 | + onChange: () => { } | |
| 1867 | 1871 | // AutoTableHeight: 200 |
| 1868 | 1872 | }, |
| 1869 | 1873 | onViewClick: (tableName, sFieldName, record, index, config) => { |
| ... | ... | @@ -1897,14 +1901,46 @@ const CommonTableComponent = props => { |
| 1897 | 1901 | ...props, |
| 1898 | 1902 | sName |
| 1899 | 1903 | }; |
| 1900 | - const sLanguage = props.app.userinfo?.sLanguage; | |
| 1904 | + const sLanguage = props.app.userinfo?.sLanguage; | |
| 1901 | 1905 | |
| 1902 | - const sTabLocalName = sLanguage === 'sEnglish' ? sEnglishTabName : sTabName; | |
| 1906 | + const sTabLocalName = sLanguage === 'sEnglish' ? sEnglishTabName : sTabName; | |
| 1903 | 1907 | |
| 1908 | + const isPack = props.app.userinfo?.sBrandsId === '2222222222'; // 纸箱品牌 | |
| 1909 | + const bBoxShow = isPack && (sName === 'slave' || sName === 'control'); | |
| 1910 | + const { slaveData = [], enabled, controlData = [], slaveSelectedRowKeys = [], controlSelectedRowKeys = [] } = props; | |
| 1911 | + /* 计算imageBox */ | |
| 1904 | 1912 | return ( |
| 1905 | 1913 | <> |
| 1906 | - <TabTitleComponent {...props} sTabName={sTabLocalName } sTipName={sTabName } /> | |
| 1907 | - <StaticEditTable {...tableProps} /> | |
| 1914 | + <TabTitleComponent {...props} sTabName={sTabLocalName} sTipName={sTabName} /> | |
| 1915 | + { | |
| 1916 | + bBoxShow ? ( | |
| 1917 | + <Row gutter={[24, 0]}> | |
| 1918 | + <Col span={15} order={1}> | |
| 1919 | + <div className={[styles.slaveTabs, 'slave-tabs-container'].join(' ')} > | |
| 1920 | + <StaticEditTable {...tableProps} /> | |
| 1921 | + </div> | |
| 1922 | + </Col> | |
| 1923 | + <Col span={9} order={2}> | |
| 1924 | + <BoxTypeDetail | |
| 1925 | + slaveData={slaveData} | |
| 1926 | + controlData={controlData} | |
| 1927 | + slaveSelectedRowKeys={slaveSelectedRowKeys} | |
| 1928 | + controlSelectedRowKeys={controlSelectedRowKeys} | |
| 1929 | + onSaveState={props.onSaveState} | |
| 1930 | + enabled={enabled} | |
| 1931 | + iColValue={16} | |
| 1932 | + isPack={isPack} | |
| 1933 | + tableName={sName} | |
| 1934 | + parentProps={props} | |
| 1935 | + /> | |
| 1936 | + </Col> | |
| 1937 | + </Row> | |
| 1938 | + ) : '' | |
| 1939 | + } | |
| 1940 | + { | |
| 1941 | + !bBoxShow ? <StaticEditTable {...tableProps} /> : '' | |
| 1942 | + } | |
| 1943 | + | |
| 1908 | 1944 | <CommonOperationBarComponent {...operationBarProps} /> |
| 1909 | 1945 | <SwasterTypeTable |
| 1910 | 1946 | {...props} |
| ... | ... | @@ -1995,15 +2031,15 @@ const CommonRepairComponent = props => { |
| 1995 | 2031 | let bCenter = false; |
| 1996 | 2032 | |
| 1997 | 2033 | // OQC标签弹窗添加清空按钮 |
| 1998 | - const onEmptyClick = () =>{ | |
| 2034 | + const onEmptyClick = () => { | |
| 1999 | 2035 | setViewRow({ |
| 2000 | - ...viewRow, | |
| 2001 | - sAbnormalLine: '', | |
| 2002 | - sAbnormalType: '', | |
| 2003 | - sAbnormalMemo: '', | |
| 2004 | - sQcPerson: '', | |
| 2005 | - dSampQty: 0, | |
| 2006 | - bReturn: false | |
| 2036 | + ...viewRow, | |
| 2037 | + sAbnormalLine: '', | |
| 2038 | + sAbnormalType: '', | |
| 2039 | + sAbnormalMemo: '', | |
| 2040 | + sQcPerson: '', | |
| 2041 | + dSampQty: 0, | |
| 2042 | + bReturn: false | |
| 2007 | 2043 | }) |
| 2008 | 2044 | } |
| 2009 | 2045 | const titleNew = title === '异常信息' ? 'Abnormal Info' : title; |
| ... | ... | @@ -2018,10 +2054,10 @@ const CommonRepairComponent = props => { |
| 2018 | 2054 | className="mesCommonModal" |
| 2019 | 2055 | footer={ |
| 2020 | 2056 | <Space> |
| 2021 | - {/* // OQC标签弹窗添加清空按钮 */} | |
| 2022 | - { | |
| 2023 | - params.tableName=='slaveWyrj2'? <Button size="large" onClick={onEmptyClick}>Clear</Button> : null | |
| 2024 | - } | |
| 2057 | + {/* // OQC标签弹窗添加清空按钮 */} | |
| 2058 | + { | |
| 2059 | + params.tableName == 'slaveWyrj2' ? <Button size="large" onClick={onEmptyClick}>Clear</Button> : null | |
| 2060 | + } | |
| 2025 | 2061 | <Button size="large" onClick={onCancel}> |
| 2026 | 2062 | {BtnCancel} |
| 2027 | 2063 | </Button> |
| ... | ... | @@ -2209,7 +2245,7 @@ const RunningStatusConditionComponent = props => { |
| 2209 | 2245 | : table0SelectedRowKeys, |
| 2210 | 2246 | bMutiSelect: true, |
| 2211 | 2247 | tableProps: { |
| 2212 | - onChange: () => {} | |
| 2248 | + onChange: () => { } | |
| 2213 | 2249 | } |
| 2214 | 2250 | }; |
| 2215 | 2251 | ... | ... |
src/mes/scheduledTasks/boxTypeDetail/boxTypeDetail.js
0 → 100644
| 1 | +import React, { useEffect, useMemo, useState } from 'react'; | |
| 2 | +import { Row, Col, Divider, Tooltip, InputNumber, Carousel, Image, Modal } from 'antd'; | |
| 3 | +import * as commonUtils from "@/utils/utils"; | |
| 4 | +import * as commonConfig from "@/utils/config"; | |
| 5 | +import * as commonFunc from "@/components/Common/commonFunc"; | |
| 6 | + | |
| 7 | +const evaluateFormula = (formula, variables) => { | |
| 8 | + if (!formula) return 0; | |
| 9 | + try { | |
| 10 | + const variableNames = formula.match(/\b[a-zA-Z_][a-zA-Z0-9_]*\b/g) || []; | |
| 11 | + const params = variableNames.join(",") + ",Math"; | |
| 12 | + const func = new Function(params, `return ${formula}`); | |
| 13 | + const args = variableNames.map(name => Number(variables[name]) || 0); | |
| 14 | + return func(...args, Math); | |
| 15 | + } catch (error) { | |
| 16 | + console.error("公式执行错误", error); | |
| 17 | + return Number(formula) || 0; | |
| 18 | + } | |
| 19 | +}; | |
| 20 | + | |
| 21 | +const removeExtension = (filename) => { | |
| 22 | + if (!filename) return ''; | |
| 23 | + const lastDotIndex = filename.lastIndexOf('.'); | |
| 24 | + return lastDotIndex === -1 ? filename : filename.substring(0, lastDotIndex); | |
| 25 | +}; | |
| 26 | + | |
| 27 | +const getImageUrl = (sName) => { | |
| 28 | + console.log('getImageUrl', sName); | |
| 29 | + return `${commonConfig.server_host}file/downloadPrice?sLogoName=${sName}&date=${new Date().getTime()}`; | |
| 30 | +}; | |
| 31 | + | |
| 32 | +const CuttingComponent = (props) => { | |
| 33 | + const { selectedRowIndex, slaveData, onSaveState } = props; | |
| 34 | + const PrintSize = commonFunc.showLocalMessage(props, "PrintSize", "印刷尺寸"); | |
| 35 | + const insert = commonFunc.showLocalMessage(props, "insert", "插入"); | |
| 36 | + const imposition = commonFunc.showLocalMessage(props, "imposition", "拼版"); | |
| 37 | + const mouthpiece = commonFunc.showLocalMessage(props, "mouthpiece", "叼口"); | |
| 38 | + const trailingEdge = commonFunc.showLocalMessage(props, "trailingEdge", "拖梢"); | |
| 39 | + const SheetSize = commonFunc.showLocalMessage(props, "SheetSize", "印张尺寸"); | |
| 40 | + const cutting = commonFunc.showLocalMessage(props, "cutting", "分切"); | |
| 41 | + const edgeTrimming = commonFunc.showLocalMessage(props, "edgeTrimmings", "修边"); | |
| 42 | + const MaterialSpecifications = commonFunc.showLocalMessage(props, "MaterialSpecifications", "材料规格"); | |
| 43 | + const length = commonFunc.showLocalMessage(props, "length", "长"); | |
| 44 | + const width = commonFunc.showLocalMessage(props, "width", "宽"); | |
| 45 | + | |
| 46 | + const lengthFormula = length + '( |-|)*| +(|+| )=|*|+|='; | |
| 47 | + const widthFormula = width + '( |-|)*| +(|+| )=|*|+|='; | |
| 48 | + const lengthFormulaList = lengthFormula.split('|'); | |
| 49 | + const widthFormulaList = widthFormula.split('|'); | |
| 50 | + | |
| 51 | + const titleList = [ | |
| 52 | + PrintSize, insert, imposition, mouthpiece, trailingEdge, | |
| 53 | + SheetSize, cutting, edgeTrimming, MaterialSpecifications, | |
| 54 | + ]; | |
| 55 | + | |
| 56 | + if (!slaveData || !slaveData[selectedRowIndex]) return null; | |
| 57 | + const slaveRowData = slaveData[selectedRowIndex]; | |
| 58 | + const { boxLengthList = [], boxWidthList = [] } = slaveRowData; | |
| 59 | + | |
| 60 | + return ( | |
| 61 | + <div className="cuttingComponent"> | |
| 62 | + <div className="title"> | |
| 63 | + {titleList.map((item, i) => ( | |
| 64 | + <div key={i} style={{ width: '9%', textAlign: 'center', fontSize: '12px' }}>{item}</div> | |
| 65 | + ))} | |
| 66 | + </div> | |
| 67 | + | |
| 68 | + <div className="title"> | |
| 69 | + {boxLengthList.map((item, index) => ( | |
| 70 | + <InputNumber | |
| 71 | + key={item.id || index} | |
| 72 | + value={item.value} | |
| 73 | + controls={false} | |
| 74 | + style={{ width: '9%', height: '26px' }} | |
| 75 | + onChange={(val) => { | |
| 76 | + const list = [...boxLengthList]; | |
| 77 | + list[index].value = Number(val) || 0; | |
| 78 | + list[5].value = (list[0].value - list[1].value) * list[2].value + (list[3].value + list[4].value); | |
| 79 | + list[list.length - 1].value = list[5].value * list[6].value + list[7].value; | |
| 80 | + slaveData[selectedRowIndex] = { | |
| 81 | + ...slaveData[selectedRowIndex], | |
| 82 | + boxLengthList: list, | |
| 83 | + dBoxLengthSum: list[list.length - 1]?.value, | |
| 84 | + dBoxLengthSumPqty: list[2]?.value, | |
| 85 | + }; | |
| 86 | + onSaveState({ slaveData }); | |
| 87 | + }} | |
| 88 | + /> | |
| 89 | + ))} | |
| 90 | + </div> | |
| 91 | + | |
| 92 | + <div className="text"> | |
| 93 | + <div className="title"> | |
| 94 | + {lengthFormulaList.map((item, i) => ( | |
| 95 | + <div key={i} style={{ width: '9%', transform: i === 0 ? 'translateX(-10px)' : i === 3 ? 'translateX(-3px)' : '' }}>{item}</div> | |
| 96 | + ))} | |
| 97 | + </div> | |
| 98 | + </div> | |
| 99 | + | |
| 100 | + <div className="title" style={{ marginTop: '8px' }}> | |
| 101 | + {boxWidthList.map((item, index) => ( | |
| 102 | + <InputNumber | |
| 103 | + key={item.id || index} | |
| 104 | + value={item.value} | |
| 105 | + controls={false} | |
| 106 | + style={{ width: '9%', height: '26px' }} | |
| 107 | + onChange={(val) => { | |
| 108 | + const list = [...boxWidthList]; | |
| 109 | + list[index].value = Number(val) || 0; | |
| 110 | + list[5].value = (list[0].value - list[1].value) * list[2].value + (list[3].value + list[4].value); | |
| 111 | + list[list.length - 1].value = list[5].value * list[6].value + list[7].value; | |
| 112 | + slaveData[selectedRowIndex] = { | |
| 113 | + ...slaveData[selectedRowIndex], | |
| 114 | + boxWidthList: list, | |
| 115 | + dBoxWidthSum: list[list.length - 1]?.value, | |
| 116 | + dBoxWidthSumPqty: list[2]?.value, | |
| 117 | + }; | |
| 118 | + onSaveState({ slaveData }); | |
| 119 | + }} | |
| 120 | + /> | |
| 121 | + ))} | |
| 122 | + </div> | |
| 123 | + | |
| 124 | + <div className="text" style={{ top: '54px' }}> | |
| 125 | + <div className="title"> | |
| 126 | + {widthFormulaList.map((item, i) => ( | |
| 127 | + <div key={i} style={{ width: '9%', transform: i === 0 ? 'translateX(-10px)' : i === 3 ? 'translateX(-3px)' : '' }}>{item}</div> | |
| 128 | + ))} | |
| 129 | + </div> | |
| 130 | + </div> | |
| 131 | + </div> | |
| 132 | + ); | |
| 133 | +}; | |
| 134 | + | |
| 135 | +export default function BoxTypeDetail(props) { | |
| 136 | + const { | |
| 137 | + slaveData, | |
| 138 | + controlData, | |
| 139 | + slaveSelectedRowKeys, | |
| 140 | + controlSelectedRowKeys, | |
| 141 | + onSaveState, | |
| 142 | + enabled = true, | |
| 143 | + sOrderCategoryId, | |
| 144 | + processShowLeft, | |
| 145 | + isPack, | |
| 146 | + parentProps, | |
| 147 | + } = props; | |
| 148 | + if(commonUtils.isEmptyArr(slaveData)) return null; | |
| 149 | + | |
| 150 | + // 使用 useMemo 缓存,避免每次渲染创建新引用 | |
| 151 | + const slaveSelectedRowKeysData = useMemo(() => { | |
| 152 | + return slaveData.find(item => slaveSelectedRowKeys?.includes(item.sId)) || slaveData[0]; | |
| 153 | + }, [slaveData, slaveSelectedRowKeys]); | |
| 154 | + | |
| 155 | + const slaveSelectedRowKeysId = slaveSelectedRowKeysData.sId; | |
| 156 | + const selectRowIndex = slaveData ? slaveData.findIndex(x => x.sId === slaveSelectedRowKeysId) : -1; | |
| 157 | + | |
| 158 | + // 使用 useMemo 缓存,避免每次渲染创建新引用 | |
| 159 | + const selectRow = useMemo(() => { | |
| 160 | + if (!slaveData || selectRowIndex < 0) return slaveData[0]; | |
| 161 | + return slaveData[selectRowIndex]; | |
| 162 | + }, [slaveData, selectRowIndex]); | |
| 163 | + | |
| 164 | + const [boxMaxModalVisible, setBoxMaxModalVisible] = useState(false); | |
| 165 | + const [boxList, setBoxList] = useState([]); | |
| 166 | + const [offsetXList, setOffsetXList] = useState([]); | |
| 167 | + const [offsetYList, setOffsetYList] = useState([]); | |
| 168 | + | |
| 169 | + // 使用 useMemo 缓存,避免每次渲染解析 JSON | |
| 170 | + const sBoxInfo = useMemo(() => { | |
| 171 | + if (!selectRow?.sBoxInfo || !commonUtils.isJSON(selectRow.sBoxInfo)) return []; | |
| 172 | + try { | |
| 173 | + return JSON.parse(selectRow.sBoxInfo); | |
| 174 | + } catch (e) { | |
| 175 | + return []; | |
| 176 | + } | |
| 177 | + }, [selectRow?.sBoxInfo]); | |
| 178 | + | |
| 179 | + const selectRowData = useMemo(() => { | |
| 180 | + return { ...selectRow, ...sBoxInfo[0] }; | |
| 181 | +}, [selectRow, sBoxInfo]); | |
| 182 | + | |
| 183 | + | |
| 184 | + // 使用 useMemo 缓存,确保引用稳定 | |
| 185 | + const upAbleConfigsExtra = useMemo(() => { | |
| 186 | + return commonUtils.isNotEmptyArr(sBoxInfo) ? sBoxInfo[0].upAbleConfigsExtra : ''; | |
| 187 | + }, [sBoxInfo]); | |
| 188 | + | |
| 189 | + | |
| 190 | + const bSelectBox = selectRowData.bSelectBox; | |
| 191 | + | |
| 192 | + useEffect(() => { | |
| 193 | + if (!upAbleConfigsExtra) return; | |
| 194 | + let slaveNewData = []; | |
| 195 | + try { | |
| 196 | + slaveNewData = JSON.parse(upAbleConfigsExtra.sColumnNameConfig || '[]'); | |
| 197 | + } catch (e) {} | |
| 198 | + | |
| 199 | + const { slaveRowData = {} } = slaveSelectedRowKeysData; | |
| 200 | + const L = Number(slaveSelectedRowKeysData.dProductLength) || 0; | |
| 201 | + const W = Number(slaveSelectedRowKeysData.dProductWidth) || 0; | |
| 202 | + const D = Number(slaveSelectedRowKeysData.dProductHeight) || 0; | |
| 203 | + | |
| 204 | + const titleList1 = [ | |
| 205 | + { name: "上方盒舌", value: "dSFHS" }, | |
| 206 | + { name: "盒底组件", value: "dHDC" }, | |
| 207 | + { name: "下方盒舌", value: "dXFHS" }, | |
| 208 | + { name: "左(上)插位组件", value: "dZSCW" }, | |
| 209 | + { name: "左贴边位", value: "dZTBW" }, | |
| 210 | + { name: "左(下)插位组件", value: "dZXCW" }, | |
| 211 | + { name: "右(上)插位组件", value: "dYSCW" }, | |
| 212 | + { name: "右贴边位", value: "dYTBW" }, | |
| 213 | + { name: "右(下)插位组件", value: "dYXCW" }, | |
| 214 | + { name: "压线", value: "dYx" }, | |
| 215 | + ]; | |
| 216 | + | |
| 217 | + const tables = [ | |
| 218 | + { name: "盒型类别", value: slaveRowData.sBoxType, type: null }, | |
| 219 | + { name: "盒身", value: slaveRowData.sBoxBody, type: slaveRowData.sTypes }, | |
| 220 | + { name: "盒长", value: L, type: null }, | |
| 221 | + { name: "盒宽", value: W, type: null }, | |
| 222 | + { name: "盒高", value: D, type: null }, | |
| 223 | + ]; | |
| 224 | + | |
| 225 | + const variables = { L, W, H: W, D, ...slaveRowData }; | |
| 226 | + const newBoxList = []; | |
| 227 | + | |
| 228 | + slaveNewData.forEach(x => { | |
| 229 | + let key = 0; | |
| 230 | + if (x.sAssignFormula) { | |
| 231 | + key = evaluateFormula(x.sAssignFormula, variables); | |
| 232 | + slaveRowData[x.sName] = key; | |
| 233 | + } else { | |
| 234 | + if (x.sTypes && x.sTypes.includes('09')) { | |
| 235 | + if (x.sName === 'dZTBW' || x.sName === 'dYTBW') { | |
| 236 | + key = Number(x.iSLength || 0) + Number(x.iCLength || 0); | |
| 237 | + } else { | |
| 238 | + key = Number(x.iSWidth || 0) + Number(x.iCWidth || 0); | |
| 239 | + } | |
| 240 | + } else { | |
| 241 | + key = slaveRowData[x.sName]; | |
| 242 | + } | |
| 243 | + } | |
| 244 | + newBoxList.push({ | |
| 245 | + value: key, | |
| 246 | + sName: titleList1.find(i => i.value === x.sName)?.name || '', | |
| 247 | + sCode: x.sName, | |
| 248 | + type: x.sTypes, | |
| 249 | + showName: x.showName, | |
| 250 | + ...x, | |
| 251 | + }); | |
| 252 | + }); | |
| 253 | + | |
| 254 | + tables.forEach(t => newBoxList.push(t)); | |
| 255 | + setBoxList(newBoxList); | |
| 256 | + }, [upAbleConfigsExtra, slaveSelectedRowKeysData]); | |
| 257 | + | |
| 258 | + useEffect(() => { | |
| 259 | + if (!upAbleConfigsExtra || !selectRowData) return; | |
| 260 | + let configData = []; | |
| 261 | + try { | |
| 262 | + configData = JSON.parse(upAbleConfigsExtra.sColumnNameConfig || '[]'); | |
| 263 | + } catch (e) {} | |
| 264 | + | |
| 265 | + const xList = selectRowData.controlSelectedRowBoxXList || []; | |
| 266 | + const yList = selectRowData.controlSelectedRowBoxYList || []; | |
| 267 | + | |
| 268 | + const ox = xList.map(item => { | |
| 269 | + const d = configData.find(c => c.sName === item.id) || {}; | |
| 270 | + return { x: d.dX || 0, y: d.dY || 0, id: item.id, value: item.value }; | |
| 271 | + }); | |
| 272 | + | |
| 273 | + const oy = yList.map(item => { | |
| 274 | + const d = configData.find(c => c.sName === item.id) || {}; | |
| 275 | + return { x: d.dX || 0, y: d.dY || 0, id: item.id, value: item.value }; | |
| 276 | + }); | |
| 277 | + | |
| 278 | + if (ox.length) ox[9].value = ox.slice(0, 9).reduce((a, b) => a + b.value, 0); | |
| 279 | + if (oy.length) oy[9].value = oy.slice(0, 9).reduce((a, b) => a + b.value, 0); | |
| 280 | + | |
| 281 | + setOffsetXList(ox); | |
| 282 | + setOffsetYList(oy); | |
| 283 | + }, [upAbleConfigsExtra, selectRowData]); | |
| 284 | + | |
| 285 | + // 数据是查看用的,不需要更新状态,移除可能导致死循环的 useEffect | |
| 286 | + | |
| 287 | + const imagesData = useMemo(() => { | |
| 288 | + if (!upAbleConfigsExtra) return []; | |
| 289 | + return [{ src: getImageUrl(removeExtension(upAbleConfigsExtra.sPackPath)), alt: "立体图" }]; | |
| 290 | + }, [upAbleConfigsExtra?.sPackPath]); | |
| 291 | + | |
| 292 | + | |
| 293 | + const boxSizeImage = useMemo(() => { | |
| 294 | + if (!upAbleConfigsExtra) return ''; | |
| 295 | + return getImageUrl(removeExtension(upAbleConfigsExtra.sPackDetailPathUpLoad)); | |
| 296 | + }, [upAbleConfigsExtra?.sPackDetailPathUpLoad]); | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + const BoxDetails = commonFunc.showLocalMessage(parentProps, "BoxDetail", "盒型详情"); | |
| 301 | + const noData = commonFunc.showLocalMessage(parentProps, 'noData', 'No Data'); | |
| 302 | + const TransversePressure = commonFunc.showLocalMessage(parentProps, "TransversePressure", "横压"); | |
| 303 | + const longitudinalPressure = commonFunc.showLocalMessage(parentProps, "longitudinalPressure", "纵压"); | |
| 304 | + const { controlSelectedRowBoxXList = [], controlSelectedRowBoxYList = [] } = selectRowData; | |
| 305 | + const boxType = false; | |
| 306 | + return ( | |
| 307 | + <> | |
| 308 | + <Modal open={boxMaxModalVisible} onCancel={() => setBoxMaxModalVisible(false)} footer={null} width={800}> | |
| 309 | + <Image src={boxSizeImage} style={{ width: '100%' }} /> | |
| 310 | + </Modal> | |
| 311 | + | |
| 312 | + | |
| 313 | + {isPack ? ( | |
| 314 | + <Row gutter={[8, 0]}> | |
| 315 | + <Col span={24 - (processShowLeft?.iColValue || 16)} order={2}> | |
| 316 | + {boxSizeImage === '' ? ( | |
| 317 | + <div style={{ width: '100%', height: '100%', position: 'relative' }}> | |
| 318 | + <Divider className="workOrderDivider" orientation="center">{BoxDetails}</Divider> | |
| 319 | + <div style={{ textAlign: 'center', fontSize: 12, position: 'absolute', bottom: 0, left: '50%', transform: 'translateX(-50%)' }}>{noData}</div> | |
| 320 | + </div> | |
| 321 | + ) : props.tableName === 'slave' && ( | |
| 322 | + <div style={{ paddingBottom: '20px' }}> | |
| 323 | + <div style={{ height: 200, display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}> | |
| 324 | + <div style={{ width: 300, height: 200, position: 'relative' }} id="imageRefId"> | |
| 325 | + <img src={boxSizeImage} style={{ width: 300, height: 200 }} onClick={() => setBoxMaxModalVisible(true)} /> | |
| 326 | + {offsetXList.map((item, i) => ( | |
| 327 | + <div key={i} style={{ position: 'absolute', left: item.x, bottom: item.y, fontSize: 10, color: 'red' }}> | |
| 328 | + {item.value > 0 ? item.value : ''} | |
| 329 | + </div> | |
| 330 | + ))} | |
| 331 | + {offsetYList.map((item, i) => ( | |
| 332 | + <div key={i} style={{ position: 'absolute', left: item.x, bottom: item.y, fontSize: 10, color: 'red' }}> | |
| 333 | + {item.value > 0 ? item.value : ''} | |
| 334 | + </div> | |
| 335 | + ))} | |
| 336 | + </div> | |
| 337 | + | |
| 338 | + <div style={{ width: '300px', height: 200 }}> | |
| 339 | + <Carousel dots style={{ width: '300px', height: 200 }}> | |
| 340 | + {imagesData.map((im, i) => ( | |
| 341 | + <div key={i} className="carousel-item"> | |
| 342 | + <Image src={im.src} style={{ width: '100%', height: 200 }} /> | |
| 343 | + </div> | |
| 344 | + ))} | |
| 345 | + </Carousel> | |
| 346 | + </div> | |
| 347 | + </div> | |
| 348 | + | |
| 349 | + {!boxType && boxList.length > 0 && ( | |
| 350 | + <div style={{ height: '12px', lineHeight: '12px', width: '100%', display: 'flex', gap: '2px', marginTop: '6px', marginBottom: '2px', alignItems: 'center' }}> | |
| 351 | + <Tooltip title={TransversePressure}> | |
| 352 | + <div style={{ whiteSpace: 'nowrap', fontSize: '14px', fontWeight: 'bold', width:'145px' }}>{TransversePressure}:</div> | |
| 353 | + </Tooltip> | |
| 354 | + <div style={{ display: 'flex', flex: 1, gap: '2px' }}> | |
| 355 | + {controlSelectedRowBoxYList?.map((cfg, i) => ( | |
| 356 | + <InputNumber | |
| 357 | + key={cfg.id} | |
| 358 | + value={cfg.value} | |
| 359 | + style={{ flex: 1, minWidth: '45px', fontSize: '14px', fontWeight: 'bold' }} | |
| 360 | + controls={false} | |
| 361 | + disabled={!enabled} | |
| 362 | + onChange={(val) => { | |
| 363 | + const list = controlSelectedRowBoxYList.map((it, idx) => idx === i ? { ...it, value: val } : it); | |
| 364 | + list[9].value = list.slice(0, 9).reduce((a, b) => a + b.value, 0); | |
| 365 | + const newSlave = [...slaveData]; | |
| 366 | + newSlave[selectRowIndex] = { | |
| 367 | + ...newSlave[selectRowIndex], | |
| 368 | + controlSelectedRowBoxYList: list, | |
| 369 | + dMaterialsWidth: list[9].value, | |
| 370 | + }; | |
| 371 | + onSaveState({ slaveData: newSlave }); | |
| 372 | + }} | |
| 373 | + /> | |
| 374 | + ))} | |
| 375 | + </div> | |
| 376 | + </div> | |
| 377 | + )} | |
| 378 | + | |
| 379 | + {!boxType && boxList.length > 0 && ( | |
| 380 | + <div style={{ height: '22px', lineHeight: '22px', width: '100%', display: 'flex', gap: '2px', marginTop: '10px', marginBottom: '2px', alignItems: 'center' }}> | |
| 381 | + <Tooltip title={longitudinalPressure}> | |
| 382 | + <div style={{ whiteSpace: 'nowrap', fontSize: '14px', fontWeight: 'bold', width:'145px' }}>{longitudinalPressure}:</div> | |
| 383 | + </Tooltip> | |
| 384 | + <div style={{ display: 'flex', flex: 1, gap: '2px' }}> | |
| 385 | + {controlSelectedRowBoxXList?.map((cfg, i) => ( | |
| 386 | + <InputNumber | |
| 387 | + key={cfg.id} | |
| 388 | + value={cfg.value} | |
| 389 | + style={{ flex: 1, minWidth: '45px', fontSize: '14px', fontWeight: 'bold' }} | |
| 390 | + controls={false} | |
| 391 | + disabled={!enabled} | |
| 392 | + onChange={(val) => { | |
| 393 | + const list = controlSelectedRowBoxXList.map((it, idx) => idx === i ? { ...it, value: val } : it); | |
| 394 | + list[9].value = list.slice(0, 9).reduce((a, b) => a + b.value, 0); | |
| 395 | + const newSlave = [...slaveData]; | |
| 396 | + newSlave[selectRowIndex] = { | |
| 397 | + ...newSlave[selectRowIndex], | |
| 398 | + controlSelectedRowBoxXList: list, | |
| 399 | + dMaterialsLength: list[9].value, | |
| 400 | + }; | |
| 401 | + onSaveState({ slaveData: newSlave }); | |
| 402 | + }} | |
| 403 | + /> | |
| 404 | + ))} | |
| 405 | + </div> | |
| 406 | + </div> | |
| 407 | + )} | |
| 408 | + | |
| 409 | + {sOrderCategoryId === '17581757610008020076844948336000' && boxList.length > 0 && ( | |
| 410 | + <CuttingComponent | |
| 411 | + {...parentProps} | |
| 412 | + selectedRowIndex={selectRowIndex} | |
| 413 | + slaveData={slaveData} | |
| 414 | + onSaveState={onSaveState} | |
| 415 | + /> | |
| 416 | + )} | |
| 417 | + </div> | |
| 418 | + )} | |
| 419 | + </Col> | |
| 420 | + </Row> | |
| 421 | + ) : null} | |
| 422 | + </> | |
| 423 | + ); | |
| 424 | +} | ... | ... |