Преглед изворни кода

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

zhangweicheng пре 5 година
родитељ
комит
c0e22c84b2

+ 1 - 0
overwrite/.eslintignore

@@ -0,0 +1 @@
+/dist

+ 42 - 0
overwrite/.eslintrc.js

@@ -0,0 +1,42 @@
+module.exports = {
+  env: {
+    browser: true,
+    es2021: true,
+    node: true,
+  },
+  extends: ['airbnb-base', 'plugin:@typescript-eslint/recommended', 'prettier'],
+  parser: '@typescript-eslint/parser',
+  parserOptions: {
+    ecmaVersion: 12,
+    sourceType: 'module',
+  },
+  plugins: ['@typescript-eslint', 'prettier'],
+  rules: {
+    'prettier/prettier': 'error',
+    'import/extensions': [
+      'error',
+      {
+        js: 'never',
+        jsx: 'never',
+        ts: 'never',
+        tsx: 'never',
+        json: 'always',
+      },
+    ],
+    'import/no-unresolved': 'off',
+    '@typescript-eslint/no-empty-function': 'off',
+    '@typescript-eslint/no-explicit-any': 'off',
+    'class-methods-use-this': 'off',
+    'import/prefer-default-export': 'off',
+    'no-unused-expressions': [
+      'error',
+      {
+        allowShortCircuit: true,
+      },
+    ],
+    'import/no-extraneous-dependencies': ['error', { devDependencies: true }],
+    'no-restricted-syntax': 'off',
+    'no-shadow': 'off',
+    '@typescript-eslint/no-shadow': 'error',
+  },
+};

+ 22 - 0
overwrite/.gitignore

@@ -0,0 +1,22 @@
+.DS_Store
+node_modules
+dist
+
+# local env files
+.env.local
+.env.*.local
+
+# Log files
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+pnpm-debug.log*
+
+# Editor directories and files
+.idea
+.vscode
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?

+ 6 - 0
overwrite/.huskyrc.js

@@ -0,0 +1,6 @@
+module.exports = {
+  hooks: {
+    'pre-commit': 'lint-staged',
+    'commit-msg': 'commitlint -E HUSKY_GIT_PARAMS',
+  },
+};

+ 19 - 0
overwrite/README.md

@@ -0,0 +1,19 @@
+# overwrite
+
+本项目是 wise-cost 项目,费用定额相同方法不同实现逻辑的解决方案。
+
+### 安装
+
+`$ npm i -S @sc/overwrite`
+
+### 打包
+
+`$ npm run build`
+
+### 基本用法
+
+```
+const overwrite = getOverWrite('');
+```
+
+具体接口请参考声明文件。

+ 29 - 0
overwrite/commitlint.config.js

@@ -0,0 +1,29 @@
+module.exports = {
+  ignores: [commit => commit.includes('init')],
+  extends: ['@commitlint/config-conventional'],
+  rules: {
+    'body-leading-blank': [2, 'always'],
+    'footer-leading-blank': [1, 'always'],
+    'header-max-length': [2, 'always', 108],
+    'subject-empty': [2, 'never'],
+    'type-empty': [2, 'never'],
+    'type-enum': [
+      2,
+      'always',
+      [
+        'feat', // 新增功能、变更需求
+        'fix', // 修复bug
+        'perf', // 优化性能
+        'refactor', // 代码重构
+        'style', // 代码格式(不影响功能,例如空格、分号等格式修正)
+        'docs', // 文档变更
+        'test', // 测试
+        'ci', // 更改持续集成软件的配置文件和package中的scripts命令,例如scopes: Travis, Circle等
+        'chore', // 变更构建流程或辅助工具(依赖更新/脚手架配置修改/webpack、gulp、npm等)
+        'revert', // 代码回退
+        'types', // ts类型定义文件更改
+        'wip', // work in process开发中
+      ],
+    ],
+  },
+};

+ 9 - 0
overwrite/lint-staged.config.js

@@ -0,0 +1,9 @@
+module.exports = {
+  '*.{js,jsx,ts,tsx}': ['eslint --fix', 'prettier --write'],
+  '{!(package)*.json,*.code-snippets,.!(browserslist)*rc}': [
+    'prettier --write--parser json',
+  ],
+  'package.json': ['prettier --write'],
+  '*.vue': ['prettier --write'],
+  '*.md': ['prettier --write'],
+};

+ 53 - 0
overwrite/package.json

@@ -0,0 +1,53 @@
+{
+  "name": "@sc/overwrite",
+  "version": "1.0.0",
+  "description": "wise-cost项目,费用定额相同方法不同实现逻辑的解决方案",
+  "main": "./dist/index.cjs.js",
+  "module": "./dist/index.esm.js",
+  "browser": "./dist/index.min.js",
+  "types": "./dist/index.d.ts",
+  "files": [
+    "dist",
+    "README.md"
+  ],
+  "scripts": {
+    "test": "cross-env TS_NODE_COMPILER_OPTIONS={\\\"module\\\":\\\"commonjs\\\"} mocha -r ts-node/register 'tests/**/*.ts'",
+    "build": "rollup -c"
+  },
+  "keywords": [],
+  "author": "smartcost",
+  "license": "ISC",
+  "devDependencies": {
+    "@commitlint/cli": "^11.0.0",
+    "@commitlint/config-conventional": "^11.0.0",
+    "@sc/types": "^1.0.28",
+    "@types/chai": "^4.2.14",
+    "@types/mocha": "^8.0.4",
+    "@types/ms": "^0.7.31",
+    "@types/uuid": "^8.3.0",
+    "@typescript-eslint/eslint-plugin": "^4.4.1",
+    "@typescript-eslint/parser": "^4.4.1",
+    "chai": "^4.2.0",
+    "cross-env": "^7.0.2",
+    "eslint": "^7.11.0",
+    "eslint-config-airbnb-base": "^14.2.0",
+    "eslint-config-prettier": "^6.12.0",
+    "eslint-plugin-import": "^2.22.1",
+    "eslint-plugin-prettier": "^3.1.4",
+    "husky": "^4.3.0",
+    "lint-staged": "^10.5.0",
+    "mocha": "^8.2.1",
+    "prettier": "^2.1.2",
+    "rollup": "^2.30.0",
+    "rollup-plugin-commonjs": "^10.1.0",
+    "rollup-plugin-node-resolve": "^5.2.0",
+    "rollup-plugin-terser": "^7.0.2",
+    "rollup-plugin-typescript2": "^0.27.3",
+    "ts-node": "^9.0.0",
+    "tslib": "^2.0.3",
+    "typescript": "^4.0.3"
+  },
+  "dependencies": {
+    "uuid": "^8.3.2"
+  }
+}

+ 6 - 0
overwrite/prettier.config.js

@@ -0,0 +1,6 @@
+module.exports = {
+  singleQuote: true, // 单引号
+  trailingComma: 'es5', // 对象末尾以逗号结束
+  arrowParens: 'avoid', // 箭头函数只有一个参数的时候,不使用()
+  endOfLine: 'auto', // CRLF,LF都可以
+};

+ 11 - 0
overwrite/rollup.config.js

@@ -0,0 +1,11 @@
+import typescript from 'rollup-plugin-typescript2'; // 一定要是typescript2,如果使用typescript,没法自动生成.d.ts文件
+import pkg from './package.json';
+
+export default [
+  {
+    input: 'src/index.ts',
+    external: ['ms'],
+    plugins: [typescript()],
+    output: [{ file: pkg.main, format: 'cjs' }],
+  },
+];

+ 13 - 0
overwrite/src/base/base.ts

@@ -0,0 +1,13 @@
+import { gljTypes } from './constant';
+import { getComponentTypes, getCustomerCoe } from './glj';
+
+export default class BaseOverwrite {
+  // 可用的人材机类型(目前只有人材机库有限制)
+  gljTypes = gljTypes;
+
+  // 根据人材机类型,获取可含有的组成物类型,空数组即为该人材机不可含有组成物
+  getComponentTypes = getComponentTypes;
+
+  // 获取自定义系数
+  getCustomerCoe = getCustomerCoe;
+}

+ 29 - 0
overwrite/src/base/constant.ts

@@ -0,0 +1,29 @@
+import { GljType } from '@sc/types';
+
+// 可用的人材机类型(目前只有人材机库有限制)
+export const gljTypes: GljType[] = [
+  GljType.LABOUR,
+  GljType.GENERAL_MATERIAL,
+  GljType.CONCRETE,
+  GljType.MORTAR,
+  GljType.MIX_RATIO,
+  GljType.COMMERCIAL_CONCRETE,
+  GljType.COMMERCIAL_MORTAR,
+  GljType.OTHER_MATERIAL,
+  GljType.GENERAL_MACHINE,
+  GljType.MACHINE_LABOUR,
+  GljType.INSTRUMENT,
+  GljType.FUEL_POWER_FEE,
+  GljType.DEPRECIATION_FEE,
+  GljType.INSPECTION_FEE,
+  GljType.MAINTENANCE,
+  GljType.DISMANTLING_FREIGHT_FEE,
+  GljType.VERIFICATION_FEE,
+  GljType.OTHER_FEE,
+  GljType.OTHER_MACHINE_USED,
+  GljType.MAIN_MATERIAL,
+  GljType.EQUIPMENT,
+  GljType.MANAGEMENT_FEE,
+  GljType.PROFIT,
+  GljType.GENERAL_RISK_FEE,
+];

+ 45 - 0
overwrite/src/base/glj.ts

@@ -0,0 +1,45 @@
+import { CoeType, GljType, IRationCoe } from '@sc/types';
+import { v1 } from 'uuid';
+
+// 根据人材机类型,获取可含有的组成物类型,空数组即为该人材机不可含有组成物
+export const getComponentTypes = (type: GljType): GljType[] => {
+  if ([GljType.CONCRETE, GljType.MORTAR, GljType.MIX_RATIO].includes(type)) {
+    return [GljType.GENERAL_MATERIAL];
+  }
+  if ([GljType.GENERAL_MACHINE, GljType.INSTRUMENT].includes(type)) {
+    return [
+      GljType.MACHINE_COMPOSITION,
+      GljType.MACHINE_LABOUR,
+      GljType.FUEL_POWER_FEE,
+      GljType.DEPRECIATION_FEE,
+      GljType.INSPECTION_FEE,
+      GljType.MAINTENANCE,
+      GljType.DISMANTLING_FREIGHT_FEE,
+      GljType.VERIFICATION_FEE,
+      GljType.OTHER_FEE,
+    ];
+  }
+  if (GljType.MAIN_MATERIAL === type) {
+    return [GljType.MAIN_MATERIAL];
+  }
+  return [];
+};
+
+// 获取自定义系数
+export const getCustomerCoe = (): IRationCoe => {
+  return {
+    ID: v1(),
+    stdID: -1,
+    name: '自定义系数',
+    content: '人工×1,材料×1,机械×1,主材×1,设备×1',
+    isAdjust: true,
+    coes: [
+      { amount: '1', operator: '*', gljCode: '', coeType: CoeType.RATION },
+      { amount: '1', operator: '*', gljCode: '', coeType: CoeType.LABOUR },
+      { amount: '1', operator: '*', gljCode: '', coeType: CoeType.MATERIAL },
+      { amount: '1', operator: '*', gljCode: '', coeType: CoeType.MACHINE },
+      { amount: '1', operator: '*', gljCode: '', coeType: CoeType.MAIN },
+      { amount: '1', operator: '*', gljCode: '', coeType: CoeType.EQUIPMENT },
+    ],
+  };
+};

+ 6 - 0
overwrite/src/chongqing-2018/chongQing2018.ts

@@ -0,0 +1,6 @@
+import BaseOverwrite from '../base/base';
+import { getCustomerCoe } from './glj';
+
+export default class ChongQing2018 extends BaseOverwrite {
+  getCustomerCoe = getCustomerCoe;
+}

+ 21 - 0
overwrite/src/chongqing-2018/glj.ts

@@ -0,0 +1,21 @@
+import { CoeType, IRationCoe } from '@sc/types';
+import { v1 } from 'uuid';
+
+// 获取自定义系数
+export const getCustomerCoe = (): IRationCoe => {
+  return {
+    ID: v1(),
+    stdID: -1,
+    name: '自定义系数',
+    content: '人工×1,材料×1,施工机具×1,主材×1,设备×1',
+    isAdjust: true,
+    coes: [
+      { amount: '1', operator: '*', gljCode: '', coeType: CoeType.RATION },
+      { amount: '1', operator: '*', gljCode: '', coeType: CoeType.LABOUR },
+      { amount: '1', operator: '*', gljCode: '', coeType: CoeType.MATERIAL },
+      { amount: '1', operator: '*', gljCode: '', coeType: CoeType.TOOL },
+      { amount: '1', operator: '*', gljCode: '', coeType: CoeType.MAIN },
+      { amount: '1', operator: '*', gljCode: '', coeType: CoeType.EQUIPMENT },
+    ],
+  };
+};

+ 17 - 0
overwrite/src/index.ts

@@ -0,0 +1,17 @@
+import BaseOverwrite from './base/base';
+import ChongQing2018 from './chongqing-2018/chongQing2018';
+
+// 费用定额ID 与 overwrite实例 映射
+const overwriteMap: Record<string, BaseOverwrite> = {
+  '5b52b027fd3bb0000b257cf8': new ChongQing2018(),
+};
+
+const baseOverwrite = new BaseOverwrite();
+
+// 根据费用定额ID,获取overwrite单例
+export function getOverwrite(compilationID?: string): BaseOverwrite {
+  return (compilationID && overwriteMap[compilationID]) || baseOverwrite;
+}
+
+export * from './base/base';
+export * from './chongqing-2018/chongQing2018';

+ 18 - 0
overwrite/tsconfig.json

@@ -0,0 +1,18 @@
+{
+  "compilerOptions": {
+    "target": "ESNext",
+    "module": "ESNext",
+    "declaration": true,
+    "outDir": "./",
+    "strict": true,
+    "esModuleInterop": true,
+    "moduleResolution": "node",
+  },
+  "include": [
+    "src/**/*.ts",
+  ],
+  "exclude": [
+    "node_modules",
+    "test"
+  ]
+}

+ 5 - 0
types/src/interface/error.ts

@@ -101,9 +101,14 @@ export enum ErrNo {
   CPT_GLJ_TREE_EMPTY = 5030,
   CPT_GLJ_INVALID = 5031, // 无效的补充人材机(需要编码、名称、单位、类型有值)
   CPT_GLJ_CODE_EXISTS = 5032, // 补充人材机编码已存在
+  INVALID_CPT_GLJ_LIB_ID = 5033, // 无效的补充人材机库ID
+  CPT_GLJ_LIB_ID = 5033, // 无效的补充人材机库ID
+  CPT_GLJ_NOT_EXISTS = 5034, // 补充人材机不存在
   /* 数据配置错误(大多数为后台标准、模板数据配置问题)  6001 - 6999 */
   // 补充人材机分类树模板 未配置
   CPT_GLJ_TREE_TEMPLATE_EMPTY = 6001,
   // 补充定额库章节树模板 未配置
   CPT_RATION_TREE_TEMPLATE_EMPTY = 6002,
+  // 该费用定额下,没有标准人材机库
+  STD_GLJ_LIB_EMPTY = 6003,
 }

+ 20 - 2
types/src/interface/glj.ts

@@ -211,6 +211,15 @@ export interface IProjectGljs {
 }
 
 /* 标准人材机相关 ↓ */
+// 标准人材机库
+export interface IStdGljLib {
+  dispName: string;
+  compilationId: string;
+  compilationName: string;
+  ID: number;
+  rationLibs: [{ dispName: string; ID: number }];
+}
+
 // 标准、补充人材机共用属性(原始数据)
 export interface IBaseRationGlj {
   code: string;
@@ -275,6 +284,9 @@ export interface IStdGljTree extends ITreeScm {
 /* 标准人材机相关 ↑ */
 
 /* 补充人材机相关 ↓ */
+// 补充人材机库标记
+export const cptLibKey = 'complementaryLib';
+
 // 补充人材机分类树-模板(后台设置)
 export interface IRawCptGljTreeTemplate {
   compilationId: string;
@@ -338,6 +350,12 @@ export interface IInsertCptGlj {
   model?: number;
 }
 
+// 准备组成物返回数据接口
+export interface IPrepareComponentResult {
+  displayComponents: ICptDisplayComponent[];
+  allowComponent: boolean;
+}
+
 // 补充人材机
 /* 补充人材机相关 ↑ */
 
@@ -354,7 +372,7 @@ export interface ISelectGljLibItem {
 
 // 获取人材机分页数据接口选项
 export interface IGetPagingGljOptions {
-  classList?: number[]; // 需要匹配的分类
+  classList?: (number | string)[]; // 需要匹配的分类
   typeList?: GljType[]; // 需要匹配的人材机类型
   libID?: number | string; // 人材机库ID
   replaceGlj?: IBaseGlj; // 替换的人材机
@@ -367,7 +385,7 @@ export interface IGetPagingGljOptions {
 // 选择人材机接口返回数据格式
 export interface ISelectGljResult {
   libData: ISelectGljLibItem[]; // 库下拉项
-  treeData: IStdGljTree[]; // 人材机分类树
+  treeData: (IStdGljTree | ICptGljTree)[]; // 人材机分类树
   gljData: (IStdGlj | ICptGlj)[]; // 人材机数据
   total: number; // 当前数据总数量
   locatedGlj?: IStdGlj | ICptGlj; // 需要定位到的人材机

+ 30 - 0
types/src/interface/report.ts

@@ -1,3 +1,8 @@
+
+export interface ReportFlags{
+   constructSumType?: string | null, taxType?: string | null, auditType?: string | null 
+}
+
 export interface ReportSubTree {
   nodeType: number;
   refId: number;
@@ -5,6 +10,8 @@ export interface ReportSubTree {
   ID: number;
   released: boolean;
   items: ReportSubTree[] | null;
+  flags?:ReportFlags;
+
 }
 export interface ReportTree {
   compilationId: string;
@@ -13,4 +20,27 @@ export interface ReportTree {
   isDeleted: boolean;
   name: string;
   items: ReportSubTree[] | null;
+  flags?: { constructSumType?: string | null, taxType?: string | null, auditType?: string | null };
+}
+
+
+//汇总项目信息
+export interface Summary {
+  compilationIllustration: string;
+  name: string;
+}
+// 汇总项目明细
+export interface SummaryDetail {
+  buildingArea: string;
+  charge: number;
+  engineeringCost: number;
+  estimate: number;
+  measure: number;
+  name: string;
+  other: number;
+  perCost: string;
+  rate: number;
+  safetyConstruction: number;
+  subEngineering: number;
+  tax: number;
 }