ts-glitter 20.6.7 → 20.6.9

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.
Files changed (160) hide show
  1. package/lowcode/Entry.js +2 -2
  2. package/lowcode/Entry.ts +2 -2
  3. package/lowcode/backend-manager/bg-blog.js +617 -621
  4. package/lowcode/backend-manager/bg-blog.ts +2323 -2325
  5. package/lowcode/backend-manager/bg-line.js +5 -4
  6. package/lowcode/backend-manager/bg-line.ts +5 -4
  7. package/lowcode/backend-manager/bg-list-component.js +9 -0
  8. package/lowcode/backend-manager/bg-list-component.ts +15 -1
  9. package/lowcode/backend-manager/bg-notify.js +6 -4
  10. package/lowcode/backend-manager/bg-notify.ts +6 -4
  11. package/lowcode/backend-manager/bg-product.js +145 -0
  12. package/lowcode/backend-manager/bg-product.ts +153 -0
  13. package/lowcode/backend-manager/bg-sns.js +5 -3
  14. package/lowcode/backend-manager/bg-sns.ts +5 -3
  15. package/lowcode/backend-manager/bg-widget.js +92 -4
  16. package/lowcode/backend-manager/bg-widget.ts +122 -6
  17. package/lowcode/backend-manager/splitPage.js +0 -39
  18. package/lowcode/backend-manager/splitPage.ts +0 -40
  19. package/lowcode/cms-plugin/auto-fcm-advertise.js +17 -5
  20. package/lowcode/cms-plugin/auto-fcm-advertise.ts +19 -6
  21. package/lowcode/cms-plugin/auto-fcm-history.js +2732 -0
  22. package/lowcode/cms-plugin/auto-fcm-history.ts +2995 -0
  23. package/lowcode/cms-plugin/cms-router.js +5 -0
  24. package/lowcode/cms-plugin/cms-router.ts +6 -0
  25. package/lowcode/cms-plugin/filter-options.js +80 -27
  26. package/lowcode/cms-plugin/filter-options.ts +83 -27
  27. package/lowcode/cms-plugin/language-backend.js +50 -39
  28. package/lowcode/cms-plugin/language-backend.ts +109 -95
  29. package/lowcode/cms-plugin/menus-setting.js +175 -151
  30. package/lowcode/cms-plugin/menus-setting.ts +620 -591
  31. package/lowcode/cms-plugin/model/order.d.ts +1 -0
  32. package/lowcode/cms-plugin/module/data.js +7 -7
  33. package/lowcode/cms-plugin/module/data.ts +262 -233
  34. package/lowcode/cms-plugin/module/delivery-html.js +18 -10
  35. package/lowcode/cms-plugin/module/delivery-html.ts +26 -10
  36. package/lowcode/cms-plugin/module/order-setting.js +458 -328
  37. package/lowcode/cms-plugin/module/order-setting.ts +622 -351
  38. package/lowcode/cms-plugin/module/product-excel.js +1 -1
  39. package/lowcode/cms-plugin/module/product-excel.ts +2 -1
  40. package/lowcode/cms-plugin/order/order-module.js +90 -1
  41. package/lowcode/cms-plugin/order/order-module.ts +106 -1
  42. package/lowcode/cms-plugin/pos-pages/payment-page.js +11 -8
  43. package/lowcode/cms-plugin/pos-pages/payment-page.ts +28 -15
  44. package/lowcode/cms-plugin/pos-pages/products-page.js +0 -39
  45. package/lowcode/cms-plugin/pos-pages/products-page.ts +0 -40
  46. package/lowcode/cms-plugin/shopping-collections.ts +1 -3
  47. package/lowcode/cms-plugin/shopping-finance-setting.js +19 -80
  48. package/lowcode/cms-plugin/shopping-finance-setting.ts +19 -87
  49. package/lowcode/cms-plugin/shopping-order-manager.js +122 -38
  50. package/lowcode/cms-plugin/shopping-order-manager.ts +160 -58
  51. package/lowcode/cms-plugin/shopping-product-setting.js +364 -376
  52. package/lowcode/cms-plugin/shopping-product-setting.ts +406 -415
  53. package/lowcode/cms-plugin/shopping-setting-advance.js +57 -16
  54. package/lowcode/cms-plugin/shopping-setting-advance.ts +69 -18
  55. package/lowcode/cms-plugin/user/user-module.js +2 -43
  56. package/lowcode/cms-plugin/user/user-module.ts +2 -46
  57. package/lowcode/cms-plugin/user-list.js +4 -6
  58. package/lowcode/cms-plugin/user-list.ts +35 -38
  59. package/lowcode/css/editor.css +42 -3
  60. package/lowcode/glitter-base/global/language.js +6 -1
  61. package/lowcode/glitter-base/global/language.ts +10 -4
  62. package/lowcode/glitter-base/global/payment-config.js +19 -16
  63. package/lowcode/glitter-base/global/payment-config.ts +22 -16
  64. package/lowcode/glitter-base/global/shipment-config.js +6 -5
  65. package/lowcode/glitter-base/global/shipment-config.ts +12 -10
  66. package/lowcode/glitter-base/route/fcm.js +21 -1
  67. package/lowcode/glitter-base/route/fcm.ts +22 -2
  68. package/lowcode/glitter-base/route/shopping.js +8 -32
  69. package/lowcode/glitter-base/route/shopping.ts +10 -33
  70. package/lowcode/glitter-base/route/user.js +11 -2
  71. package/lowcode/glitter-base/route/user.ts +23 -12
  72. package/lowcode/jspage/function-page/setting_editor.js +9 -0
  73. package/lowcode/jspage/function-page/setting_editor.ts +9 -0
  74. package/lowcode/public-components/blogs/list.js +223 -195
  75. package/lowcode/public-components/blogs/list.ts +383 -352
  76. package/lowcode/public-components/product/product-list.js +8 -4
  77. package/lowcode/public-components/product/product-list.ts +9 -4
  78. package/lowcode/public-components/terms-related/index.js +1 -1
  79. package/lowcode/public-components/terms-related/index.ts +1 -1
  80. package/lowcode/public-components/user-manager/um-login.js +1 -1
  81. package/lowcode/public-components/user-manager/um-login.ts +2 -2
  82. package/lowcode/public-components/user-manager/um-order.js +41 -5
  83. package/lowcode/public-components/user-manager/um-order.ts +58 -20
  84. package/lowcode/public-components/user-manager/um-voucher.ts +2 -2
  85. package/nhi4veq3gk.json +1 -0
  86. package/package.json +1 -1
  87. package/src/Language.d.ts +2 -0
  88. package/src/Language.js +66 -65
  89. package/src/Language.js.map +1 -1
  90. package/src/Language.ts +719 -715
  91. package/src/api-public/config/shipment-config.js +3 -2
  92. package/src/api-public/config/shipment-config.js.map +1 -1
  93. package/src/api-public/config/shipment-config.ts +3 -2
  94. package/src/api-public/controllers/ai-chat.js.map +1 -1
  95. package/src/api-public/controllers/ai-chat.ts +1 -2
  96. package/src/api-public/controllers/fcm.js +23 -58
  97. package/src/api-public/controllers/fcm.js.map +1 -1
  98. package/src/api-public/controllers/fcm.ts +28 -56
  99. package/src/api-public/controllers/shop.js +7 -1
  100. package/src/api-public/controllers/shop.js.map +1 -1
  101. package/src/api-public/controllers/shop.ts +17 -10
  102. package/src/api-public/controllers/user.js +1 -0
  103. package/src/api-public/controllers/user.js.map +1 -1
  104. package/src/api-public/controllers/user.ts +2 -0
  105. package/src/api-public/services/auto-send-email.js +247 -187
  106. package/src/api-public/services/auto-send-email.js.map +1 -1
  107. package/src/api-public/services/auto-send-email.ts +568 -505
  108. package/src/api-public/services/delivery.js +1 -1
  109. package/src/api-public/services/delivery.js.map +1 -1
  110. package/src/api-public/services/delivery.ts +6 -5
  111. package/src/api-public/services/financial-service.js +1 -2
  112. package/src/api-public/services/financial-service.js.map +1 -1
  113. package/src/api-public/services/financial-service.ts +4 -6
  114. package/src/api-public/services/manager.d.ts +4 -3
  115. package/src/api-public/services/manager.js +8 -12
  116. package/src/api-public/services/manager.js.map +1 -1
  117. package/src/api-public/services/manager.ts +57 -59
  118. package/src/api-public/services/model/handlePaymentTransaction.d.ts +1 -1
  119. package/src/api-public/services/model/handlePaymentTransaction.js +23 -3
  120. package/src/api-public/services/model/handlePaymentTransaction.js.map +1 -1
  121. package/src/api-public/services/model/handlePaymentTransaction.ts +25 -36
  122. package/src/api-public/services/schedule.d.ts +1 -0
  123. package/src/api-public/services/schedule.js +27 -0
  124. package/src/api-public/services/schedule.js.map +1 -1
  125. package/src/api-public/services/schedule.ts +30 -0
  126. package/src/api-public/services/shopping.d.ts +22 -2
  127. package/src/api-public/services/shopping.js +362 -90
  128. package/src/api-public/services/shopping.js.map +1 -1
  129. package/src/api-public/services/shopping.ts +481 -134
  130. package/src/api-public/services/user.d.ts +1 -0
  131. package/src/api-public/services/user.js +36 -16
  132. package/src/api-public/services/user.js.map +1 -1
  133. package/src/api-public/services/user.ts +42 -23
  134. package/src/api-public/services/workers.js +3 -3
  135. package/src/api-public/services/workers.js.map +1 -1
  136. package/src/api-public/services/workers.ts +103 -103
  137. package/src/app-project/serverless/src/modules/database.js +1 -1
  138. package/src/app-project/serverless/src/modules/database.js.map +1 -1
  139. package/src/app-project/serverless/src/modules/database.ts +171 -171
  140. package/src/controllers/template.d.ts +1 -1
  141. package/src/controllers/template.js +16 -16
  142. package/src/controllers/template.js.map +1 -1
  143. package/src/controllers/template.ts +98 -84
  144. package/src/modules/database.js +3 -1
  145. package/src/modules/database.js.map +1 -1
  146. package/src/modules/database.ts +185 -181
  147. package/src/modules/firebase.d.ts +17 -0
  148. package/src/modules/firebase.js +126 -0
  149. package/src/modules/firebase.js.map +1 -1
  150. package/src/modules/firebase.ts +169 -0
  151. package/src/public-config-initial/auto-fcm.js +8 -2
  152. package/src/public-config-initial/auto-fcm.js.map +1 -1
  153. package/src/public-config-initial/auto-fcm.ts +15 -6
  154. package/src/services/app.d.ts +2 -1
  155. package/src/services/app.js.map +1 -1
  156. package/src/services/app.ts +2 -1
  157. package/src/services/template.d.ts +3 -2
  158. package/src/services/template.js +2 -1
  159. package/src/services/template.js.map +1 -1
  160. package/src/services/template.ts +13 -20
@@ -5,55 +5,40 @@ import { ShareDialog } from '../../glitterBundle/dialog/ShareDialog.js';
5
5
  import { Tool } from '../../modules/tool.js';
6
6
  import { OrderDetail } from './data.js';
7
7
  import { EditorElem } from '../../glitterBundle/plugins/editor-elem.js';
8
+ import { ShipmentConfig } from '../../glitter-base/global/shipment-config.js';
9
+ import { PaymentConfig } from '../../glitter-base/global/payment-config.js';
8
10
  const html = String.raw;
9
11
  export class OrderSetting {
10
- static getPaymentMethodText(orderData) {
12
+ static getPaymentMethodText(orderData, paymentMethod) {
11
13
  const paymentMethods = {
12
14
  POS: '門市POS付款',
13
15
  off_line: '線下付款',
14
- newWebPay: '藍新金流',
15
- ecPay: '綠界金流',
16
- line_pay: 'Line Pay',
17
- atm: '銀行轉帳',
18
- line: 'Line 轉帳',
19
- cash_on_delivery: '貨到付款',
20
16
  };
17
+ paymentMethod.map((item) => {
18
+ paymentMethods[item.key] = item.name;
19
+ });
21
20
  return orderData.orderSource === 'POS'
22
21
  ? paymentMethods['POS']
23
22
  : paymentMethods[orderData.customer_info.payment_select] || '線下付款';
24
23
  }
25
24
  static getShippingMethodText(orderData) {
26
- switch (orderData.user_info.shipment) {
27
- case 'UNIMARTC2C':
28
- return '7-11店到店';
29
- case 'FAMIC2C':
30
- return '全家店到店';
31
- case 'OKMARTC2C':
32
- return 'OK店到店';
33
- case 'HILIFEC2C':
34
- return '萊爾富店到店';
35
- case 'normal':
36
- return '中華郵政';
37
- case 'black_cat':
38
- return '黑貓到府';
39
- case 'shop':
40
- return '實體門市取貨';
41
- case 'global_express':
42
- return '國際快遞';
43
- case 'now':
44
- return '立即取貨';
45
- default:
46
- return '宅配';
25
+ if (!orderData.user_info.shipment) {
26
+ return '立即取貨';
47
27
  }
28
+ const shippingData = ShipmentConfig.list.find(item => item.value === orderData.user_info.shipment);
29
+ return shippingData ? shippingData.title : '立即取貨';
48
30
  }
49
31
  static getShippingAddress(orderData) {
50
32
  const shipment = orderData.user_info.shipment;
51
- if (['UNIMARTC2C', 'FAMIC2C', 'OKMARTC2C', 'HILIFEC2C'].includes(shipment)) {
33
+ if (['UNIMARTC2C', 'UNIMARTFREEZE', 'FAMIC2C', 'FAMIC2CFREEZE', 'OKMARTC2C', 'HILIFEC2C'].includes(shipment)) {
52
34
  return `${orderData.user_info.CVSStoreName} (${orderData.user_info.CVSAddress})`;
53
35
  }
54
36
  if (shipment === 'shop') {
55
37
  return '實體門市';
56
38
  }
39
+ if (shipment === 'now') {
40
+ return '立即取貨';
41
+ }
57
42
  return orderData.user_info.address;
58
43
  }
59
44
  static getPaymentStatusOpt() {
@@ -72,6 +57,7 @@ export class OrderSetting {
72
57
  static getShippmentOpt() {
73
58
  return [
74
59
  { title: '未出貨', value: 'wait' },
60
+ { title: '待預購', value: 'pre_order' },
75
61
  { title: '備貨中', value: 'in_stock' },
76
62
  { title: '已出貨', value: 'shipping' },
77
63
  { title: '已到貨', value: 'arrived' },
@@ -678,6 +664,11 @@ export class OrderSetting {
678
664
  { width: 10, align: 'center' },
679
665
  { width: 30, align: 'center' },
680
666
  ];
667
+ const ovm = {
668
+ list_id: gvc.glitter.getUUID(),
669
+ list_loading: true,
670
+ payment_method: [],
671
+ };
681
672
  return html `
682
673
  <div class="${gClass('check-info-box')}">
683
674
  ${BgWidget.grayNote('請與顧客確認合併訂單的付款、配送方式及地址<br />應與下列哪筆訂單相同,避免爭議')}
@@ -700,59 +691,79 @@ export class OrderSetting {
700
691
  })
701
692
  .join('')}
702
693
  </div>
703
- <div class="d-flex flex-column gap-0 mt-3">
704
- ${orders
705
- .map(order => {
706
- const orderData = order.orderData;
707
- const vt = this.getAllStatusBadge(order);
708
- const row = [
709
- {
710
- title: html `
711
- <div class="d-flex gap-2">
712
- ${gvc.bindView({
713
- bind: `r-${order.cart_token}`,
714
- view: () => {
715
- return html `<input
716
- class="form-check-input ${dialogVM.dotClass} cursor_pointer"
717
- style="margin-top: 0.25rem;"
718
- type="radio"
719
- id="r-${order.cart_token}"
720
- name="check-info-radios"
721
- onchange="${gvc.event(() => {
722
- dialogVM.selectOrderID = order.cart_token;
723
- gvc.notifyDataChange(orders.map(d => `r-${d.cart_token}`));
724
- })}"
725
- ${dialogVM.selectOrderID === order.cart_token ? 'checked' : ''}
726
- />`;
727
- },
728
- })}
729
- <span style="color: #4d86db;">${order.cart_token}</span>
730
- <div class="d-flex justify-content-end gap-2">
731
- ${vt.archivedBadge()}
732
- ${vt.paymentBadge()}${vt.outShipBadge()}${vt.orderStatusBadge()}
733
- </div>
734
- </div>
735
- `,
736
- },
737
- { title: order.created_time.split('T')[0] },
738
- { title: this.getPaymentMethodText(orderData) },
739
- { title: this.getShippingMethodText(orderData) },
740
- { title: this.getShippingAddress(orderData) },
741
- ]
742
- .map((item, i) => {
743
- var _a;
744
- return html ` <div
745
- class="tx_normal"
746
- style="width: ${styles[i].width}%; text-align: ${styles[i].align};"
747
- >
748
- <span style="white-space: break-spaces;">${((_a = item.title) !== null && _a !== void 0 ? _a : '').trim()}</span>
749
- </div>`;
750
- })
751
- .join('');
752
- return html ` <div class="${gClass('order-row')}">${row}</div>`;
753
- })
754
- .join('')}
755
- </div>
694
+ ${gvc.bindView({
695
+ bind: ovm.list_id,
696
+ view: () => {
697
+ if (ovm.list_loading) {
698
+ return '';
699
+ }
700
+ else {
701
+ return orders
702
+ .map(order => {
703
+ const orderData = order.orderData;
704
+ const vt = this.getAllStatusBadge(order);
705
+ const row = [
706
+ {
707
+ title: html `
708
+ <div class="d-flex gap-2">
709
+ ${gvc.bindView({
710
+ bind: `r-${order.cart_token}`,
711
+ view: () => {
712
+ return html `<input
713
+ class="form-check-input ${dialogVM.dotClass} cursor_pointer"
714
+ style="margin-top: 0.25rem;"
715
+ type="radio"
716
+ id="r-${order.cart_token}"
717
+ name="check-info-radios"
718
+ onchange="${gvc.event(() => {
719
+ dialogVM.selectOrderID = order.cart_token;
720
+ gvc.notifyDataChange(orders.map(d => `r-${d.cart_token}`));
721
+ })}"
722
+ ${dialogVM.selectOrderID === order.cart_token ? 'checked' : ''}
723
+ />`;
724
+ },
725
+ })}
726
+ <span style="color: #4d86db;">${order.cart_token}</span>
727
+ <div class="d-flex justify-content-end gap-2">
728
+ ${vt.archivedBadge()}
729
+ ${vt.paymentBadge()}${vt.outShipBadge()}${vt.orderStatusBadge()}
730
+ </div>
731
+ </div>
732
+ `,
733
+ },
734
+ { title: order.created_time.split('T')[0] },
735
+ { title: this.getPaymentMethodText(orderData, ovm.payment_method) },
736
+ { title: this.getShippingMethodText(orderData) },
737
+ { title: this.getShippingAddress(orderData) },
738
+ ]
739
+ .map((item, i) => {
740
+ var _a;
741
+ return html ` <div
742
+ class="tx_normal"
743
+ style="width: ${styles[i].width}%; text-align: ${styles[i].align};"
744
+ >
745
+ <span style="white-space: break-spaces;">${((_a = item.title) !== null && _a !== void 0 ? _a : '').trim()}</span>
746
+ </div>`;
747
+ })
748
+ .join('');
749
+ return html ` <div class="${gClass('order-row')}">${row}</div>`;
750
+ })
751
+ .join('');
752
+ }
753
+ },
754
+ divCreate: {
755
+ class: 'd-flex flex-column gap-0 mt-3',
756
+ },
757
+ onCreate: () => {
758
+ if (ovm.list_loading) {
759
+ PaymentConfig.getSupportPayment(true).then(response => {
760
+ ovm.payment_method = response;
761
+ ovm.list_loading = false;
762
+ gvc.notifyDataChange(ovm.list_id);
763
+ });
764
+ }
765
+ },
766
+ })}
756
767
  </div>
757
768
  </div>
758
769
  `;
@@ -841,6 +852,11 @@ export class OrderSetting {
841
852
  { width: 10, align: 'center' },
842
853
  { width: 5, align: 'center' },
843
854
  ];
855
+ const ovm = {
856
+ list_id: gvc.glitter.getUUID(),
857
+ list_loading: true,
858
+ payment_method: [],
859
+ };
844
860
  return html ` <div class="${gClass('box')} mt-2" style="${isDesktop ? '' : 'width: 1200px'}">
845
861
  <div class="d-flex">
846
862
  ${[
@@ -860,59 +876,79 @@ export class OrderSetting {
860
876
  })
861
877
  .join('')}
862
878
  </div>
863
- <div class="d-flex flex-column gap-0 mt-3">
864
- ${orders
865
- .map((order, index) => {
866
- const orderData = order.orderData;
867
- const vt = this.getAllStatusBadge(order);
868
- const row = [
869
- {
870
- title: html `
871
- <div class="d-flex gap-3">
872
- <span style="color: #4d86db;">${order.cart_token}</span>
873
- <div class="d-flex justify-content-end gap-2">
874
- ${vt.archivedBadge()} ${vt.paymentBadge()}${vt.outShipBadge()}${vt.orderStatusBadge()}
875
- </div>
876
- </div>
877
- `,
878
- },
879
- { title: order.created_time.split('T')[0] },
880
- { title: this.getPaymentMethodText(orderData) },
881
- { title: this.getShippingMethodText(orderData) },
882
- { title: this.getShippingAddress(orderData) },
883
- { title: `$ ${orderData.total.toLocaleString()}` },
884
- { title: `${orderData.lineItems.length}件商品` },
885
- {
886
- title: orders.length > 1
887
- ? html `<i
888
- class="fa-solid fa-xmark"
889
- style="color: #B0B0B0; cursor: pointer"
890
- onclick="${gvc.event(() => {
891
- if (order.cart_token === data.targetID) {
892
- data.targetID = '';
893
- }
894
- data.orders.splice(index, 1);
895
- vm.dataObject = setDataStatus(dataMap);
896
- gvc.notifyDataChange([editID, ids.header, ids.dashboard]);
897
- })}"
898
- ></i>`
899
- : '',
900
- },
901
- ]
902
- .map((item, i) => {
903
- var _a;
904
- return html ` <div
905
- class="tx_normal"
906
- style="width: ${styles[i].width}%; text-align: ${styles[i].align};"
907
- >
908
- <span style="white-space: break-spaces;">${((_a = item.title) !== null && _a !== void 0 ? _a : '').trim()}</span>
909
- </div>`;
910
- })
911
- .join('');
912
- return html ` <div class="${gClass('order-row')}">${row}</div>`;
913
- })
914
- .join('')}
915
- </div>
879
+ ${gvc.bindView({
880
+ bind: ovm.list_id,
881
+ view: () => {
882
+ if (ovm.list_loading) {
883
+ return '';
884
+ }
885
+ else {
886
+ return orders
887
+ .map((order, index) => {
888
+ const orderData = order.orderData;
889
+ const vt = this.getAllStatusBadge(order);
890
+ const row = [
891
+ {
892
+ title: html `
893
+ <div class="d-flex gap-3">
894
+ <span style="color: #4d86db;">${order.cart_token}</span>
895
+ <div class="d-flex justify-content-end gap-2">
896
+ ${vt.archivedBadge()} ${vt.paymentBadge()}${vt.outShipBadge()}${vt.orderStatusBadge()}
897
+ </div>
898
+ </div>
899
+ `,
900
+ },
901
+ { title: order.created_time.split('T')[0] },
902
+ { title: this.getPaymentMethodText(orderData, ovm.payment_method) },
903
+ { title: this.getShippingMethodText(orderData) },
904
+ { title: this.getShippingAddress(orderData) },
905
+ { title: `$ ${orderData.total.toLocaleString()}` },
906
+ { title: `${orderData.lineItems.length}件商品` },
907
+ {
908
+ title: orders.length > 1
909
+ ? html `<i
910
+ class="fa-solid fa-xmark"
911
+ style="color: #B0B0B0; cursor: pointer"
912
+ onclick="${gvc.event(() => {
913
+ if (order.cart_token === data.targetID) {
914
+ data.targetID = '';
915
+ }
916
+ data.orders.splice(index, 1);
917
+ vm.dataObject = setDataStatus(dataMap);
918
+ gvc.notifyDataChange([editID, ids.header, ids.dashboard]);
919
+ })}"
920
+ ></i>`
921
+ : '',
922
+ },
923
+ ]
924
+ .map((item, i) => {
925
+ var _a;
926
+ return html ` <div
927
+ class="tx_normal"
928
+ style="width: ${styles[i].width}%; text-align: ${styles[i].align};"
929
+ >
930
+ <span style="white-space: break-spaces;">${((_a = item.title) !== null && _a !== void 0 ? _a : '').trim()}</span>
931
+ </div>`;
932
+ })
933
+ .join('');
934
+ return html ` <div class="${gClass('order-row')}">${row}</div>`;
935
+ })
936
+ .join('');
937
+ }
938
+ },
939
+ divCreate: {
940
+ class: 'd-flex flex-column gap-0 mt-3',
941
+ },
942
+ onCreate: () => {
943
+ if (ovm.list_loading) {
944
+ PaymentConfig.getSupportPayment(true).then(response => {
945
+ ovm.payment_method = response;
946
+ ovm.list_loading = false;
947
+ gvc.notifyDataChange(ovm.list_id);
948
+ });
949
+ }
950
+ },
951
+ })}
916
952
  </div>`;
917
953
  };
918
954
  const isExpanded = ids.show === editID;
@@ -994,7 +1030,14 @@ export class OrderSetting {
994
1030
  const { user_info } = orderData;
995
1031
  const isPayStatusSame = status === baseStatus;
996
1032
  const isShipmentSame = user_info.shipment === baseShipment;
997
- const isAddressSame = ['UNIMARTC2C', 'FAMIC2C', 'OKMARTC2C', 'HILIFEC2C'].includes(baseShipment)
1033
+ const isAddressSame = [
1034
+ 'UNIMARTC2C',
1035
+ 'UNIMARTFREEZE',
1036
+ 'FAMIC2C',
1037
+ 'FAMIC2CFREEZE',
1038
+ 'OKMARTC2C',
1039
+ 'HILIFEC2C',
1040
+ ].includes(baseShipment)
998
1041
  ? user_info.CVSStoreName === baseCVSStoreName
999
1042
  : user_info.address === baseAddress;
1000
1043
  return isPayStatusSame && isShipmentSame && isAddressSame;
@@ -1154,7 +1197,7 @@ export class OrderSetting {
1154
1197
  },
1155
1198
  {
1156
1199
  key: '出貨單號碼',
1157
- value: html `<div style="width: 200px;">
1200
+ value: html ` <div style="width: 200px;">
1158
1201
  ${BgWidget.grayNote(dd.orderData.user_info.shipment_number
1159
1202
  ? `#${dd.orderData.user_info.shipment_number}`
1160
1203
  : dd.orderData.orderSource === 'POS'
@@ -1256,7 +1299,7 @@ export class OrderSetting {
1256
1299
  })
1257
1300
  : '',
1258
1301
  ].filter(Boolean);
1259
- return html `<div class="d-flex align-items-center gap-2">${htmlArray.join('')}</div>`;
1302
+ return html ` <div class="d-flex align-items-center gap-2">${htmlArray.join('')}</div>`;
1260
1303
  },
1261
1304
  divCreate: {
1262
1305
  style: 'min-width: 580px;',
@@ -1330,6 +1373,9 @@ export class OrderSetting {
1330
1373
  callback: (value) => {
1331
1374
  checkArray.forEach((order) => {
1332
1375
  order.orderData.progress = value;
1376
+ if (['wait', 'returns', undefined].includes(value)) {
1377
+ order.orderData.user_info.shipment_number = '';
1378
+ }
1333
1379
  });
1334
1380
  },
1335
1381
  });
@@ -1431,11 +1477,12 @@ export class OrderSetting {
1431
1477
  });
1432
1478
  }, 'batchEditOrders');
1433
1479
  }
1434
- static splitOrder(topGVC, orderData, callback) {
1480
+ static splitOrder(topGVC, origOrderData, callback) {
1435
1481
  var _a, _b;
1482
+ const orderData = structuredClone(origOrderData);
1436
1483
  function assignOrder(orderCreateUnit) {
1437
1484
  orderCreateUnit.cart_token = orderData.orderID;
1438
- orderCreateUnit.customer_info = orderData.user_info;
1485
+ orderCreateUnit.customer_info = orderData.customer_info;
1439
1486
  orderCreateUnit.user_info = orderData.user_info;
1440
1487
  orderCreateUnit.voucher = orderData.voucherList;
1441
1488
  orderCreateUnit.lineItems = structuredClone(orderData.lineItems);
@@ -1444,6 +1491,7 @@ export class OrderSetting {
1444
1491
  });
1445
1492
  }
1446
1493
  orderData.orderSource = 'split';
1494
+ let storeList = [];
1447
1495
  const dataArray = orderData.lineItems;
1448
1496
  const parentPageConfig = (_b = (_a = window.parent) === null || _a === void 0 ? void 0 : _a.glitter) === null || _b === void 0 ? void 0 : _b.pageConfig;
1449
1497
  const latestPageConfig = parentPageConfig === null || parentPageConfig === void 0 ? void 0 : parentPageConfig[parentPageConfig.length - 1];
@@ -1456,9 +1504,8 @@ export class OrderSetting {
1456
1504
  const passData = structuredClone(orderCreateUnit);
1457
1505
  const isDesktop = document.body.clientWidth > 768;
1458
1506
  const vm = {
1459
- dataObject: {},
1460
- originDataObject: {},
1461
1507
  prefix: 'split-orders',
1508
+ loading: true,
1462
1509
  splitCount: 1,
1463
1510
  };
1464
1511
  const ids = {
@@ -1466,6 +1513,7 @@ export class OrderSetting {
1466
1513
  page: glitter.getUUID(),
1467
1514
  header: glitter.getUUID(),
1468
1515
  dashboard: glitter.getUUID(),
1516
+ origQTY: glitter.getUUID(),
1469
1517
  itemList: glitter.getUUID(),
1470
1518
  block: glitter.getUUID(),
1471
1519
  summary: glitter.getUUID(),
@@ -1527,31 +1575,7 @@ export class OrderSetting {
1527
1575
  bottom: 0;
1528
1576
  z-index: 10;
1529
1577
  }
1530
- .${vm.prefix}-dashboard-gray {
1531
- color: #8d8d8d;
1532
- font-size: 16px;
1533
- font-weight: 400;
1534
- }
1535
- .${vm.prefix}-update {
1536
- width: 80px;
1537
- color: #4d86db;
1538
- font-weight: 400;
1539
- gap: 8px;
1540
- cursor: pointer;
1541
- }
1542
- .${vm.prefix}-list {
1543
- list-style: disc;
1544
- white-space: break-spaces;
1545
- }
1546
- .${vm.prefix}-box {
1547
- border-radius: 10px;
1548
- padding: 6px 10px;
1549
- }
1550
- .${vm.prefix}-check-info-box {
1551
- position: absolute;
1552
- width: 1000px;
1553
- overflow: auto;
1554
- }
1578
+
1555
1579
  .${vm.prefix}-order-row {
1556
1580
  display: flex;
1557
1581
  align-items: center;
@@ -1589,7 +1613,7 @@ export class OrderSetting {
1589
1613
  height:26px;
1590
1614
  color:#4D86DB;
1591
1615
  gap: 6px;
1592
- padding-left:18px;
1616
+ padding:0 18px;
1593
1617
  display: flex;
1594
1618
  align-items: start;
1595
1619
  cursor:pointer;
@@ -1601,13 +1625,15 @@ export class OrderSetting {
1601
1625
  }
1602
1626
  .${vm.prefix}-itemList-section{
1603
1627
  min-width: 100%;
1628
+ border-bottom: 1px solid #DDD;
1604
1629
  padding-top:24px;
1605
1630
  gap:5px;
1606
- display: flex;
1631
+ display: inline-flex;
1607
1632
  }
1608
1633
  .${vm.prefix}-summary-section{
1609
- border-top: 1px solid #DDD;
1634
+ min-width: 100%;
1610
1635
  border-bottom: 1px solid #DDD;
1636
+ width:fit-content;
1611
1637
  }
1612
1638
  .${vm.prefix}-summary-title{
1613
1639
  width:606px;
@@ -1654,13 +1680,13 @@ export class OrderSetting {
1654
1680
 
1655
1681
  .${vm.prefix}-dialog-ul{
1656
1682
  padding:6px ;
1657
- list-style:disc;
1658
1683
 
1659
1684
  }
1660
1685
  .${vm.prefix}-dialog-ul li{
1686
+ margin-bottom: 3px;
1661
1687
  list-style:disc;
1662
1688
  text-align:left;
1663
- list-style-position: inside;
1689
+ white-space:break-spaces;
1664
1690
  }
1665
1691
  `);
1666
1692
  };
@@ -1697,21 +1723,43 @@ export class OrderSetting {
1697
1723
  dialog.checkYesOrNotWithCustomWidth({
1698
1724
  callback: bool => {
1699
1725
  if (bool) {
1726
+ function deductFromStoresTS(log, amountToDeduct) {
1727
+ const updatedLog = Object.assign({}, log);
1728
+ const deductions = {};
1729
+ let remainingAmount = Math.max(0, amountToDeduct);
1730
+ const sortedEntries = Object.entries(updatedLog).sort(([, valueA], [, valueB]) => valueB - valueA);
1731
+ for (const [storeKey, storeValue] of sortedEntries) {
1732
+ if (remainingAmount <= 0) {
1733
+ break;
1734
+ }
1735
+ if (storeValue <= 0) {
1736
+ continue;
1737
+ }
1738
+ const amountDeductedFromThisStore = Math.min(remainingAmount, storeValue);
1739
+ if (amountDeductedFromThisStore > 0) {
1740
+ updatedLog[storeKey] -= amountDeductedFromThisStore;
1741
+ deductions[storeKey] = amountDeductedFromThisStore;
1742
+ remainingAmount -= amountDeductedFromThisStore;
1743
+ }
1744
+ }
1745
+ return {
1746
+ updatedLog: updatedLog,
1747
+ deductions: deductions,
1748
+ };
1749
+ }
1700
1750
  orderData.lineItems.forEach((lineItem, index) => {
1701
1751
  let count = 0;
1702
- count = splitOrderArray.reduce((total, order) => {
1703
- return (total += Number(order.lineItems[index].count));
1704
- }, 0);
1705
- lineItem.count -= count;
1752
+ splitOrderArray.forEach(order => {
1753
+ lineItem.count -= order.lineItems[index].count;
1754
+ const resultTS = deductFromStoresTS(lineItem.deduction_log, order.lineItems[index].count);
1755
+ order.lineItems[index].deduction_log = resultTS.deductions;
1756
+ lineItem.deduction_log = resultTS.updatedLog;
1757
+ });
1706
1758
  });
1707
1759
  const passData = {
1708
1760
  orderData: orderData,
1709
1761
  splitOrderArray: splitOrderArray,
1710
1762
  };
1711
- ApiShop.combineOrder(vm.dataObject).then(r => {
1712
- if (r.result && r.response) {
1713
- }
1714
- });
1715
1763
  dialog.dataLoading({ visible: true });
1716
1764
  ApiShop.splitOrder(passData).then(r => {
1717
1765
  if (r.result && r.response) {
@@ -1731,13 +1779,27 @@ export class OrderSetting {
1731
1779
  const renderFooter = (gvc) => gvc.bindView({
1732
1780
  bind: ids.footer,
1733
1781
  view: () => {
1734
- const allOrdersHaveZeroItems = splitOrderArray.every(order => order.lineItems.every(item => item.count === 0));
1782
+ let allOrdersHaveZeroItems = false;
1783
+ let origQtyZero = true;
1784
+ let iSplitQtyCount = 0;
1785
+ splitOrderArray.forEach(splitOrder => {
1786
+ if (splitOrder.lineItems.every(item => item.count === 0)) {
1787
+ allOrdersHaveZeroItems = true;
1788
+ }
1789
+ iSplitQtyCount += splitOrder.lineItems.reduce((count, lineItem) => {
1790
+ return (count += lineItem.count);
1791
+ }, 0);
1792
+ });
1793
+ const iQtyCount = dataArray.reduce((iCount, lineItem) => {
1794
+ return (iCount += lineItem.count);
1795
+ }, 0);
1796
+ origQtyZero = iSplitQtyCount === iQtyCount;
1735
1797
  let checkBTN = ``;
1736
- if (!allOrdersHaveZeroItems) {
1737
- checkBTN = BgWidget.save(gvc.event(handleSave), '拆分訂單');
1798
+ if (allOrdersHaveZeroItems || origQtyZero) {
1799
+ checkBTN = BgWidget.disableSave('拆分訂單');
1738
1800
  }
1739
1801
  else {
1740
- checkBTN = BgWidget.disableSave('拆分訂單');
1802
+ checkBTN = BgWidget.save(gvc.event(handleSave), '拆分訂單');
1741
1803
  }
1742
1804
  return html ` ${BgWidget.cancel(gvc.event(closeDialog))} ${checkBTN} `;
1743
1805
  },
@@ -1755,52 +1817,51 @@ export class OrderSetting {
1755
1817
  const hits = [
1756
1818
  '原訂單將保留剩餘商品,訂單金額與折扣將調整;子訂單將包含選定商品,並按比例分配優惠折扣',
1757
1819
  '拆單後,運費及附加費用不變,將保留於原訂單內,若需要,請手動編輯訂單新增費用',
1820
+ '請務必進入每一張新的子訂單,為其中的所有商品選擇正確的出貨庫存',
1758
1821
  ];
1759
1822
  return html `
1760
1823
  <div class="row">
1761
- <div class="col-12 ">
1762
- ${BgWidget.mainCard(html `
1763
- <div style="${phoneCardStyle}">
1764
- <span class="tx_700">拆單需知</span>
1765
- <div class="w-100 d-flex">
1766
- <ul class="mt-2 ms-4">
1767
- ${hits
1824
+ ${BgWidget.mainCard(html `
1825
+ <div style="${phoneCardStyle}">
1826
+ <span class="tx_700">拆單需知</span>
1827
+ <div class="w-100 d-flex flex-column">
1828
+ <ul class="mt-2 ms-4 ${gClass('dialog-ul')}">
1829
+ ${hits
1768
1830
  .map(hit => {
1769
- return html ` <li class="${gClass('list')}">${hit}</li>`;
1831
+ return html ` <li class="">${hit}</li>`;
1770
1832
  })
1771
1833
  .join('')}
1772
- </ul>
1773
- <div
1774
- class="${gClass('split-rule')} ms-auto d-flex align-items-end"
1775
- onclick="${gvc.event(() => {
1834
+ </ul>
1835
+ <div
1836
+ class="${gClass('split-rule')} ms-auto d-flex align-items-end justify-content-end"
1837
+ onclick="${gvc.event(() => {
1776
1838
  BgWidget.settingDialog({
1777
1839
  gvc: gvc,
1778
1840
  title: '拆單需知',
1779
1841
  width: 766,
1780
1842
  innerHTML: gvc => {
1781
1843
  return html ` <ul class="${gClass('dialog-ul')}">
1782
- <li>
1783
- 原訂單將保留剩餘商品,訂單金額與折扣將調整;子訂單將包含選定商品,並按比例分配優惠折扣
1784
- </li>
1785
- <li>拆單後運費及附加費用不變,將保留於原訂單內,如需更改,請手動編輯訂單新增費用</li>
1786
- <li>子訂單會預設繼承母訂單的配送與付款方式,如需更改,請手動編輯訂單內容</li>
1787
- <li>子訂單若要重新開立發票,請至發票頁面手動建立</li>
1788
- <li>若發票已開立,系統不會自動作廢,需至訂單頁面手動作廢並重新開立</li>
1789
- <li>代收金額將更新,已建立的出貨單需取消並重新建立</li>
1790
- </ul>`;
1844
+ <li>
1845
+ 原訂單將保留剩餘商品,訂單金額與折扣將調整;子訂單將包含選定商品,並按比例分配優惠折扣
1846
+ </li>
1847
+ <li>拆單後運費及附加費用不變,將保留於原訂單內,如需更改,請手動編輯訂單新增費用</li>
1848
+ <li>子訂單會預設繼承母訂單的配送與付款方式,如需更改,請手動編輯訂單內容</li>
1849
+ <li>子訂單若要重新開立發票,請至發票頁面手動建立</li>
1850
+ <li>若發票已開立,系統不會自動作廢,需至訂單頁面手動作廢並重新開立</li>
1851
+ <li>代收金額將更新,已建立的出貨單需取消並重新建立</li>
1852
+ </ul>`;
1791
1853
  },
1792
1854
  footer_html: (gvc) => {
1793
1855
  return '';
1794
1856
  },
1795
1857
  });
1796
1858
  })}"
1797
- >
1798
- 詳細拆單規則
1799
- </div>
1859
+ >
1860
+ 詳細拆單規則
1800
1861
  </div>
1801
1862
  </div>
1802
- `)}
1803
- </div>
1863
+ </div>
1864
+ `)}
1804
1865
  </div>
1805
1866
  `;
1806
1867
  };
@@ -1819,15 +1880,26 @@ export class OrderSetting {
1819
1880
  };
1820
1881
  return splitOrderArray
1821
1882
  .map((order, index) => {
1822
- var _a, _b;
1883
+ var _a, _b, _c;
1823
1884
  return html `
1824
1885
  <div class="d-flex flex-column">
1825
1886
  <div class="${commonClass}" style="width: ${titleDom.width};${(_a = titleDom === null || titleDom === void 0 ? void 0 : titleDom.style) !== null && _a !== void 0 ? _a : ''}">
1826
- <div class="tx_700">${titleDom.title}${index + 1}</div>
1887
+ <div class="tx_700">
1888
+ ${titleDom.title}${index + 1}
1889
+ <i
1890
+ class="fa-solid fa-xmark cursor_pointer"
1891
+ onclick="${gvc.event(() => {
1892
+ if (splitOrderArray.length > 1) {
1893
+ splitOrderArray.splice(index, 1);
1894
+ gvc.notifyDataChange([ids.itemList, ids.summary, ids.footer]);
1895
+ }
1896
+ })}"
1897
+ ></i>
1898
+ </div>
1827
1899
  <div class="flex-fill"></div>
1828
1900
  </div>
1829
1901
  <div
1830
- class="d-flex flex-column"
1902
+ class="d-flex flex-column flex-shrink-0"
1831
1903
  style="width: ${titleDom.width};gap:16px;padding-top: 24px;${(_b = titleDom === null || titleDom === void 0 ? void 0 : titleDom.style) !== null && _b !== void 0 ? _b : ''}"
1832
1904
  >
1833
1905
  ${splitOrderArray[index].lineItems
@@ -1838,26 +1910,31 @@ export class OrderSetting {
1838
1910
  style="${commonHeight};"
1839
1911
  type="number"
1840
1912
  value="${item.count}"
1841
- min="0"
1842
1913
  onchange="${gvc.event(e => {
1914
+ if (Number(e.value) < 0) {
1915
+ e.value = '0';
1916
+ }
1843
1917
  const temp = structuredClone(item.count);
1844
1918
  item.count = Number(e.value);
1845
1919
  let nowQty = 0;
1846
- splitOrderArray.forEach((order, index) => {
1847
- nowQty += order.lineItems[itemIndex].count;
1920
+ splitOrderArray.forEach((splitOrder, index) => {
1921
+ nowQty += splitOrder.lineItems[itemIndex].count;
1848
1922
  });
1849
- if (order.lineItems[itemIndex].count >= nowQty) {
1850
- }
1851
- else {
1923
+ if (dataArray[itemIndex].count < nowQty) {
1852
1924
  item.count = temp;
1925
+ e.value = temp;
1853
1926
  }
1854
- gvc.notifyDataChange([ids.itemList, ids.summary, ids.footer]);
1927
+ gvc.notifyDataChange([ids.summary, ids.footer, 'oriQty']);
1855
1928
  })}"
1856
1929
  />
1857
1930
  `;
1858
1931
  })
1859
1932
  .join('')}
1860
1933
  </div>
1934
+ <div
1935
+ class="d-flex flex-column flex-grow-1"
1936
+ style="width: ${titleDom.width};gap:16px;padding-top: 24px;${(_c = titleDom === null || titleDom === void 0 ? void 0 : titleDom.style) !== null && _c !== void 0 ? _c : ''}"
1937
+ ></div>
1861
1938
  </div>
1862
1939
  `;
1863
1940
  })
@@ -1897,125 +1974,161 @@ export class OrderSetting {
1897
1974
  htmlArray: [],
1898
1975
  },
1899
1976
  ];
1900
- dataArray.forEach((item, lineItemIndex) => {
1901
- return html `
1902
- <div class="d-flex w-100">
1903
- ${dataRaws
1904
- .map((dataRaw, dataRowIndex) => {
1905
- var _a, _b;
1906
- switch (dataRaw.key) {
1907
- case 'name': {
1977
+ function drawLineItems(dataRaw) {
1978
+ switch (dataRaw.key) {
1979
+ case 'name': {
1980
+ return dataArray
1981
+ .map((item, lineItemIndex) => {
1982
+ var _a, _b;
1908
1983
  const spec = item.spec.length > 0 ? Tool.truncateString(item.spec.join(''), 5) : '單一規格';
1909
- const sku = '';
1910
- dataRaw.htmlArray.push(html ` <div class="${commonClass}" style="width: ${dataRaw.width};gap:12px;${commonHeight}">
1911
- <img class="${gClass('product-preview-img')}" src="${item.preview_image}" alt="產品圖片" />
1912
- <div class="d-flex flex-column flex-grow-1" style="gap:2px;">
1913
- <div class="tx_normal_14" style="white-space: normal;line-height: normal;">
1914
- ${Tool.truncateString((_a = item.title) !== null && _a !== void 0 ? _a : '', 10)} -${spec}
1915
- </div>
1916
- <div class="tx_normal_14 ${gClass('font-gray')}">
1917
- 存貨單位 (SKU): ${(_b = item.sku) !== null && _b !== void 0 ? _b : '無SKU'}
1918
- </div>
1919
- </div>
1920
- </div>`);
1921
- break;
1922
- }
1923
- case 'stock': {
1924
- dataRaw.htmlArray.push(html `
1925
- <div
1926
- class="tx_normal ${commonClass} justify-content-start"
1927
- style="width: ${dataRaw.width};${commonHeight}"
1928
- >
1929
- AA倉庫
1930
- </div>
1931
- `);
1932
- break;
1933
- }
1934
- case 'price': {
1935
- dataRaw.htmlArray.push(html `
1936
- <div
1937
- class="tx_normal ${commonClass} justify-content-start"
1938
- style="width: ${dataRaw.width};${commonHeight}"
1939
- >
1940
- ${item.sale_price}
1941
- </div>
1942
- `);
1943
- break;
1944
- }
1945
- case 'totalQty': {
1946
- dataRaw.htmlArray.push(html `
1947
- <div
1948
- class="tx_normal ${commonClass} justify-content-start"
1949
- style="width: ${dataRaw.width};${commonHeight}"
1950
- >
1951
- ${item.count}
1952
- </div>
1953
- `);
1954
- break;
1984
+ return html ` <div class="${commonClass}" style="width: ${dataRaw.width};gap:12px;${commonHeight}">
1985
+ ${BgWidget.validImageBox({
1986
+ gvc: gvc,
1987
+ image: (_a = item.preview_image) !== null && _a !== void 0 ? _a : '',
1988
+ width: 42,
1989
+ })}
1990
+ <div class="d-flex flex-column flex-grow-1" style="gap:2px;">
1991
+ <div class="tx_normal_14" style="white-space: normal;line-height: normal;">
1992
+ ${Tool.truncateString((_b = item.title) !== null && _b !== void 0 ? _b : '', 10)} -${spec}
1993
+ </div>
1994
+ <div class="tx_normal_14 ${gClass('font-gray')}">
1995
+ 存貨單位 (SKU): ${item.sku && item.sku.length > 0 ? item.sku : '無SKU'}
1996
+ </div>
1997
+ </div>
1998
+ </div>`;
1999
+ })
2000
+ .join('');
2001
+ }
2002
+ case 'stock': {
2003
+ if (storeList.length > 0) {
2004
+ return dataArray.map((item) => {
2005
+ var _a;
2006
+ let maxEntry = {
2007
+ key: "",
2008
+ title: "",
2009
+ value: 0
2010
+ };
2011
+ console.log("item.deduction_log -- ", item.deduction_log);
2012
+ Object.entries(item.deduction_log).forEach((log) => {
2013
+ if (maxEntry.value < log[1]) {
2014
+ maxEntry = {
2015
+ key: log[0],
2016
+ title: log[0],
2017
+ value: log[1]
2018
+ };
2019
+ }
2020
+ });
2021
+ maxEntry.title = storeList.find((store) => {
2022
+ return store.id == maxEntry.key;
2023
+ }).name;
2024
+ return html `
2025
+ <div
2026
+ class="tx_normal ${commonClass} justify-content-start"
2027
+ style="width: ${dataRaw.width};${commonHeight}"
2028
+ >
2029
+ ${(_a = maxEntry.title) !== null && _a !== void 0 ? _a : "出貨庫存錯誤"}
2030
+ </div>
2031
+ `;
2032
+ }).join('');
1955
2033
  }
1956
- case 'oriQty': {
2034
+ return html `
2035
+ <div
2036
+ class="tx_normal ${commonClass} justify-content-start"
2037
+ style="width: ${dataRaw.width};${commonHeight}"
2038
+ >
2039
+ AA倉庫
2040
+ </div>
2041
+ `;
2042
+ }
2043
+ case 'price': {
2044
+ return dataArray
2045
+ .map((item, lineItemIndex) => {
2046
+ const spec = item.spec.length > 0 ? Tool.truncateString(item.spec.join(''), 5) : '單一規格';
2047
+ return html `
2048
+ <div
2049
+ class="tx_normal ${commonClass} justify-content-start"
2050
+ style="width: ${dataRaw.width};${commonHeight}"
2051
+ >
2052
+ ${item.sale_price}
2053
+ </div>
2054
+ `;
2055
+ })
2056
+ .join('');
2057
+ }
2058
+ case 'totalQty': {
2059
+ return dataArray
2060
+ .map((item, lineItemIndex) => {
2061
+ const spec = item.spec.length > 0 ? Tool.truncateString(item.spec.join(''), 5) : '單一規格';
2062
+ return html `
2063
+ <div
2064
+ class="tx_normal ${commonClass} justify-content-start"
2065
+ style="width: ${dataRaw.width};${commonHeight}"
2066
+ >
2067
+ ${item.count}
2068
+ </div>
2069
+ `;
2070
+ })
2071
+ .join('');
2072
+ }
2073
+ case 'oriQty': {
2074
+ return dataArray
2075
+ .map((item, lineItemIndex) => {
1957
2076
  let splitQty = 0;
1958
2077
  splitOrderArray.forEach(order => {
1959
2078
  splitQty += Number(order.lineItems[lineItemIndex].count);
1960
2079
  });
1961
2080
  const minusQtyClass = `${gClass('minusQty')} ${splitQty > 0 ? '' : 'd-none'}`;
1962
- dataRaw.htmlArray.push(html `
1963
- <div
1964
- class="tx_normal ${commonClass} justify-content-start"
1965
- style="width: ${dataRaw.width};${commonHeight}"
1966
- >
1967
- ${item.count} <span class="${minusQtyClass}"> -> ${Number(item.count) - splitQty}</span>
1968
- </div>
1969
- `);
1970
- break;
1971
- }
2081
+ return html `
2082
+ <div
2083
+ class="tx_normal ${commonClass} justify-content-start"
2084
+ style="width: ${dataRaw.width};${commonHeight}"
2085
+ >
2086
+ ${item.count}
2087
+ <span class="${minusQtyClass}">
2088
+ <i class="fa-solid fa-arrow-right ${gClass('font-blue')} ${gClass('summary-right')}"></i
2089
+ >${Number(item.count) - splitQty}</span
2090
+ >
2091
+ </div>
2092
+ `;
2093
+ })
2094
+ .join('');
1972
2095
  }
1973
- return html ``;
1974
- })
1975
- .join('')}
1976
- </div>
1977
- `;
1978
- });
2096
+ default: {
2097
+ return '';
2098
+ }
2099
+ }
2100
+ }
1979
2101
  return html `
1980
2102
  ${dataRaws
1981
2103
  .map(item => {
1982
2104
  var _a, _b;
1983
2105
  return html `
1984
- <div class="d-flex flex-column">
2106
+ <div class="d-flex flex-column flex-shrink-0">
1985
2107
  <div class="${commonClass}" style="width: ${item.width};${(_a = item === null || item === void 0 ? void 0 : item.style) !== null && _a !== void 0 ? _a : ''}">
1986
2108
  <div class="tx_700">${item.title}</div>
1987
2109
  <div class="flex-fill"></div>
1988
2110
  </div>
1989
- <div
1990
- class="d-flex flex-column"
1991
- style="width: ${item.width};gap:16px;padding-top: 24px;${(_b = item === null || item === void 0 ? void 0 : item.style) !== null && _b !== void 0 ? _b : ''}"
1992
- >
1993
- ${item.htmlArray.join('')}
1994
- </div>
2111
+ ${gvc.bindView({
2112
+ bind: item.key,
2113
+ view: () => {
2114
+ return (drawLineItems(item) +
2115
+ html ` <div class="${commonClass} mt-3" style="width: ${item.width};"></div>`);
2116
+ },
2117
+ divCreate: {
2118
+ class: 'd-flex flex-column',
2119
+ style: `width: ${item.width};gap:16px;padding-top: 24px;${(_b = item === null || item === void 0 ? void 0 : item.style) !== null && _b !== void 0 ? _b : ''}`,
2120
+ },
2121
+ })}
1995
2122
  </div>
1996
2123
  `;
1997
2124
  })
1998
2125
  .join('')}
1999
- ${drawSplitOrder()} ${addBTN}
2126
+ <div class="d-flex flex-shrink-0" style="overflow-x: scroll;gap:5px;">${drawSplitOrder()} ${addBTN}</div>
2000
2127
  `;
2001
2128
  },
2002
2129
  divCreate: { style: '', class: `${gClass('itemList-section')}` },
2003
2130
  });
2004
2131
  };
2005
- const renderBlock = (gvc) => {
2006
- const subBlock = splitOrderArray
2007
- .map((order, index) => {
2008
- return html `<div class="${gClass('summary-subSummary')}"></div>`;
2009
- })
2010
- .join('');
2011
- return html `
2012
- <div class="d-flex" style="height:27px;">
2013
- <div class="${gClass('summary-title')}"></div>
2014
- <div class="${gClass('summary-oriSummary')}"></div>
2015
- ${subBlock}
2016
- </div>
2017
- `;
2018
- };
2019
2132
  const renderSummary = (gvc) => {
2020
2133
  return gvc.bindView({
2021
2134
  bind: ids.summary,
@@ -2033,8 +2146,7 @@ export class OrderSetting {
2033
2146
  const sale_price = dataArray.reduce((total, data) => total + data.sale_price * Number(data.count), 0);
2034
2147
  const split_price = splitOrderArray.reduce((total, order) => total +
2035
2148
  order.lineItems.reduce((subTotal, lineItem) => subTotal + lineItem.sale_price * Number(lineItem.count), 0), 0);
2036
- const rate = 1 - split_price / (sale_price + orderData.shipment_fee);
2037
- const discount = Math.round(orderData.discount * rate);
2149
+ const split_discount = splitOrderArray.reduce((total, order) => total + order.discount, 0);
2038
2150
  switch (index) {
2039
2151
  case 1:
2040
2152
  if (split_price) {
@@ -2055,7 +2167,7 @@ export class OrderSetting {
2055
2167
  <div class="d-flex align-items-center">
2056
2168
  <span class="text-decoration-line-through">-${orderData.discount}</span
2057
2169
  ><i class="fa-solid fa-arrow-right ${gClass('font-blue')} ${gClass('summary-right')}"></i
2058
- ><span class="${gClass('font-blue')}">-${discount}</span>
2170
+ ><span class="${gClass('font-blue')}">-${orderData.discount - split_discount}</span>
2059
2171
  </div>
2060
2172
  `;
2061
2173
  }
@@ -2067,7 +2179,10 @@ export class OrderSetting {
2067
2179
  <span class="text-decoration-line-through">${orderData.total}</span
2068
2180
  ><i class="fa-solid fa-arrow-right ${gClass('font-blue')} ${gClass('summary-right')}"></i
2069
2181
  ><span class="${gClass('font-blue')}"
2070
- >${sale_price - split_price - discount + orderData.shipment_fee}</span
2182
+ >${sale_price -
2183
+ split_price -
2184
+ (orderData.discount - split_discount) +
2185
+ orderData.shipment_fee}</span
2071
2186
  >
2072
2187
  </div>
2073
2188
  `;
@@ -2142,18 +2257,33 @@ export class OrderSetting {
2142
2257
  applyClass();
2143
2258
  return gvc.bindView({
2144
2259
  bind: ids.page,
2145
- view: () => html `
2146
- <div class="d-flex flex-column ${gClass('full-screen')}">
2147
- ${renderHeader(gvc)}
2148
- <div
2149
- class="flex-fill scrollbar-appear"
2150
- style="${isDesktop ? 'padding: 24px 32px;' : 'padding: 0;'} overflow: hidden auto;"
2151
- >
2152
- ${renderHint(gvc)} ${renderItemList(gvc)} ${renderBlock(gvc)} ${renderSummary(gvc)}
2260
+ view: () => {
2261
+ if (vm.loading) {
2262
+ glitter.share.loading_dialog.dataLoading({ text: '載入中...', visible: true });
2263
+ ApiUser.getPublicConfig('store_manager', 'manager').then((dd) => {
2264
+ if (dd.result && dd.response.value) {
2265
+ storeList = dd.response.value.list;
2266
+ vm.loading = false;
2267
+ gvc.notifyDataChange(ids.page);
2268
+ }
2269
+ });
2270
+ }
2271
+ else {
2272
+ glitter.share.loading_dialog.dataLoading({ text: '載入中...', visible: false });
2273
+ }
2274
+ return html `
2275
+ <div class="d-flex flex-column ${gClass('full-screen')}">
2276
+ ${renderHeader(gvc)}
2277
+ <div
2278
+ class="flex-fill scrollbar-appear"
2279
+ style="${isDesktop ? 'padding: 24px 32px;' : 'padding: 0 24px;'} overflow: scroll;"
2280
+ >
2281
+ ${renderHint(gvc)} ${renderItemList(gvc)} ${renderSummary(gvc)}
2282
+ </div>
2283
+ ${renderFooter(gvc)}
2153
2284
  </div>
2154
- ${renderFooter(gvc)}
2155
- </div>
2156
- `,
2285
+ `;
2286
+ },
2157
2287
  });
2158
2288
  }, 'splitOrder');
2159
2289
  }