Просмотр исходного кода

fix(report): 删除多余代码,把client中部分报表专属代码抽到report模块中

lishihao 4 лет назад
Родитель
Сommit
866fe341b6

+ 0 - 281
report/src/excel_util/excel_base_files/theme1.xml

@@ -1,281 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office 主题">
-	<a:themeElements>
-		<a:clrScheme name="Office">
-			<a:dk1>
-				<a:sysClr val="windowText" lastClr="000000"/>
-			</a:dk1>
-			<a:lt1>
-				<a:sysClr val="window" lastClr="FFFFFF"/>
-			</a:lt1>
-			<a:dk2>
-				<a:srgbClr val="1F497D"/>
-			</a:dk2>
-			<a:lt2>
-				<a:srgbClr val="EEECE1"/>
-			</a:lt2>
-			<a:accent1>
-				<a:srgbClr val="4F81BD"/>
-			</a:accent1>
-			<a:accent2>
-				<a:srgbClr val="C0504D"/>
-			</a:accent2>
-			<a:accent3>
-				<a:srgbClr val="9BBB59"/>
-			</a:accent3>
-			<a:accent4>
-				<a:srgbClr val="8064A2"/>
-			</a:accent4>
-			<a:accent5>
-				<a:srgbClr val="4BACC6"/>
-			</a:accent5>
-			<a:accent6>
-				<a:srgbClr val="F79646"/>
-			</a:accent6>
-			<a:hlink>
-				<a:srgbClr val="0000FF"/>
-			</a:hlink>
-			<a:folHlink>
-				<a:srgbClr val="800080"/>
-			</a:folHlink>
-		</a:clrScheme>
-		<a:fontScheme name="Office">
-			<a:majorFont>
-				<a:latin typeface="Cambria"/>
-				<a:ea typeface=""/>
-				<a:cs typeface=""/>
-				<a:font script="Jpan" typeface="MS Pゴシック"/>
-				<a:font script="Hang" typeface="맑은 고딕"/>
-				<a:font script="Hans" typeface="宋体"/>
-				<a:font script="Hant" typeface="新細明體"/>
-				<a:font script="Arab" typeface="Times New Roman"/>
-				<a:font script="Hebr" typeface="Times New Roman"/>
-				<a:font script="Thai" typeface="Tahoma"/>
-				<a:font script="Ethi" typeface="Nyala"/>
-				<a:font script="Beng" typeface="Vrinda"/>
-				<a:font script="Gujr" typeface="Shruti"/>
-				<a:font script="Khmr" typeface="MoolBoran"/>
-				<a:font script="Knda" typeface="Tunga"/>
-				<a:font script="Guru" typeface="Raavi"/>
-				<a:font script="Cans" typeface="Euphemia"/>
-				<a:font script="Cher" typeface="Plantagenet Cherokee"/>
-				<a:font script="Yiii" typeface="Microsoft Yi Baiti"/>
-				<a:font script="Tibt" typeface="Microsoft Himalaya"/>
-				<a:font script="Thaa" typeface="MV Boli"/>
-				<a:font script="Deva" typeface="Mangal"/>
-				<a:font script="Telu" typeface="Gautami"/>
-				<a:font script="Taml" typeface="Latha"/>
-				<a:font script="Syrc" typeface="Estrangelo Edessa"/>
-				<a:font script="Orya" typeface="Kalinga"/>
-				<a:font script="Mlym" typeface="Kartika"/>
-				<a:font script="Laoo" typeface="DokChampa"/>
-				<a:font script="Sinh" typeface="Iskoola Pota"/>
-				<a:font script="Mong" typeface="Mongolian Baiti"/>
-				<a:font script="Viet" typeface="Times New Roman"/>
-				<a:font script="Uigh" typeface="Microsoft Uighur"/>
-			</a:majorFont>
-			<a:minorFont>
-				<a:latin typeface="Calibri"/>
-				<a:ea typeface=""/>
-				<a:cs typeface=""/>
-				<a:font script="Jpan" typeface="MS Pゴシック"/>
-				<a:font script="Hang" typeface="맑은 고딕"/>
-				<a:font script="Hans" typeface="宋体"/>
-				<a:font script="Hant" typeface="新細明體"/>
-				<a:font script="Arab" typeface="Arial"/>
-				<a:font script="Hebr" typeface="Arial"/>
-				<a:font script="Thai" typeface="Tahoma"/>
-				<a:font script="Ethi" typeface="Nyala"/>
-				<a:font script="Beng" typeface="Vrinda"/>
-				<a:font script="Gujr" typeface="Shruti"/>
-				<a:font script="Khmr" typeface="DaunPenh"/>
-				<a:font script="Knda" typeface="Tunga"/>
-				<a:font script="Guru" typeface="Raavi"/>
-				<a:font script="Cans" typeface="Euphemia"/>
-				<a:font script="Cher" typeface="Plantagenet Cherokee"/>
-				<a:font script="Yiii" typeface="Microsoft Yi Baiti"/>
-				<a:font script="Tibt" typeface="Microsoft Himalaya"/>
-				<a:font script="Thaa" typeface="MV Boli"/>
-				<a:font script="Deva" typeface="Mangal"/>
-				<a:font script="Telu" typeface="Gautami"/>
-				<a:font script="Taml" typeface="Latha"/>
-				<a:font script="Syrc" typeface="Estrangelo Edessa"/>
-				<a:font script="Orya" typeface="Kalinga"/>
-				<a:font script="Mlym" typeface="Kartika"/>
-				<a:font script="Laoo" typeface="DokChampa"/>
-				<a:font script="Sinh" typeface="Iskoola Pota"/>
-				<a:font script="Mong" typeface="Mongolian Baiti"/>
-				<a:font script="Viet" typeface="Arial"/>
-				<a:font script="Uigh" typeface="Microsoft Uighur"/>
-			</a:minorFont>
-		</a:fontScheme>
-		<a:fmtScheme name="Office">
-			<a:fillStyleLst>
-				<a:solidFill>
-					<a:schemeClr val="phClr"/>
-				</a:solidFill>
-				<a:gradFill rotWithShape="1">
-					<a:gsLst>
-						<a:gs pos="0">
-							<a:schemeClr val="phClr">
-								<a:tint val="50000"/>
-								<a:satMod val="300000"/>
-							</a:schemeClr>
-						</a:gs>
-						<a:gs pos="35000">
-							<a:schemeClr val="phClr">
-								<a:tint val="37000"/>
-								<a:satMod val="300000"/>
-							</a:schemeClr>
-						</a:gs>
-						<a:gs pos="100000">
-							<a:schemeClr val="phClr">
-								<a:tint val="15000"/>
-								<a:satMod val="350000"/>
-							</a:schemeClr>
-						</a:gs>
-					</a:gsLst>
-					<a:lin ang="16200000" scaled="1"/>
-				</a:gradFill>
-				<a:gradFill rotWithShape="1">
-					<a:gsLst>
-						<a:gs pos="0">
-							<a:schemeClr val="phClr">
-								<a:shade val="51000"/>
-								<a:satMod val="130000"/>
-							</a:schemeClr>
-						</a:gs>
-						<a:gs pos="80000">
-							<a:schemeClr val="phClr">
-								<a:shade val="93000"/>
-								<a:satMod val="130000"/>
-							</a:schemeClr>
-						</a:gs>
-						<a:gs pos="100000">
-							<a:schemeClr val="phClr">
-								<a:shade val="94000"/>
-								<a:satMod val="135000"/>
-							</a:schemeClr>
-						</a:gs>
-					</a:gsLst>
-					<a:lin ang="16200000" scaled="0"/>
-				</a:gradFill>
-			</a:fillStyleLst>
-			<a:lnStyleLst>
-				<a:ln w="9525" cap="flat" cmpd="sng" algn="ctr">
-					<a:solidFill>
-						<a:schemeClr val="phClr">
-							<a:shade val="95000"/>
-							<a:satMod val="105000"/>
-						</a:schemeClr>
-					</a:solidFill>
-					<a:prstDash val="solid"/>
-				</a:ln>
-				<a:ln w="25400" cap="flat" cmpd="sng" algn="ctr">
-					<a:solidFill>
-						<a:schemeClr val="phClr"/>
-					</a:solidFill>
-					<a:prstDash val="solid"/>
-				</a:ln>
-				<a:ln w="38100" cap="flat" cmpd="sng" algn="ctr">
-					<a:solidFill>
-						<a:schemeClr val="phClr"/>
-					</a:solidFill>
-					<a:prstDash val="solid"/>
-				</a:ln>
-			</a:lnStyleLst>
-			<a:effectStyleLst>
-				<a:effectStyle>
-					<a:effectLst>
-						<a:outerShdw blurRad="40000" dist="20000" dir="5400000" rotWithShape="0">
-							<a:srgbClr val="000000">
-								<a:alpha val="38000"/>
-							</a:srgbClr>
-						</a:outerShdw>
-					</a:effectLst>
-				</a:effectStyle>
-				<a:effectStyle>
-					<a:effectLst>
-						<a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0">
-							<a:srgbClr val="000000">
-								<a:alpha val="35000"/>
-							</a:srgbClr>
-						</a:outerShdw>
-					</a:effectLst>
-				</a:effectStyle>
-				<a:effectStyle>
-					<a:effectLst>
-						<a:outerShdw blurRad="40000" dist="23000" dir="5400000" rotWithShape="0">
-							<a:srgbClr val="000000">
-								<a:alpha val="35000"/>
-							</a:srgbClr>
-						</a:outerShdw>
-					</a:effectLst>
-					<a:scene3d>
-						<a:camera prst="orthographicFront">
-							<a:rot lat="0" lon="0" rev="0"/>
-						</a:camera>
-						<a:lightRig rig="threePt" dir="t">
-							<a:rot lat="0" lon="0" rev="1200000"/>
-						</a:lightRig>
-					</a:scene3d>
-					<a:sp3d>
-						<a:bevelT w="63500" h="25400"/>
-					</a:sp3d>
-				</a:effectStyle>
-			</a:effectStyleLst>
-			<a:bgFillStyleLst>
-				<a:solidFill>
-					<a:schemeClr val="phClr"/>
-				</a:solidFill>
-				<a:gradFill rotWithShape="1">
-					<a:gsLst>
-						<a:gs pos="0">
-							<a:schemeClr val="phClr">
-								<a:tint val="40000"/>
-								<a:satMod val="350000"/>
-							</a:schemeClr>
-						</a:gs>
-						<a:gs pos="40000">
-							<a:schemeClr val="phClr">
-								<a:tint val="45000"/>
-								<a:shade val="99000"/>
-								<a:satMod val="350000"/>
-							</a:schemeClr>
-						</a:gs>
-						<a:gs pos="100000">
-							<a:schemeClr val="phClr">
-								<a:shade val="20000"/>
-								<a:satMod val="255000"/>
-							</a:schemeClr>
-						</a:gs>
-					</a:gsLst>
-					<a:path path="circle">
-						<a:fillToRect l="50000" t="-80000" r="50000" b="180000"/>
-					</a:path>
-				</a:gradFill>
-				<a:gradFill rotWithShape="1">
-					<a:gsLst>
-						<a:gs pos="0">
-							<a:schemeClr val="phClr">
-								<a:tint val="80000"/>
-								<a:satMod val="300000"/>
-							</a:schemeClr>
-						</a:gs>
-						<a:gs pos="100000">
-							<a:schemeClr val="phClr">
-								<a:shade val="30000"/>
-								<a:satMod val="200000"/>
-							</a:schemeClr>
-						</a:gs>
-					</a:gsLst>
-					<a:path path="circle">
-						<a:fillToRect l="50000" t="50000" r="50000" b="50000"/>
-					</a:path>
-				</a:gradFill>
-			</a:bgFillStyleLst>
-		</a:fmtScheme>
-	</a:themeElements>
-	<a:objectDefaults/>
-	<a:extraClrSchemeLst/>
-</a:theme>

Разница между файлами не показана из-за своего большого размера
+ 0 - 1459
report/src/excel_util/rpt_excel_util.ts


+ 0 - 16
report/src/excel_util/test/demo.test.ts

@@ -1,16 +0,0 @@
-/**
- * demo of unit test
- */
-
-import * as chai from 'chai';
-import Demo from './demo';
-
-// Demo类的测试声明
-const expect = chai.expect;
-describe('Demo', function () {
-    describe('Demo.getSum', function() {
-        it('1+1 应该等于 2', function() {
-            expect(Demo.getSum([1, 1])).to.be.equal(2);
-        });
-    });
-});

+ 0 - 15
report/src/excel_util/test/demo.ts

@@ -1,15 +0,0 @@
-
-export default class Demo {
-    /**
-     * @name getSum
-     * @description 求和demo
-     * @param arg 
-     */
-    public static getSum (arg: Array<number>): number {
-        let sum: number = 0;
-        for (let i in arg) {
-            sum += arg[i];
-        }
-        return sum;
-    }
-}

+ 0 - 2
report/src/pdfUnit/index.ts

@@ -1,2 +0,0 @@
-export * from './rpt_font_util';
-// export * from './rpt_pdf_util';

+ 0 - 26
report/src/pdfUnit/rpt_font_util.ts

@@ -1,26 +0,0 @@
-/**
- * Created by Tony on 2018/8/2.
- */
-
-let fontMapObj:Record<string,string> = {
-    "宋体": "Smart"
-    ,"楷体": "simkai"
-    ,"黑体": "simhei"
-};
-//下划线在option中支持
-//另注意:PDFkit设置字体的时候会检测是否同源,也就是说,如果是同一种字体转换不同的特性(如粗体、斜体),那么在设置的时候会无效
-//      比如前一种是普通的字体,后来想设置这种字体的斜体,实际上这种设置会失效
-
-
-export const getActualFont=(mapName:string, isBold:boolean, isItalic:boolean) =>{
-    let rst = ["Smart"];
-    if (fontMapObj[mapName]) rst[0] = fontMapObj[mapName];
-    if (isBold) {
-        rst.push("_bold");
-    }
-    if (isItalic) {
-        rst.push("_italic");
-    }
-    return rst.join("");
-}
-export default {}

+ 0 - 542
report/src/pdfUnit/rpt_pdf_util.ts

@@ -1,542 +0,0 @@
-// /**
-//  * Created by Tony on 2019/9/10.
-//  */
-
-// import { IArea, ICell, IControlCollection, IFontCollection, IFontSubCollection, IMergeBand, IPreviewPage, IRptTpl, IStyleCollection, IStyles } from '../interface/basic';
-// import { jsPDF as JsPDF } from 'jspdf';
-// import { Canvas } from 'canvas';
-// import JV from '../core/jpc_value_define';
-// const PDF_SCALE = 0.75;
-// // const DPI = getScreenDPI();
-
-// export default class JpcJsPDFHelper {
-//   doc: JsPDF;
-
-//   initialize(
-//     orientation: string ,
-//     unit: 'pt' | 'px' | 'in' | 'mm' | 'cm' | 'ex' | 'em' | 'pc',
-//     format: string | number[]
-//   ) {
-//     this.doc = new JsPDF(orientation, unit, format);
-//   }
-
-
-//   outputAsPdf(pageData:IPreviewPage, paperSize:string, pdfName:string) {
-//     const me = this;
-//     const offsetX = 0;
-//     const offsetY = 0;
-//     const newName = pdfName;
-//     const pageObj = pageData;
-//     const paperSizeIdx = JV.PAGES_SIZE_STR.indexOf(paperSize);
-//     const size = JV.PAGES_SIZE[paperSizeIdx];
-//     let orientation = '';
-//     if (pageData.打印页面_信息.纸张宽高[0] > pageData.打印页面_信息.纸张宽高[1]) {
-//       orientation = 'landscape';
-//     } else {
-//       orientation = 'portrait';
-//     }
-//     this.doc = me.initialize(orientation, 'pt', paperSize.toLowerCase());
-//     const {doc}=this;
-//     doc.setFont('SmartSimsun', 'normal'); // 目前只考虑宋体
-
-
-//     const privateDrawCell=(doc:JsPDF, ctx:Canvas, cell:ICell, fonts:IFontCollection, styles:IStyles, controls:IControlCollection, mergedBand:IMergeBand) =>{
-//       ctx.beginPath();
-//       const style = styles[cell.style];
-//       if (style) {
-//         const isNeedMergeBand = private_chkIfInMergedBand(mergedBand, cell);
-//         private_drawLine(
-//           cell,
-//           doc,
-//           ctx,
-//           style,
-//           'Top',
-//           ['Left', 'Top'],
-//           ['Right', 'Top'],
-//           mergedBand,
-//           styles,
-//           isNeedMergeBand
-//         );
-//         private_drawLine(
-//           cell,
-//           doc,
-//           ctx,
-//           style,
-//           'Right',
-//           ['Right', 'Top'],
-//           ['Right', 'Bottom'],
-//           mergedBand,
-//           styles,
-//           isNeedMergeBand
-//         );
-//         private_drawLine(
-//           cell,
-//           doc,
-//           ctx,
-//           style,
-//           'Bottom',
-//           ['Right', 'Bottom'],
-//           ['Left', 'Bottom'],
-//           mergedBand,
-//           styles,
-//           isNeedMergeBand
-//         );
-//         private_drawLine(
-//           cell,
-//           doc,
-//           ctx,
-//           style,
-//          'Left',
-//           ['Left', 'Bottom'],
-//           ['Left', 'Top'],
-//           mergedBand,
-//           styles,
-//           isNeedMergeBand
-//         );
-//       }
-//       private_drawCellText(doc, ctx, cell, fonts, controls);
-//       ctx.closePath();
-//     }
-    
-//     const private_chkIfInMergedBand=(mergedBand:IMergeBand, cell:ICell)=> {
-//       let rst = false;
-//       if (mergedBand && cell) {
-//         rst =
-//           mergedBand.Top <= cell.area.Top&&
-//           mergedBand.Bottom >= cell.area.Bottom &&
-//           mergedBand.Left<= cell.area.Left &&
-//           mergedBand.Right >= cell.area.Right;
-//       }
-//       return rst;
-//     }
-
-//     const private_drawLine=(
-//       cell:ICell,
-//       doc:JsPDF,
-//       ctx:Canvas,
-//       style:IStyles,
-//       styleBorderDest:'Top'|'Left'|'Right'|'Bottom',
-//       startP:['Top'|'Left'|'Right'|'Bottom','Top'|'Left'|'Right'|'Bottom'],
-//       destP:['Top'|'Left'|'Right'|'Bottom','Top'|'Left'|'Right'|'Bottom'],
-//       mergedBand:IMergeBand,
-//       styles:Record<string,IStyleCollection>,
-//       isNeedMergeBand:boolean
-//     ) =>{
-//       let destStyle = style;
-//       if (mergedBand) {
-//         if (
-//           isNeedMergeBand &&
-//           parseFloat(`${mergedBand[styleBorderDest]}`) === parseFloat(`${cell.area[styleBorderDest]}`)
-//         ) {
-//           Object.assign(destStyle, styles[mergedBand.style.ID])
-//         }
-//       }
-//       if (destStyle[styleBorderDest] && parseFloat(destStyle[styleBorderDest][JV.PROP_LINE_WEIGHT]) !== 0) {
-//         doc.setDrawColor(destStyle[styleBorderDest][JV.PROP_COLOR]);
-//         if (parseInt(destStyle[styleBorderDest][JV.PROP_LINE_WEIGHT]) === 2) {
-//           doc.setLineWidth(1 * destStyle[styleBorderDest][JV.PROP_LINE_WEIGHT]);
-//         } else {
-//           doc.setLineWidth(0.1);
-//         }
-//         doc.line(
-//           (cell.area[startP[0]] + offsetX) * PDF_SCALE,
-//           (cell.area[startP[1]] + offsetY) * PDF_SCALE,
-//           (cell.area[destP[0]] + offsetX) * PDF_SCALE,
-//           (cell.area[destP[1]] + offsetY) * PDF_SCALE
-//         );
-//       }
-//     }
-
-//     const private_drawCellText=(doc:JsPDF, ctx:Canvas, cell:ICell, fonts:IFontCollection, controls:IControlCollection)=> {
-//       if (cell.Value !== undefined && cell.Value !== null) {
-//         const values = `${cell.Value}`.split('|');
-//         // let font = fonts[cell[JV.PROP_FONT]];
-//         let font = null;
-//         if (typeof cell.font === 'string') {
-//           font = fonts[cell.font];
-//         } else {
-//           font = cell.font;
-//         }
-//         if (font[JV.FONT_PROPS[JV.FONT_PROP_IDX_BOLD]] === 'T') {
-//           doc.setFont('SmartSimsun', 'bold');
-//           // doc.setFontStyle("bold");
-//         } else {
-//           doc.setFont('SmartSimsun', 'normal');
-//         }
-//         // let control = controls[cell[JV.PROP_CONTROL]];
-//         let control = null;
-//         if (typeof cell.control === 'string') {
-//           control = controls[cell.control];
-//         } else {
-//           control = cell.control;
-//         }
-//         const height = cell.area.Bottom - cell.area.Top;
-//         const area = [
-//           cell.area.Left + offsetX,
-//           cell.area.Top + offsetY,
-//           cell.area.Right+ offsetX,
-//           cell.area.Bottom + offsetY,
-//         ];
-//         let ah = height;
-//         let restTopH = 0;
-//         let restBottomH = 0;
-//         if (control.CloseOutput === 'T') {
-//           ah =
-//             (parseFloat(`${font.FontHeight}`) +
-//               JV.OUTPUT_OFFSET[JV.OFFSET_IDX_TOP] +
-//               JV.OUTPUT_OFFSET[JV.OFFSET_IDX_BOTTOM]) *
-//             values.length;
-//           const restH = height - ah;
-//           if (control.Vertical === 'center') {
-//             restTopH = restH / 2;
-//             restBottomH = restH / 2;
-//           } else if (control.Vertical === 'bottom') {
-//             restBottomH = restH;
-//           } else {
-//             restTopH = restH;
-//           }
-//         }
-//         let spaceIdxArr = [];
-//         for (let i = 0; i < values.length; i++) {
-//           area[JV.IDX_TOP] = cell.area.Top + i * (ah / values.length) + offsetY + restTopH;
-//           area[JV.IDX_BOTTOM] =
-//             cell.area.Top + (i + 1) * (ah / values.length) + offsetY + restBottomH;
-//           if (values[i] === null || values[i] === undefined || values[i] === 'null') {
-//             values[i] = '';
-//           }
-//           // 因pdfkit输出空格只有浏览器的一半宽度,需要额外加空格补上,jspdf也有这个情况 -----------------------------
-//           if (typeof values[i] === 'string') {
-//             for (let j = 0; j < values[i].length; j++) {
-//               if (values[i][j] === ' ') spaceIdxArr.push(j);
-//             }
-//           }
-//           for (let j = spaceIdxArr.length - 1; j >= 0; j--) {
-//             values[i] = `${values[i].slice(0, spaceIdxArr[j])} ${values[i].slice(spaceIdxArr[j])}`;
-//           }
-//           // -----------------------------
-//           private_drawText(doc, ctx, values[i], area, font, control);
-//           spaceIdxArr = [];
-//         }
-//       }
-//     }
-
-//     const private_drawText=(doc:JsPDF, ctx:Canvas, val:string, area:number[], font:IFontSubCollection, control:IControlCollection)=> {
-//       let dftFontHeight = 12;
-//       const output:any = [];
-//       if (font) {
-//         dftFontHeight = 1 * font.FontHeight;
-//         doc.setFontSize(dftFontHeight);
-//       }
-//       // doc.font(fontFile);
-//       const options = {};
-//       const inner_setupControl =  (outVal: string, inArea: IArea, inFontHeight: number, inOutput: any[])=> {
-//         if (control) {
-//           private_setupAreaH(outVal, inArea, control.Horizon, font.FontAngle, inFontHeight, inOutput, options);
-//           private_setupAreaV(outVal, inArea, control.Vertical, font.FontAngle, inFontHeight, inOutput);
-//         } else {
-//           private_setupAreaH(outVal, inArea, 'left', parseInt(`${font.FontAngle}`), inFontHeight, inOutput, options);
-//           private_setupAreaV(outVal, inArea, 'bottom', parseInt(`${font.FontAngle}`), inFontHeight, inOutput);
-//         }
-//       };
-//       inner_setupControl(val, area, dftFontHeight, output);
-//       let validAreaTxtWidth =
-//         area[JV.IDX_RIGHT] -
-//         JV.OUTPUT_OFFSET[JV.OFFSET_IDX_RIGHT] -
-//         area[JV.IDX_LEFT] -
-//         JV.OUTPUT_OFFSET[JV.OFFSET_IDX_RIGHT];
-//       let validTxtLines = Math.floor(
-//         (area[JV.IDX_BOTTOM] - area[JV.IDX_TOP]) /
-//           (dftFontHeight + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_BOTTOM] + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_TOP] + 4)
-//       );
-//       if (parseInt(`${font.FontAngle}`) !== 0) {
-//         validAreaTxtWidth =
-//           area[JV.IDX_BOTTOM] -
-//           JV.OUTPUT_OFFSET[JV.OFFSET_IDX_BOTTOM] -
-//           area[JV.IDX_TOP] -
-//           JV.OUTPUT_OFFSET[JV.OFFSET_IDX_TOP];
-//         validTxtLines = Math.floor(
-//           (area[JV.IDX_RIGHT] - area[JV.IDX_LEFT]) /
-//             (dftFontHeight + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_RIGHT] + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_LEFT] + 4)
-//         );
-//       }
-
-//       const private_drawUnderline=(underLineVal, underLineArea)=> {
-//         // A. 暂不支持角度; B. PDF输出时,坐标没有translate
-//         // let ctx = doc;
-//         // 1. 计算下划线的相关坐标
-//         let width = doc.getTextWidth(underLineVal);
-//         if (width > underLineArea[JV.IDX_RIGHT] - underLineArea[JV.IDX_LEFT]) {
-//           width = underLineArea[JV.IDX_RIGHT] - underLineArea[JV.IDX_LEFT];
-//         }
-//         const height = dftFontHeight;
-//         let startX = underLineArea[JV.IDX_LEFT];
-//         let startY = underLineArea[JV.IDX_TOP];
-//         let endX = underLineArea[JV.IDX_RIGHT];
-//         let endY = underLineArea[JV.IDX_BOTTOM];
-//         // let startX = 0, startY = 0, endX = width, endY = startY;
-//         if (control.Horizon === 'left') {
-//           startX = Math.round(underLineArea[JV.IDX_LEFT] + JV.OUTPUT_OFFSET[JV.IDX_LEFT]);
-//         } else if (control.Horizon === 'right') {
-//           startX = Math.round(underLineArea[JV.IDX_RIGHT] - width - JV.OUTPUT_OFFSET[JV.IDX_RIGHT]);
-//         } else {
-//           startX = Math.round(
-//             underLineArea[JV.IDX_LEFT] + (underLineArea[JV.IDX_RIGHT] - underLineArea[JV.IDX_LEFT] - width) / 2
-//           );
-//         }
-//         endX = Math.round(startX + width);
-
-//         if (control.Vertical === 'top') {
-//           startY = Math.round(
-//             underLineArea[JV.IDX_TOP] + JV.OUTPUT_OFFSET[JV.IDX_TOP] + JV.OUTPUT_OFFSET[JV.IDX_BOTTOM] + height
-//           );
-//         } else if (control.Vertical === 'bottom') {
-//           startY = Math.round(underLineArea[JV.IDX_BOTTOM] + JV.OUTPUT_OFFSET[JV.IDX_BOTTOM]);
-//         } else {
-//           startY =
-//             Math.round(
-//               underLineArea[JV.IDX_TOP] + (underLineArea[JV.IDX_BOTTOM] - underLineArea[JV.IDX_TOP] + height) / 2
-//             ) +
-//             JV.OUTPUT_OFFSET[JV.IDX_TOP] +
-//             JV.OUTPUT_OFFSET[JV.IDX_BOTTOM];
-//         }
-//         endY = Math.round(startY);
-//         // 2. 画线
-//         // ctx.save();
-//         if (output[1] !== Math.round(output[1])) {
-//           ctx.translate(0, 0.5);
-//         }
-
-//         doc.setDrawColor('BLACK');
-//         doc.setLineWidth(0.1);
-//         doc.line(startX * PDF_SCALE, startY * PDF_SCALE, endX * PDF_SCALE, endY * PDF_SCALE);
-//       }
-
-//       let rotateOptions;
-//       if (parseInt(font.FontAngle) !== 0) {
-//         if (control) {
-//           rotateOptions = private_setupAreaRotateOption(
-//             area,
-//             validAreaTxtWidth,
-//             control.Vertical,
-//             dftFontHeight,
-//             output
-//           );
-//         } else {
-//           rotateOptions = private_setupAreaRotateOption(area, validAreaTxtWidth, 'bottom', dftFontHeight, output);
-//         }
-//         doc.rotate(font.FontAngle, rotateOptions);
-//       }
-//       if (
-//         validAreaTxtWidth >= doc.getTextWidth(val) ||
-//         (control && control.Shrink !== 'T' && validTxtLines < private_splitString(val, validAreaTxtWidth, doc))
-//       ) {
-//         options.width = validAreaTxtWidth * PDF_SCALE;
-//         options.height = dftFontHeight * PDF_SCALE;
-//         doc.setFontSize(dftFontHeight);
-//         if (font[JV.FONT_PROPS[5]] === 'T' && parseInt(font.FontAngle) === 0) {
-//           private_drawUnderline(val, area);
-//         }
-//         doc.setFontSize(dftFontHeight * PDF_SCALE);
-//         doc.text(output[0] * PDF_SCALE, output[1] * PDF_SCALE, val);
-//       } else {
-//         while (true) {
-//           let lines = Math.floor(
-//             (area[JV.IDX_BOTTOM] - area[JV.IDX_TOP]) /
-//               (dftFontHeight + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_BOTTOM] + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_TOP] + 4)
-//           );
-//           lines = lines === 0 || (control.Shrink === 'T' && control.ShrinkFirst === 'T') ? 1 : lines;
-//           const actLines = private_splitString(val, validAreaTxtWidth, doc);
-//           if (actLines.length > lines && dftFontHeight >= 6) {
-//             dftFontHeight--;
-//             doc.setFontSize(dftFontHeight);
-//             options.width = validAreaTxtWidth * PDF_SCALE;
-//             options.height = dftFontHeight * PDF_SCALE;
-//           } else {
-//             const aH = dftFontHeight + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_BOTTOM] + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_TOP] + 4;
-//             if (
-//               aH * actLines.length < area[JV.IDX_BOTTOM] - area[JV.IDX_TOP] &&
-//               control &&
-//               control.Vertical !== 'top'
-//             ) {
-//               if (control.Vertical === 'bottom') {
-//                 area[JV.IDX_TOP] = area[JV.IDX_BOTTOM] - aH * actLines.length;
-//               } else {
-//                 area[JV.IDX_TOP] = (area[JV.IDX_TOP] + area[JV.IDX_BOTTOM]) / 2 - (aH * actLines.length) / 2;
-//                 area[JV.IDX_BOTTOM] = area[JV.IDX_TOP] + aH * actLines.length;
-//               }
-//             }
-//             const newArea = [];
-//             const baseTop = area[JV.IDX_TOP];
-//             for (let ai = 0; ai < area.length; ai++) {
-//               newArea[ai] = area[ai];
-//             }
-//             options.width = validAreaTxtWidth * PDF_SCALE;
-//             options.height = dftFontHeight * PDF_SCALE;
-//             for (let lIdx = 0; lIdx < actLines.length; lIdx++) {
-//               newArea[JV.IDX_TOP] = Math.round(aH * lIdx + baseTop);
-//               newArea[JV.IDX_BOTTOM] = Math.round(aH * (lIdx + 1) + baseTop);
-//               doc.setFontSize(dftFontHeight);
-//               inner_setupControl(actLines[lIdx], newArea, dftFontHeight, output);
-//               if (font[JV.FONT_PROPS[5]] === 'T' && parseInt(font.FontAngle) === 0) {
-//                 private_drawUnderline(actLines[lIdx], newArea);
-//               }
-//               doc.setFontSize(dftFontHeight * PDF_SCALE);
-//               doc.text(output[0] * PDF_SCALE, output[1] * PDF_SCALE, actLines[lIdx]);
-//             }
-//             break;
-//           }
-//         }
-//       }
-//     }
-
-//     const private_setupAreaH=(outVal, area, type, fontAngle, dftFontHeight, outputPoint, options)=> {
-//       // jspdf输出方式不同(但与H5的canvas处理方式有所不同,因为没有相关alignment属性,需要自己算,而且角度还暂时不支持)-------------------------------------------
-//       let lType = type;
-//       if (type !== 'left' && type !== 'right' && type !== 'center') lType = 'left';
-//       switch (lType) {
-//         case 'left':
-//           if (fontAngle === JV.VERTICAL_ANGLE_INT) {
-//             // outputPoint[1] = 1 * area[JV.IDX_TOP] + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_LEFT];
-//           } else if (fontAngle === JV.ANTI_VERTICAL_ANGLE_INT) {
-//             // outputPoint[1] = 1 * area[JV.IDX_BOTTOM] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_LEFT];
-//           } else {
-//             outputPoint[0] = 1 * area[JV.IDX_LEFT] + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_LEFT];
-//           }
-//           // ctx.textAlign="start";
-//           break;
-//         case 'right':
-//           if (fontAngle === JV.VERTICAL_ANGLE_INT) {
-//             outputPoint[1] = 1 * area[JV.IDX_BOTTOM] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_RIGHT];
-//           } else if (fontAngle === JV.ANTI_VERTICAL_ANGLE_INT) {
-//             outputPoint[1] = 1 * area[JV.IDX_TOP] + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_RIGHT];
-//           } else {
-//             const width = doc.getTextWidth(outVal);
-//             outputPoint[0] = 1 * area[JV.IDX_RIGHT] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_RIGHT] - width;
-//           }
-//           // ctx.textAlign="end";
-//           break;
-//         case 'center':
-//           if (fontAngle === JV.VERTICAL_ANGLE_INT || fontAngle === JV.ANTI_VERTICAL_ANGLE_INT) {
-//             outputPoint[1] = (1 * area[JV.IDX_TOP] + 1 * area[JV.IDX_BOTTOM]) / 2;
-//           } else {
-//             const width = doc.getTextWidth(outVal);
-//             outputPoint[0] = (1 * area[JV.IDX_LEFT] + 1 * area[JV.IDX_RIGHT]) / 2 - width / 2;
-//           }
-//           // ctx.textAlign="center";
-//           break;
-//       }
-//     }
-
-//     const private_setupAreaV=(outVal, area, type, fontAngle, dftFontHeight, outputPoint)=> {
-//       // jspdf输出方式不同(与H5的canvas一样处理)-------------------------------------------
-//       let lType = type;
-//       if (type !== 'top' && type !== 'bottom' && type !== 'center') lType = 'top';
-//       switch (lType) {
-//         case 'top':
-//           if (fontAngle === JV.VERTICAL_ANGLE_INT) {
-//             outputPoint[0] = 1 * area[JV.IDX_RIGHT] - dftFontHeight - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_TOP];
-//           } else if (fontAngle === JV.ANTI_VERTICAL_ANGLE_INT) {
-//             outputPoint[0] = 1 * area[JV.IDX_LEFT] + dftFontHeight + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_TOP];
-//           } else outputPoint[1] = 1 * area[JV.IDX_TOP] + dftFontHeight + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_TOP];
-//           break;
-//         case 'bottom':
-//           if (fontAngle === JV.VERTICAL_ANGLE_INT) {
-//             outputPoint[0] = 1 * area[JV.IDX_LEFT] + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_BOTTOM];
-//           } else if (fontAngle === JV.ANTI_VERTICAL_ANGLE_INT) {
-//             outputPoint[0] = 1 * area[JV.IDX_RIGHT] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_BOTTOM];
-//           } else {
-//             outputPoint[1] = 1 * area[JV.IDX_BOTTOM] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_BOTTOM];
-//             // if (fontName === "宋体") outputPoint[1] = outputPoint[1] - 1;
-//             outputPoint[1] -= 1; // 宋体需要提上一个像素点
-//           }
-//           break;
-//         case 'center':
-//           if (fontAngle === JV.VERTICAL_ANGLE_INT) {
-//             outputPoint[0] = (1 * area[JV.IDX_LEFT] + 1 * area[JV.IDX_RIGHT] - dftFontHeight) / 2;
-//           } else if (fontAngle === JV.ANTI_VERTICAL_ANGLE_INT) {
-//             outputPoint[0] = (1 * area[JV.IDX_LEFT] + 1 * area[JV.IDX_RIGHT] + dftFontHeight) / 2;
-//           } else {
-//             outputPoint[1] = (1 * area[JV.IDX_TOP] + 1 * area[JV.IDX_BOTTOM] + dftFontHeight) / 2;
-//             // if (fontName === "宋体") outputPoint[1] = outputPoint[1] - 1;
-//             outputPoint[1] -= 1; // 宋体需要提上一个像素点
-//           }
-//           break;
-//       }
-//     }
-
-//     const private_splitString=(strVal, areaWidth, doc) =>{
-//       const rst = [];
-//       if (strVal) {
-//         let preSIdx = 0;
-//         let txtWidth = 0;
-//         let currentW = 0;
-//         const chnW = doc.getTextWidth('一');
-//         const otherW = doc.getTextWidth('_');
-//         for (let sIdx = 0; sIdx < strVal.length; sIdx++) {
-//           currentW = strVal.charCodeAt(sIdx) > 127 ? chnW : otherW;
-//           txtWidth += currentW;
-//           if (txtWidth > areaWidth) {
-//             if (preSIdx < sIdx) {
-//               rst.push(strVal.substr(preSIdx, sIdx - preSIdx));
-//               preSIdx = sIdx;
-//             } else {
-//               rst.push(strVal.substr(preSIdx, 1));
-//               preSIdx = sIdx + 1;
-//             }
-//             txtWidth = currentW;
-//           }
-//           if (sIdx === strVal.length - 1) {
-//             rst.push(strVal.substr(preSIdx, strVal.length - preSIdx));
-//           }
-//         }
-//       }
-//       if (rst.length === 0) rst.push(''); // 什么都没有,也得整个空串
-//       return rst;
-//     }
-
-//     const private_setupAreaRotateOption=(area, w, type = 'top', dftFontHeight, outputPoint)=> {
-//       const x = (area[JV.IDX_RIGHT] - area[JV.IDX_LEFT]) / 2 + area[JV.IDX_LEFT];
-//       const y = (area[JV.IDX_BOTTOM] - area[JV.IDX_TOP]) / 2 + area[JV.IDX_TOP];
-//       const rotateOptions = { origin: [x, y] };
-//       const h = area[JV.IDX_RIGHT] - area[JV.IDX_LEFT];
-//       outputPoint[0] = x - w / 2 + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_LEFT];
-//       switch (type) {
-//         case 'top':
-//           outputPoint[1] = y - h / 2 + JV.OUTPUT_OFFSET[JV.OFFSET_IDX_TOP];
-//           break;
-//         case 'bottom':
-//           outputPoint[1] = y + h / 2 - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_BOTTOM] - dftFontHeight;
-//           break;
-//         case 'center':
-//           outputPoint[1] = y + dftFontHeight / 2;
-//           break;
-//       }
-//       return rotateOptions;
-//     }
-//     const newPageMergeBand = {...pageObj.MergeBand};
-//     if (pageObj && pageObj.items.length > 0) {
-//       for (let i = 0; i < pageObj.items.length; i++) {
-//         if (i > 0) {
-//           doc.addPage(paperSize.toLowerCase(), orientation);
-//         }
-//         const ctx = doc.canvas.getContext();
-//         const page = pageObj.items[i];
-//         const fonts = pageObj.control_collection;
-//         const styles = pageObj.style_collection;
-//         const controls = pageObj.control_collection;
-
-//         if (page.page_merge_border) {
-//           Object.assign(newPageMergeBand,page.page_merge_border);
-//         }
-//         for (let j = 0; j < page.cells.length; j++) {
-//           const cell = page.cells[j];
-//           privateDrawCell(doc, ctx, cell, fonts, styles, controls, newPageMergeBand);
-//         }
-//       }
-//     }
-//     doc.save(`${newName}.pdf`);
-
-//   },
-// }
-
-

+ 197 - 0
report/src/public/commonConstants.ts

@@ -0,0 +1,197 @@
+// 部分数据从main_consts.js中抽出来,因为除了造价书界面,有一些页面也需要用到其中的变量
+// 但是其他页面直接引入整个main_consts.js不合理,且会报错(main_consts.js正常运行依赖main.html的一些内容)
+
+// 清单固定行
+const fixedFlag = {
+  // 分部分项工程
+  SUB_ENGINERRING: 1,
+  // 措施项目
+  MEASURE: 2,
+  // 施工技术措施项目
+  CONSTRUCTION_TECH: 3,
+  // 安全文明施工按实计算费用
+  SAFETY_CONSTRUCTION_ACTUAL: 4,
+  // 施工组织措施专项费用
+  CONSTRUCTION_ORGANIZATION: 5,
+  // 安全文明施工专项费用
+  SAFETY_CONSTRUCTION: 6,
+  // 其他项目
+  OTHER: 7,
+  // 暂列金额
+  PROVISIONAL: 8,
+  // 暂估价
+  ESTIMATE: 9,
+  // 材料(工程设备)暂估价
+  MATERIAL_PROVISIONAL: 10,
+  // 专业工程暂估价
+  ENGINEERING_ESITIMATE: 11,
+  // 计日工
+  DAYWORK: 12,
+  // 总承包服务费
+  TURN_KEY_CONTRACT: 13,
+  // 索赔与现场签证
+  CLAIM_VISA: 14,
+  // 规费
+  CHARGE: 15,
+  // 社会保险费及住房公积金 Social insurance fee and housing accumulation fund
+  SOCIAL_INSURANCE_HOUSING_FUND: 16,
+  // 工程排污费 charges for disposing pollutants
+  POLLUTANTS: 17,
+  // 税金
+  TAX: 18,
+  // 工程造价
+  ENGINEERINGCOST: 19,
+  // 增值税
+  ADDED_VALUE_TAX: 20,
+  // 专项技术措施暂估价
+  SPECIAL_TECH_PROVISIONAL: 21,
+  // 专业发包工程管理费
+  LET_CONTRACT_MANAGEMENT: 22,
+  // 人工
+  LABOUR: 23,
+  // 材料
+  MATERIAL: 24,
+  // 施工机械
+  MACHINE: 25,
+  // 索赔
+  CLAIM: 26,
+  // 现场签证
+  VISA: 27,
+  // 附加税
+  ADDITIONAL_TAX: 28,
+  // 环境保护税
+  ENVIRONMENTAL_PROTECTION_TAX: 29,
+  // 建设工程竣工档案编制费
+  PROJECT_COMPLETE_ARCH_FEE: 30,
+  // 住宅工程质量分户验收费
+  HOUSE_QUALITY_ACCEPT_FEE: 31,
+  // 组织措施费
+  ORGANIZATION: 32,
+  // 其他措施费
+  OTHER_MEASURE_FEE: 33,
+  // 绿色施工安全防护措施费
+  GREEN_MEASURE_FEE: 34,
+  // 预算包干费
+  BUDGET_INCLUDE_WORK_FEE: 35,
+  // 工程优质费
+  PROJECT_HIGH_QUALITY_FEE: 36,
+  // 概算幅度差
+  BUDGET_ESTIMATE_DIFF: 37,
+  // 其他费用(与其他项目不同,参考广东的用法)
+  OTHER_FEE: 38,
+};
+// 清单类型
+const billType = {
+  DXFY: 1, // 大项费用
+  FB: 2, // 分部
+  FX: 3, // 分项
+  BILL: 4, // 清单
+  BX: 5, // 补项
+};
+// 定额类型
+const rationType = {
+  ration: 1,
+  volumePrice: 2,
+  gljRation: 3,
+  install: 4,
+  overHeight: 5, // 超高子目
+  itemIncrease: 6, // 子目增加
+};
+// 项目类型
+const projectType = {
+  Folder: 'Folder',
+  Project: 'Project',
+  Engineering: 'Engineering',
+  Tender: 'Tender',
+};
+// 计税方式
+const TaxType = {
+  NORMAL: 1,
+  SIMPLE: 2,
+};
+// 供货方式
+const supplyType = {
+  // 自行采购
+  ZXCG: 0,
+  // 部分甲供
+  BFJG: 1,
+  // 完全甲供
+  WQJG: 2,
+  // 甲供材料 (“完全甲供”改文字为“甲供材料”)
+  JGCL: 2,
+  // 甲定乙供
+  JDYG: 3,
+};
+const supplyText = {
+  // 自行采购
+  ZXCG: '自行采购',
+  // 部分甲供
+  BFJG: '部分甲供',
+  // 完全甲供
+  WQJG: '完全甲供',
+  // 甲定乙供
+  JDYG: '甲定乙供',
+};
+const SourceType = {
+  BILLS: 'bills',
+  RATION: 'ration',
+};
+const DEFAULT_REGION = '全省';
+
+// 补充人材机库
+const COMPLEMENTARY_LIB = 'complementaryLib';
+
+// 费用定额
+const COMPILATION = 'compilation';
+
+// 缓存key
+const StorageKey = {
+  // 主界面一旦出现这个缓存,马上提示
+  ONCE_MAIN_LOADED: 'onceMainLoaded',
+};
+
+// 分享权限变更的类型
+const SharePermissionChangeType = {
+  UPDATE_COOPERATE: 1,
+  UPDATE_COPY: 2,
+  CANCEL: 3,
+  SHARE: 4,
+  READ: 5,
+};
+
+// 页面目标
+const PageTarget = {
+  PM: 1, // 项目管理
+  MAIN: 2, // 造价书
+};
+
+const BlankType = {
+  NOT_FOUND: 1,
+  SHARE_CANCEL: 2,
+};
+
+// 分享库类型
+const ShareLibType = {
+  RATION_LIB: 1,
+  GLJ_LIB: 2,
+  BLOCK_LIB: 3,
+};
+
+export default {
+  fixedFlag,
+  billType,
+  rationType,
+  projectType,
+  TaxType,
+  supplyType,
+  supplyText,
+  SourceType,
+  DEFAULT_REGION,
+  COMPILATION,
+  COMPLEMENTARY_LIB,
+  StorageKey,
+  SharePermissionChangeType,
+  PageTarget,
+  BlankType,
+  ShareLibType,
+};

Разница между файлами не показана из-за своего большого размера
+ 913 - 0
report/src/public/pinyin.ts


+ 12 - 0
report/src/public/reportNumber.ts

@@ -0,0 +1,12 @@
+// 继承Number变量,在eval中使用
+import scMathUtil from './scMathUtil';
+
+export default class ReportNumber extends Number {
+  toDecimal(ADigit: unknown) {
+    const digit =
+      (ADigit != null || ADigit !== undefined) && typeof ADigit === 'number' && Number.isInteger(ADigit) && ADigit >= 0
+        ? -ADigit
+        : -2;
+    return scMathUtil.roundForObj(this, -digit);
+  }
+}

+ 148 - 0
report/src/public/rptCommon.ts

@@ -0,0 +1,148 @@
+// 数据的操作,加减乘除
+import { IRptTpl } from '../interface/basic';
+import { get } from 'lodash';
+
+import stringUtil from './stringUtil';
+import commonConstants from './commonConstants';
+
+// import StringUtil from './stringUtil';
+// const stringUtil = new StringUtil();
+// 为Date对象绑定转换日期的方法
+stringUtil.setupDateFormat();
+export class RptCommon {
+  template!: IRptTpl;
+
+  currentDataObj: any;
+
+  initialize(rptTpl: IRptTpl, currentDataObj: any) {
+    this.template = rptTpl;
+    this.currentDataObj = currentDataObj;
+  }
+
+  multiply(val1: number[], val2: number[], fixFormat: number) {
+    const rst = [];
+    let maxLen = val1.length;
+    let minLen = val2.length;
+    if (minLen > maxLen) {
+      maxLen += minLen;
+      minLen = maxLen - minLen;
+      maxLen -= minLen;
+    }
+    for (let i = 0; i < maxLen; i++) {
+      let value = (i < val1.length ? val1[i] : val1[minLen - 1]) * (i < val2.length ? val2[i] : val2[minLen - 1]);
+      if (value === null || value === undefined) {
+        value = 0;
+      }
+      if (fixFormat) value = parseFloat(value.toFixed(fixFormat));
+      rst.push(value);
+    }
+    return rst;
+  }
+
+  divide(val1: number[], val2: number[], fixFormat: number) {
+    const rst = [];
+    let maxLen = val1.length;
+    let minLen = val2.length;
+    if (minLen > maxLen) {
+      maxLen += minLen;
+      minLen = maxLen - minLen;
+      maxLen -= minLen;
+    }
+    for (let i = 0; i < maxLen; i++) {
+      let value = (i < val1.length ? val1[i] : val1[minLen - 1]) / (i < val2.length ? val2[i] : val2[minLen - 1]);
+      if (fixFormat) value = parseFloat(value.toFixed(fixFormat));
+      rst.push(value);
+    }
+    return rst;
+  }
+
+  plus(val1: number[], val2: number[], fixFormat: number) {
+    const rst = [];
+    let maxLen = val1.length;
+    let minLen = val2.length;
+    if (minLen > maxLen) {
+      maxLen += minLen;
+      minLen = maxLen - minLen;
+      maxLen -= minLen;
+    }
+    for (let i = 0; i < maxLen; i++) {
+      let value = (i < val1.length ? val1[i] : val1[minLen - 1]) + (i < val2.length ? val2[i] : val2[minLen - 1]);
+      if (fixFormat) value = parseFloat(value.toFixed(fixFormat));
+      rst.push(value);
+    }
+    return rst;
+  }
+
+  multiPlus(arrVal: number[][], fixFormat: number) {
+    const rst = [];
+    for (let i = 0; i < arrVal.length; i++) {
+      const valItem = arrVal[i];
+      if (i === 0) {
+        for (const dtl of valItem) {
+          let value = dtl;
+          if (fixFormat) value = parseFloat(value.toFixed(fixFormat));
+          rst.push(value);
+        }
+      } else {
+        for (let j = 0; j < valItem.length; j++) {
+          if (j < rst.length) {
+            let value: number = rst[j] + valItem[j];
+            if (fixFormat) value = parseFloat(value.toFixed(fixFormat));
+            rst[j] = value;
+          } else {
+            let value = valItem[j];
+            if (fixFormat) value = parseFloat(value.toFixed(fixFormat));
+            rst.push(value);
+          }
+        }
+      }
+    }
+    return rst;
+  }
+
+  minus(val1: number[], val2: number[], fixFormat: number) {
+    const rst = [];
+    let maxLen = val1.length;
+    let minLen = val2.length;
+    if (minLen > maxLen) {
+      maxLen += minLen;
+      minLen = maxLen - minLen;
+      maxLen -= minLen;
+    }
+    for (let i = 0; i < maxLen; i++) {
+      let value = (i < val1.length ? val1[i] : val1[minLen - 1]) - (i < val2.length ? val2[i] : val2[minLen - 1]);
+      if (fixFormat) value = parseFloat(value.toFixed(fixFormat));
+      rst.push(value);
+    }
+    return rst;
+  }
+
+  formatString(arrVal: string[], formatStr: string) {
+    const rst = [];
+    for (const val of arrVal) {
+      rst.push(stringUtil.replaceAll(formatStr, '%S', val));
+    }
+    return rst;
+  }
+
+  getSupplyType(srcValArr: Record<string, number>[]) {
+    const rst = [];
+    for (const val of srcValArr) {
+      let hasKey = false;
+      const { supplyType } = commonConstants;
+      for (const propKey in supplyType) {
+        if (get(supplyType, propKey) === val) {
+          hasKey = true;
+          rst.push(get(supplyType, propKey));
+          break;
+        }
+      }
+      if (!hasKey) {
+        rst.push('未知方式');
+      }
+    }
+    return rst;
+  }
+}
+
+export default { RptCommon };

+ 23 - 0
report/src/public/stringUtil.ts

@@ -1,3 +1,7 @@
+import Pinyin from './pinyin';
+import ReportDate from './ReportDate'
+
+const pinyin = new Pinyin();
 
 const isEmptyString = (str: string) => {
     let rst = false;
@@ -95,6 +99,17 @@ const convertStrToBoolean = (str: string) => {
     }
     return rst;
 }
+
+
+
+const getPinYinFullChars=(value: string) =>{
+    return pinyin.getFullChars(value);
+  }
+
+ const getPinYinCamelChars=(value: string)=> {
+    return pinyin.getCamelChars(value);
+  }
+
 const formatNumber = (formatStr: string, val: any) => {
     let rst = val;
     if (formatStr) {
@@ -127,6 +142,11 @@ const formatNumber = (formatStr: string, val: any) => {
     }
     return rst;
 }
+const setupDateFormat=()=> {
+    // 原本是直接向Date赋值的,但是现在ts不允许这么做,因此定义一个继承了Date的类使用
+    const newReportDate = new ReportDate();
+    Object.assign(Date, newReportDate);
+  }
 
 
 export default {
@@ -139,4 +159,7 @@ export default {
     convertToCaptionNum,
     convertStrToBoolean,
     formatNumber,
+    getPinYinFullChars,
+    getPinYinCamelChars,
+    setupDateFormat
 }