Commit 6cdb4c1b98a4307a924018c9a16e8ba5ee95c67a

Authored by Min
2 parents 46052874 c3149b8d

Merge branch 'main' of http://git.xlyprint.cn/zhangz/xlyUmi

Too many changes to show.

To preserve performance only 5 of 8 files are displayed.

package.json
... ... @@ -44,7 +44,8 @@
44 44 "react-sortable-hoc": "^2.0.0",
45 45 "react-to-print": "^3.0.5",
46 46 "umi": "^4.4.11",
47   - "weixin-js-sdk": "1.6.0"
  47 + "weixin-js-sdk": "1.6.0",
  48 + "xlsx": "^0.18.5"
48 49 },
49 50 "devDependencies": {
50 51 "@types/react": "^18.0.33",
... ...
src/components/Common/BoxDesign/createAirplaneBox.js
... ... @@ -93,7 +93,16 @@ export const createPathElement = (x, y, width, height, id, wrapperId) => {
93 93 svg.setAttribute("stroke-dasharray", "4"); // 添加虚线效果
94 94 return svg;
95 95 };
96   -
  96 +export const createPathElements = (x, y, width, height, id, wrapperId) => {
  97 + const d = `M ${x} ${y} L ${x} ${y + height} L ${x + width} ${y + height} L ${x + width} ${y} L ${x} ${y} Z`;
  98 + const svg = document.createElementNS("http://www.w3.org/2000/svg", "path");
  99 + svg.setAttribute("d", d);
  100 + svg.setAttribute("fill", "transparent");
  101 + svg.setAttribute("stroke", "#7588B9");
  102 + svg.setAttribute("stroke-width", "1");
  103 + // svg.setAttribute("stroke-dasharray", "4"); // 添加虚线效果
  104 + return svg;
  105 +};
97 106 //
98 107 // 左边斜线贴边
99 108 export const createTrapezoid = (height, offsetX, offsetY, size) => {
... ...
src/components/Common/BoxDesignCompontent/svg.js
... ... @@ -13,6 +13,7 @@ import {
13 13 createTrapezoidWeltTop,
14 14 createFoldWeltTop,
15 15 createFoldWeltTopLine,
  16 + createPathElements,
16 17 createRoundedCornersWeltTop,
17 18 createRightAngleBoxBottomComponent,
18 19 createBoxBottomComponent1,
... ... @@ -57,17 +58,14 @@ const SvgBox = props => {
57 58 const [deep, setDeep] = useState(0);
58 59 const [svgType, setSvgType] = useState(1);
59 60 // 盒身
60   - useEffect(
61   - () => {
62   - setTimeout(() => {
63   - const svg = svgRef.current;
64   - if (svg) {
65   - initSVG();
66   - }
67   - }, 0);
68   - },
69   - [boxList, svgType]
70   - );
  61 + useEffect(() => {
  62 + setTimeout(() => {
  63 + const svg = svgRef.current;
  64 + if (svg) {
  65 + initSVG();
  66 + }
  67 + }, 0);
  68 + }, [boxList, svgType]);
71 69  
72 70 // 初始化svg
73 71 const initSVG = () => {
... ... @@ -189,6 +187,9 @@ const SvgBox = props => {
189 187 } else if (Number(svgType) === 5) {
190 188 viewBoxWidth = (boxHeight + boxWidth) * 2 + dYTBW + dZTBW;
191 189 viewBoxHeight = boxLength + max;
  190 + } else if (Number(svgType) === 6) {
  191 + viewBoxWidth = boxLength + 2;
  192 + viewBoxHeight = boxWidth + 2;
192 193 }
193 194 // 计算缩放比例
194 195 let scale = 1;
... ... @@ -263,10 +264,12 @@ const SvgBox = props => {
263 264 topSize = Number(zscwValue) + boxHeight * 3;
264 265 }
265 266 ySvg = topSize;
  267 + } else if (Number(svgType) === 6) {
  268 + leftSize = 0;
266 269 } else {
267 270 leftSize = zbtb?.value;
268 271 }
269   - svg.setAttribute("viewBox", `${-(leftSize * scale)||0} ${-ySvg} ${viewBoxWidth} ${viewBoxHeight}`);
  272 + svg.setAttribute("viewBox", `${-(leftSize * scale) || 0} ${-ySvg} ${viewBoxWidth} ${viewBoxHeight}`);
270 273 svg.setAttribute("width", `${viewBoxWidth}px`);
271 274 svg.setAttribute("height", `${viewBoxHeight}px`);
272 275 svgContainerRef.current.style.width = `${viewBoxWidth}px`;
... ... @@ -276,7 +279,7 @@ const SvgBox = props => {
276 279 svgContainerRef.current.style.transform = `scale(${scaleX >= 1 ? 1 : scaleX}, ${scaleY >= 1 ? 1 : scaleY})`;
277 280 svgContainerRef.current.style.transformOrigin = "top left";
278 281 svgContainerRef.current.style.paddingTop = dSvgBoxWidth ? "0" : "25px";
279   - svgContainerRef.current.style.backgroundColor = props.isMobile ? '#EDF4FF' : ''
  282 + svgContainerRef.current.style.backgroundColor = props.isMobile ? "#EDF4FF" : "";
280 283 } else if (props.showNew === 2) {
281 284 // g.setAttribute("transform", `rotate(${iFAngle, dSvgBoxWidth/2,dSvgBoxHeight*2})`);
282 285 let ySvg = topOffect(boxList, boxLength, boxWidth, boxHeight) * scale;
... ... @@ -308,10 +311,12 @@ const SvgBox = props => {
308 311 topSize = Number(zscwValue) + boxHeight * 3;
309 312 }
310 313 ySvg = topSize;
  314 + } else if (Number(svgType) === 6) {
  315 + leftSize = 0;
311 316 } else {
312 317 leftSize = zbtb?.value;
313 318 }
314   - svg.setAttribute("viewBox", `${-(((leftSize * scale) || 0))} ${-ySvg} ${dSvgBoxWidth} ${dSvgBoxHeight}`);
  319 + svg.setAttribute("viewBox", `${-(leftSize * scale || 0)} ${-ySvg} ${dSvgBoxWidth} ${dSvgBoxHeight}`);
315 320 svg.setAttribute("width", `${dSvgBoxWidth}px`);
316 321 svg.setAttribute("height", `${dSvgBoxHeight}px`);
317 322 svgContainerRef.current.style.width = `${dSvgBoxWidth}px`;
... ... @@ -784,7 +789,7 @@ const SvgBox = props => {
784 789 }
785 790 // 左边部件
786 791 pathList.push(createFull(zxbj?.type, scaledHeight, -scaledDeep, -dZXCW, -scaledDeep, 0));
787   - if ((zxbj?.type === "4001" && dZXCW) || (zxbj?.type === "4006" && dZXCW)|| (zxbj?.type === "4007" && dZXCW)) {
  792 + if ((zxbj?.type === "4001" && dZXCW) || (zxbj?.type === "4006" && dZXCW) || (zxbj?.type === "4007" && dZXCW)) {
788 793 pathList.push(createHorizontalDoubleArrow(scaledDeep, -scaledDeep - scaledDeep / 2, scaledHeight * 0.8, scales));
789 794 pathList.push(createText(-scaledDeep - scaledDeep / 2, scaledHeight * 0.8 + 5, 10 * scales, "D"));
790 795 pathList.push(createText(-scaledDeep - scaledDeep - dZXCW / 2, scaledHeight * 0.5, 10 * scales, dZXCW));
... ... @@ -925,7 +930,7 @@ const SvgBox = props => {
925 930 pathList.push(createText(scaledHeight * 0.1 + 10 * scales, -scaledDeep / 2, 10 * scales, "D"));
926 931 pathList.push(createDoubleArrow(scaledDeep, scaledHeight * 0.8, -(scaledDeep + scaledDeep / 2), scales));
927 932 pathList.push(createText(scaledHeight * 0.8 + 10 * scales, -(scaledDeep + scaledHeight / 2), 10 * scales, "D"));
928   - }else if (zsbj?.type && dZSCW) {
  933 + } else if (zsbj?.type && dZSCW) {
929 934 pathList.push(createText(scaledHeight / 2, -dZSCW / 2 + 4, 10 * scales, dZSCW));
930 935 }
931 936 // 右上部件
... ... @@ -949,7 +954,7 @@ const SvgBox = props => {
949 954 pathList.push(createText(scaledHeight + scaledDeep + scaledHeight * 0.1 + 10 * scales, -scaledDeep / 2, 10 * scales, "D"));
950 955 pathList.push(createDoubleArrow(scaledDeep, scaledHeight + scaledDeep + scaledHeight * 0.8, -(scaledDeep + scaledDeep / 2), scales));
951 956 pathList.push(createText(scaledHeight + scaledDeep + scaledHeight * 0.8 + 10 * scales, -(scaledDeep + scaledDeep / 2), 10 * scales, "D"));
952   - }else if (ysbj?.type && dYSCW) {
  957 + } else if (ysbj?.type && dYSCW) {
953 958 pathList.push(createText(scaledHeight + scaledDeep + scaledHeight * 0.5, -dYSCW / 2 + 4, 10 * scales, dYSCW));
954 959 }
955 960 // 左下部件-
... ... @@ -975,7 +980,7 @@ const SvgBox = props => {
975 980 pathList.push(createText(scaledHeight * 0.1 + 10 * scales, scaledWidth + scaledDeep / 2, 10 * scales, "D"));
976 981 pathList.push(createDoubleArrow(scaledDeep, scaledHeight * 0.8, scaledWidth + (scaledDeep + scaledDeep / 2), scales));
977 982 pathList.push(createText(scaledHeight * 0.8 + 10 * scales, scaledWidth + (scaledDeep + scaledDeep / 2), 10 * scales, "D"));
978   - }else if (zxbj?.type && dZXCW) {
  983 + } else if (zxbj?.type && dZXCW) {
979 984 pathList.push(createText(scaledHeight / 2, scaledWidth + dZXCW / 2 - 4, 10 * scales, dZXCW));
980 985 }
981 986 }
... ... @@ -1027,6 +1032,12 @@ const SvgBox = props => {
1027 1032 });
1028 1033 svg.appendChild(g);
1029 1034 // g.setAttribute('transform', `rotate(90, ${viewBoxWidth/2}, ${viewBoxHeight/2})`);
  1035 + } else if (Number(svgType) === 6) {
  1036 + const rectangles = [{ x: 0, y: 0, width: scaledWidth, height: scaledHeight }];
  1037 + rectangles.forEach(rect => {
  1038 + g.appendChild(createPathElements(rect.x, rect.y, rect.width, rect.height));
  1039 + });
  1040 + svg.appendChild(g);
1030 1041 }
1031 1042 };
1032 1043 // 计算头部偏移
... ... @@ -1044,6 +1055,7 @@ const SvgBox = props => {
1044 1055 const five = ["6005", "3005", "4005", "7005"];
1045 1056 const dYSCW = Number(yscw?.value) || 0;
1046 1057 const dZSCW = Number(zscw?.value) || 0;
  1058 + if (Number(svgType) === 6) return 0;
1047 1059 // 如果存在插位就不计算盒舌
1048 1060 if (zscw?.type && yscw?.type) {
1049 1061 const max = Math.max(dZSCW, dYSCW);
... ... @@ -1075,8 +1087,10 @@ const SvgBox = props => {
1075 1087 if (
1076 1088 five.includes(zscw?.type) ||
1077 1089 five.includes(yscw?.type) ||
1078   - (four.includes(zscw?.type) || four.includes(yscw?.type)) ||
1079   - (one.includes(zscw?.type) || one.includes(yscw?.type))
  1090 + four.includes(zscw?.type) ||
  1091 + four.includes(yscw?.type) ||
  1092 + one.includes(zscw?.type) ||
  1093 + one.includes(yscw?.type)
1080 1094 ) {
1081 1095 const coefficient = svgType === "5" ? height : width;
1082 1096 let addValue = 0;
... ... @@ -1096,8 +1110,10 @@ const SvgBox = props => {
1096 1110 if (
1097 1111 five.includes(zscw?.type) ||
1098 1112 five.includes(yscw?.type) ||
1099   - (four.includes(zscw?.type) || four.includes(yscw?.type)) ||
1100   - (one.includes(zscw?.type) || one.includes(yscw?.type))
  1113 + four.includes(zscw?.type) ||
  1114 + four.includes(yscw?.type) ||
  1115 + one.includes(zscw?.type) ||
  1116 + one.includes(yscw?.type)
1101 1117 ) {
1102 1118 const coefficient = svgType === "5" ? height : width;
1103 1119 let addValue = 0;
... ... @@ -1138,6 +1154,7 @@ const SvgBox = props => {
1138 1154 const five = ["6005", "3005", "4005", "7005"];
1139 1155 const dYSCW = Number(yscw?.value) || 0;
1140 1156 const dZSCW = Number(zscw?.value) || 0;
  1157 + if (Number(svgType) === 6) return 0;
1141 1158 if (hdzj?.type) {
1142 1159 return Number(hdzj?.value);
1143 1160 }
... ... @@ -1171,8 +1188,10 @@ const SvgBox = props => {
1171 1188 if (
1172 1189 five.includes(zscw?.type) ||
1173 1190 five.includes(yscw?.type) ||
1174   - (four.includes(zscw?.type) || four.includes(yscw?.type)) ||
1175   - (one.includes(zscw?.type) || one.includes(yscw?.type))
  1191 + four.includes(zscw?.type) ||
  1192 + four.includes(yscw?.type) ||
  1193 + one.includes(zscw?.type) ||
  1194 + one.includes(yscw?.type)
1176 1195 ) {
1177 1196 const coefficient = svgType === "5" ? height : width;
1178 1197 let addValue = 0;
... ... @@ -1192,8 +1211,10 @@ const SvgBox = props => {
1192 1211 if (
1193 1212 five.includes(zscw?.type) ||
1194 1213 five.includes(yscw?.type) ||
1195   - (four.includes(zscw?.type) || four.includes(yscw?.type)) ||
1196   - (one.includes(zscw?.type) || one.includes(yscw?.type))
  1214 + four.includes(zscw?.type) ||
  1215 + four.includes(yscw?.type) ||
  1216 + one.includes(zscw?.type) ||
  1217 + one.includes(yscw?.type)
1197 1218 ) {
1198 1219 const coefficient = svgType === "5" ? height : width;
1199 1220 let addValue = 0;
... ...
src/components/Common/CommonElementEvent.js
... ... @@ -2,6 +2,7 @@
2 2 /* eslint-disable array-callback-return,no-undef,prefer-destructuring */
3 3 import React, { Component } from 'react';
4 4 import { Modal, message } from 'antd-v4';
  5 +import * as XLSX from 'xlsx';
5 6 import commonConfig from '../../utils/config';
6 7 import * as commonFunc from './commonFunc';
7 8 import * as commonBusiness from './commonBusiness'; /* 单据业务功能 */
... ... @@ -4068,6 +4069,9 @@ export default (ChildComponent) => {
4068 4069 }
4069 4070 this.props.onSaveState({
4070 4071 masterData, masterConfig, customerInfoData, ...addState, contactData, enabled: sModelsType === 'system/sisformulaInfo' ? this.props.enabled : true, bUserModel: masterData.bUserModel,
  4072 + }, () => {
  4073 + this.masterChangeCb && this.masterChangeCb();
  4074 + this.masterChangeCb = null;
4071 4075 });
4072 4076 };
4073 4077 handleChangeProductParteName = (sAllPartsName, sisproductclassifyProcessClassifyConfigNew) => {
... ... @@ -4640,6 +4644,78 @@ export default (ChildComponent) => {
4640 4644 return newWin;
4641 4645 }
4642 4646  
  4647 + // 导入模版功能
  4648 + handleImportExcel = () => {
  4649 + const fileInput = document.createElement('input');
  4650 + fileInput.type = 'file';
  4651 + fileInput.accept = '.xlsx, .xls';
  4652 + fileInput.style.position = 'fixed';
  4653 + fileInput.style.left = '-9999px';
  4654 + document.body.appendChild(fileInput);
  4655 +
  4656 + fileInput.addEventListener('change', (e) => {
  4657 + const file = e.target.files[0];
  4658 + if (file) {
  4659 + if (!file) return;
  4660 +
  4661 + const reader = new FileReader();
  4662 + reader.readAsArrayBuffer(file);
  4663 + reader.onload = (evt) => {
  4664 + try {
  4665 + const data = evt.target.result;
  4666 + const workbook = XLSX.read(data, { type: 'binary' });
  4667 + const sColTitleName = [];
  4668 + workbook.SheetNames.forEach((sheetName, i) => {
  4669 + const sheet = workbook.Sheets[sheetName];
  4670 + const parsedData = XLSX.utils.sheet_to_json(sheet, { header: 1 });
  4671 + const [firstRow, ...restRows] = parsedData;
  4672 + sColTitleName.push(firstRow.reduce((pre, item, index) => {
  4673 + if (index === 0) {
  4674 + pre.sName = item.replace('sName', '');
  4675 + } else if (item.endsWith('sName')) {
  4676 + pre[`sName${index}`] = item.replace('sName', '');
  4677 + } else {
  4678 + pre[`sValue${index}`] = item;
  4679 + }
  4680 + return pre;
  4681 + }, { panelName: sheetName }));
  4682 + });
  4683 + this.masterChangeCb = () => {
  4684 + const addState = {};
  4685 + workbook.SheetNames.forEach((sheetName, i) => {
  4686 + const sheet = workbook.Sheets[sheetName];
  4687 + const parsedData = XLSX.utils.sheet_to_json(sheet, { header: 1 });
  4688 + const [firstRow, ...restRows] = parsedData;
  4689 + const tableName = `customizeParam${i || ''}`;
  4690 + let { [`${tableName}Data`]: tableData = [], [`${tableName}DelData`]: tableDelData = [] } = this.props;
  4691 + tableDelData = [...tableDelData, ...tableData.map(item => ({ ...item, handleType: 'del' }))];
  4692 + tableData = restRows.map(item => {
  4693 + const columnKeys = Object.keys(sColTitleName[i]);
  4694 + columnKeys.shift();
  4695 + return { ...this.handleTableAdd(tableName, true), ...item.reduce((pre, cur, index) => {
  4696 + pre[columnKeys[index]] = cur;
  4697 + return pre;
  4698 + }, { sType: tableName }) };
  4699 + });
  4700 + addState[`${tableName}Data`] = tableData;
  4701 + addState[`${tableName}DelData`] = tableDelData;
  4702 + });
  4703 + this.props.onSaveState(addState);
  4704 + };
  4705 + this.handleMasterChange('masterData', 'sColTitleName', { sColTitleName: JSON.stringify(sColTitleName) }, undefined, []);
  4706 + } catch (error) {
  4707 + console.log('=====err', error);
  4708 + message.error('文件格式错误');
  4709 + }
  4710 + };
  4711 + }
  4712 +
  4713 + document.body.removeChild(fileInput);
  4714 + });
  4715 +
  4716 + fileInput.click();
  4717 + }
  4718 +
4643 4719 /* 按钮点击功能 */
4644 4720 handleBtnClick = (e, btnName) => {
4645 4721 if (btnName === 'BtnAccounts') {
... ... @@ -4648,8 +4724,10 @@ export default (ChildComponent) => {
4648 4724 this.handleDesignFunction();
4649 4725 } else if (e === 'BtnResetpwd') { /* 管理员重置密码 */
4650 4726 this.handleResetPwd();
4651   - } if (e === 'BtnOut') {
  4727 + } else if (e === 'BtnOut') {
4652 4728 this.handleOut();
  4729 + } else if (e === 'BtnImportExcel') { // 导入Excel模版
  4730 + this.handleImportExcel();
4653 4731 }
4654 4732 // else if (e === 'BtnConfigCustomizeParam') { /* 生成变量设置 */
4655 4733 // const { masterData, customizeParamConfig } = this.props;
... ...
src/components/Common/Typesetting/typesetting.js
1 1 /* eslint-disable */
2 2 import React, { useEffect, useState, useRef } from "react";
3   -import { Modal } from "antd-v4";
  3 +import { Modal, message } from "antd-v4";
4 4 import { VerticalRightOutlined, VerticalLeftOutlined, LeftOutlined, RightOutlined, UpOutlined, DownOutlined } from "@ant-design/icons";
5 5 import * as commonUtils from "@/utils/utils"; /* 通用方法 */
6 6 import commonConfig from "@/utils/config";
... ... @@ -606,7 +606,9 @@ const Typesetting = props => {
606 606 Number(slaveDataDetail?.dMaxWidth) >= Number(slaveRowData?.dMachineWidth);
607 607  
608 608 const isShow = slaveRowData && slaveRowData.dMachineLength && slaveRowData.dMaxWidth && slaveRowData.dMaxLength && isMax && innerDivs.length;
609   -
  609 + if (isCustomized && !isShow) {
  610 + message.error("排版尺寸大于上机尺寸,请确认参数!");
  611 + }
610 612 const onClick = () => {
611 613 if (isMobile) return;
612 614 setIsModalOpen(true);
... ...