@etsoo/appscript 1.2.21 → 1.2.25
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.
- package/__tests__/app/CoreApp.ts +15 -0
- package/lib/cjs/app/CoreApp.d.ts +27 -0
- package/lib/cjs/app/CoreApp.js +20 -0
- package/lib/cjs/business/BusinessUtils.d.ts +21 -2
- package/lib/cjs/business/BusinessUtils.js +32 -6
- package/lib/cjs/business/EntityStatus.d.ts +1 -0
- package/lib/cjs/business/EntityStatus.js +1 -0
- package/lib/cjs/business/ProductUnit.d.ts +47 -45
- package/lib/cjs/business/ProductUnit.js +36 -48
- package/lib/cjs/business/RepeatOption.d.ts +56 -0
- package/lib/cjs/business/RepeatOption.js +60 -0
- package/lib/cjs/i18n/en-US.json +24 -0
- package/lib/cjs/i18n/zh-CN.json +26 -1
- package/lib/cjs/i18n/zh-HK.json +25 -1
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/mjs/app/CoreApp.d.ts +27 -0
- package/lib/mjs/app/CoreApp.js +20 -0
- package/lib/mjs/business/BusinessUtils.d.ts +21 -2
- package/lib/mjs/business/BusinessUtils.js +32 -6
- package/lib/mjs/business/EntityStatus.d.ts +1 -0
- package/lib/mjs/business/EntityStatus.js +1 -0
- package/lib/mjs/business/ProductUnit.d.ts +47 -45
- package/lib/mjs/business/ProductUnit.js +35 -47
- package/lib/mjs/business/RepeatOption.d.ts +56 -0
- package/lib/mjs/business/RepeatOption.js +57 -0
- package/lib/mjs/i18n/en-US.json +24 -0
- package/lib/mjs/i18n/zh-CN.json +26 -1
- package/lib/mjs/i18n/zh-HK.json +25 -1
- package/lib/mjs/index.d.ts +1 -0
- package/lib/mjs/index.js +1 -0
- package/package.json +10 -10
- package/src/app/CoreApp.ts +37 -0
- package/src/business/BusinessUtils.ts +66 -7
- package/src/business/EntityStatus.ts +1 -0
- package/src/business/ProductUnit.ts +35 -51
- package/src/business/RepeatOption.ts +65 -0
- package/src/i18n/en-US.json +24 -0
- package/src/i18n/zh-CN.json +26 -1
- package/src/i18n/zh-HK.json +25 -1
- package/src/index.ts +1 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repeat options
|
|
3
|
+
* Part of ProductUnit, range 10 - 39
|
|
4
|
+
*/
|
|
5
|
+
export var RepeatOption;
|
|
6
|
+
(function (RepeatOption) {
|
|
7
|
+
/**
|
|
8
|
+
* Hour
|
|
9
|
+
* 小时
|
|
10
|
+
*/
|
|
11
|
+
RepeatOption[RepeatOption["HOUR"] = 10] = "HOUR";
|
|
12
|
+
/**
|
|
13
|
+
* Day
|
|
14
|
+
* 天
|
|
15
|
+
*/
|
|
16
|
+
RepeatOption[RepeatOption["DAY"] = 11] = "DAY";
|
|
17
|
+
/**
|
|
18
|
+
* Year
|
|
19
|
+
* 年
|
|
20
|
+
*/
|
|
21
|
+
RepeatOption[RepeatOption["YEAR"] = 12] = "YEAR";
|
|
22
|
+
/**
|
|
23
|
+
* Week
|
|
24
|
+
* 周
|
|
25
|
+
*/
|
|
26
|
+
RepeatOption[RepeatOption["WEEK"] = 21] = "WEEK";
|
|
27
|
+
/**
|
|
28
|
+
* Two weeks
|
|
29
|
+
* 两周
|
|
30
|
+
*/
|
|
31
|
+
RepeatOption[RepeatOption["FORTNIGHT"] = 22] = "FORTNIGHT";
|
|
32
|
+
/**
|
|
33
|
+
* Four weeks
|
|
34
|
+
* 四周
|
|
35
|
+
*/
|
|
36
|
+
RepeatOption[RepeatOption["FOURWEEK"] = 24] = "FOURWEEK";
|
|
37
|
+
/**
|
|
38
|
+
* Month
|
|
39
|
+
* 月
|
|
40
|
+
*/
|
|
41
|
+
RepeatOption[RepeatOption["MONTH"] = 31] = "MONTH";
|
|
42
|
+
/**
|
|
43
|
+
* Two months
|
|
44
|
+
* 两月
|
|
45
|
+
*/
|
|
46
|
+
RepeatOption[RepeatOption["BIMONTH"] = 32] = "BIMONTH";
|
|
47
|
+
/**
|
|
48
|
+
* Quater(3 months)
|
|
49
|
+
* 季(三个月)
|
|
50
|
+
*/
|
|
51
|
+
RepeatOption[RepeatOption["QUATER"] = 33] = "QUATER";
|
|
52
|
+
/**
|
|
53
|
+
* Half a year
|
|
54
|
+
* 半年
|
|
55
|
+
*/
|
|
56
|
+
RepeatOption[RepeatOption["HALFYEAR"] = 36] = "HALFYEAR";
|
|
57
|
+
})(RepeatOption || (RepeatOption = {}));
|
package/lib/mjs/i18n/en-US.json
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"creation": "Creation",
|
|
13
13
|
"currency": "Currency",
|
|
14
14
|
"delete": "Delete",
|
|
15
|
+
"deleteConfirm": "Are you sure you want to permanently delete this {0}?",
|
|
15
16
|
"description": "Description",
|
|
16
17
|
"done": "Done",
|
|
17
18
|
"edit": "Edit",
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
"pageNotFound": "Page Not Found",
|
|
44
45
|
"prompt": "Input",
|
|
45
46
|
"pullToRefresh": "Pull down to refresh",
|
|
47
|
+
"record": "Record",
|
|
46
48
|
"refresh": "Refresh",
|
|
47
49
|
"refreshing": "Refreshing",
|
|
48
50
|
"releaseToRefresh": "Release to refresh",
|
|
@@ -63,13 +65,35 @@
|
|
|
63
65
|
"showIt": "Show it",
|
|
64
66
|
"signout": "Sign out",
|
|
65
67
|
"smartERP": "SmartERP",
|
|
68
|
+
"sortTip": "Drag and drop items to sort",
|
|
66
69
|
"status": "Status",
|
|
70
|
+
"statusArchived": "Archived",
|
|
71
|
+
"statusDeleted": "Deleted",
|
|
72
|
+
"statusFlaged": "Flaged",
|
|
73
|
+
"statusNormal": "Normla",
|
|
74
|
+
"statusInactivated": "Inactivated",
|
|
67
75
|
"submit": "Submit",
|
|
68
76
|
"success": "Success",
|
|
69
77
|
"timeDifferenceInvalid": "The time difference between the device and the server is {0}, which exceeds the limit of {1} seconds. Please adjust the device time. If it is abnormal, please inform the administrator",
|
|
70
78
|
"tokenExpiry": "Your session is about to expire. Click the Cancel button to continue",
|
|
71
79
|
"yes": "Yes",
|
|
72
80
|
"unknownError": "Unknown Error",
|
|
81
|
+
"unitJoin": "per {0}",
|
|
82
|
+
"unitPC": "PC",
|
|
83
|
+
"unitSET": "SET",
|
|
84
|
+
"unitHOUR": "Hour",
|
|
85
|
+
"unitDAY": "Day",
|
|
86
|
+
"unitYEAR": "Year",
|
|
87
|
+
"unitWEEK": "Week",
|
|
88
|
+
"unitFORTNIGHT": "Fortnight",
|
|
89
|
+
"unitFOURWEEK": "4-week",
|
|
90
|
+
"unitMONTH": "Month",
|
|
91
|
+
"unitBIMONTH": "2-month",
|
|
92
|
+
"unitQUATER": "Quater",
|
|
93
|
+
"unitHALFYEAR": "6-month",
|
|
94
|
+
"unitGRAM": "g",
|
|
95
|
+
"unitJIN": "½Kg",
|
|
96
|
+
"unitKILOGRAM": "Kg",
|
|
73
97
|
"warning": "Warning",
|
|
74
98
|
"welcome": "{0}, welcome!"
|
|
75
99
|
}
|
package/lib/mjs/i18n/zh-CN.json
CHANGED
|
@@ -12,12 +12,13 @@
|
|
|
12
12
|
"creation": "登记时间",
|
|
13
13
|
"currency": "币种",
|
|
14
14
|
"delete": "删除",
|
|
15
|
+
"deleteConfirm": "确定要永久删除此{0}吗?",
|
|
15
16
|
"description": "描述",
|
|
16
17
|
"done": "完成",
|
|
17
18
|
"edit": "修改",
|
|
18
19
|
"email": "电子邮箱",
|
|
19
20
|
"emailAddresses": "电子邮箱",
|
|
20
|
-
"enabled": "
|
|
21
|
+
"enabled": "已启用",
|
|
21
22
|
"etsoo": "亿速思维",
|
|
22
23
|
"expiry": "到期时间",
|
|
23
24
|
"failed": "操作失败",
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
"pageNotFound": "找不到页面",
|
|
44
45
|
"prompt": "输入",
|
|
45
46
|
"pullToRefresh": "下拉刷新",
|
|
47
|
+
"record": "记录",
|
|
46
48
|
"refresh": "刷新",
|
|
47
49
|
"refreshing": "正在刷新",
|
|
48
50
|
"releaseToRefresh": "释放刷新",
|
|
@@ -63,13 +65,36 @@
|
|
|
63
65
|
"showIt": "显示",
|
|
64
66
|
"signout": "退出",
|
|
65
67
|
"smartERP": "司友云ERP",
|
|
68
|
+
"sortTip": "拖拽项目进行排序",
|
|
66
69
|
"status": "状态",
|
|
70
|
+
"statusArchived": "已归档",
|
|
71
|
+
"statusDeleted": "已删除",
|
|
72
|
+
"statusFlaged": "已标记",
|
|
73
|
+
"statusNormal": "正常",
|
|
74
|
+
"statusInactivated": "已停用",
|
|
67
75
|
"submit": "提交",
|
|
68
76
|
"success": "成功",
|
|
69
77
|
"timeDifferenceInvalid": "设备时间和服务器时间差为{0},超过{1}秒的限制,请调整设备时间,如果异常请告知管理员",
|
|
70
78
|
"tokenExpiry": "您的会话即将过期。点击 取消 按钮继续使用",
|
|
71
79
|
"yes": "是",
|
|
72
80
|
"unknownError": "未知错误",
|
|
81
|
+
"unitJoin": "每{0}",
|
|
82
|
+
"unitPC": "件",
|
|
83
|
+
"unitSET": "套",
|
|
84
|
+
"unitHOUR": "小时",
|
|
85
|
+
"unitDAY": "天",
|
|
86
|
+
"unitYEAR": "年",
|
|
87
|
+
"unitWEEK": "周",
|
|
88
|
+
"unitFORTNIGHT": "两周",
|
|
89
|
+
"unitFOURWEEK": "四周",
|
|
90
|
+
"unitMONTH": "月",
|
|
91
|
+
"unitBIMONTH": "两月",
|
|
92
|
+
"unitQUATER": "季度",
|
|
93
|
+
"unitHALFYEAR": "半年",
|
|
94
|
+
"unitGRAM": "克",
|
|
95
|
+
"unitJIN": "斤",
|
|
96
|
+
"unitKILOGRAM": "公斤",
|
|
97
|
+
"unitTON": "吨",
|
|
73
98
|
"warning": "警告",
|
|
74
99
|
"welcome": "{0}, 欢迎光临!"
|
|
75
100
|
}
|
package/lib/mjs/i18n/zh-HK.json
CHANGED
|
@@ -12,12 +12,13 @@
|
|
|
12
12
|
"creation": "登記時間",
|
|
13
13
|
"currency": "幣種",
|
|
14
14
|
"delete": "刪除",
|
|
15
|
+
"deleteConfirm": "確定要永久刪除此{0}嗎?",
|
|
15
16
|
"description": "描述",
|
|
16
17
|
"done": "完成",
|
|
17
18
|
"edit": "修改",
|
|
18
19
|
"email": "電子郵箱",
|
|
19
20
|
"emailAddresses": "電子郵箱",
|
|
20
|
-
"enabled": "
|
|
21
|
+
"enabled": "已啟用",
|
|
21
22
|
"etsoo": "億速思維",
|
|
22
23
|
"expiry": "到期時間",
|
|
23
24
|
"failed": "操作失敗",
|
|
@@ -43,6 +44,7 @@
|
|
|
43
44
|
"pageNotFound": "找不到頁面",
|
|
44
45
|
"prompt": "輸入",
|
|
45
46
|
"pullToRefresh": "下拉刷新",
|
|
47
|
+
"record": "記錄",
|
|
46
48
|
"refresh": "刷新",
|
|
47
49
|
"refreshing": "正在刷新",
|
|
48
50
|
"releaseToRefresh": "釋放刷新",
|
|
@@ -63,13 +65,35 @@
|
|
|
63
65
|
"showIt": "顯示",
|
|
64
66
|
"signout": "退出",
|
|
65
67
|
"smartERP": "司友雲ERP",
|
|
68
|
+
"sortTip": "拖拽項目進行排序",
|
|
66
69
|
"status": "狀態",
|
|
70
|
+
"statusArchived": "已歸檔",
|
|
71
|
+
"statusDeleted": "已刪除",
|
|
72
|
+
"statusFlaged": "已標記",
|
|
73
|
+
"statusNormal": "正常",
|
|
74
|
+
"statusInactivated": "已停用",
|
|
67
75
|
"submit": "提交",
|
|
68
76
|
"success": "成功",
|
|
69
77
|
"timeDifferenceInvalid": "設備時間和服務器時間差為{0},超過{1}秒的限制,請調整設備時間,如果異常請告知管理員",
|
|
70
78
|
"tokenExpiry": "您的會話即將過期。點擊 取消 按鈕繼續使用",
|
|
71
79
|
"yes": "是",
|
|
72
80
|
"unknownError": "未知錯誤",
|
|
81
|
+
"unitJoin": "每{0}",
|
|
82
|
+
"unitPC": "件",
|
|
83
|
+
"unitSET": "套",
|
|
84
|
+
"unitHOUR": "小時",
|
|
85
|
+
"unitDAY": "天",
|
|
86
|
+
"unitYEAR": "年",
|
|
87
|
+
"unitWEEK": "週",
|
|
88
|
+
"unitFORTNIGHT": "兩週",
|
|
89
|
+
"unitFOURWEEK": "四周",
|
|
90
|
+
"unitMONTH": "月",
|
|
91
|
+
"unitBIMONTH": "兩月",
|
|
92
|
+
"unitQUATER": "季度",
|
|
93
|
+
"unitHALFYEAR": "半年",
|
|
94
|
+
"unitGRAM": "克",
|
|
95
|
+
"unitJIN": "斤",
|
|
96
|
+
"unitKILOGRAM": "公斤",
|
|
73
97
|
"warning": "警告",
|
|
74
98
|
"welcome": "{0}, 歡迎光臨!"
|
|
75
99
|
}
|
package/lib/mjs/index.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export * from './business/BusinessTax';
|
|
|
12
12
|
export * from './business/BusinessUtils';
|
|
13
13
|
export * from './business/EntityStatus';
|
|
14
14
|
export * from './business/ProductUnit';
|
|
15
|
+
export * from './business/RepeatOption';
|
|
15
16
|
export * from './def/ListItem';
|
|
16
17
|
export * from './dto/IdDto';
|
|
17
18
|
export * from './dto/IdLabelDto';
|
package/lib/mjs/index.js
CHANGED
|
@@ -16,6 +16,7 @@ export * from './business/BusinessTax';
|
|
|
16
16
|
export * from './business/BusinessUtils';
|
|
17
17
|
export * from './business/EntityStatus';
|
|
18
18
|
export * from './business/ProductUnit';
|
|
19
|
+
export * from './business/RepeatOption';
|
|
19
20
|
// def
|
|
20
21
|
export * from './def/ListItem';
|
|
21
22
|
// dto
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/appscript",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.25",
|
|
4
4
|
"description": "Applications shared TypeScript framework",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -54,24 +54,24 @@
|
|
|
54
54
|
"dependencies": {
|
|
55
55
|
"@etsoo/notificationbase": "^1.1.0",
|
|
56
56
|
"@etsoo/restclient": "^1.0.64",
|
|
57
|
-
"@etsoo/shared": "^1.1.
|
|
57
|
+
"@etsoo/shared": "^1.1.5",
|
|
58
58
|
"@types/crypto-js": "^4.1.0",
|
|
59
59
|
"crypto-js": "^4.1.1"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@babel/cli": "^7.16.
|
|
62
|
+
"@babel/cli": "^7.16.8",
|
|
63
63
|
"@babel/core": "^7.16.7",
|
|
64
|
-
"@babel/plugin-transform-runtime": "^7.16.
|
|
65
|
-
"@babel/preset-env": "^7.16.
|
|
66
|
-
"@babel/runtime-corejs3": "^7.16.
|
|
64
|
+
"@babel/plugin-transform-runtime": "^7.16.8",
|
|
65
|
+
"@babel/preset-env": "^7.16.8",
|
|
66
|
+
"@babel/runtime-corejs3": "^7.16.8",
|
|
67
67
|
"@types/jest": "^27.4.0",
|
|
68
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
69
|
-
"@typescript-eslint/parser": "^5.
|
|
70
|
-
"eslint": "^8.
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "^5.10.0",
|
|
69
|
+
"@typescript-eslint/parser": "^5.10.0",
|
|
70
|
+
"eslint": "^8.7.0",
|
|
71
71
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
72
72
|
"eslint-plugin-import": "^2.25.4",
|
|
73
73
|
"jest": "^27.4.7",
|
|
74
|
-
"ts-jest": "^27.1.
|
|
74
|
+
"ts-jest": "^27.1.3",
|
|
75
75
|
"typescript": "^4.5.4"
|
|
76
76
|
}
|
|
77
77
|
}
|
package/src/app/CoreApp.ts
CHANGED
|
@@ -29,6 +29,8 @@ import {
|
|
|
29
29
|
} from 'crypto-js';
|
|
30
30
|
import { AddressRegion } from '../address/AddressRegion';
|
|
31
31
|
import { AddressUtils } from '../address/AddressUtils';
|
|
32
|
+
import { BusinessUtils } from '../business/BusinessUtils';
|
|
33
|
+
import { ProductUnit } from '../business/ProductUnit';
|
|
32
34
|
import { IdLabelDto } from '../dto/IdLabelDto';
|
|
33
35
|
import { InitCallDto } from '../dto/InitCallDto';
|
|
34
36
|
import { ActionResultError } from '../result/ActionResultError';
|
|
@@ -330,6 +332,12 @@ export interface ICoreApp<
|
|
|
330
332
|
*/
|
|
331
333
|
getCacheToken(): string | undefined;
|
|
332
334
|
|
|
335
|
+
/**
|
|
336
|
+
* Get entity status label
|
|
337
|
+
* @param data Input data
|
|
338
|
+
*/
|
|
339
|
+
getEntityStatusLabel<D extends { entityStatus?: number }>(data: D): string;
|
|
340
|
+
|
|
333
341
|
/**
|
|
334
342
|
* Get all regions
|
|
335
343
|
* @returns Regions
|
|
@@ -349,6 +357,13 @@ export interface ICoreApp<
|
|
|
349
357
|
*/
|
|
350
358
|
getTimeZone(): string | undefined;
|
|
351
359
|
|
|
360
|
+
/**
|
|
361
|
+
* Get product unit and repeat option label
|
|
362
|
+
* @param unit Product unit or repeat option
|
|
363
|
+
* @param isJoined Add the join label like 'per Kg' for Kg
|
|
364
|
+
*/
|
|
365
|
+
getUnitLabel(unit?: ProductUnit, isJoined?: boolean): string;
|
|
366
|
+
|
|
352
367
|
/**
|
|
353
368
|
* Hash message, SHA3 or HmacSHA512, 512 as Base64
|
|
354
369
|
* https://cryptojs.gitbook.io/docs/
|
|
@@ -1386,6 +1401,18 @@ export abstract class CoreApp<
|
|
|
1386
1401
|
});
|
|
1387
1402
|
}
|
|
1388
1403
|
|
|
1404
|
+
/**
|
|
1405
|
+
* Get entity status label
|
|
1406
|
+
* @param data Input data
|
|
1407
|
+
*/
|
|
1408
|
+
getEntityStatusLabel<D extends { entityStatus?: number }>(data: D) {
|
|
1409
|
+
if (data == null || data.entityStatus == null) return '';
|
|
1410
|
+
return BusinessUtils.getEntityStatusLabel(
|
|
1411
|
+
data.entityStatus,
|
|
1412
|
+
this.labelDelegate
|
|
1413
|
+
);
|
|
1414
|
+
}
|
|
1415
|
+
|
|
1389
1416
|
/**
|
|
1390
1417
|
* Get refresh token from response headers
|
|
1391
1418
|
* @param rawResponse Raw response from API call
|
|
@@ -1408,6 +1435,16 @@ export abstract class CoreApp<
|
|
|
1408
1435
|
return this.settings.timeZone ?? this.ipData?.timezone;
|
|
1409
1436
|
}
|
|
1410
1437
|
|
|
1438
|
+
/**
|
|
1439
|
+
* Get product unit and repeat option label
|
|
1440
|
+
* @param unit Product unit or repeat option
|
|
1441
|
+
* @param isJoined Add the join label like 'per Kg' for Kg
|
|
1442
|
+
*/
|
|
1443
|
+
getUnitLabel(unit?: ProductUnit, isJoined?: boolean): string {
|
|
1444
|
+
if (unit == null) return '';
|
|
1445
|
+
return BusinessUtils.getUnitLabel(unit, this.labelDelegate, isJoined);
|
|
1446
|
+
}
|
|
1447
|
+
|
|
1411
1448
|
/**
|
|
1412
1449
|
* Hash message, SHA3 or HmacSHA512, 512 as Base64
|
|
1413
1450
|
* https://cryptojs.gitbook.io/docs/
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DataTypes } from '@etsoo/shared';
|
|
2
|
+
import { RepeatOption } from '..';
|
|
2
3
|
import { IdLabelDto } from '../dto/IdLabelDto';
|
|
3
4
|
import { ICultureGet } from '../state/Culture';
|
|
4
5
|
import { EntityStatus } from './EntityStatus';
|
|
@@ -27,7 +28,7 @@ export namespace BusinessUtils {
|
|
|
27
28
|
|
|
28
29
|
/**
|
|
29
30
|
* Get product unit's label
|
|
30
|
-
* Please define the label in culture with key '
|
|
31
|
+
* Please define the label in culture with key 'statusNormal' for Normal status
|
|
31
32
|
* @param unit Unit
|
|
32
33
|
* @param func Label delegate
|
|
33
34
|
* @returns Label
|
|
@@ -62,11 +63,21 @@ export namespace BusinessUtils {
|
|
|
62
63
|
* Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
|
|
63
64
|
* @param unit Unit
|
|
64
65
|
* @param func Label delegate
|
|
66
|
+
* @param isJoined Add the join label like 'per Kg' for Kg
|
|
65
67
|
* @returns Label
|
|
66
68
|
*/
|
|
67
|
-
export function getUnitLabel(
|
|
69
|
+
export function getUnitLabel(
|
|
70
|
+
unit: ProductUnit,
|
|
71
|
+
func: ICultureGet,
|
|
72
|
+
isJoined?: boolean
|
|
73
|
+
) {
|
|
68
74
|
const key = ProductUnit[unit];
|
|
69
|
-
|
|
75
|
+
const label = func('unit' + key) ?? key;
|
|
76
|
+
if (isJoined) {
|
|
77
|
+
const jLabel = func('unitJoin');
|
|
78
|
+
if (jLabel) return jLabel.format(label);
|
|
79
|
+
}
|
|
80
|
+
return label;
|
|
70
81
|
}
|
|
71
82
|
|
|
72
83
|
/**
|
|
@@ -74,13 +85,61 @@ export namespace BusinessUtils {
|
|
|
74
85
|
* @param func Label delegate
|
|
75
86
|
* @returns Units
|
|
76
87
|
*/
|
|
77
|
-
export function getUnits(func: ICultureGet): IdLabelDto[]
|
|
78
|
-
|
|
79
|
-
|
|
88
|
+
export function getUnits(func: ICultureGet): IdLabelDto[];
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
*
|
|
92
|
+
* Get all product units
|
|
93
|
+
* @param func Label delegate
|
|
94
|
+
* @param options Define the order and limit the items
|
|
95
|
+
* @param isJoined Add the join label like 'per Kg' for Kg
|
|
96
|
+
* @returns Units
|
|
97
|
+
*/
|
|
98
|
+
export function getUnits(
|
|
99
|
+
func: ICultureGet,
|
|
100
|
+
options?: string[],
|
|
101
|
+
isJoined?: boolean
|
|
102
|
+
): IdLabelDto[];
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
*
|
|
106
|
+
* Get all product units
|
|
107
|
+
* @param func Label delegate
|
|
108
|
+
* @param options Define the order and limit the items
|
|
109
|
+
* @param isJoined Add the join label like 'per Kg' for Kg
|
|
110
|
+
* @returns Units
|
|
111
|
+
*/
|
|
112
|
+
export function getUnits(
|
|
113
|
+
func: ICultureGet,
|
|
114
|
+
options?: string[],
|
|
115
|
+
isJoined?: boolean
|
|
116
|
+
): IdLabelDto[] {
|
|
117
|
+
options ??= DataTypes.getEnumKeys(ProductUnit);
|
|
118
|
+
return options.map((key) => {
|
|
119
|
+
const id = DataTypes.getEnumByKey(ProductUnit, key)! as number;
|
|
80
120
|
return {
|
|
81
121
|
id,
|
|
82
|
-
label: getUnitLabel(id, func)
|
|
122
|
+
label: getUnitLabel(id, func, isJoined).formatInitial(true)
|
|
83
123
|
};
|
|
84
124
|
});
|
|
85
125
|
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
*
|
|
129
|
+
* Get all repeat options
|
|
130
|
+
* @param func Label delegate
|
|
131
|
+
* @param options Define the order and limit the items
|
|
132
|
+
* @param isJoined Add the join label like 'per Kg' for Kg
|
|
133
|
+
* @returns Units
|
|
134
|
+
*/
|
|
135
|
+
export function getRepeatOptions(
|
|
136
|
+
func: ICultureGet,
|
|
137
|
+
options?: string[],
|
|
138
|
+
isJoined: boolean = true
|
|
139
|
+
): IdLabelDto[] {
|
|
140
|
+
options ??= DataTypes.getEnumKeys(RepeatOption);
|
|
141
|
+
isJoined ??= true;
|
|
142
|
+
|
|
143
|
+
return getUnits(func, options, isJoined);
|
|
144
|
+
}
|
|
86
145
|
}
|
|
@@ -1,77 +1,61 @@
|
|
|
1
|
+
import { RepeatOption } from './RepeatOption';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
* Product units
|
|
3
|
-
*
|
|
4
|
+
* Product base units
|
|
5
|
+
* 1 - 9
|
|
4
6
|
*/
|
|
5
|
-
export enum
|
|
7
|
+
export enum ProductBaseUnit {
|
|
6
8
|
/**
|
|
7
9
|
* Picese
|
|
8
10
|
* 件
|
|
9
11
|
*/
|
|
10
|
-
PC =
|
|
12
|
+
PC = 1,
|
|
11
13
|
|
|
12
14
|
/**
|
|
13
15
|
* Set
|
|
14
16
|
* 套
|
|
15
17
|
*/
|
|
16
|
-
SET =
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Year
|
|
20
|
-
* 年
|
|
21
|
-
*/
|
|
22
|
-
YEAR = 10,
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Quater
|
|
26
|
-
* 季
|
|
27
|
-
*/
|
|
28
|
-
QUATER = 11,
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Month
|
|
32
|
-
* 月
|
|
33
|
-
*/
|
|
34
|
-
MONTH = 12,
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Fortnight
|
|
38
|
-
* 两周
|
|
39
|
-
*/
|
|
40
|
-
FORNIGHT = 13,
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Week
|
|
44
|
-
* 周
|
|
45
|
-
*/
|
|
46
|
-
WEEK = 14,
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Day
|
|
50
|
-
* 天
|
|
51
|
-
*/
|
|
52
|
-
DAY = 15,
|
|
18
|
+
SET = 2
|
|
19
|
+
}
|
|
53
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Product weight units
|
|
23
|
+
* Range 40 - 49
|
|
24
|
+
*/
|
|
25
|
+
export enum ProductWeightUnit {
|
|
54
26
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
27
|
+
* Gram
|
|
28
|
+
* 克
|
|
57
29
|
*/
|
|
58
|
-
|
|
30
|
+
GRAM = 40,
|
|
59
31
|
|
|
60
32
|
/**
|
|
61
|
-
*
|
|
62
|
-
*
|
|
33
|
+
* Half Kg
|
|
34
|
+
* 斤
|
|
63
35
|
*/
|
|
64
|
-
|
|
36
|
+
JIN = 41,
|
|
65
37
|
|
|
66
38
|
/**
|
|
67
39
|
* Kilogram
|
|
68
40
|
* 千克
|
|
69
41
|
*/
|
|
70
|
-
KILOGRAM =
|
|
42
|
+
KILOGRAM = 42,
|
|
71
43
|
|
|
72
44
|
/**
|
|
73
|
-
*
|
|
74
|
-
*
|
|
45
|
+
* Ton
|
|
46
|
+
* 吨
|
|
75
47
|
*/
|
|
76
|
-
|
|
48
|
+
TON = 49
|
|
77
49
|
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Product units enum
|
|
53
|
+
* Repeat options take range 10 - 39
|
|
54
|
+
* See com.etsoo.CoreFramework.Business.ProductUnit
|
|
55
|
+
*/
|
|
56
|
+
export const ProductUnit = {
|
|
57
|
+
...ProductBaseUnit,
|
|
58
|
+
...RepeatOption,
|
|
59
|
+
...ProductWeightUnit
|
|
60
|
+
};
|
|
61
|
+
export type ProductUnit = ProductBaseUnit | RepeatOption | ProductWeightUnit;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repeat options
|
|
3
|
+
* Part of ProductUnit, range 10 - 39
|
|
4
|
+
*/
|
|
5
|
+
export enum RepeatOption {
|
|
6
|
+
/**
|
|
7
|
+
* Hour
|
|
8
|
+
* 小时
|
|
9
|
+
*/
|
|
10
|
+
HOUR = 10,
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Day
|
|
14
|
+
* 天
|
|
15
|
+
*/
|
|
16
|
+
DAY = 11,
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Year
|
|
20
|
+
* 年
|
|
21
|
+
*/
|
|
22
|
+
YEAR = 12,
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Week
|
|
26
|
+
* 周
|
|
27
|
+
*/
|
|
28
|
+
WEEK = 21,
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Two weeks
|
|
32
|
+
* 两周
|
|
33
|
+
*/
|
|
34
|
+
FORTNIGHT = 22,
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Four weeks
|
|
38
|
+
* 四周
|
|
39
|
+
*/
|
|
40
|
+
FOURWEEK = 24,
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Month
|
|
44
|
+
* 月
|
|
45
|
+
*/
|
|
46
|
+
MONTH = 31,
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Two months
|
|
50
|
+
* 两月
|
|
51
|
+
*/
|
|
52
|
+
BIMONTH = 32,
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Quater(3 months)
|
|
56
|
+
* 季(三个月)
|
|
57
|
+
*/
|
|
58
|
+
QUATER = 33,
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Half a year
|
|
62
|
+
* 半年
|
|
63
|
+
*/
|
|
64
|
+
HALFYEAR = 36
|
|
65
|
+
}
|