Commit 5c636474d23825b2cabf198b0e1a84b2134b37c9
1 parent
3a9c918b
优化快速报价功能;
Showing
1 changed file
with
75 additions
and
30 deletions
src/components/QuickQuote/index.jsx
| ... | ... | @@ -167,12 +167,15 @@ const QuickQuoteEvent = props => { |
| 167 | 167 | }; |
| 168 | 168 | |
| 169 | 169 | addState.onDataChange = (name, sFieldName, changeValue, sId, dropDownData, isWait) => { |
| 170 | - const { masterData = {}, slaveData = [], selectedNode = {} } = state; | |
| 170 | + const { masterData = {}, slaveData = [], selectedNode = {}, manyData = [] } = state; | |
| 171 | 171 | const extraState = { |
| 172 | 172 | calcPriceFinished: false, |
| 173 | - manyData: [], | |
| 174 | 173 | }; |
| 175 | 174 | |
| 175 | + if (manyData.some(item => Object.keys(item).length > 4)) { | |
| 176 | + extraState.manyData = []; | |
| 177 | + } | |
| 178 | + | |
| 176 | 179 | if (name === "master") { |
| 177 | 180 | const masterDataNew = { ...masterData, ...changeValue }; |
| 178 | 181 | masterDataNew.handleType = masterDataNew.handleType || "update"; |
| ... | ... | @@ -954,6 +957,17 @@ const QuickQuoteEvent = props => { |
| 954 | 957 | } |
| 955 | 958 | }; |
| 956 | 959 | |
| 960 | + // 获取国际化名称 | |
| 961 | + const getI18nName = (sFieldName, sDefault) => { | |
| 962 | + return commonFunc.showMessage(props.app?.commonConst, sFieldName) || sDefault; | |
| 963 | + }; | |
| 964 | + | |
| 965 | + addState.getI18nName = getI18nName; | |
| 966 | + | |
| 967 | + addState.getI18nNameList = (...list) => { | |
| 968 | + return list.map(item => getI18nName(...item)); | |
| 969 | + }; | |
| 970 | + | |
| 957 | 971 | return { |
| 958 | 972 | ...props, |
| 959 | 973 | onDataChange0: props.onDataChange, |
| ... | ... | @@ -1037,6 +1051,19 @@ const TreeComponent = props => { |
| 1037 | 1051 | |
| 1038 | 1052 | const timeRef = useRef(0); |
| 1039 | 1053 | |
| 1054 | + // 摊平数组 | |
| 1055 | + const flattenArray = arr => { | |
| 1056 | + return arr.reduce((result, item) => { | |
| 1057 | + // 如果存在 children,则递归处理 | |
| 1058 | + if (item.children && item.children.length > 0) { | |
| 1059 | + result.push(...flattenArray(item.children)); | |
| 1060 | + } else { | |
| 1061 | + result.push(item); | |
| 1062 | + } | |
| 1063 | + return result; | |
| 1064 | + }, []); | |
| 1065 | + }; | |
| 1066 | + | |
| 1040 | 1067 | // 点击节点后查询数据 |
| 1041 | 1068 | useEffect(() => { |
| 1042 | 1069 | if (!selectedNode.sId || commonUtils.isEmptyObject(slaveConfig)) return; |
| ... | ... | @@ -1126,10 +1153,15 @@ const TreeComponent = props => { |
| 1126 | 1153 | props.setState(pre => { |
| 1127 | 1154 | const { masterData = {} } = pre; |
| 1128 | 1155 | const { sProductName, sProductUnit } = masterData; |
| 1156 | + const showNameList = [...flattenArray(treeData).map(item => item.showName), ""]; | |
| 1129 | 1157 | return { |
| 1130 | 1158 | ...pre, |
| 1131 | 1159 | selectedNode: select.selectedNodes[0]?.treeNode || {}, |
| 1132 | - masterData: { ...masterData, sProductName: sProductName || select.node.title, sProductUnit: sProductUnit || select.node.treeNode.sUnit }, | |
| 1160 | + masterData: { | |
| 1161 | + ...masterData, | |
| 1162 | + sProductName: showNameList.includes(sProductName) ? select.node.title : sProductName, | |
| 1163 | + sProductUnit: sProductUnit || select.node.treeNode.sUnit, | |
| 1164 | + }, | |
| 1133 | 1165 | }; |
| 1134 | 1166 | }); |
| 1135 | 1167 | }} |
| ... | ... | @@ -1145,7 +1177,7 @@ const TreeComponent = props => { |
| 1145 | 1177 | // 内容组件 |
| 1146 | 1178 | const ContentComponent = props => { |
| 1147 | 1179 | const { selectedNode = {}, extraParts = {} } = props.state; |
| 1148 | - const manyqtysInfo = commonUtils.isNotEmptyObject(props.app) ? commonFunc.showMessage(props.app.commonConst, "manyqtysInfo") : "多数量报价"; | |
| 1180 | + const manyqtysInfo = props.getI18nName("manyqtysInfo", "多数量报价"); | |
| 1149 | 1181 | const { showName } = selectedNode; |
| 1150 | 1182 | const extraPartsList = extraParts[showName] || []; |
| 1151 | 1183 | let { sAllPartsName = "" } = selectedNode; |
| ... | ... | @@ -1429,12 +1461,11 @@ const BoxComponent = props => { |
| 1429 | 1461 | default: x => x.sName === "sMagnification" || x.sName === "dPartsLength" || x.sName === "dPartsWidth", |
| 1430 | 1462 | }; |
| 1431 | 1463 | |
| 1432 | - | |
| 1433 | - if (selectedNode.sTypeKey === "juantong") { | |
| 1434 | - upViewProps12.viewConfigs = upViewProps12.viewConfigs.filter(filterConditions.juantong); | |
| 1435 | - } else if (!(selectedNode.sTypeKey === "huace" && slaveRowData.sBoxModel === "封面")) { | |
| 1436 | - upViewProps12.viewConfigs = upViewProps12.viewConfigs.filter(filterConditions.default); | |
| 1437 | - } | |
| 1464 | + if (selectedNode.sTypeKey === "juantong") { | |
| 1465 | + upViewProps12.viewConfigs = upViewProps12.viewConfigs.filter(filterConditions.juantong); | |
| 1466 | + } else if (!(selectedNode.sTypeKey === "huace" && slaveRowData.sBoxModel === "封面")) { | |
| 1467 | + upViewProps12.viewConfigs = upViewProps12.viewConfigs.filter(filterConditions.default); | |
| 1468 | + } | |
| 1438 | 1469 | // 拼板信息表单 |
| 1439 | 1470 | const upViewProps20 = getUpViewPropsByITag(20); |
| 1440 | 1471 | |
| ... | ... | @@ -1852,9 +1883,7 @@ const BoxComponent = props => { |
| 1852 | 1883 | showNew: 1, |
| 1853 | 1884 | }; |
| 1854 | 1885 | const isShowImg = boxList.find(x => x.sName === "盒身")?.type !== "" || false; |
| 1855 | - const PrintingParameters = commonUtils.isNotEmptyObject(props.app) | |
| 1856 | - ? commonFunc.showMessage(props.app.commonConst, "PrintingParameters") | |
| 1857 | - : "印刷参数"; | |
| 1886 | + const PrintingParameters = props.getI18nName("PrintingParameters", "印刷参数"); | |
| 1858 | 1887 | |
| 1859 | 1888 | return ( |
| 1860 | 1889 | <Tabs |
| ... | ... | @@ -2123,7 +2152,7 @@ const PrintParamsComponent = props => { |
| 2123 | 2152 | // 材料组件 |
| 2124 | 2153 | const MaterialsComponent = props => { |
| 2125 | 2154 | const { state, slaveRowData, boxModel } = props; |
| 2126 | - const { slaveConfig, slaveData = [], selectedNode = {} } = state; | |
| 2155 | + const { slaveConfig, slaveData = [], selectedNode = {}, manyData = [] } = state; | |
| 2127 | 2156 | const { sParam = "" } = selectedNode; |
| 2128 | 2157 | const sParamList = sParam.split(","); |
| 2129 | 2158 | const materialsInfoDefaultData = sParam ? new Array(sParamList.length).fill({}).map((_, index) => ({ showName: sParamList[index] })) : [{}]; |
| ... | ... | @@ -2152,9 +2181,12 @@ const MaterialsComponent = props => { |
| 2152 | 2181 | |
| 2153 | 2182 | const extraState = { |
| 2154 | 2183 | calcPriceFinished: false, |
| 2155 | - manyData: [], | |
| 2156 | 2184 | }; |
| 2157 | 2185 | |
| 2186 | + if (manyData.some(item => Object.keys(item).length > 4)) { | |
| 2187 | + extraState.manyData = []; | |
| 2188 | + } | |
| 2189 | + | |
| 2158 | 2190 | return materialsInfo.map((item, index) => { |
| 2159 | 2191 | let viewRow = { ...materialsInfo[index], sProductClassifyId: selectedNode.sId }; |
| 2160 | 2192 | viewRow = { ...viewRow, sMaterialsName0: viewRow.showName || "" }; |
| ... | ... | @@ -2248,19 +2280,14 @@ const ManyComponent = props => { |
| 2248 | 2280 | const [submitLoading, setSubmitLoading] = useState(false); |
| 2249 | 2281 | const [processPercent, setProcessPercent] = useState(0); |
| 2250 | 2282 | |
| 2251 | - const BtnNewQuotation = commonUtils.isNotEmptyObject(props.app) ? commonFunc.showMessage(props.app.commonConst, "BtnNewQuotation") : "新报价"; | |
| 2252 | - | |
| 2253 | - const BtnDraft = commonUtils.isNotEmptyObject(props.app) ? commonFunc.showMessage(props.app.commonConst, "BtnDraft") : "存草稿"; | |
| 2254 | - | |
| 2255 | - const BtnPriceverification = commonUtils.isNotEmptyObject(props.app) | |
| 2256 | - ? commonFunc.showMessage(props.app.commonConst, "BtnPriceverification") | |
| 2257 | - : "核价"; | |
| 2258 | - | |
| 2259 | - const BtnConfirmQuantity = commonUtils.isNotEmptyObject(props.app) | |
| 2260 | - ? commonFunc.showMessage(props.app.commonConst, "BtnConfirmQuantity") | |
| 2261 | - : "确认下单数量"; | |
| 2262 | - | |
| 2263 | - const btnOrdering = commonUtils.isNotEmptyObject(props.app) ? commonFunc.showMessage(props.app.commonConst, "btnOrdering") : "下单中..."; | |
| 2283 | + const [BtnNewQuotation, BtnDraft, BtnPriceverification, BtnConfirmQuantity, btnOrdering, BtnPrintPreview] = props.getI18nNameList( | |
| 2284 | + ["BtnNewQuotation", "新报价"], | |
| 2285 | + ["BtnDraft", "存草稿"], | |
| 2286 | + ["BtnPriceverification", "核价"], | |
| 2287 | + ["BtnConfirmQuantity", "确认下单数量"], | |
| 2288 | + ["btnOrdering", "下单中..."], | |
| 2289 | + ["BtnPrintPreview", "打印预览"] | |
| 2290 | + ); | |
| 2264 | 2291 | |
| 2265 | 2292 | // 核价事件 |
| 2266 | 2293 | const onCalcPrice = () => { |
| ... | ... | @@ -2340,12 +2367,27 @@ const ManyComponent = props => { |
| 2340 | 2367 | dQuickQuoteProductQty: dProductQty, |
| 2341 | 2368 | })); |
| 2342 | 2369 | }, |
| 2370 | + onDataChange: (...args) => { | |
| 2371 | + const iIndex = state.manyData.findIndex(item => item.sId === args[3]); | |
| 2372 | + const rowData = { ...state.manyData[iIndex] }; | |
| 2373 | + state.manyData[iIndex] = { | |
| 2374 | + sId: rowData.sId, | |
| 2375 | + iRowNum: rowData.iRowNum, | |
| 2376 | + sParentId: rowData.sParentId, | |
| 2377 | + handleType: rowData.handleType, | |
| 2378 | + ...args[2], | |
| 2379 | + }; | |
| 2380 | + setState(pre => ({ | |
| 2381 | + ...pre, | |
| 2382 | + calcPriceFinished: false, | |
| 2383 | + manyData: state.manyData, | |
| 2384 | + })); | |
| 2385 | + }, | |
| 2343 | 2386 | fixedHeight: 185, |
| 2344 | - enabled: false, | |
| 2345 | 2387 | }; |
| 2346 | 2388 | |
| 2347 | 2389 | return ( |
| 2348 | - <div className={styles.many}> | |
| 2390 | + <div className={`xly-bill-list ${styles.many}`}> | |
| 2349 | 2391 | <StaticEditTable {...tableProps} /> |
| 2350 | 2392 | {enabled && ( |
| 2351 | 2393 | <div className={styles.btns}> |
| ... | ... | @@ -2362,6 +2404,9 @@ const ManyComponent = props => { |
| 2362 | 2404 | > |
| 2363 | 2405 | {BtnDraft} |
| 2364 | 2406 | </Button> |
| 2407 | + <Button type="primary" size="large" onClick={() => {}}> | |
| 2408 | + {BtnPrintPreview} | |
| 2409 | + </Button> | |
| 2365 | 2410 | <Button type="primary" size="large" loading={loading || calcPriceLoading} className={styles.calcPrice} onClick={onCalcPrice}> |
| 2366 | 2411 | {calcPriceLoading ? `核价中【进度${processPercent}%】...` : BtnPriceverification} |
| 2367 | 2412 | </Button> | ... | ... |