Prechádzať zdrojové kódy

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

zhangweicheng 5 rokov pred
rodič
commit
db801ce7ca

+ 1 - 1
tree/package.json

@@ -1,6 +1,6 @@
 {
 {
   "name": "@sc/tree",
   "name": "@sc/tree",
-  "version": "1.0.4",
+  "version": "1.0.7",
   "description": "a template for npm package coding",
   "description": "a template for npm package coding",
   "main": "./dist/index.cjs.js",
   "main": "./dist/index.cjs.js",
   "module": "./dist/index.esm.js",
   "module": "./dist/index.esm.js",

+ 70 - 5
tree/src/tree.ts

@@ -4,7 +4,7 @@ export interface TreeRaw {
   ID: string;
   ID: string;
   parentID: string;
   parentID: string;
   seq: number;
   seq: number;
-  [propName: string]: any;
+  [props: string]: any;
 }
 }
 
 
 export interface TreeNode extends TreeRaw {
 export interface TreeNode extends TreeRaw {
@@ -308,7 +308,7 @@ export class Tree {
     this.rawData.push(...nodes);
     this.rawData.push(...nodes);
     // 排序
     // 排序
     this.reSortData(nodes);
     this.reSortData(nodes);
-    return this.data;
+    return nodes;
   }
   }
 
 
   // 准备删除,返回所有需要删除的节点,包括嵌套节点
   // 准备删除,返回所有需要删除的节点,包括嵌套节点
@@ -319,7 +319,7 @@ export class Tree {
   /**
   /**
    * 删除节点
    * 删除节点
    * @param {TreeNode[]} treeNodes - 要删除的节点,不需要包含嵌套节点
    * @param {TreeNode[]} treeNodes - 要删除的节点,不需要包含嵌套节点
-   * @return {TreeNode[]} 返回删除节点后,树的data
+   * @return {TreeNode[]} 返回删除节点
    */
    */
   delete(treeNodes: TreeNode[]): TreeNode[] {
   delete(treeNodes: TreeNode[]): TreeNode[] {
     const allDeletedNodes: TreeNode[] = [];
     const allDeletedNodes: TreeNode[] = [];
@@ -351,7 +351,7 @@ export class Tree {
     deleteNodes(treeNodes);
     deleteNodes(treeNodes);
     // 排序
     // 排序
     this.reSortData(allDeletedNodes);
     this.reSortData(allDeletedNodes);
-    return this.data;
+    return allDeletedNodes;
   }
   }
 
 
   // IDList 返回所有需要删除的节点,包括嵌套节点
   // IDList 返回所有需要删除的节点,包括嵌套节点
@@ -468,10 +468,12 @@ export class Tree {
     }
     }
     // 最末节点的所有后兄弟节点,成为最末节点的子节点
     // 最末节点的所有后兄弟节点,成为最末节点的子节点
     const lastNodeNextBrothers = lastNode.getCtx().nextBrothers();
     const lastNodeNextBrothers = lastNode.getCtx().nextBrothers();
+    const lastNodeLastChild = lastNode.getCtx().lastChild();
+    const lastNodeLastChildSeq = lastNodeLastChild ? lastNodeLastChild.seq : 0;
     lastNodeNextBrothers.forEach((node, index) => {
     lastNodeNextBrothers.forEach((node, index) => {
       updateData.push({
       updateData.push({
         ID: node.ID,
         ID: node.ID,
-        update: { parentID: lastNode.ID, seq: index },
+        update: { parentID: lastNode.ID, seq: index + lastNodeLastChildSeq },
       });
       });
     });
     });
     return updateData;
     return updateData;
@@ -536,5 +538,68 @@ export class Tree {
       ...nodes
       ...nodes
     );
     );
     this.updateValue(updateData);
     this.updateValue(updateData);
+    this.reGenData();
+  }
+
+  // 准备移动节点块(连续的兄弟节点),不维护seq连号
+  prepareMoveTo(
+    nodes: TreeNode[],
+    parent: TreeNode | None,
+    next: TreeNode | None
+  ): UpdateData[] {
+    const updateData: UpdateData[] = [];
+    let prev: TreeNode | None;
+    if (next) {
+      prev = next.getCtx().prev();
+    } else {
+      prev = parent ? parent.getCtx().lastChild() : null;
+    }
+    const baseSeq = prev ? prev.seq + 1 : this.seqStartIndex;
+    updateData.push(
+      ...nodes.map((node, index) => ({
+        ID: node.ID,
+        update: {
+          parentID: (parent && parent.ID) || this.rootID,
+          seq: baseSeq + index,
+        },
+      }))
+    );
+    const curBaseSeq = baseSeq + nodes.length;
+    const nextBrothers = prev ? prev.getCtx().nextBrothers() : [];
+    updateData.push(
+      ...nextBrothers.map((node, index) => ({
+        ID: node.ID,
+        update: {
+          seq: curBaseSeq + index,
+        },
+      }))
+    );
+    return updateData;
+  }
+
+  moveTo(
+    nodes: TreeNode[],
+    parent: TreeNode | None,
+    updateData: UpdateData[]
+  ): void {
+    const firstNode = nodes[0];
+    const newParentID = parent ? parent.ID : this.rootID;
+    const orgParentID = firstNode.parentID;
+    const orgBrothers = this.parentMap[orgParentID];
+    orgBrothers.splice(orgBrothers.indexOf(firstNode), nodes.length);
+    (this.parentMap[newParentID] || (this.parentMap[newParentID] = [])).push(
+      ...nodes
+    );
+    this.updateValue(updateData);
+    this.resortDataByID([orgParentID, newParentID]);
+  }
+
+  // 清除所有节点(不变更data引用)
+  clear(): void {
+    this.rawData.splice(0, this.rawData.length);
+    this.data.splice(0, this.data.length);
+    this.parentMap = {};
+    this.IDMap = {};
+    this.ctxMap = {};
   }
   }
 }
 }

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

@@ -69,20 +69,20 @@ export enum supplyType {
   JDYG, // 甲定乙供
   JDYG, // 甲定乙供
 }
 }
 
 
-export interface IUpdate<T extends IAny> {
+export interface IUpdate<T extends IAny = any> {
   filter: T;
   filter: T;
   update: T;
   update: T;
 }
 }
 
 
-export interface ICreate<T extends IAny> {
+export interface ICreate<T extends IAny = any> {
   document: T;
   document: T;
 }
 }
 
 
-export interface IDelete<T extends IAny> {
+export interface IDelete<T extends IAny = any> {
   filter: T;
   filter: T;
 }
 }
 
 
-export interface IBulkWrite<T extends IAny> {
+export interface IBulkWrite<T extends IAny = any> {
   update?: IUpdate<T>[];
   update?: IUpdate<T>[];
   create?: ICreate<T>[];
   create?: ICreate<T>[];
   remove?: IDelete<T>[];
   remove?: IDelete<T>[];

+ 8 - 2
types/src/interface/project.ts

@@ -1,3 +1,4 @@
+import { ValuationType } from './compilation';
 import { ILabourCoeFile } from './labourCoe';
 import { ILabourCoeFile } from './labourCoe';
 import { IIncreaseSetting } from './increaseFee';
 import { IIncreaseSetting } from './increaseFee';
 import {
 import {
@@ -101,7 +102,7 @@ export enum FileTypeName {
 
 
 export const FileTypeMap = {
 export const FileTypeMap = {
   [FileType.SUBMISSION]: FileTypeName.SUBMISSION,
   [FileType.SUBMISSION]: FileTypeName.SUBMISSION,
-  [FileType.INVITATION]: FileTypeName.SUBMISSION,
+  [FileType.INVITATION]: FileTypeName.INVITATION,
   [FileType.CONTROL]: FileTypeName.CONTROL,
   [FileType.CONTROL]: FileTypeName.CONTROL,
 };
 };
 
 
@@ -156,6 +157,7 @@ export interface IEconomicIndex {
 // 项目属性
 // 项目属性
 export interface IProperty {
 export interface IProperty {
   rootProjectID?: string; // 建设项目ID
   rootProjectID?: string; // 建设项目ID
+  valuationType?: ValuationType; // 计价类型
   valuationID?: string; // 计价规则
   valuationID?: string; // 计价规则
   programID?: number; // 工程专业,填计算程序工程专业ID
   programID?: number; // 工程专业,填计算程序工程专业ID
   engineeringID?: string; // 工程专业ID
   engineeringID?: string; // 工程专业ID
@@ -184,7 +186,7 @@ export interface IProperty {
   progressiveLibID?: string; // 累进区间库
   progressiveLibID?: string; // 累进区间库
   lockBills?: boolean; // 锁定清单
   lockBills?: boolean; // 锁定清单
   decimal?: IDecimal; // 小数位数
   decimal?: IDecimal; // 小数位数
-  billsQuantityDecimal: IBillsQuantityDecimal[]; // 清单工程量精度
+  billsQuantityDecimal?: IBillsQuantityDecimal[]; // 清单工程量精度
   displaySetting?: IDisplaySetting; // 呈现选项
   displaySetting?: IDisplaySetting; // 呈现选项
   billsCalcMode?: number; // 清单计费取费方式
   billsCalcMode?: number; // 清单计费取费方式
   zanguCalcMode?: number; // 暂估合价计算方式
   zanguCalcMode?: number; // 暂估合价计算方式
@@ -238,6 +240,10 @@ export interface IProject extends ITreeScm {
   deleteType?: DeleteEnum;
   deleteType?: DeleteEnum;
   deleteDate?: number;
   deleteDate?: number;
   deleteBy?: string;
   deleteBy?: string;
+  // 只是为了显示,不是自身的正在数据,比如汇总信息等
+  external?: {
+    cost: number; // 工程造价
+  };
 }
 }
 
 
 export interface IProjectBulkRst {
 export interface IProjectBulkRst {