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
@@ -202,10 +202,10 @@ export class PaymentPage {
202
202
  ${(() => {
203
203
  if (orderDetail.lineItems.length > 0) {
204
204
  return orderDetail.lineItems
205
- .map((data: any) => {
205
+ .map((data: any, index: number) => {
206
206
  return html`
207
207
  <div class="d-flex" style="">
208
- <div class="col-9 col-sm-6 d-flex align-items-center">
208
+ <div class="col-12 col-sm-6 d-flex align-items-center">
209
209
  <div
210
210
  class="d-flex flex-column align-items-center justify-content-center"
211
211
  style="gap:5px;width:75px;"
@@ -233,7 +233,16 @@ export class PaymentPage {
233
233
  </div>
234
234
  </div>
235
235
  <div
236
- class="d-flex flex-column py-2"
236
+ class="d-flex flex-column py-2" onclick="${gvc.event(() => {
237
+ PosFunction.setMoney(
238
+ gvc,
239
+ count => {
240
+ obj.ogOrderData.lineItems[index].count = count;
241
+ refreshOrderView();
242
+ },
243
+ '更改商品數量'
244
+ );
245
+ })}"
237
246
  style="font-size: 16px;font-style: normal;font-weight: 500;letter-spacing: 0.64px;margin-left: 12px;"
238
247
  >
239
248
  <div class="d-flex justify-content-center flex-column" style="gap:5px;">
@@ -241,7 +250,7 @@ export class PaymentPage {
241
250
  if (!data.pre_order) {
242
251
  return ``;
243
252
  } else {
244
- return html`<div>${BgWidget.dangerInsignia('需預購')}</div>`;
253
+ return html` <div>${BgWidget.dangerInsignia('需預購')}</div>`;
245
254
  }
246
255
  })()}
247
256
  ${data.title}
@@ -269,15 +278,86 @@ export class PaymentPage {
269
278
  </div>`
270
279
  : ``}
271
280
  </div>
281
+ <div class="flex-fill"></div>
282
+ <div class="d-sm-none d-flex align-items-center justify-content-center flex-column" style="gap:0px;" onclick="${gvc.event(()=>{
283
+ PosFunction.setMoney(
284
+ gvc,
285
+ money => {
286
+ if (money === data.sale_price) {
287
+ delete obj.ogOrderData.lineItems[index].custom_price;
288
+ } else {
289
+ obj.ogOrderData.lineItems[index].custom_price = money;
290
+ }
291
+ refreshOrderView();
292
+ },
293
+ '更改商品單價'
294
+ )
295
+ })}">
296
+ ${(data.sale_price !== data.variant_sale_price) ? `
297
+ <span class="text-decoration-line-through"
298
+ >$${parseInt((data.variant_sale_price * data.count) as any, 10).toLocaleString()}</span
299
+ >
300
+ <span class="text-danger"
301
+ >$${parseInt((data.sale_price * data.count) as any, 10).toLocaleString()}</span
302
+ >
303
+ `:`
304
+ <span
305
+ >$${parseInt((data.sale_price * data.count) as any, 10).toLocaleString()}</span
306
+ >
307
+ `}
308
+
309
+ </div>
272
310
  </div>
273
311
  <div class="col-2 d-none d-sm-flex align-items-center justify-content-start">
274
312
  $${parseInt(data.sale_price as any, 10).toLocaleString()}
275
313
  </div>
276
- <div class="col-3 col-lg-2 d-flex align-items-center justify-content-center">
314
+ <div
315
+ class="col-3 col-lg-2 d-flex align-items-center justify-content-center d-none d-sm-flex"
316
+ style="gap:10px;cursor: pointer;"
317
+ onclick="${gvc.event(() => {
318
+ PosFunction.setMoney(
319
+ gvc,
320
+ count => {
321
+ obj.ogOrderData.lineItems[index].count = count;
322
+ refreshOrderView();
323
+ },
324
+ '更改商品數量'
325
+ );
326
+ })}"
327
+ >
277
328
  ${Number(data.count as any).toLocaleString()}
278
329
  </div>
279
- <div class="col-3 col-lg-2 d-flex align-items-center justify-content-center">
280
- $${parseInt((data.sale_price * data.count) as any, 10).toLocaleString()}
330
+ <div
331
+ class="col-3 col-lg-2 d-flex align-items-center justify-content-center d-none d-sm-flex"
332
+ style="gap:10px;cursor: pointer;"
333
+ onclick="${gvc.event(() => {
334
+ PosFunction.setMoney(
335
+ gvc,
336
+ money => {
337
+ if (money === data.sale_price) {
338
+ delete obj.ogOrderData.lineItems[index].custom_price;
339
+ } else {
340
+ obj.ogOrderData.lineItems[index].custom_price = money;
341
+ }
342
+ refreshOrderView();
343
+ },
344
+ '更改商品單價'
345
+ );
346
+ })}"
347
+ >
348
+ ${(data.sale_price !== data.variant_sale_price) ? `
349
+ <span class="text-decoration-line-through"
350
+ >$${parseInt((data.variant_sale_price * data.count) as any, 10).toLocaleString()}</span
351
+ >
352
+ <span class="text-danger"
353
+ >$${parseInt((data.sale_price * data.count) as any, 10).toLocaleString()}</span
354
+ >
355
+ `:`
356
+ <span
357
+ >$${parseInt((data.sale_price * data.count) as any, 10).toLocaleString()}</span
358
+ >
359
+ `}
360
+
281
361
  </div>
282
362
  </div>
283
363
  `;
@@ -2075,25 +2155,24 @@ export class PaymentPage {
2075
2155
  PayConfig.pos_config.pos_support_finction.includes('print_order_receipt') ||
2076
2156
  PayConfig.pos_config.pos_support_finction.includes('print_order_detail')
2077
2157
  ) {
2078
-
2079
2158
  if (PayConfig.deviceType === 'pos') {
2080
2159
  //客戶聯
2081
- await IminModule.printTransactionDetails(res.response.data.orderID,invoice,glitter.share.staff_title);
2160
+ await IminModule.printTransactionDetails(res.response.data.orderID, invoice, glitter.share.staff_title);
2082
2161
  //如果需要收執聯的話
2083
- if(
2162
+ if (
2084
2163
  PayConfig.pos_config.pos_support_finction.includes('print_order_receipt') &&
2085
2164
  PayConfig.pos_config.pos_support_finction.includes('print_order_detail')
2086
- ){
2165
+ ) {
2087
2166
  await new Promise(resolve => {
2088
- const dialog=new ShareDialog(glitter)
2167
+ const dialog = new ShareDialog(glitter);
2089
2168
  dialog.infoMessage({
2090
- text:'請撕取客戶聯,在列印留存聯',
2091
- callback:()=>{
2092
- resolve(true)
2093
- }
2094
- })
2095
- })
2096
- await IminModule.printTransactionDetails(res.response.data.orderID,invoice,glitter.share.staff_title);
2169
+ text: '請撕取客戶聯,在列印留存聯',
2170
+ callback: () => {
2171
+ resolve(true);
2172
+ },
2173
+ });
2174
+ });
2175
+ await IminModule.printTransactionDetails(res.response.data.orderID, invoice, glitter.share.staff_title);
2097
2176
  }
2098
2177
  } else {
2099
2178
  ConnectionMode.sendCommand({
@@ -58,10 +58,11 @@ export class ProductService {
58
58
  {
59
59
  check: (data) => !data.seo.domain,
60
60
  errorMessage: '未設定商品連結',
61
- },
61
+ }
62
62
  ];
63
63
  for (const languageCode of supportedLanguages) {
64
64
  const currentLanguageData = languageData[languageCode];
65
+ currentLanguageData.seo.domain = currentLanguageData.seo.domain.replace(/\+/g, '');
65
66
  for (const rule of validationRules) {
66
67
  if (rule.check(currentLanguageData)) {
67
68
  vm.language = languageCode;
@@ -67,7 +67,7 @@ export class ProductService {
67
67
  {
68
68
  check: (data: LanguageData) => !data.seo.domain,
69
69
  errorMessage: '未設定商品連結',
70
- },
70
+ }
71
71
  // {
72
72
  // check: (data: LanguageData) => !CheckInput.isChineseEnglishNumberHyphen(data.seo.domain),
73
73
  // errorMessage: '連結僅限使用中英文數字與連接號',
@@ -77,8 +77,9 @@ export class ProductService {
77
77
  // 遍歷支持的語言並進行驗證
78
78
  for (const languageCode of supportedLanguages) {
79
79
  const currentLanguageData = languageData[languageCode];
80
-
80
+ currentLanguageData.seo.domain = currentLanguageData.seo.domain.replace(/\+/g, '');
81
81
  for (const rule of validationRules) {
82
+
82
83
  if (rule.check(currentLanguageData)) {
83
84
  vm.language = languageCode;
84
85
  refresh();
@@ -7,20 +7,21 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { BgWidget } from '../backend-manager/bg-widget.js';
11
10
  import { EditorElem } from '../glitterBundle/plugins/editor-elem.js';
12
11
  import { ShareDialog } from '../glitterBundle/dialog/ShareDialog.js';
13
- import { ApiPageConfig } from '../api/pageConfig.js';
12
+ import { BgWidget } from '../backend-manager/bg-widget.js';
14
13
  import { CheckInput } from '../modules/checkInput.js';
15
- import { LanguageBackend } from './language-backend.js';
16
14
  import { Tool } from '../modules/tool.js';
17
- import { ProductAi } from './ai-generator/product-ai.js';
18
15
  import { imageLibrary } from '../modules/image-library.js';
16
+ import { LanguageBackend } from './language-backend.js';
17
+ import { ProductAi } from './ai-generator/product-ai.js';
18
+ import { ApiPageConfig } from '../api/pageConfig.js';
19
19
  import { Language } from '../glitter-base/global/language.js';
20
- import { ShoppingShipmentSetting } from './shopping-shipment-setting.js';
21
- import { ShipmentConfig } from '../glitter-base/global/shipment-config.js';
22
20
  import { ApiUser } from '../glitter-base/route/user.js';
21
+ import { ApiShop } from '../glitter-base/route/shopping.js';
23
22
  import { PaymentConfig } from '../glitter-base/global/payment-config.js';
23
+ import { ShipmentConfig } from '../glitter-base/global/shipment-config.js';
24
+ import { ShoppingShipmentSetting } from './shopping-shipment-setting.js';
24
25
  const html = String.raw;
25
26
  export class ShoppingFinanceSetting {
26
27
  static main(gvc, pos) {
@@ -552,6 +553,11 @@ export class ShoppingFinanceSetting {
552
553
  gvc.closeDialog();
553
554
  })),
554
555
  BgWidget.save(gvc.event(() => {
556
+ if (payData.key == "ecPay" && key_d.ActionURL == "https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5") {
557
+ key_d.MERCHANT_ID = "3002607";
558
+ key_d.HASH_KEY = "pwFHCqoQZGmho4w6";
559
+ key_d.HASH_IV = "EkRm7iFT261dpevs";
560
+ }
555
561
  keyData[payData.key] = key_d;
556
562
  saveData();
557
563
  gvc.closeDialog();
@@ -1537,6 +1543,7 @@ export class ShoppingFinanceSetting {
1537
1543
  BgWidget.tab([
1538
1544
  { title: '基本設定', key: 'delivery_setting' },
1539
1545
  { title: '物流追蹤', key: 'delivery_track' },
1546
+ { title: '物流群組', key: 'delivery_group' },
1540
1547
  { title: '配送備註', key: 'delivery_note' },
1541
1548
  ], gvc, vm.page, text => {
1542
1549
  vm.page = text;
@@ -2608,6 +2615,244 @@ export class ShoppingFinanceSetting {
2608
2615
  }),
2609
2616
  ]);
2610
2617
  }
2618
+ else if (vm.page === 'delivery_group') {
2619
+ const dvm = {
2620
+ id: gvc.glitter.getUUID(),
2621
+ loading: true,
2622
+ dataList: [],
2623
+ };
2624
+ function updateGroup(dialogGVC) {
2625
+ dialog.dataLoading({ visible: true });
2626
+ setTimeout(() => {
2627
+ ApiUser.setPublicConfig({
2628
+ user_id: 'manager',
2629
+ key: 'logistics_group',
2630
+ value: dvm.dataList,
2631
+ }).then(() => {
2632
+ dialog.dataLoading({ visible: false });
2633
+ dialog.successMessage({ text: '設定成功' });
2634
+ dialogGVC.closeDialog();
2635
+ dvm.loading = true;
2636
+ gvc.notifyDataChange(dvm.id);
2637
+ });
2638
+ }, 100);
2639
+ }
2640
+ function deleteProductLogisticGroup(group, callback) {
2641
+ if (group) {
2642
+ ApiShop.deleteProductLogistic({ group }).then(() => callback());
2643
+ }
2644
+ }
2645
+ function editGroupDialog(item) {
2646
+ const cloneData = structuredClone(item);
2647
+ const postData = item
2648
+ ? structuredClone(item)
2649
+ : {
2650
+ key: Tool.randomString(8),
2651
+ name: '',
2652
+ list: [],
2653
+ };
2654
+ return BgWidget.settingDialog({
2655
+ gvc,
2656
+ title: '設定群組',
2657
+ innerHTML: iGVC => {
2658
+ const id = iGVC.glitter.getUUID();
2659
+ let loading = true;
2660
+ let dataList = [];
2661
+ return iGVC.bindView({
2662
+ bind: id,
2663
+ view: () => {
2664
+ if (loading) {
2665
+ return BgWidget.spinner();
2666
+ }
2667
+ return [
2668
+ html `<div class="tx_700">群組名稱</div>`,
2669
+ BgWidget.editeInput({
2670
+ gvc: iGVC,
2671
+ title: '',
2672
+ default: postData.name,
2673
+ placeHolder: '請輸入群組名稱',
2674
+ callback: value => {
2675
+ postData.name = value;
2676
+ },
2677
+ }),
2678
+ html `<div class="tx_700">包含的物流</div>`,
2679
+ BgWidget.multiCheckboxContainer(iGVC, dataList, postData.list, text => {
2680
+ postData.list = text;
2681
+ }, { single: false }),
2682
+ ].join(BgWidget.mbContainer(12));
2683
+ },
2684
+ onCreate: () => {
2685
+ if (loading) {
2686
+ ApiPageConfig.getPrivateConfig(window.parent.appName, 'logistics_setting').then((dd) => {
2687
+ var _a;
2688
+ if (dd.result && dd.response.result[0]) {
2689
+ const shipment_setting = dd.response.result[0].value;
2690
+ const combinedList = [
2691
+ ...ShipmentConfig.list.map(dd => ({
2692
+ name: dd.title,
2693
+ value: dd.value,
2694
+ })),
2695
+ ...((_a = shipment_setting.custom_delivery) !== null && _a !== void 0 ? _a : []).map((dd) => ({
2696
+ form: dd.form,
2697
+ name: dd.name,
2698
+ value: dd.id,
2699
+ })),
2700
+ ];
2701
+ const supportedList = combinedList.filter(d1 => shipment_setting.support.some((d2) => d2 === d1.value));
2702
+ dataList = supportedList.map(data => ({
2703
+ key: data.value,
2704
+ name: data.name,
2705
+ }));
2706
+ }
2707
+ loading = false;
2708
+ iGVC.notifyDataChange(id);
2709
+ });
2710
+ }
2711
+ },
2712
+ });
2713
+ },
2714
+ footer_html: fGVC => {
2715
+ return [
2716
+ item
2717
+ ? BgWidget.danger(fGVC.event(() => {
2718
+ dialog.checkYesOrNot({
2719
+ text: '若刪除此群組,有使用到此群組的商品將會改成全部物流皆可使用,確定要刪除此物流群組?',
2720
+ callback: bool => {
2721
+ if (bool) {
2722
+ dvm.dataList = dvm.dataList.filter(data => data.key !== (item === null || item === void 0 ? void 0 : item.key));
2723
+ deleteProductLogisticGroup(item === null || item === void 0 ? void 0 : item.key, () => updateGroup(fGVC));
2724
+ }
2725
+ },
2726
+ });
2727
+ }))
2728
+ : '',
2729
+ BgWidget.cancel(fGVC.event(() => {
2730
+ if (item) {
2731
+ item = cloneData;
2732
+ }
2733
+ fGVC.closeDialog();
2734
+ })),
2735
+ BgWidget.save(fGVC.event(() => {
2736
+ for (const data of dvm.dataList) {
2737
+ if (data.key !== postData.key) {
2738
+ if (data.name === postData.name) {
2739
+ dialog.infoMessage({ text: `群組名「${postData.name}」已經存在` });
2740
+ return;
2741
+ }
2742
+ if (Tool.ObjCompare(postData.list, data.list)) {
2743
+ dialog.infoMessage({ text: '此群組的物流組合已經存在,請調整您點選的物流' });
2744
+ return;
2745
+ }
2746
+ if (postData.list.length === 0) {
2747
+ dialog.infoMessage({ text: '請勾選至少一種物流的組合' });
2748
+ return;
2749
+ }
2750
+ }
2751
+ }
2752
+ if (item) {
2753
+ const target = dvm.dataList.find(data => data.key === (item === null || item === void 0 ? void 0 : item.key));
2754
+ target && Object.assign(target, postData);
2755
+ }
2756
+ else {
2757
+ dvm.dataList.push(postData);
2758
+ }
2759
+ updateGroup(fGVC);
2760
+ })),
2761
+ ].join('');
2762
+ },
2763
+ });
2764
+ }
2765
+ view = view.concat([
2766
+ html ` <div class="px-md-0 px-2">
2767
+ ${BgWidget.normalInsignia('可以將多個物流設定成一個群組集中,在商品設定頁可以一次管理物流方式')}
2768
+ </div>`,
2769
+ gvc.bindView(() => {
2770
+ return {
2771
+ bind: dvm.id,
2772
+ view: () => {
2773
+ if (dvm.loading) {
2774
+ return BgWidget.spinner();
2775
+ }
2776
+ return dvm.dataList
2777
+ .map(item => {
2778
+ const dd = {
2779
+ title: item.name,
2780
+ value: item.key,
2781
+ list: item.list,
2782
+ type: 'font_awesome',
2783
+ src: html `<i class="fa-solid fa-object-group fs-4"></i>`,
2784
+ };
2785
+ return html `
2786
+ <div class="col-12 col-md-4 p-0 p-md-2">
2787
+ <div
2788
+ class="w-100 position-relative main-card"
2789
+ style="padding: 24px; background: white; overflow: hidden; justify-content: space-between; align-items: center; gap: 18px; display: inline-flex;"
2790
+ >
2791
+ <div
2792
+ style="align-self: stretch; justify-content: flex-start; align-items: center; gap: 28px; display: inline-flex;"
2793
+ >
2794
+ <div>${dd.type === 'font_awesome' ? dd.src : html ` <img src="${dd.src}" />`}</div>
2795
+ <div
2796
+ style="flex-direction: column; justify-content: center; align-items: flex-start; gap: 4px; display: inline-flex"
2797
+ >
2798
+ <div class="tx_normal">${dd.title}</div>
2799
+ </div>
2800
+ </div>
2801
+ <div>
2802
+ ${BgWidget.customButton({
2803
+ button: { color: 'gray', size: 'sm' },
2804
+ text: { name: '設定群組' },
2805
+ event: gvc.event(() => editGroupDialog(item)),
2806
+ })}
2807
+ </div>
2808
+ </div>
2809
+ </div>
2810
+ ${document.body.clientWidth > 768 ? '' : BgWidget.mbContainer(8)}
2811
+ `;
2812
+ })
2813
+ .concat([
2814
+ html ` <div
2815
+ class="col-12 col-md-4 p-0 p-md-2"
2816
+ style="cursor: pointer;"
2817
+ onclick="${gvc.event(() => editGroupDialog())}"
2818
+ >
2819
+ <div
2820
+ class="w-100 main-card"
2821
+ style="max-height:73.59px;padding: 24px; background: white; overflow: hidden; flex-direction: column; justify-content: center; align-items: center; gap: 18px; display: inline-flex"
2822
+ >
2823
+ <div
2824
+ class="fw-bold"
2825
+ style="align-self: stretch; justify-content: center; align-items: center; gap: 14px; display: inline-flex;color:#4D86DB;"
2826
+ >
2827
+ <i class="fa-regular fa-circle-plus fs-5"></i>
2828
+ <div class="fs-5">新增物流群組</div>
2829
+ </div>
2830
+ </div>
2831
+ </div>`,
2832
+ ])
2833
+ .join('');
2834
+ },
2835
+ divCreate: {
2836
+ class: 'row guide3-3 mt-3 px-1',
2837
+ },
2838
+ onCreate: () => {
2839
+ if (dvm.loading) {
2840
+ ApiUser.getPublicConfig('logistics_group', 'manager').then(r => {
2841
+ var _a;
2842
+ if (r.result) {
2843
+ dvm.dataList = (_a = r.response.value) !== null && _a !== void 0 ? _a : [];
2844
+ }
2845
+ setTimeout(() => {
2846
+ dvm.loading = false;
2847
+ gvc.notifyDataChange(dvm.id);
2848
+ }, 100);
2849
+ });
2850
+ }
2851
+ },
2852
+ };
2853
+ }),
2854
+ ]);
2855
+ }
2611
2856
  view.push(BgWidget.mbContainer(240));
2612
2857
  return BgWidget.container(view.join(''));
2613
2858
  },