ts-glitter 21.0.4 → 21.0.6

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 (164) hide show
  1. package/lowcode/Entry.js +1 -1
  2. package/lowcode/Entry.ts +1 -1
  3. package/lowcode/backend-manager/bg-blog.js +22 -37
  4. package/lowcode/backend-manager/bg-blog.ts +45 -34
  5. package/lowcode/backend-manager/bg-list-component.js +2 -2
  6. package/lowcode/backend-manager/bg-list-component.ts +2 -2
  7. package/lowcode/backend-manager/bg-widget.js +21 -0
  8. package/lowcode/backend-manager/bg-widget.ts +21 -0
  9. package/lowcode/cms-plugin/filter-options.js +3 -3
  10. package/lowcode/cms-plugin/filter-options.ts +1 -1
  11. package/lowcode/cms-plugin/pos-pages/models.ts +1 -0
  12. package/lowcode/cms-plugin/pos-pages/payment-page.js +74 -8
  13. package/lowcode/cms-plugin/pos-pages/payment-page.ts +98 -19
  14. package/lowcode/cms-plugin/product-service.js +2 -1
  15. package/lowcode/cms-plugin/product-service.ts +3 -2
  16. package/lowcode/cms-plugin/shopping-finance-setting.js +251 -6
  17. package/lowcode/cms-plugin/shopping-finance-setting.ts +291 -6
  18. package/lowcode/cms-plugin/shopping-order-manager.js +56 -46
  19. package/lowcode/cms-plugin/shopping-order-manager.ts +59 -47
  20. package/lowcode/cms-plugin/shopping-product-setting.js +10 -5
  21. package/lowcode/cms-plugin/shopping-product-setting.ts +14 -6
  22. package/lowcode/cms-plugin/shopping-setting-advance.js +21 -72
  23. package/lowcode/cms-plugin/shopping-setting-advance.ts +31 -98
  24. package/lowcode/css/editor.css +48 -16
  25. package/lowcode/css/front-end.css +16 -17
  26. package/lowcode/glitter-base/global/language.js +2 -0
  27. package/lowcode/glitter-base/global/language.ts +3 -0
  28. package/lowcode/glitter-base/global/shipment-config.js +4 -4
  29. package/lowcode/glitter-base/global/shipment-config.ts +1 -1
  30. package/lowcode/glitter-base/route/shopping.js +11 -0
  31. package/lowcode/glitter-base/route/shopping.ts +12 -0
  32. package/lowcode/official_view_component/form-widget/input-custom.js +0 -1
  33. package/lowcode/official_view_component/form-widget/input-custom.ts +0 -1
  34. package/lowcode/public-components/checkout/index.js +578 -780
  35. package/lowcode/public-components/checkout/index.ts +2457 -2652
  36. package/lowcode/public-components/headers/header-class.js +252 -324
  37. package/lowcode/public-components/headers/header-class.ts +389 -480
  38. package/lowcode/public-components/modules/cart-module.js +433 -0
  39. package/lowcode/public-components/modules/cart-module.ts +491 -0
  40. package/lowcode/public-components/modules/product-module.js +45 -0
  41. package/lowcode/public-components/modules/product-module.ts +58 -0
  42. package/lowcode/public-components/product/product-detail.js +178 -184
  43. package/lowcode/public-components/product/product-detail.ts +564 -579
  44. package/lowcode/public-components/user-manager/um-order.js +162 -32
  45. package/lowcode/public-components/user-manager/um-order.ts +181 -46
  46. package/lowcode/public-models/product.ts +1 -0
  47. package/package.json +1 -1
  48. package/src/Language.js +1 -0
  49. package/src/Language.js.map +1 -1
  50. package/src/Language.ts +3 -0
  51. package/src/api-public/controllers/article.js +33 -29
  52. package/src/api-public/controllers/article.js.map +1 -1
  53. package/src/api-public/controllers/article.ts +152 -146
  54. package/src/api-public/controllers/index.js +2 -0
  55. package/src/api-public/controllers/index.js.map +1 -1
  56. package/src/api-public/controllers/index.ts +2 -0
  57. package/src/api-public/controllers/shop.js +125 -47
  58. package/src/api-public/controllers/shop.js.map +1 -1
  59. package/src/api-public/controllers/shop.ts +148 -61
  60. package/src/api-public/controllers/user.js +51 -52
  61. package/src/api-public/controllers/user.js.map +1 -1
  62. package/src/api-public/controllers/user.ts +63 -52
  63. package/src/api-public/models/glitter-finance.js +2 -1
  64. package/src/api-public/models/glitter-finance.js.map +5 -1
  65. package/src/api-public/services/checkout-event.d.ts +1 -0
  66. package/src/api-public/services/checkout-event.js +38 -13
  67. package/src/api-public/services/checkout-event.js.map +1 -1
  68. package/src/api-public/services/checkout-event.ts +38 -10
  69. package/src/api-public/services/factories/payment-strategy-factory.d.ts +6 -0
  70. package/src/api-public/services/factories/payment-strategy-factory.js +49 -0
  71. package/src/api-public/services/factories/payment-strategy-factory.js.map +1 -0
  72. package/src/api-public/services/factories/payment-strategy-factory.ts +71 -0
  73. package/src/api-public/services/fb-service.js +4 -4
  74. package/src/api-public/services/fb-service.js.map +1 -1
  75. package/src/api-public/services/financial-service.d.ts +2 -1
  76. package/src/api-public/services/financial-service.js +48 -53
  77. package/src/api-public/services/financial-service.js.map +1 -1
  78. package/src/api-public/services/financial-service.ts +29 -38
  79. package/src/api-public/services/financial-serviceV2.d.ts +298 -0
  80. package/src/api-public/services/financial-serviceV2.js +1158 -0
  81. package/src/api-public/services/financial-serviceV2.js.map +1 -0
  82. package/src/api-public/services/financial-serviceV2.ts +1518 -0
  83. package/src/api-public/services/interface/payment-keys-interface.d.ts +37 -0
  84. package/src/api-public/services/interface/payment-keys-interface.js +3 -0
  85. package/src/api-public/services/interface/payment-keys-interface.js.map +1 -0
  86. package/src/api-public/services/interface/payment-keys-interface.ts +46 -0
  87. package/src/api-public/services/interface/payment-strategy-interface.d.ts +17 -0
  88. package/src/api-public/services/interface/payment-strategy-interface.js +3 -0
  89. package/src/api-public/services/interface/payment-strategy-interface.js.map +1 -0
  90. package/src/api-public/services/interface/payment-strategy-interface.ts +48 -0
  91. package/src/api-public/services/migrate-event/public-user-config.d.ts +5 -0
  92. package/src/api-public/services/migrate-event/public-user-config.js +81 -0
  93. package/src/api-public/services/migrate-event/public-user-config.js.map +1 -0
  94. package/src/api-public/services/migrate-event/public-user-config.ts +106 -0
  95. package/src/api-public/services/model/handlePaymentTransaction.js +0 -68
  96. package/src/api-public/services/model/handlePaymentTransaction.js.map +1 -1
  97. package/src/api-public/services/model/handlePaymentTransaction.ts +62 -54
  98. package/src/api-public/services/monitor.d.ts +1 -0
  99. package/src/api-public/services/payment-service.d.ts +12 -0
  100. package/src/api-public/services/payment-service.js +83 -0
  101. package/src/api-public/services/payment-service.js.map +1 -0
  102. package/src/api-public/services/payment-service.ts +112 -0
  103. package/src/api-public/services/shopping.d.ts +2 -1
  104. package/src/api-public/services/shopping.js +60 -23
  105. package/src/api-public/services/shopping.js.map +1 -1
  106. package/src/api-public/services/shopping.ts +88 -16
  107. package/src/api-public/services/strategies/ecpay-strategy.d.ts +8 -0
  108. package/src/api-public/services/strategies/ecpay-strategy.js +26 -0
  109. package/src/api-public/services/strategies/ecpay-strategy.js.map +1 -0
  110. package/src/api-public/services/strategies/ecpay-strategy.ts +30 -0
  111. package/src/api-public/services/strategies/ezpay-strategy.d.ts +8 -0
  112. package/src/api-public/services/strategies/ezpay-strategy.js +26 -0
  113. package/src/api-public/services/strategies/ezpay-strategy.js.map +1 -0
  114. package/src/api-public/services/strategies/ezpay-strategy.ts +31 -0
  115. package/src/api-public/services/strategies/jkopay-strategy.d.ts +8 -0
  116. package/src/api-public/services/strategies/jkopay-strategy.js +32 -0
  117. package/src/api-public/services/strategies/jkopay-strategy.js.map +1 -0
  118. package/src/api-public/services/strategies/jkopay-strategy.ts +36 -0
  119. package/src/api-public/services/strategies/linepay-strategy.d.ts +8 -0
  120. package/src/api-public/services/strategies/linepay-strategy.js +32 -0
  121. package/src/api-public/services/strategies/linepay-strategy.js.map +1 -0
  122. package/src/api-public/services/strategies/linepay-strategy.ts +35 -0
  123. package/src/api-public/services/strategies/paynow-strategy.d.ts +8 -0
  124. package/src/api-public/services/strategies/paynow-strategy.js +26 -0
  125. package/src/api-public/services/strategies/paynow-strategy.js.map +1 -0
  126. package/src/api-public/services/strategies/paynow-strategy.ts +29 -0
  127. package/src/api-public/services/strategies/paypal-strategy.d.ts +8 -0
  128. package/src/api-public/services/strategies/paypal-strategy.js +28 -0
  129. package/src/api-public/services/strategies/paypal-strategy.js.map +1 -0
  130. package/src/api-public/services/strategies/paypal-strategy.ts +31 -0
  131. package/src/api-public/services/updated-table-checked.d.ts +1 -0
  132. package/src/api-public/services/updated-table-checked.js +37 -15
  133. package/src/api-public/services/updated-table-checked.js.map +1 -1
  134. package/src/api-public/services/updated-table-checked.ts +56 -36
  135. package/src/api-public/utils/ut-permission.d.ts +1 -0
  136. package/src/app-project/serverless/src/index.js +17 -7
  137. package/src/app-project/serverless/src/index.js.map +1 -1
  138. package/src/app-project/serverless/src/modules/CryptoJS.js +17 -7
  139. package/src/app-project/serverless/src/modules/CryptoJS.js.map +1 -1
  140. package/src/app-project/serverless/src/modules/ssh.js +17 -7
  141. package/src/app-project/serverless/src/modules/ssh.js.map +1 -1
  142. package/src/config.d.ts +1 -1
  143. package/src/modules/AWSLib.js +3 -2
  144. package/src/modules/AWSLib.js.map +1 -1
  145. package/src/modules/CryptoJS.js +17 -7
  146. package/src/modules/CryptoJS.js.map +1 -1
  147. package/src/modules/database.d.ts +1 -1
  148. package/src/modules/redis.d.ts +1 -1
  149. package/src/modules/ssh.js +17 -7
  150. package/src/modules/ssh.js.map +1 -1
  151. package/src/modules/tool.d.ts +4 -4
  152. package/src/modules/tool.js +2 -1
  153. package/src/modules/tool.js.map +1 -1
  154. package/src/run.js +2 -1
  155. package/src/run.js.map +1 -1
  156. package/src/services/create-instance.js +4 -3
  157. package/src/services/create-instance.js.map +1 -1
  158. package/src/services/saas-table-check.js +2 -2
  159. package/src/services/saas-table-check.js.map +5 -1
  160. package/src/services/tool.js +3 -2
  161. package/src/services/tool.js.map +1 -1
  162. package/vp00rqhw1r.json +1 -0
  163. package/src/api-public/services/product-migrate.d.ts +0 -8
  164. package/src/api-public/services/product-migrate.js.map +0 -1
@@ -402,25 +402,32 @@ export class ShoppingOrderManager {
402
402
  ),
403
403
  ];
404
404
 
405
+ function cartTokenComponent(cart_token: any, source_badge: string, is_watch_user: boolean) {
406
+ return html`<div style="min-width:200px;">
407
+ <div style="position: relative; height: 40px;">
408
+ <div
409
+ style="position: absolute; bottom: 9px; height: 9px; width: 127px; ${is_watch_user
410
+ ? 'background-color: #ffe9b2'
411
+ : ''}"
412
+ ></div>
413
+ <span style="position: absolute; bottom: 0;">${cart_token}${source_badge}</span>
414
+ </div>
415
+ </div>`;
416
+ }
417
+
405
418
  return data.response.data.map((dd: any) => {
406
419
  const vt = OrderSetting.getAllStatusBadge(dd);
407
420
  dd.orderData.total = dd.orderData.total || 0;
408
421
  dd.orderData.customer_info = dd.orderData.customer_info ?? {};
409
422
 
410
423
  const isWatchUser = watchUsers.includes(dd.orderData.email);
411
- const backgroundColor = isWatchUser ? `background-color: #ffe9b2` : '';
412
424
  const tooltipText = isWatchUser ? '此份訂單的顧客為觀察名單' : '';
413
425
 
414
426
  if (query.isShipment) {
415
427
  return [
416
428
  {
417
429
  key: '訂單編號',
418
- value: html` <div
419
- class="d-flex align-items-center gap-2"
420
- style="min-width: 200px; ${backgroundColor}"
421
- >
422
- ${dd.cart_token}${vt.sourceBadge()}
423
- </div>`,
430
+ value: cartTokenComponent(dd.cart_token, vt.sourceBadge(), isWatchUser),
424
431
  tooltip: tooltipText,
425
432
  },
426
433
  {
@@ -449,12 +456,7 @@ export class ShoppingOrderManager {
449
456
  return [
450
457
  {
451
458
  key: '訂單編號',
452
- value: html` <div
453
- class="d-flex align-items-center gap-2"
454
- style="min-width: 200px; ${backgroundColor}"
455
- >
456
- ${dd.cart_token}${vt.sourceBadge()}
457
- </div>`,
459
+ value: cartTokenComponent(dd.cart_token, vt.sourceBadge(), isWatchUser),
458
460
  tooltip: tooltipText,
459
461
  },
460
462
  {
@@ -1738,19 +1740,21 @@ export class ShoppingOrderManager {
1738
1740
  ['姓名', 'name'],
1739
1741
  ['電話', 'phone'],
1740
1742
  ['信箱', 'email'],
1743
+ ['縣市', 'city'],
1744
+ ['鄉鎮', 'area'],
1745
+ ['地址', 'address'],
1741
1746
  ];
1747
+
1742
1748
  const receipt = (
1743
1749
  await ApiUser.getPublicConfig('custom_form_checkout_recipient', 'manager')
1744
1750
  ).response.value;
1751
+
1745
1752
  receipt.list.map((d1: any) => {
1746
- if (
1747
- !viewModel.find(dd => {
1748
- return dd[1] === d1.key;
1749
- })
1750
- ) {
1753
+ if (!viewModel.find(dd => dd[1] === d1.key)) {
1751
1754
  viewModel.push([d1.title, d1.key]);
1752
1755
  }
1753
1756
  });
1757
+
1754
1758
  if (vm.mode == 'read') {
1755
1759
  return viewModel
1756
1760
  .map(item => {
@@ -2865,7 +2869,7 @@ export class ShoppingOrderManager {
2865
2869
  html` <div class="d-flex flex-column" style="gap:8px;">
2866
2870
  <div
2867
2871
  class="d-flex align-items-center"
2868
- style="font-weight: 700; gap:8px;cursor:pointer;"
2872
+ style="gap: 8px; cursor: pointer;"
2869
2873
  onclick="${gvc.event(() => {
2870
2874
  if (userData.userID) {
2871
2875
  child_vm.userID = userData.userID;
@@ -2873,30 +2877,43 @@ export class ShoppingOrderManager {
2873
2877
  }
2874
2878
  })}"
2875
2879
  >
2876
- ${(() => {
2877
- const name = userData?.userData?.name;
2878
- if (name) {
2879
- return html`<span style="color: #4D86DB;">${name}</span>`;
2880
- }
2881
- return html`<span style="color: #393939;">訪客</span>`;
2882
- })()}
2883
- ${(() => {
2884
- if (userDataLoading) {
2885
- return BgWidget.secondaryInsignia('讀取中');
2886
- }
2887
- if (userData.member == undefined) {
2888
- return BgWidget.secondaryInsignia('訪客');
2889
- }
2890
- if (userData?.member.length > 0) {
2891
- for (let i = 0; i < userData.member.length; i++) {
2892
- if (userData.member[i].trigger) {
2893
- return BgWidget.primaryInsignia(userData.member[i].tag_name);
2880
+ ${[
2881
+ (() => {
2882
+ const name = userData?.userData?.name;
2883
+ if (name) {
2884
+ return html`<span style="font-weight: 500; color: #4D86DB;">${name}</span>`;
2885
+ }
2886
+ return html`<span style="font-weight: normal; color: #393939;">訪客</span>`;
2887
+ })(),
2888
+ (() => {
2889
+ if (userData.status === 0) {
2890
+ return '';
2891
+ }
2892
+ if (userDataLoading) {
2893
+ return BgWidget.grayInsignia('讀取中');
2894
+ }
2895
+ if (userData.member === undefined) {
2896
+ return BgWidget.grayInsignia('訪客');
2897
+ }
2898
+ if (userData?.member.length > 0) {
2899
+ for (let i = 0; i < userData.member.length; i++) {
2900
+ if (userData.member[i].trigger) {
2901
+ return BgWidget.darkInsignia(userData.member[i].tag_name);
2902
+ }
2894
2903
  }
2895
2904
  }
2896
- return BgWidget.primaryInsignia('一般會員');
2897
- }
2898
- return BgWidget.secondaryInsignia('訪客');
2899
- })()}
2905
+ return BgWidget.darkInsignia('一般會員');
2906
+ })(),
2907
+ (() => {
2908
+ if (userData.status === 0) {
2909
+ return BgWidget.dangerInsignia('黑名單');
2910
+ }
2911
+ if (userData.status === 2) {
2912
+ return BgWidget.watchingInsignia('觀察名單');
2913
+ }
2914
+ return '';
2915
+ })(),
2916
+ ].join('')}
2900
2917
  </div>
2901
2918
  <div style="color: #393939;font-weight: 400;">
2902
2919
  ${userData?.userData?.phone ??
@@ -2906,9 +2923,6 @@ export class ShoppingOrderManager {
2906
2923
  <div style="color: #393939;font-weight: 400;word-break:break-all;">
2907
2924
  ${userData?.userData?.email ?? orderData.orderData.user_info.email ?? ''}
2908
2925
  </div>
2909
- <div style="color: #393939;font-weight: 700;">
2910
- ${userData.status === 2 ? '* 此顧客列為觀察名單' : ''}
2911
- </div>
2912
2926
  </div>`,
2913
2927
  BgWidget.horizontalLine(),
2914
2928
  gvc.bindView({
@@ -3020,9 +3034,7 @@ export class ShoppingOrderManager {
3020
3034
  orderData.orderData.user_info.area,
3021
3035
  orderData.orderData.user_info.address,
3022
3036
  ]
3023
- .filter(dd => {
3024
- return dd;
3025
- })
3037
+ .filter(Boolean)
3026
3038
  .join('')}
3027
3039
  </div>`
3028
3040
  );
@@ -297,12 +297,17 @@ export class ShoppingProductSetting {
297
297
  }
298
298
  });
299
299
  if (countStock == 0) {
300
- return html ` 無追蹤庫存 `;
300
+ return '無追蹤庫存';
301
301
  }
302
- return html `${countStock}個子類
303
- ${sum > 1
304
- ? `有${sum}件庫存`
305
- : html ` <span style="color:#8E0E2B">有${sum} 件庫存</span>`}`;
302
+ const countStockText = countStock > 1 ? `${countStock} 個子類` : '';
303
+ const stockText = html ` <span
304
+ style="${sum > 1
305
+ ? 'color: #393939'
306
+ : 'color: #8E0E2B; font-weight: 500;'}"
307
+ >
308
+ 庫存 ${sum.toLocaleString()} 件</span
309
+ >`;
310
+ return `${countStockText}${stockText}`;
306
311
  })(),
307
312
  },
308
313
  {
@@ -345,20 +345,28 @@ export class ShoppingProductSetting {
345
345
  value: (() => {
346
346
  let sum = 0;
347
347
  let countStock = 0;
348
+
348
349
  dd.content.variants.forEach((variant: any) => {
349
350
  if (variant.show_understocking == 'true') {
350
351
  countStock++;
351
352
  sum += variant.stock;
352
353
  }
353
354
  });
354
- // const sum = dd.content.variants.reduce((acc: any, curr: any) => acc + curr.stock, 0);
355
+
355
356
  if (countStock == 0) {
356
- return html` 無追蹤庫存 `;
357
+ return '無追蹤庫存';
357
358
  }
358
- return html`${countStock}個子類
359
- ${sum > 1
360
- ? `有${sum}件庫存`
361
- : html` <span style="color:#8E0E2B">有${sum} 件庫存</span>`}`;
359
+
360
+ const countStockText = countStock > 1 ? `${countStock} 個子類` : '';
361
+ const stockText = html` <span
362
+ style="${sum > 1
363
+ ? 'color: #393939'
364
+ : 'color: #8E0E2B; font-weight: 500;'}"
365
+ >
366
+ 庫存 ${sum.toLocaleString()} 件</span
367
+ >`;
368
+
369
+ return `${countStockText}${stockText}`;
362
370
  })(),
363
371
  },
364
372
  {
@@ -9,9 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { BgWidget } from '../backend-manager/bg-widget.js';
11
11
  import { BgProduct } from '../backend-manager/bg-product.js';
12
- import { ApiPageConfig } from '../api/pageConfig.js';
13
12
  import { ApiUser } from '../glitter-base/route/user.js';
14
- import { ShipmentConfig } from '../glitter-base/global/shipment-config.js';
15
13
  import { QuestionInfo } from './module/question-info.js';
16
14
  import { Tool } from '../modules/tool.js';
17
15
  const html = String.raw;
@@ -753,7 +751,7 @@ export class ShoppingSettingAdvance {
753
751
  var _a;
754
752
  let loading = true;
755
753
  let dataList = [];
756
- postMD.designated_logistics = (_a = postMD.designated_logistics) !== null && _a !== void 0 ? _a : { type: 'all', list: [] };
754
+ postMD.designated_logistics = (_a = postMD.designated_logistics) !== null && _a !== void 0 ? _a : { group: '' };
757
755
  return {
758
756
  bind: 'designatedLogistics',
759
757
  view: () => {
@@ -785,79 +783,30 @@ export class ShoppingSettingAdvance {
785
783
  key: 'designated',
786
784
  value: '指定物流',
787
785
  },
788
- ],
786
+ ].filter(item => {
787
+ return !(item.key === 'designated' && dataList.length === 0);
788
+ }),
789
789
  style: 'width: 100%;',
790
790
  })}
791
791
  <div>
792
792
  ${(() => {
793
793
  switch (postMD.designated_logistics.type) {
794
794
  case 'designated':
795
- return (() => {
796
- const designatedVM = {
797
- id: gvc.glitter.getUUID(),
798
- loading: true,
799
- dataList: [],
800
- };
801
- return gvc.bindView({
802
- bind: designatedVM.id,
803
- view: () => {
804
- var _a;
805
- if (designatedVM.loading) {
806
- return BgWidget.spinner({ text: { visible: false } });
807
- }
808
- else {
809
- return BgWidget.selectDropList({
810
- gvc: gvc,
811
- callback: (value) => {
812
- postMD.designated_logistics.list = value;
813
- gvc.notifyDataChange(id);
814
- },
815
- default: (_a = postMD.designated_logistics.list) !== null && _a !== void 0 ? _a : [],
816
- options: designatedVM.dataList,
817
- style: 'width: 100%;',
818
- });
819
- }
820
- },
821
- divCreate: {
822
- style: 'width: 100%;',
823
- },
824
- onCreate: () => {
825
- if (designatedVM.loading) {
826
- ApiPageConfig.getPrivateConfig(window.parent.appName, 'logistics_setting')
827
- .then((dd) => {
828
- var _a;
829
- if (!dd.result || !dd.response.result[0]) {
830
- throw new Error('Failed to fetch logistics setting or empty result.');
831
- }
832
- const shipment_setting = dd.response.result[0].value;
833
- const combinedList = [
834
- ...ShipmentConfig.list.map(dd => ({
835
- name: dd.title,
836
- value: dd.value,
837
- })),
838
- ...((_a = shipment_setting.custom_delivery) !== null && _a !== void 0 ? _a : []).map((dd) => ({
839
- form: dd.form,
840
- name: dd.name,
841
- value: dd.id,
842
- })),
843
- ];
844
- const supportedList = combinedList.filter(d1 => shipment_setting.support.some((d2) => d2 === d1.value));
845
- designatedVM.dataList = supportedList.map(item => ({
846
- key: item.value,
847
- value: item.name,
848
- }));
849
- designatedVM.loading = false;
850
- gvc.notifyDataChange(designatedVM.id);
851
- })
852
- .catch(error => {
853
- console.error('Error fetching logistics setting:', error);
854
- designatedVM.loading = false;
855
- gvc.notifyDataChange(designatedVM.id);
856
- });
857
- }
858
- },
859
- });
860
- })();
795
+ return BgWidget.selectDropList({
796
+ gvc: gvc,
797
+ callback: (value) => {
798
+ postMD.designated_logistics.group = value;
799
+ gvc.notifyDataChange(id);
800
+ },
801
+ default: postMD.designated_logistics.group || [],
802
+ options: dataList.map((data) => {
803
+ return {
804
+ key: data.key,
805
+ value: data.name,
806
+ };
807
+ }),
808
+ style: 'width: 100%;',
809
+ });
861
810
  default:
862
811
  return '';
863
812
  }
@@ -871,10 +820,10 @@ export class ShoppingSettingAdvance {
871
820
  },
872
821
  onCreate: () => {
873
822
  if (loading) {
874
- ApiPageConfig.getPrivateConfig(window.parent.appName, 'glitter_delivery').then(res => {
823
+ ApiUser.getPublicConfig('logistics_group', 'manager').then(r => {
875
824
  dataList = (() => {
876
825
  try {
877
- return res.response.result[0].value;
826
+ return r.response.value;
878
827
  }
879
828
  catch (error) {
880
829
  return dataList;
@@ -1,10 +1,8 @@
1
1
  import { GVC } from '../glitterBundle/GVController.js';
2
2
  import { BgWidget } from '../backend-manager/bg-widget.js';
3
3
  import { BgProduct, OptionsItem } from '../backend-manager/bg-product.js';
4
- import { ApiPageConfig } from '../api/pageConfig.js';
5
4
  import { ApiUser } from '../glitter-base/route/user.js';
6
5
  import { LanguageLocation } from '../glitter-base/global/language.js';
7
- import { ShipmentConfig } from '../glitter-base/global/shipment-config.js';
8
6
  import { QuestionInfo } from './module/question-info.js';
9
7
  import { Tool } from '../modules/tool.js';
10
8
  import { Product, MultiSaleType } from '../public-models/product.js';
@@ -828,7 +826,8 @@ export class ShoppingSettingAdvance {
828
826
  obj.gvc.bindView(() => {
829
827
  let loading = true;
830
828
  let dataList: any = [];
831
- postMD.designated_logistics = postMD.designated_logistics ?? { type: 'all', list: [] };
829
+ postMD.designated_logistics = postMD.designated_logistics ?? { group: '' };
830
+
832
831
  return {
833
832
  bind: 'designatedLogistics',
834
833
  view: () => {
@@ -860,94 +859,30 @@ export class ShoppingSettingAdvance {
860
859
  key: 'designated',
861
860
  value: '指定物流',
862
861
  },
863
- ],
862
+ ].filter(item => {
863
+ return !(item.key === 'designated' && dataList.length === 0);
864
+ }),
864
865
  style: 'width: 100%;',
865
866
  })}
866
867
  <div>
867
868
  ${(() => {
868
869
  switch (postMD.designated_logistics.type) {
869
870
  case 'designated':
870
- return (() => {
871
- const designatedVM = {
872
- id: gvc.glitter.getUUID(),
873
- loading: true,
874
- dataList: [] as any,
875
- };
876
- return gvc.bindView({
877
- bind: designatedVM.id,
878
- view: () => {
879
- if (designatedVM.loading) {
880
- return BgWidget.spinner({ text: { visible: false } });
881
- } else {
882
- return BgWidget.selectDropList({
883
- gvc: gvc,
884
- callback: (value: []) => {
885
- postMD.designated_logistics.list = value;
886
- gvc.notifyDataChange(id);
887
- },
888
- default: postMD.designated_logistics.list ?? [],
889
- options: designatedVM.dataList,
890
- style: 'width: 100%;',
891
- });
892
- }
893
- },
894
- divCreate: {
895
- style: 'width: 100%;',
896
- },
897
- onCreate: () => {
898
- if (designatedVM.loading) {
899
- ApiPageConfig.getPrivateConfig(
900
- (window.parent as any).appName,
901
- 'logistics_setting'
902
- )
903
- .then((dd: any) => {
904
- if (!dd.result || !dd.response.result[0]) {
905
- throw new Error(
906
- 'Failed to fetch logistics setting or empty result.'
907
- );
908
- }
909
-
910
- const shipment_setting = dd.response.result[0].value;
911
-
912
- // 合併 ShipmentConfig.list 和 shipment_setting.custom_delivery
913
- const combinedList = [
914
- ...ShipmentConfig.list.map(dd => ({
915
- name: dd.title,
916
- value: dd.value,
917
- })),
918
- ...(shipment_setting.custom_delivery ?? []).map(
919
- (dd: any) => ({
920
- form: dd.form,
921
- name: dd.name,
922
- value: dd.id,
923
- })
924
- ),
925
- ];
926
-
927
- // 過濾出 shipment_setting.support 中支援的項目
928
- const supportedList = combinedList.filter(d1 =>
929
- shipment_setting.support.some((d2: any) => d2 === d1.value)
930
- );
931
-
932
- // 轉換為 designatedVM.dataList 所需的格式
933
- designatedVM.dataList = supportedList.map(item => ({
934
- key: item.value,
935
- value: item.name,
936
- }));
937
-
938
- // 更新狀態並通知資料變更
939
- designatedVM.loading = false;
940
- gvc.notifyDataChange(designatedVM.id);
941
- })
942
- .catch(error => {
943
- console.error('Error fetching logistics setting:', error);
944
- designatedVM.loading = false;
945
- gvc.notifyDataChange(designatedVM.id);
946
- });
947
- }
948
- },
949
- });
950
- })();
871
+ return BgWidget.selectDropList({
872
+ gvc: gvc,
873
+ callback: (value: []) => {
874
+ postMD.designated_logistics.group = value;
875
+ gvc.notifyDataChange(id);
876
+ },
877
+ default: postMD.designated_logistics.group || [],
878
+ options: dataList.map((data: any) => {
879
+ return {
880
+ key: data.key,
881
+ value: data.name,
882
+ };
883
+ }),
884
+ style: 'width: 100%;',
885
+ });
951
886
  default:
952
887
  return '';
953
888
  }
@@ -961,19 +896,17 @@ export class ShoppingSettingAdvance {
961
896
  },
962
897
  onCreate: () => {
963
898
  if (loading) {
964
- ApiPageConfig.getPrivateConfig((window.parent as any).appName, 'glitter_delivery').then(
965
- res => {
966
- dataList = (() => {
967
- try {
968
- return res.response.result[0].value;
969
- } catch (error) {
970
- return dataList;
971
- }
972
- })();
973
- loading = false;
974
- gvc.notifyDataChange('designatedLogistics');
975
- }
976
- );
899
+ ApiUser.getPublicConfig('logistics_group', 'manager').then(r => {
900
+ dataList = (() => {
901
+ try {
902
+ return r.response.value;
903
+ } catch (error) {
904
+ return dataList;
905
+ }
906
+ })();
907
+ loading = false;
908
+ gvc.notifyDataChange('designatedLogistics');
909
+ });
977
910
  }
978
911
  },
979
912
  };