ts-glitter 21.2.4 → 21.2.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/lowcode/Entry.js +1 -1
  2. package/lowcode/Entry.ts +1 -1
  3. package/lowcode/backend-manager/bg-blog.js +19 -21
  4. package/lowcode/backend-manager/bg-blog.ts +20 -21
  5. package/lowcode/backend-manager/bg-product.js +94 -99
  6. package/lowcode/backend-manager/bg-product.ts +104 -109
  7. package/lowcode/cms-plugin/filter-options.js +1 -0
  8. package/lowcode/cms-plugin/filter-options.ts +1 -0
  9. package/lowcode/cms-plugin/pos-pages/payment-page.js +16 -6
  10. package/lowcode/cms-plugin/pos-pages/payment-page.ts +15 -2
  11. package/lowcode/cms-plugin/pos-pages/pos-function.js +102 -55
  12. package/lowcode/cms-plugin/pos-pages/pos-function.ts +111 -61
  13. package/lowcode/cms-plugin/pos-pages/pos-summary.js +4 -4
  14. package/lowcode/cms-plugin/pos-pages/pos-summary.ts +4 -1
  15. package/lowcode/cms-plugin/shopping-order-manager.js +10 -7
  16. package/lowcode/cms-plugin/shopping-order-manager.ts +10 -7
  17. package/lowcode/cms-plugin/shopping-product-setting.js +9 -6
  18. package/lowcode/cms-plugin/shopping-product-setting.ts +13 -6
  19. package/lowcode/cms-plugin/shopping-setting-basic.js +411 -405
  20. package/lowcode/cms-plugin/shopping-setting-basic.ts +497 -486
  21. package/lowcode/public-components/checkout/index.js +5 -3
  22. package/lowcode/public-components/checkout/index.ts +8 -3
  23. package/package.json +1 -1
  24. package/src/api-public/controllers/shop.js +6 -5
  25. package/src/api-public/controllers/shop.js.map +1 -1
  26. package/src/api-public/controllers/shop.ts +12 -13
  27. package/src/api-public/controllers/user.js +2 -1
  28. package/src/api-public/controllers/user.js.map +1 -1
  29. package/src/api-public/controllers/user.ts +2 -1
  30. package/src/api-public/services/checkout-event.js +17 -7
  31. package/src/api-public/services/checkout-event.js.map +1 -1
  32. package/src/api-public/services/data-analyze.d.ts +1 -1
  33. package/src/api-public/services/fb-api.js +3 -2
  34. package/src/api-public/services/fb-api.js.map +1 -1
  35. package/src/api-public/services/fb-api.ts +3 -2
  36. package/src/api-public/services/financial-serviceV2.js +17 -7
  37. package/src/api-public/services/financial-serviceV2.js.map +1 -1
  38. package/src/api-public/services/mail.js +3 -3
  39. package/src/api-public/services/mail.js.map +1 -1
  40. package/src/api-public/services/mail.ts +144 -134
  41. package/src/api-public/services/monitor.d.ts +1 -0
  42. package/src/api-public/services/monitor.js +5 -2
  43. package/src/api-public/services/monitor.js.map +1 -1
  44. package/src/api-public/services/monitor.ts +5 -2
  45. package/src/api-public/services/shopping.js +5 -4
  46. package/src/api-public/services/shopping.js.map +1 -1
  47. package/src/api-public/services/shopping.ts +15 -14
  48. package/src/api-public/services/user.js +17 -7
  49. package/src/api-public/services/user.js.map +1 -1
  50. package/src/index.js +17 -7
  51. package/src/index.js.map +1 -1
  52. package/src/seo-config.js +1 -1
  53. package/src/seo-config.js.map +1 -1
  54. package/src/seo-config.ts +1 -1
  55. package/src/services/app.js +17 -7
  56. package/src/services/app.js.map +1 -1
  57. package/src/services/ses.js.map +1 -1
  58. package/src/services/ses.ts +41 -35
@@ -36,7 +36,7 @@ export class BgProduct {
36
36
  return (window.parent as any).glitter.innerDialog((gvc: GVC) => {
37
37
  return html`
38
38
  <div class="bg-white shadow rounded-3">
39
- <div class="px-3" style="max-height: calc(100vh - 100px);overflow-y: auto;">
39
+ <div class="px-3" style="max-height: calc(100vh - 100px); overflow-y: auto;">
40
40
  ${StockList.main(
41
41
  gvc,
42
42
  {
@@ -120,7 +120,7 @@ export class BgProduct {
120
120
  </div>
121
121
  <div class="c_dialog">
122
122
  <div class="c_dialog_body">
123
- <div class="c_dialog_main p-3" style="gap: 12px; min-height: 480px; max-height: 480px;">
123
+ <div class="c_dialog_main p-3" style="gap: 12px; min-height: 480px; max-height: 500px;">
124
124
  <div class="d-flex mb-2" style="gap: 6px;">
125
125
  ${BgWidget.selectFilter({
126
126
  gvc,
@@ -159,11 +159,8 @@ export class BgProduct {
159
159
  return !obj.filter || obj.filter(dd);
160
160
  })
161
161
  .map((opt, index) => {
162
- const id = gvc.glitter.getUUID();
163
- vm.ids.push({
164
- key: opt.key,
165
- id: id,
166
- });
162
+ const id = `ProductsDialog${index}`;
163
+ vm.ids.push({ key: opt.key, id: id });
167
164
 
168
165
  function call() {
169
166
  if (obj.single) {
@@ -191,117 +188,115 @@ export class BgProduct {
191
188
  }
192
189
 
193
190
  return (
194
- gvc.bindView(() => {
195
- return {
196
- bind: id,
197
- view: () => {
198
- return html`<input
199
- class="form-check-input mt-0 ${vm.checkClass} cursor_pointer"
200
- type="checkbox"
201
- id="${opt.key}"
202
- name="radio_${vm.id}_${index}"
203
- onclick="${gvc.event(() => call())}"
204
- ${obj.default.includes(opt.key) ? 'checked' : ''}
205
- />
206
- <div class="d-flex align-items-center justify-content-between w-100">
207
- <div>
208
- <div
209
- class="d-flex align-items-center form-check-label c_updown_label gap-3"
210
- style="max-width: ${document.body.clientWidth > 768 ? 500 : 220}px;"
211
- >
212
- ${BgWidget.validImageBox({
213
- gvc: gvc,
214
- image: opt.image,
215
- width: 40,
216
- class: 'cursor_pointer',
217
- events: [
218
- {
219
- key: 'onclick',
220
- value: gvc.event(() => call()),
221
- },
222
- ],
223
- })}
224
- <div class="d-flex flex-column">
225
- <div
226
- class="tx_normal ${opt.note ? 'mb-1' : ''} d-flex gap-2 cursor_pointer"
227
- style="text-wrap: auto;"
228
- onclick="${gvc.event(() => call())}"
229
- >
230
- ${opt.value}
231
- </div>
232
- ${opt.sub_title
233
- ? html`
234
- <div class="fw-500" style="color: grey; font-size: 13px;">
235
- ${opt.sub_title}
236
- </div>
237
- `
238
- : ''}
191
+ gvc.bindView({
192
+ bind: id,
193
+ view: () => {
194
+ return html`<input
195
+ class="form-check-input mt-0 ${vm.checkClass} cursor_pointer"
196
+ type="checkbox"
197
+ id="${opt.key}"
198
+ name="radio_${vm.id}_${index}"
199
+ onclick="${gvc.event(() => call())}"
200
+ ${obj.default.includes(opt.key) ? 'checked' : ''}
201
+ />
202
+ <div class="d-flex align-items-center justify-content-between w-100">
203
+ <div>
204
+ <div
205
+ class="d-flex align-items-center form-check-label c_updown_label gap-3"
206
+ style="max-width: ${document.body.clientWidth > 768 ? 500 : 220}px;"
207
+ >
208
+ ${BgWidget.validImageBox({
209
+ gvc: gvc,
210
+ image: opt.image,
211
+ width: 40,
212
+ class: 'cursor_pointer',
213
+ events: [
214
+ {
215
+ key: 'onclick',
216
+ value: gvc.event(() => call()),
217
+ },
218
+ ],
219
+ })}
220
+ <div class="d-flex flex-column">
221
+ <div
222
+ class="tx_normal ${opt.note ? 'mb-1' : ''} d-flex gap-2 cursor_pointer"
223
+ style="text-wrap: auto;"
224
+ onclick="${gvc.event(() => call())}"
225
+ >
226
+ ${opt.value}
239
227
  </div>
228
+ ${opt.sub_title
229
+ ? html`
230
+ <div class="fw-500" style="color: grey; font-size: 13px;">
231
+ ${opt.sub_title}
232
+ </div>
233
+ `
234
+ : ''}
240
235
  </div>
241
- ${(() => {
242
- const isVisibleProduct =
243
- opt.content.visible === 'false' && !obj.show_product_type
244
- ? BgWidget.warningInsignia('隱形商品', { size: 'sm' })
245
- : '';
246
-
247
- const productCategory = obj.show_product_type
248
- ? BgWidget.infoInsignia(ProductConfig.getName(opt.content), {
249
- size: 'sm',
250
- })
236
+ </div>
237
+ ${(() => {
238
+ const isVisibleProduct =
239
+ opt.content.visible === 'false' && !obj.show_product_type
240
+ ? BgWidget.warningInsignia('隱形商品', { size: 'sm' })
251
241
  : '';
252
242
 
253
- const collections = opt.content?.collection
254
- ?.filter(Boolean)
255
- .map((col: string) => BgWidget.normalInsignia(col, { size: 'sm' }))
256
- .join('');
243
+ const productCategory = obj.show_product_type
244
+ ? BgWidget.infoInsignia(ProductConfig.getName(opt.content), {
245
+ size: 'sm',
246
+ })
247
+ : '';
257
248
 
258
- const renderString = `${isVisibleProduct}${productCategory}${collections}`;
249
+ const collections = opt.content?.collection
250
+ ?.filter(Boolean)
251
+ .map((col: string) => BgWidget.normalInsignia(col, { size: 'sm' }))
252
+ .join('');
259
253
 
260
- return renderString
261
- ? html`<div class="d-flex flex-wrap gap-1 mt-2">${renderString}</div>`
262
- : '';
263
- })()}
264
- </div>
265
- <div class="text-end">
266
- <div class="tx_normal_14">
267
- ${(() => {
268
- const contentMap: Record<string, () => string> = {
269
- price: () => {
270
- return html`$${parseInt(
271
- `${
272
- opt.content[vm.orderString || 'min_price'] ??
273
- opt.content.variants[opt.variant_index ?? 0].sale_price
274
- }`,
275
- 10
276
- ).toLocaleString()}`;
277
- },
278
- stock: () => {
279
- const variant = opt.content.variants[opt.variant_index ?? 0];
280
- if (variant.show_understocking === 'false') {
281
- return '不追蹤庫存';
282
- }
254
+ const renderString = `${isVisibleProduct}${productCategory}${collections}`;
283
255
 
284
- const n = Number(opt.content.variants[opt.variant_index ?? 0].stock);
285
- return html`庫存 ${(isNaN(n) ? 0 : n).toLocaleString()} 個`;
286
- },
287
- };
256
+ return renderString
257
+ ? html`<div class="d-flex flex-wrap gap-1 mt-2">${renderString}</div>`
258
+ : '';
259
+ })()}
260
+ </div>
261
+ <div class="text-end">
262
+ <div class="tx_normal_14">
263
+ ${(() => {
264
+ const contentMap: Record<string, () => string> = {
265
+ price: () => {
266
+ return html`$${parseInt(
267
+ `${
268
+ opt.content[vm.orderString || 'min_price'] ??
269
+ opt.content.variants[opt.variant_index ?? 0].sale_price
270
+ }`,
271
+ 10
272
+ ).toLocaleString()}`;
273
+ },
274
+ stock: () => {
275
+ const variant = opt.content.variants[opt.variant_index ?? 0];
276
+ if (variant.show_understocking === 'false') {
277
+ return '不追蹤庫存';
278
+ }
288
279
 
289
- return (
290
- obj.right_element_type
291
- ? contentMap[obj.right_element_type]
292
- : contentMap.price
293
- )();
294
- })()}
295
- </div>
296
- ${opt.note ? html` <div class="tx_gray_12">${opt.note}</div> ` : ''}
280
+ const n = Number(opt.content.variants[opt.variant_index ?? 0].stock);
281
+ return html`庫存 ${(isNaN(n) ? 0 : n).toLocaleString()} 個`;
282
+ },
283
+ };
284
+
285
+ return (
286
+ obj.right_element_type
287
+ ? contentMap[obj.right_element_type]
288
+ : contentMap.price
289
+ )();
290
+ })()}
297
291
  </div>
298
- </div>`;
299
- },
300
- divCreate: {
301
- class: 'd-flex align-items-center',
302
- style: `gap: ${document.body.clientWidth > 800 ? 24 : 12}px`,
303
- },
304
- };
292
+ ${opt.note ? html` <div class="tx_gray_12">${opt.note}</div> ` : ''}
293
+ </div>
294
+ </div>`;
295
+ },
296
+ divCreate: {
297
+ class: 'd-flex align-items-center',
298
+ style: `gap: ${document.body.clientWidth > 800 ? 24 : 12}px`,
299
+ },
305
300
  }) + BgWidget.horizontalLine({ margin: 0.15 })
306
301
  );
307
302
  })
@@ -574,6 +574,7 @@ FilterOptions.productListOrderBy = [
574
574
  { key: 'created_time_asc', value: '建立時間舊 > 新' },
575
575
  { key: 'updated_time_desc', value: '更新時間新 > 舊' },
576
576
  { key: 'updated_time_asc', value: '更新時間舊 > 新' },
577
+ { key: 'sort_weight', value: '商品顯示權重高 > 低' },
577
578
  ];
578
579
  FilterOptions.imageLibraryOrderBy = [
579
580
  { key: 'default', value: '預設' },
@@ -600,6 +600,7 @@ export class FilterOptions {
600
600
  { key: 'created_time_asc', value: '建立時間舊 > 新' },
601
601
  { key: 'updated_time_desc', value: '更新時間新 > 舊' },
602
602
  { key: 'updated_time_asc', value: '更新時間舊 > 新' },
603
+ { key: 'sort_weight', value: '商品顯示權重高 > 低' },
603
604
  // { key: 'stock_desc', value: '庫存數量多 > 少' },
604
605
  // { key: 'stock_asc', value: '庫存數量少 > 多' },
605
606
  ];
@@ -201,7 +201,9 @@ export class PaymentPage {
201
201
  <div
202
202
  class="d-flex flex-column py-2"
203
203
  onclick="${gvc.event(() => {
204
- PosFunction.setMoney(gvc, count => {
204
+ var _a, _b;
205
+ const def = ((_b = (_a = obj.ogOrderData.lineItems) === null || _a === void 0 ? void 0 : _a[index]) === null || _b === void 0 ? void 0 : _b.count) || 0;
206
+ PosFunction.setMoney(gvc, def, count => {
205
207
  obj.ogOrderData.lineItems[index].count = count;
206
208
  refreshOrderView();
207
209
  }, '更改商品數量');
@@ -247,7 +249,9 @@ export class PaymentPage {
247
249
  class="d-sm-none d-flex align-items-center justify-content-center flex-column"
248
250
  style="gap:0px;"
249
251
  onclick="${gvc.event(() => {
250
- PosFunction.setMoney(gvc, money => {
252
+ var _a, _b;
253
+ const n = ((_b = (_a = obj.ogOrderData.lineItems) === null || _a === void 0 ? void 0 : _a[index]) === null || _b === void 0 ? void 0 : _b.custom_price) || 0;
254
+ PosFunction.setMoney(gvc, n, money => {
251
255
  if (money === data.sale_price) {
252
256
  delete obj.ogOrderData.lineItems[index].custom_price;
253
257
  }
@@ -283,7 +287,9 @@ export class PaymentPage {
283
287
  class="col-3 col-lg-2 d-flex align-items-center justify-content-center d-none d-sm-flex"
284
288
  style="gap:10px;cursor: pointer;"
285
289
  onclick="${gvc.event(() => {
286
- PosFunction.setMoney(gvc, count => {
290
+ var _a, _b;
291
+ const def = ((_b = (_a = obj.ogOrderData.lineItems) === null || _a === void 0 ? void 0 : _a[index]) === null || _b === void 0 ? void 0 : _b.count) || 0;
292
+ PosFunction.setMoney(gvc, def, count => {
287
293
  obj.ogOrderData.lineItems[index].count = count;
288
294
  refreshOrderView();
289
295
  }, '更改商品數量');
@@ -295,7 +301,9 @@ export class PaymentPage {
295
301
  class="col-3 col-lg-2 d-flex align-items-center justify-content-center d-none d-sm-flex"
296
302
  style="gap:10px;cursor: pointer;"
297
303
  onclick="${gvc.event(() => {
298
- PosFunction.setMoney(gvc, money => {
304
+ var _a, _b;
305
+ const def = ((_b = (_a = obj.ogOrderData.lineItems) === null || _a === void 0 ? void 0 : _a[index]) === null || _b === void 0 ? void 0 : _b.custom_price) || 0;
306
+ PosFunction.setMoney(gvc, def, money => {
299
307
  if (money === data.sale_price) {
300
308
  delete obj.ogOrderData.lineItems[index].custom_price;
301
309
  }
@@ -1334,7 +1342,7 @@ export class PaymentPage {
1334
1342
  dialog.errorMessage({ text: '此付款金額已結清,無法進行調整' });
1335
1343
  return;
1336
1344
  }
1337
- PosFunction.setMoney(gvc, money => {
1345
+ PosFunction.setMoney(gvc, dd.total, money => {
1338
1346
  dd.total = money || 0;
1339
1347
  refreshOrderView();
1340
1348
  });
@@ -1425,7 +1433,9 @@ export class PaymentPage {
1425
1433
  class="ms-auto"
1426
1434
  value="${obj.ogOrderData.pos_info.payment[0].total}"
1427
1435
  onclick="${gvc.event(() => {
1428
- PosFunction.setMoney(gvc, money => {
1436
+ var _a, _b;
1437
+ const def = (_b = (_a = obj.ogOrderData.pos_info.payment) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.total;
1438
+ PosFunction.setMoney(gvc, def, money => {
1429
1439
  obj.ogOrderData.pos_info.payment[0].total = money || 0;
1430
1440
  PaymentPage.storeHistory(obj.ogOrderData);
1431
1441
  gvc.notifyDataChange(vm_id);
@@ -235,8 +235,11 @@ export class PaymentPage {
235
235
  <div
236
236
  class="d-flex flex-column py-2"
237
237
  onclick="${gvc.event(() => {
238
+ const def = obj.ogOrderData.lineItems?.[index]?.count || 0;
239
+
238
240
  PosFunction.setMoney(
239
241
  gvc,
242
+ def,
240
243
  count => {
241
244
  obj.ogOrderData.lineItems[index].count = count;
242
245
  refreshOrderView();
@@ -284,8 +287,11 @@ export class PaymentPage {
284
287
  class="d-sm-none d-flex align-items-center justify-content-center flex-column"
285
288
  style="gap:0px;"
286
289
  onclick="${gvc.event(() => {
290
+ const n = obj.ogOrderData.lineItems?.[index]?.custom_price || 0;
291
+
287
292
  PosFunction.setMoney(
288
293
  gvc,
294
+ n,
289
295
  money => {
290
296
  if (money === data.sale_price) {
291
297
  delete obj.ogOrderData.lineItems[index].custom_price;
@@ -325,8 +331,11 @@ export class PaymentPage {
325
331
  class="col-3 col-lg-2 d-flex align-items-center justify-content-center d-none d-sm-flex"
326
332
  style="gap:10px;cursor: pointer;"
327
333
  onclick="${gvc.event(() => {
334
+ const def = obj.ogOrderData.lineItems?.[index]?.count || 0;
335
+
328
336
  PosFunction.setMoney(
329
337
  gvc,
338
+ def,
330
339
  count => {
331
340
  obj.ogOrderData.lineItems[index].count = count;
332
341
  refreshOrderView();
@@ -341,8 +350,11 @@ export class PaymentPage {
341
350
  class="col-3 col-lg-2 d-flex align-items-center justify-content-center d-none d-sm-flex"
342
351
  style="gap:10px;cursor: pointer;"
343
352
  onclick="${gvc.event(() => {
353
+ const def = obj.ogOrderData.lineItems?.[index]?.custom_price || 0;
354
+
344
355
  PosFunction.setMoney(
345
356
  gvc,
357
+ def,
346
358
  money => {
347
359
  if (money === data.sale_price) {
348
360
  delete obj.ogOrderData.lineItems[index].custom_price;
@@ -1442,7 +1454,7 @@ export class PaymentPage {
1442
1454
  dialog.errorMessage({ text: '此付款金額已結清,無法進行調整' });
1443
1455
  return;
1444
1456
  }
1445
- PosFunction.setMoney(gvc, money => {
1457
+ PosFunction.setMoney(gvc, dd.total, money => {
1446
1458
  dd.total = money || 0;
1447
1459
  refreshOrderView();
1448
1460
  });
@@ -1555,7 +1567,8 @@ export class PaymentPage {
1555
1567
  class="ms-auto"
1556
1568
  value="${obj.ogOrderData.pos_info.payment[0].total}"
1557
1569
  onclick="${gvc.event(() => {
1558
- PosFunction.setMoney(gvc, money => {
1570
+ const def = obj.ogOrderData.pos_info.payment?.[0]?.total;
1571
+ PosFunction.setMoney(gvc, def, money => {
1559
1572
  obj.ogOrderData.pos_info.payment[0].total = money || 0;
1560
1573
  PaymentPage.storeHistory(obj.ogOrderData);
1561
1574
  gvc.notifyDataChange(vm_id);
@@ -313,7 +313,6 @@ export class PosFunction {
313
313
  `;
314
314
  },
315
315
  divCreate: {
316
- class: '',
317
316
  style: `width: 338px; max-height: 400px; overflow-y: auto; padding: 25px 20px; background: white; box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.15); border-radius: 20px; display: flex; flex-direction: column; align-items: center; gap: 10px;`,
318
317
  },
319
318
  }));
@@ -435,82 +434,122 @@ export class PosFunction {
435
434
  });
436
435
  }, 'selectStoreSwitch');
437
436
  }
438
- static setMoney(gvc, callback, title) {
437
+ static setMoney(gvc, def, callback, title) {
439
438
  gvc.glitter.innerDialog(gvc => {
440
439
  const c_vm = {
441
- text: '',
442
440
  id: gvc.glitter.getUUID(),
441
+ addListener: false,
442
+ text: def ? `${def}` : '',
443
443
  };
444
444
  const numberButtons = [
445
- [1, 2, 3],
446
- [4, 5, 6],
447
445
  [7, 8, 9],
448
- ['<i class="fa-regular fa-delete-left"></i>', 0, '確認'],
446
+ [4, 5, 6],
447
+ [1, 2, 3],
448
+ ['C', 0, '<i class="fa-regular fa-delete-left"></i>'],
449
449
  ];
450
450
  const handleButtonClick = (value) => {
451
- if (value === '確認') {
452
- callback(parseInt(c_vm.text, 10));
453
- gvc.closeDialog();
451
+ if (value === '確認' || value === 'Enter') {
452
+ saveEvent();
454
453
  }
455
454
  else if (value === '取消') {
456
- gvc.closeDialog();
455
+ closeEvent();
457
456
  }
458
- else if (typeof value === 'string' && value.includes('fa-regular')) {
457
+ else if (value === 'Backspace' || (typeof value === 'string' && value.includes('fa-regular'))) {
459
458
  c_vm.text = c_vm.text.slice(0, -1);
460
459
  gvc.notifyDataChange(c_vm.id);
461
460
  }
461
+ else if (value === 'c' || value === 'C') {
462
+ c_vm.text = '';
463
+ gvc.notifyDataChange(c_vm.id);
464
+ }
462
465
  else {
463
466
  c_vm.text += value;
467
+ if (c_vm.text[0] === '0') {
468
+ c_vm.text = c_vm.text.slice(1, c_vm.text.length);
469
+ }
464
470
  gvc.notifyDataChange(c_vm.id);
465
471
  }
466
472
  };
473
+ const numberBoardClickEvent = (e) => {
474
+ const key = e.key;
475
+ if (/^[0-9]$/.test(key) || key === 'Backspace' || key === 'Enter' || key.toLowerCase() === 'c') {
476
+ handleButtonClick(key);
477
+ }
478
+ };
479
+ const closeEvent = () => {
480
+ document.removeEventListener('keydown', numberBoardClickEvent);
481
+ gvc.closeDialog();
482
+ };
483
+ const saveEvent = () => {
484
+ callback(parseInt(c_vm.text, 10));
485
+ closeEvent();
486
+ };
467
487
  return gvc.bindView(() => ({
468
488
  bind: c_vm.id,
469
- view: () => html `
470
- <div
471
- style="flex-direction: column; justify-content: flex-start; align-items: flex-start; gap: 20px; display: inline-flex"
472
- >
473
- <div style="align-self: stretch; display: inline-flex; justify-content: center;">
474
- <div class="fw-bold" style="text-align: center; color: #585858; font-size: 28px;">
475
- ${title || '輸入收款金額'}
476
- </div>
477
- </div>
478
- <div class="border w-100 p-3 rounded-3 d-flex align-items-center justify-content-end" style="gap: 20px;">
479
- <span style="font-size: 28px;">${c_vm.text || 0}</span>
480
- </div>
489
+ view: () => {
490
+ return html `
481
491
  <div
482
- style="background: white; flex-direction: column; justify-content: flex-start; align-items: center; gap: 32px; display: flex"
492
+ style="flex-direction: column; justify-content: flex-start; align-items: flex-end; gap: 20px; display: inline-flex"
483
493
  >
494
+ <div style="align-self: stretch; display: inline-flex; justify-content: center;">
495
+ <div class="fw-bold" style="text-align: center; color: #585858; font-size: 28px;">
496
+ ${title || '輸入收款金額'}
497
+ </div>
498
+ </div>
499
+ <div class="border w-100 p-3 rounded-3 d-flex align-items-center justify-content-end" style="gap: 20px;">
500
+ <span style="font-size: 28px;">${c_vm.text || 0}</span>
501
+ </div>
484
502
  <div
485
- style="align-self: stretch; border-radius: 10px; border: 1px solid #DDD; display: flex; flex-direction: column;"
503
+ style="background: white; flex-direction: column; justify-content: flex-start; align-items: center; gap: 32px; display: flex"
486
504
  >
487
- ${numberButtons
488
- .map(row => html `
489
- <div style="display: inline-flex; justify-content: flex-start; align-items: center;">
490
- ${row
491
- .map(value => html `
492
- <div
493
- style="height: 56px; width: 95px; display: inline-flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px;"
494
- onclick="${gvc.event(() => handleButtonClick(value))}"
495
- >
505
+ <div
506
+ style="align-self: stretch; border-radius: 10px; border: 1px solid #DDD; display: flex; flex-direction: column;"
507
+ >
508
+ ${numberButtons
509
+ .map(row => html `
510
+ <div style="display: inline-flex; justify-content: flex-start; align-items: center;">
511
+ ${row
512
+ .map(value => html `
496
513
  <div
497
- style="align-self: stretch; text-align: center; color: #393939; font-size: 20px; font-weight: 700; line-height: 28px;"
514
+ style="height: 56px; width: 95px; display: inline-flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px;"
515
+ onclick="${gvc.event(() => handleButtonClick(value))}"
498
516
  >
499
- ${value}
517
+ <div
518
+ style="align-self: stretch; text-align: center; color: #393939; font-size: 20px; font-weight: 700; line-height: 28px;"
519
+ >
520
+ ${value}
521
+ </div>
500
522
  </div>
501
- </div>
502
- `)
503
- .join('<div style="border-right: 1px #DDDDDD solid; height: 56px;"></div>')}
504
- </div>
505
- `)
506
- .join('<div style="border-top: 1px #DDDDDD solid; height: 1px; width: 100%;"></div>')}
523
+ `)
524
+ .join('<div style="border-right: 1px #DDDDDD solid; height: 56px;"></div>')}
525
+ </div>
526
+ `)
527
+ .join('<div style="border-top: 1px #DDDDDD solid; height: 1px; width: 100%;"></div>')}
528
+ </div>
507
529
  </div>
530
+ <div>${BgWidget.save(gvc.event(saveEvent), '確認')}</div>
508
531
  </div>
509
- </div>
510
- `,
532
+ `;
533
+ },
511
534
  divCreate: {
512
- class: '',
513
- style: `width: 338px; padding: 25px 20px; background: white; box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.15); border-radius: 20px; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: 10px;`,
535
+ style: `
536
+ width: 338px;
537
+ padding: 25px 20px;
538
+ background: white;
539
+ box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.15);
540
+ border-radius: 20px;
541
+ overflow: hidden;
542
+ display: flex;
543
+ flex-direction: column;
544
+ align-items: center;
545
+ gap: 10px;
546
+ `,
547
+ },
548
+ onCreate: () => {
549
+ if (!c_vm.addListener) {
550
+ c_vm.addListener = true;
551
+ document.addEventListener('keydown', numberBoardClickEvent);
552
+ }
514
553
  },
515
554
  }));
516
555
  }, 'setMoney');
@@ -555,11 +594,12 @@ export class PosFunction {
555
594
  }
556
595
  };
557
596
  const handlePaymentAmountClick = (method, id, gvc, dialog) => {
597
+ console.log(method);
558
598
  if (method.paied) {
559
599
  dialog.errorMessage({ text: '此付款金額已結清,無法進行調整' });
560
600
  return;
561
601
  }
562
- PosFunction.setMoney(gvc, money => {
602
+ PosFunction.setMoney(gvc, method.total, money => {
563
603
  method.total = money || 0;
564
604
  gvc.notifyDataChange(id);
565
605
  });
@@ -658,16 +698,23 @@ export class PosFunction {
658
698
  });
659
699
  return btnArray
660
700
  .map(btn => {
661
- return `
662
- <div style="flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 15px; border-radius: 10px; background: #F6F6F6; ${method.method === btn.value ? 'color: #393939; border: 3px solid #393939; box-shadow: 2px 2px 15px rgba(0, 0, 0, 0.20);' : 'color: #8D8D8D;'}"
663
- onclick="${gvc.event(() => {
701
+ return html `
702
+ <div
703
+ style="flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 15px; border-radius: 10px; background: #F6F6F6; ${method.method ===
704
+ btn.value
705
+ ? 'color: #393939; border: 3px solid #393939; box-shadow: 2px 2px 15px rgba(0, 0, 0, 0.20);'
706
+ : 'color: #8D8D8D;'}"
707
+ onclick="${gvc.event(() => {
664
708
  method = { method: btn.value, total: 0 };
665
709
  gvc.notifyDataChange(id);
666
- })}">
667
- <div style="width: 28px; height: 28px;">${drawIcon(method.method === btn.value, btn.value)}</div>
668
- <div style="font-size: 16px; font-weight: 500;">${btn.title}</div>
669
- </div>
670
- `;
710
+ })}"
711
+ >
712
+ <div style="width: 28px; height: 28px;">
713
+ ${drawIcon(method.method === btn.value, btn.value)}
714
+ </div>
715
+ <div style="font-size: 16px; font-weight: 500;">${btn.title}</div>
716
+ </div>
717
+ `;
671
718
  })
672
719
  .join('');
673
720
  })()}