Commit a831986ad098d9ae665a036a2c482b249b2f867a

Authored by 陈鑫涛
1 parent 06033ae2

快速报价app修改数量

src/components/Common/Typesetting/typesetting.js
... ... @@ -63,6 +63,7 @@ const Typesetting = props => {
63 63 const [dPartsLength, setDPartsLength] = useState(0);
64 64 const [newDHorizontalType, setNewDHorizontalType] = useState(0);
65 65 const [newDPortraitType, setNewDPortraitType] = useState(0);
  66 + const [oldVariables, setOldVariables] = useState('')
66 67 // 横板
67 68 let { dHorizontal, dPortrait, dHorizontalType, dPortraitType } = slaveRowData;
68 69 // 使用 useRef 获取 DOM 元素
... ... @@ -94,24 +95,24 @@ const Typesetting = props => {
94 95 const H = masterData?.dWidth || 0;
95 96 const D = masterData?.dHeight || 0;
96 97 // 动态计算公式值
97   -const evaluateFormula = (formula, variables) => {
98   - if (!formula) return 0; // 如果公式为空,返回0
99   - try {
100   - // 提取公式中的变量名
101   - const variableNames = formula.match(/\b[a-zA-Z_][a-zA-Z0-9_]*\b/g) || [];
102   - // 构建函数参数
103   - const params = variableNames.join(",") + ",Math";
104   - // 替换公式中的变量为实际值
105   - const func = new Function(params, `return ${formula}`);
106   - // 提取变量值
107   - const args = variableNames.map(name => Number(variables[name]) || 0);
108   - // 执行函数并返回结果
109   - return func(...args, Math);
110   - } catch (error) {
111   - console.error("公式执行错误:", error);
112   - return 0;
113   - }
114   - };
  98 + const evaluateFormula = (formula, variables) => {
  99 + if (!formula) return 0; // 如果公式为空,返回0
  100 + try {
  101 + // 提取公式中的变量名
  102 + const variableNames = formula.match(/\b[a-zA-Z_][a-zA-Z0-9_]*\b/g) || [];
  103 + // 构建函数参数
  104 + const params = variableNames.join(",") + ",Math";
  105 + // 替换公式中的变量为实际值
  106 + const func = new Function(params, `return ${formula}`);
  107 + // 提取变量值
  108 + const args = variableNames.map(name => Number(variables[name]) || 0);
  109 + // 执行函数并返回结果
  110 + return func(...args, Math);
  111 + } catch (error) {
  112 + console.error("公式执行错误:", error);
  113 + return 0;
  114 + }
  115 + };
115 116  
116 117 // 计算公式值
117 118 const variables = {
... ... @@ -124,7 +125,7 @@ const evaluateFormula = (formula, variables) => {
124 125 const { sStripType = 0 } = props.state.selectedNode;
125 126 let boxList = [];
126 127 if (sColumnNameConfig) {
127   - const slaveNewData = JSON.parse(sColumnNameConfig);
  128 + const slaveNewData = slaveRowData.upAbleConfigsExtra || JSON.parse(slaveRowData.sColumnNameConfig);
128 129 const tables = [
129 130 { name: "盒型类别", value: slaveRowData.sBoxType, type: null },
130 131 { name: "盒身", value: slaveRowData.sBoxBody, type: slaveRowData.sTypes },
... ... @@ -180,17 +181,14 @@ const evaluateFormula = (formula, variables) => {
180 181 });
181 182 }
182 183  
183   - const result = boxList?.reduce((acc, { sCode, value }) => ({ ...acc, [sCode]: value }), {});
  184 + const result = boxList?.reduce((acc, { sCode, value }) => ({ ...acc, [sCode]: Number(value) }), {});
184 185  
185 186 // 计算表达式结果
186 187 const variabless = {
187   - L,
188   - W,
189   - H,
190   - D,
191   - ...props.slaveRowData,
  188 + ...variables,
192 189 ...result,
193 190 };
  191 +
194 192 let DisableMateriallIcon = L ? sPackDetailPath : null;
195 193 // 盒子展长展开公式计算
196 194 const innerWidth = slaveRowData.sTypes === "6" ? evaluateFormula(sWidthFormula, variabless) : evaluateFormula(sLengthFormula, variabless);
... ... @@ -218,12 +216,16 @@ const evaluateFormula = (formula, variables) => {
218 216 // dSvgBoxHeight = jInnerHeight;
219 217 // dSvgBoxWidth = jInnerWidth;
220 218 }
221   - const innerHeightCombined = isVertical ? jInnerHeight * 2 + dSWidthOffset + dFWidthOffset + dXBJJ: Math.max(jInnerHeight + dFWidthOffset, jInnerHeight + dSWidthOffset) + dXBJJ; // 计算内层盒子高度 从上向下排列 取首盒加偏移量和次盒加偏移量最大的值 从左往右排列 盒子尺寸 * 2 加上首盒偏移量和次盒偏移量
  219 + const innerHeightCombined = isVertical
  220 + ? jInnerHeight * 2 + dSWidthOffset + dFWidthOffset + dXBJJ
  221 + : Math.max(jInnerHeight + dFWidthOffset, jInnerHeight + dSWidthOffset) + dXBJJ; // 计算内层盒子高度 从上向下排列 取首盒加偏移量和次盒加偏移量最大的值 从左往右排列 盒子尺寸 * 2 加上首盒偏移量和次盒偏移量
222 222 // 计算内层盒子宽度 从上向下排列 取首盒加偏移量和次盒加偏移量最大的值 从左往右排列 盒子尺寸 * 2 加上首盒偏移量和次盒偏移量
223 223 const innerWidthCombined = isVertical
224 224 ? Math.max(jInnerWidth + dFLengthOffset, jInnerWidth + dSLengthOffset) + dYBJJ
225 225 : jInnerWidth * 2 + dSLengthOffset + dFLengthOffset + dYBJJ;
226 226  
  227 + console.log(innerWidthCombined,innerHeightCombined,jInnerWidth,jInnerHeight,'innerHeightCombined');
  228 +
227 229 const style = {
228 230 width: `${outerWidth}px`,
229 231 height: `${outerHeight}px`,
... ... @@ -235,7 +237,7 @@ const evaluateFormula = (formula, variables) => {
235 237 const dSWidthOffsetCombined = innerWidthCombined + boxLengthOffset + (reference ? 0 : dSLengthOffset);
236 238 let cols = dSWidthOffsetCombined === 0 ? 0 : Math.floor(outerWidth / dSWidthOffsetCombined);
237 239 const rowsCombined = innerHeightCombined + boxWidthOffset + (reference ? 0 : dSWidthOffset);
238   - let rows =rowsCombined === 0 ? 0 : Math.floor(outerHeight / (rowsCombined));
  240 + let rows = rowsCombined === 0 ? 0 : Math.floor(outerHeight / rowsCombined);
239 241 let colsMaxLength = (cols - 1) * (innerWidthCombined + boxLengthOffset + (reference ? 0 : dSLengthOffset)) + innerWidthCombined;
240 242 while (colsMaxLength >= outerWidth && cols > 0) {
241 243 cols = cols - 1;
... ... @@ -247,7 +249,7 @@ const evaluateFormula = (formula, variables) => {
247 249 rows = rows - 1;
248 250 rowsMaxLength = (rows - 1) * (innerHeightCombined + boxWidthOffset + (reference ? 0 : dSWidthOffset)) + innerHeightCombined;
249 251 }
250   -console.log(cols, rows, outerWidth, outerHeight, "cols rows outerWidth outerHeight");
  252 + console.log(cols, rows, outerWidth, outerHeight, "cols rows outerWidth outerHeight");
251 253  
252 254 // 最大上机长 上机宽 开料尺寸
253 255 // 计算剩余空间 每组都算上偏移量 那么剩余需要加上后面偏移的总量
... ... @@ -548,29 +550,6 @@ console.log(cols, rows, outerWidth, outerHeight, "cols rows outerWidth outerHeig
548 550 }
549 551 }
550 552  
551   - // // 如果第一行只能放下一个
552   - // if (cols === 0 && !isVertical) {
553   - // const maxLength = Number(slaveDataDetail?.dMaxLength);
554   - // if (maxLength > innerWidth) {
555   - // let leftPosition = 0;
556   - // let topPosition = 0;
557   - // innerDivs.push(createBoxOne(0, rows, 3, leftPosition, topPosition, iFAngle, DisableMateriallIcon));
558   - // }
559   - // }
560   -
561   - // // 如果第一列
562   - // if (rows === 0 && isVertical) {
563   - // const maxWidth = Number(slaveDataDetail?.dMaxWidth);
564   - // if (maxWidth > innerHeight) {
565   - // for (let index = 0; index < cols; index++) {
566   - // let leftPosition = index * (innerWidthCombined + dYBJJ);
567   - // let topPosition = 0;
568   - // innerDivs.push(createBoxOne(cols, 0, 3, leftPosition, topPosition, iFAngle, DisableMateriallIcon));
569   - // }
570   - // }
571   - // }
572   -
573   - console.log(cols, rows, innerDivs.length, "innerDivs");
574 553  
575 554 // 判断展开长展开宽是否变化
576 555 if (dPartsLength !== innerWidth && !innerDivs.length) {
... ... @@ -578,6 +557,7 @@ console.log(cols, rows, outerWidth, outerHeight, &quot;cols rows outerWidth outerHeig
578 557 onSaveDPartsLength(innerWidth, innerHeight, slaveData);
579 558 }
580 559 const propsData = innerDivs[innerDivs.length - 1];
  560 +
581 561 let openEdition = 0;
582 562 if (propsData && L) {
583 563 const sMaterialsName = slaveData.find(x => x.sTreeNodeName === selectedNode.showName && x.sBoxModel === props.boxModel).sMaterialsName;
... ... @@ -599,7 +579,6 @@ console.log(cols, rows, outerWidth, outerHeight, &quot;cols rows outerWidth outerHeig
599 579 ? rows + rows * (cols * 2)
600 580 : rows * (cols * 2);
601 581  
602   -
603 582 let dHorizontalType = isVertical ? cols : remaining ? cols * 2 + 1 : cols * 2;
604 583 let dPortraitType = isVertical ? (remaining ? rows * 2 + 1 : rows * 2) : remaining ? rows : rows;
605 584 if (cols === 0 || rows === 0) {
... ... @@ -623,7 +602,8 @@ console.log(cols, rows, outerWidth, outerHeight, &quot;cols rows outerWidth outerHeig
623 602 newMaterialWidth !== materialWidth ||
624 603 materialName !== sMaterialsName ||
625 604 newDHorizontalType !== dHorizontalType ||
626   - newDPortraitType !== dPortraitType
  605 + newDPortraitType !== dPortraitType ||
  606 + oldVariables !== JSON.stringify(slaveRowData)
627 607 ) {
628 608 setMaterialLength(newMaterialLength);
629 609 setMaterialWidth(newMaterialWidth);
... ... @@ -632,6 +612,7 @@ console.log(cols, rows, outerWidth, outerHeight, &quot;cols rows outerWidth outerHeig
632 612 setDPartsLength(innerWidth);
633 613 setNewDHorizontalType(dHorizontalType);
634 614 setNewDPortraitType(dPortraitType);
  615 + setOldVariables(JSON.stringify(slaveRowData));
635 616 // setDMaterialsKQty(newDMaterialsKQty)
636 617 const scaleX = (clientWidth - 50) / (outerWidth + 110);
637 618 const scaleY = (clientHeight - 5) / (outerHeight + 90);
... ... @@ -708,7 +689,7 @@ console.log(cols, rows, outerWidth, outerHeight, &quot;cols rows outerWidth outerHeig
708 689 Number(slaveDataDetail?.dMaxLength) >= Number(slaveRowData?.dMachineLength) &&
709 690 Number(slaveDataDetail?.dMaxWidth) >= Number(slaveRowData?.dMachineWidth);
710 691  
711   - const isShow = (slaveRowData && slaveRowData.dMachineLength && slaveRowData.dMaxWidth && slaveRowData.dMaxLength && isMax && innerDivs.length > 0);
  692 + const isShow = slaveRowData && slaveRowData.dMachineLength && slaveRowData.dMaxWidth && slaveRowData.dMaxLength && isMax && innerDivs.length > 0;
712 693 console.log(
713 694 slaveDataDetail?.dMaxLength,
714 695 slaveDataDetail?.dMaxWidth,
... ...
src/mobile/quotation/detailNew.jsx
... ... @@ -153,7 +153,7 @@ const QuickQuoteEvent = props =&gt; {
153 153 const { showName: sTreeNodeName } = selectedNode;
154 154 const boxModel = name.replace("slaveUp", "").replace("slaveDown", "");
155 155 const iIndex = slaveData.findIndex(item => item.sTreeNodeName === sTreeNodeName && item.sBoxModel === boxModel);
156   - console.log("🚀 ~ iIndex:", iIndex,boxModel,props)
  156 + console.log("🚀 ~ iIndex:", iIndex, boxModel, props);
157 157 let masterDataNew = { ...masterData, ...changeValue };
158 158 masterDataNew.handleType = masterDataNew.handleType || "update";
159 159 masterDataNew.sId = commonUtils.createSid();
... ... @@ -1397,7 +1397,6 @@ const BoxComponent = props =&gt; {
1397 1397 const slaveRowData = slaveData.find(item => item.sTreeNodeName === selectedNode.showName && item.sBoxModel === boxModel) || {};
1398 1398  
1399 1399 const { sModelsId } = props;
1400   - console.log("🚀 ~ props:", props)
1401 1400 const [selectList, setSelectList] = useState([]);
1402 1401 const [boxTypeList, setBoxTypeList] = useState([]);
1403 1402 const [searchValue, setSearchValue] = useState("");
... ... @@ -1408,12 +1407,14 @@ const BoxComponent = props =&gt; {
1408 1407 // 获取盒型信息
1409 1408 useEffect(() => {
1410 1409 const sId = "17428091410008594700322758474000";
  1410 + console.log(props, "props");
  1411 + const { selectedNode } = props;
1411 1412 const url = `${commonConfig.server_host}business/getSelectLimit/${sId}`;
1412 1413 const body = {
1413 1414 sSqlCondition: {
1414   - sProductClassifyId:sModelsId
  1415 + sProductClassifyId: selectedNode.sId,
1415 1416 },
1416   - sKeyUpFilterName: '',
  1417 + sKeyUpFilterName: "",
1417 1418 pageNum: 1,
1418 1419 pageSize: 1000,
1419 1420 };
... ... @@ -2221,7 +2222,8 @@ const BoxComponent = props =&gt; {
2221 2222 )}
2222 2223 </div>
2223 2224 </div>
2224   - {getTableCloum(i, x)}
  2225 + {/* {getTableCloum(i, x)} */}
  2226 + <BackendParamsExtraComponent {...props} itemDetail={x} onCostomClick={onCostomClick} />
2225 2227 </div>
2226 2228 ))
2227 2229 : ""}
... ... @@ -2244,7 +2246,7 @@ const BoxComponent = props =&gt; {
2244 2246 ))
2245 2247 : ""}
2246 2248 </div>
2247   - <BackendParamsExtraComponent {...props} onCostomClick={onCostomClick} />
  2249 +
2248 2250 <div>
2249 2251 <div className={styles.projectBtn}>
2250 2252 <div className={styles.boxTitle} style={{ marginTop: "2rem" }}>
... ... @@ -2315,14 +2317,14 @@ const PrintParamsComponent = props =&gt; {
2315 2317 iColValue: 8,
2316 2318 };
2317 2319 });
2318   - console.log("🚀 ~ printParamsConfig:", printParamsConfig)
2319   -// printParamsConfig.forEach(item=>{
2320   -// const showDropDown = commonUtils.isNotEmptyArr(item.dropDownData)
2321   -// ? this.props.showConfig.dropDownData
2322   -// : typeof this.props.showConfig.showDropDown === "object"
2323   -// ? this.props.showConfig.showDropDown
2324   -// : commonUtils.objectToArr(commonUtils.convertStrToObj(this.props.showConfig.showDropDown));
2325   -// })
  2320 + console.log("🚀 ~ printParamsConfig:", printParamsConfig);
  2321 + // printParamsConfig.forEach(item=>{
  2322 + // const showDropDown = commonUtils.isNotEmptyArr(item.dropDownData)
  2323 + // ? this.props.showConfig.dropDownData
  2324 + // : typeof this.props.showConfig.showDropDown === "object"
  2325 + // ? this.props.showConfig.showDropDown
  2326 + // : commonUtils.objectToArr(commonUtils.convertStrToObj(this.props.showConfig.showDropDown));
  2327 + // })
2326 2328 const result = [];
2327 2329 for (let i = 0; i < printParams.length + 1; i++) {
2328 2330 const printParamsItem = printParams[i - 1];
... ... @@ -2589,6 +2591,9 @@ const ManyComponent = props =&gt; {
2589 2591 const [submitLoading, setSubmitLoading] = useState(false);
2590 2592 const [processPercent, setProcessPercent] = useState(0);
2591 2593 const [selectedRadio, setSelectedRadio] = useState(null);
  2594 + const [visible, setVisible] = useState(false);
  2595 + const [value, setValue] = useState("");
  2596 + const [changeValue, setChangeValue] = useState("");
2592 2597 // 根据主表数量更改多数量表
2593 2598 useEffect(() => {
2594 2599 const baseCount = masterData.dProductQty || 1000;
... ... @@ -2616,15 +2621,7 @@ const ManyComponent = props =&gt; {
2616 2621 useEffect(() => {
2617 2622 if (calcPriceLoading) {
2618 2623 setProcessPercent(0);
2619   - // window.tempWsAction = ({ data } = {}) => {
2620   - // const { action, msg } = commonUtils.convertStrToObj(data, {});
2621   - // if (action === "quotationAllprogress") {
2622   - // setProcessPercent(msg);
2623   - // }
2624   - // };
2625   - } else {
2626   - // window.tempWsAction = null;
2627   - }
  2624 + }
2628 2625 }, [calcPriceLoading]);
2629 2626  
2630 2627 // 监听确认下单数量结束
... ... @@ -2662,6 +2659,7 @@ const ManyComponent = props =&gt; {
2662 2659 };
2663 2660 const handleRadioChange = selectedRowKeys => {
2664 2661 const dProductQty = manyData.find(item => item.sId === selectedRowKeys.sId).dManyQty;
  2662 + console.log("🚀 ~ dProductQty:", dProductQty);
2665 2663 // 这一步导致了点击数量没有变化
2666 2664 // props.slaveData?.forEach(slaveRowData => {
2667 2665 // props.onDataChange0("slave", "dProductQty", { dProductQty }, slaveRowData.sId, [], props);
... ... @@ -2674,6 +2672,11 @@ const ManyComponent = props =&gt; {
2674 2672 }));
2675 2673 setSelectedRadio(dProductQty);
2676 2674 };
  2675 +
  2676 + const changrManyQty = item => {
  2677 + setChangeValue(item);
  2678 + setVisible(true);
  2679 + };
2677 2680 return (
2678 2681 <div>
2679 2682 <div style={{ marginBottom: "1rem", textAlign: "right" }}>
... ... @@ -2725,11 +2728,13 @@ const ManyComponent = props =&gt; {
2725 2728 {data && data.length
2726 2729 ? data.map(item => {
2727 2730 return (
2728   - <div className={styles.tableBox} onClick={() => handleRadioChange(item)}>
  2731 + <div className={styles.tableBox}>
2729 2732 <div style={{ width: "1rem", "--icon-size": "1.375rem", "--font-size": "1rem", "--gap": "0.5rem" }}>
2730   - <Radio checked={selectedRadio === item.dManyQty} />
  2733 + <Radio checked={selectedRadio === item.dManyQty} onClick={() => handleRadioChange(item)} />
  2734 + </div>
  2735 + <div className={styles.tableBody} onClick={() => changrManyQty(item)}>
  2736 + {item.dManyQty}
2731 2737 </div>
2732   - <div className={styles.tableBody}>{item.dManyQty}</div>
2733 2738 <div className={styles.tableBody}>{item.dPrintMoney}</div>
2734 2739 <div className={styles.tableBody}>{item.dAfterProcessMoney}</div>
2735 2740 <div className={styles.tableBody}>{item.dMaterialsMoney}</div>
... ... @@ -2740,6 +2745,51 @@ const ManyComponent = props =&gt; {
2740 2745 })
2741 2746 : ""}
2742 2747 </div>
  2748 + <CenterPopup visible={visible}>
  2749 + <div className={styles.addTabs}>
  2750 + <div>请输入数量:</div>
  2751 + <Input
  2752 + placeholder="请输入内容"
  2753 + clearable
  2754 + value={value}
  2755 + onChange={val => {
  2756 + setValue(val);
  2757 + }}
  2758 + />
  2759 + <div className={styles.addTabsBtn}>
  2760 + <Button
  2761 + color="primary"
  2762 + fill="outline"
  2763 + size="small"
  2764 + style={{ marginRight: "1rem" }}
  2765 + onClick={() => {
  2766 + setValue("");
  2767 + setVisible(false);
  2768 + }}
  2769 + >
  2770 + 取消
  2771 + </Button>
  2772 + <Button
  2773 + color="primary"
  2774 + fill="solid"
  2775 + size="small"
  2776 + onClick={() => {
  2777 +
  2778 + console.log(data,changeValue, value,'asdasdasd');
  2779 + const i = data.findIndex(item => item.sId === changeValue.sId);
  2780 + if (i !== -1) {
  2781 + data[i].dManyQty = Number(value);
  2782 + handleRadioChange(data[i])
  2783 + }
  2784 + setVisible(false);
  2785 + setValue("");
  2786 + }}
  2787 + >
  2788 + 确认
  2789 + </Button>
  2790 + </div>
  2791 + </div>
  2792 + </CenterPopup>
2743 2793 </div>
2744 2794 );
2745 2795 };
... ... @@ -2749,6 +2799,7 @@ const BackendParamsExtraComponent = props =&gt; {
2749 2799 const { backendParamsConfig = [], backendConfig = {}, slaveData, selectedNode } = state;
2750 2800 const { sParentFieldsName, sBoxModel } = backendConfig;
2751 2801 if (!backendParamsConfig.length) return "";
  2802 + if (sParentFieldsName !== props.itemDetail.sName) return;
2752 2803 // 使用 useMemo 缓存计算结果
2753 2804 const slaveRowData = slaveData.find(item => item.sTreeNodeName === selectedNode.showName && item.sBoxModel === sBoxModel) || {};
2754 2805  
... ... @@ -2843,10 +2894,10 @@ const BackendParamsExtraComponent = props =&gt; {
2843 2894 if (!viewConfigs.length) return;
2844 2895 return (
2845 2896 <div>
2846   - <div className={styles.boxTitle}>
  2897 + {/* <div className={styles.boxTitle}>
2847 2898 后道参数额外配置
2848 2899 <EditFill color="#BFBFBF" style={{ marginLeft: "1rem" }} />
2849   - </div>
  2900 + </div> */}
2850 2901 <div>
2851 2902 <Grid columns={3} gap={8}>
2852 2903 {viewProps.viewConfigs.map(x => (
... ...