Jelajahi Sumber

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

# Conflicts:
#	types/src/interface/base.ts
chenshilong 4 tahun lalu
induk
melakukan
9d412d17d6

+ 4 - 4
crypto/src/AES/index.ts

@@ -6,8 +6,8 @@ const iv = CryptoJS.enc.Utf8.parse('ABCDEF7563850888'); // 十六位十六进制
 // 解密方法
 export const Decrypt = (word: string): string => {
   const encryptedHexStr = CryptoJS.enc.Hex.parse(word);
-  const srcs = CryptoJS.enc.Base64.stringify(encryptedHexStr);
-  const decrypt = CryptoJS.AES.decrypt(srcs, key, {
+  const src = CryptoJS.enc.Base64.stringify(encryptedHexStr);
+  const decrypt = CryptoJS.AES.decrypt(src, key, {
     iv,
     mode: CryptoJS.mode.CBC,
     padding: CryptoJS.pad.Pkcs7,
@@ -17,8 +17,8 @@ export const Decrypt = (word: string): string => {
 };
 
 export const Encrypt = (word: string): string => {
-  const srcs = CryptoJS.enc.Utf8.parse(word);
-  const encrypted = CryptoJS.AES.encrypt(srcs, key, {
+  const src = CryptoJS.enc.Utf8.parse(word);
+  const encrypted = CryptoJS.AES.encrypt(src, key, {
     iv,
     mode: CryptoJS.mode.CBC,
     padding: CryptoJS.pad.Pkcs7,

+ 6 - 3
crypto/tests/test.ts

@@ -1,9 +1,12 @@
 import { expect } from 'chai';
-import justTest from '../src/index';
+import { Encrypt, Decrypt } from '../src/AES/index';
 
 describe('Demo Test', () => {
   it('just a test', () => {
-    const testStr = justTest();
-    expect(testStr).to.equal('just a test');
+    const encString = Encrypt('Word');
+    console.log(encString);
+    console.log(Decrypt(encString));
+
+    expect(Decrypt(encString)).to.equal('Word');
   });
 });

+ 1 - 1
handsontable/package.json

@@ -10,7 +10,7 @@
     "url": "https://github.com/handsontable/handsontable/issues"
   },
   "author": "Handsoncode <hello@handsontable.com>",
-  "version": "6.3.10",
+  "version": "6.3.11",
   "browser": "dist/handsontable.js",
   "main": "commonjs/index.js",
   "module": "es/index.js",

+ 2 - 2
handsontable/src/css/handsontable.css

@@ -81,9 +81,9 @@
   border-left-width: 0;
   border-right: 1px solid #CCC;
   border-bottom: 1px solid #CCC;
-  height: 22px;
+  height: 19px;
   empty-cells: show;
-  line-height: 21px;
+  line-height: 18px;
   padding: 0 4px 0 4px;
   /* top, bottom padding different than 0 is handled poorly by FF with HTML5 doctype */
   background-color: #FFF;

+ 1 - 1
handsontable/src/dataMap.js

@@ -520,7 +520,7 @@ DataMap.prototype.get = function(row, prop) {
     for (let i = 0, ilen = sliced.length; i < ilen; i++) {
       out = out[sliced[i]];
 
-      if (typeof out === 'undefined') {
+      if (typeof out === 'undefined' || out === null) {
         return null;
       }
     }

+ 11 - 6
report/src/interface/basic.ts

@@ -639,14 +639,19 @@ export interface RptTreeNode {
       auditType?: string | null;
     };
   }
+//   方案列表
 export interface IRptSchemeList{
-    ID:string;
-    name:string;
-    typeID:string;
-    typeName:string;
-    data:RptTreeNode[];
-
+    ID: string;
+    name: string;
+    data?: string[];
+    level?:string;//级别,用来区分是单位工程、单项工程和建设项目的
 }
+//方案数据
+export interface IRptSchemeData {
+    userID:string;
+    data:IRptSchemeList
+}
+
 //报表设置参数
 export interface IRptCustomizeCfg {
     userID?: string;

+ 23 - 2
types/src/interface/base.ts

@@ -22,6 +22,7 @@ export interface IFileRef {
   ID: string;
   name: string;
   type?: number;
+  isDefault?: boolean;
 }
 
 export interface INumFileRef {
@@ -123,12 +124,16 @@ export enum CptModelName {
   rations = 'rations',
   rationGljs = 'rationGljs',
   shareList = 'shareList',
+  shareProject = 'shareProject',
+  shareLib = 'shareLib',
+  shareLink = 'shareLink',
   unitPriceFile = 'unitPriceFile',
   feeRateFile = 'feeRateFile',
   labourCoeFile = 'labourCoeFile',
   importLogs = 'importLogs',
   cptGlj = 'cptGlj',
   cptGljTree = 'cptGljTree',
+  cptRationLib = 'cptRationLib',
   cptRationTree = 'cptRationTree',
   cptRation = 'cptRation',
   cptRationCoe = 'cptRationCoe',
@@ -164,6 +169,7 @@ export enum ActionName {
   ADD_GLJ_RATIONS = 'addGljRations', // 插入工料机类型的定额
   CLEAN_ZMHS = 'cleanZmhs', // 清空子目换算
   RESET_INSTALL_FEE = 'resetInstallFee', // 重置安装增加费设置
+  CALC_AREA_INCREASE = 'calcAreaIncrease', // 计算面积增加费
 
   // 定额工料机相关
   UPDATE_INDEX_KEY = 'updateIndexKey', // 修改定额工料机的名称,规格,单位
@@ -172,6 +178,10 @@ export enum ActionName {
 
   // 项目工料机相关
   APPLY_ALL_INFO_PRICE = 'applyAllInfoPrice', // 批量套用信息价
+  PROJECT_GLJ_EXIST_CHECK = 'projectGljExistCheck', // 检查工料机是否已经存在
+
+  // 安装增加费
+  CALC_INSTALL_FEE = 'calcInstallFee', // 计算安装增加费
 
   // 清单相关
   ADD_STD_BILLS = 'addStdBills', // 添加标准清单
@@ -243,7 +253,7 @@ export interface IGetData {
   subject: ISubjectGetData;
   construction: { project?: IProject };
   treeData: IProject[];
-  isOwner: boolean;
+  isManager: boolean;
   projectsPermission: IProjectPermission[];
 }
 
@@ -261,7 +271,16 @@ export interface IBRBase {
   quantity?: number;
   quantityEXP?: string;
   quantityDetails?: IQuantityDetail[]; // 工程量明细 -- 原先保存在另外的表中
-  fees?: any; // 费用字段
+  // 是否记取面积增加费
+  areaIncreaseFee?: boolean | null; // { type: Schema.Types.Mixed; default: false }; // true 是,false否,null 不确定,三个状态
+  fees?: {
+    [key: string]: {
+      tenderTotalFee: number;
+      tenderUnitPrice: number;
+      totalFee: number;
+      unitPrice: number;
+    };
+  }; // 费用字段
   bookmarks?: IBookmark[]; // 书签批注
 
   targetUnitPrice?: number; // 调价:目标综合单价
@@ -271,3 +290,5 @@ export interface IBRBase {
   rationQtyCoe?: number; // 调价:子目工程量调整系数
   gljQtyCoe?: IGljQtyCoe; // 调价:工料机消耗量调整系数
 }
+
+export const SeparateString = '|----|';

+ 8 - 0
types/src/interface/enterprise.ts

@@ -100,3 +100,11 @@ export interface ISystemLog {
   content: string;
   time: number;
 }
+
+export interface IMemberInfo {
+  userID: string;
+  userName: string;
+  mobile: string;
+  enterpriseID: string;
+  enterpriseName: string;
+}

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

@@ -4,6 +4,7 @@
  * @Date: 2021-05-26 17:37:16
  */
 import { FromType, ITreeScm, SupplyType } from './base';
+import { IReceivedShareLib } from './share';
 
 // 工料机类型
 export enum GljType {
@@ -198,7 +199,7 @@ export interface IProjectGlj {
   noAdjustPrice: boolean; // 不调价  { type: boolean; default: false }
   noTaxEqp?: boolean; // 不计税设备  { type: boolean; default: false }
   adjCoe?: number; // 调整系数ID
-  specs: string; // 规格型号
+  specs?: string; // 规格型号
   type: GljType; // 类型
   model?: number; // 机型
   unit: string; // 单位
@@ -222,7 +223,7 @@ export interface IProjectGlj {
   // 经济指标数据
   materialIndexType?: string; // 工料指标类别
   materialIndexUnit?: string; // 工料指标单位
-  materialIndexCoe: number; // 单位转换系数
+  materialIndexCoe?: number; // 单位转换系数
   isMainMaterial: boolean; // 是否主要材料 (0为否 1为是) { type: boolean; default: false };
   remark?: string; // 备注
   originPlace?: string; // 产地
@@ -392,6 +393,7 @@ export interface ISelectGljLibItem {
   key: string; // 与gljLibID拼接的形成的唯一值
   isPrior: boolean; // 优先的
   from: FromType;
+  isShare?: boolean; // 是否是被人分享的
   located?: boolean; // 定位到的库(替换时需要)
 }
 
@@ -456,3 +458,11 @@ export interface IAddComponentFilter {
   projectGljID: string;
   libGljs: (IStdGlj | ICptGlj)[];
 }
+
+// 进入人材机库需要准备的数据(一些状态)
+export interface IPrepareCptGljLib {
+  // 人材机库分享人数
+  shareCount: number;
+  // 接收到的分享人材机库数据
+  receiveLibs: IReceivedShareLib[];
+}

+ 2 - 1
types/src/interface/increaseFee.ts

@@ -1,10 +1,11 @@
 import { IAny } from './base';
 
 export interface IIncreaseSettingItem {
+  ID: string;
   name: string;
   base: string;
   coe: number;
-  scope: IAny;
+  scope?: { [ID: string]: boolean };
 }
 
 export interface IIncreaseSetting {

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

@@ -16,7 +16,7 @@ export * from './option';
 export * from './quantityDetail';
 export * from './report';
 export * from './configMaterial';
-export * from './socket';
+export * from './message';
 export * from './enterprise';
 export * from './infoPrice';
 export * from './installation';

+ 40 - 0
types/src/interface/message.ts

@@ -0,0 +1,40 @@
+/* eslint-disable import/prefer-default-export */
+export enum SocketEvent {
+  JOIN = 'join',
+  LEAVE = 'leave',
+  NOTIFY = 'notify',
+}
+
+export enum SocketName {
+  INVITE = 'invite',
+  REMOVE_FROM_ENTERPRISE = 'removeFromEnterprise',
+}
+
+export interface ISocketData {
+  // success warning info error, 空字符串或者 undefined 代表普通的消息
+  type?: string;
+  // 房间号
+  rooms: string[];
+  // 消息的名称,标识这个消息是什么消息,如 invite 表示邀请加入企业
+  name: SocketName;
+  // 数据
+  data: any;
+}
+
+export enum MessageName {
+  INVITE = 'invite',
+  REMOVE_FROM_ENTERPRISE = 'removeFromEnterprise',
+}
+
+export interface IMessage {
+  ID: string;
+  userID: string;
+  title: string;
+  content: string;
+  name: MessageName;
+  data?: any;
+  tags: string[];
+  unread: boolean;
+  removable: boolean;
+  createTime: number;
+}

+ 0 - 6
types/src/interface/notification.ts

@@ -1,6 +0,0 @@
-export interface INotificationListItem {
-  ID: string;
-  status: 'unread' | 'already';
-  title: string;
-  removable: boolean;
-}

+ 5 - 1
types/src/interface/project.ts

@@ -57,6 +57,8 @@ export interface IProgression {
 export interface IProgressiveInterval {
   name: string;
   progression: IProgression[];
+  generalRate?: number;
+  simpleRate?: number;
 }
 
 // 超高降效
@@ -277,6 +279,7 @@ export interface IProject extends ITreeScm {
     createDateForView?: number;
     actualTreeData?: ITreeScm; // 真正的树结构数据。有时候可能需要暂时变更project的树结构数据,在这种时候需要存储原本的真实树结构数据
     from?: string; // 来自于某用户名称
+    members?: string[]; // 成员协作
   };
 }
 
@@ -299,7 +302,8 @@ export interface IConstructionDefaultSetting {
 // 项目权限
 export interface IProjectPermission {
   projectID: string;
-  share: ISharePermission;
+  readOnly: boolean;
+  allowCopy: boolean;
 }
 
 // constructionTreeData接口

+ 37 - 13
types/src/interface/ration.ts

@@ -155,7 +155,7 @@ export interface IOptionList {
 }
 export interface ICptCoeItem extends IBaseCoeItem {
   ID: string;
-  ownerID: string;
+  libID: string;
   compilationID: string;
   coes: ICptCoe[];
 }
@@ -211,7 +211,7 @@ export interface IStdRation extends IBaseRation {
 }
 
 export interface ICptRation extends IBaseRation {
-  ownerID: string;
+  libID: string;
   compilationID: string;
   ID: string;
   sectionId: string;
@@ -270,7 +270,7 @@ export interface ITemplateItem {
   fxID: string; // 这个是分项对应的ID
   unit: string;
   quantity: number;
-  coe: number;
+  coe?: number;
   billID?: string; // 记取位置对应的清单ID
 }
 export interface IRationTemplate {
@@ -316,9 +316,7 @@ export interface IRation extends IBRBase {
   prefix?: RationPrefix; // { type: string; default: '' }; // 定额是补充、借用时用  补 借
   referenceRationID?: string; // 如果是通过模板关联子目生成的定额,这里记录对应的主定额ID
   jobContentText?: string; // 工作内容 (选择自清单)
-  manageFeeRate?: string; // 管理费率
-  // 是否记取面积增加费
-  areaIncreaseFee?: boolean | null; // { type: Schema.Types.Mixed; default: false }; // true 是,false否,null 不确定,三个状态
+  manageFeeRate?: number; // 管理费率
   // 工料机特有属性
   // 工料机类型的定额或者特殊清单会用到市场价和调后价
   marketPrice?: number;
@@ -355,12 +353,6 @@ export interface ILibRationsAndGljsResult {
   rationGljs: (IStdGlj | ICptGlj)[];
 }
 
-export enum RationListType {
-  ASS = 'rationAssList',
-  COE = 'rationCoeList',
-  GLJ = 'rationGljList',
-}
-
 // 补充定额章节树-模板(后台设置)
 export interface ICptRationTreeTemplate {
   compilationId: string;
@@ -382,8 +374,9 @@ export interface ICptRationTree extends ITreeScm {
 
 // 补充定额章节树容器
 export interface ICptRationTreeData {
+  libID: string;
+  ID: string;
   compilationID: string;
-  ownerID: string; // 企业或用户
   treeData: ICptRationTree[];
 }
 
@@ -449,3 +442,34 @@ export enum RationSubProp {
   INS = 'rationInstallList', // 定额安装增加费
   TPL = 'rationTemplate', // 定额子目模板
 }
+
+// 补充定额库选项
+export interface ICptRationLibOption {
+  ID: string;
+  name: string;
+  readOnly: boolean;
+}
+
+// 进入定额库需要准备的数据(一些状态)
+export interface IPrepareCptRationLib {
+  // 定额库分享人数
+  shareCount: number;
+  // 库下拉选项
+  libOptions: ICptRationLibOption[];
+}
+
+// 补充定额库
+export interface ICptRationLib {
+  ID: string;
+  // 库名称,预留字段,以后可能允许自行新建补充库
+  name?: string;
+  // 费用定额ID
+  compilationID: string;
+  // 企业ID,可为空字符串
+  enterpriseID: string;
+  // 用户ID
+  userID: string;
+  // 是否为企业内部库
+  isEnterpriseInternal: boolean;
+  createDate: number;
+}

+ 13 - 8
types/src/interface/report.ts

@@ -1,30 +1,35 @@
-
-export interface ReportFlags{
-   constructSumType?: string | null, taxType?: string | null, auditType?: string | null 
+export interface ReportFlags {
+  constructSumType?: string | null;
+  taxType?: string | null;
+  auditType?: string | null;
 }
 
 export interface ReportSubTree {
+  UUID: string;
   nodeType: number;
   refId: number;
   name: string;
   ID: number;
   released: boolean;
   items: ReportSubTree[] | null;
-  flags?:ReportFlags;
-
+  flags?: ReportFlags;
 }
 export interface ReportTree {
+  UUID: string;
   compilationId: string;
   userId: string;
   released: boolean;
   isDeleted: boolean;
   name: string;
   items: ReportSubTree[] | null;
-  flags?: { constructSumType?: string | null, taxType?: string | null, auditType?: string | null };
+  flags?: {
+    constructSumType?: string | null;
+    taxType?: string | null;
+    auditType?: string | null;
+  };
 }
 
-
-//汇总项目信息
+// 汇总项目信息
 export interface Summary {
   compilationIllustration: string;
   name: string;

+ 215 - 27
types/src/interface/share.ts

@@ -1,10 +1,24 @@
-import { IRecentUser, IUser } from './user';
+import { IOption } from './option';
+import { ICompilation } from './compilation';
+import { EntityType, IUser } from './user';
+import { ISystemSetting, ProjectType } from '.';
 
+// 分享类型
 export enum ShareType {
-  PROJECT = 1, // 项目
-  RATION_LIB, // 定额库
-  GLJ_LIB, // 工料机库
-  PRICE_TEMPLATE, // 租价模板
+  PROJECT = 'project', // 项目
+  RATION_LIB = 'rationLib', // 定额库
+  GLJ_LIB = 'gljLib', // 工料机库
+  PRICE_TEMPLATE = 'priceTemplate', // 租价模板
+}
+
+// 分享版本
+export enum ShareVersion {
+  // 个人版
+  PERSON = 'person',
+  // 企业版
+  ENTERPRISE = 'enterprise',
+  // 成员协作
+  MEMBER_COOPERATION = 'memberCooperation',
 }
 
 // 分享权限
@@ -13,29 +27,45 @@ export interface ISharePermission {
   allowCooperate: boolean;
 }
 
-export interface IShareProject extends ISharePermission {
-  shareDate?: number;
-  updateDate?: number;
-  projectID: string; // 项目ID
-  compilationID: string;
-  isRead?: boolean;
-}
-
-export interface IShareLib extends ISharePermission {
-  shareDate?: number;
-  updateDate?: number;
-  compilationID: string;
-}
-
-export interface IShare {
+/* export interface IShare {
   ID: string;
-  owner: string;
-  receiver: string;
+  version: ShareVersion;
+  ownerID: string;
+  ownerType: EntityType;
+  // 负责人ID
+  managerID: string;
+  receiverID: string;
+  receiverEnterpriseID?: string;
   recentDate: number;
   projectList: IShareProject[];
   rationLibList: IShareLib[];
   gljLibList: IShareLib[];
   priceTemplateList: IShareLib[];
+} */
+
+export interface IShareBase extends ISharePermission {
+  ID: string;
+  version: ShareVersion;
+  type: ShareType;
+  ownerID: string;
+  ownerType: EntityType;
+  userID: string;
+  enterpriseID: string;
+  receiverID: string;
+  receiverEnterpriseID: string;
+  shareDate: number;
+  updateDate: number;
+}
+
+export interface IShareProject extends IShareBase {
+  projectID: string; // 项目ID
+  constructionID: string; // 项目所属建设项目ID,涉及到一些层级,有这个字段会更方便
+  compilationID: string;
+  isRead?: boolean;
+}
+
+export interface IShareLib extends IShareBase {
+  compilationID: string;
 }
 
 export type ShareItem = IShareProject | IShareLib;
@@ -44,18 +74,35 @@ export type ShareItem = IShareProject | IShareLib;
 export interface IShareHistory extends ISharePermission {
   ID: string; // 分享ID
   user: Partial<IUser>;
+  enterpriseID?: string;
+  enterpriseName?: string;
   shareType: ShareType;
   projectID?: string;
   compilationID?: string;
 }
 
+export interface ICreateShareProject extends ISharePermission {
+  ID: string;
+  projectID: string; // 项目ID
+  constructionID: string; // 项目所属建设项目ID,涉及到一些层级,有这个字段会更方便
+  compilationID: string;
+}
+
+export interface ICreateShareLib extends ISharePermission {
+  ID: string;
+  compilationID: string;
+}
+
 export interface ICreatShare {
-  receiver: string;
-  doc: ShareItem;
+  receiverID: string;
+  receiverEnterpriseID: string; // 一个用户可能有多个企业,需要记住企业ID
+  doc: ICreateShareProject | ICreateShareLib;
   type: ShareType;
 }
 
 export interface IUpdateShare {
+  receiverID: string;
+  receiverEnterpriseID: string;
   filter: { ID: string; projectID?: string; compilationID?: string };
   update: {
     updateDate?: number;
@@ -67,18 +114,159 @@ export interface IUpdateShare {
 }
 
 export interface IDelShare {
+  receiverID: string;
+  receiverEnterpriseID: string;
   filter: { ID: string; projectID?: string; compilationID?: string };
   type: ShareType;
 }
 
 export interface IBulkShare {
   update?: IUpdateShare[];
-  create?: { ID: string; docs: ICreatShare[] };
+  create?: ICreatShare[];
   remove?: IDelShare[];
 }
 
+// 分享链接
+export interface IShareLink {
+  // 链接ID
+  ID: string;
+  // 是否需要密码
+  needPassword: boolean;
+  // 密码
+  password?: string;
+  // 分享的项目ID
+  projectID: string;
+  // 所属建设项目ID
+  constructionID: string;
+  // 项目所属费用定额ID
+  compilationID: string;
+  // 拥有者ID
+  ownerID: string;
+  ownerType: EntityType;
+  // 创建链接的人ID
+  creatorID: string;
+  // 分享时间
+  shareDate: number;
+}
+
+// 最近分享 条目
+export interface IRecentShareItem {
+  userID: string;
+  enterpriseID: string;
+  recentDate: number;
+}
+
+// 最近分享
+export interface IRecentShare {
+  userID: string;
+  enterpriseID: string;
+  // 个人版
+  personVer: IRecentShareItem[];
+  // 企业版
+  enterpriseVer: IRecentShareItem[];
+  // 成员协作
+  memberCooperation: IRecentShareItem[];
+}
+
+// 最近分享用户
+export interface IRecentShareUser {
+  userID: string;
+  name: string;
+  mobile: string;
+  enterpriseID?: string;
+  enterpriseName?: string;
+  recentDate: number;
+}
+
 // 初始化分享弹窗时需要的数据
 export interface IPreparePopup {
-  history: IShareHistory[];
-  recentContacts: IRecentUser[];
+  // 个人版已分享
+  personHistory: IShareHistory[];
+  // 企业版已分享
+  enterpriseHistory: IShareHistory[];
+  // 成员协作已分享
+  memberCoHistory: IShareHistory[];
+  // 个人版最近分享
+  personRecentUsers: IRecentShareUser[];
+  // 企业版最近分享
+  enterpriseRecentUsers: IRecentShareUser[];
+  // 成员协作最近分享
+  memberCoRecentUsers: IRecentShareUser[];
+  // 分享链接
+  shareLink?: IShareLink;
+}
+
+// 检查分享链接时需要的信息
+export interface IShareLinkInfo {
+  // 链接ID
+  ID: string;
+  // 是否需要密码
+  needPassword: boolean;
+  // 项目所属费用定额ID
+  compilationID: string;
+  // 分享的项目ID
+  projectID: string;
+  // 所属建设项目ID
+  constructionID: string;
+  // 分享的项目名称
+  projectName: string;
+  // 分享链接的人名
+  creatorName: string;
+}
+
+// 进入分享链接项目前准备数据
+export interface IPrepareShareLinkProject {
+  // 分享链接项目的费用定额数据
+  compilation: ICompilation;
+  // 选项信息
+  option: IOption;
+  // 系统设置信息
+  systemSetting: ISystemSetting;
+  // 报表设置信息(用户)
+  customizeCfg: any;
+}
+
+// 接收到的项目数据
+export interface IReceivedShareProject {
+  // 项目ID
+  ID: string;
+  // 项目类型
+  type: ProjectType;
+  // 建设项目名称
+  name: string;
+  // 建设项目下分享的工程
+  children: IReceivedShareProject[];
+  // 来自用户名
+  fromUserName: string;
+  // 分享时间
+  shareDate: number;
+  // 分享项目来自的企业ID
+  enterpriseID?: string;
+  // 分享项目来自的企业名称
+  enterpriseName?: string;
+}
+
+// 接收到的库数据
+export interface IReceivedShareLib {
+  // 类型
+  type: ShareType;
+  // 库名称
+  name: string;
+  // 拼接成的库ID(非分享数据ID)
+  ID: string;
+  // 分享时间
+  shareDate: number;
+  // 来自用户名
+  fromUserName: string;
+  // 指定用户(名称)
+  toUsers?: string[];
+}
+
+// 根据手机号搜索出来用户信息
+export interface IShareSearchUser {
+  userID: string;
+  userName: string;
+  mobile: string;
+  enterpriseID?: string;
+  enterpriseName?: string;
 }

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

@@ -1,5 +0,0 @@
-/* eslint-disable import/prefer-default-export */
-export enum SocketEvent {
-  TEST = 'test',
-  JOIN = 'join',
-}

+ 1 - 1
util/package.json

@@ -1,6 +1,6 @@
 {
   "name": "@sc/util",
-  "version": "1.0.8",
+  "version": "1.0.9",
   "description": "通用的工具包",
   "main": "./dist/index.cjs.js",
   "module": "./dist/index.esm.js",

+ 2 - 2
util/src/reg.ts

@@ -16,8 +16,8 @@ export const mobileReg = /^1\d{10}$/;
 // 短信验证码
 export const smsCodeReg = /^\d{6}$/;
 
-// 密码
-export const weakPasswordReg = /^\S{6,16}$/;
+// 密码
+export const passwordReg = /^(?=.*\d)(?=.*[a-zA-Z]).{6,16}$/;
 
 // 效验身份证
 export const idCardReg = /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/;

+ 11 - 0
wise-cost-connect/.editorconfig

@@ -0,0 +1,11 @@
+# 🎨 editorconfig.org
+
+root = true
+
+[*]
+charset = utf-8
+end_of_line = lf
+indent_style = space
+indent_size = 2
+trim_trailing_whitespace = true
+insert_final_newline = true

+ 7 - 0
wise-cost-connect/.eslintrc.json

@@ -0,0 +1,7 @@
+{
+  "extends": "./node_modules/mwts/",
+  "ignorePatterns": ["node_modules", "dist", "test", "jest.config.js", "typings"],
+  "env": {
+    "jest": true
+  }
+}

+ 15 - 0
wise-cost-connect/.gitignore

@@ -0,0 +1,15 @@
+logs/
+npm-debug.log
+yarn-error.log
+node_modules/
+package-lock.json
+yarn.lock
+coverage/
+dist/
+.idea/
+run/
+.DS_Store
+*.sw*
+*.un~
+.tsbuildinfo
+.tsbuildinfo.*

+ 3 - 0
wise-cost-connect/.prettierrc.js

@@ -0,0 +1,3 @@
+module.exports = {
+  ...require('mwts/.prettierrc.json')
+}

+ 72 - 0
wise-cost-connect/README.md

@@ -0,0 +1,72 @@
+### 开始
+
+wise-cost MongoDB数据库连接组件
+
+组件开发与使用参考midway 组件开发:[http://www.midwayjs.org/doc/component/develop](https://note.youdao.com/)
+
+### 使用组件:
+
+添加依赖:
+```
+// package.json
+{
+  "dependencies": {
+    "@sc/connect": "^1.0.0",
+  },
+}
+```
+然后,在应用中引入这个组件。
+
+```
+// 应用或者函数的 src/configuration.ts
+import { Configuration } from '@midwayjs/decorator';
+import * as connect from '@sc/connect';
+
+@Configuration({
+	imports: [
+  	connect
+  ],
+})
+export class ContainerLifeCycle {
+}
+```
+
+然后在使用的地方引入
+
+```
+import { Provide, Inject } from '@midwayjs/decorator';
+import { MongoDBConnect } from '@sc/connect';
+
+@Provide()
+export class Library {
+
+  @Inject()
+  mongooseDB: MongoDBConnect;
+
+}
+```
+
+同时也像egg-mongoose一样,挂载了 mongoose 和 MongoDBConnect 到 app 下了 
+
+
+### 初始化
+
+npm install
+
+### 构建
+
+
+```
+npm run build
+```
+
+
+### 代码风格
+
+ESLint + Airbnb config
+
+### 发布
+
+发布
+
+`npm publish`

+ 38 - 0
wise-cost-connect/package.json

@@ -0,0 +1,38 @@
+{
+  "name": "@sc/connect",
+  "version": "1.0.0",
+  "description": "",
+  "main": "dist/index.js",
+  "typings": "dist/index.d.ts",
+  "scripts": {
+    "build": "midway-bin build -c",
+    "test": "midway-bin test --ts",
+    "cov": "midway-bin cov --ts",
+    "lint": "mwts check",
+    "lint:fix": "mwts fix"
+  },
+  "keywords": [],
+  "author": "",
+  "files": [
+    "dist/**/*.js",
+    "dist/**/*.d.ts"
+  ],
+  "dependencies": {
+    "mongoose": "^5.10.9",
+    "@types/mongoose": "^5.3.24"
+  },
+  "devDependencies": {
+    "@midwayjs/cli": "^1.2.38",
+    "@midwayjs/core": "^2.3.0",
+    "@midwayjs/decorator": "^2.3.0",
+    "@types/jest": "^26.0.10",
+    "@types/node": "14",
+    "cross-env": "^6.0.0",
+    "globby": "8.0.2",
+    "jest": "^26.4.0",
+    "mwts": "^1.0.5",
+    "ts-jest": "^26.2.0",
+    "typescript": "^4.0.0"
+  }
+ 
+}

+ 0 - 0
wise-cost-connect/src/config/config.default.ts


+ 42 - 0
wise-cost-connect/src/configuration.ts

@@ -0,0 +1,42 @@
+// src/configuration.ts
+import { App, Config, Configuration, Logger } from '@midwayjs/decorator';
+import path, { join } from 'path';
+import { ILifeCycle } from '@midwayjs/core';
+import { IMongooseApp, MongoDBConnect } from './connect/mongoDBConnect';
+import * as globby from 'globby';
+
+@Configuration({
+  namespace: 'connect',
+  importConfigs: [join(__dirname, 'config')],
+})
+export class AutoConfiguration implements ILifeCycle {
+  @App()
+  app: IMongooseApp;
+
+  @Config('mongoose')
+  mongoDBConfig;
+
+  @Config('baseDir')
+  baseDir: string;
+
+  @Logger()
+  logger;
+
+  async onReady() {
+    const connect = new MongoDBConnect(this.mongoDBConfig, this.app); //生成连接对像
+    this.app.getApplicationContext().registerObject('mongooseDB', connect); //注册到app中
+    this.loadModelFile(); //加载model文件
+  }
+
+  loadModelFile() {
+    const dir = path.join(this.baseDir, 'app/model');
+    const files: string[] = globby.sync(['**/*.(js|ts)', '!**/*.d.ts'], {
+      cwd: dir,
+    });
+    files.forEach(filePath => require(path.join(dir, filePath))(this.app));
+  }
+  async onStop(): Promise<void> {
+    // 关闭数据库连接
+    await this.app.mongooseDB.closeDB();
+  }
+}

+ 58 - 0
wise-cost-connect/src/connect/mongoDBConnect.ts

@@ -0,0 +1,58 @@
+import { IMidwayApplication } from '@midwayjs/core';
+import { Inject } from '@midwayjs/decorator';
+import mongoose, { Connection, ConnectOptions, Mongoose } from 'mongoose';
+
+export interface IMongooseApp extends IMidwayApplication {
+  mongoose: Mongoose;
+  mongooseDB: MongoDBConnect;
+}
+
+export class MongoDBConnect {
+  @Inject()
+  logger;
+
+  private clients: Map<string, Connection>;
+
+  private newConnection(
+    name = 'default',
+    config: { url: string; options: ConnectOptions }
+  ) {
+    const { url, options } = config;
+    if (!url) {
+      return this.logger.error('url 不能为空!');
+    }
+    const conn = mongoose.createConnection(url, options);
+    this.clients[name] = conn;
+  }
+
+  private createClients(config: any) {
+    const { client, clients } = config;
+    if (client) {
+      this.newConnection(client.name, client);
+    }
+
+    if (clients) {
+      Object.keys(clients).forEach(dbName =>
+        this.newConnection(dbName, clients[dbName])
+      );
+    }
+  }
+
+  constructor(config: any, app: IMongooseApp) {
+    this.clients = new Map();
+    this.createClients(config);
+    app.mongoose = mongoose;
+    app.mongooseDB = this;
+  }
+
+  get(dbName: string) {
+    return this.clients[dbName];
+  }
+
+  async closeDB() {
+    const connects: Connection[] = Object.values(this.clients);
+    for (const connect of connects) {
+      await connect.close();
+    }
+  }
+}

+ 2 - 0
wise-cost-connect/src/index.ts

@@ -0,0 +1,2 @@
+export { AutoConfiguration as Configuration } from './configuration';
+export * from './connect/mongoDBConnect';

+ 3 - 0
wise-cost-connect/test/index.test.ts

@@ -0,0 +1,3 @@
+describe('/test/index.test.ts', () => {
+  it('test component', () => {});
+});

+ 25 - 0
wise-cost-connect/tsconfig.json

@@ -0,0 +1,25 @@
+{
+  "compileOnSave": true,
+  "compilerOptions": {
+    "target": "ES2018",
+    "module": "commonjs",
+    "moduleResolution": "node",
+    "experimentalDecorators": true,
+    "emitDecoratorMetadata": true,
+    "inlineSourceMap":false,
+    "noImplicitThis": true,
+    "esModuleInterop": true,
+    "noUnusedLocals": true,
+    "stripInternal": true,
+    "skipLibCheck": false,
+    "noImplicitReturns": false,
+    "pretty": true,
+    "declaration": true,
+    "outDir": "dist"
+  },
+  "exclude": [
+    "dist",
+    "node_modules",
+    "test"
+  ]
+}

+ 1 - 1
wise-cost-util/src/cptLib.ts

@@ -6,7 +6,7 @@ export const cptLibKey = 'complementaryLib';
  * @param libID 库ID
  */
 export const isCptLib = (libID: number | string): boolean => {
-  return new RegExp(cptLibKey).test(String(libID));
+  return /[\da-zA-Z-]{36}/.test(String(libID));
 };
 
 /**