ts-glitter 19.4.1 → 19.4.3

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 CHANGED
@@ -141,7 +141,7 @@ export class Entry {
141
141
  }
142
142
  window.renderClock = (_b = window.renderClock) !== null && _b !== void 0 ? _b : createClock();
143
143
  console.log(`Entry-time:`, window.renderClock.stop());
144
- glitter.share.editerVersion = 'V_19.4.1';
144
+ glitter.share.editerVersion = 'V_19.4.3';
145
145
  glitter.share.start = new Date();
146
146
  const vm = { appConfig: [] };
147
147
  window.saasConfig = {
package/lowcode/Entry.ts CHANGED
@@ -140,7 +140,7 @@ export class Entry {
140
140
  }
141
141
  (window as any).renderClock = (window as any).renderClock ?? createClock();
142
142
  console.log(`Entry-time:`, (window as any).renderClock.stop());
143
- glitter.share.editerVersion = 'V_19.4.1';
143
+ glitter.share.editerVersion = 'V_19.4.3';
144
144
  glitter.share.start = new Date();
145
145
  const vm = { appConfig: [] };
146
146
  (window as any).saasConfig = {
@@ -409,59 +409,53 @@ export class DeliveryHTML {
409
409
  .join('');
410
410
  }
411
411
  static pickHTML(vm, glitter, dataArray) {
412
- const section = (data) => {
413
- const orderData = data.orderData;
414
- return html `
415
- <div class="page">
416
- <div class="header">
417
- <h1 class="subtitle">商店名稱:${vm.store.shop_name}</h1>
418
- <h1 class="title">${vm.info.title}</h1>
419
- <h1 class="subtitle">${vm.info.subtitle}時間:${glitter.ut.dateFormat(new Date(), 'yyyy-MM-dd hh:mm')}</h1>
420
- </div>
421
- <div class="items">
422
- <table>
423
- <thead>
424
- <tr>
425
- <th class="text-left">項次</th>
426
- <th class="text-left">商品名稱</th>
427
- <th class="text-right">貨號</th>
428
- <th class="text-right">數量</th>
429
- </tr>
430
- </thead>
431
- <tbody>
432
- ${orderData.lineItems
433
- .map((item, index) => {
434
- var _a;
412
+ const formulaLineItems = () => {
413
+ const mergedItems = dataArray
414
+ .flatMap(data => data.orderData.lineItems)
415
+ .reduce((acc, item) => {
416
+ const key = `${item.id}-${item.spec.join('/')}`;
417
+ if (!acc[key]) {
418
+ acc[key] = Object.assign(Object.assign({}, item), { count: 0 });
419
+ }
420
+ acc[key].count += item.count;
421
+ return acc;
422
+ }, {});
423
+ const resultHtml = Object.values(mergedItems).map((item, index) => {
435
424
  return html `
436
- <tr>
437
- <td class="text-left">${index + 1}</td>
438
- <td class="text-left">
439
- ${item.title} ${item.spec.length > 0 ? `(${item.spec.join('/')})` : ''}
440
- </td>
441
- <td class="text-right">${(_a = item.sku) !== null && _a !== void 0 ? _a : ''}</td>
442
- <td class="text-right">${item.count}</td>
443
- </tr>
444
- `;
445
- })
446
- .join('')}
447
- </tbody>
448
- </table>
449
- </div>
450
- </div>
451
- `;
425
+ <tr>
426
+ <td class="text-left">${index + 1}</td>
427
+ <td class="text-left">${item.title} ${item.spec.length > 0 ? `(${item.spec.join('/')})` : ''}</td>
428
+ <td class="text-right">${item.sku || '-'}</td>
429
+ <td class="text-right">${item.count}</td>
430
+ </tr>
431
+ `;
432
+ });
433
+ return resultHtml;
452
434
  };
453
- return dataArray
454
- .map(data => {
455
- try {
456
- return section(data);
457
- }
458
- catch (e) {
459
- const text = `訂單 #${data.cart_token} 列印揀貨發生錯誤`;
460
- console.error(`${text}: ${e}`);
461
- return text;
462
- }
463
- })
464
- .join('');
435
+ return html `
436
+ <div class="page">
437
+ <div class="header">
438
+ <h1 class="subtitle">商店名稱:${vm.store.shop_name}</h1>
439
+ <h1 class="title">${vm.info.title}</h1>
440
+ <h1 class="subtitle">${vm.info.subtitle}時間:${glitter.ut.dateFormat(new Date(), 'yyyy-MM-dd hh:mm')}</h1>
441
+ </div>
442
+ <div class="items">
443
+ <table>
444
+ <thead>
445
+ <tr>
446
+ <th class="text-left">項次</th>
447
+ <th class="text-left">商品名稱</th>
448
+ <th class="text-right">貨號</th>
449
+ <th class="text-right">數量</th>
450
+ </tr>
451
+ </thead>
452
+ <tbody>
453
+ ${formulaLineItems().join('')}
454
+ </tbody>
455
+ </table>
456
+ </div>
457
+ </div>
458
+ `;
465
459
  }
466
460
  static addressHTML(vm, dataArray) {
467
461
  const dataMap = dataArray.map(order => {
@@ -458,58 +458,59 @@ export class DeliveryHTML {
458
458
 
459
459
  // 揀貨單 HTML
460
460
  static pickHTML(vm: any, glitter: any, dataArray: CartData[]) {
461
- const section = (data: CartData) => {
462
- const orderData = data.orderData;
463
- return html`
464
- <div class="page">
465
- <div class="header">
466
- <h1 class="subtitle">商店名稱:${vm.store.shop_name}</h1>
467
- <h1 class="title">${vm.info.title}</h1>
468
- <h1 class="subtitle">${vm.info.subtitle}時間:${glitter.ut.dateFormat(new Date(), 'yyyy-MM-dd hh:mm')}</h1>
469
- </div>
470
- <div class="items">
471
- <table>
472
- <thead>
473
- <tr>
474
- <th class="text-left">項次</th>
475
- <th class="text-left">商品名稱</th>
476
- <th class="text-right">貨號</th>
477
- <th class="text-right">數量</th>
478
- </tr>
479
- </thead>
480
- <tbody>
481
- ${orderData.lineItems
482
- .map((item, index) => {
483
- return html`
484
- <tr>
485
- <td class="text-left">${index + 1}</td>
486
- <td class="text-left">
487
- ${item.title} ${item.spec.length > 0 ? `(${item.spec.join('/')})` : ''}
488
- </td>
489
- <td class="text-right">${item.sku ?? ''}</td>
490
- <td class="text-right">${item.count}</td>
491
- </tr>
492
- `;
493
- })
494
- .join('')}
495
- </tbody>
496
- </table>
497
- </div>
498
- </div>
499
- `;
461
+ const formulaLineItems = () => {
462
+ const mergedItems = dataArray
463
+ .flatMap(data => data.orderData.lineItems)
464
+ .reduce(
465
+ (acc, item) => {
466
+ const key = `${item.id}-${item.spec.join('/')}`; // 唯一識別鍵
467
+ if (!acc[key]) {
468
+ acc[key] = { ...item, count: 0 }; // 初始化 count
469
+ }
470
+ acc[key].count += item.count; // 數量累加
471
+ return acc;
472
+ },
473
+ {} as Record<string, any>
474
+ );
475
+
476
+ const resultHtml = Object.values(mergedItems).map((item, index) => {
477
+ return html`
478
+ <tr>
479
+ <td class="text-left">${index + 1}</td>
480
+ <td class="text-left">${item.title} ${item.spec.length > 0 ? `(${item.spec.join('/')})` : ''}</td>
481
+ <td class="text-right">${item.sku || '-'}</td>
482
+ <td class="text-right">${item.count}</td>
483
+ </tr>
484
+ `;
485
+ });
486
+
487
+ return resultHtml;
500
488
  };
501
489
 
502
- return dataArray
503
- .map(data => {
504
- try {
505
- return section(data);
506
- } catch (e) {
507
- const text = `訂單 #${data.cart_token} 列印揀貨發生錯誤`;
508
- console.error(`${text}: ${e}`);
509
- return text;
510
- }
511
- })
512
- .join('');
490
+ return html`
491
+ <div class="page">
492
+ <div class="header">
493
+ <h1 class="subtitle">商店名稱:${vm.store.shop_name}</h1>
494
+ <h1 class="title">${vm.info.title}</h1>
495
+ <h1 class="subtitle">${vm.info.subtitle}時間:${glitter.ut.dateFormat(new Date(), 'yyyy-MM-dd hh:mm')}</h1>
496
+ </div>
497
+ <div class="items">
498
+ <table>
499
+ <thead>
500
+ <tr>
501
+ <th class="text-left">項次</th>
502
+ <th class="text-left">商品名稱</th>
503
+ <th class="text-right">貨號</th>
504
+ <th class="text-right">數量</th>
505
+ </tr>
506
+ </thead>
507
+ <tbody>
508
+ ${formulaLineItems().join('')}
509
+ </tbody>
510
+ </table>
511
+ </div>
512
+ </div>
513
+ `;
513
514
  }
514
515
 
515
516
  // 地址貼條 HTML