ts-glitter 22.5.7 → 22.5.8

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 (83) hide show
  1. package/lowcode/Entry.js +1 -1
  2. package/lowcode/Entry.ts +1 -1
  3. package/lowcode/backend-manager/bg-product.js +13 -13
  4. package/lowcode/backend-manager/bg-product.ts +13 -13
  5. package/lowcode/backend-manager/bg-shopping.js +8 -13
  6. package/lowcode/backend-manager/bg-shopping.ts +8 -15
  7. package/lowcode/backend-manager/bg-widget.js +62 -49
  8. package/lowcode/backend-manager/bg-widget.ts +129 -93
  9. package/lowcode/cms-plugin/POS-setting.js +30 -9
  10. package/lowcode/cms-plugin/POS-setting.ts +49 -16
  11. package/lowcode/cms-plugin/cms-router.js +27 -21
  12. package/lowcode/cms-plugin/cms-router.ts +116 -101
  13. package/lowcode/cms-plugin/filter-options.js +25 -17
  14. package/lowcode/cms-plugin/filter-options.ts +27 -17
  15. package/lowcode/cms-plugin/module/product-excel.js +2 -0
  16. package/lowcode/cms-plugin/module/product-excel.ts +2 -0
  17. package/lowcode/cms-plugin/module/product-setting.js +13 -12
  18. package/lowcode/cms-plugin/module/product-setting.ts +26 -23
  19. package/lowcode/cms-plugin/order/order-module.js +91 -68
  20. package/lowcode/cms-plugin/order/order-module.ts +105 -73
  21. package/lowcode/cms-plugin/pos-checkout-setting.js +46 -39
  22. package/lowcode/cms-plugin/pos-checkout-setting.ts +237 -227
  23. package/lowcode/cms-plugin/pos-config-setting.js +25 -23
  24. package/lowcode/cms-plugin/pos-config-setting.ts +35 -32
  25. package/lowcode/cms-plugin/pos-pages/payment-function.js +253 -139
  26. package/lowcode/cms-plugin/pos-pages/payment-function.ts +405 -279
  27. package/lowcode/cms-plugin/pos-pages/payment-page.js +348 -267
  28. package/lowcode/cms-plugin/pos-pages/payment-page.ts +378 -296
  29. package/lowcode/cms-plugin/pos-pages/pos-function.js +76 -19
  30. package/lowcode/cms-plugin/pos-pages/pos-function.ts +84 -19
  31. package/lowcode/cms-plugin/shopping-discount-setting.js +2 -2
  32. package/lowcode/cms-plugin/shopping-discount-setting.ts +2 -2
  33. package/lowcode/cms-plugin/shopping-finance-setting.js +1590 -1701
  34. package/lowcode/cms-plugin/shopping-finance-setting.ts +1967 -2011
  35. package/lowcode/cms-plugin/shopping-order-manager.js +74 -62
  36. package/lowcode/cms-plugin/shopping-order-manager.ts +119 -85
  37. package/lowcode/cms-plugin/shopping-product-text.js +874 -531
  38. package/lowcode/cms-plugin/shopping-product-text.ts +1656 -1305
  39. package/lowcode/cms-plugin/shopping-setting-basic.js +152 -124
  40. package/lowcode/cms-plugin/shopping-setting-basic.ts +315 -247
  41. package/lowcode/css/editor.css +3 -2
  42. package/lowcode/glitter-base/global/language.js +5 -3
  43. package/lowcode/glitter-base/global/language.ts +8 -6
  44. package/lowcode/glitter-base/global/payment-config.js +6 -0
  45. package/lowcode/glitter-base/global/payment-config.ts +6 -3
  46. package/lowcode/public-components/product/pd-class.js +1 -3
  47. package/lowcode/public-components/product/pd-class.ts +1 -3
  48. package/lowcode/public-components/user-manager/um-order.js +2 -1
  49. package/lowcode/public-components/user-manager/um-order.ts +2 -1
  50. package/package.json +1 -1
  51. package/src/api-public/controllers/index.js +14 -3
  52. package/src/api-public/controllers/index.js.map +1 -1
  53. package/src/api-public/controllers/index.ts +16 -3
  54. package/src/api-public/controllers/shop.js +14 -7
  55. package/src/api-public/controllers/shop.js.map +1 -1
  56. package/src/api-public/controllers/shop.ts +14 -8
  57. package/src/api-public/services/data-analyze.d.ts +1 -1
  58. package/src/api-public/services/ezpay/tool.d.ts +0 -1
  59. package/src/api-public/services/financial-serviceV2.js +7 -17
  60. package/src/api-public/services/financial-serviceV2.js.map +1 -1
  61. package/src/api-public/services/shopee.js.map +1 -1
  62. package/src/api-public/services/updated-table-checked.js +20 -0
  63. package/src/api-public/services/updated-table-checked.js.map +1 -1
  64. package/src/api-public/services/updated-table-checked.ts +21 -0
  65. package/src/app-project/serverless/src/modules/database.d.ts +1 -1
  66. package/src/app-project/serverless/src/modules/redis.d.ts +1 -1
  67. package/src/helper/glitter-util.d.ts +0 -1
  68. package/src/index.js +3 -3
  69. package/src/index.js.map +13 -1
  70. package/src/modules/tool.d.ts +2 -0
  71. package/src/modules/tool.js +7 -0
  72. package/src/modules/tool.js.map +1 -1
  73. package/src/modules/tool.ts +7 -0
  74. package/src/seo-config.js +3 -3
  75. package/src/seo-config.js.map +9 -1
  76. package/src/services/private_config.js +11 -0
  77. package/src/services/private_config.js.map +1 -1
  78. package/src/services/private_config.ts +11 -0
  79. package/src/services/saas-table-check.js +12 -0
  80. package/src/services/saas-table-check.js.map +1 -1
  81. package/src/services/saas-table-check.ts +12 -0
  82. package/src/services/ses.js +3 -4
  83. package/src/services/ses.js.map +1 -1
@@ -63,6 +63,24 @@ interface StockOptionsItem extends OptionsItem {
63
63
  stock: number;
64
64
  }
65
65
 
66
+ export interface CustomButtonObject {
67
+ button: {
68
+ color: 'black' | 'gray' | 'snow';
69
+ size: 'sm' | 'md' | 'lg';
70
+ class?: string;
71
+ style?: string;
72
+ };
73
+ text: {
74
+ name: string;
75
+ class?: string;
76
+ style?: string;
77
+ };
78
+ event: string;
79
+ icon?: {
80
+ name: string;
81
+ };
82
+ }
83
+
66
84
  export interface OptionsItem {
67
85
  key: string;
68
86
  value: string;
@@ -397,20 +415,28 @@ export class BgWidget {
397
415
  }
398
416
 
399
417
  static checkInput(gvc: GVC, def: boolean, callback: (value: boolean) => void) {
400
- const id = gvc.glitter.getUUID()
401
- const trueImg = html`<i class="fa-solid fa-square-check" style="width: 16px;height: 16px;" onclick="${gvc.event(e => {
402
- callback(def);
403
- gvc.notifyDataChange(id)
404
- })}"></i>`;
405
- const falseImg = html`<div style="width: 16px;height: 16px;border-radius: 3px;border: 1px solid #DDD;" onclick="${gvc.event(e => {
406
- callback(def);
407
- gvc.notifyDataChange(id)
408
- })}"></div>`;
418
+ const id = gvc.glitter.getUUID();
419
+ const trueImg = html`<i
420
+ class="fa-solid fa-square-check"
421
+ style="width: 16px;height: 16px;"
422
+ onclick="${gvc.event(e => {
423
+ callback(def);
424
+ gvc.notifyDataChange(id);
425
+ })}"
426
+ ></i>`;
427
+ const falseImg = html`<div
428
+ style="width: 16px;height: 16px;border-radius: 3px;border: 1px solid #DDD;"
429
+ onclick="${gvc.event(e => {
430
+ callback(def);
431
+ gvc.notifyDataChange(id);
432
+ })}"
433
+ ></div>`;
409
434
  return gvc.bindView({
410
- bind:id,
411
- view:()=>{
412
- return (def)?trueImg:falseImg
413
- },divCreate:{}
435
+ bind: id,
436
+ view: () => {
437
+ return def ? trueImg : falseImg;
438
+ },
439
+ divCreate: {},
414
440
  });
415
441
  }
416
442
 
@@ -952,7 +978,7 @@ export class BgWidget {
952
978
  : ''}
953
979
  <div
954
980
  class="d-flex w-100 align-items-center border rounded-3 ${obj.readonly ? `bgw-input-readonly` : ``}"
955
- style="margin: 8px 0;overflow: hidden;"
981
+ style="margin: 8px 0; overflow: hidden;"
956
982
  >
957
983
  ${obj.global_language
958
984
  ? html`
@@ -2138,6 +2164,7 @@ ${obj.default ?? ''}</textarea
2138
2164
  header: Tool.randomString(6),
2139
2165
  headerCell: Tool.randomString(6),
2140
2166
  tr: Tool.randomString(6),
2167
+ table: glitter.getUUID(),
2141
2168
  textClass: Tool.randomString(6),
2142
2169
  };
2143
2170
 
@@ -2220,13 +2247,14 @@ ${obj.default ?? ''}</textarea
2220
2247
  const checkboxSelector = result ? 'i.fa-square' : 'i.fa-square-check';
2221
2248
 
2222
2249
  vm.originalData.forEach((item: any, index: number) => {
2223
- const checkboxParent = gvc.glitter.document.querySelector(`[gvc-checkbox="checkbox${index}"]`);
2250
+ const checkboxParent = gvc.glitter.document.querySelector(
2251
+ `.${ids.table} [gvc-checkbox="checkbox${index}"]`
2252
+ );
2224
2253
  const checkboxIcon = checkboxParent?.querySelector(checkboxSelector) as HTMLElement | null;
2225
-
2226
2254
  checkboxIcon?.click();
2227
2255
  });
2228
2256
 
2229
- gvc.notifyDataChange(ids.filter);
2257
+ gvc.notifyDataChange([ids.filter, ids.table]);
2230
2258
  obj.itemSelect?.();
2231
2259
  changeHeaderStyle();
2232
2260
  }
@@ -2336,9 +2364,9 @@ ${obj.default ?? ''}</textarea
2336
2364
  return html` <div style="margin-top: 4px; overflow-x: scroll; position: relative; min-height: 350px">
2337
2365
  <div
2338
2366
  class="w-100 h-100 bg-white top-0"
2339
- style="position: absolute; z-index: ${defWidth > 0 ? 0 : 2}; display: ${defWidth > 0
2340
- ? 'none'
2341
- : 'block'};"
2367
+ style="position: absolute; z-index: ${defWidth > 0 ? 0 : 2}; display: ${
2368
+ defWidth > 0 ? 'none' : 'block'
2369
+ };"
2342
2370
  ></div>
2343
2371
  ${gvc.bindView({
2344
2372
  bind: ids.header,
@@ -2472,26 +2500,27 @@ ${obj.default ?? ''}</textarea
2472
2500
  })}
2473
2501
  <table class="table table-centered table-nowrap text-center table-hover" style="width: ${defWidth}px;">
2474
2502
  <tbody>
2475
- ${vm.tableData
2476
- .map((dd, trIndex: number) => {
2477
- return html` <tr
2478
- class="${trIndex === 0 ? ids.tr : ''} ${dd.find(d3 => d3.tooltip)
2479
- ? 'tr-tooltip-container'
2480
- : ''}"
2481
- onclick="${gvc.event((e, event) => {
2482
- obj.rowClick && obj.rowClick(dd, trIndex, e, event);
2483
- })}"
2484
- onmouseover="${gvc.event(() => {
2485
- $(`#${ids.pencil}${trIndex}`).removeClass('d-none');
2486
- })}"
2487
- onmouseout="${gvc.event(() => {
2488
- $(`#${ids.pencil}${trIndex}`).addClass('d-none');
2489
- })}"
2490
- >
2491
- ${dd
2492
- .map((d3, tdIndex: number) => {
2493
- const tdClass = Tool.randomString(5);
2494
- const style = `
2503
+ <tbody class="${ids.table}">
2504
+ ${vm.tableData
2505
+ .map((dd, trIndex: number) => {
2506
+ return html` <tr
2507
+ class="${trIndex === 0 ? ids.tr : ''} ${dd.find(d3 => d3.tooltip)
2508
+ ? 'tr-tooltip-container'
2509
+ : ''}"
2510
+ onclick="${gvc.event((e, event) => {
2511
+ obj.rowClick && obj.rowClick(dd, trIndex, e, event);
2512
+ })}"
2513
+ onmouseover="${gvc.event(() => {
2514
+ $(`#${ids.pencil}${trIndex}`).removeClass('d-none');
2515
+ })}"
2516
+ onmouseout="${gvc.event(() => {
2517
+ $(`#${ids.pencil}${trIndex}`).addClass('d-none');
2518
+ })}"
2519
+ >
2520
+ ${dd
2521
+ .map((d3, tdIndex: number) => {
2522
+ const tdClass = Tool.randomString(5);
2523
+ const style = `
2495
2524
  border: none;
2496
2525
  vertical-align: middle;
2497
2526
  width: ${widthList[tdIndex]}px;
@@ -2499,48 +2528,51 @@ ${obj.default ?? ''}</textarea
2499
2528
  ${dd.length > 1 && tdIndex === dd.length - 1 ? 'border-radius: 0 10px 10px 0;' : ''}
2500
2529
  ${dd.length === 1 ? 'border-radius: 10px;' : ''}
2501
2530
  `;
2502
-
2503
- return html` <td
2504
- class="${ids.textClass} ${tdClass} tb-v3 tx_normal position-relative"
2505
- style="${style}"
2506
- ${obj.filter.length !== 0 && tdIndex === 0 ? `gvc-checkbox="checkbox${trIndex}"` : ''}
2507
- onclick="${d3.stopClick ? gvc.event((_, event) => event.stopPropagation()) : ''}"
2508
- >
2509
- <div
2510
- class="text-nowrap ${d3.tooltip ? 'hover-element' : ''}"
2511
- style="color: #393939 !important;"
2512
- ${d3.tooltip ? `data-tooltip="${d3.tooltip}"` : ''}
2531
+ return html` <td
2532
+ class="${ids.textClass} ${tdClass} tb-v3 tx_normal position-relative"
2533
+ style="${style}"
2534
+ ${obj.filter.length !== 0 && tdIndex === 0 ? `gvc-checkbox="checkbox${trIndex}"` : ''}
2535
+ onclick="${d3.stopClick ? gvc.event((_, event) => event.stopPropagation()) : ''}"
2513
2536
  >
2514
- ${d3.value}
2515
- </div>
2516
- ${d3.tooltip ? html`<div class="td-tooltip">${d3.tooltip}</div>` : ''}
2517
- </td>`;
2518
- })
2519
- .join('')}
2520
- </tr>`;
2521
- })
2522
- .join('')}
2537
+ <div
2538
+ class="text-nowrap ${d3.tooltip ? 'hover-element' : ''}"
2539
+ style="color: #393939 !important;"
2540
+ ${d3.tooltip ? `data-tooltip="${d3.tooltip}"` : ''}
2541
+ >
2542
+ ${d3.value}
2543
+ </div>
2544
+ ${d3.tooltip ? html`<div class="td-tooltip">${d3.tooltip}</div>` : ''}
2545
+ </td>`;
2546
+ })
2547
+ .join('')}
2548
+ </tr>`;
2549
+ })
2550
+ .join('')}
2551
+ </tbody>
2552
+
2523
2553
  </tbody>
2524
2554
  </table>
2525
2555
  </div>
2526
2556
  <div>
2527
- ${obj.hiddenPageSplit
2528
- ? ''
2529
- : ps.pageSplitV2(
2530
- vm.pageSize,
2531
- vm.page,
2532
- page => {
2533
- vm.tableData = [];
2534
- vm.page = page;
2535
- vm.loading = true;
2536
- created.checkbox = false;
2537
- obj.tabClick && obj.tabClick!!(vm);
2538
- if (created.header && created.table) {
2539
- gvc.notifyDataChange(ids.container);
2540
- }
2541
- },
2542
- false
2543
- )}
2557
+ ${
2558
+ obj.hiddenPageSplit
2559
+ ? ''
2560
+ : ps.pageSplitV2(
2561
+ vm.pageSize,
2562
+ vm.page,
2563
+ page => {
2564
+ vm.tableData = [];
2565
+ vm.page = page;
2566
+ vm.loading = true;
2567
+ created.checkbox = false;
2568
+ obj.tabClick && obj.tabClick!!(vm);
2569
+ if (created.header && created.table) {
2570
+ gvc.notifyDataChange(ids.container);
2571
+ }
2572
+ },
2573
+ false
2574
+ )
2575
+ }
2544
2576
  </div>`;
2545
2577
  } catch (e) {
2546
2578
  console.error(e);
@@ -2626,6 +2658,8 @@ ${obj.default ?? ''}</textarea
2626
2658
  }
2627
2659
 
2628
2660
  // 容器
2661
+ static isPhone = () => document.body.offsetWidth < 768;
2662
+
2629
2663
  static getContainerWidth = (obj?: { rate?: { web?: number; pad?: number; phone?: number } }) => {
2630
2664
  const clientWidth = document.body.clientWidth;
2631
2665
  const rateForWeb = obj && obj.rate && obj.rate.web ? obj.rate.web : 0.95;
@@ -2653,8 +2687,10 @@ ${obj.default ?? ''}</textarea
2653
2687
  }
2654
2688
  ) {
2655
2689
  return html` <div
2656
- class="mb-0 ${document.body.clientWidth > 768 ? 'mx-auto mt-3' : 'w-100 mx-0'}"
2657
- style="max-width: 100%; width: ${this.getContainerWidth()}px; ${obj?.style ?? ''}"
2690
+ class="mb-0 ${this.isPhone() ? 'w-100 mx-0' : 'mx-auto'}"
2691
+ style="max-width: 100%; width: ${this.getContainerWidth()}px; ${this.isPhone()
2692
+ ? ''
2693
+ : 'border-top: 1rem solid #f5f5f5;'} ${obj?.style ?? ''}"
2658
2694
  >
2659
2695
  ${htmlString}
2660
2696
  </div>`;
@@ -4145,7 +4181,7 @@ ${obj.default ?? ''}</textarea
4145
4181
  }
4146
4182
 
4147
4183
  return html` <div style="width: 100%; overflow-y: auto;" class="bg-white shadow rounded-3">
4148
- <div class="w-100 d-flex align-items-center p-3 border-bottom">
4184
+ <div class="w-100 d-flex align-items-center border-bottom" style="padding: 12px 20px;">
4149
4185
  <div class="tx_700">${obj.title}</div>
4150
4186
  <div class="flex-fill"></div>
4151
4187
  <i
@@ -4346,7 +4382,7 @@ ${obj.default ?? ''}</textarea
4346
4382
  return html` <div class="my-4">${this.spinner()}</div>`;
4347
4383
  }
4348
4384
  return html` <div class="bg-white shadow rounded-3" style="width: 100%; overflow-y: auto;">
4349
- <div class="w-100 d-flex align-items-center p-3 border-bottom">
4385
+ <div class="w-100 d-flex align-items-center border-bottom" style="padding: 12px 20px;">
4350
4386
  <div class="tx_700">${obj.title ?? '產品列表'}</div>
4351
4387
  <div class="flex-fill"></div>
4352
4388
  <i
@@ -4479,7 +4515,7 @@ ${obj.default ?? ''}</textarea
4479
4515
  return html` <div class="my-4">${this.spinner()}</div>`;
4480
4516
  }
4481
4517
  return html` <div class="bg-white shadow rounded-3" style="width: 100%; overflow-y: auto;">
4482
- <div class="w-100 d-flex align-items-center p-3 border-bottom">
4518
+ <div class="w-100 d-flex align-items-center border-bottom" style="padding: 12px 20px;">
4483
4519
  <div class="tx_700">${obj.title ?? '產品列表'}</div>
4484
4520
  <div class="flex-fill"></div>
4485
4521
  <i
@@ -4681,7 +4717,7 @@ ${obj.default ?? ''}</textarea
4681
4717
  return html` <div class="my-4">${this.spinner()}</div>`;
4682
4718
  }
4683
4719
  return html` <div class="bg-white shadow rounded-3" style="width: 100%; overflow-y: auto;">
4684
- <div class="w-100 d-flex align-items-center p-3 border-bottom">
4720
+ <div class="w-100 d-flex align-items-center border-bottom" style="padding: 12px 20px;">
4685
4721
  <div class="tx_700">${obj.title ?? '產品列表'}</div>
4686
4722
  <div class="flex-fill"></div>
4687
4723
  <i
@@ -4835,7 +4871,7 @@ ${obj.default ?? ''}</textarea
4835
4871
  return html` <div class="my-4">${this.spinner()}</div>`;
4836
4872
  }
4837
4873
  return html` <div class="bg-white shadow rounded-3" style="width: 100%; overflow-y: auto;">
4838
- <div class="w-100 d-flex align-items-center p-3 border-bottom">
4874
+ <div class="w-100 d-flex align-items-center border-bottom" style="padding: 12px 20px;">
4839
4875
  <div class="tx_700">${obj.title ?? '產品列表'}</div>
4840
4876
  <div class="flex-fill"></div>
4841
4877
  <i
@@ -4852,9 +4888,9 @@ ${obj.default ?? ''}</textarea
4852
4888
  <div class="c_dialog_body">
4853
4889
  <div
4854
4890
  class="c_dialog_main"
4855
- style="${obj.d_main_style || ''};gap: 24px; ${obj.height
4856
- ? `height:${obj.height}px;max-height: 100vh;`
4857
- : `height:auto;max-height: 500px;`} "
4891
+ style="gap: 24px; ${obj.d_main_style || ''}; ${obj.height
4892
+ ? `height: ${obj.height}px; max-height: 100vh;`
4893
+ : `height: auto; max-height: 500px;`} "
4858
4894
  >
4859
4895
  ${obj.innerHTML(gvc) ?? ''}
4860
4896
  </div>
@@ -4901,7 +4937,7 @@ ${obj.default ?? ''}</textarea
4901
4937
  : 'min-width: 90vw; max-width: 92.5vw;'}"
4902
4938
  >
4903
4939
  <div class="bg-white shadow rounded-3" style="width: 100%; overflow-y: auto;">
4904
- <div class="w-100 d-flex align-items-center p-3 border-bottom">
4940
+ <div class="w-100 d-flex align-items-center border-bottom" style="padding: 12px 20px;">
4905
4941
  <div class="tx_700">${obj.title}</div>
4906
4942
  <div class="flex-fill"></div>
4907
4943
  <i
@@ -5071,7 +5107,7 @@ ${obj.default ?? ''}</textarea
5071
5107
  return obj.gvc.glitter.innerDialog((gvc: GVC) => {
5072
5108
  return html` <div class="bg-white shadow rounded-3" style="overflow-y: auto;width:414px;">
5073
5109
  <div class="bg-white shadow rounded-3" style="width: 100%; overflow-y: auto;">
5074
- <div class="w-100 d-flex align-items-center p-3 border-bottom">
5110
+ <div class="w-100 d-flex align-items-center border-bottom" style="padding: 12px 20px;">
5075
5111
  <div class="tx_700">${obj.title}</div>
5076
5112
  <div class="flex-fill"></div>
5077
5113
  <i
@@ -5238,8 +5274,8 @@ ${obj.default ?? ''}</textarea
5238
5274
  style="width: 100%; max-height: 100%; overflow-y: auto; position: relative;"
5239
5275
  >
5240
5276
  <div
5241
- class="w-100 d-flex align-items-center p-3 border-bottom"
5242
- style="position: sticky; top: 0; z-index: 2; background: #fff;"
5277
+ class="w-100 d-flex align-items-center border-bottom"
5278
+ style="position: sticky; top: 0; z-index: 2; background: #fff; padding: 12px 20px;"
5243
5279
  >
5244
5280
  <div class="tx_700">
5245
5281
  ${typeof obj.title === 'function' ? obj.title(gvc) : (obj.title ?? '產品列表')}
@@ -5721,8 +5757,8 @@ ${obj.default ?? ''}</textarea
5721
5757
  style="width: 100%; padding-top: 61px;"
5722
5758
  >
5723
5759
  <div
5724
- class="w-100 d-flex align-items-center p-3 border-bottom position-absolute"
5725
- style="background: #F2F2F2;top:0;left:0"
5760
+ class="w-100 d-flex align-items-center border-bottom position-absolute"
5761
+ style="background: #F2F2F2; top: 0; left: 0; padding: 12px 20px;"
5726
5762
  >
5727
5763
  <div class="tx_700 dialog-title">${obj.title ?? '圖片庫'}</div>
5728
5764
  <div class="flex-fill"></div>
@@ -31,6 +31,7 @@ import { SaasOffer } from '../saas-offer.js';
31
31
  import { Language } from '../glitter-base/global/language.js';
32
32
  import { CreditCard } from './pos-pages/credit-card.js';
33
33
  import { BgWidget } from '../backend-manager/bg-widget.js';
34
+ import { Tool } from '../modules/tool.js';
34
35
  const html = String.raw;
35
36
  export class POSSetting {
36
37
  static loginManager(gvc, mode, result) {
@@ -333,6 +334,9 @@ export class POSSetting {
333
334
  const gvc = obj.gvc;
334
335
  const data = obj.defaultData;
335
336
  const orderDetail = obj.orderDetail;
337
+ const vm = {
338
+ specs: [],
339
+ };
336
340
  let selectVariant = obj.selectVariant;
337
341
  let count = 1;
338
342
  function arraysEqual(arr1, arr2) {
@@ -345,6 +349,7 @@ export class POSSetting {
345
349
  product.content.specs.forEach((spec) => {
346
350
  emptyArray.push(spec.option.find((opt) => opt.select == true).title);
347
351
  });
352
+ vm.specs = emptyArray;
348
353
  return product.content.variants.find((variant) => arraysEqual(variant.spec, emptyArray));
349
354
  }
350
355
  data.content.specs.map((dd, index) => {
@@ -352,23 +357,32 @@ export class POSSetting {
352
357
  d1.select = index === 0;
353
358
  });
354
359
  });
360
+ const invisibleVariants = data.content.variants.filter((v) => v.invisible);
361
+ const visibleVariants = data.content.variants.filter((v) => !v.invisible);
355
362
  selectVariant = changeSelectVariant(data);
356
363
  obj.callback(selectVariant);
357
364
  gvc.glitter.innerDialog(gvc => {
358
365
  return gvc.bindView({
359
366
  bind: 'productDialog',
360
367
  view: () => {
361
- var _a;
368
+ var _a, _b;
362
369
  try {
363
370
  selectVariant.preview_image = selectVariant.preview_image || [];
364
- selectVariant.stock = gvc.glitter.share.store_list.filter((dd) => {
371
+ selectVariant.stock = gvc.glitter.share.store_list
372
+ .filter((dd) => {
365
373
  var _a;
366
- return (dd.id === POSSetting.config.where_store) || ((_a = gvc.glitter.share.store_list.find((dd) => {
367
- return dd.id === POSSetting.config.where_store;
368
- }).support_store) !== null && _a !== void 0 ? _a : []).includes(dd.id);
369
- }).map((d1) => {
374
+ return (dd.id === POSSetting.config.where_store ||
375
+ ((_a = gvc.glitter.share.store_list.find((dd) => {
376
+ return dd.id === POSSetting.config.where_store;
377
+ }).support_store) !== null && _a !== void 0 ? _a : []).includes(dd.id));
378
+ })
379
+ .map((d1) => {
370
380
  return selectVariant.stockList[d1.id].count;
371
- }).reduce((acc, val) => acc + val, 0);
381
+ })
382
+ .reduce((acc, val) => acc + val, 0);
383
+ if (vm.specs.length === 0 || invisibleVariants.find((iv) => Tool.ObjCompare(iv.spec, vm.specs))) {
384
+ vm.specs = (_a = visibleVariants === null || visibleVariants === void 0 ? void 0 : visibleVariants[0].spec) !== null && _a !== void 0 ? _a : [];
385
+ }
372
386
  return html ` <div
373
387
  class="w-100 h-100 d-flex align-items-center justify-content-center"
374
388
  onclick="${gvc.event(() => gvc.glitter.closeDiaLog())}"
@@ -390,7 +404,7 @@ export class POSSetting {
390
404
  'https://d3jnmi1tfjgtti.cloudfront.net/file/234285319/1722936949034-default_image.jpg'}');"
391
405
  ></div>
392
406
  <div class="d-flex flex-column flex-fill justify-content-center">
393
- <div style="font-size: 24px;font-weight: 700;">${(_a = data.content.title) !== null && _a !== void 0 ? _a : 'no name'}</div>
407
+ <div style="font-size: 24px;font-weight: 700;">${(_b = data.content.title) !== null && _b !== void 0 ? _b : 'no name'}</div>
394
408
  <div style="font-size: 20px;font-weight: 500;margin-top: 8px;">
395
409
  NT.${parseInt(selectVariant.sale_price, 10).toLocaleString()}
396
410
  </div>
@@ -401,6 +415,9 @@ export class POSSetting {
401
415
  return '';
402
416
  }
403
417
  const productSpecs = data.content.specs;
418
+ const invisibleVariants = data.content.variants
419
+ .filter((v) => v.invisible)
420
+ .map((v) => v.spec);
404
421
  return productSpecs
405
422
  .map((spec, index1) => {
406
423
  return html ` <div>
@@ -410,6 +427,11 @@ export class POSSetting {
410
427
  </h5>
411
428
  <div class="d-flex gap-2 flex-wrap">
412
429
  ${gvc.map(spec.option.map((opt, optIndex) => {
430
+ const cloneSpecs = vm.specs.slice();
431
+ cloneSpecs[index1] = opt.title;
432
+ if (invisibleVariants.find((iv) => Tool.ObjCompare(iv, cloneSpecs))) {
433
+ return '';
434
+ }
413
435
  return html ` <div
414
436
  class="spec-option ${spec.option[optIndex].select ? 'selected-option' : ''}"
415
437
  onclick="${gvc.event(() => {
@@ -551,7 +573,6 @@ export class POSSetting {
551
573
  }
552
574
  ApiUser.getPublicConfig('store_manager', 'manager').then((dd) => {
553
575
  var _a;
554
- console.log(`selectVariant===>`, selectVariant);
555
576
  if (dd.result && Array.isArray((_a = dd.response.value) === null || _a === void 0 ? void 0 : _a.list)) {
556
577
  dd.response.value.list.map((store) => {
557
578
  var _a, _b, _c;
@@ -23,6 +23,7 @@ import { SaasOffer } from '../saas-offer.js';
23
23
  import { Language } from '../glitter-base/global/language.js';
24
24
  import { CreditCard } from './pos-pages/credit-card.js';
25
25
  import { BgWidget } from '../backend-manager/bg-widget.js';
26
+ import { Tool } from '../modules/tool.js';
26
27
 
27
28
  const html = String.raw;
28
29
 
@@ -384,6 +385,9 @@ export class POSSetting {
384
385
  const gvc = obj.gvc;
385
386
  const data = obj.defaultData;
386
387
  const orderDetail = obj.orderDetail;
388
+ const vm = {
389
+ specs: [] as any[],
390
+ };
387
391
  let selectVariant = obj.selectVariant;
388
392
 
389
393
  let count = 1;
@@ -398,15 +402,23 @@ export class POSSetting {
398
402
  product.content.specs.forEach((spec: any) => {
399
403
  emptyArray.push(spec.option.find((opt: any) => opt.select == true).title);
400
404
  });
405
+ vm.specs = emptyArray;
401
406
  return product.content.variants.find((variant: any) => arraysEqual(variant.spec, emptyArray));
402
407
  }
403
- data.content.specs.map((dd:any,index:number)=>{
404
- dd.option.map((d1:any,index:number)=>{
405
- d1.select = index===0;
406
- })
408
+
409
+ data.content.specs.map((dd: any, index: number) => {
410
+ dd.option.map((d1: any, index: number) => {
411
+ d1.select = index === 0;
412
+ });
407
413
  });
414
+
415
+ // 可顯示與不可顯示產品規格
416
+ const invisibleVariants = data.content.variants.filter((v: any) => v.invisible);
417
+ const visibleVariants = data.content.variants.filter((v: any) => !v.invisible);
418
+
408
419
  selectVariant = changeSelectVariant(data);
409
420
  obj.callback(selectVariant);
421
+
410
422
  gvc.glitter.innerDialog(
411
423
  gvc => {
412
424
  return gvc.bindView({
@@ -414,16 +426,26 @@ export class POSSetting {
414
426
  view: () => {
415
427
  try {
416
428
  selectVariant.preview_image = selectVariant.preview_image || [];
417
- selectVariant.stock = gvc.glitter.share.store_list.filter((dd:any)=>{
418
- return (dd.id===POSSetting.config.where_store) || (
419
- gvc.glitter.share.store_list.find((dd:any)=>{
420
- return dd.id === POSSetting.config.where_store;
421
- }).support_store ?? []
422
- ).includes(dd.id);
423
- }).map((d1:any)=>{
424
- return selectVariant.stockList[d1.id].count
425
- }).reduce((acc: any, val: any) => acc + val,0)
426
-
429
+ selectVariant.stock = gvc.glitter.share.store_list
430
+ .filter((dd: any) => {
431
+ return (
432
+ dd.id === POSSetting.config.where_store ||
433
+ (
434
+ gvc.glitter.share.store_list.find((dd: any) => {
435
+ return dd.id === POSSetting.config.where_store;
436
+ }).support_store ?? []
437
+ ).includes(dd.id)
438
+ );
439
+ })
440
+ .map((d1: any) => {
441
+ return selectVariant.stockList[d1.id].count;
442
+ })
443
+ .reduce((acc: any, val: any) => acc + val, 0);
444
+
445
+ // 更新規格
446
+ if (vm.specs.length === 0 || invisibleVariants.find((iv: any) => Tool.ObjCompare(iv.spec, vm.specs))) {
447
+ vm.specs = visibleVariants?.[0].spec ?? [];
448
+ }
427
449
 
428
450
  return html` <div
429
451
  class="w-100 h-100 d-flex align-items-center justify-content-center"
@@ -466,7 +488,11 @@ export class POSSetting {
466
488
  'zh-TW': string;
467
489
  };
468
490
  }[] = data.content.specs;
469
-
491
+
492
+ const invisibleVariants = data.content.variants
493
+ .filter((v: any) => v.invisible)
494
+ .map((v: any) => v.spec);
495
+
470
496
  return productSpecs
471
497
  .map((spec, index1) => {
472
498
  return html` <div>
@@ -477,6 +503,14 @@ export class POSSetting {
477
503
  <div class="d-flex gap-2 flex-wrap">
478
504
  ${gvc.map(
479
505
  spec.option.map((opt: any, optIndex: number) => {
506
+ // 排除不可顯示的規格選項
507
+ const cloneSpecs = vm.specs.slice();
508
+ cloneSpecs[index1] = opt.title;
509
+
510
+ if (invisibleVariants.find((iv: any) => Tool.ObjCompare(iv, cloneSpecs))) {
511
+ return '';
512
+ }
513
+
480
514
  return html` <div
481
515
  class="spec-option ${spec.option[optIndex].select ? 'selected-option' : ''}"
482
516
  onclick="${gvc.event(() => {
@@ -624,7 +658,6 @@ export class POSSetting {
624
658
  }
625
659
 
626
660
  ApiUser.getPublicConfig('store_manager', 'manager').then((dd: any) => {
627
- console.log(`selectVariant===>`,selectVariant)
628
661
  if (dd.result && Array.isArray(dd.response.value?.list)) {
629
662
  dd.response.value.list.map((store: any) => {
630
663
  const n = selectVariant.stockList?.[store.id]?.count ?? 0;