ts-glitter 19.1.0 → 19.1.2
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/lowcode/Entry.js +1 -1
- package/lowcode/Entry.ts +1 -1
- package/lowcode/cms-plugin/module/order-setting.js +49 -33
- package/lowcode/cms-plugin/module/order-setting.ts +55 -37
- package/package.json +1 -1
- package/src/api-public/services/product-initial.js.map +1 -1
- package/src/api-public/services/product-initial.ts +1 -1
- package/src/api-public/services/shopping.js +9 -12
- package/src/api-public/services/shopping.js.map +1 -1
- package/src/api-public/services/shopping.ts +20 -28
- package/src/api-public/services/updated-table-checked.js.map +1 -1
- package/src/api-public/services/updated-table-checked.ts +0 -1
package/lowcode/Entry.js
CHANGED
|
@@ -132,7 +132,7 @@ export class Entry {
|
|
|
132
132
|
}
|
|
133
133
|
window.renderClock = (_b = window.renderClock) !== null && _b !== void 0 ? _b : createClock();
|
|
134
134
|
console.log(`Entry-time:`, window.renderClock.stop());
|
|
135
|
-
glitter.share.editerVersion = 'V_19.1.
|
|
135
|
+
glitter.share.editerVersion = 'V_19.1.2';
|
|
136
136
|
glitter.share.start = new Date();
|
|
137
137
|
const vm = { appConfig: [] };
|
|
138
138
|
window.saasConfig = {
|
package/lowcode/Entry.ts
CHANGED
|
@@ -132,7 +132,7 @@ export class Entry {
|
|
|
132
132
|
}
|
|
133
133
|
(window as any).renderClock = (window as any).renderClock ?? createClock();
|
|
134
134
|
console.log(`Entry-time:`, (window as any).renderClock.stop());
|
|
135
|
-
glitter.share.editerVersion = 'V_19.1.
|
|
135
|
+
glitter.share.editerVersion = 'V_19.1.2';
|
|
136
136
|
glitter.share.start = new Date();
|
|
137
137
|
const vm = { appConfig: [] };
|
|
138
138
|
(window as any).saasConfig = {
|
|
@@ -230,20 +230,22 @@ export class OrderSetting {
|
|
|
230
230
|
return gvc.bindView({
|
|
231
231
|
bind: id,
|
|
232
232
|
view: () => {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
233
|
+
console.log(`postMD==>`, postMD);
|
|
234
|
+
try {
|
|
235
|
+
return postMD
|
|
236
|
+
.map((item) => {
|
|
237
|
+
if (!item.deduction_log || Object.keys(item.deduction_log).length === 0) {
|
|
238
|
+
return ``;
|
|
239
|
+
}
|
|
240
|
+
return html `
|
|
241
|
+
<div class="d-inline-flex align-items-center" style="gap:44px;">
|
|
240
242
|
<div
|
|
241
243
|
class="d-flex align-items-center flex-shrink-0"
|
|
242
244
|
style="width: ${titleLength}px;gap: 12px"
|
|
243
245
|
>
|
|
244
246
|
<img style="height: 54px;width: 54px;border-radius: 5px;" src="${item.preview_image}" />
|
|
245
247
|
<div class="d-flex flex-column" style="font-size: 16px;">
|
|
246
|
-
<div>${item.title}</div>
|
|
248
|
+
<div style="max-width: calc(${titleLength} - 100px);white-space: normal;word-break: break-all;">${item.title}</div>
|
|
247
249
|
<div style="color: #8D8D8D;font-size: 14px;">
|
|
248
250
|
${item.spec.length == 0 ? `單一規格` : item.spec.join(`,`)}
|
|
249
251
|
</div>
|
|
@@ -257,17 +259,20 @@ export class OrderSetting {
|
|
|
257
259
|
${item.count}
|
|
258
260
|
</div>
|
|
259
261
|
${stockList
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
262
|
+
.flatMap((stock) => {
|
|
263
|
+
var _a, _b, _c, _d, _e;
|
|
264
|
+
if (!item.deduction_log) {
|
|
265
|
+
return ``;
|
|
266
|
+
}
|
|
267
|
+
const limit = (_c = (_b = (_a = item.stockList) === null || _a === void 0 ? void 0 : _a[stock.id]) === null || _b === void 0 ? void 0 : _b.count) !== null && _c !== void 0 ? _c : 0;
|
|
268
|
+
return [
|
|
269
|
+
html ` <div
|
|
265
270
|
class="d-flex align-items-center justify-content-end flex-shrink-0"
|
|
266
271
|
style="width: ${elementLength}px;gap: 12px;"
|
|
267
272
|
>
|
|
268
273
|
${parseInt(limit)}
|
|
269
274
|
</div>`,
|
|
270
|
-
|
|
275
|
+
html ` <div
|
|
271
276
|
class="d-flex align-items-center justify-content-end flex-shrink-0"
|
|
272
277
|
style="width: ${elementLength}px;gap: 12px"
|
|
273
278
|
>
|
|
@@ -279,30 +284,38 @@ export class OrderSetting {
|
|
|
279
284
|
value="${(_e = item.deduction_log[stock.id]) !== null && _e !== void 0 ? _e : 0}"
|
|
280
285
|
type="number"
|
|
281
286
|
onchange="${gvc.event((e) => {
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
287
|
+
var _a;
|
|
288
|
+
const originalDeduction = (_a = item.deduction_log[stock.id]) !== null && _a !== void 0 ? _a : 0;
|
|
289
|
+
item.deduction_log[stock.id] = 0;
|
|
290
|
+
const totalDeducted = Object.values(item.deduction_log).reduce((total, deduction) => total + deduction, 0);
|
|
291
|
+
const remainingStock = item.count - totalDeducted;
|
|
292
|
+
const newDeduction = Math.min(parseInt(e.value), remainingStock);
|
|
293
|
+
item.deduction_log[stock.id] = newDeduction;
|
|
294
|
+
if (originalDeduction !== newDeduction) {
|
|
295
|
+
const stockDiff = newDeduction - originalDeduction;
|
|
296
|
+
item.stockList[stock.id].count -= stockDiff;
|
|
297
|
+
}
|
|
298
|
+
gvc.notifyDataChange(id);
|
|
299
|
+
})}"
|
|
295
300
|
/>
|
|
296
301
|
</div>`,
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
302
|
+
];
|
|
303
|
+
})
|
|
304
|
+
.join('')}
|
|
300
305
|
</div>
|
|
301
306
|
`;
|
|
302
|
-
|
|
303
|
-
|
|
307
|
+
}).filter((item) => {
|
|
308
|
+
return item;
|
|
309
|
+
}).map((dd, index) => {
|
|
310
|
+
return `<div class="${index ? `border-top pt-2` : ` pb-2`}">${dd}</div>`;
|
|
311
|
+
})
|
|
312
|
+
.join(``);
|
|
313
|
+
}
|
|
314
|
+
catch (e) {
|
|
315
|
+
console.log(e);
|
|
316
|
+
}
|
|
304
317
|
},
|
|
305
|
-
divCreate: { class: 'd-flex flex-column', style: 'margin-bottom:80px;gap:12px;' },
|
|
318
|
+
divCreate: { class: 'd-inline-flex flex-column ', style: 'margin-bottom:80px;gap:12px;' },
|
|
306
319
|
});
|
|
307
320
|
})()}
|
|
308
321
|
</div>
|
|
@@ -318,6 +331,9 @@ export class OrderSetting {
|
|
|
318
331
|
var _a;
|
|
319
332
|
const errorProducts = [];
|
|
320
333
|
const hasError = postMD.some((product) => {
|
|
334
|
+
if (!product.deduction_log) {
|
|
335
|
+
return false;
|
|
336
|
+
}
|
|
321
337
|
const totalDeduction = Object.values(product.deduction_log).reduce((sum, value) => sum + value, 0);
|
|
322
338
|
if (Object.keys(product.deduction_log).length && totalDeduction !== product.count) {
|
|
323
339
|
errorProducts.push(`${product.title} - ${product.spec.join(',')}`);
|
|
@@ -153,6 +153,7 @@ export class OrderSetting {
|
|
|
153
153
|
return gvc.bindView({
|
|
154
154
|
bind: 'editDialog',
|
|
155
155
|
view: () => {
|
|
156
|
+
|
|
156
157
|
const titleLength = 250;
|
|
157
158
|
const elementLength = 100;
|
|
158
159
|
if (loading && productLoading) {
|
|
@@ -275,20 +276,22 @@ export class OrderSetting {
|
|
|
275
276
|
return gvc.bindView({
|
|
276
277
|
bind: id,
|
|
277
278
|
view: () => {
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
279
|
+
console.log(`postMD==>`,postMD)
|
|
280
|
+
try {
|
|
281
|
+
return postMD
|
|
282
|
+
.map((item: any) => {
|
|
283
|
+
if (!item.deduction_log || Object.keys(item.deduction_log).length === 0) {
|
|
284
|
+
return ``;
|
|
285
|
+
}
|
|
286
|
+
return html`
|
|
287
|
+
<div class="d-inline-flex align-items-center" style="gap:44px;">
|
|
285
288
|
<div
|
|
286
289
|
class="d-flex align-items-center flex-shrink-0"
|
|
287
290
|
style="width: ${titleLength}px;gap: 12px"
|
|
288
291
|
>
|
|
289
292
|
<img style="height: 54px;width: 54px;border-radius: 5px;" src="${item.preview_image}" />
|
|
290
293
|
<div class="d-flex flex-column" style="font-size: 16px;">
|
|
291
|
-
<div>${item.title}</div>
|
|
294
|
+
<div style="max-width: calc(${titleLength} - 100px);white-space: normal;word-break: break-all;">${item.title}</div>
|
|
292
295
|
<div style="color: #8D8D8D;font-size: 14px;">
|
|
293
296
|
${item.spec.length == 0 ? `單一規格` : item.spec.join(`,`)}
|
|
294
297
|
</div>
|
|
@@ -302,16 +305,20 @@ export class OrderSetting {
|
|
|
302
305
|
${item.count}
|
|
303
306
|
</div>
|
|
304
307
|
${stockList
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
return
|
|
308
|
-
|
|
308
|
+
.flatMap((stock: any) => {
|
|
309
|
+
if(!item.deduction_log){
|
|
310
|
+
return ``
|
|
311
|
+
}
|
|
312
|
+
const limit = item.stockList?.[stock.id]?.count ?? 0;
|
|
313
|
+
|
|
314
|
+
return [
|
|
315
|
+
html` <div
|
|
309
316
|
class="d-flex align-items-center justify-content-end flex-shrink-0"
|
|
310
317
|
style="width: ${elementLength}px;gap: 12px;"
|
|
311
318
|
>
|
|
312
319
|
${parseInt(limit)}
|
|
313
320
|
</div>`,
|
|
314
|
-
|
|
321
|
+
html` <div
|
|
315
322
|
class="d-flex align-items-center justify-content-end flex-shrink-0"
|
|
316
323
|
style="width: ${elementLength}px;gap: 12px"
|
|
317
324
|
>
|
|
@@ -323,40 +330,48 @@ export class OrderSetting {
|
|
|
323
330
|
value="${item.deduction_log[stock.id] ?? 0}"
|
|
324
331
|
type="number"
|
|
325
332
|
onchange="${gvc.event((e: any) => {
|
|
326
|
-
|
|
327
|
-
|
|
333
|
+
const originalDeduction = item.deduction_log[stock.id] ?? 0;
|
|
334
|
+
item.deduction_log[stock.id] = 0;
|
|
328
335
|
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
336
|
+
/// 明確指定 item.deduction_log 的型別為 Record<string, number>
|
|
337
|
+
const totalDeducted = Object.values(
|
|
338
|
+
item.deduction_log as Record<string, number>
|
|
339
|
+
).reduce((total, deduction) => total + deduction, 0);
|
|
340
|
+
const remainingStock = item.count - totalDeducted;
|
|
334
341
|
|
|
335
|
-
|
|
336
|
-
|
|
342
|
+
// 限制輸入值不超過剩餘庫存
|
|
343
|
+
const newDeduction = Math.min(parseInt(e.value), remainingStock);
|
|
337
344
|
|
|
338
|
-
|
|
339
|
-
|
|
345
|
+
// 更新扣除紀錄
|
|
346
|
+
item.deduction_log[stock.id] = newDeduction;
|
|
340
347
|
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
348
|
+
// 如果有變更,更新庫存數量
|
|
349
|
+
if (originalDeduction !== newDeduction) {
|
|
350
|
+
const stockDiff = newDeduction - originalDeduction;
|
|
351
|
+
item.stockList[stock.id]!.count -= stockDiff;
|
|
352
|
+
}
|
|
346
353
|
|
|
347
|
-
|
|
348
|
-
|
|
354
|
+
gvc.notifyDataChange(id);
|
|
355
|
+
})}"
|
|
349
356
|
/>
|
|
350
357
|
</div>`,
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
358
|
+
];
|
|
359
|
+
})
|
|
360
|
+
.join('')}
|
|
354
361
|
</div>
|
|
355
362
|
`;
|
|
356
|
-
|
|
357
|
-
|
|
363
|
+
}).filter((item:string) => {
|
|
364
|
+
return item
|
|
365
|
+
}).map((dd:any,index:number)=>{
|
|
366
|
+
return `<div class="${index ? `border-top pt-2`:` pb-2`}">${dd}</div>`
|
|
367
|
+
})
|
|
368
|
+
.join(``);
|
|
369
|
+
}catch (e) {
|
|
370
|
+
console.log(e)
|
|
371
|
+
}
|
|
372
|
+
|
|
358
373
|
},
|
|
359
|
-
divCreate: { class: 'd-flex flex-column', style: 'margin-bottom:80px;gap:12px;' },
|
|
374
|
+
divCreate: { class: 'd-inline-flex flex-column ', style: 'margin-bottom:80px;gap:12px;' },
|
|
360
375
|
});
|
|
361
376
|
})()}
|
|
362
377
|
</div>
|
|
@@ -374,6 +389,9 @@ export class OrderSetting {
|
|
|
374
389
|
gvc.event(() => {
|
|
375
390
|
const errorProducts: string[] = [];
|
|
376
391
|
const hasError = postMD.some((product: any) => {
|
|
392
|
+
if(!product.deduction_log){
|
|
393
|
+
return false
|
|
394
|
+
}
|
|
377
395
|
const totalDeduction = Object.values(product.deduction_log as Record<string, number>).reduce(
|
|
378
396
|
(sum, value) => sum + value,
|
|
379
397
|
0
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-initial.js","sourceRoot":"","sources":["product-initial.ts"],"names":[],"mappings":";;;AAAA,MAAa,cAAc;IAClB,MAAM,CAAC,OAAO,CAAC,OAAW;;QAE/B,OAAO,CAAC,aAAa,GAAI,MAAA,OAAO,CAAC,aAAa,mCAAI,EAAE,CAAC;QACrD,CAAC,OAAO,EAAC,OAAO,EAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAC,EAAE;YAClC,IAAG,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,EAAC,CAAC;gBAC7B,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,GAAG;oBAC1B,KAAK,EAAE,OAAO,CAAC,GAAG;oBAClB,OAAO,EAAC,OAAO,CAAC,KAAK;oBACrB,SAAS,EAAE,OAAO,CAAC,OAAO;oBAC1B,WAAW,EAAE,OAAO,CAAC,SAAS;oBAC9B,cAAc,EAAE,OAAO,CAAC,YAAY;oBACpC,eAAe,EAAE,OAAO,CAAC,aAAa;oBACtC,eAAe,EAAE,OAAO,CAAC,aAAa;iBACvC,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"product-initial.js","sourceRoot":"","sources":["product-initial.ts"],"names":[],"mappings":";;;AAAA,MAAa,cAAc;IAClB,MAAM,CAAC,OAAO,CAAC,OAAW;;QAE/B,OAAO,CAAC,aAAa,GAAI,MAAA,OAAO,CAAC,aAAa,mCAAI,EAAE,CAAC;QACrD,CAAC,OAAO,EAAC,OAAO,EAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,EAAC,EAAE;YAClC,IAAG,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,EAAC,CAAC;gBAC7B,OAAO,CAAC,aAAa,CAAC,EAAE,CAAC,GAAG;oBAC1B,KAAK,EAAE,OAAO,CAAC,GAAG;oBAClB,OAAO,EAAC,OAAO,CAAC,KAAK;oBACrB,SAAS,EAAE,OAAO,CAAC,OAAO;oBAC1B,WAAW,EAAE,OAAO,CAAC,SAAS;oBAC9B,cAAc,EAAE,OAAO,CAAC,YAAY;oBACpC,eAAe,EAAE,OAAO,CAAC,aAAa;oBACtC,eAAe,EAAE,OAAO,CAAC,aAAa;iBACvC,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAlBD,wCAkBC"}
|
|
@@ -1328,18 +1328,17 @@ class Shopping {
|
|
|
1328
1328
|
}
|
|
1329
1329
|
data.line_items = await Promise.all(data.line_items.map(async (item) => {
|
|
1330
1330
|
var _a, _b, _c, _d, _e;
|
|
1331
|
-
const
|
|
1331
|
+
const getProductData = (await this.getProduct({
|
|
1332
1332
|
page: 0,
|
|
1333
1333
|
limit: 1,
|
|
1334
|
-
id: item.id
|
|
1334
|
+
id: `${item.id}`,
|
|
1335
1335
|
status: 'inRange',
|
|
1336
1336
|
channel: checkOutType === 'POS' ? (data.isExhibition ? 'exhibition' : 'pos') : undefined,
|
|
1337
1337
|
whereStore: checkOutType === 'POS' ? data.pos_store : undefined,
|
|
1338
1338
|
setUserID: `${(userData === null || userData === void 0 ? void 0 : userData.userID) || ''}`,
|
|
1339
1339
|
})).data;
|
|
1340
|
-
console.log(`data.line_items`,
|
|
1341
|
-
if (
|
|
1342
|
-
const getProductData = getProductArray[0];
|
|
1340
|
+
console.log(`data.line_items`, getProductData);
|
|
1341
|
+
if (getProductData) {
|
|
1343
1342
|
const content = getProductData.content;
|
|
1344
1343
|
const variant = getVariant(content, item);
|
|
1345
1344
|
console.log(`variant=>`, variant);
|
|
@@ -1641,15 +1640,14 @@ class Shopping {
|
|
|
1641
1640
|
if (!((_1 = giveawayData.add_on_products) === null || _1 === void 0 ? void 0 : _1.length))
|
|
1642
1641
|
continue;
|
|
1643
1642
|
const productPromises = giveawayData.add_on_products.map(async (id) => {
|
|
1644
|
-
|
|
1645
|
-
const getGiveawayData = ((_a = (await this.getProduct({
|
|
1643
|
+
const getGiveawayData = (await this.getProduct({
|
|
1646
1644
|
page: 0,
|
|
1647
1645
|
limit: 1,
|
|
1648
1646
|
id: `${id}`,
|
|
1649
1647
|
status: 'inRange',
|
|
1650
1648
|
channel: checkOutType === 'POS' ? (data.isExhibition ? 'exhibition' : 'pos') : undefined,
|
|
1651
1649
|
whereStore: checkOutType === 'POS' ? data.pos_store : undefined,
|
|
1652
|
-
})).data
|
|
1650
|
+
})).data.content;
|
|
1653
1651
|
getGiveawayData.voucher_id = giveawayData.id;
|
|
1654
1652
|
return getGiveawayData;
|
|
1655
1653
|
});
|
|
@@ -2696,12 +2694,12 @@ class Shopping {
|
|
|
2696
2694
|
if (newItem.product_category === 'kitchen' && ((_a = newItem.spec) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
2697
2695
|
return new Shopping(this.app, this.token).calcVariantsStock(newItem.count, '', newItem.id, newItem.spec);
|
|
2698
2696
|
}
|
|
2699
|
-
|
|
2697
|
+
for (const [location, newCount] of Object.entries(newItem.deduction_log)) {
|
|
2700
2698
|
const originalCount = originalItem.deduction_log[location] || 0;
|
|
2701
2699
|
const parsedNewCount = Number(newCount || 0);
|
|
2702
2700
|
const delta = (isNaN(parsedNewCount) ? 0 : parsedNewCount) - originalCount;
|
|
2703
|
-
|
|
2704
|
-
}
|
|
2701
|
+
await new Shopping(this.app, this.token).calcVariantsStock(delta * -1, location, newItem.id, newItem.spec);
|
|
2702
|
+
}
|
|
2705
2703
|
});
|
|
2706
2704
|
await Promise.all(stockAdjustments);
|
|
2707
2705
|
}
|
|
@@ -3400,7 +3398,6 @@ class Shopping {
|
|
|
3400
3398
|
limit: 1,
|
|
3401
3399
|
is_manger: true
|
|
3402
3400
|
})).data.content;
|
|
3403
|
-
console.log(`pd_data_${product_id}`, pd_data);
|
|
3404
3401
|
const variant_s = pd_data.variants.find((dd) => {
|
|
3405
3402
|
return dd.spec.join('-') === spec.join('-');
|
|
3406
3403
|
});
|