@etsoo/appscript 1.3.89 → 1.3.91

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.
@@ -177,6 +177,7 @@
177
177
  "statusAudited": "Audited",
178
178
  "statusCompleted": "Completed",
179
179
  "statusDeleted": "Deleted",
180
+ "statusDoing": "Doing",
180
181
  "statusFlaged": "Flaged",
181
182
  "statusNormal": "Normla",
182
183
  "statusInactivated": "Inactivated",
@@ -177,6 +177,7 @@
177
177
  "statusAudited": "已审核",
178
178
  "statusCompleted": "已完成",
179
179
  "statusDeleted": "已删除",
180
+ "statusDoing": "处理中",
180
181
  "statusFlaged": "已标记",
181
182
  "statusNormal": "正常",
182
183
  "statusInactivated": "已停用",
@@ -177,6 +177,7 @@
177
177
  "statusAudited": "已審核",
178
178
  "statusCompleted": "已完成",
179
179
  "statusDeleted": "已刪除",
180
+ "statusDoing": "處理中",
180
181
  "statusFlaged": "已標記",
181
182
  "statusNormal": "正常",
182
183
  "statusInactivated": "已停用",
@@ -22,6 +22,7 @@ export * from './business/DataPrivacy';
22
22
  export * from './business/EntityStatus';
23
23
  export * from './business/ProductUnit';
24
24
  export * from './business/RepeatOption';
25
+ export * from './business/ShoppingCart';
25
26
  export * from './def/ListItem';
26
27
  export * from './erp/dto/AuditLineDto';
27
28
  export * from './erp/dto/CurrencyDto';
package/lib/cjs/index.js CHANGED
@@ -43,6 +43,7 @@ __exportStar(require("./business/DataPrivacy"), exports);
43
43
  __exportStar(require("./business/EntityStatus"), exports);
44
44
  __exportStar(require("./business/ProductUnit"), exports);
45
45
  __exportStar(require("./business/RepeatOption"), exports);
46
+ __exportStar(require("./business/ShoppingCart"), exports);
46
47
  // def
47
48
  __exportStar(require("./def/ListItem"), exports);
48
49
  // erp dto
@@ -2,6 +2,7 @@ import { INotifier, NotificationAlign, NotificationCallProps, NotificationConten
2
2
  import { ApiDataError, IApi, IPData } from '@etsoo/restclient';
3
3
  import { DataTypes, DateUtils, IStorage, ListType, ListType1 } from '@etsoo/shared';
4
4
  import { AddressRegion } from '../address/AddressRegion';
5
+ import { EntityStatus } from '../business/EntityStatus';
5
6
  import { InitCallDto } from '../erp/dto/InitCallDto';
6
7
  import { IActionResult } from '../result/IActionResult';
7
8
  import { InitCallResult, InitCallResultData } from '../result/InitCallResult';
@@ -402,9 +403,10 @@ export declare abstract class CoreApp<U extends IUser, S extends IAppSettings, N
402
403
  getRoles(role: number): ListType[];
403
404
  /**
404
405
  * Get status list
406
+ * @param ids Limited ids
405
407
  * @returns list
406
408
  */
407
- getStatusList(): ListType[];
409
+ getStatusList(ids?: EntityStatus[]): ListType[];
408
410
  /**
409
411
  * Get status label
410
412
  * @param status Status value
@@ -975,10 +975,13 @@ export class CoreApp {
975
975
  }
976
976
  /**
977
977
  * Get status list
978
+ * @param ids Limited ids
978
979
  * @returns list
979
980
  */
980
- getStatusList() {
981
- return this.getEnumList(EntityStatus, 'status');
981
+ getStatusList(ids = []) {
982
+ return this.getEnumList(EntityStatus, 'status', ids.length > 0
983
+ ? (id, _key) => (ids.includes(id) ? id : undefined)
984
+ : undefined);
982
985
  }
983
986
  /**
984
987
  * Get status label
@@ -6,6 +6,7 @@ import { IActionResult } from '../result/IActionResult';
6
6
  import { IUser } from '../state/User';
7
7
  import { IAppSettings } from './AppSettings';
8
8
  import { UserRole } from './UserRole';
9
+ import { EntityStatus } from '../business/EntityStatus';
9
10
  /**
10
11
  * Detect IP callback interface
11
12
  */
@@ -343,9 +344,10 @@ export interface IApp {
343
344
  getStatusLabel(status: number | null | undefined): string;
344
345
  /**
345
346
  * Get status list
347
+ * @param ids Limited ids
346
348
  * @returns list
347
349
  */
348
- getStatusList(): ListType[];
350
+ getStatusList(ids?: EntityStatus[]): ListType[];
349
351
  /**
350
352
  * Get refresh token from response headers
351
353
  * @param rawResponse Raw response from API call
@@ -16,10 +16,14 @@ export declare enum EntityStatus {
16
16
  * Approved
17
17
  */
18
18
  Approved = 100,
19
+ /**
20
+ * Doing
21
+ */
22
+ Doing = 110,
19
23
  /**
20
24
  * Audited
21
25
  */
22
- Audited = 111,
26
+ Audited = 120,
23
27
  /**
24
28
  * Inactivated
25
29
  */
@@ -17,10 +17,14 @@ export var EntityStatus;
17
17
  * Approved
18
18
  */
19
19
  EntityStatus[EntityStatus["Approved"] = 100] = "Approved";
20
+ /**
21
+ * Doing
22
+ */
23
+ EntityStatus[EntityStatus["Doing"] = 110] = "Doing";
20
24
  /**
21
25
  * Audited
22
26
  */
23
- EntityStatus[EntityStatus["Audited"] = 111] = "Audited";
27
+ EntityStatus[EntityStatus["Audited"] = 120] = "Audited";
24
28
  /**
25
29
  * Inactivated
26
30
  */
@@ -0,0 +1,285 @@
1
+ import { DataTypes, IStorage } from '@etsoo/shared';
2
+ /**
3
+ * Shopping cart owner
4
+ * 购物篮所有人
5
+ */
6
+ export type ShoppingCartOwner = DataTypes.IdNameItem & {
7
+ isSupplier?: boolean;
8
+ };
9
+ /**
10
+ * Shopping cart data
11
+ * 购物篮数据
12
+ */
13
+ export type ShoppingCartData<T extends ShoppingCartItem> = {
14
+ currency: string;
15
+ owner: ShoppingCartOwner;
16
+ items: T[];
17
+ promotions: ShoppingPromotion[];
18
+ formData?: any;
19
+ };
20
+ /**
21
+ * Shopping promotion
22
+ * 购物促销
23
+ */
24
+ export type ShoppingPromotion = {
25
+ /**
26
+ * Promotion id
27
+ * 促销编号
28
+ */
29
+ id: number;
30
+ /**
31
+ * Promotion title
32
+ * 促销标题
33
+ */
34
+ title: string;
35
+ /**
36
+ * Discount amount
37
+ * 折扣金额
38
+ */
39
+ amount: number;
40
+ };
41
+ /**
42
+ * Shopping cart base item
43
+ * 购物篮基础项目
44
+ */
45
+ export type ShoppingCartItemBase = {
46
+ /**
47
+ * Product id
48
+ * 产品编号
49
+ */
50
+ id: DataTypes.IdType;
51
+ /**
52
+ * Product title, default is name
53
+ * 产品标题,默认为name
54
+ */
55
+ title?: string;
56
+ /**
57
+ * Sale price
58
+ * 销售价格
59
+ */
60
+ price: number;
61
+ /**
62
+ * Qty
63
+ * 数量
64
+ */
65
+ qty: number;
66
+ /**
67
+ * Product level promotions
68
+ * 产品层次促销
69
+ */
70
+ promotions: ShoppingPromotion[];
71
+ };
72
+ /**
73
+ * Shopping cart item
74
+ * 购物篮项目
75
+ */
76
+ export type ShoppingCartItem = ShoppingCartItemBase & {
77
+ /**
78
+ * Product name
79
+ * 产品名称
80
+ */
81
+ name: string;
82
+ /**
83
+ * Current price for cache
84
+ * 当前缓存价格
85
+ */
86
+ currentPrice?: number;
87
+ /**
88
+ * Subtotal
89
+ * 小计
90
+ */
91
+ subtotal: number;
92
+ /**
93
+ * Total discount amount
94
+ * 总折扣金额
95
+ */
96
+ discount: number;
97
+ };
98
+ /**
99
+ * Shopping cart change reason
100
+ * 购物篮改变原因
101
+ */
102
+ export type ShoppingCartChangeReason = 'add' | 'clear' | 'remove' | 'title' | 'update';
103
+ /**
104
+ * Shopping cart
105
+ * 购物篮
106
+ */
107
+ export declare class ShoppingCart<T extends ShoppingCartItem> {
108
+ private readonly storage;
109
+ /**
110
+ * Create identifier key
111
+ * 创建识别键
112
+ * @param currency Currency
113
+ * @returns Result
114
+ */
115
+ static createKey(currency: string): string;
116
+ /**
117
+ * Clear shopping cart
118
+ * 清除购物篮
119
+ * @param identifier Identifier
120
+ * @param storage Storage
121
+ */
122
+ static clear(identifier: string, storage: IStorage): void;
123
+ /**
124
+ * Clear shopping cart
125
+ * 清除购物篮
126
+ * @param currency Currency
127
+ * @param storage Storage
128
+ */
129
+ static clearWith(currency: string, storage?: IStorage): void;
130
+ /**
131
+ * Owner data
132
+ * 所有者信息
133
+ */
134
+ owner?: ShoppingCartOwner;
135
+ /**
136
+ * ISO currency id
137
+ * 标准货币编号
138
+ */
139
+ readonly currency: string;
140
+ /**
141
+ * Items
142
+ * 项目
143
+ */
144
+ readonly items: T[];
145
+ /**
146
+ * Order level promotions
147
+ * 订单层面促销
148
+ */
149
+ readonly promotions: ShoppingPromotion[];
150
+ /**
151
+ * Related form data
152
+ * 关联的表单数据
153
+ */
154
+ formData: any;
155
+ /**
156
+ * Currency symbol
157
+ * 币种符号
158
+ */
159
+ readonly symbol: string | undefined;
160
+ /**
161
+ * Cart identifier
162
+ * 购物篮标识
163
+ */
164
+ private readonly identifier;
165
+ /**
166
+ * Lines count
167
+ * 项目数量
168
+ */
169
+ get lines(): number;
170
+ /**
171
+ * Total qty
172
+ * 总数量
173
+ */
174
+ get totalQty(): number;
175
+ /**
176
+ * Total amount
177
+ * 总金额
178
+ */
179
+ get totalAmount(): number;
180
+ /**
181
+ * Total amount string
182
+ * 总金额字符串
183
+ */
184
+ get totalAmountStr(): string;
185
+ /**
186
+ * Cached prices
187
+ * 缓存的价格
188
+ */
189
+ private readonly prices;
190
+ /**
191
+ * Onchange callback
192
+ * 改变时回调
193
+ */
194
+ onChange?: (reason: ShoppingCartChangeReason, changedItems: T[]) => void;
195
+ /**
196
+ * Constructor
197
+ * 构造函数
198
+ * @param currency Currency ISO code
199
+ * @param storage Data storage
200
+ */
201
+ constructor(currency: string, storage?: IStorage);
202
+ /**
203
+ * Constructor
204
+ * 构造函数
205
+ * @param state Initialization state
206
+ * @param storage Data storage
207
+ */
208
+ constructor(state: ShoppingCartData<T>, storage?: IStorage);
209
+ private doChange;
210
+ /**
211
+ * Add item
212
+ * 添加项目
213
+ * @param item New item
214
+ */
215
+ addItem(item: T): void;
216
+ /**
217
+ * Add items
218
+ * @param items New items
219
+ */
220
+ addItems(items: T[]): void;
221
+ /**
222
+ * Cache price
223
+ * @param id Item id
224
+ * @param price Price
225
+ */
226
+ cachePrice(id: T['id'], price: number): void;
227
+ /**
228
+ * Clear storage
229
+ * @param keepOwner Keep owner data
230
+ */
231
+ clear(keepOwner?: boolean): void;
232
+ /**
233
+ * Format amount
234
+ * @param amount Amount
235
+ * @returns Result
236
+ */
237
+ formatAmount(amount: number): string;
238
+ /**
239
+ * Get item
240
+ * @param id Item id
241
+ * @returns Result
242
+ */
243
+ getItem(id: T['id']): T | undefined;
244
+ /**
245
+ * Reset
246
+ * @param item Shopping cart item
247
+ */
248
+ reset(item: ShoppingCartItem): void;
249
+ /**
250
+ * Save cart data
251
+ * @param persisted For persisted storage
252
+ */
253
+ save(persisted?: boolean): ShoppingCartData<T> | undefined;
254
+ /**
255
+ * Trigger update
256
+ * 触发更新
257
+ */
258
+ update(): void;
259
+ /**
260
+ * Update discount
261
+ * @param item Shopping cart item
262
+ */
263
+ updateDiscount(item: ShoppingCartItem): void;
264
+ /**
265
+ * Update item
266
+ * 更新项目
267
+ * @param id Product id
268
+ * @param qty Qty
269
+ * @param itemCreator New item creator
270
+ * @returns Updated or not
271
+ */
272
+ updateItem(id: T['id'], qty: number | undefined, itemCreator?: () => Omit<T, 'id' | 'price' | 'qty' | 'subtotal' | 'discount' | 'promotions'>): boolean;
273
+ /**
274
+ * Update price
275
+ * @param id Item id
276
+ * @param price New price
277
+ */
278
+ updatePrice(id: T['id'], price: number): void;
279
+ /**
280
+ * Update title
281
+ * @param id Item id
282
+ * @param title New title
283
+ */
284
+ updateTitle(id: T['id'], title: string): void;
285
+ }