ts-glitter 22.4.7 → 22.4.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 (98) hide show
  1. package/lib/glitterBundle/Glitter.css +74 -62
  2. package/lowcode/Entry.js +1 -1
  3. package/lowcode/Entry.ts +1 -1
  4. package/lowcode/backend-manager/bg-product.js +49 -32
  5. package/lowcode/backend-manager/bg-product.ts +57 -39
  6. package/lowcode/backend-manager/bg-widget.js +17 -0
  7. package/lowcode/backend-manager/bg-widget.ts +18 -0
  8. package/lowcode/cms-plugin/information/information-module.js +5 -5
  9. package/lowcode/cms-plugin/information/information-module.ts +9 -5
  10. package/lowcode/cms-plugin/menus-setting.js +69 -55
  11. package/lowcode/cms-plugin/menus-setting.ts +77 -61
  12. package/lowcode/cms-plugin/module/form-module.js +109 -89
  13. package/lowcode/cms-plugin/module/form-module.ts +680 -650
  14. package/lowcode/cms-plugin/module/product-excel.js +1 -0
  15. package/lowcode/cms-plugin/module/product-excel.ts +2 -0
  16. package/lowcode/cms-plugin/pos-pages/payment-page.js +28 -10
  17. package/lowcode/cms-plugin/pos-pages/payment-page.ts +29 -10
  18. package/lowcode/cms-plugin/shopping-allowance-manager.js +0 -1
  19. package/lowcode/cms-plugin/shopping-allowance-manager.ts +0 -1
  20. package/lowcode/cms-plugin/shopping-collections.js +367 -193
  21. package/lowcode/cms-plugin/shopping-collections.ts +664 -243
  22. package/lowcode/cms-plugin/shopping-information.js +392 -38
  23. package/lowcode/cms-plugin/shopping-information.ts +479 -87
  24. package/lowcode/cms-plugin/shopping-product-setting.js +2 -2
  25. package/lowcode/cms-plugin/shopping-product-setting.ts +2 -2
  26. package/lowcode/cms-plugin/shopping-setting-advance.js +906 -766
  27. package/lowcode/cms-plugin/shopping-setting-advance.ts +977 -841
  28. package/lowcode/cms-plugin/shopping-setting-basic.js +1547 -1285
  29. package/lowcode/cms-plugin/shopping-setting-basic.ts +1742 -1466
  30. package/lowcode/cms-plugin/stock-stores.js +1 -0
  31. package/lowcode/cms-plugin/stock-stores.ts +1 -0
  32. package/lowcode/cms-plugin/user-list.js +47 -12
  33. package/lowcode/cms-plugin/user-list.ts +52 -14
  34. package/lowcode/css/editor.css +6 -0
  35. package/lowcode/glitterBundle/Glitter.css +74 -62
  36. package/lowcode/jslib/nestable/index.html +317 -0
  37. package/lowcode/jslib/nestable/jquery.nestable.js +484 -0
  38. package/lowcode/official_view_component/form-widget/input-custom.js +98 -6
  39. package/lowcode/official_view_component/form-widget/input-custom.ts +121 -16
  40. package/lowcode/public-components/headers/header-class.js +63 -0
  41. package/lowcode/public-components/headers/header-class.ts +65 -0
  42. package/lowcode/public-components/headers/sy-02.js +386 -400
  43. package/lowcode/public-components/headers/sy-02.ts +482 -492
  44. package/lowcode/public-components/headers/sy-03.js +42 -43
  45. package/lowcode/public-components/headers/sy-03.ts +46 -43
  46. package/lowcode/public-components/headers/sy-04.js +43 -41
  47. package/lowcode/public-components/headers/sy-04.ts +48 -41
  48. package/lowcode/public-components/headers/sy-05.js +30 -27
  49. package/lowcode/public-components/headers/sy-05.ts +33 -27
  50. package/lowcode/public-components/product/product-list.js +160 -148
  51. package/lowcode/public-components/product/product-list.ts +186 -165
  52. package/lowcode/public-models/product.ts +26 -1
  53. package/lowcode/src/glitterBundle/Glitter.css +74 -62
  54. package/package.json +1 -1
  55. package/rxmnt81tnk.json +1 -0
  56. package/src/api-public/controllers/shop.js +10 -4
  57. package/src/api-public/controllers/shop.js.map +1 -1
  58. package/src/api-public/controllers/shop.ts +14 -9
  59. package/src/api-public/services/ezpay/tool.d.ts +1 -0
  60. package/src/api-public/services/mail.js +1 -1
  61. package/src/api-public/services/mail.js.map +1 -1
  62. package/src/api-public/services/mail.ts +1 -1
  63. package/src/api-public/services/schedule.d.ts +0 -1
  64. package/src/api-public/services/schedule.js +12 -35
  65. package/src/api-public/services/schedule.js.map +1 -1
  66. package/src/api-public/services/schedule.ts +15 -39
  67. package/src/api-public/services/shopee.js +7 -17
  68. package/src/api-public/services/shopping.d.ts +27 -6
  69. package/src/api-public/services/shopping.js +364 -85
  70. package/src/api-public/services/shopping.js.map +1 -1
  71. package/src/api-public/services/shopping.ts +510 -101
  72. package/src/api-public/services/updated-table-checked.js +58 -1
  73. package/src/api-public/services/updated-table-checked.js.map +1 -1
  74. package/src/api-public/services/updated-table-checked.ts +62 -1
  75. package/src/api-public/services/user-update.js +14 -0
  76. package/src/api-public/services/user-update.js.map +1 -1
  77. package/src/api-public/services/user-update.ts +15 -0
  78. package/src/api-public/services/user.js +1 -1
  79. package/src/api-public/services/user.js.map +1 -1
  80. package/src/api-public/services/user.ts +1 -1
  81. package/src/app-project/serverless/src/modules/database.d.ts +1 -1
  82. package/src/app-project/serverless/src/modules/redis.d.ts +1 -1
  83. package/src/helper/glitter-util.d.ts +1 -0
  84. package/src/index.js +7 -5
  85. package/src/index.js.map +1 -1
  86. package/src/index.ts +45 -38
  87. package/src/modules/firebase.js +1 -0
  88. package/src/modules/firebase.js.map +1 -1
  89. package/src/modules/firebase.ts +1 -0
  90. package/src/seo-config.d.ts +1 -1
  91. package/src/seo-config.js +1 -2
  92. package/src/seo-config.js.map +1 -1
  93. package/src/seo-config.ts +1 -2
  94. package/src/services/saas-table-check.js.map +1 -1
  95. package/src/services/ses.js +4 -3
  96. package/src/services/ses.js.map +1 -1
  97. package/src/services/system-schedule.js.map +1 -1
  98. package/src/services/system-schedule.ts +1 -0
@@ -20,6 +20,7 @@ import { QuestionInfo } from './module/question-info.js';
20
20
  import { ProductAi } from './ai-generator/product-ai.js';
21
21
  import { ShoppingProductSetting } from './shopping-product-setting.js';
22
22
  const html = String.raw;
23
+ const css = String.raw;
23
24
  export class ShoppingSettingBasic {
24
25
  static updateVariants(gvc, postMD, shipment_config, variantsViewID, obj) {
25
26
  const specs = {};
@@ -79,21 +80,6 @@ export class ShoppingSettingBasic {
79
80
  });
80
81
  }
81
82
  });
82
- postMD.variants = postMD.variants.filter(variant => {
83
- let pass = true;
84
- let index = 0;
85
- for (const b of variant.spec) {
86
- if (!postMD.specs[index] ||
87
- !postMD.specs[index].option.find((dd) => {
88
- return dd.title === b;
89
- })) {
90
- pass = false;
91
- break;
92
- }
93
- index++;
94
- }
95
- return pass && variant.spec.length === postMD.specs.length;
96
- });
97
83
  if (postMD.variants.length === 0) {
98
84
  postMD.variants.push({
99
85
  show_understocking: 'true',
@@ -116,6 +102,27 @@ export class ShoppingSettingBasic {
116
102
  preview_image: '',
117
103
  });
118
104
  }
105
+ else {
106
+ if (postMD.variants.length === 1) {
107
+ }
108
+ else {
109
+ postMD.variants = postMD.variants.filter(variant => {
110
+ let pass = true;
111
+ let index = 0;
112
+ for (const b of variant.spec) {
113
+ if (!postMD.specs[index] ||
114
+ !postMD.specs[index].option.find((dd) => {
115
+ return dd.title === b;
116
+ })) {
117
+ pass = false;
118
+ break;
119
+ }
120
+ index++;
121
+ }
122
+ return pass && variant.spec.length === postMD.specs.length;
123
+ });
124
+ }
125
+ }
119
126
  postMD.variants.map((dd) => {
120
127
  dd.checked = undefined;
121
128
  return dd;
@@ -146,6 +153,16 @@ export class ShoppingSettingBasic {
146
153
  const variantsViewID = gvc.glitter.getUUID();
147
154
  const dialog = new ShareDialog(gvc.glitter);
148
155
  const sel_lan = () => vm.language;
156
+ const section_ID = {
157
+ reserve_locations: gvc.glitter.getUUID(),
158
+ dialog_location_main: gvc.glitter.getUUID(),
159
+ dialog_location_list: gvc.glitter.getUUID(),
160
+ store_product_config_panel: gvc.glitter.getUUID(),
161
+ };
162
+ const loading = {
163
+ reserve_locations: true,
164
+ };
165
+ let stockList = [];
149
166
  let selectFunRow = false;
150
167
  let createPage = { page: 'add' };
151
168
  function checkSpecSingle() {
@@ -193,750 +210,914 @@ export class ShoppingSettingBasic {
193
210
  }
194
211
  });
195
212
  }
196
- ShoppingSettingBasic.updateVariants(gvc, postMD, shipment_config, variantsViewID, obj);
197
- const cat_title = (() => {
198
- switch (postMD.product_category) {
199
- case 'commodity':
200
- return '商品';
201
- case 'course':
202
- return '課程';
203
- case 'kitchen':
204
- return '餐飲組合';
205
- default:
206
- return '商品';
207
- }
208
- })();
209
- return BgWidget.container1x2({
210
- html: [
211
- BgWidget.mainCard(html `
212
- <div class="d-flex flex-column guide5-4">
213
- <div style="font-weight: 700;">
214
- ${cat_title}名稱 ${BgWidget.requiredStar()}
215
- ${BgWidget.languageInsignia(vm.language, 'margin-left:5px;')}
216
- </div>
217
- ${BgWidget.editeInput({
218
- gvc: gvc,
219
- title: '',
220
- type: 'text',
221
- default: (_a = language_data.title) !== null && _a !== void 0 ? _a : '',
222
- placeHolder: `請輸入${cat_title}名稱`,
223
- callback: text => {
224
- if (language_data.seo.domain === language_data.title) {
225
- language_data.seo.domain = text;
226
- }
227
- language_data.title = text;
228
- gvc.notifyDataChange('seo');
229
- },
230
- })}
231
- </div>
232
- `),
233
- BgWidget.mainCard([
234
- obj.gvc.bindView(() => {
235
- var _a, _b;
236
- const vm = {
237
- id: obj.gvc.glitter.getUUID(),
238
- type: 'product-detail',
239
- documents: [],
240
- };
241
- language_data.content_array = (_a = language_data.content_array) !== null && _a !== void 0 ? _a : [];
242
- language_data.content_json = (_b = language_data.content_json) !== null && _b !== void 0 ? _b : [];
243
- return {
244
- bind: vm.id,
245
- view: () => __awaiter(this, void 0, void 0, function* () {
246
- return html ` <div class="d-flex align-items-center justify-content-end">
247
- <div class="d-flex align-items-center gap-2">
248
- <div style="color: #393939; font-weight: 700;">
249
- ${cat_title}簡述 ${BgWidget.languageInsignia(sel_lan(), 'margin-left:5px;')}
250
- </div>
251
- </div>
252
- <div class="flex-fill"></div>
213
+ function drawShortDescriptionRichText() {
214
+ return BgWidget.mainCard([
215
+ obj.gvc.bindView(() => {
216
+ var _a, _b;
217
+ const vm = {
218
+ id: obj.gvc.glitter.getUUID(),
219
+ type: 'product-detail',
220
+ documents: [],
221
+ };
222
+ language_data.content_array = (_a = language_data.content_array) !== null && _a !== void 0 ? _a : [];
223
+ language_data.content_json = (_b = language_data.content_json) !== null && _b !== void 0 ? _b : [];
224
+ return {
225
+ bind: vm.id,
226
+ view: () => __awaiter(this, void 0, void 0, function* () {
227
+ return html ` <!-- 繪製商品的簡短描述區塊 -->
228
+ <div class="d-flex align-items-center justify-content-end">
229
+ <div class="d-flex align-items-center gap-2">
230
+ <div style="color: #393939; font-weight: 700;">
231
+ ${cat_title}簡述 ${BgWidget.languageInsignia(sel_lan(), 'margin-left:5px;')}
253
232
  </div>
254
- ${BgWidget.grayNote(`將顯示於${cat_title}名稱下方,快速呈現${cat_title}重點資訊,建議精簡`)}
255
- <div class="my-3">
256
- ${gvc.bindView((() => {
257
- var _a;
258
- const id = gvc.glitter.getUUID();
259
- language_data.sub_title = (_a = language_data.sub_title) !== null && _a !== void 0 ? _a : '';
260
- return {
261
- bind: id,
262
- view: () => {
263
- return html ` <div
264
- class="d-flex justify-content-between align-items-center gap-3 mb-1"
265
- style="cursor: pointer;"
266
- onclick="${gvc.event(() => {
267
- const originContent = `${language_data.sub_title}`;
268
- BgWidget.fullDialog({
269
- gvc: gvc,
270
- title: gvc2 => {
271
- return html `<div class="d-flex align-items-center" style="gap:10px;">
272
- ${`${cat_title}簡述` +
273
- BgWidget.aiChatButton({
274
- gvc: gvc2,
275
- select: 'writer',
276
- click: () => {
277
- ProductAi.generateRichText(gvc, text => {
278
- language_data.sub_title += text;
279
- gvc.notifyDataChange(vm.id);
280
- gvc2.recreateView();
281
- });
282
- },
283
- })}
284
- </div>`;
285
- },
286
- innerHTML: gvc2 => {
287
- return html ` <div>
288
- ${EditorElem.richText({
233
+ </div>
234
+ <div class="flex-fill"></div>
235
+ </div>
236
+ ${BgWidget.grayNote(`將顯示於${cat_title}名稱下方,快速呈現${cat_title}重點資訊,建議精簡`)}
237
+ <div class="my-3">
238
+ ${gvc.bindView((() => {
239
+ var _a;
240
+ const id = gvc.glitter.getUUID();
241
+ language_data.sub_title = (_a = language_data.sub_title) !== null && _a !== void 0 ? _a : '';
242
+ return {
243
+ bind: id,
244
+ view: () => {
245
+ return html ` <div
246
+ class="d-flex justify-content-between align-items-center gap-3 mb-1"
247
+ style="cursor: pointer;"
248
+ onclick="${gvc.event(() => {
249
+ const originContent = `${language_data.sub_title}`;
250
+ BgWidget.fullDialog({
251
+ gvc: gvc,
252
+ title: gvc2 => {
253
+ return html ` <div class="d-flex align-items-center" style="gap:10px;">
254
+ ${`${cat_title}簡述` +
255
+ BgWidget.aiChatButton({
289
256
  gvc: gvc2,
290
- def: language_data.sub_title,
291
- setHeight: '100vh',
292
- hiddenBorder: true,
293
- insertImageEvent: editor => {
294
- const mark = `{{${Tool.randomString(8)}}}`;
295
- editor.selection.setAtEnd(editor.$el.get(0));
296
- editor.html.insert(mark);
297
- editor.undo.saveStep();
298
- imageLibrary.selectImageLibrary(gvc, urlArray => {
299
- if (urlArray.length > 0) {
300
- const imgHTML = urlArray
301
- .map(url => {
302
- return html ` <img src="${url.data}" />`;
303
- })
304
- .join('');
305
- editor.html.set(editor.html
306
- .get(0)
307
- .replace(mark, html ` <div class="d-flex flex-column">${imgHTML}</div>`));
308
- editor.undo.saveStep();
309
- }
310
- else {
311
- dialog.errorMessage({ text: '請選擇至少一張圖片' });
312
- }
313
- }, html ` <div
314
- class="d-flex flex-column"
315
- style="border-radius: 10px 10px 0px 0px;background: #F2F2F2;"
316
- >
317
- 圖片庫
318
- </div>`, {
319
- mul: true,
320
- cancelEvent: () => {
321
- editor.html.set(editor.html.get(0).replace(mark, ''));
322
- editor.undo.saveStep();
323
- },
257
+ select: 'writer',
258
+ click: () => {
259
+ ProductAi.generateRichText(gvc, text => {
260
+ language_data.sub_title += text;
261
+ gvc.notifyDataChange(vm.id);
262
+ gvc2.recreateView();
324
263
  });
325
264
  },
326
- callback: text => {
327
- language_data.sub_title = text;
328
- },
329
- rich_height: `calc(${window.parent.innerHeight}px - 70px - 58px - 49px - 64px - 40px + ${document.body.clientWidth < 800 ? `70` : `0`}px)`,
330
265
  })}
331
- </div>`;
332
- },
333
- footer_html: (gvc2) => {
334
- return [
335
- BgWidget.cancel(gvc2.event(() => {
336
- dialog.checkYesOrNot({
337
- text: '確定要取消並關閉嗎?',
338
- callback: bool => {
339
- if (bool) {
340
- language_data.sub_title = originContent;
341
- gvc2.closeDialog();
342
- }
343
- },
344
- });
345
- })),
346
- BgWidget.save(gvc2.event(() => {
347
- dialog.checkYesOrNot({
348
- text: '確定要儲存並更新嗎?',
349
- callback: bool => {
350
- if (bool) {
351
- gvc2.closeDialog();
352
- gvc.notifyDataChange(id);
353
- }
354
- },
355
- });
356
- })),
357
- ].join('');
358
- },
359
- closeCallback: () => {
360
- language_data.sub_title = originContent;
361
- },
362
- });
363
- })}"
364
- >
365
- ${(() => {
366
- const text = gvc.glitter.utText.removeTag(language_data.sub_title);
367
- return BgWidget.richTextView(Tool.truncateString(text, 100));
368
- })()}
369
- </div>`;
370
- },
371
- };
372
- })())}
373
- </div>`;
374
- }),
375
- };
376
- }),
377
- ].join(BgWidget.mbContainer(12))),
378
- obj.postMD.productType.giveaway
379
- ? ''
380
- : BgWidget.mainCard([
381
- obj.gvc.bindView(() => {
382
- const vm_this = vm;
383
- return (() => {
384
- var _a, _b;
385
- const vm = {
386
- id: obj.gvc.glitter.getUUID(),
387
- type: 'product-detail',
388
- loading: true,
389
- documents: [],
266
+ </div>`;
267
+ },
268
+ innerHTML: gvc2 => {
269
+ return html ` <div>
270
+ ${EditorElem.richText({
271
+ gvc: gvc2,
272
+ def: language_data.sub_title,
273
+ setHeight: '100vh',
274
+ hiddenBorder: true,
275
+ insertImageEvent: editor => {
276
+ const mark = `{{${Tool.randomString(8)}}}`;
277
+ editor.selection.setAtEnd(editor.$el.get(0));
278
+ editor.html.insert(mark);
279
+ editor.undo.saveStep();
280
+ imageLibrary.selectImageLibrary(gvc, urlArray => {
281
+ if (urlArray.length > 0) {
282
+ const imgHTML = urlArray
283
+ .map(url => {
284
+ return html ` <img src="${url.data}" />`;
285
+ })
286
+ .join('');
287
+ editor.html.set(editor.html
288
+ .get(0)
289
+ .replace(mark, html ` <div class="d-flex flex-column">${imgHTML}</div>`));
290
+ editor.undo.saveStep();
291
+ }
292
+ else {
293
+ dialog.errorMessage({ text: '請選擇至少一張圖片' });
294
+ }
295
+ }, html ` <div
296
+ class="d-flex flex-column"
297
+ style="border-radius: 10px 10px 0px 0px;background: #F2F2F2;"
298
+ >
299
+ 圖片庫
300
+ </div>`, {
301
+ mul: true,
302
+ cancelEvent: () => {
303
+ editor.html.set(editor.html.get(0).replace(mark, ''));
304
+ editor.undo.saveStep();
305
+ },
306
+ });
307
+ },
308
+ callback: text => {
309
+ language_data.sub_title = text;
310
+ },
311
+ rich_height: `calc(${window.parent.innerHeight}px - 70px - 58px - 49px - 64px - 40px + ${document.body.clientWidth < 800 ? `70` : `0`}px)`,
312
+ })}
313
+ </div>`;
314
+ },
315
+ footer_html: (gvc2) => {
316
+ return [
317
+ BgWidget.cancel(gvc2.event(() => {
318
+ language_data.sub_title = originContent;
319
+ gvc2.closeDialog();
320
+ })),
321
+ BgWidget.save(gvc2.event(() => {
322
+ gvc2.closeDialog();
323
+ gvc.notifyDataChange(id);
324
+ })),
325
+ ].join('');
326
+ },
327
+ closeCallback: () => {
328
+ language_data.sub_title = originContent;
329
+ },
330
+ });
331
+ })}"
332
+ >
333
+ ${(() => {
334
+ const text = gvc.glitter.utText.removeTag(language_data.sub_title);
335
+ return BgWidget.richTextView(Tool.truncateString(text, 100));
336
+ })()}
337
+ </div>`;
338
+ },
390
339
  };
391
- language_data.content_array = (_a = language_data.content_array) !== null && _a !== void 0 ? _a : [];
392
- language_data.content_json = (_b = language_data.content_json) !== null && _b !== void 0 ? _b : [];
393
- if (!vm_this.content_detail) {
394
- ApiUser.getPublicConfig('text-manager', 'manager').then((data) => {
395
- vm.documents = data.response.value;
396
- if (!Array.isArray(vm.documents)) {
397
- vm.documents = [];
398
- }
399
- vm_this.content_detail = vm.documents;
400
- vm.loading = false;
401
- gvc.notifyDataChange(vm.id);
402
- });
403
- }
404
- else {
405
- vm.documents = vm_this.content_detail;
340
+ })())}
341
+ </div>`;
342
+ }),
343
+ };
344
+ }),
345
+ ].join(BgWidget.mbContainer(12)));
346
+ }
347
+ function drawDetailDescriptionRichText() {
348
+ return obj.postMD.productType.giveaway
349
+ ? ''
350
+ : BgWidget.mainCard([
351
+ obj.gvc.bindView(() => {
352
+ const vm_this = vm;
353
+ return (() => {
354
+ var _a, _b;
355
+ const vm = {
356
+ id: obj.gvc.glitter.getUUID(),
357
+ type: 'product-detail',
358
+ loading: true,
359
+ documents: [],
360
+ };
361
+ language_data.content_array = (_a = language_data.content_array) !== null && _a !== void 0 ? _a : [];
362
+ language_data.content_json = (_b = language_data.content_json) !== null && _b !== void 0 ? _b : [];
363
+ if (!vm_this.content_detail) {
364
+ ApiUser.getPublicConfig('text-manager', 'manager').then((data) => {
365
+ vm.documents = data.response.value;
366
+ if (!Array.isArray(vm.documents)) {
367
+ vm.documents = [];
368
+ }
369
+ vm_this.content_detail = vm.documents;
406
370
  vm.loading = false;
407
- }
408
- return {
409
- bind: vm.id,
410
- view: () => __awaiter(this, void 0, void 0, function* () {
411
- if (vm.loading) {
412
- return BgWidget.spinner();
413
- }
414
- language_data.content_array = language_data.content_array.filter((id) => {
415
- return vm.documents.some((item) => item.id === id);
416
- });
417
- language_data.content_json = language_data.content_json.filter((d) => {
418
- return vm.documents.some((item) => item.id === d.id);
419
- });
420
- function formatRichtext(text, tags, jsonData) {
421
- var _a, _b, _c;
422
- let gText = `${text}`;
423
- if (tags && tags.length > 0) {
424
- for (const item of tags) {
425
- const data = jsonData.find(j => j.key === item.key);
426
- const textImage = data && data.value
427
- ? html `<span
428
- style="font-size: ${(_a = item.font_size) !== null && _a !== void 0 ? _a : '14'}px; color: ${(_b = item.font_color) !== null && _b !== void 0 ? _b : '#393939'}; background: ${(_c = item.font_bgr) !== null && _c !== void 0 ? _c : '#fff'}"
429
- >${data.value}</span
430
- >`
431
- : html `#${item.title}#`;
432
- const regex = new RegExp(`@{{${item.key}}}`, 'g');
433
- gText = gText.replace(regex, textImage);
434
- }
371
+ gvc.notifyDataChange(vm.id);
372
+ });
373
+ }
374
+ else {
375
+ vm.documents = vm_this.content_detail;
376
+ vm.loading = false;
377
+ }
378
+ return {
379
+ bind: vm.id,
380
+ view: () => __awaiter(this, void 0, void 0, function* () {
381
+ if (vm.loading) {
382
+ return BgWidget.spinner();
383
+ }
384
+ language_data.content_array = language_data.content_array.filter((id) => {
385
+ return vm.documents.some((item) => item.id === id);
386
+ });
387
+ language_data.content_json = language_data.content_json.filter((d) => {
388
+ return vm.documents.some((item) => item.id === d.id);
389
+ });
390
+ function formatRichtext(text, tags, jsonData) {
391
+ var _a, _b, _c;
392
+ let gText = `${text}`;
393
+ if (tags && tags.length > 0) {
394
+ for (const item of tags) {
395
+ const data = jsonData.find(j => j.key === item.key);
396
+ const textImage = data && data.value
397
+ ? html `<span
398
+ style="font-size: ${(_a = item.font_size) !== null && _a !== void 0 ? _a : '14'}px; color: ${(_b = item.font_color) !== null && _b !== void 0 ? _b : '#393939'}; background: ${(_c = item.font_bgr) !== null && _c !== void 0 ? _c : '#fff'}"
399
+ >${data.value}</span
400
+ >`
401
+ : html `#${item.title}#`;
402
+ const regex = new RegExp(`@{{${item.key}}}`, 'g');
403
+ gText = gText.replace(regex, textImage);
435
404
  }
436
- return gText;
437
405
  }
438
- return html ` <div class="d-flex align-items-center justify-content-end mb-3">
439
- <div class="d-flex align-items-center gap-2">
440
- <div style="color: #393939; font-weight: 700;">
441
- ${cat_title}詳細描述 ${BgWidget.languageInsignia(sel_lan(), 'margin-left:5px;')}
442
- </div>
443
- </div>
444
- <div class="flex-fill"></div>
445
- <div
446
- class="cursor_pointer"
447
- onclick="${gvc.event(() => {
448
- BgWidget.dialog({
449
- gvc: gvc,
450
- title: '設定',
451
- xmark: () => {
452
- return new Promise(resolve => {
453
- gvc.notifyDataChange(vm.id);
454
- resolve(true);
455
- });
456
- },
457
- innerHTML: gvc => {
458
- const id = gvc.glitter.getUUID();
459
- return gvc.bindView(() => {
460
- return {
461
- bind: id,
462
- view: () => {
463
- return vm.documents
464
- .map((dd) => {
465
- return html ` <li class="w-100 px-2">
466
- <div class="w-100 d-flex justify-content-between">
467
- <div class="d-flex justify-content-start align-items-center gap-3">
468
- <i
469
- class="fa-solid fa-grip-dots-vertical dragItem cursor_pointer"
470
- ></i>
471
- <div class="tx_normal">${dd.title}</div>
472
- </div>
473
- ${gvc.bindView((() => {
474
- const iconId = gvc.glitter.getUUID();
475
- return {
476
- bind: iconId,
477
- view: () => {
478
- return html ` <i
479
- class="${language_data.content_array.includes(dd.id)
480
- ? 'fa-solid fa-eye'
481
- : 'fa-sharp fa-solid fa-eye-slash'} d-flex align-items-center justify-content-center cursor_pointer"
482
- onclick="${gvc.event(() => {
483
- if (language_data.content_array.includes(dd.id)) {
484
- language_data.content_array =
485
- language_data.content_array.filter((d) => d !== dd.id);
486
- }
487
- else {
488
- language_data.content_array.push(dd.id);
489
- }
490
- gvc.notifyDataChange(iconId);
491
- })}"
492
- ></i>`;
493
- },
494
- divCreate: {
495
- class: 'd-flex',
496
- },
497
- };
498
- })())}
499
- </div>
500
- </li>`;
501
- })
502
- .join('');
503
- },
504
- divCreate: {
505
- elem: 'ul',
506
- class: 'w-100 my-2 d-flex flex-column gap-4',
507
- },
508
- onCreate: () => {
509
- if (!vm.loading) {
510
- gvc.glitter.addMtScript([
511
- {
512
- src: `https://raw.githack.com/SortableJS/Sortable/master/Sortable.js`,
406
+ return gText;
407
+ }
408
+ return html `<!-- 繪製商品的詳細描述區塊-->
409
+ <div class="d-flex align-items-center justify-content-end mb-3">
410
+ <div class="d-flex align-items-center gap-2">
411
+ <div style="color: #393939; font-weight: 700;">
412
+ ${cat_title}詳細描述 ${BgWidget.languageInsignia(sel_lan(), 'margin-left:5px;')}
413
+ </div>
414
+ </div>
415
+ <div class="flex-fill"></div>
416
+ <div
417
+ class="cursor_pointer"
418
+ onclick="${gvc.event(() => {
419
+ BgWidget.dialog({
420
+ gvc: gvc,
421
+ title: '設定',
422
+ xmark: () => {
423
+ return new Promise(resolve => {
424
+ gvc.notifyDataChange(vm.id);
425
+ resolve(true);
426
+ });
427
+ },
428
+ innerHTML: gvc => {
429
+ const id = gvc.glitter.getUUID();
430
+ return gvc.bindView(() => {
431
+ return {
432
+ bind: id,
433
+ view: () => {
434
+ return vm.documents
435
+ .map((dd) => {
436
+ return html ` <li class="w-100 px-2">
437
+ <div class="w-100 d-flex justify-content-between">
438
+ <div class="d-flex justify-content-start align-items-center gap-3">
439
+ <i class="fa-solid fa-grip-dots-vertical dragItem cursor_pointer"></i>
440
+ <div class="tx_normal">${dd.title}</div>
441
+ </div>
442
+ ${gvc.bindView((() => {
443
+ const iconId = gvc.glitter.getUUID();
444
+ return {
445
+ bind: iconId,
446
+ view: () => {
447
+ return html ` <i
448
+ class="${language_data.content_array.includes(dd.id)
449
+ ? 'fa-solid fa-eye'
450
+ : 'fa-sharp fa-solid fa-eye-slash'} d-flex align-items-center justify-content-center cursor_pointer"
451
+ onclick="${gvc.event(() => {
452
+ if (language_data.content_array.includes(dd.id)) {
453
+ language_data.content_array =
454
+ language_data.content_array.filter((d) => d !== dd.id);
455
+ }
456
+ else {
457
+ language_data.content_array.push(dd.id);
458
+ }
459
+ gvc.notifyDataChange(iconId);
460
+ })}"
461
+ ></i>`;
513
462
  },
514
- ], () => { }, () => { });
515
- const interval = setInterval(() => {
516
- if (window.Sortable) {
517
- try {
518
- gvc.addStyle(`
463
+ divCreate: {
464
+ class: 'd-flex',
465
+ },
466
+ };
467
+ })())}
468
+ </div>
469
+ </li>`;
470
+ })
471
+ .join('');
472
+ },
473
+ divCreate: {
474
+ elem: 'ul',
475
+ class: 'w-100 my-2 d-flex flex-column gap-4',
476
+ },
477
+ onCreate: () => {
478
+ if (!vm.loading) {
479
+ gvc.glitter.addMtScript([
480
+ {
481
+ src: `https://raw.githack.com/SortableJS/Sortable/master/Sortable.js`,
482
+ },
483
+ ], () => { }, () => { });
484
+ const interval = setInterval(() => {
485
+ if (window.Sortable) {
486
+ try {
487
+ gvc.addStyle(`
519
488
  ul {
520
489
  list-style: none;
521
490
  padding: 0;
522
491
  }
523
492
  `);
524
- function swapArr(arr, t1, t2) {
525
- const data = arr[t1];
526
- arr.splice(t1, 1);
527
- arr.splice(t2, 0, data);
528
- }
529
- let startIndex = 0;
530
- Sortable.create(gvc.getBindViewElem(id).get(0), {
531
- group: id,
532
- animation: 100,
533
- handle: '.dragItem',
534
- onEnd: (evt) => {
535
- swapArr(vm.documents, startIndex, evt.newIndex);
536
- ApiUser.setPublicConfig({
537
- key: 'text-manager',
538
- user_id: 'manager',
539
- value: vm.documents,
540
- }).then(result => {
541
- if (!result.response.result) {
542
- dialog.errorMessage({ text: '設定失敗' });
543
- }
544
- });
545
- },
546
- onStart: (evt) => {
547
- startIndex = evt.oldIndex;
548
- },
549
- });
493
+ function swapArr(arr, t1, t2) {
494
+ const data = arr[t1];
495
+ arr.splice(t1, 1);
496
+ arr.splice(t2, 0, data);
550
497
  }
551
- catch (e) { }
552
- clearInterval(interval);
498
+ let startIndex = 0;
499
+ Sortable.create(gvc.getBindViewElem(id).get(0), {
500
+ group: id,
501
+ animation: 100,
502
+ handle: '.dragItem',
503
+ onEnd: (evt) => {
504
+ swapArr(vm.documents, startIndex, evt.newIndex);
505
+ ApiUser.setPublicConfig({
506
+ key: 'text-manager',
507
+ user_id: 'manager',
508
+ value: vm.documents,
509
+ }).then(result => {
510
+ if (!result.response.result) {
511
+ dialog.errorMessage({ text: '設定失敗' });
512
+ }
513
+ });
514
+ },
515
+ onStart: (evt) => {
516
+ startIndex = evt.oldIndex;
517
+ },
518
+ });
553
519
  }
554
- }, 100);
555
- }
556
- },
557
- };
520
+ catch (e) { }
521
+ clearInterval(interval);
522
+ }
523
+ }, 100);
524
+ }
525
+ },
526
+ };
527
+ });
528
+ },
529
+ });
530
+ })}"
531
+ >
532
+ 設定<i class="fa-regular fa-gear ms-1"></i>
533
+ </div>
534
+ </div>
535
+ <div class="my-3">
536
+ ${gvc.bindView((() => {
537
+ const id = gvc.glitter.getUUID();
538
+ return {
539
+ bind: id,
540
+ view: () => {
541
+ return html ` <div
542
+ class="d-flex justify-content-between align-items-center gap-3 mb-1"
543
+ style="cursor: pointer;"
544
+ onclick="${gvc.event(() => {
545
+ const originContent = `${language_data.content}`;
546
+ BgWidget.fullDialog({
547
+ gvc: gvc,
548
+ title: gvc2 => {
549
+ return html ` <div class="d-flex align-items-center" style="gap:10px;">
550
+ ${`${cat_title}描述` +
551
+ BgWidget.aiChatButton({
552
+ gvc: gvc2,
553
+ select: 'writer',
554
+ click: () => {
555
+ ProductAi.generateRichText(gvc, text => {
556
+ language_data.content += text;
557
+ gvc.notifyDataChange(vm.id);
558
+ gvc2.recreateView();
559
+ });
560
+ },
561
+ })}
562
+ </div>`;
563
+ },
564
+ innerHTML: gvc2 => {
565
+ return html ` <div>
566
+ ${EditorElem.richText({
567
+ gvc: gvc2,
568
+ def: language_data.content,
569
+ setHeight: '100vh',
570
+ hiddenBorder: true,
571
+ insertImageEvent: editor => {
572
+ const mark = `{{${Tool.randomString(8)}}}`;
573
+ editor.selection.setAtEnd(editor.$el.get(0));
574
+ editor.html.insert(mark);
575
+ editor.undo.saveStep();
576
+ imageLibrary.selectImageLibrary(gvc, urlArray => {
577
+ if (urlArray.length > 0) {
578
+ const imgHTML = urlArray
579
+ .map(url => {
580
+ return html ` <img src="${url.data}" />`;
581
+ })
582
+ .join('');
583
+ editor.html.set(editor.html
584
+ .get(0)
585
+ .replace(mark, html ` <div class="d-flex flex-column">${imgHTML}</div>`));
586
+ editor.undo.saveStep();
587
+ }
588
+ else {
589
+ dialog.errorMessage({ text: '請選擇至少一張圖片' });
590
+ }
591
+ }, html ` <div
592
+ class="d-flex flex-column"
593
+ style="border-radius: 10px 10px 0px 0px;background: #F2F2F2;"
594
+ >
595
+ 圖片庫
596
+ </div>`, {
597
+ mul: true,
598
+ cancelEvent: () => {
599
+ editor.html.set(editor.html.get(0).replace(mark, ''));
600
+ editor.undo.saveStep();
601
+ },
602
+ });
603
+ },
604
+ callback: text => {
605
+ language_data.content = text;
606
+ },
607
+ rich_height: `calc(${window.parent.innerHeight}px - 70px - 58px - 49px - 64px - 40px + ${document.body.clientWidth < 800 ? `70` : `0`}px)`,
608
+ })}
609
+ </div>`;
610
+ },
611
+ footer_html: (gvc2) => {
612
+ return [
613
+ BgWidget.cancel(gvc2.event(() => {
614
+ language_data.content = originContent;
615
+ gvc2.closeDialog();
616
+ })),
617
+ BgWidget.save(gvc2.event(() => {
618
+ gvc2.closeDialog();
619
+ gvc.notifyDataChange(id);
620
+ })),
621
+ ].join('');
622
+ },
623
+ closeCallback: () => {
624
+ language_data.content = originContent;
625
+ },
558
626
  });
559
- },
560
- });
561
- })}"
562
- >
563
- 設定<i class="fa-regular fa-gear ms-1"></i>
564
- </div>
565
- </div>
566
- <div class="my-3">
567
- ${gvc.bindView((() => {
568
- const id = gvc.glitter.getUUID();
569
- return {
570
- bind: id,
571
- view: () => {
627
+ })}"
628
+ >
629
+ ${(() => {
630
+ const text = gvc.glitter.utText.removeTag(language_data.content);
631
+ return BgWidget.richTextView(Tool.truncateString(text, 100));
632
+ })()}
633
+ </div>`;
634
+ },
635
+ };
636
+ })())}
637
+ </div>
638
+ ${(vm.documents || [])
639
+ .filter((item) => {
640
+ return language_data.content_array.includes(item.id);
641
+ })
642
+ .map((item, index) => {
643
+ return BgWidget.openBoxContainer({
644
+ gvc,
645
+ tag: 'content_array',
646
+ title: item.title,
647
+ insideHTML: (() => {
648
+ if (item.data.tags && item.data.tags.length > 0) {
649
+ const id = obj.gvc.glitter.getUUID();
572
650
  return html ` <div
573
- class="d-flex justify-content-between align-items-center gap-3 mb-1"
574
- style="cursor: pointer;"
575
- onclick="${gvc.event(() => {
576
- const originContent = `${language_data.content}`;
577
- BgWidget.fullDialog({
651
+ class="cursor_pointer text-end me-1 mb-2"
652
+ onclick="${gvc.event(() => {
653
+ const originJson = JSON.parse(JSON.stringify(language_data.content_json));
654
+ BgWidget.settingDialog({
578
655
  gvc: gvc,
579
- title: gvc2 => {
580
- return html `<div class="d-flex align-items-center" style="gap:10px;">
581
- ${`${cat_title}描述` +
582
- BgWidget.aiChatButton({
583
- gvc: gvc2,
584
- select: 'writer',
585
- click: () => {
586
- ProductAi.generateRichText(gvc, text => {
587
- language_data.content += text;
588
- gvc.notifyDataChange(vm.id);
589
- gvc2.recreateView();
590
- });
591
- },
592
- })}
593
- </div>`;
594
- },
595
- innerHTML: gvc2 => {
656
+ title: '設定',
657
+ innerHTML: gvc => {
596
658
  return html ` <div>
597
- ${EditorElem.richText({
598
- gvc: gvc2,
599
- def: language_data.content,
600
- setHeight: '100vh',
601
- hiddenBorder: true,
602
- insertImageEvent: editor => {
603
- const mark = `{{${Tool.randomString(8)}}}`;
604
- editor.selection.setAtEnd(editor.$el.get(0));
605
- editor.html.insert(mark);
606
- editor.undo.saveStep();
607
- imageLibrary.selectImageLibrary(gvc, urlArray => {
608
- if (urlArray.length > 0) {
609
- const imgHTML = urlArray
610
- .map(url => {
611
- return html ` <img src="${url.data}" />`;
612
- })
613
- .join('');
614
- editor.html.set(editor.html
615
- .get(0)
616
- .replace(mark, html ` <div class="d-flex flex-column">${imgHTML}</div>`));
617
- editor.undo.saveStep();
659
+ ${item.data.tags
660
+ .map((tag) => {
661
+ return html ` <div>
662
+ ${BgWidget.editeInput({
663
+ gvc,
664
+ title: tag.title,
665
+ default: (() => {
666
+ const docIndex = language_data.content_json.findIndex((c) => c.id === item.id);
667
+ if (docIndex === -1) {
668
+ return '';
618
669
  }
619
- else {
620
- dialog.errorMessage({ text: '請選擇至少一張圖片' });
670
+ if (language_data.content_json[docIndex].list === undefined) {
671
+ return '';
621
672
  }
622
- }, html ` <div
623
- class="d-flex flex-column"
624
- style="border-radius: 10px 10px 0px 0px;background: #F2F2F2;"
625
- >
626
- 圖片庫
627
- </div>`, {
628
- mul: true,
629
- cancelEvent: () => {
630
- editor.html.set(editor.html.get(0).replace(mark, ''));
631
- editor.undo.saveStep();
632
- },
633
- });
634
- },
635
- callback: text => {
636
- language_data.content = text;
637
- },
638
- rich_height: `calc(${window.parent.innerHeight}px - 70px - 58px - 49px - 64px - 40px + ${document.body.clientWidth < 800 ? `70` : `0`}px)`,
639
- })}
640
- </div>`;
641
- },
642
- footer_html: (gvc2) => {
643
- return [
644
- BgWidget.cancel(gvc2.event(() => {
645
- dialog.checkYesOrNot({
646
- text: '確定要取消並關閉嗎?',
647
- callback: bool => {
648
- if (bool) {
649
- language_data.content = originContent;
650
- gvc2.closeDialog();
651
- }
652
- },
653
- });
673
+ const keyIndex = language_data.content_json[docIndex].list.findIndex((l) => l.key === tag.key);
674
+ if (keyIndex === -1) {
675
+ return '';
676
+ }
677
+ return language_data.content_json[docIndex].list[keyIndex]
678
+ .value;
679
+ })(),
680
+ callback: text => {
681
+ const docIndex = language_data.content_json.findIndex((c) => c.id === item.id);
682
+ if (docIndex === -1) {
683
+ language_data.content_json.push({
684
+ id: item.id,
685
+ list: [
686
+ {
687
+ key: tag.key,
688
+ value: text,
689
+ },
690
+ ],
691
+ });
692
+ return;
693
+ }
694
+ if (language_data.content_json[docIndex].list === undefined) {
695
+ language_data.content_json[docIndex].list = [
696
+ {
697
+ key: tag.key,
698
+ value: text,
699
+ },
700
+ ];
701
+ return;
702
+ }
703
+ const keyIndex = language_data.content_json[docIndex].list.findIndex((l) => l.key === tag.key);
704
+ if (keyIndex === -1) {
705
+ language_data.content_json[docIndex].list.push({
706
+ key: tag.key,
707
+ value: text,
708
+ });
709
+ return;
710
+ }
711
+ language_data.content_json[docIndex].list[keyIndex].value =
712
+ text;
713
+ },
714
+ placeHolder: '輸入文本標籤',
715
+ })}
716
+ </div>`;
717
+ })
718
+ .join(BgWidget.mbContainer(12))}
719
+ </div>`;
720
+ },
721
+ footer_html: (gvc2) => {
722
+ return [
723
+ BgWidget.cancel(gvc2.event(() => {
724
+ language_data.content_json = originJson;
725
+ gvc2.closeDialog();
654
726
  })),
655
727
  BgWidget.save(gvc2.event(() => {
656
- dialog.checkYesOrNot({
657
- text: '確定要儲存並更新嗎?',
658
- callback: bool => {
659
- if (bool) {
660
- gvc2.closeDialog();
661
- gvc.notifyDataChange(id);
662
- }
663
- },
664
- });
728
+ gvc2.closeDialog();
729
+ gvc.notifyDataChange(`${id}-${index}`);
665
730
  })),
666
731
  ].join('');
667
732
  },
668
733
  closeCallback: () => {
669
- language_data.content = originContent;
734
+ language_data.content_json = originJson;
670
735
  },
671
736
  });
672
737
  })}"
673
- >
674
- ${(() => {
675
- const text = gvc.glitter.utText.removeTag(language_data.content);
676
- return BgWidget.richTextView(Tool.truncateString(text, 100));
677
- })()}
678
- </div>`;
679
- },
680
- };
681
- })())}
682
- </div>
683
- ${(vm.documents || [])
684
- .filter((item) => {
685
- return language_data.content_array.includes(item.id);
686
- })
687
- .map((item, index) => {
688
- return BgWidget.openBoxContainer({
689
- gvc,
690
- tag: 'content_array',
691
- title: item.title,
692
- insideHTML: (() => {
693
- if (item.data.tags && item.data.tags.length > 0) {
694
- const id = obj.gvc.glitter.getUUID();
695
- return html ` <div
696
- class="cursor_pointer text-end me-1 mb-2"
697
- onclick="${gvc.event(() => {
698
- const originJson = JSON.parse(JSON.stringify(language_data.content_json));
699
- BgWidget.settingDialog({
700
- gvc: gvc,
701
- title: '設定',
702
- innerHTML: gvc => {
703
- return html ` <div>
704
- ${item.data.tags
705
- .map((tag) => {
706
- return html ` <div>
707
- ${BgWidget.editeInput({
708
- gvc,
709
- title: tag.title,
710
- default: (() => {
711
- const docIndex = language_data.content_json.findIndex((c) => c.id === item.id);
712
- if (docIndex === -1) {
713
- return '';
714
- }
715
- if (language_data.content_json[docIndex].list === undefined) {
716
- return '';
717
- }
718
- const keyIndex = language_data.content_json[docIndex].list.findIndex((l) => l.key === tag.key);
719
- if (keyIndex === -1) {
720
- return '';
721
- }
722
- return language_data.content_json[docIndex].list[keyIndex]
723
- .value;
724
- })(),
725
- callback: text => {
726
- const docIndex = language_data.content_json.findIndex((c) => c.id === item.id);
727
- if (docIndex === -1) {
728
- language_data.content_json.push({
729
- id: item.id,
730
- list: [
731
- {
732
- key: tag.key,
733
- value: text,
734
- },
735
- ],
736
- });
737
- return;
738
- }
739
- if (language_data.content_json[docIndex].list === undefined) {
740
- language_data.content_json[docIndex].list = [
741
- {
742
- key: tag.key,
743
- value: text,
744
- },
745
- ];
746
- return;
747
- }
748
- const keyIndex = language_data.content_json[docIndex].list.findIndex((l) => l.key === tag.key);
749
- if (keyIndex === -1) {
750
- language_data.content_json[docIndex].list.push({
751
- key: tag.key,
752
- value: text,
753
- });
754
- return;
755
- }
756
- language_data.content_json[docIndex].list[keyIndex].value =
757
- text;
758
- },
759
- placeHolder: '輸入文本標籤',
760
- })}
761
- </div>`;
762
- })
763
- .join(BgWidget.mbContainer(12))}
764
- </div>`;
765
- },
766
- footer_html: (gvc2) => {
767
- return [
768
- BgWidget.cancel(gvc2.event(() => {
769
- language_data.content_json = originJson;
770
- gvc2.closeDialog();
771
- })),
772
- BgWidget.save(gvc2.event(() => {
773
- gvc2.closeDialog();
774
- gvc.notifyDataChange(`${id}-${index}`);
775
- })),
776
- ].join('');
777
- },
778
- closeCallback: () => {
779
- language_data.content_json = originJson;
780
- },
781
- });
782
- })}"
783
- >
784
- 標籤設值
785
- </div>
786
- ${gvc.bindView((() => {
787
- return {
788
- bind: `${id}-${index}`,
789
- view: () => {
790
- const content = item.data.content || '';
791
- const tags = item.data.tags;
792
- const jsonData = language_data.content_json.find((c) => c.id === item.id);
793
- return html ` <div
794
- style="border: 2px #DDDDDD solid; border-radius: 6px; padding: 12px;"
795
- >
796
- ${tags
797
- ? formatRichtext(content, tags, jsonData ? jsonData.list : [])
798
- : content}
799
- </div>`;
800
- },
801
- };
802
- })())}`;
803
- }
804
- return html ` <div
805
- style="border: 1px #DDDDDD solid; border-radius: 6px; padding: 12px"
806
738
  >
807
- ${item.data.content || ''}
808
- </div>`;
809
- })(),
810
- });
811
- })
812
- .join(BgWidget.mbContainer(8))}`;
813
- }),
814
- };
815
- })();
816
- }),
817
- ].join(BgWidget.mbContainer(12))),
818
- BgWidget.mainCard(html `
819
- <div
820
- class="d-flex align-items-center justify-content-between"
821
- style="color: #393939;font-size: 16px;font-weight: 700;margin-bottom: 18px;"
822
- >
823
- <div class="d-flex align-items-center">
824
- 圖片${BgWidget.languageInsignia(sel_lan(), 'margin-left:5px;')}
825
- </div>
826
- <div class="d-flex align-items-center gap-2">
827
- ${BgWidget.customButton({
828
- button: {
829
- color: 'black',
830
- size: 'sm',
831
- },
832
- text: {
833
- name: '上傳圖片',
834
- },
835
- event: gvc.event(() => {
836
- EditorElem.uploadFileFunction({
837
- gvc: gvc,
838
- callback: (images) => {
839
- const addImage = (urlArray) => {
840
- if (urlArray.length > 0) {
841
- language_data.preview_image.push(...urlArray);
842
- saveImageLib(urlArray);
843
- obj.gvc.notifyDataChange('image_view');
844
- }
845
- else {
846
- dialog.errorMessage({ text: '請選擇至少一張圖片' });
847
- }
848
- };
849
- addImage(images);
850
- },
851
- type: `image/*`,
852
- return_array: true,
853
- multiple: true,
854
- });
739
+ 標籤設值
740
+ </div>
741
+ ${gvc.bindView((() => {
742
+ return {
743
+ bind: `${id}-${index}`,
744
+ view: () => {
745
+ const content = item.data.content || '';
746
+ const tags = item.data.tags;
747
+ const jsonData = language_data.content_json.find((c) => c.id === item.id);
748
+ return html ` <div
749
+ style="border: 2px #DDDDDD solid; border-radius: 6px; padding: 12px;"
750
+ >
751
+ ${tags
752
+ ? formatRichtext(content, tags, jsonData ? jsonData.list : [])
753
+ : content}
754
+ </div>`;
755
+ },
756
+ };
757
+ })())}`;
758
+ }
759
+ return html ` <div style="border: 1px #DDDDDD solid; border-radius: 6px; padding: 12px">
760
+ ${item.data.content || ''}
761
+ </div>`;
762
+ })(),
763
+ });
764
+ })
765
+ .join(BgWidget.mbContainer(8))}`;
766
+ }),
767
+ };
768
+ })();
855
769
  }),
856
- })}
857
- ${BgWidget.customButton({
858
- button: {
859
- color: 'black',
860
- size: 'sm',
770
+ ].join(BgWidget.mbContainer(12)));
771
+ }
772
+ function drawProductImageBlock() {
773
+ return BgWidget.mainCard(html `<!--繪製商品圖片展示區塊-->
774
+ <div
775
+ class="d-flex align-items-center justify-content-between"
776
+ style="color: #393939;font-size: 16px;font-weight: 700;margin-bottom: 18px;"
777
+ >
778
+ <div class="d-flex align-items-center">圖片${BgWidget.languageInsignia(sel_lan(), 'margin-left:5px;')}</div>
779
+ <div class="d-flex align-items-center gap-2">
780
+ ${BgWidget.customButton({
781
+ button: {
782
+ color: 'black',
783
+ size: 'sm',
784
+ },
785
+ text: {
786
+ name: '上傳圖片',
787
+ },
788
+ event: gvc.event(() => {
789
+ EditorElem.uploadFileFunction({
790
+ gvc: gvc,
791
+ callback: (images) => {
792
+ const addImage = (urlArray) => {
793
+ if (urlArray.length > 0) {
794
+ language_data.preview_image.push(...urlArray);
795
+ saveImageLib(urlArray);
796
+ obj.gvc.notifyDataChange('image_view');
797
+ }
798
+ else {
799
+ dialog.errorMessage({ text: '請選擇至少一張圖片' });
800
+ }
801
+ };
802
+ addImage(images);
803
+ },
804
+ type: `image/*`,
805
+ return_array: true,
806
+ multiple: true,
807
+ });
808
+ }),
809
+ })}
810
+ ${BgWidget.customButton({
811
+ button: {
812
+ color: 'black',
813
+ size: 'sm',
814
+ },
815
+ text: {
816
+ name: '從圖片庫選取',
817
+ },
818
+ event: gvc.event(() => {
819
+ imageLibrary.selectImageLibrary(gvc, urlArray => {
820
+ if (urlArray.length > 0) {
821
+ language_data.preview_image.push(...urlArray.map((data) => {
822
+ return data.data;
823
+ }));
824
+ obj.gvc.notifyDataChange('image_view');
825
+ }
826
+ else {
827
+ dialog.errorMessage({ text: '請選擇至少一張圖片' });
828
+ }
829
+ }, html ` <div class="d-flex flex-column" style="border-radius: 10px 10px 0px 0px;background: #F2F2F2;">
830
+ 圖片庫
831
+ </div>`, { mul: true });
832
+ }),
833
+ })}
834
+ </div>
835
+ </div>
836
+ ${obj.gvc.bindView(() => {
837
+ return {
838
+ bind: 'image_view',
839
+ view: () => {
840
+ return (html ` <div class="my-2"></div>` +
841
+ EditorElem.flexMediaManagerV2({
842
+ gvc: obj.gvc,
843
+ data: language_data.preview_image,
844
+ event: {
845
+ delete: (index) => {
846
+ postMD.variants.forEach((variant) => {
847
+ var _a, _b;
848
+ if (variant.preview_image === language_data.preview_image[index]) {
849
+ variant.preview_image = (_a = language_data.preview_image[0]) !== null && _a !== void 0 ? _a : BgWidget.noImageURL;
850
+ }
851
+ if (variant[`preview_image_${vm.language}`] === language_data.preview_image[index]) {
852
+ variant[`preview_image_${vm.language}`] =
853
+ (_b = language_data.preview_image[0]) !== null && _b !== void 0 ? _b : BgWidget.noImageURL;
854
+ }
855
+ });
856
+ ShoppingSettingBasic.updateVariants(gvc, postMD, shipment_config, variantsViewID, obj);
857
+ },
858
+ },
859
+ }));
861
860
  },
862
- text: {
863
- name: '從圖片庫選取',
861
+ divCreate: {
862
+ class: `d-flex w-100`,
863
+ style: `overflow-y:scroll;height:180px;`,
864
864
  },
865
- event: gvc.event(() => {
866
- imageLibrary.selectImageLibrary(gvc, urlArray => {
867
- if (urlArray.length > 0) {
868
- language_data.preview_image.push(...urlArray.map((data) => {
869
- return data.data;
870
- }));
871
- obj.gvc.notifyDataChange('image_view');
872
- }
873
- else {
874
- dialog.errorMessage({ text: '請選擇至少一張圖片' });
875
- }
876
- }, html ` <div
877
- class="d-flex flex-column"
878
- style="border-radius: 10px 10px 0px 0px;background: #F2F2F2;"
865
+ };
866
+ })}
867
+ `);
868
+ }
869
+ function drawReserveLocations() {
870
+ if (postMD.product_category === 'reserve') {
871
+ function getStockStore() {
872
+ ApiUser.getPublicConfig('store_manager', 'manager').then((storeData) => {
873
+ if (storeData.result) {
874
+ stockList = storeData.response.value.list.filter((store) => store.is_shop);
875
+ postMD.reserve_locations = stockList;
876
+ console.log('postMD.reserve_locations -- ', postMD.reserve_locations);
877
+ gvc.notifyDataChange([section_ID.reserve_locations, section_ID.store_product_config_panel]);
878
+ }
879
+ });
880
+ loading.reserve_locations = false;
881
+ }
882
+ return gvc.bindView({
883
+ bind: section_ID.reserve_locations,
884
+ view: () => {
885
+ gvc.addStyle(css `
886
+ .location-btn {
887
+ height: 34px;
888
+ padding: 0 12px;
889
+ border-radius: 10px;
890
+ border: 1px solid #393939;
891
+ gap: 6px;
892
+ }
893
+
894
+ .location-dialog {
895
+ display: flex;
896
+ width: 504px;
897
+
898
+ flex-direction: column;
899
+ align-items: center;
900
+ gap: 18px;
901
+ border-radius: 10px;
902
+ background: #fff;
903
+ }
904
+
905
+ .location-dialog .title {
906
+ display: flex;
907
+ padding: 12px 20px;
908
+ justify-content: space-between;
909
+ border-radius: 10px 10px 0 0;
910
+ align-items: center;
911
+ background: #f2f2f2;
912
+ color: #393939;
913
+ }
914
+
915
+ .location-dialog .section {
916
+ padding: 0 20px;
917
+ gap: 12px;
918
+ }
919
+ `);
920
+ if (loading.reserve_locations) {
921
+ getStockStore();
922
+ return ``;
923
+ }
924
+ function popoutSelectLocation(callback) {
925
+ gvc.glitter.innerDialog(gvc => {
926
+ function drawRaw(store) {
927
+ const checked = temp_Reserve_locations.filter(store2 => store2.id == store.id).length > 0;
928
+ return html `
929
+ <div class="w-100 d-flex align-items-center" style="padding:0 4px;gap:8px;">
930
+ ${BgWidget.checkInput(gvc, checked, () => {
931
+ if (checked) {
932
+ temp_Reserve_locations.splice(temp_Reserve_locations.findIndex(store2 => store2.id == store.id), 1);
933
+ }
934
+ else {
935
+ temp_Reserve_locations.push(store);
936
+ }
937
+ gvc.notifyDataChange([section_ID.dialog_location_main]);
938
+ })}
939
+ <div>${store.name}</div>
940
+ </div>
941
+ `;
942
+ }
943
+ let temp_Reserve_locations = structuredClone(postMD.reserve_locations);
944
+ let searchText = '';
945
+ return gvc.bindView({
946
+ bind: section_ID.dialog_location_main,
947
+ view: () => {
948
+ const allCheck = temp_Reserve_locations.length == stockList.length;
949
+ return html `
950
+ <div class="title w-100">
951
+ <div class="tx_normal">新增服務地點</div>
952
+ <i
953
+ class="fa-solid fa-xmark cursor_pointer"
954
+ onclick="${gvc.event(() => {
955
+ gvc.glitter.closeDiaLog('location-select');
956
+ })}"
957
+ ></i>
958
+ </div>
959
+ <div class="section w-100 d-flex flex-column">
960
+ ${BgWidget.searchFilter(gvc.event(e => {
961
+ searchText = e.value;
962
+ gvc.notifyDataChange(section_ID.dialog_location_list);
963
+ }), searchText || '', '搜尋門市')}
964
+ <div class="d-flex align-items-center" style="gap:8px;padding:4px 4px 0; ">
965
+ ${BgWidget.checkInput(gvc, allCheck, () => {
966
+ if (allCheck) {
967
+ temp_Reserve_locations = [];
968
+ }
969
+ else {
970
+ temp_Reserve_locations = stockList;
971
+ }
972
+ gvc.notifyDataChange([section_ID.dialog_location_list, section_ID.dialog_location_main]);
973
+ })}
974
+ 門市名稱
975
+ </div>
976
+ <hr class="w-100" />
977
+ ${gvc.bindView({
978
+ bind: section_ID.dialog_location_list,
979
+ view: () => {
980
+ const showList = stockList.filter(store => store.name.toLowerCase().includes(searchText.toLowerCase()));
981
+ return showList.map(drawRaw).join('');
982
+ },
983
+ divCreate: {
984
+ class: 'd-flex flex-column',
985
+ style: 'gap:16px',
986
+ },
987
+ })}
988
+ </div>
989
+ <div
990
+ class="w-100 d-flex align-items-center justify-content-end"
991
+ style="gap:14px;padding:0 20px 20px"
879
992
  >
880
- 圖片庫
881
- </div>`, { mul: true });
882
- }),
883
- })}
884
- </div>
885
- </div>
886
- ${obj.gvc.bindView(() => {
887
- return {
888
- bind: 'image_view',
889
- view: () => {
890
- return (html ` <div class="my-2"></div>` +
891
- EditorElem.flexMediaManagerV2({
892
- gvc: obj.gvc,
893
- data: language_data.preview_image,
894
- event: {
895
- delete: (index) => {
896
- postMD.variants.forEach((variant) => {
897
- var _a, _b;
898
- if (variant.preview_image === language_data.preview_image[index]) {
899
- variant.preview_image = (_a = language_data.preview_image[0]) !== null && _a !== void 0 ? _a : BgWidget.noImageURL;
900
- }
901
- if (variant[`preview_image_${vm.language}`] === language_data.preview_image[index]) {
902
- variant[`preview_image_${vm.language}`] =
903
- (_b = language_data.preview_image[0]) !== null && _b !== void 0 ? _b : BgWidget.noImageURL;
904
- }
905
- });
906
- ShoppingSettingBasic.updateVariants(gvc, postMD, shipment_config, variantsViewID, obj);
907
- },
993
+ ${BgWidget.cancel(gvc.event(() => {
994
+ gvc.glitter.closeDiaLog('location-select');
995
+ }))}
996
+ ${BgWidget.save(gvc.event(() => {
997
+ gvc.glitter.closeDiaLog('location-select');
998
+ callback(temp_Reserve_locations);
999
+ }))}
1000
+ </div>
1001
+ `;
908
1002
  },
909
- }));
910
- },
911
- divCreate: {
912
- class: `d-flex w-100`,
913
- style: `overflow-y:scroll;height:180px;`,
914
- },
915
- };
916
- })}
917
- `),
918
- (() => {
919
- if (postMD.variants.length === 1) {
920
- try {
921
- postMD.variants[0].editable = true;
922
- return ShoppingProductSetting.editProductSpec({
923
- vm: obj.vm,
924
- defData: postMD,
925
- gvc: gvc,
926
- single: true,
927
- });
1003
+ divCreate: {
1004
+ class: 'location-dialog',
1005
+ },
1006
+ });
1007
+ }, 'location-select');
928
1008
  }
929
- catch (e) {
930
- console.error(e);
931
- return '';
1009
+ function drawLocation(location) {
1010
+ const width = postMD.reserve_locations.length > 3 ? 'width:calc(25% - 12px)' : 'flex:1 1 auto;max-width:50%;';
1011
+ return html `
1012
+ <div class="location-btn tx_normal d-flex align-items-center " style="${width} ">
1013
+ <div class="d-flex align-items-center justify-content-center flex-fill" style="cursor:default">
1014
+ ${location.name}
1015
+ </div>
1016
+ <i
1017
+ class="fa-solid fa-xmark ms-auto cursor_pointer"
1018
+ style="color:#B0B0B0"
1019
+ onclick="${gvc.event(() => {
1020
+ postMD.reserve_locations.splice(postMD.reserve_locations.findIndex(store => store.id == location.id), 1);
1021
+ gvc.notifyDataChange(section_ID.reserve_locations);
1022
+ })}"
1023
+ ></i>
1024
+ </div>
1025
+ `;
932
1026
  }
933
- }
1027
+ return BgWidget.mainCard(html `<!--繪製預約門市選擇區塊-->
1028
+ <div class="d-flex flex-column" style="gap:18px;">
1029
+ <div class="d-flex align-items-center">
1030
+ 服務地點${BgWidget.languageInsignia(sel_lan(), 'margin-left:5px;')}
1031
+ </div>
1032
+ <div class="d-flex flex-wrap" style="gap:12px;">
1033
+ ${stockList.length == 0
1034
+ ? html ` <div class="w-100 d-flex align-items-center justify-content-center tx_gray_16">
1035
+ 尚未設置門市,請前往POS實體門市>門市設定
1036
+ </div>`
1037
+ : postMD.reserve_locations.map(drawLocation).join('')}
1038
+ </div>
1039
+ <div
1040
+ class="d-flex justify-content-center align-items-center cursor_pointer"
1041
+ style="gap:4px;color: #36B;"
1042
+ onclick="${gvc.event(() => {
1043
+ popoutSelectLocation(newStoreList => {
1044
+ postMD.reserve_locations = newStoreList;
1045
+ gvc.notifyDataChange(section_ID.reserve_locations);
1046
+ });
1047
+ })}"
1048
+ >
1049
+ 新增服務地點 <i class="fa-solid fa-plus"></i>
1050
+ </div>
1051
+ </div>
1052
+ `);
1053
+ },
1054
+ divCreate: {},
1055
+ });
1056
+ }
1057
+ else {
1058
+ return ``;
1059
+ }
1060
+ }
1061
+ function drawIndividualStoreProductConfigPanel() {
1062
+ if (postMD.product_category == 'reserve') {
1063
+ if (postMD.reserve_locations && postMD.reserve_locations.length > 0) {
1064
+ return gvc.bindView({
1065
+ bind: section_ID.store_product_config_panel,
1066
+ view: () => {
1067
+ return BgWidget.mainCard(html `<!--繪製單一門市的商品配置面板-->
1068
+ <div class="d-flex flex-column">
1069
+ <div class="tx_700">依門市管理</div>
1070
+ <div class="tx_gray_14">其他門市將預設套用此門市的設定,如需修改,請切換至對應門市進行調整</div>
1071
+ </div>
1072
+ ${BgWidget.select({
1073
+ default: postMD.reserve_locations[0].id,
1074
+ gvc: gvc,
1075
+ options: postMD.reserve_locations.map(location => {
1076
+ return {
1077
+ value: location.name,
1078
+ key: location.id,
1079
+ };
1080
+ }),
1081
+ callback(value) { },
1082
+ })}
1083
+ `);
1084
+ },
1085
+ divCreate: {},
1086
+ });
1087
+ }
1088
+ else {
1089
+ return ``;
1090
+ }
1091
+ }
1092
+ else {
1093
+ return ``;
1094
+ }
1095
+ }
1096
+ function drawSpecEditView() {
1097
+ if (postMD.variants.length === 1) {
1098
+ try {
1099
+ postMD.variants[0].editable = true;
1100
+ return html `
1101
+ <!-- 繪製 編輯商品規格編輯區塊-->
1102
+ ` + ShoppingProductSetting.editProductSpec({
1103
+ vm: obj.vm,
1104
+ defData: postMD,
1105
+ gvc: gvc,
1106
+ single: true,
1107
+ });
1108
+ }
1109
+ catch (e) {
1110
+ console.error(e);
934
1111
  return '';
935
- })(),
936
- BgWidget.mainCard(obj.gvc.bindView(() => {
937
- const specid = obj.gvc.glitter.getUUID();
938
- let editIndex = -1;
939
- gvc.addStyle(`
1112
+ }
1113
+ }
1114
+ return '';
1115
+ }
1116
+ function drawProductSpecList() {
1117
+ return BgWidget.mainCard(obj.gvc.bindView(() => {
1118
+ const specid = obj.gvc.glitter.getUUID();
1119
+ let editIndex = -1;
1120
+ gvc.addStyle(`
940
1121
  .spec-option {
941
1122
  border: 0.25px solid #393939;
942
1123
  background-color: #f7f7f7;
@@ -948,599 +1129,680 @@ export class ShoppingSettingBasic {
948
1129
  text-align: center;
949
1130
  }
950
1131
  `);
951
- return {
952
- bind: specid,
953
- dataList: [{ obj: createPage, key: 'page' }],
954
- view: () => {
955
- let returnHTML = html `
956
- <div
957
- class="d-flex align-items-center justify-content-between"
958
- style="font-size: 16px;font-weight: 700;"
959
- >
960
- ${cat_title}規格 ${BgWidget.languageInsignia(sel_lan(), '')}
961
- </div>
962
- `;
963
- let editSpectPage = [];
964
- if (postMD.specs.length > 0) {
965
- postMD.specs.map((d, index) => {
966
- editSpectPage.push({
967
- type: index === editIndex ? 'edit' : 'show',
968
- });
1132
+ return {
1133
+ bind: specid,
1134
+ dataList: [{ obj: createPage, key: 'page' }],
1135
+ view: () => {
1136
+ let returnHTML = html `
1137
+ <!-- 繪製商品規格列表區塊-->
1138
+ <div
1139
+ class="d-flex align-items-center justify-content-between"
1140
+ style="font-size: 16px;font-weight: 700;"
1141
+ >
1142
+ ${cat_title}規格 ${BgWidget.languageInsignia(sel_lan(), '')}
1143
+ </div>
1144
+ `;
1145
+ let editSpectPage = [];
1146
+ if (postMD.specs.length > 0) {
1147
+ postMD.specs.map((d, index) => {
1148
+ editSpectPage.push({
1149
+ type: index === editIndex ? 'edit' : 'show',
969
1150
  });
970
- returnHTML += html `
971
- ${EditorElem.arrayItem({
972
- customEditor: true,
973
- gvc: obj.gvc,
974
- title: '',
975
- hoverGray: true,
976
- position: 'front',
977
- height: 100,
978
- originalArray: postMD.specs,
979
- expand: true,
980
- copyable: false,
981
- hr: true,
982
- minus: false,
983
- refreshComponent: (fromIndex, toIndex) => {
984
- postMD.variants.map(item => {
985
- if (fromIndex === undefined ||
986
- toIndex === undefined ||
987
- fromIndex < 0 ||
988
- fromIndex >= item.spec.length ||
989
- toIndex < 0 ||
990
- toIndex >= item.spec.length) {
991
- throw new Error('索引超出範圍');
992
- }
993
- let element = item.spec.splice(fromIndex, 1)[0];
994
- item.spec.splice(toIndex, 0, element);
995
- return item;
996
- });
997
- obj.gvc.notifyDataChange([specid, 'productInf', 'spec_text_show']);
998
- },
999
- array: () => {
1000
- function swapArray(arr, index1, index2) {
1001
- if (index1 === index2)
1002
- return;
1003
- const [item] = arr.splice(index1, 1);
1004
- arr.splice(index2, 0, item);
1151
+ });
1152
+ returnHTML += html `
1153
+ ${EditorElem.arrayItem({
1154
+ customEditor: true,
1155
+ gvc: obj.gvc,
1156
+ title: '',
1157
+ hoverGray: true,
1158
+ position: 'front',
1159
+ height: 100,
1160
+ originalArray: postMD.specs,
1161
+ expand: true,
1162
+ copyable: false,
1163
+ hr: true,
1164
+ minus: false,
1165
+ refreshComponent: (fromIndex, toIndex) => {
1166
+ postMD.variants.map(item => {
1167
+ if (fromIndex === undefined ||
1168
+ toIndex === undefined ||
1169
+ fromIndex < 0 ||
1170
+ fromIndex >= item.spec.length ||
1171
+ toIndex < 0 ||
1172
+ toIndex >= item.spec.length) {
1173
+ throw new Error('索引超出範圍');
1005
1174
  }
1006
- return postMD.specs.map((dd, specIndex) => {
1007
- let temp = {
1008
- title: '',
1009
- option: [],
1010
- };
1011
- return {
1012
- title: gvc.bindView({
1013
- bind: `editSpec${specIndex}`,
1014
- dataList: [
1015
- {
1016
- obj: editSpectPage[specIndex],
1017
- key: 'type',
1018
- },
1019
- ],
1020
- view: () => {
1021
- var _a;
1022
- dd.language_title = ((_a = dd.language_title) !== null && _a !== void 0 ? _a : {});
1023
- if (editSpectPage[specIndex].type == 'show') {
1024
- return gvc.bindView({
1025
- bind: gvc.glitter.getUUID(),
1026
- view: () => {
1027
- return html `<div style="font-size: 16px;">
1028
- ${dd.language_title[sel_lan()] || dd.title}
1175
+ let element = item.spec.splice(fromIndex, 1)[0];
1176
+ item.spec.splice(toIndex, 0, element);
1177
+ return item;
1178
+ });
1179
+ obj.gvc.notifyDataChange([specid, 'productInf', 'spec_text_show']);
1180
+ },
1181
+ array: () => {
1182
+ function swapArray(arr, index1, index2) {
1183
+ if (index1 === index2)
1184
+ return;
1185
+ const [item] = arr.splice(index1, 1);
1186
+ arr.splice(index2, 0, item);
1187
+ }
1188
+ return postMD.specs.map((dd, specIndex) => {
1189
+ let temp = {
1190
+ title: '',
1191
+ option: [],
1192
+ };
1193
+ return {
1194
+ title: gvc.bindView({
1195
+ bind: `editSpec${specIndex}`,
1196
+ dataList: [
1197
+ {
1198
+ obj: editSpectPage[specIndex],
1199
+ key: 'type',
1200
+ },
1201
+ ],
1202
+ view: () => {
1203
+ var _a;
1204
+ dd.language_title = ((_a = dd.language_title) !== null && _a !== void 0 ? _a : {});
1205
+ if (editSpectPage[specIndex].type == 'show') {
1206
+ return gvc.bindView({
1207
+ bind: gvc.glitter.getUUID(),
1208
+ view: () => {
1209
+ return html ` <div style="font-size: 16px;">
1210
+ ${dd.language_title[sel_lan()] || dd.title}
1211
+ </div>
1212
+ ${(() => {
1213
+ let returnHTML = '';
1214
+ dd.option.map((opt, index) => {
1215
+ var _a;
1216
+ opt.language_title = ((_a = opt.language_title) !== null && _a !== void 0 ? _a : {});
1217
+ returnHTML += html `
1218
+ <div
1219
+ class="spec-option"
1220
+ style="cursor: move;"
1221
+ draggable="true"
1222
+ data-index="${index}"
1223
+ >
1224
+ ${Tool.truncateString(opt.language_title[sel_lan()] || opt.title, 30)}
1225
+ </div>
1226
+ `;
1227
+ });
1228
+ return html `
1229
+ <div class="d-flex w-100 flex-wrap gap-2" id="sortable-list-${specIndex}">
1230
+ ${returnHTML}
1231
+ <div
1232
+ class="position-absolute"
1233
+ style="right:12px;top:50%;transform: translateY(-50%);"
1234
+ onclick="${gvc.event(() => {
1235
+ createPage.page = 'add';
1236
+ editIndex = specIndex;
1237
+ gvc.notifyDataChange(specid);
1238
+ })}"
1239
+ >
1240
+ <svg
1241
+ style="cursor: pointer;"
1242
+ xmlns="http://www.w3.org/2000/svg"
1243
+ width="16"
1244
+ height="17"
1245
+ viewBox="0 0 16 17"
1246
+ fill="none"
1247
+ >
1248
+ <g clip-path="url(#clip0_8114_2928)">
1249
+ <path
1250
+ d="M1.13728 11.7785L0.418533 14.2191L0.0310334 15.5379C-0.0470916 15.8035 0.0247834 16.0879 0.218533 16.2816C0.412283 16.4754 0.696658 16.5473 0.959158 16.4723L2.28103 16.0816L4.72166 15.3629C5.04666 15.2691 5.34978 15.1129 5.61541 14.9098L5.62478 14.916L5.64041 14.891C5.68416 14.8566 5.72478 14.8223 5.76541 14.7879C5.80916 14.7504 5.84978 14.7098 5.89041 14.6691L15.3967 5.16602C16.081 4.48164 16.1654 3.42852 15.6529 2.65039C15.581 2.54102 15.4935 2.43477 15.3967 2.33789L14.1654 1.10352C13.3842 0.322266 12.1185 0.322266 11.3373 1.10352L1.83103 10.6098C1.75291 10.6879 1.67791 10.7723 1.60916 10.8598L1.58416 10.8754L1.59041 10.8848C1.38728 11.1504 1.23416 11.4535 1.13728 11.7785ZM11.9685 6.46914L6.16853 12.2691L4.61853 11.8816L4.23103 10.3316L10.031 4.53164L11.9685 6.46914ZM3.03103 11.716L3.27166 12.6848C3.33728 12.9535 3.54978 13.1629 3.81853 13.2316L4.78728 13.4723L4.55603 13.8223C4.47478 13.866 4.39041 13.9035 4.30291 13.9285L3.57166 14.1441L1.85603 14.6441L2.35916 12.9316L2.57478 12.2004C2.59978 12.1129 2.63728 12.0254 2.68103 11.9473L3.03103 11.716ZM9.85291 7.33477C10.0467 7.14102 10.0467 6.82227 9.85291 6.62852C9.65916 6.43477 9.34041 6.43477 9.14666 6.62852L6.14666 9.62852C5.95291 9.82227 5.95291 10.141 6.14666 10.3348C6.34041 10.5285 6.65916 10.5285 6.85291 10.3348L9.85291 7.33477Z"
1251
+ fill="#393939"
1252
+ />
1253
+ </g>
1254
+ <defs>
1255
+ <clipPath id="clip0_8114_2928">
1256
+ <rect
1257
+ width="16"
1258
+ height="16"
1259
+ fill="white"
1260
+ transform="translate(0 0.5)"
1261
+ />
1262
+ </clipPath>
1263
+ </defs>
1264
+ </svg>
1265
+ </div>
1029
1266
  </div>
1030
- ${(() => {
1031
- let returnHTML = '';
1032
- dd.option.map((opt, index) => {
1033
- var _a;
1034
- opt.language_title = ((_a = opt.language_title) !== null && _a !== void 0 ? _a : {});
1035
- returnHTML += html `
1036
- <div
1037
- class="spec-option"
1038
- style="cursor: move;"
1039
- draggable="true"
1040
- data-index="${index}"
1041
- >
1042
- ${Tool.truncateString(opt.language_title[sel_lan()] || opt.title, 30)}
1043
- </div>
1044
- `;
1045
- });
1046
- return html `
1047
- <div class="d-flex w-100 flex-wrap gap-2" id="sortable-list-${specIndex}">
1048
- ${returnHTML}
1049
- <div
1050
- class="position-absolute"
1051
- style="right:12px;top:50%;transform: translateY(-50%);"
1052
- onclick="${gvc.event(() => {
1053
- createPage.page = 'add';
1054
- editIndex = specIndex;
1055
- gvc.notifyDataChange(specid);
1056
- })}"
1057
- >
1058
- <svg
1059
- style="cursor: pointer;"
1060
- xmlns="http://www.w3.org/2000/svg"
1061
- width="16"
1062
- height="17"
1063
- viewBox="0 0 16 17"
1064
- fill="none"
1065
- >
1066
- <g clip-path="url(#clip0_8114_2928)">
1067
- <path
1068
- d="M1.13728 11.7785L0.418533 14.2191L0.0310334 15.5379C-0.0470916 15.8035 0.0247834 16.0879 0.218533 16.2816C0.412283 16.4754 0.696658 16.5473 0.959158 16.4723L2.28103 16.0816L4.72166 15.3629C5.04666 15.2691 5.34978 15.1129 5.61541 14.9098L5.62478 14.916L5.64041 14.891C5.68416 14.8566 5.72478 14.8223 5.76541 14.7879C5.80916 14.7504 5.84978 14.7098 5.89041 14.6691L15.3967 5.16602C16.081 4.48164 16.1654 3.42852 15.6529 2.65039C15.581 2.54102 15.4935 2.43477 15.3967 2.33789L14.1654 1.10352C13.3842 0.322266 12.1185 0.322266 11.3373 1.10352L1.83103 10.6098C1.75291 10.6879 1.67791 10.7723 1.60916 10.8598L1.58416 10.8754L1.59041 10.8848C1.38728 11.1504 1.23416 11.4535 1.13728 11.7785ZM11.9685 6.46914L6.16853 12.2691L4.61853 11.8816L4.23103 10.3316L10.031 4.53164L11.9685 6.46914ZM3.03103 11.716L3.27166 12.6848C3.33728 12.9535 3.54978 13.1629 3.81853 13.2316L4.78728 13.4723L4.55603 13.8223C4.47478 13.866 4.39041 13.9035 4.30291 13.9285L3.57166 14.1441L1.85603 14.6441L2.35916 12.9316L2.57478 12.2004C2.59978 12.1129 2.63728 12.0254 2.68103 11.9473L3.03103 11.716ZM9.85291 7.33477C10.0467 7.14102 10.0467 6.82227 9.85291 6.62852C9.65916 6.43477 9.34041 6.43477 9.14666 6.62852L6.14666 9.62852C5.95291 9.82227 5.95291 10.141 6.14666 10.3348C6.34041 10.5285 6.65916 10.5285 6.85291 10.3348L9.85291 7.33477Z"
1069
- fill="#393939"
1070
- />
1071
- </g>
1072
- <defs>
1073
- <clipPath id="clip0_8114_2928">
1074
- <rect
1075
- width="16"
1076
- height="16"
1077
- fill="white"
1078
- transform="translate(0 0.5)"
1079
- />
1080
- </clipPath>
1081
- </defs>
1082
- </svg>
1083
- </div>
1084
- </div>
1085
- `;
1086
- })()}`;
1087
- },
1088
- divCreate: {
1089
- class: 'd-flex flex-column',
1090
- style: 'gap: 6px; align-items: flex-start; padding: 12px 0;',
1091
- },
1092
- onCreate: () => {
1093
- gvc.addMtScript([{ src: 'https://cdn.jsdelivr.net/npm/sortablejs@1.15.0/Sortable.min.js' }], () => {
1094
- const interval = setInterval(() => {
1095
- const Sortable = window.Sortable;
1096
- if (!Sortable)
1267
+ `;
1268
+ })()}`;
1269
+ },
1270
+ divCreate: {
1271
+ class: 'd-flex flex-column',
1272
+ style: 'gap: 6px; align-items: flex-start; padding: 12px 0;',
1273
+ },
1274
+ onCreate: () => {
1275
+ gvc.addMtScript([{ src: 'https://cdn.jsdelivr.net/npm/sortablejs@1.15.0/Sortable.min.js' }], () => {
1276
+ const interval = setInterval(() => {
1277
+ const Sortable = window.Sortable;
1278
+ if (!Sortable)
1279
+ return;
1280
+ clearInterval(interval);
1281
+ try {
1282
+ const dragId = `sortable-list-${specIndex}`;
1283
+ const dragEl = document.getElementById(dragId);
1284
+ if (!dragEl) {
1285
+ console.warn(`Element with id '${dragId}' not found.`);
1097
1286
  return;
1098
- clearInterval(interval);
1099
- try {
1100
- const dragId = `sortable-list-${specIndex}`;
1101
- const dragEl = document.getElementById(dragId);
1102
- if (!dragEl) {
1103
- console.warn(`Element with id '${dragId}' not found.`);
1104
- return;
1105
- }
1106
- Sortable.create(dragEl, {
1107
- group: { name: dragId, pull: false, put: false },
1108
- animation: 150,
1109
- onEnd(evt) {
1110
- swapArray(postMD.specs[specIndex].option, evt.oldIndex, evt.newIndex);
1111
- },
1112
- });
1113
- }
1114
- catch (e) {
1115
- console.error('SortableJS initialization error:', e);
1116
1287
  }
1117
- }, 100);
1118
- }, () => console.error('Failed to load SortableJS'));
1288
+ Sortable.create(dragEl, {
1289
+ group: { name: dragId, pull: false, put: false },
1290
+ animation: 150,
1291
+ onEnd(evt) {
1292
+ swapArray(postMD.specs[specIndex].option, evt.oldIndex, evt.newIndex);
1293
+ },
1294
+ });
1295
+ }
1296
+ catch (e) {
1297
+ console.error('SortableJS initialization error:', e);
1298
+ }
1299
+ }, 100);
1300
+ }, () => console.error('Failed to load SortableJS'));
1301
+ },
1302
+ });
1303
+ }
1304
+ temp = JSON.parse(JSON.stringify(dd));
1305
+ if (sel_lan() !== window.parent.store_info.language_setting.def) {
1306
+ return obj.gvc.bindView({
1307
+ bind: 'spec_text_show',
1308
+ dataList: [
1309
+ {
1310
+ obj: createPage,
1311
+ key: 'page',
1119
1312
  },
1120
- });
1121
- }
1122
- temp = JSON.parse(JSON.stringify(dd));
1123
- if (sel_lan() !== window.parent.store_info.language_setting.def) {
1124
- return obj.gvc.bindView({
1125
- bind: 'spec_text_show',
1126
- dataList: [
1127
- {
1128
- obj: createPage,
1129
- key: 'page',
1130
- },
1131
- ],
1132
- view: () => {
1313
+ ],
1314
+ view: () => {
1315
+ var _a;
1316
+ let returnHTML = '';
1317
+ let specs_in_line = [];
1318
+ temp.option = (_a = temp.option) !== null && _a !== void 0 ? _a : [];
1319
+ specs_in_line.push(html ` <div class="d-flex flex-column w-100">
1320
+ <div class="d-flex flex-column" style="gap:10px;">
1321
+ <div class="fw-500">規格種類 - ${temp.title}</div>
1322
+ <input
1323
+ class="form-control w-100"
1324
+ placeholder="${temp.title}"
1325
+ style="width:100px;height: 35px;"
1326
+ value="${temp.language_title[vm.language] || ''}"
1327
+ onchange="${gvc.event((e, event) => {
1328
+ temp.language_title[vm.language] = e.value;
1329
+ })}"
1330
+ />
1331
+ </div>
1332
+ <div class="d-flex flex-column w-100" style="gap:5px;">
1333
+ ${temp.option
1334
+ .map((d, index) => {
1133
1335
  var _a;
1134
- let returnHTML = '';
1135
- let specs_in_line = [];
1136
- temp.option = (_a = temp.option) !== null && _a !== void 0 ? _a : [];
1137
- specs_in_line.push(html ` <div class="d-flex flex-column w-100">
1138
- <div class="d-flex flex-column" style="gap:10px;">
1139
- <div class="fw-500">規格種類 - ${temp.title}</div>
1140
- <input
1141
- class="form-control w-100"
1142
- placeholder="${temp.title}"
1143
- style="width:100px;height: 35px;"
1144
- value="${temp.language_title[vm.language] || ''}"
1145
- onchange="${gvc.event((e, event) => {
1146
- temp.language_title[vm.language] = e.value;
1336
+ d.language_title = (_a = d.language_title) !== null && _a !== void 0 ? _a : {};
1337
+ return html ` <div class="d-flex flex-column mt-2" style="gap:10px;">
1338
+ <div class="fw-500">選項${index + 1} - ${d.title}</div>
1339
+ <input
1340
+ class="form-control w-100"
1341
+ placeholder="${d.title}"
1342
+ style="width:100px;height: 35px;"
1343
+ value="${d.language_title[vm.language] || ''}"
1344
+ onchange="${gvc.event((e, event) => {
1345
+ d.language_title[vm.language] = e.value;
1147
1346
  })}"
1148
- />
1149
- </div>
1150
- <div class="d-flex flex-column w-100" style="gap:5px;">
1151
- ${temp.option
1152
- .map((d, index) => {
1153
- var _a;
1154
- d.language_title = (_a = d.language_title) !== null && _a !== void 0 ? _a : {};
1155
- return html ` <div class="d-flex flex-column mt-2" style="gap:10px;">
1156
- <div class="fw-500">選項${index + 1} - ${d.title}</div>
1157
- <input
1158
- class="form-control w-100"
1159
- placeholder="${d.title}"
1160
- style="width:100px;height: 35px;"
1161
- value="${d.language_title[vm.language] || ''}"
1162
- onchange="${gvc.event((e, event) => {
1163
- d.language_title[vm.language] = e.value;
1164
- })}"
1165
- />
1166
- </div>`;
1167
- })
1168
- .join('<div class="mx-1"></div>')}
1169
- </div>
1170
- </div>`);
1171
- returnHTML += specs_in_line.join(`<div class="w-100 border-top"></div>`);
1172
- returnHTML += html ` <div
1173
- class="d-flex w-100 justify-content-end align-items-center w-100 bg-white"
1174
- style="gap:14px; margin-top: 12px;"
1175
- >
1176
- ${BgWidget.cancel(obj.gvc.event(() => {
1177
- editIndex = -1;
1178
- gvc.notifyDataChange(vm.id);
1179
- }))}
1180
- ${BgWidget.save(obj.gvc.event(() => {
1181
- postMD.specs[specIndex] = temp;
1182
- ShoppingSettingBasic.updateVariants(gvc, postMD, shipment_config, variantsViewID, obj);
1183
- gvc.notifyDataChange(vm.id);
1184
- }), '完成')}
1185
- </div>`;
1186
- return returnHTML;
1187
- },
1188
- divCreate: {
1189
- class: `d-flex flex-column p-3 my-2 border rounded-3`,
1190
- style: `gap:18px;background:white;`,
1191
- },
1192
- });
1193
- }
1194
- else {
1195
- return html `
1196
- <div
1197
- style="background-color:white !important;display: flex;padding: 20px;flex-direction: column;align-items: flex-end;gap: 24px;align-self: stretch;border-radius: 10px;border: 1px solid #DDD;"
1198
- >
1199
- <div
1200
- style="display: flex;flex-direction: column;align-items: flex-end;gap: 18px;align-self: stretch;background-color:white !important;"
1201
- >
1202
- <div
1203
- style="width:100%;display: flex;flex-direction: column;align-items: flex-end;gap: 18px;background-color:white !important;"
1204
- >
1205
- ${ShoppingProductSetting.specInput(gvc, temp, {
1206
- cancel: () => {
1207
- editSpectPage[specIndex].type = 'show';
1347
+ />
1348
+ </div>`;
1349
+ })
1350
+ .join('<div class="mx-1"></div>')}
1351
+ </div>
1352
+ </div>`);
1353
+ returnHTML += specs_in_line.join(`<div class="w-100 border-top"></div>`);
1354
+ returnHTML += html ` <div
1355
+ class="d-flex w-100 justify-content-end align-items-center w-100 bg-white"
1356
+ style="gap:14px; margin-top: 12px;"
1357
+ >
1358
+ ${BgWidget.cancel(obj.gvc.event(() => {
1208
1359
  editIndex = -1;
1209
- gvc.notifyDataChange(specid);
1210
- },
1211
- save: () => {
1212
- editSpectPage[specIndex].type = 'show';
1360
+ gvc.notifyDataChange(vm.id);
1361
+ }))}
1362
+ ${BgWidget.save(obj.gvc.event(() => {
1213
1363
  postMD.specs[specIndex] = temp;
1214
- checkSpecSingle();
1215
1364
  ShoppingSettingBasic.updateVariants(gvc, postMD, shipment_config, variantsViewID, obj);
1216
1365
  gvc.notifyDataChange(vm.id);
1217
- },
1218
- })}
1219
- </div>
1220
- </div>
1366
+ }), '完成')}
1367
+ </div>`;
1368
+ return returnHTML;
1369
+ },
1370
+ divCreate: {
1371
+ class: `d-flex flex-column p-3 my-2 border rounded-3`,
1372
+ style: `gap:18px;background:white;`,
1373
+ },
1374
+ });
1375
+ }
1376
+ else {
1377
+ return html `
1378
+ <div
1379
+ style="background-color:white !important;display: flex;padding: 20px;flex-direction: column;align-items: flex-end;gap: 24px;align-self: stretch;border-radius: 10px;border: 1px solid #DDD;"
1380
+ >
1381
+ <div
1382
+ style="display: flex;flex-direction: column;align-items: flex-end;gap: 18px;align-self: stretch;background-color:white !important;"
1383
+ >
1384
+ <div
1385
+ style="width:100%;display: flex;flex-direction: column;align-items: flex-end;gap: 18px;background-color:white !important;"
1386
+ >
1387
+ ${ShoppingProductSetting.specInput(gvc, temp, {
1388
+ cancel: () => {
1389
+ editSpectPage[specIndex].type = 'show';
1390
+ editIndex = -1;
1391
+ gvc.notifyDataChange(specid);
1392
+ },
1393
+ save: () => {
1394
+ editSpectPage[specIndex].type = 'show';
1395
+ postMD.specs[specIndex] = temp;
1396
+ checkSpecSingle();
1397
+ ShoppingSettingBasic.updateVariants(gvc, postMD, shipment_config, variantsViewID, obj);
1398
+ gvc.notifyDataChange(vm.id);
1399
+ },
1400
+ })}
1221
1401
  </div>
1222
- `;
1223
- }
1224
- },
1225
- divCreate: { class: `w-100 position-relative` },
1226
- }),
1227
- innerHtml: (gvc) => {
1228
- return '';
1402
+ </div>
1403
+ </div>
1404
+ `;
1405
+ }
1229
1406
  },
1230
- editTitle: `編輯規格`,
1231
- draggable: editSpectPage[specIndex].type === 'show',
1232
- };
1233
- });
1234
- },
1235
- })}
1236
- `;
1237
- }
1238
- if (createPage.page == 'edit' && editIndex === -1) {
1239
- let temp = {
1240
- title: '',
1241
- option: [],
1242
- };
1243
- returnHTML += html `
1244
- ${BgWidget.mainCard(html `
1245
- <div
1246
- style="display: flex;flex-direction: column;align-items: flex-end;gap: 18px;align-self: stretch;"
1247
- >
1248
- <div style="width:100%;display: flex;flex-direction: column;align-items: flex-end;gap: 18px;">
1249
- ${ShoppingProductSetting.specInput(gvc, temp, {
1250
- cancel: () => {
1251
- createPage.page = 'add';
1252
- },
1253
- save: () => {
1254
- postMD.specs.push(temp);
1255
- createPage.page = 'add';
1256
- checkSpecSingle();
1257
- ShoppingSettingBasic.updateVariants(gvc, postMD, shipment_config, variantsViewID, obj);
1258
- gvc.notifyDataChange([vm.id]);
1259
- },
1260
- })}
1261
- </div>
1262
- </div>
1263
- `)}
1264
- `;
1265
- }
1266
- else if (sel_lan() !== window.parent.store_info.language_setting.def) {
1267
- returnHTML += `<div class="w-100 d-flex align-items-center justify-content-center">${BgWidget.grayNote('若要新增規格請切換至預設語言新增')}</div>`;
1268
- }
1269
- else {
1270
- returnHTML += html `
1271
- <div
1272
- style="width:100%;display:flex;align-items: center;justify-content: center;color: #36B;gap:6px;cursor: pointer;"
1273
- onclick="${gvc.event(() => {
1274
- editIndex = -1;
1275
- createPage.page = 'edit';
1276
- })}"
1277
- >
1278
- 新增規格
1279
- <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="none">
1280
- <path
1281
- d="M1.5 7.23926H12.5"
1282
- stroke="#3366BB"
1283
- stroke-width="2"
1284
- stroke-linecap="round"
1285
- stroke-linejoin="round"
1286
- />
1287
- <path
1288
- d="M6.76172 1.5L6.76172 12.5"
1289
- stroke="#3366BB"
1290
- stroke-width="2"
1291
- stroke-linecap="round"
1292
- stroke-linejoin="round"
1293
- />
1294
- </svg>
1295
- </div>
1296
- `;
1297
- }
1298
- return returnHTML;
1299
- },
1300
- divCreate: {
1301
- class: `d-flex flex-column`,
1302
- style: `gap:18px;`,
1303
- },
1304
- };
1305
- })),
1306
- postMD.product_category === 'kitchen'
1307
- ? (() => {
1308
- var _a;
1309
- let map_ = [];
1310
- postMD.shipment_type = (_a = postMD.shipment_type) !== null && _a !== void 0 ? _a : 'volume';
1311
- map_.push(BgWidget.mainCard(gvc.bindView(() => {
1312
- const vm = {
1313
- id: gvc.glitter.getUUID(),
1407
+ divCreate: { class: `w-100 position-relative` },
1408
+ }),
1409
+ innerHtml: (gvc) => {
1410
+ return '';
1411
+ },
1412
+ editTitle: `編輯規格`,
1413
+ draggable: editSpectPage[specIndex].type === 'show',
1414
+ };
1415
+ });
1416
+ },
1417
+ })}
1418
+ `;
1419
+ }
1420
+ if (createPage.page == 'edit' && editIndex === -1) {
1421
+ let temp = {
1422
+ title: '',
1423
+ option: [],
1314
1424
  };
1315
- return {
1316
- bind: vm.id,
1317
- view: () => {
1318
- return html ` <div style="font-weight: 700;margin-bottom: 6px;">運費計算</div>
1319
- ${BgWidget.multiCheckboxContainer(gvc, [
1320
- {
1321
- key: 'volume',
1322
- name: '依材積計算',
1323
- customerClass: 'guide5-6',
1324
- },
1325
- {
1326
- key: 'weight',
1327
- name: '依重量計算',
1328
- },
1329
- {
1330
- key: 'none',
1331
- name: '不計算運費',
1332
- },
1333
- ], [postMD.shipment_type], data => {
1334
- postMD.shipment_type = data[0];
1335
- gvc.notifyDataChange(vm.id);
1336
- }, { single: true })}`;
1425
+ returnHTML += html `
1426
+ ${BgWidget.mainCard(html `
1427
+ <div
1428
+ style="display: flex;flex-direction: column;align-items: flex-end;gap: 18px;align-self: stretch;"
1429
+ >
1430
+ <div style="width:100%;display: flex;flex-direction: column;align-items: flex-end;gap: 18px;">
1431
+ ${ShoppingProductSetting.specInput(gvc, temp, {
1432
+ cancel: () => {
1433
+ createPage.page = 'add';
1337
1434
  },
1338
- divCreate: {
1339
- class: `d-flex flex-column `,
1340
- style: `gap:12px;`,
1435
+ save: () => {
1436
+ postMD.specs.push(temp);
1437
+ createPage.page = 'add';
1438
+ checkSpecSingle();
1439
+ ShoppingSettingBasic.updateVariants(gvc, postMD, shipment_config, variantsViewID, obj);
1440
+ gvc.notifyDataChange([vm.id]);
1341
1441
  },
1342
- };
1343
- })));
1344
- map_.push(BgWidget.mainCard(html `
1345
- <div class="d-flex flex-column" style="gap:18px;">
1346
- <div class="d-flex flex-column guide5-7" style="gap:18px;">
1347
- <div style="font-weight: 700;"></div>
1348
- <div class="row">
1349
- ${[
1350
- {
1351
- title: '長度',
1352
- value: 'v_length',
1353
- unit: '公分',
1354
- },
1355
- {
1356
- title: '寬度',
1357
- value: 'v_width',
1358
- unit: '公分',
1359
- },
1360
- {
1361
- title: '高度',
1362
- value: 'v_height',
1363
- unit: '公分',
1364
- },
1365
- ]
1366
- .map(dd => {
1367
- postMD[dd.value] = postMD[dd.value] || '0';
1368
- return html ` <div
1369
- style="display: flex;justify-content: center;align-items: center;gap: 10px;position: relative;"
1370
- class=" col-12 col-sm-4 mb-2"
1371
- >
1372
- <div style="white-space: nowrap;">${dd.title}</div>
1373
- <input
1374
- class="ps-3"
1375
- style="border-radius: 10px;border: 1px solid #DDD;height: 40px;width: calc(100% - 50px);"
1376
- type="number"
1377
- onchange="${gvc.event(e => {
1378
- postMD[dd.value] = e.value;
1379
- })}"
1380
- value="${postMD[dd.value]}"
1381
- />
1382
- <div style="color: #8D8D8D;position: absolute;right: 25px;top: 7px;">${dd.unit}</div>
1383
- </div>`;
1384
- })
1385
- .join('')}
1386
- </div>
1387
- </div>
1388
- <div style="font-weight: 700;">商品重量</div>
1389
- <div class="w-100 row m-0" style="color:#393939;">
1390
- <input
1391
- class="col-6"
1392
- style="display: flex;height: 40px;padding: 10px 18px;align-items: center;gap: 10px;border-radius: 10px;border: 1px solid #DDD;"
1393
- placeholder="請輸入商品重量"
1394
- value="${postMD['weight'] || 0}"
1395
- onchange="${gvc.event(e => {
1396
- postMD['weight'] = e.value;
1397
- })}"
1398
- />
1399
- <div class="col-6" style="display: flex;align-items: center;gap: 10px;">
1400
- <div style="white-space: nowrap;">單位</div>
1401
- <select
1402
- class="form-select d-flex align-items-center flex-fill"
1403
- style="border-radius: 10px;border: 1px solid #DDD;padding-left: 18px;"
1404
- >
1405
- <option value="kg">公斤</option>
1406
- </select>
1407
- </div>
1442
+ })}
1408
1443
  </div>
1409
1444
  </div>
1410
- `));
1411
- if (postMD.specs.length) {
1412
- map_.push(BgWidget.mainCard([
1413
- html `
1414
- <div
1415
- class="d-flex flex-column"
1416
- style="font-size: 16px;font-weight: 700;color:#393939;${postMD.shopee_id
1417
- ? ''
1418
- : `margin-bottom: 10px;`}"
1419
- >
1420
- 組合費用
1421
- ${BgWidget.grayNote('購買金額為用戶選擇的選項價格去進行加總,如未輸入庫存數量則不追蹤庫存')}
1422
- </div>
1423
- `,
1424
- obj.gvc.bindView(() => {
1425
- const vm = {
1426
- id: obj.gvc.glitter.getUUID(),
1427
- };
1428
- return {
1429
- bind: vm.id,
1430
- view: () => {
1431
- return (html `
1432
- <div class="w-100 d-flex align-items-center border-bottom py-2 border-top">
1433
- <div class="fw-500" style="flex:1;">名稱</div>
1434
- <div class="fw-500" style="flex:1;">價格</div>
1435
- <div class="fw-500" style="flex:1;">庫存</div>
1436
- </div>
1437
- ` +
1438
- postMD.specs
1439
- .map(dd => {
1440
- return dd.option
1441
- .map((d1) => {
1442
- var _a;
1443
- d1.price = (_a = d1.price) !== null && _a !== void 0 ? _a : 0;
1444
- return html `<div class="w-100 d-flex align-items-center py-2">
1445
- <div class="fw-500" style="flex:1;">${dd.title} / ${d1.title}</div>
1446
- <div class="fw-50 pe-3" style="flex:1;">
1447
- ${BgWidget.editeInput({
1448
- gvc: gvc,
1449
- title: '',
1450
- default: `${d1.price}`,
1451
- callback: text => {
1452
- d1.price = parseInt(text, 10);
1453
- ShoppingSettingBasic.updateVariants(gvc, postMD, shipment_config, variantsViewID, obj);
1454
- },
1455
- placeHolder: '價格',
1456
- type: 'number',
1457
- })}
1458
- </div>
1459
- <div class="fw-50" style="flex:1;">
1460
- ${BgWidget.editeInput({
1461
- gvc: gvc,
1462
- title: '',
1463
- default: `${d1.stock}`,
1464
- callback: text => {
1465
- d1.stock = text;
1466
- },
1467
- placeHolder: '不追蹤庫存',
1468
- type: 'number',
1469
- })}
1470
- </div>
1471
- </div>`;
1472
- })
1473
- .join('');
1474
- })
1475
- .join(''));
1476
- },
1477
- };
1478
- }),
1479
- ].join('')));
1445
+ `)}
1446
+ `;
1447
+ }
1448
+ else if (sel_lan() !== window.parent.store_info.language_setting.def) {
1449
+ returnHTML += `<div class="w-100 d-flex align-items-center justify-content-center">${BgWidget.grayNote('若要新增規格請切換至預設語言新增')}</div>`;
1480
1450
  }
1481
1451
  else {
1482
- map_.push(BgWidget.mainCard(obj.gvc.bindView(() => {
1452
+ returnHTML += html `
1453
+ <div
1454
+ style="width:100%;display:flex;align-items: center;justify-content: center;color: #36B;gap:6px;cursor: pointer;"
1455
+ onclick="${gvc.event(() => {
1456
+ editIndex = -1;
1457
+ createPage.page = 'edit';
1458
+ })}"
1459
+ >
1460
+ 新增規格
1461
+ <svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="none">
1462
+ <path
1463
+ d="M1.5 7.23926H12.5"
1464
+ stroke="#3366BB"
1465
+ stroke-width="2"
1466
+ stroke-linecap="round"
1467
+ stroke-linejoin="round"
1468
+ />
1469
+ <path
1470
+ d="M6.76172 1.5L6.76172 12.5"
1471
+ stroke="#3366BB"
1472
+ stroke-width="2"
1473
+ stroke-linecap="round"
1474
+ stroke-linejoin="round"
1475
+ />
1476
+ </svg>
1477
+ </div>
1478
+ `;
1479
+ }
1480
+ return returnHTML;
1481
+ },
1482
+ divCreate: {
1483
+ class: `d-flex flex-column`,
1484
+ style: `gap:18px;`,
1485
+ },
1486
+ };
1487
+ }));
1488
+ }
1489
+ function drawKitchenSingleSpecDetail() {
1490
+ return postMD.product_category === 'kitchen'
1491
+ ? (() => {
1492
+ var _a;
1493
+ let map_ = [];
1494
+ postMD.shipment_type = (_a = postMD.shipment_type) !== null && _a !== void 0 ? _a : 'volume';
1495
+ map_.push(BgWidget.mainCard(gvc.bindView(() => {
1496
+ const vm = {
1497
+ id: gvc.glitter.getUUID(),
1498
+ };
1499
+ return {
1500
+ bind: vm.id,
1501
+ view: () => {
1502
+ return html ` <!-- 繪製餐飲組合的單規格詳細區塊-->
1503
+ <div style="font-weight: 700;margin-bottom: 6px;">運費計算</div>
1504
+ ${BgWidget.multiCheckboxContainer(gvc, [
1505
+ {
1506
+ key: 'volume',
1507
+ name: '依材積計算',
1508
+ customerClass: 'guide5-6',
1509
+ },
1510
+ {
1511
+ key: 'weight',
1512
+ name: '依重量計算',
1513
+ },
1514
+ {
1515
+ key: 'none',
1516
+ name: '不計算運費',
1517
+ },
1518
+ ], [postMD.shipment_type], data => {
1519
+ postMD.shipment_type = data[0];
1520
+ gvc.notifyDataChange(vm.id);
1521
+ }, { single: true })}`;
1522
+ },
1523
+ divCreate: {
1524
+ class: `d-flex flex-column `,
1525
+ style: `gap:12px;`,
1526
+ },
1527
+ };
1528
+ })));
1529
+ map_.push(BgWidget.mainCard(html `
1530
+ <div class="d-flex flex-column" style="gap:18px;">
1531
+ <div class="d-flex flex-column guide5-7" style="gap:18px;">
1532
+ <div style="font-weight: 700;"></div>
1533
+ <div class="row">
1534
+ ${[
1535
+ {
1536
+ title: '長度',
1537
+ value: 'v_length',
1538
+ unit: '公分',
1539
+ },
1540
+ {
1541
+ title: '寬度',
1542
+ value: 'v_width',
1543
+ unit: '公分',
1544
+ },
1545
+ {
1546
+ title: '高度',
1547
+ value: 'v_height',
1548
+ unit: '公分',
1549
+ },
1550
+ ]
1551
+ .map(dd => {
1552
+ postMD[dd.value] = postMD[dd.value] || '0';
1553
+ return html ` <div
1554
+ style="display: flex;justify-content: center;align-items: center;gap: 10px;position: relative;"
1555
+ class=" col-12 col-sm-4 mb-2"
1556
+ >
1557
+ <div style="white-space: nowrap;">${dd.title}</div>
1558
+ <input
1559
+ class="ps-3"
1560
+ style="border-radius: 10px;border: 1px solid #DDD;height: 40px;width: calc(100% - 50px);"
1561
+ type="number"
1562
+ onchange="${gvc.event(e => {
1563
+ postMD[dd.value] = e.value;
1564
+ })}"
1565
+ value="${postMD[dd.value]}"
1566
+ />
1567
+ <div style="color: #8D8D8D;position: absolute;right: 25px;top: 7px;">${dd.unit}</div>
1568
+ </div>`;
1569
+ })
1570
+ .join('')}
1571
+ </div>
1572
+ </div>
1573
+ <div style="font-weight: 700;">商品重量</div>
1574
+ <div class="w-100 row m-0" style="color:#393939;">
1575
+ <input
1576
+ class="col-6"
1577
+ style="display: flex;height: 40px;padding: 10px 18px;align-items: center;gap: 10px;border-radius: 10px;border: 1px solid #DDD;"
1578
+ placeholder="請輸入商品重量"
1579
+ value="${postMD['weight'] || 0}"
1580
+ onchange="${gvc.event(e => {
1581
+ postMD['weight'] = e.value;
1582
+ })}"
1583
+ />
1584
+ <div class="col-6" style="display: flex;align-items: center;gap: 10px;">
1585
+ <div style="white-space: nowrap;">單位</div>
1586
+ <select
1587
+ class="form-select d-flex align-items-center flex-fill"
1588
+ style="border-radius: 10px;border: 1px solid #DDD;padding-left: 18px;"
1589
+ >
1590
+ <option value="kg">公斤</option>
1591
+ </select>
1592
+ </div>
1593
+ </div>
1594
+ </div>
1595
+ `));
1596
+ if (postMD.specs.length) {
1597
+ map_.push(BgWidget.mainCard([
1598
+ html `
1599
+ <div
1600
+ class="d-flex flex-column"
1601
+ style="font-size: 16px;font-weight: 700;color:#393939;${postMD.shopee_id
1602
+ ? ''
1603
+ : `margin-bottom: 10px;`}"
1604
+ >
1605
+ 組合費用
1606
+ ${BgWidget.grayNote('購買金額為用戶選擇的選項價格去進行加總,如未輸入庫存數量則不追蹤庫存')}
1607
+ </div>
1608
+ `,
1609
+ obj.gvc.bindView(() => {
1483
1610
  const vm = {
1484
1611
  id: obj.gvc.glitter.getUUID(),
1485
1612
  };
1486
1613
  return {
1487
1614
  bind: vm.id,
1488
1615
  view: () => {
1489
- var _a, _b;
1490
- postMD.price = (_a = postMD.price) !== null && _a !== void 0 ? _a : 0;
1491
- postMD.stock = (_b = postMD.stock) !== null && _b !== void 0 ? _b : 0;
1492
- return [
1493
- html `
1494
- <div
1495
- class="d-flex flex-column"
1496
- style="font-size: 16px;font-weight: 700;color:#393939;${postMD.shopee_id
1497
- ? ''
1498
- : `margin-bottom: 10px;`}"
1499
- >
1500
- 組合費用 ${BgWidget.grayNote('如未輸入庫存數量則不追蹤庫存')}
1501
- </div>
1502
- `,
1503
- html `
1504
- <div class="w-100 d-flex align-items-center border-bottom py-2 border-top">
1505
- <div class="fw-500" style="flex:1;">價格</div>
1506
- <div class="fw-500" style="flex:1;">庫存</div>
1507
- </div>
1508
- `,
1509
- html `<div class="w-100 d-flex align-items-center py-2">
1510
- <div class="fw-50 pe-3" style="flex:1;">
1511
- ${BgWidget.editeInput({
1512
- gvc: gvc,
1513
- title: '',
1514
- default: `${postMD.price}`,
1515
- callback: text => {
1516
- postMD.price = parseInt(text, 10);
1517
- ShoppingSettingBasic.updateVariants(gvc, postMD, shipment_config, variantsViewID, obj);
1518
- },
1519
- placeHolder: '價格',
1520
- type: 'number',
1521
- })}
1522
- </div>
1523
- <div class="fw-50" style="flex:1;">
1524
- ${BgWidget.editeInput({
1525
- gvc: gvc,
1526
- title: '',
1527
- default: `${postMD.stock}`,
1528
- callback: text => {
1529
- postMD.stock = text;
1530
- },
1531
- placeHolder: '不追蹤庫存',
1532
- type: 'number',
1533
- })}
1534
- </div>
1535
- </div>`,
1536
- ].join('');
1616
+ return (html `
1617
+ <div class="w-100 d-flex align-items-center border-bottom py-2 border-top">
1618
+ <div class="fw-500" style="flex:1;">名稱</div>
1619
+ <div class="fw-500" style="flex:1;">價格</div>
1620
+ <div class="fw-500" style="flex:1;">庫存</div>
1621
+ </div>
1622
+ ` +
1623
+ postMD.specs
1624
+ .map(dd => {
1625
+ return dd.option
1626
+ .map((d1) => {
1627
+ var _a;
1628
+ d1.price = (_a = d1.price) !== null && _a !== void 0 ? _a : 0;
1629
+ return html ` <div class="w-100 d-flex align-items-center py-2">
1630
+ <div class="fw-500" style="flex:1;">${dd.title} / ${d1.title}</div>
1631
+ <div class="fw-50 pe-3" style="flex:1;">
1632
+ ${BgWidget.editeInput({
1633
+ gvc: gvc,
1634
+ title: '',
1635
+ default: `${d1.price}`,
1636
+ callback: text => {
1637
+ d1.price = parseInt(text, 10);
1638
+ ShoppingSettingBasic.updateVariants(gvc, postMD, shipment_config, variantsViewID, obj);
1639
+ },
1640
+ placeHolder: '價格',
1641
+ type: 'number',
1642
+ })}
1643
+ </div>
1644
+ <div class="fw-50" style="flex:1;">
1645
+ ${BgWidget.editeInput({
1646
+ gvc: gvc,
1647
+ title: '',
1648
+ default: `${d1.stock}`,
1649
+ callback: text => {
1650
+ d1.stock = text;
1651
+ },
1652
+ placeHolder: '不追蹤庫存',
1653
+ type: 'number',
1654
+ })}
1655
+ </div>
1656
+ </div>`;
1657
+ })
1658
+ .join('');
1659
+ })
1660
+ .join(''));
1537
1661
  },
1538
1662
  };
1539
- })));
1663
+ }),
1664
+ ].join('')));
1665
+ }
1666
+ else {
1667
+ map_.push(BgWidget.mainCard(obj.gvc.bindView(() => {
1668
+ const vm = {
1669
+ id: obj.gvc.glitter.getUUID(),
1670
+ };
1671
+ return {
1672
+ bind: vm.id,
1673
+ view: () => {
1674
+ var _a, _b;
1675
+ postMD.price = (_a = postMD.price) !== null && _a !== void 0 ? _a : 0;
1676
+ postMD.stock = (_b = postMD.stock) !== null && _b !== void 0 ? _b : 0;
1677
+ return [
1678
+ html `
1679
+ <div
1680
+ class="d-flex flex-column"
1681
+ style="font-size: 16px;font-weight: 700;color:#393939;${postMD.shopee_id
1682
+ ? ''
1683
+ : `margin-bottom: 10px;`}"
1684
+ >
1685
+ 組合費用 ${BgWidget.grayNote('如未輸入庫存數量則不追蹤庫存')}
1686
+ </div>
1687
+ `,
1688
+ html `
1689
+ <div class="w-100 d-flex align-items-center border-bottom py-2 border-top">
1690
+ <div class="fw-500" style="flex:1;">價格</div>
1691
+ <div class="fw-500" style="flex:1;">庫存</div>
1692
+ </div>
1693
+ `,
1694
+ html ` <div class="w-100 d-flex align-items-center py-2">
1695
+ <div class="fw-50 pe-3" style="flex:1;">
1696
+ ${BgWidget.editeInput({
1697
+ gvc: gvc,
1698
+ title: '',
1699
+ default: `${postMD.price}`,
1700
+ callback: text => {
1701
+ postMD.price = parseInt(text, 10);
1702
+ ShoppingSettingBasic.updateVariants(gvc, postMD, shipment_config, variantsViewID, obj);
1703
+ },
1704
+ placeHolder: '價格',
1705
+ type: 'number',
1706
+ })}
1707
+ </div>
1708
+ <div class="fw-50" style="flex:1;">
1709
+ ${BgWidget.editeInput({
1710
+ gvc: gvc,
1711
+ title: '',
1712
+ default: `${postMD.stock}`,
1713
+ callback: text => {
1714
+ postMD.stock = text;
1715
+ },
1716
+ placeHolder: '不追蹤庫存',
1717
+ type: 'number',
1718
+ })}
1719
+ </div>
1720
+ </div>`,
1721
+ ].join('');
1722
+ },
1723
+ };
1724
+ })));
1725
+ }
1726
+ return map_.join(BgWidget.mbContainer(18));
1727
+ })()
1728
+ : '';
1729
+ }
1730
+ function drawReservationSettings() {
1731
+ function drawTitle(title, subTitle, inputKey) {
1732
+ return html `
1733
+ <div class="d-flex flex-column w-100" >
1734
+ <div class="tx_700 ">${title}</div>
1735
+ ${subTitle
1736
+ ? html `<div class="tx_gray_14" style="margin: 4px 0 8px 0;">${subTitle}</div>`
1737
+ : html `<div style="height: 18px;"></div>`}
1738
+ <div class="d-flex" style="gap: 18px;">
1739
+ <div class="d-flex flex-fill align-items-center" style="height: 40px;padding: 0 18px;border-radius: 10px;border: 1px solid #DDD;">
1740
+ <input class="border-0 h-100 flex-fill" >
1741
+ <div class="tx_gray_14 ms-auto">小時</div>
1742
+ </div>
1743
+ <div class="d-flex flex-fill align-items-center" style="height: 40px;padding: 0 18px;border-radius: 10px;border: 1px solid #DDD;">
1744
+ <input class="border-0 h-100 flex-fill" >
1745
+ <div class="tx_gray_14 ms-auto">分鐘</div>
1746
+ </div>
1747
+ </div>
1748
+ </div>
1749
+ `;
1750
+ }
1751
+ return BgWidget.mainCard(html `
1752
+ ${drawTitle("預設服務時長", "", "defaultServiceDuration")}
1753
+ <div class="tx_700">
1754
+ 預設服務時長
1755
+ </div>
1756
+ `);
1757
+ }
1758
+ ShoppingSettingBasic.updateVariants(gvc, postMD, shipment_config, variantsViewID, obj);
1759
+ const cat_title = (() => {
1760
+ switch (postMD.product_category) {
1761
+ case 'commodity':
1762
+ return '商品';
1763
+ case 'course':
1764
+ return '課程';
1765
+ case 'reserve':
1766
+ return '預約';
1767
+ case 'kitchen':
1768
+ return '餐飲組合';
1769
+ default:
1770
+ return '商品';
1771
+ }
1772
+ })();
1773
+ return BgWidget.container1x2({
1774
+ html: [
1775
+ BgWidget.mainCard(html `
1776
+ <div class="d-flex flex-column guide5-4">
1777
+ <div style="font-weight: 700;">
1778
+ ${cat_title}名稱 ${BgWidget.requiredStar()}
1779
+ ${BgWidget.languageInsignia(vm.language, 'margin-left:5px;')}
1780
+ </div>
1781
+ ${BgWidget.editeInput({
1782
+ gvc: gvc,
1783
+ title: '',
1784
+ type: 'text',
1785
+ default: (_a = language_data.title) !== null && _a !== void 0 ? _a : '',
1786
+ placeHolder: `請輸入${cat_title}名稱`,
1787
+ callback: text => {
1788
+ if (language_data.seo.domain === language_data.title) {
1789
+ language_data.seo.domain = text;
1540
1790
  }
1541
- return map_.join(BgWidget.mbContainer(18));
1542
- })()
1543
- : '',
1791
+ language_data.title = text;
1792
+ gvc.notifyDataChange('seo');
1793
+ },
1794
+ })}
1795
+ </div>
1796
+ `),
1797
+ drawShortDescriptionRichText(),
1798
+ drawDetailDescriptionRichText(),
1799
+ drawProductImageBlock(),
1800
+ drawReserveLocations(),
1801
+ drawReservationSettings(),
1802
+ drawIndividualStoreProductConfigPanel(),
1803
+ drawSpecEditView(),
1804
+ drawProductSpecList(),
1805
+ drawKitchenSingleSpecDetail(),
1544
1806
  postMD.product_category !== 'kitchen' && postMD.specs.length
1545
1807
  ? (() => {
1546
1808
  var _a;
@@ -2883,11 +3145,11 @@ export class ShoppingSettingBasic {
2883
3145
  },
2884
3146
  });
2885
3147
  })
2886
- .join(html `<div class="border-bottom my-1 w-100"></div>`));
3148
+ .join(html ` <div class="border-bottom my-1 w-100"></div>`));
2887
3149
  }
2888
3150
  return viewList.join('');
2889
3151
  })
2890
- .join(html `<div class="border-bottom mx-n2 my-1 w-100"></div>`);
3152
+ .join(html ` <div class="border-bottom mx-n2 my-1 w-100"></div>`);
2891
3153
  },
2892
3154
  };
2893
3155
  }),
@@ -2923,8 +3185,8 @@ export class ShoppingSettingBasic {
2923
3185
  搜尋引擎列表 ${BgWidget.languageInsignia(sel_lan(), 'margin-left:5px;')}
2924
3186
  </div>
2925
3187
  ${[
2926
- html `<div class="tx_normal fw-normal mb-2">${cat_title}網址 ${BgWidget.requiredStar()}</div> `,
2927
- html `<div
3188
+ html ` <div class="tx_normal fw-normal mb-2">${cat_title}網址 ${BgWidget.requiredStar()}</div> `,
3189
+ html ` <div
2928
3190
  style="justify-content: flex-start; align-items: center; display: inline-flex;border:1px solid #EAEAEA;border-radius: 10px;overflow: hidden; ${document
2929
3191
  .body.clientWidth > 768
2930
3192
  ? 'gap: 18px; '