@etsoo/smarterp-crm 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/.gitattributes +2 -0
  2. package/.github/workflows/main.yml +60 -0
  3. package/LICENSE +21 -0
  4. package/README.md +17 -0
  5. package/__tests__/PersonApi.ts +15 -0
  6. package/__tests__/app/TestApp.ts +139 -0
  7. package/__tests__/tsconfig.json +20 -0
  8. package/babel.config.json +11 -0
  9. package/lib/cjs/CrmApp.d.ts +186 -0
  10. package/lib/cjs/CrmApp.js +170 -0
  11. package/lib/cjs/PersonApi.d.ts +38 -0
  12. package/lib/cjs/PersonApi.js +45 -0
  13. package/lib/cjs/PersonProfileApi.d.ts +54 -0
  14. package/lib/cjs/PersonProfileApi.js +63 -0
  15. package/lib/cjs/components/index.d.ts +1 -0
  16. package/lib/cjs/components/index.js +18 -0
  17. package/lib/cjs/components/person/PersonTiplist.d.ts +28 -0
  18. package/lib/cjs/components/person/PersonTiplist.js +27 -0
  19. package/lib/cjs/dto/person/AddressItem.d.ts +36 -0
  20. package/lib/cjs/dto/person/AddressItem.js +12 -0
  21. package/lib/cjs/dto/person/CategoryItem.d.ts +16 -0
  22. package/lib/cjs/dto/person/CategoryItem.js +2 -0
  23. package/lib/cjs/dto/person/ContactItem.d.ts +30 -0
  24. package/lib/cjs/dto/person/ContactItem.js +2 -0
  25. package/lib/cjs/dto/person/MaritalStatus.d.ts +36 -0
  26. package/lib/cjs/dto/person/MaritalStatus.js +40 -0
  27. package/lib/cjs/dto/person/PersonDegree.d.ts +26 -0
  28. package/lib/cjs/dto/person/PersonDegree.js +30 -0
  29. package/lib/cjs/dto/person/PersonEducation.d.ts +111 -0
  30. package/lib/cjs/dto/person/PersonEducation.js +115 -0
  31. package/lib/cjs/dto/person/PersonListDto.d.ts +6 -0
  32. package/lib/cjs/dto/person/PersonListDto.js +2 -0
  33. package/lib/cjs/dto/person/PersonQueryData.d.ts +24 -0
  34. package/lib/cjs/dto/person/PersonQueryData.js +2 -0
  35. package/lib/cjs/dto/person/PersonReadDto.d.ts +206 -0
  36. package/lib/cjs/dto/person/PersonReadDto.js +2 -0
  37. package/lib/cjs/dto/person/PersonTitle.d.ts +36 -0
  38. package/lib/cjs/dto/person/PersonTitle.js +40 -0
  39. package/lib/cjs/dto/personProfile/PersonProfileKind.d.ts +26 -0
  40. package/lib/cjs/dto/personProfile/PersonProfileKind.js +30 -0
  41. package/lib/cjs/dto/personProfile/PersonProfileListData.d.ts +16 -0
  42. package/lib/cjs/dto/personProfile/PersonProfileListData.js +2 -0
  43. package/lib/cjs/dto/personProfile/PersonProfileQueryData.d.ts +43 -0
  44. package/lib/cjs/dto/personProfile/PersonProfileQueryData.js +2 -0
  45. package/lib/cjs/dto/personProfile/PersonProfileUpdateReadData.d.ts +73 -0
  46. package/lib/cjs/dto/personProfile/PersonProfileUpdateReadData.js +2 -0
  47. package/lib/cjs/dto/personProfile/PersonProfileViewData.d.ts +5 -0
  48. package/lib/cjs/dto/personProfile/PersonProfileViewData.js +2 -0
  49. package/lib/cjs/i18n/CrmCulture.d.ts +244 -0
  50. package/lib/cjs/i18n/CrmCulture.js +23 -0
  51. package/lib/cjs/i18n/en.json +74 -0
  52. package/lib/cjs/i18n/zh-Hans.json +74 -0
  53. package/lib/cjs/i18n/zh-Hant.json +74 -0
  54. package/lib/cjs/index.d.ts +20 -0
  55. package/lib/cjs/index.js +40 -0
  56. package/lib/cjs/rq/person/PersonListRQ.d.ts +6 -0
  57. package/lib/cjs/rq/person/PersonListRQ.js +2 -0
  58. package/lib/cjs/rq/person/PersonQueryRQ.d.ts +6 -0
  59. package/lib/cjs/rq/person/PersonQueryRQ.js +2 -0
  60. package/lib/cjs/rq/personProfile/PersonProfileCreateRQ.d.ts +73 -0
  61. package/lib/cjs/rq/personProfile/PersonProfileCreateRQ.js +2 -0
  62. package/lib/cjs/rq/personProfile/PersonProfileListRQ.d.ts +48 -0
  63. package/lib/cjs/rq/personProfile/PersonProfileListRQ.js +2 -0
  64. package/lib/cjs/rq/personProfile/PersonProfileQueryRQ.d.ts +12 -0
  65. package/lib/cjs/rq/personProfile/PersonProfileQueryRQ.js +2 -0
  66. package/lib/mjs/CrmApp.d.ts +186 -0
  67. package/lib/mjs/CrmApp.js +165 -0
  68. package/lib/mjs/PersonApi.d.ts +38 -0
  69. package/lib/mjs/PersonApi.js +41 -0
  70. package/lib/mjs/PersonProfileApi.d.ts +54 -0
  71. package/lib/mjs/PersonProfileApi.js +59 -0
  72. package/lib/mjs/components/index.d.ts +1 -0
  73. package/lib/mjs/components/index.js +2 -0
  74. package/lib/mjs/components/person/PersonTiplist.d.ts +28 -0
  75. package/lib/mjs/components/person/PersonTiplist.js +24 -0
  76. package/lib/mjs/dto/person/AddressItem.d.ts +36 -0
  77. package/lib/mjs/dto/person/AddressItem.js +11 -0
  78. package/lib/mjs/dto/person/CategoryItem.d.ts +16 -0
  79. package/lib/mjs/dto/person/CategoryItem.js +1 -0
  80. package/lib/mjs/dto/person/ContactItem.d.ts +30 -0
  81. package/lib/mjs/dto/person/ContactItem.js +1 -0
  82. package/lib/mjs/dto/person/MaritalStatus.d.ts +36 -0
  83. package/lib/mjs/dto/person/MaritalStatus.js +37 -0
  84. package/lib/mjs/dto/person/PersonDegree.d.ts +26 -0
  85. package/lib/mjs/dto/person/PersonDegree.js +27 -0
  86. package/lib/mjs/dto/person/PersonEducation.d.ts +111 -0
  87. package/lib/mjs/dto/person/PersonEducation.js +112 -0
  88. package/lib/mjs/dto/person/PersonListDto.d.ts +6 -0
  89. package/lib/mjs/dto/person/PersonListDto.js +1 -0
  90. package/lib/mjs/dto/person/PersonQueryData.d.ts +24 -0
  91. package/lib/mjs/dto/person/PersonQueryData.js +1 -0
  92. package/lib/mjs/dto/person/PersonReadDto.d.ts +206 -0
  93. package/lib/mjs/dto/person/PersonReadDto.js +1 -0
  94. package/lib/mjs/dto/person/PersonTitle.d.ts +36 -0
  95. package/lib/mjs/dto/person/PersonTitle.js +37 -0
  96. package/lib/mjs/dto/personProfile/PersonProfileKind.d.ts +26 -0
  97. package/lib/mjs/dto/personProfile/PersonProfileKind.js +27 -0
  98. package/lib/mjs/dto/personProfile/PersonProfileListData.d.ts +16 -0
  99. package/lib/mjs/dto/personProfile/PersonProfileListData.js +1 -0
  100. package/lib/mjs/dto/personProfile/PersonProfileQueryData.d.ts +43 -0
  101. package/lib/mjs/dto/personProfile/PersonProfileQueryData.js +1 -0
  102. package/lib/mjs/dto/personProfile/PersonProfileUpdateReadData.d.ts +73 -0
  103. package/lib/mjs/dto/personProfile/PersonProfileUpdateReadData.js +1 -0
  104. package/lib/mjs/dto/personProfile/PersonProfileViewData.d.ts +5 -0
  105. package/lib/mjs/dto/personProfile/PersonProfileViewData.js +1 -0
  106. package/lib/mjs/i18n/CrmCulture.d.ts +460 -0
  107. package/lib/mjs/i18n/CrmCulture.js +20 -0
  108. package/lib/mjs/i18n/en.json +74 -0
  109. package/lib/mjs/i18n/zh-Hans.json +74 -0
  110. package/lib/mjs/i18n/zh-Hant.json +74 -0
  111. package/lib/mjs/index.d.ts +20 -0
  112. package/lib/mjs/index.js +24 -0
  113. package/lib/mjs/rq/person/PersonListRQ.d.ts +6 -0
  114. package/lib/mjs/rq/person/PersonListRQ.js +1 -0
  115. package/lib/mjs/rq/person/PersonQueryRQ.d.ts +6 -0
  116. package/lib/mjs/rq/person/PersonQueryRQ.js +1 -0
  117. package/lib/mjs/rq/personProfile/PersonProfileCreateRQ.d.ts +73 -0
  118. package/lib/mjs/rq/personProfile/PersonProfileCreateRQ.js +1 -0
  119. package/lib/mjs/rq/personProfile/PersonProfileListRQ.d.ts +48 -0
  120. package/lib/mjs/rq/personProfile/PersonProfileListRQ.js +1 -0
  121. package/lib/mjs/rq/personProfile/PersonProfileQueryRQ.d.ts +12 -0
  122. package/lib/mjs/rq/personProfile/PersonProfileQueryRQ.js +1 -0
  123. package/package.json +64 -0
  124. package/src/CrmApp.ts +270 -0
  125. package/src/PersonApi.ts +50 -0
  126. package/src/PersonProfileApi.ts +81 -0
  127. package/src/components/index.ts +2 -0
  128. package/src/components/person/PersonTiplist.tsx +75 -0
  129. package/src/dto/person/AddressItem.ts +39 -0
  130. package/src/dto/person/CategoryItem.ts +17 -0
  131. package/src/dto/person/ContactItem.ts +38 -0
  132. package/src/dto/person/MaritalStatus.ts +41 -0
  133. package/src/dto/person/PersonDegree.ts +29 -0
  134. package/src/dto/person/PersonEducation.ts +131 -0
  135. package/src/dto/person/PersonListDto.ts +7 -0
  136. package/src/dto/person/PersonQueryData.ts +28 -0
  137. package/src/dto/person/PersonReadDto.ts +242 -0
  138. package/src/dto/person/PersonTitle.ts +41 -0
  139. package/src/dto/personProfile/PersonProfileKind.ts +29 -0
  140. package/src/dto/personProfile/PersonProfileListData.ts +17 -0
  141. package/src/dto/personProfile/PersonProfileQueryData.ts +50 -0
  142. package/src/dto/personProfile/PersonProfileUpdateReadData.ts +86 -0
  143. package/src/dto/personProfile/PersonProfileViewData.ts +5 -0
  144. package/src/i18n/CrmCulture.ts +21 -0
  145. package/src/i18n/en.json +74 -0
  146. package/src/i18n/zh-Hans.json +74 -0
  147. package/src/i18n/zh-Hant.json +74 -0
  148. package/src/index.ts +30 -0
  149. package/src/rq/person/PersonListRQ.ts +7 -0
  150. package/src/rq/person/PersonQueryRQ.ts +7 -0
  151. package/src/rq/personProfile/PersonProfileCreateRQ.ts +86 -0
  152. package/src/rq/personProfile/PersonProfileListRQ.ts +56 -0
  153. package/src/rq/personProfile/PersonProfileQueryRQ.ts +13 -0
  154. package/tsconfig.cjs.json +20 -0
  155. package/tsconfig.json +20 -0
  156. package/vite.config.mts +12 -0
package/.gitattributes ADDED
@@ -0,0 +1,2 @@
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
@@ -0,0 +1,60 @@
1
+ # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
+ # For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3
+ # https://docs.github.com/en/actions/language-and-framework-guides/publishing-nodejs-packages
4
+
5
+ # Description
6
+ name: Node.js Package
7
+
8
+ # Event to trigger the action
9
+ on:
10
+ [push]
11
+ # release:
12
+ # types: [created]
13
+
14
+ jobs:
15
+ # Publish to NPM
16
+ publish-npm:
17
+ # Condition: previous build is successful
18
+ # needs: Any previous jobs
19
+
20
+ # Operation system
21
+ runs-on: ubuntu-latest
22
+
23
+ steps:
24
+ # https://github.com/actions/checkout, This action checks-out your repository under $GITHUB_WORKSPACE
25
+ # so your workflow can access it.
26
+ - uses: actions/checkout@v4
27
+
28
+ # Set up your GitHub Actions workflow with a specific version of node.js
29
+ # Setup .npmrc file to publish to npm
30
+ - uses: actions/setup-node@v4
31
+ with:
32
+ node-version: "20.x"
33
+ registry-url: "https://registry.npmjs.org"
34
+
35
+ # Named after Continuous Integration, installs dependencies directly from package-lock.json
36
+ # ci vs install
37
+ - run: npm install
38
+
39
+ # Make sure pass the test without any exception
40
+ - run: npm test
41
+
42
+ # Build the package
43
+ - run: npm run build
44
+
45
+ # Check if the package is already published
46
+ - name: Check publish status
47
+ id: check
48
+ uses: tehpsalmist/npm-publish-status-action@v1
49
+
50
+ # Publish to npm
51
+ # For scoped package, make it public for free service
52
+ - name: Publish if necessary
53
+ id: publish
54
+ if: ${{ steps.check.outputs.exists == '0' }} # package version doesn't yet exist, ship it!
55
+ run: npm publish --access public
56
+ env:
57
+ NODE_AUTH_TOKEN: ${{ secrets.ETSOONpmToken }}
58
+ - name: Report publish status
59
+ if: ${{ steps.check.outputs.exists == '1' }}
60
+ run: 'echo "package version already exists on npm registry"'
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2004-2025 ETSOO ® (亿速思维 ®), https://etsoo.com, https://etsoo.nz
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,17 @@
1
+ # @etsoo/smarterp-crm
2
+
3
+ **TypeScript APIs for SmartERP Customer Relationship Management (CRM)**
4
+
5
+ ## Installing
6
+
7
+ Using npm:
8
+
9
+ ```bash
10
+ $ npm install @etsoo/smarterp-crm
11
+ ```
12
+
13
+ Using yarn:
14
+
15
+ ```bash
16
+ $ yarn add @etsoo/shared/smarterp-crm
17
+ ```
@@ -0,0 +1,15 @@
1
+ import { PersonApi } from "../src";
2
+ import { isLocalTest, TestApp } from "./app/TestApp";
3
+
4
+ const app = new TestApp();
5
+
6
+ await app.changeCulture(app.settings.cultures[0]);
7
+
8
+ const api = new PersonApi(app);
9
+
10
+ test("Empty tests", () => {
11
+ expect(api).not.toBeNull();
12
+ });
13
+
14
+ if (isLocalTest) {
15
+ }
@@ -0,0 +1,139 @@
1
+ import {
2
+ INotificaseBase,
3
+ INotification,
4
+ Notification,
5
+ NotificationCallProps,
6
+ NotificationContainer,
7
+ NotificationRenderProps
8
+ } from "@etsoo/notificationbase";
9
+ import {
10
+ AddressUtils,
11
+ CoreApp,
12
+ createClient,
13
+ Culture,
14
+ IAppSettings,
15
+ InitCallResultData,
16
+ IUser
17
+ } from "@etsoo/appscript";
18
+ import { DataTypes, DomUtils, Utils, WindowStorage } from "@etsoo/shared";
19
+
20
+ // Detected country or region
21
+ const { detectedCountry } = DomUtils;
22
+
23
+ // Detected culture
24
+ const { detectedCulture } = DomUtils;
25
+
26
+ // Supported cultures
27
+ const supportedCultures: DataTypes.CultureDefinition[] = [
28
+ Culture.zhHans({}),
29
+ Culture.en({})
30
+ ];
31
+
32
+ // Supported regions
33
+ const supportedRegions = ["CN"];
34
+
35
+ // Class implementation for tests
36
+ class NotificationTest extends Notification<any, NotificationCallProps> {
37
+ render(props: NotificationRenderProps, className?: string, options?: any) {
38
+ throw new Error("Method not implemented.");
39
+ }
40
+ }
41
+
42
+ class NotificationContainerTest extends NotificationContainer<
43
+ any,
44
+ NotificationCallProps
45
+ > {
46
+ protected addRaw(
47
+ data: INotificaseBase<any, NotificationCallProps>
48
+ ): INotification<any, NotificationCallProps> {
49
+ return new NotificationTest(data.type, data.content);
50
+ }
51
+ }
52
+
53
+ // Container
54
+ var container = new NotificationContainerTest((update) => {});
55
+
56
+ // Is local test (integration test)
57
+ // Make sure your local environment is ready
58
+ export const isLocalTest = process.env.NODE_ENV === "local";
59
+
60
+ // Test application class
61
+ export class TestApp extends CoreApp<
62
+ IUser,
63
+ IAppSettings,
64
+ {},
65
+ NotificationCallProps
66
+ > {
67
+ /**
68
+ * Constructor
69
+ * @param settings Settings
70
+ * @param name Application name
71
+ */
72
+ constructor() {
73
+ super(
74
+ {
75
+ appId: 0,
76
+
77
+ /**
78
+ * Endpoint of the API service
79
+ */
80
+ endpoint: "http://{hostname}:9000/api/",
81
+
82
+ endpoints: {
83
+ core: {
84
+ endpoint: "https://{hostname}:9001/api/",
85
+ webUrl: ""
86
+ }
87
+ },
88
+
89
+ /**
90
+ * App root url
91
+ */
92
+ homepage: "/cms",
93
+
94
+ /**
95
+ * Web url of the cloud
96
+ */
97
+ webUrl: "https://localhost",
98
+
99
+ // Detected culture
100
+ detectedCulture,
101
+
102
+ // Supported cultures
103
+ cultures: supportedCultures,
104
+
105
+ // Supported regions
106
+ regions: supportedRegions,
107
+
108
+ // Browser's time zone
109
+ timeZone: Utils.getTimeZone(),
110
+
111
+ // Current country or region
112
+ currentRegion: AddressUtils.getRegion(
113
+ supportedRegions,
114
+ detectedCountry,
115
+ detectedCulture
116
+ ),
117
+
118
+ // Current culture
119
+ currentCulture: DomUtils.getCulture(
120
+ supportedCultures,
121
+ detectedCulture
122
+ )![0]
123
+ },
124
+ createClient(),
125
+ container,
126
+ new WindowStorage(),
127
+ "SmartERP"
128
+ );
129
+ }
130
+
131
+ freshCountdownUI(callback?: () => PromiseLike<unknown>): void {
132
+ throw new Error("Method not implemented.");
133
+ }
134
+
135
+ initCallUpdateLocal(data: InitCallResultData, timestamp: number) {
136
+ this.initCallUpdate(data, timestamp);
137
+ return this.passphrase;
138
+ }
139
+ }
@@ -0,0 +1,20 @@
1
+ {
2
+ "compilerOptions": {
3
+ /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
+ "target": "ES2022",
5
+ "module": "ES2022",
6
+ "moduleResolution": "bundler",
7
+ "allowJs": false,
8
+ "isolatedModules": true,
9
+ "outDir": "./lib",
10
+ "noEmit": false,
11
+ "declaration": true,
12
+ "strict": true,
13
+ "esModuleInterop": true,
14
+ "skipLibCheck": false,
15
+ "jsx": "react-jsx",
16
+ "forceConsistentCasingInFileNames": true,
17
+ "types": ["vitest/globals"]
18
+ },
19
+ "include": [".."]
20
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "presets": [["@babel/env"]],
3
+ "plugins": [
4
+ [
5
+ "@babel/plugin-transform-runtime",
6
+ {
7
+ "corejs": 3
8
+ }
9
+ ]
10
+ ]
11
+ }
@@ -0,0 +1,186 @@
1
+ import { IApi, IApp } from "@etsoo/appscript";
2
+ import { PersonApi } from "./PersonApi";
3
+ import { IServiceApp } from "@etsoo/materialui";
4
+ import { IdentityTypeData } from "./dto/person/ContactItem";
5
+ import { PersonTitle } from "./dto/person/PersonTitle";
6
+ import { ListType } from "@etsoo/shared";
7
+ import { MaritalStatus } from "./dto/person/MaritalStatus";
8
+ import { PersonDegree } from "./dto/person/PersonDegree";
9
+ import { PersonEducation } from "./dto/person/PersonEducation";
10
+ import { PersonProfileApi } from "./PersonProfileApi";
11
+ /**
12
+ * Get CRM app context hook
13
+ * @returns CRM app
14
+ */
15
+ export declare function useRequiredCrmContext(): ICrmApp;
16
+ /**
17
+ * CRM service app interface
18
+ * CRM 服务应用程序接口
19
+ */
20
+ export type ICrmServiceApp = IServiceApp & (ICrmApp | {
21
+ crm: ICrmApp;
22
+ });
23
+ /**
24
+ * CRM application interface
25
+ * CRM应用程序接口
26
+ */
27
+ export interface ICrmApp {
28
+ /**
29
+ * Application
30
+ * 应用程序
31
+ */
32
+ get app(): IApp;
33
+ /**
34
+ * Person API
35
+ * 人员接口
36
+ */
37
+ readonly personApi: PersonApi;
38
+ /**
39
+ * Person profile API
40
+ * 人员档案接口
41
+ */
42
+ readonly personProfileApi: PersonProfileApi;
43
+ /**
44
+ * Get marital status
45
+ * 获取婚姻状况
46
+ * @param status
47
+ */
48
+ getMaritalStatus(status?: MaritalStatus): string | undefined;
49
+ /**
50
+ * Get marital statuses
51
+ * 获取婚姻状况列表
52
+ * @param status
53
+ */
54
+ getMaritalStatuses(): ListType[];
55
+ /**
56
+ * Get person degree
57
+ * 获取人员学历
58
+ * @param degree
59
+ */
60
+ getPersonDegree(degree?: PersonDegree): string | undefined;
61
+ /**
62
+ * Get person degree list
63
+ * 获取人员学历列表
64
+ */
65
+ getPersonDegrees(): ListType[];
66
+ /**
67
+ * Get person education
68
+ * 获取人员学历
69
+ * @param education
70
+ */
71
+ getPersonEducation(education?: PersonEducation): string | undefined;
72
+ /**
73
+ * Get person education list
74
+ * 获取人员学历列表
75
+ */
76
+ getPersonEducations(): ListType[];
77
+ /**
78
+ * Get person gender
79
+ * 获取人员性别
80
+ * @param gender Gender value
81
+ * @returns Label
82
+ */
83
+ getPersonGender(gender?: string): string | undefined;
84
+ /**
85
+ * Get identity type
86
+ * 获取身份类型
87
+ * @param data Identity type data
88
+ */
89
+ getIdentityType(data?: IdentityTypeData): string;
90
+ /**
91
+ * Get person title
92
+ * 获取人员头衔
93
+ * @param title
94
+ */
95
+ getPersonTitle(title?: PersonTitle): string | undefined;
96
+ /**
97
+ * Get person titles
98
+ * 获取人员头衔
99
+ */
100
+ getPersonTitles(): ListType[];
101
+ }
102
+ /**
103
+ * CRM application
104
+ * CRM应用程序
105
+ */
106
+ export declare class CrmApp implements ICrmApp {
107
+ readonly app: IApp;
108
+ readonly api: IApi;
109
+ private _personApi?;
110
+ /**
111
+ * Person API
112
+ * 人员接口
113
+ */
114
+ get personApi(): PersonApi;
115
+ private _personProfileApi?;
116
+ /**
117
+ * Person profile API
118
+ * 人员档案接口
119
+ */
120
+ get personProfileApi(): PersonProfileApi;
121
+ /**
122
+ * Constructor
123
+ * 构造函数
124
+ * @param app Base application
125
+ * @param api API
126
+ */
127
+ constructor(app: IApp, api: IApi);
128
+ /**
129
+ * Get person gender
130
+ * 获取人员性别
131
+ * @param gender Gender value
132
+ * @returns Label
133
+ */
134
+ getPersonGender(gender?: string): string | undefined;
135
+ /**
136
+ * Get identity type
137
+ * 获取身份类型
138
+ * @param data Identity type data
139
+ */
140
+ getIdentityType(data?: IdentityTypeData): string;
141
+ /**
142
+ * Get marital status
143
+ * 获取婚姻状况
144
+ * @param status
145
+ */
146
+ getMaritalStatus(status?: MaritalStatus): string | undefined;
147
+ /**
148
+ * Get marital statuses
149
+ * 获取婚姻状况列表
150
+ * @param status
151
+ */
152
+ getMaritalStatuses(): ListType[];
153
+ /**
154
+ * Get person degree
155
+ * 获取人员学历
156
+ * @param degree
157
+ */
158
+ getPersonDegree(degree?: PersonDegree): string | undefined;
159
+ /**
160
+ * Get person degree list
161
+ * 获取人员学历列表
162
+ */
163
+ getPersonDegrees(): ListType[];
164
+ /**
165
+ * Get person education
166
+ * 获取人员学历
167
+ * @param education
168
+ */
169
+ getPersonEducation(education?: PersonEducation): string | undefined;
170
+ /**
171
+ * Get person education list
172
+ * 获取人员学历列表
173
+ */
174
+ getPersonEducations(): ListType[];
175
+ /**
176
+ * Get person title
177
+ * 获取人员头衔
178
+ * @param title
179
+ */
180
+ getPersonTitle(title?: PersonTitle): string | undefined;
181
+ /**
182
+ * Get person titles
183
+ * 获取人员头衔
184
+ */
185
+ getPersonTitles(): ListType[];
186
+ }
@@ -0,0 +1,170 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CrmApp = void 0;
4
+ exports.useRequiredCrmContext = useRequiredCrmContext;
5
+ const appscript_1 = require("@etsoo/appscript");
6
+ const PersonApi_1 = require("./PersonApi");
7
+ const react_1 = require("@etsoo/react");
8
+ const materialui_1 = require("@etsoo/materialui");
9
+ const PersonTitle_1 = require("./dto/person/PersonTitle");
10
+ const MaritalStatus_1 = require("./dto/person/MaritalStatus");
11
+ const PersonDegree_1 = require("./dto/person/PersonDegree");
12
+ const PersonEducation_1 = require("./dto/person/PersonEducation");
13
+ const PersonProfileApi_1 = require("./PersonProfileApi");
14
+ /**
15
+ * Get CRM app context hook
16
+ * @returns CRM app
17
+ */
18
+ function useRequiredCrmContext() {
19
+ // Get the app context
20
+ const app = (0, react_1.useRequiredContext)(materialui_1.ReactAppContext);
21
+ // Check the app type
22
+ if ("crm" in app) {
23
+ return app.crm;
24
+ }
25
+ else {
26
+ return app;
27
+ }
28
+ }
29
+ /**
30
+ * CRM application
31
+ * CRM应用程序
32
+ */
33
+ class CrmApp {
34
+ app;
35
+ api;
36
+ _personApi;
37
+ /**
38
+ * Person API
39
+ * 人员接口
40
+ */
41
+ get personApi() {
42
+ return (this._personApi ??= new PersonApi_1.PersonApi(this.app, this.api));
43
+ }
44
+ _personProfileApi;
45
+ /**
46
+ * Person profile API
47
+ * 人员档案接口
48
+ */
49
+ get personProfileApi() {
50
+ return (this._personProfileApi ??= new PersonProfileApi_1.PersonProfileApi(this.app, this.api));
51
+ }
52
+ /**
53
+ * Constructor
54
+ * 构造函数
55
+ * @param app Base application
56
+ * @param api API
57
+ */
58
+ constructor(app, api) {
59
+ this.app = app;
60
+ this.api = api;
61
+ }
62
+ /**
63
+ * Get person gender
64
+ * 获取人员性别
65
+ * @param gender Gender value
66
+ * @returns Label
67
+ */
68
+ getPersonGender(gender) {
69
+ if (gender === "M")
70
+ return this.app.get("personMale") ?? "Male";
71
+ else if (gender === "F")
72
+ return this.app.get("personFemale") ?? "Female";
73
+ else
74
+ return undefined;
75
+ }
76
+ /**
77
+ * Get identity type
78
+ * 获取身份类型
79
+ * @param data Identity type data
80
+ */
81
+ getIdentityType(data) {
82
+ if (data == null)
83
+ return "";
84
+ if (data.isOrg) {
85
+ return this.app.get("org");
86
+ }
87
+ const type = data.identityType;
88
+ return this.app
89
+ .getEnumList(appscript_1.IdentityType, "id", (id, _key) => {
90
+ if ((id & type) > 0)
91
+ return id;
92
+ })
93
+ .map((d) => d.label)
94
+ .join(", ");
95
+ }
96
+ /**
97
+ * Get marital status
98
+ * 获取婚姻状况
99
+ * @param status
100
+ */
101
+ getMaritalStatus(status) {
102
+ if (status == null)
103
+ return undefined;
104
+ const key = MaritalStatus_1.MaritalStatus[status];
105
+ return this.app.get("marital" + key) ?? key;
106
+ }
107
+ /**
108
+ * Get marital statuses
109
+ * 获取婚姻状况列表
110
+ * @param status
111
+ */
112
+ getMaritalStatuses() {
113
+ return this.app.getEnumList(MaritalStatus_1.MaritalStatus, "marital");
114
+ }
115
+ /**
116
+ * Get person degree
117
+ * 获取人员学历
118
+ * @param degree
119
+ */
120
+ getPersonDegree(degree) {
121
+ if (degree == null)
122
+ return undefined;
123
+ const key = PersonDegree_1.PersonDegree[degree];
124
+ return this.app.get("degree" + key) ?? key;
125
+ }
126
+ /**
127
+ * Get person degree list
128
+ * 获取人员学历列表
129
+ */
130
+ getPersonDegrees() {
131
+ return this.app.getEnumList(PersonDegree_1.PersonDegree, "degree");
132
+ }
133
+ /**
134
+ * Get person education
135
+ * 获取人员学历
136
+ * @param education
137
+ */
138
+ getPersonEducation(education) {
139
+ if (education == null)
140
+ return undefined;
141
+ const key = PersonEducation_1.PersonEducation[education];
142
+ return this.app.get("education" + key) ?? key;
143
+ }
144
+ /**
145
+ * Get person education list
146
+ * 获取人员学历列表
147
+ */
148
+ getPersonEducations() {
149
+ return this.app.getEnumList(PersonEducation_1.PersonEducation, "education");
150
+ }
151
+ /**
152
+ * Get person title
153
+ * 获取人员头衔
154
+ * @param title
155
+ */
156
+ getPersonTitle(title) {
157
+ if (title == null)
158
+ return undefined;
159
+ const key = PersonTitle_1.PersonTitle[title];
160
+ return this.app.get("personTitle" + key) ?? key;
161
+ }
162
+ /**
163
+ * Get person titles
164
+ * 获取人员头衔
165
+ */
166
+ getPersonTitles() {
167
+ return this.app.getEnumList(PersonTitle_1.PersonTitle, "personTitle");
168
+ }
169
+ }
170
+ exports.CrmApp = CrmApp;
@@ -0,0 +1,38 @@
1
+ import { EntityApi, IApi, IApiPayload, IApp } from "@etsoo/appscript";
2
+ import { PersonListRQ } from "./rq/person/PersonListRQ";
3
+ import { PersonQueryRQ } from "./rq/person/PersonQueryRQ";
4
+ import { PersonListDto } from "./dto/person/PersonListDto";
5
+ import { PersonQueryData } from "./dto/person/PersonQueryData";
6
+ import { PersonViewData } from "./dto/person/PersonReadDto";
7
+ /**
8
+ * Person API
9
+ */
10
+ export declare class PersonApi extends EntityApi {
11
+ /**
12
+ * Constructor
13
+ * @param app Application
14
+ * @param api API
15
+ */
16
+ constructor(app: IApp, api?: IApi);
17
+ /**
18
+ * List
19
+ * @param rq Request data
20
+ * @param payload Payload
21
+ * @returns Result
22
+ */
23
+ list(rq: PersonListRQ, payload: IApiPayload<PersonListDto[]>): Promise<PersonListDto[] | undefined>;
24
+ /**
25
+ * Query
26
+ * @param rq Request data
27
+ * @param payload Payload
28
+ * @returns Result
29
+ */
30
+ query(rq: PersonQueryRQ, payload?: IApiPayload<PersonQueryData[]>): Promise<PersonQueryData[] | undefined>;
31
+ /**
32
+ * Read
33
+ * @param id Id
34
+ * @param payload Payload
35
+ * @returns Result
36
+ */
37
+ read(id: number, payload?: IApiPayload<PersonViewData>): Promise<PersonViewData | undefined>;
38
+ }