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

Merge branch 'master' of http://192.168.1.41:3000/SmartCost/SCCommon

# Conflicts:
#	tree/src/nodeCtx.ts
#	tree/src/tree.ts
vian 4 лет назад
Родитель
Сommit
457b40f959

+ 1 - 1
report/.eslintrc.js

@@ -19,7 +19,7 @@ module.exports = {
       {
         js: 'never',
         jsx: 'never',
-        ts: 'never',
+        ts: 'always',
         tsx: 'never',
         json: 'always',
       },

+ 2 - 0
report/src/core/helper/jpc_helper_common.ts

@@ -140,7 +140,9 @@ const JpcCommonHelper = {
         if (strVal) {
             let areaWidth = area.Right - area.Left - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_RIGHT] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_LEFT] - 1;
             let txtWidth = 0, currentW = 0;
+            // 这里是一个一个字获取宽度,然后在对比区域宽度,算出最后有多少行
             for (let sIdx = 0; sIdx < strVal.length; sIdx++) {
+                //大于127为中文字
                 currentW = (strVal.charCodeAt(sIdx) > 127) ? chnW : otherW;
                 txtWidth += currentW;
                 if (txtWidth > areaWidth) {

+ 6 - 6
report/src/core/jpc_ex.ts

@@ -308,10 +308,10 @@ class JpcExClass {
 
 //暂定
 const private_buildDftItems = (
-    rptTpl: any,
+    rptTpl: IRptTpl,
     dftCollection: IControlSubCollection[] | IFontSubCollection[] | null,
-    nodeName: string
-) => {
+    nodeName: string 
+) => { 
     const rst: any = {};
     if (dftCollection) {
         for (let i = 0; i < dftCollection.length; i++) {
@@ -319,9 +319,9 @@ const private_buildDftItems = (
             rst[dftCollection[i].ID] = { ...dftCollectionProps };
         }
         const propArray = (nodeName === 'control_collection') ? JV.CONTROL_PROPS : JV.FONT_PROPS;
-        if (rptTpl && rptTpl[nodeName] && rptTpl[nodeName].length) {
-            for (let i = 0; i < rptTpl[nodeName].length; i++) {
-                const rptDftItem = rptTpl[nodeName][i];
+        if (rptTpl && rptTpl[nodeName as keyof IRptTpl] && rptTpl[nodeName  as keyof IRptTpl].length) {
+            for (let i = 0; i < rptTpl[nodeName  as keyof IRptTpl].length; i++) {
+                const rptDftItem = rptTpl[nodeName  as keyof IRptTpl][i];
                 if (rst[rptDftItem.ID] === undefined) {
                     const item: any = {};
                     for (let j = 0; j < propArray.length; j++) {

+ 18 - 14
report/src/core/jpc_flow_tab.ts

@@ -44,8 +44,8 @@ class JpcFlowTabClass {
     segments: number[][];
     dispValueIdxLst: number[][][];
     page_seg_map: number[][];
-    disp_fields_idx: any[];
-    disp_fields_ex_idx: any[];
+    disp_fields_idx: number[];
+    disp_fields_ex_idx: number[];
     seg_sum_fields_idx: any[];
     seg_sum_tab_fields: any[];
     page_sum_fields_idx: any[];
@@ -811,7 +811,7 @@ class JpcFlowTabClass {
         return rst;
     };
     outputContent(rptTpl: IRptTpl, dataObj: IDataObj, page: number, bands: IBands, unitFactor: number, controls: IControlCollection, multiColIdx: number, $CURRENT_RPT: ICurrent_RPT, customizeCfg: ICustomizeCfg) {
-        let me = this, rst: any[] = [], prepareObj = {};
+        let me = this, rst: any[] = [], prepareObj =<IPageAreaObj>{};
         // let FLOW_NODE_STR = me.isEx?'流水式表_拓展信息':'流水式表_信息';
         let flow_node_str = me.isEx ? rptTpl.流水式表_拓展信息 : rptTpl.流水式表_信息;
         let tab = flow_node_str.流水式表_数据;
@@ -991,6 +991,8 @@ class JpcFlowTabClass {
                 }
             }
         }
+        //合并自动换行的格子,直接把第一个格子的值一个一个递增为目标值,并且把被合并的格子的id纪录下来,准备在下面进行删除
+        //(本来是一行一个格子的,此处通过表示对值进行递增)
         let eliminateCells = combineAutoHeightCells(prepareObj, page, controls);
         for (let idIdx = eliminateCells.length - 1; idIdx >= 0; idIdx--) {
             rst.splice(eliminateCells[idIdx], 1);
@@ -1439,7 +1441,7 @@ function _addPageValue(ValuedIdxLst: number[][][], sortedSequence: number[], grp
 }
 
 function push_cell(pageCellObj: IPageCellObj, cell: ICell, cellIdx: number) {
-    let key = cell.area.Left; + '_' + cell.area.Right;
+    let key = cell.area.Left + '_' + cell.area.Right;
     if (!pageCellObj[key]) {
         pageCellObj[key] = [];
     }
@@ -1461,7 +1463,7 @@ function setupControl(mergeCell: ICell, controls: IControlCollection) {
     let orgCtrl = null;
     if (typeof mergeCell.control === "string") {
         orgCtrl = controls[mergeCell.control];
-        mergeCell.control = {
+        mergeCell.control = <IControlSubCollection>{
             "Shrink": "T",
             "ShrinkFirst": orgCtrl.ShrinkFirst,
             "CloseOutput": orgCtrl.CloseOutput,
@@ -1470,7 +1472,7 @@ function setupControl(mergeCell: ICell, controls: IControlCollection) {
             "Vertical": orgCtrl.Vertical,
             "Wrap": (mergeCell.isAutoHeight) ? 'T' : 'F',
             "VerticalForExcel": "center"
-        } as IControlSubCollection;
+        };
     } else {
         mergeCell.control.Shrink = "T";
         mergeCell.control.Vertical = "top";
@@ -1488,22 +1490,25 @@ function setupControl(mergeCell: ICell, controls: IControlCollection) {
     return orgCtrl;
 }
 
-function combineAutoHeightCells(prepareObj: IPageAreaObj | {}, page: number, controls: IControlCollection) {
+function combineAutoHeightCells(prepareObj: IPageAreaObj , page: number, controls: IControlCollection) {
+    // 该方法主要是用来生成自动合并的格子的,本来是已经生成了一行一个格子的,但现在需要把可以自动合并的格子进行中整合,在这里进行这个动作
+    // 最后输出的是被合并的格子的index,在外面再剔除
     let rst = [];
-    if ((prepareObj as IPageAreaObj).cellsArr) {
+    if (prepareObj.cellsArr) {
         //merge cells' value and area
         //备注: 系统逻辑已经把Cell的顺序放好,无需再做排序。
-        for (let mergeKey in (prepareObj as IPageAreaObj).pageCellObj) {
-            let sameColCells = (prepareObj as IPageAreaObj).pageCellObj[mergeKey]; //左右位置相同的Cell先放在一起,统一处理
+        for (let mergeKey in prepareObj.pageCellObj) {
+            let sameColCells = prepareObj.pageCellObj[mergeKey]; //左右位置相同的Cell先放在一起,统一处理
             if (sameColCells.length > 1) {
-                //强转格式,此处是强制把本来是字符串的control属性转化为对象,by lish
-                let firstMergeCell = { ...sameColCells[0].cell, control: {} as IControlSubCollection }  as ICell;
+            //    这里获取第一个被合并的cell的数据
+                let firstMergeCell = sameColCells[0].cell ;
                 firstMergeCell.style = firstMergeCell.style.slice(0, firstMergeCell.style.indexOf("_AutoHeightMerge")); //首先还原original style
                 //生成原始对象,并且把对象中的control属性转化为对象
                 let orgCtrl = setupControl(firstMergeCell, controls);
                 let validValueAmt = 0, fullValidValueAmt = 0;
                 for (let i = 1; i < sameColCells.length; i++) {
                     let mergeCell = sameColCells[i].cell;
+                    //含有“_AutoHeightMerge_Top”的都是每个自动合并的cell的第一行(项)
                     if (mergeCell.style.indexOf("_AutoHeightMerge_Top") < 0) {
                         fullValidValueAmt++;
                         //merge into the firstMergeCell! position & value
@@ -1528,8 +1533,7 @@ function combineAutoHeightCells(prepareObj: IPageAreaObj | {}, page: number, con
                                 firstMergeCell.control.VerticalForExcel = 'center';
                             }
                         }
-                        //强制把已为对象的control属性还原成为字符串,by lish
-                        firstMergeCell = sameColCells[i].cell as unknown as ICell;
+                        firstMergeCell = <ICell>sameColCells[i].cell;
                         firstMergeCell.style = firstMergeCell.style.slice(0, firstMergeCell.style.indexOf("_AutoHeightMerge"));
                         orgCtrl = setupControl(firstMergeCell, controls);
                         validValueAmt = 0;

+ 1 - 1
report/src/interface/basic.ts

@@ -136,7 +136,7 @@ export interface IPageCellObj {
     }[];
 }
 export interface ICell {
-    font: string;
+    font: string | IFontSubCollection;
     control: IControlSubCollection|string;
     style: string;
     Value: number | string | null;

+ 4 - 1
tree/src/nodeCtx.ts

@@ -9,9 +9,12 @@ export class NodeContext<T extends TreeRaw = TreeRaw> {
   // 展开收起
   expanded = false;
 
-  constructor(node: TreeNode<T>, tree: Tree<T>) {
+  constructor(node: TreeNode<T>, tree: Tree<T>, expanded?: boolean) {
     this.ref = node;
     this.tree = tree;
+    if (expanded) {
+      this.expanded = expanded;
+    }
   }
 
   ID(): string {

+ 4 - 4
tree/src/tree.ts

@@ -62,7 +62,7 @@ export class Tree<T extends TreeRaw = TreeRaw> {
   // 节点上下文与节点ID映射
   ctxMap: CtxIDMap<T>;
 
-  constructor(rawData: TreeRaw[], rootID = '-1') {
+  constructor(rawData: TreeRaw[], rootID = '-1', expanded?: boolean) {
     this.rootID = rootID;
     this.rawData = this.genNodeContext(rawData);
     this.rawData = this.sort(this.rawData);
@@ -70,7 +70,7 @@ export class Tree<T extends TreeRaw = TreeRaw> {
     this.IDMap = {};
     this.parentMap = {};
     this.ctxMap = {};
-    this.genMap(this.rawData);
+    this.genMap(this.rawData, expanded);
     this.genData();
   }
 
@@ -95,10 +95,10 @@ export class Tree<T extends TreeRaw = TreeRaw> {
   }
 
   // 生成映射表
-  private genMap(data: TreeNode<T>[]): void {
+  private genMap(data: TreeNode<T>[], expanded?: boolean): void {
     data.forEach(item => {
       this.IDMap[item.ID] = item;
-      this.ctxMap[item.ID] = new NodeContext(item, this);
+      this.ctxMap[item.ID] = new NodeContext(item, this, expanded);
       (
         this.parentMap[item.parentID] || (this.parentMap[item.parentID] = [])
       ).push(item);

+ 1 - 1
types/src/interface/base.ts

@@ -193,7 +193,7 @@ export interface ISetData<T = any, F = any, R = any> {
   prop?: string; // 用来指表中的数组属性名,针对如configMaterial里,一个collections 里有多个数组数据的情况
   actionName?: ActionName; // 除了增删改查,还会有更复杂的操作,用这个来区分
   filter?: F; // 查询条件
-  update?: T; // 和update类型对应,
+  update?: Partial<T>; // 和update类型对应,
   documents?: T[]; // add 类型对应,批量插入
   odocs?: any[]; // 存放撤销的原始数据?
   result?: R; // 特殊的返回结果

+ 23 - 17
types/src/interface/compilation.ts

@@ -1,4 +1,3 @@
-import { ELockInfo } from './user';
 import { TaxType, IGLJCol } from './project';
 import { IFileRef, INumFileRef } from './base';
 
@@ -7,6 +6,7 @@ export interface ICptItem {
   name: string;
   description: string;
 }
+
 export interface IProgramLib extends INumFileRef {
   displayName: string;
 }
@@ -62,25 +62,31 @@ export enum versionType {
   PRO = 'pro', // 专业版
 }
 
+export enum LockInfo {
+  DEFAULT = 0, // 默认值
+  BORROW = 1, // 借用
+  BUY = 2, // 销售
+}
+
 export interface ICompilation {
   ID: string;
   name: string;
-  creator?: string;
-  createTime?: number;
-  releaseTime?: number;
-  rationValuations?: any;
-  billValuations?: IValuation[];
-  isRelease?: boolean;
-  description?: string;
-  overWriteUrl?: string;
-  categoryID?: string;
-  example?: number[];
-  adProjects?: number[];
+  creator: string;
+  createTime: number;
+  releaseTime: number;
+  rationValuations: any;
+  billValuations: IValuation[];
+  isRelease: boolean;
+  description: string;
+  overWriteUrl: string;
+  categoryID: string;
+  example: number[];
+  adProjects: number[];
 
   // 附加
-  version?: versionType; // 版本
-  versionText?: string; // 版本对应的显示文字:免费版,学习版,专业版
-  lockInfo?: ELockInfo; //
+  version: versionType; // 版本
+  versionText: string; // 版本对应的显示文字:免费版,学习版,专业版
+  lockInfo: LockInfo; // 锁信息
 }
 
 export enum ValuationType {
@@ -98,6 +104,6 @@ export interface IProCptItem {
   remark: string;
   // 截至时间,0 代表无限制
   deadline: number;
-  // 锁信息 1:借出;2:销售
-  lock: number;
+  // 锁信息
+  lock: LockInfo;
 }

+ 20 - 12
types/src/interface/enterprise.ts

@@ -6,13 +6,25 @@ export enum Relationship {
   IRRELEVANT = 'irrelevant',
 }
 
+export enum MemberRole {
+  ADMIN = 'admin',
+  STAFF = 'staff',
+}
+
+export enum MemberStatus {
+  NORMAL = 'normal',
+  DISABLED = 'disabled',
+  UNCONFIRMED = 'unconfirmed',
+}
+
 export interface IMember {
   userID: string;
   memberName: string;
   position: string;
-  status: 'normal' | 'disabled' | 'unconfirmed';
+  role: MemberRole;
+  status: MemberStatus;
   cptList: string[];
-  createProject: 'yes' | 'no';
+  createProject: boolean;
   projectView: 'self' | 'all';
   editProject: 'self' | 'all';
   exportProject: 'disabled' | 'self' | 'all';
@@ -20,24 +32,20 @@ export interface IMember {
   shareProject: 'disabled' | 'self' | 'all';
 }
 
-export interface IMemberInfo extends IMember {
-  role: 'admin' | 'staff';
-}
-
 export interface IEnterprise {
   ID: string;
-  adminID: string;
-  adminName: string;
   members: IMember[];
   activated: boolean;
   licenceNum: number;
   proCptList: IProCptItem[];
   usedCptList: string[];
-  enterpriseName: string;
+  // 公司名称
+  name: string;
   logo: string;
-  enterpriseLocation: string[];
-  enterpriseType: string;
-  enterpriseScale: string;
+  location: string[];
+  // 公司类型
+  type: string;
+  scale: string;
   createTime: number;
   passwordCheck: 'no' | 'weak' | 'normal' | 'strong' | 'super';
   subdomain: string;

+ 0 - 22
types/src/interface/user.ts

@@ -1,17 +1,5 @@
 import { IProCptItem } from './compilation';
 
-/* eslint-disable camelcase */
-export enum ELockInfo {
-  BORROW = 1, // 借用
-  BUY = 2, // 销售
-}
-
-export interface IUpgradeItemInfo {
-  compilationID: string;
-  isUpgrade: boolean;
-  lock?: ELockInfo;
-}
-
 // 实体类型
 export enum EntityType {
   // 个人
@@ -37,16 +25,6 @@ export enum UserType {
   PROFESSIONAL = 'professional',
 }
 
-export interface IUsed {
-  compilationId: string;
-}
-
-export interface ISpecifyCptItem {
-  accountType: string;
-  enterpriseID?: string;
-  cptID: string;
-}
-
 export interface IUsedCptItem {
   // 编办 ID
   compilationID: string;