@etsoo/appscript 1.0.89 → 1.0.93
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/lib/cjs/business/BusinessUtils.d.ts +29 -0
- package/lib/cjs/business/BusinessUtils.js +54 -0
- package/lib/cjs/business/ProductUnit.d.ts +18 -0
- package/lib/cjs/business/ProductUnit.js +70 -0
- package/lib/cjs/index.d.ts +2 -0
- package/lib/cjs/index.js +3 -0
- package/lib/mjs/business/BusinessUtils.d.ts +29 -0
- package/lib/mjs/business/BusinessUtils.js +51 -0
- package/lib/mjs/business/ProductUnit.d.ts +18 -0
- package/lib/mjs/business/ProductUnit.js +67 -0
- package/lib/mjs/index.d.ts +2 -0
- package/lib/mjs/index.js +3 -0
- package/package.json +3 -3
- package/src/business/BusinessUtils.ts +55 -0
- package/src/business/ProductUnit.ts +77 -0
- package/src/index.ts +4 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { IdLabelDto } from '../dto/IdLabelDto';
|
|
2
|
+
import { ICultureGet } from '../state/Culture';
|
|
3
|
+
import { ProductUnit } from './ProductUnit';
|
|
4
|
+
/**
|
|
5
|
+
* Business utils
|
|
6
|
+
*/
|
|
7
|
+
export declare namespace BusinessUtils {
|
|
8
|
+
/**
|
|
9
|
+
* Add blank item to id/label data array
|
|
10
|
+
* @param input Input array
|
|
11
|
+
* @param copy Copy or change the current inpu
|
|
12
|
+
* @returns Items with blank item
|
|
13
|
+
*/
|
|
14
|
+
function addIdLabelBlankItem(input: IdLabelDto[], copy?: boolean): IdLabelDto[];
|
|
15
|
+
/**
|
|
16
|
+
* Get product unit's label
|
|
17
|
+
* Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
|
|
18
|
+
* @param unit Unit
|
|
19
|
+
* @param func Label delegate
|
|
20
|
+
* @returns Label
|
|
21
|
+
*/
|
|
22
|
+
function getUnitLabel(unit: ProductUnit, func: ICultureGet): string;
|
|
23
|
+
/**
|
|
24
|
+
* Get all product units
|
|
25
|
+
* @param func Label delegate
|
|
26
|
+
* @returns Units
|
|
27
|
+
*/
|
|
28
|
+
function getUnits(func: ICultureGet): IdLabelDto[];
|
|
29
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BusinessUtils = void 0;
|
|
4
|
+
const shared_1 = require("@etsoo/shared");
|
|
5
|
+
const ProductUnit_1 = require("./ProductUnit");
|
|
6
|
+
/**
|
|
7
|
+
* Business utils
|
|
8
|
+
*/
|
|
9
|
+
var BusinessUtils;
|
|
10
|
+
(function (BusinessUtils) {
|
|
11
|
+
/**
|
|
12
|
+
* Add blank item to id/label data array
|
|
13
|
+
* @param input Input array
|
|
14
|
+
* @param copy Copy or change the current inpu
|
|
15
|
+
* @returns Items with blank item
|
|
16
|
+
*/
|
|
17
|
+
function addIdLabelBlankItem(input, copy = false) {
|
|
18
|
+
const blankItem = { id: '', label: '---' };
|
|
19
|
+
if (copy)
|
|
20
|
+
return [blankItem, ...input];
|
|
21
|
+
input.unshift(blankItem);
|
|
22
|
+
return input;
|
|
23
|
+
}
|
|
24
|
+
BusinessUtils.addIdLabelBlankItem = addIdLabelBlankItem;
|
|
25
|
+
// Get unit label by key
|
|
26
|
+
function getUnitLabelByKey(func, key) {
|
|
27
|
+
var _a;
|
|
28
|
+
return (_a = func('unit' + key)) !== null && _a !== void 0 ? _a : key;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get product unit's label
|
|
32
|
+
* Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
|
|
33
|
+
* @param unit Unit
|
|
34
|
+
* @param func Label delegate
|
|
35
|
+
* @returns Label
|
|
36
|
+
*/
|
|
37
|
+
function getUnitLabel(unit, func) {
|
|
38
|
+
const key = ProductUnit_1.ProductUnit[unit];
|
|
39
|
+
return getUnitLabelByKey(func, key);
|
|
40
|
+
}
|
|
41
|
+
BusinessUtils.getUnitLabel = getUnitLabel;
|
|
42
|
+
/**
|
|
43
|
+
* Get all product units
|
|
44
|
+
* @param func Label delegate
|
|
45
|
+
* @returns Units
|
|
46
|
+
*/
|
|
47
|
+
function getUnits(func) {
|
|
48
|
+
return shared_1.Utils.getEnumKeys(ProductUnit_1.ProductUnit).map((key) => ({
|
|
49
|
+
id: ProductUnit_1.ProductUnit[key],
|
|
50
|
+
label: getUnitLabelByKey(func, key)
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
BusinessUtils.getUnits = getUnits;
|
|
54
|
+
})(BusinessUtils = exports.BusinessUtils || (exports.BusinessUtils = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product units enum
|
|
3
|
+
* See com.etsoo.CoreFramework.Business.ProductUnit
|
|
4
|
+
*/
|
|
5
|
+
export declare enum ProductUnit {
|
|
6
|
+
PC = 0,
|
|
7
|
+
SET = 1,
|
|
8
|
+
YEAR = 10,
|
|
9
|
+
QUATER = 11,
|
|
10
|
+
MONTH = 12,
|
|
11
|
+
FORNIGHT = 13,
|
|
12
|
+
WEEK = 14,
|
|
13
|
+
DAY = 15,
|
|
14
|
+
HOUR = 16,
|
|
15
|
+
TON = 31,
|
|
16
|
+
KILOGRAM = 32,
|
|
17
|
+
GRAM = 33
|
|
18
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ProductUnit = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Product units enum
|
|
6
|
+
* See com.etsoo.CoreFramework.Business.ProductUnit
|
|
7
|
+
*/
|
|
8
|
+
var ProductUnit;
|
|
9
|
+
(function (ProductUnit) {
|
|
10
|
+
/// <summary>
|
|
11
|
+
/// Picese
|
|
12
|
+
/// 件
|
|
13
|
+
/// </summary>
|
|
14
|
+
ProductUnit[ProductUnit["PC"] = 0] = "PC";
|
|
15
|
+
/// <summary>
|
|
16
|
+
/// Set
|
|
17
|
+
/// 套
|
|
18
|
+
/// </summary>
|
|
19
|
+
ProductUnit[ProductUnit["SET"] = 1] = "SET";
|
|
20
|
+
/// <summary>
|
|
21
|
+
/// Year
|
|
22
|
+
/// 年
|
|
23
|
+
/// </summary>
|
|
24
|
+
ProductUnit[ProductUnit["YEAR"] = 10] = "YEAR";
|
|
25
|
+
/// <summary>
|
|
26
|
+
/// Quater
|
|
27
|
+
/// 季
|
|
28
|
+
/// </summary>
|
|
29
|
+
ProductUnit[ProductUnit["QUATER"] = 11] = "QUATER";
|
|
30
|
+
/// <summary>
|
|
31
|
+
/// Month
|
|
32
|
+
/// 月
|
|
33
|
+
/// </summary>
|
|
34
|
+
ProductUnit[ProductUnit["MONTH"] = 12] = "MONTH";
|
|
35
|
+
/// <summary>
|
|
36
|
+
/// Fortnight
|
|
37
|
+
/// 两周
|
|
38
|
+
/// </summary>
|
|
39
|
+
ProductUnit[ProductUnit["FORNIGHT"] = 13] = "FORNIGHT";
|
|
40
|
+
/// <summary>
|
|
41
|
+
/// Week
|
|
42
|
+
/// 周
|
|
43
|
+
/// </summary>
|
|
44
|
+
ProductUnit[ProductUnit["WEEK"] = 14] = "WEEK";
|
|
45
|
+
/// <summary>
|
|
46
|
+
/// Day
|
|
47
|
+
/// 天
|
|
48
|
+
/// </summary>
|
|
49
|
+
ProductUnit[ProductUnit["DAY"] = 15] = "DAY";
|
|
50
|
+
/// <summary>
|
|
51
|
+
/// Hour
|
|
52
|
+
/// 小时
|
|
53
|
+
/// </summary>
|
|
54
|
+
ProductUnit[ProductUnit["HOUR"] = 16] = "HOUR";
|
|
55
|
+
/// <summary>
|
|
56
|
+
/// Ton
|
|
57
|
+
/// 吨
|
|
58
|
+
/// </summary>
|
|
59
|
+
ProductUnit[ProductUnit["TON"] = 31] = "TON";
|
|
60
|
+
/// <summary>
|
|
61
|
+
/// Kilogram
|
|
62
|
+
/// 千克
|
|
63
|
+
/// </summary>
|
|
64
|
+
ProductUnit[ProductUnit["KILOGRAM"] = 32] = "KILOGRAM";
|
|
65
|
+
/// <summary>
|
|
66
|
+
/// Gram
|
|
67
|
+
/// 克
|
|
68
|
+
/// </summary>
|
|
69
|
+
ProductUnit[ProductUnit["GRAM"] = 33] = "GRAM";
|
|
70
|
+
})(ProductUnit = exports.ProductUnit || (exports.ProductUnit = {}));
|
package/lib/cjs/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export * from './app/ExternalSettings';
|
|
|
4
4
|
export * from './bridges/ElectronBridge';
|
|
5
5
|
export * from './bridges/IAppData';
|
|
6
6
|
export * from './bridges/IBridge';
|
|
7
|
+
export * from './business/BusinessUtils';
|
|
8
|
+
export * from './business/ProductUnit';
|
|
7
9
|
export * from './dto/IdLabelDto';
|
|
8
10
|
export * from './dto/UpdateDto';
|
|
9
11
|
export * from './result/ActionResult';
|
package/lib/cjs/index.js
CHANGED
|
@@ -18,6 +18,9 @@ __exportStar(require("./app/ExternalSettings"), exports);
|
|
|
18
18
|
__exportStar(require("./bridges/ElectronBridge"), exports);
|
|
19
19
|
__exportStar(require("./bridges/IAppData"), exports);
|
|
20
20
|
__exportStar(require("./bridges/IBridge"), exports);
|
|
21
|
+
// business
|
|
22
|
+
__exportStar(require("./business/BusinessUtils"), exports);
|
|
23
|
+
__exportStar(require("./business/ProductUnit"), exports);
|
|
21
24
|
// dto
|
|
22
25
|
__exportStar(require("./dto/IdLabelDto"), exports);
|
|
23
26
|
__exportStar(require("./dto/UpdateDto"), exports);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { IdLabelDto } from '../dto/IdLabelDto';
|
|
2
|
+
import { ICultureGet } from '../state/Culture';
|
|
3
|
+
import { ProductUnit } from './ProductUnit';
|
|
4
|
+
/**
|
|
5
|
+
* Business utils
|
|
6
|
+
*/
|
|
7
|
+
export declare namespace BusinessUtils {
|
|
8
|
+
/**
|
|
9
|
+
* Add blank item to id/label data array
|
|
10
|
+
* @param input Input array
|
|
11
|
+
* @param copy Copy or change the current inpu
|
|
12
|
+
* @returns Items with blank item
|
|
13
|
+
*/
|
|
14
|
+
function addIdLabelBlankItem(input: IdLabelDto[], copy?: boolean): IdLabelDto[];
|
|
15
|
+
/**
|
|
16
|
+
* Get product unit's label
|
|
17
|
+
* Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
|
|
18
|
+
* @param unit Unit
|
|
19
|
+
* @param func Label delegate
|
|
20
|
+
* @returns Label
|
|
21
|
+
*/
|
|
22
|
+
function getUnitLabel(unit: ProductUnit, func: ICultureGet): string;
|
|
23
|
+
/**
|
|
24
|
+
* Get all product units
|
|
25
|
+
* @param func Label delegate
|
|
26
|
+
* @returns Units
|
|
27
|
+
*/
|
|
28
|
+
function getUnits(func: ICultureGet): IdLabelDto[];
|
|
29
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Utils } from '@etsoo/shared';
|
|
2
|
+
import { ProductUnit } from './ProductUnit';
|
|
3
|
+
/**
|
|
4
|
+
* Business utils
|
|
5
|
+
*/
|
|
6
|
+
export var BusinessUtils;
|
|
7
|
+
(function (BusinessUtils) {
|
|
8
|
+
/**
|
|
9
|
+
* Add blank item to id/label data array
|
|
10
|
+
* @param input Input array
|
|
11
|
+
* @param copy Copy or change the current inpu
|
|
12
|
+
* @returns Items with blank item
|
|
13
|
+
*/
|
|
14
|
+
function addIdLabelBlankItem(input, copy = false) {
|
|
15
|
+
const blankItem = { id: '', label: '---' };
|
|
16
|
+
if (copy)
|
|
17
|
+
return [blankItem, ...input];
|
|
18
|
+
input.unshift(blankItem);
|
|
19
|
+
return input;
|
|
20
|
+
}
|
|
21
|
+
BusinessUtils.addIdLabelBlankItem = addIdLabelBlankItem;
|
|
22
|
+
// Get unit label by key
|
|
23
|
+
function getUnitLabelByKey(func, key) {
|
|
24
|
+
var _a;
|
|
25
|
+
return (_a = func('unit' + key)) !== null && _a !== void 0 ? _a : key;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Get product unit's label
|
|
29
|
+
* Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
|
|
30
|
+
* @param unit Unit
|
|
31
|
+
* @param func Label delegate
|
|
32
|
+
* @returns Label
|
|
33
|
+
*/
|
|
34
|
+
function getUnitLabel(unit, func) {
|
|
35
|
+
const key = ProductUnit[unit];
|
|
36
|
+
return getUnitLabelByKey(func, key);
|
|
37
|
+
}
|
|
38
|
+
BusinessUtils.getUnitLabel = getUnitLabel;
|
|
39
|
+
/**
|
|
40
|
+
* Get all product units
|
|
41
|
+
* @param func Label delegate
|
|
42
|
+
* @returns Units
|
|
43
|
+
*/
|
|
44
|
+
function getUnits(func) {
|
|
45
|
+
return Utils.getEnumKeys(ProductUnit).map((key) => ({
|
|
46
|
+
id: ProductUnit[key],
|
|
47
|
+
label: getUnitLabelByKey(func, key)
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
BusinessUtils.getUnits = getUnits;
|
|
51
|
+
})(BusinessUtils || (BusinessUtils = {}));
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product units enum
|
|
3
|
+
* See com.etsoo.CoreFramework.Business.ProductUnit
|
|
4
|
+
*/
|
|
5
|
+
export declare enum ProductUnit {
|
|
6
|
+
PC = 0,
|
|
7
|
+
SET = 1,
|
|
8
|
+
YEAR = 10,
|
|
9
|
+
QUATER = 11,
|
|
10
|
+
MONTH = 12,
|
|
11
|
+
FORNIGHT = 13,
|
|
12
|
+
WEEK = 14,
|
|
13
|
+
DAY = 15,
|
|
14
|
+
HOUR = 16,
|
|
15
|
+
TON = 31,
|
|
16
|
+
KILOGRAM = 32,
|
|
17
|
+
GRAM = 33
|
|
18
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product units enum
|
|
3
|
+
* See com.etsoo.CoreFramework.Business.ProductUnit
|
|
4
|
+
*/
|
|
5
|
+
export var ProductUnit;
|
|
6
|
+
(function (ProductUnit) {
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Picese
|
|
9
|
+
/// 件
|
|
10
|
+
/// </summary>
|
|
11
|
+
ProductUnit[ProductUnit["PC"] = 0] = "PC";
|
|
12
|
+
/// <summary>
|
|
13
|
+
/// Set
|
|
14
|
+
/// 套
|
|
15
|
+
/// </summary>
|
|
16
|
+
ProductUnit[ProductUnit["SET"] = 1] = "SET";
|
|
17
|
+
/// <summary>
|
|
18
|
+
/// Year
|
|
19
|
+
/// 年
|
|
20
|
+
/// </summary>
|
|
21
|
+
ProductUnit[ProductUnit["YEAR"] = 10] = "YEAR";
|
|
22
|
+
/// <summary>
|
|
23
|
+
/// Quater
|
|
24
|
+
/// 季
|
|
25
|
+
/// </summary>
|
|
26
|
+
ProductUnit[ProductUnit["QUATER"] = 11] = "QUATER";
|
|
27
|
+
/// <summary>
|
|
28
|
+
/// Month
|
|
29
|
+
/// 月
|
|
30
|
+
/// </summary>
|
|
31
|
+
ProductUnit[ProductUnit["MONTH"] = 12] = "MONTH";
|
|
32
|
+
/// <summary>
|
|
33
|
+
/// Fortnight
|
|
34
|
+
/// 两周
|
|
35
|
+
/// </summary>
|
|
36
|
+
ProductUnit[ProductUnit["FORNIGHT"] = 13] = "FORNIGHT";
|
|
37
|
+
/// <summary>
|
|
38
|
+
/// Week
|
|
39
|
+
/// 周
|
|
40
|
+
/// </summary>
|
|
41
|
+
ProductUnit[ProductUnit["WEEK"] = 14] = "WEEK";
|
|
42
|
+
/// <summary>
|
|
43
|
+
/// Day
|
|
44
|
+
/// 天
|
|
45
|
+
/// </summary>
|
|
46
|
+
ProductUnit[ProductUnit["DAY"] = 15] = "DAY";
|
|
47
|
+
/// <summary>
|
|
48
|
+
/// Hour
|
|
49
|
+
/// 小时
|
|
50
|
+
/// </summary>
|
|
51
|
+
ProductUnit[ProductUnit["HOUR"] = 16] = "HOUR";
|
|
52
|
+
/// <summary>
|
|
53
|
+
/// Ton
|
|
54
|
+
/// 吨
|
|
55
|
+
/// </summary>
|
|
56
|
+
ProductUnit[ProductUnit["TON"] = 31] = "TON";
|
|
57
|
+
/// <summary>
|
|
58
|
+
/// Kilogram
|
|
59
|
+
/// 千克
|
|
60
|
+
/// </summary>
|
|
61
|
+
ProductUnit[ProductUnit["KILOGRAM"] = 32] = "KILOGRAM";
|
|
62
|
+
/// <summary>
|
|
63
|
+
/// Gram
|
|
64
|
+
/// 克
|
|
65
|
+
/// </summary>
|
|
66
|
+
ProductUnit[ProductUnit["GRAM"] = 33] = "GRAM";
|
|
67
|
+
})(ProductUnit || (ProductUnit = {}));
|
package/lib/mjs/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export * from './app/ExternalSettings';
|
|
|
4
4
|
export * from './bridges/ElectronBridge';
|
|
5
5
|
export * from './bridges/IAppData';
|
|
6
6
|
export * from './bridges/IBridge';
|
|
7
|
+
export * from './business/BusinessUtils';
|
|
8
|
+
export * from './business/ProductUnit';
|
|
7
9
|
export * from './dto/IdLabelDto';
|
|
8
10
|
export * from './dto/UpdateDto';
|
|
9
11
|
export * from './result/ActionResult';
|
package/lib/mjs/index.js
CHANGED
|
@@ -6,6 +6,9 @@ export * from './app/ExternalSettings';
|
|
|
6
6
|
export * from './bridges/ElectronBridge';
|
|
7
7
|
export * from './bridges/IAppData';
|
|
8
8
|
export * from './bridges/IBridge';
|
|
9
|
+
// business
|
|
10
|
+
export * from './business/BusinessUtils';
|
|
11
|
+
export * from './business/ProductUnit';
|
|
9
12
|
// dto
|
|
10
13
|
export * from './dto/IdLabelDto';
|
|
11
14
|
export * from './dto/UpdateDto';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@etsoo/appscript",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.93",
|
|
4
4
|
"description": "Applications shared TypeScript framework",
|
|
5
5
|
"main": "lib/cjs/index.js",
|
|
6
6
|
"module": "lib/mjs/index.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@etsoo/notificationbase": "^1.0.78",
|
|
51
51
|
"@etsoo/restclient": "^1.0.51",
|
|
52
|
-
"@etsoo/shared": "^1.0.
|
|
52
|
+
"@etsoo/shared": "^1.0.42"
|
|
53
53
|
},
|
|
54
54
|
"devDependencies": {
|
|
55
55
|
"@babel/cli": "^7.15.7",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"eslint": "^7.32.0",
|
|
64
64
|
"eslint-config-airbnb-base": "^14.2.1",
|
|
65
65
|
"eslint-plugin-import": "^2.24.2",
|
|
66
|
-
"jest": "^27.2.
|
|
66
|
+
"jest": "^27.2.4",
|
|
67
67
|
"ts-jest": "^27.0.5",
|
|
68
68
|
"typescript": "^4.4.3"
|
|
69
69
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Utils } from '@etsoo/shared';
|
|
2
|
+
import { IdLabelDto } from '../dto/IdLabelDto';
|
|
3
|
+
import { ICultureGet } from '../state/Culture';
|
|
4
|
+
import { ProductUnit } from './ProductUnit';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Business utils
|
|
8
|
+
*/
|
|
9
|
+
export namespace BusinessUtils {
|
|
10
|
+
/**
|
|
11
|
+
* Add blank item to id/label data array
|
|
12
|
+
* @param input Input array
|
|
13
|
+
* @param copy Copy or change the current inpu
|
|
14
|
+
* @returns Items with blank item
|
|
15
|
+
*/
|
|
16
|
+
export function addIdLabelBlankItem(
|
|
17
|
+
input: IdLabelDto[],
|
|
18
|
+
copy: boolean = false
|
|
19
|
+
) {
|
|
20
|
+
const blankItem: IdLabelDto = { id: '', label: '---' };
|
|
21
|
+
if (copy) return [blankItem, ...input];
|
|
22
|
+
|
|
23
|
+
input.unshift(blankItem);
|
|
24
|
+
return input;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Get unit label by key
|
|
28
|
+
function getUnitLabelByKey(func: ICultureGet, key: string) {
|
|
29
|
+
return func('unit' + key) ?? key;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Get product unit's label
|
|
34
|
+
* Please define the label in culture with key 'unitPC' for ProductUnit.PC like that
|
|
35
|
+
* @param unit Unit
|
|
36
|
+
* @param func Label delegate
|
|
37
|
+
* @returns Label
|
|
38
|
+
*/
|
|
39
|
+
export function getUnitLabel(unit: ProductUnit, func: ICultureGet) {
|
|
40
|
+
const key = ProductUnit[unit];
|
|
41
|
+
return getUnitLabelByKey(func, key);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Get all product units
|
|
46
|
+
* @param func Label delegate
|
|
47
|
+
* @returns Units
|
|
48
|
+
*/
|
|
49
|
+
export function getUnits(func: ICultureGet): IdLabelDto[] {
|
|
50
|
+
return Utils.getEnumKeys(ProductUnit).map((key) => ({
|
|
51
|
+
id: ProductUnit[key as keyof typeof ProductUnit],
|
|
52
|
+
label: getUnitLabelByKey(func, key)
|
|
53
|
+
}));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Product units enum
|
|
3
|
+
* See com.etsoo.CoreFramework.Business.ProductUnit
|
|
4
|
+
*/
|
|
5
|
+
export enum ProductUnit {
|
|
6
|
+
/// <summary>
|
|
7
|
+
/// Picese
|
|
8
|
+
/// 件
|
|
9
|
+
/// </summary>
|
|
10
|
+
PC = 0,
|
|
11
|
+
|
|
12
|
+
/// <summary>
|
|
13
|
+
/// Set
|
|
14
|
+
/// 套
|
|
15
|
+
/// </summary>
|
|
16
|
+
SET = 1,
|
|
17
|
+
|
|
18
|
+
/// <summary>
|
|
19
|
+
/// Year
|
|
20
|
+
/// 年
|
|
21
|
+
/// </summary>
|
|
22
|
+
YEAR = 10,
|
|
23
|
+
|
|
24
|
+
/// <summary>
|
|
25
|
+
/// Quater
|
|
26
|
+
/// 季
|
|
27
|
+
/// </summary>
|
|
28
|
+
QUATER = 11,
|
|
29
|
+
|
|
30
|
+
/// <summary>
|
|
31
|
+
/// Month
|
|
32
|
+
/// 月
|
|
33
|
+
/// </summary>
|
|
34
|
+
MONTH = 12,
|
|
35
|
+
|
|
36
|
+
/// <summary>
|
|
37
|
+
/// Fortnight
|
|
38
|
+
/// 两周
|
|
39
|
+
/// </summary>
|
|
40
|
+
FORNIGHT = 13,
|
|
41
|
+
|
|
42
|
+
/// <summary>
|
|
43
|
+
/// Week
|
|
44
|
+
/// 周
|
|
45
|
+
/// </summary>
|
|
46
|
+
WEEK = 14,
|
|
47
|
+
|
|
48
|
+
/// <summary>
|
|
49
|
+
/// Day
|
|
50
|
+
/// 天
|
|
51
|
+
/// </summary>
|
|
52
|
+
DAY = 15,
|
|
53
|
+
|
|
54
|
+
/// <summary>
|
|
55
|
+
/// Hour
|
|
56
|
+
/// 小时
|
|
57
|
+
/// </summary>
|
|
58
|
+
HOUR = 16,
|
|
59
|
+
|
|
60
|
+
/// <summary>
|
|
61
|
+
/// Ton
|
|
62
|
+
/// 吨
|
|
63
|
+
/// </summary>
|
|
64
|
+
TON = 31,
|
|
65
|
+
|
|
66
|
+
/// <summary>
|
|
67
|
+
/// Kilogram
|
|
68
|
+
/// 千克
|
|
69
|
+
/// </summary>
|
|
70
|
+
KILOGRAM = 32,
|
|
71
|
+
|
|
72
|
+
/// <summary>
|
|
73
|
+
/// Gram
|
|
74
|
+
/// 克
|
|
75
|
+
/// </summary>
|
|
76
|
+
GRAM = 33
|
|
77
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -8,6 +8,10 @@ export * from './bridges/ElectronBridge';
|
|
|
8
8
|
export * from './bridges/IAppData';
|
|
9
9
|
export * from './bridges/IBridge';
|
|
10
10
|
|
|
11
|
+
// business
|
|
12
|
+
export * from './business/BusinessUtils';
|
|
13
|
+
export * from './business/ProductUnit';
|
|
14
|
+
|
|
11
15
|
// dto
|
|
12
16
|
export * from './dto/IdLabelDto';
|
|
13
17
|
export * from './dto/UpdateDto';
|