ts-glitter 20.7.8 → 20.7.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 (30) hide show
  1. package/lowcode/Entry.js +1 -1
  2. package/lowcode/Entry.ts +1 -1
  3. package/lowcode/cms-plugin/POS-setting.js +1 -0
  4. package/lowcode/cms-plugin/POS-setting.ts +1 -0
  5. package/lowcode/cms-plugin/cms-router.js +5 -0
  6. package/lowcode/cms-plugin/cms-router.ts +5 -0
  7. package/lowcode/cms-plugin/pos-config-setting.js +591 -0
  8. package/lowcode/cms-plugin/pos-config-setting.ts +681 -0
  9. package/lowcode/cms-plugin/pos-pages/imin-module.js +176 -59
  10. package/lowcode/cms-plugin/pos-pages/imin-module.ts +708 -568
  11. package/lowcode/cms-plugin/pos-pages/payment-page.js +47 -16
  12. package/lowcode/cms-plugin/pos-pages/payment-page.ts +55 -16
  13. package/lowcode/glitterBundle/dialog/ShareDialog.js +3 -0
  14. package/lowcode/glitterBundle/dialog/ShareDialog.ts +5 -0
  15. package/lowcode/glitterBundle/dialog/dialog.js +5 -1
  16. package/lowcode/glitterBundle/dialog/dialog.ts +4 -1
  17. package/lowcode/jspage/function-page/setting_editor.js +8 -0
  18. package/lowcode/jspage/function-page/setting_editor.ts +8 -0
  19. package/lowcode/public-components/terms-related/index.js +1 -1
  20. package/lowcode/public-components/terms-related/index.ts +1 -1
  21. package/package.json +1 -1
  22. package/src/api-public/services/order-event.js +1 -1
  23. package/src/api-public/services/order-event.js.map +1 -1
  24. package/src/api-public/services/order-event.ts +1 -1
  25. package/src/api-public/services/user.js +9 -8
  26. package/src/api-public/services/user.js.map +1 -1
  27. package/src/api-public/services/user.ts +13 -13
  28. package/src/services/template.js +1 -0
  29. package/src/services/template.js.map +1 -1
  30. package/src/services/template.ts +1 -0
@@ -9,6 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  };
10
10
  import { PayConfig } from './pay-config.js';
11
11
  import { PaymentPage } from './payment-page.js';
12
+ import { ApiShop } from '../../glitter-base/route/shopping.js';
13
+ import { Glitter } from '../../glitterBundle/Glitter.js';
12
14
  export class IminModule {
13
15
  static init() {
14
16
  return new Promise((resolve, reject) => {
@@ -85,7 +87,7 @@ export class IminModule {
85
87
  yield IminPrintInstance.setDoubleQRSize(4);
86
88
  yield IminPrintInstance.setDoubleQR1MarginLeft(10);
87
89
  yield IminPrintInstance.setDoubleQR2MarginLeft(520);
88
- const ba = (new Blob([invoice.qrcode_0]).size - (new Blob([invoice.qrcode_1]).size)) * 1.1;
90
+ const ba = (new Blob([invoice.qrcode_0]).size - new Blob([invoice.qrcode_1]).size) * 1.1;
89
91
  for (let a = 0; a <= ba; a++) {
90
92
  invoice.qrcode_1 += '*';
91
93
  }
@@ -174,16 +176,16 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
174
176
  });
175
177
  }
176
178
  function generateQRCode(text, size) {
177
- return new Promise((resolve) => {
179
+ return new Promise(resolve => {
178
180
  try {
179
181
  const div = document.createElement('div');
180
182
  var qrcode_R = new QRCode(div, {
181
183
  text: text,
182
184
  width: 50,
183
185
  height: 50,
184
- colorDark: "#000000",
185
- colorLight: "#ffffff",
186
- correctLevel: QRCode.CorrectLevel.M
186
+ colorDark: '#000000',
187
+ colorLight: '#ffffff',
188
+ correctLevel: QRCode.CorrectLevel.M,
187
189
  });
188
190
  setTimeout(() => {
189
191
  resolve(div.querySelector('canvas').toDataURL('image/png'));
@@ -195,12 +197,13 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
195
197
  }
196
198
  });
197
199
  }
198
- mergeQRCodes([invoice.qrcode_0, invoice.qrcode_1]).then((res) => {
200
+ mergeQRCodes([invoice.qrcode_0, invoice.qrcode_1]).then(res => {
199
201
  console.log(`two-qrcode=>`, res);
200
202
  glitter.runJsInterFace('start-print', {
201
203
  'command-list': [
202
204
  {
203
- key: 'print-text', data: {
205
+ key: 'print-text',
206
+ data: {
204
207
  style: 'bold',
205
208
  text: PayConfig.pos_config.shop_name,
206
209
  font_size: 50,
@@ -208,12 +211,14 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
208
211
  },
209
212
  },
210
213
  {
211
- key: 'print-space', data: {
214
+ key: 'print-space',
215
+ data: {
212
216
  space: 20,
213
217
  },
214
218
  },
215
219
  {
216
- key: 'print-text', data: {
220
+ key: 'print-text',
221
+ data: {
217
222
  style: 'normal',
218
223
  text: '電子發票證明聯',
219
224
  font_size: 40,
@@ -221,7 +226,8 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
221
226
  },
222
227
  },
223
228
  {
224
- key: 'print-text', data: {
229
+ key: 'print-text',
230
+ data: {
225
231
  style: 'normal',
226
232
  text: invoice.date,
227
233
  font_size: 50,
@@ -229,7 +235,8 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
229
235
  },
230
236
  },
231
237
  {
232
- key: 'print-text', data: {
238
+ key: 'print-text',
239
+ data: {
233
240
  style: 'normal',
234
241
  text: invoice.invoice_code,
235
242
  font_size: 50,
@@ -237,12 +244,14 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
237
244
  },
238
245
  },
239
246
  {
240
- key: 'print-space', data: {
247
+ key: 'print-space',
248
+ data: {
241
249
  space: 10,
242
250
  },
243
251
  },
244
252
  {
245
- key: 'print-text', data: {
253
+ key: 'print-text',
254
+ data: {
246
255
  style: 'normal',
247
256
  text: invoice.create_date,
248
257
  font_size: 24,
@@ -250,12 +259,14 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
250
259
  },
251
260
  },
252
261
  {
253
- key: 'print-space', data: {
262
+ key: 'print-space',
263
+ data: {
254
264
  space: 5,
255
265
  },
256
266
  },
257
267
  {
258
- key: 'print-text', data: {
268
+ key: 'print-text',
269
+ data: {
259
270
  style: 'normal',
260
271
  text: `${invoice.random_code} ${invoice.total}`,
261
272
  font_size: 24,
@@ -263,12 +274,14 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
263
274
  },
264
275
  },
265
276
  {
266
- key: 'print-space', data: {
277
+ key: 'print-space',
278
+ data: {
267
279
  space: 5,
268
280
  },
269
281
  },
270
282
  {
271
- key: 'print-text', data: {
283
+ key: 'print-text',
284
+ data: {
272
285
  style: 'normal',
273
286
  text: `${invoice.sale_gui} ${invoice.buy_gui}`,
274
287
  font_size: 24,
@@ -276,36 +289,42 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
276
289
  },
277
290
  },
278
291
  {
279
- key: 'print-space', data: {
292
+ key: 'print-space',
293
+ data: {
280
294
  space: 15,
281
295
  },
282
296
  },
283
297
  {
284
- key: 'barcode', data: {
298
+ key: 'barcode',
299
+ data: {
285
300
  text: invoice.bar_code,
286
301
  height: 50,
287
302
  width: 384,
288
303
  },
289
304
  },
290
305
  {
291
- key: 'print-space', data: {
306
+ key: 'print-space',
307
+ data: {
292
308
  space: 15,
293
309
  },
294
310
  },
295
311
  {
296
- key: 'print-bitmap', data: {
312
+ key: 'print-bitmap',
313
+ data: {
297
314
  base64: res,
298
315
  height: 150,
299
316
  width: 350,
300
317
  },
301
318
  },
302
319
  {
303
- key: 'print-space', data: {
320
+ key: 'print-space',
321
+ data: {
304
322
  space: 100,
305
323
  },
306
324
  },
307
325
  {
308
- key: 'print-text', data: {
326
+ key: 'print-text',
327
+ data: {
309
328
  style: 'normal',
310
329
  text: '交易明細',
311
330
  font_size: 40,
@@ -313,12 +332,14 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
313
332
  },
314
333
  },
315
334
  {
316
- key: 'print-space', data: {
335
+ key: 'print-space',
336
+ data: {
317
337
  space: 5,
318
338
  },
319
339
  },
320
340
  {
321
- key: 'print-text', data: {
341
+ key: 'print-text',
342
+ data: {
322
343
  style: 'normal',
323
344
  text: '時間:' + invoice.create_date,
324
345
  font_size: 24,
@@ -326,12 +347,14 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
326
347
  },
327
348
  },
328
349
  {
329
- key: 'print-space', data: {
350
+ key: 'print-space',
351
+ data: {
330
352
  space: 5,
331
353
  },
332
354
  },
333
355
  {
334
- key: 'print-text', data: {
356
+ key: 'print-text',
357
+ data: {
335
358
  style: 'normal',
336
359
  text: '營業人統編:' + invoice.sale_gui.replace('賣方 ', ''),
337
360
  font_size: 24,
@@ -339,12 +362,14 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
339
362
  },
340
363
  },
341
364
  {
342
- key: 'print-space', data: {
365
+ key: 'print-space',
366
+ data: {
343
367
  space: 5,
344
368
  },
345
369
  },
346
370
  {
347
- key: 'print-text', data: {
371
+ key: 'print-text',
372
+ data: {
348
373
  style: 'normal',
349
374
  text: '訂單編號:' + orderID,
350
375
  font_size: 24,
@@ -352,12 +377,14 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
352
377
  },
353
378
  },
354
379
  {
355
- key: 'print-space', data: {
380
+ key: 'print-space',
381
+ data: {
356
382
  space: 5,
357
383
  },
358
384
  },
359
385
  {
360
- key: 'print-text', data: {
386
+ key: 'print-text',
387
+ data: {
361
388
  style: 'normal',
362
389
  text: '發票號碼:' + invoice.invoice_code,
363
390
  font_size: 24,
@@ -365,12 +392,14 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
365
392
  },
366
393
  },
367
394
  {
368
- key: 'print-space', data: {
395
+ key: 'print-space',
396
+ data: {
369
397
  space: 5,
370
398
  },
371
399
  },
372
400
  {
373
- key: 'print-text', data: {
401
+ key: 'print-text',
402
+ data: {
374
403
  style: 'normal',
375
404
  text: '員工:' + staff_title,
376
405
  font_size: 24,
@@ -378,12 +407,14 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
378
407
  },
379
408
  },
380
409
  {
381
- key: 'print-space', data: {
410
+ key: 'print-space',
411
+ data: {
382
412
  space: 20,
383
413
  },
384
414
  },
385
415
  {
386
- key: 'print-text', data: {
416
+ key: 'print-text',
417
+ data: {
387
418
  style: 'normal',
388
419
  text: '品名 單價*數量 金額',
389
420
  font_size: 24,
@@ -395,7 +426,8 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
395
426
  const pay_what = PaymentPage.stripHtmlTags(invoice.pay_detail);
396
427
  for (let a = 0; a < pay_what.length; a++) {
397
428
  b.push({
398
- key: 'print-text', data: {
429
+ key: 'print-text',
430
+ data: {
399
431
  style: 'normal',
400
432
  text: pay_what[a],
401
433
  font_size: 24,
@@ -406,7 +438,8 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
406
438
  return b;
407
439
  })(),
408
440
  {
409
- key: 'print-space', data: {
441
+ key: 'print-space',
442
+ data: {
410
443
  space: 5,
411
444
  },
412
445
  },
@@ -415,7 +448,8 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
415
448
  let tempDiv = document.createElement('div');
416
449
  tempDiv.innerHTML = invoice.pay_detail_footer;
417
450
  c.push({
418
- key: 'print-text', data: {
451
+ key: 'print-text',
452
+ data: {
419
453
  style: 'normal',
420
454
  text: tempDiv.querySelector('.invoice-detail-sum').children[0].textContent,
421
455
  font_size: 24,
@@ -423,12 +457,14 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
423
457
  },
424
458
  });
425
459
  c.push({
426
- key: 'print-space', data: {
460
+ key: 'print-space',
461
+ data: {
427
462
  space: 5,
428
463
  },
429
464
  });
430
465
  c.push({
431
- key: 'print-text', data: {
466
+ key: 'print-text',
467
+ data: {
432
468
  style: 'normal',
433
469
  text: tempDiv.querySelector('.invoice-detail-sum').children[1].textContent,
434
470
  font_size: 24,
@@ -436,12 +472,14 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
436
472
  },
437
473
  });
438
474
  c.push({
439
- key: 'print-space', data: {
475
+ key: 'print-space',
476
+ data: {
440
477
  space: 20,
441
478
  },
442
479
  });
443
480
  c.push({
444
- key: 'print-text', data: {
481
+ key: 'print-text',
482
+ data: {
445
483
  style: 'normal',
446
484
  text: tempDiv.querySelector('.invoice-detail-sum').children[2].textContent,
447
485
  font_size: 24,
@@ -451,13 +489,13 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
451
489
  return c;
452
490
  })(),
453
491
  {
454
- key: 'print-space', data: {
492
+ key: 'print-space',
493
+ data: {
455
494
  space: 150,
456
495
  },
457
496
  },
458
497
  ],
459
- }, () => {
460
- }, {});
498
+ }, () => { }, {});
461
499
  });
462
500
  });
463
501
  }
@@ -467,20 +505,21 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
467
505
  glitter.runJsInterFace('start-print', {
468
506
  'command-list': [
469
507
  {
470
- key: 'barcode', data: {
508
+ key: 'barcode',
509
+ data: {
471
510
  text: code,
472
511
  height: 50,
473
512
  width: 384,
474
513
  },
475
514
  },
476
515
  {
477
- key: 'print-space', data: {
516
+ key: 'print-space',
517
+ data: {
478
518
  space: 150,
479
519
  },
480
520
  },
481
521
  ],
482
- }, () => {
483
- }, {});
522
+ }, () => { }, {});
484
523
  });
485
524
  }
486
525
  static printQrCodeSumi(code) {
@@ -492,16 +531,16 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
492
531
  glitter.root_path + 'jslib/qrcode-d.js',
493
532
  ], () => {
494
533
  function generateQRCode(text, size) {
495
- return new Promise((resolve) => {
534
+ return new Promise(resolve => {
496
535
  try {
497
536
  const div = document.createElement('div');
498
537
  var qrcode_R = new QRCode(div, {
499
538
  text: text,
500
539
  width: 100,
501
540
  height: 100,
502
- colorDark: "#000000",
503
- colorLight: "#ffffff",
504
- correctLevel: QRCode.CorrectLevel.M
541
+ colorDark: '#000000',
542
+ colorLight: '#ffffff',
543
+ correctLevel: QRCode.CorrectLevel.M,
505
544
  });
506
545
  setTimeout(() => {
507
546
  resolve(div.querySelector('canvas').toDataURL('image/png'));
@@ -518,23 +557,23 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
518
557
  glitter.runJsInterFace('start-print', {
519
558
  'command-list': [
520
559
  {
521
- key: 'print-bitmap', data: {
560
+ key: 'print-bitmap',
561
+ data: {
522
562
  base64: res.split('base64,')[1],
523
563
  height: 185,
524
564
  width: 185,
525
565
  },
526
566
  },
527
567
  {
528
- key: 'print-space', data: {
568
+ key: 'print-space',
569
+ data: {
529
570
  space: 150,
530
571
  },
531
572
  },
532
573
  ],
533
- }, () => {
534
- }, {});
574
+ }, () => { }, {});
535
575
  });
536
- }, () => {
537
- });
576
+ }, () => { });
538
577
  });
539
578
  }
540
579
  static printCode(code) {
@@ -557,4 +596,82 @@ ${tempDiv.querySelector('.invoice-detail-sum').children[2].textContent.replace(/
557
596
  yield IminPrintInstance.printAndFeedPaper(70);
558
597
  });
559
598
  }
599
+ static printTransactionDetails(orderID, invoice, staff_title) {
600
+ return __awaiter(this, void 0, void 0, function* () {
601
+ yield IminModule.init();
602
+ const IminPrintInstance = window.IminPrintInstance;
603
+ const od = (yield ApiShop.getOrder({
604
+ limit: 1,
605
+ page: 0,
606
+ data_from: 'user',
607
+ search: orderID,
608
+ searchType: 'cart_token',
609
+ })).response.data[0];
610
+ console.log(`order_data==>`, od);
611
+ if (window.parent.glitter.share.PayConfig.posType === 'SUNMI') {
612
+ }
613
+ else {
614
+ function nextLine24(align) {
615
+ return __awaiter(this, void 0, void 0, function* () {
616
+ yield IminPrintInstance.printAndFeedPaper(5);
617
+ yield IminPrintInstance.setAlignment(align);
618
+ yield IminPrintInstance.setTextSize(24);
619
+ yield IminPrintInstance.setTextStyle(0);
620
+ });
621
+ }
622
+ yield IminPrintInstance.setAlignment(1);
623
+ yield IminPrintInstance.setTextSize(50);
624
+ yield IminPrintInstance.setTextStyle(1);
625
+ yield IminPrintInstance.printText(PayConfig.pos_config.shop_name);
626
+ yield IminPrintInstance.printAndFeedPaper(20);
627
+ yield IminPrintInstance.printAndFeedPaper(5);
628
+ yield IminPrintInstance.setAlignment(1);
629
+ yield IminPrintInstance.setTextSize(40);
630
+ yield IminPrintInstance.setTextStyle(0);
631
+ if (PayConfig.pos_config.pos_support_finction.includes("order_sort")) {
632
+ yield IminPrintInstance.printText(`取餐號碼 : ${od.orderData.user_info.shipment_number}`);
633
+ }
634
+ else {
635
+ yield IminPrintInstance.printText('交易明細');
636
+ }
637
+ yield IminPrintInstance.printAndFeedPaper(5);
638
+ yield nextLine24(0);
639
+ yield IminPrintInstance.printText('時間:' + Glitter.glitter.ut.dateFormat(new Date(od.created_time), 'yyyy-MM-dd hh:mm:ss'));
640
+ if (invoice) {
641
+ yield nextLine24(0);
642
+ yield IminPrintInstance.printText('營業人統編:' + invoice.sale_gui.replace('賣方 ', ''));
643
+ }
644
+ yield nextLine24(0);
645
+ yield IminPrintInstance.printText('訂單編號:' + orderID);
646
+ if (invoice) {
647
+ yield nextLine24(0);
648
+ yield IminPrintInstance.printText('發票號碼:' + invoice.invoice_code);
649
+ }
650
+ yield nextLine24(0);
651
+ yield IminPrintInstance.printText('員工:' + staff_title);
652
+ yield IminPrintInstance.printAndFeedPaper(30);
653
+ yield IminPrintInstance.printText('品名 單價*數量 金額 ');
654
+ for (const b of od.orderData.lineItems) {
655
+ yield nextLine24(0);
656
+ yield IminPrintInstance.printText(b.title);
657
+ yield nextLine24(1);
658
+ yield IminPrintInstance.printText(`${b.sale_price.toLocaleString()} * ${b.count}`);
659
+ yield nextLine24(2);
660
+ yield IminPrintInstance.printText(b.sale_price);
661
+ }
662
+ yield nextLine24(0);
663
+ yield IminPrintInstance.printText(`折扣 ${od.orderData.discount.toLocaleString()}`);
664
+ yield nextLine24(0);
665
+ yield IminPrintInstance.printText(`合計 ${od.orderData.lineItems.length} 項`);
666
+ yield nextLine24(0);
667
+ yield IminPrintInstance.printText(`總計 $${od.total.toLocaleString()}`);
668
+ yield nextLine24(0);
669
+ if (od.orderData.user_info.note) {
670
+ yield IminPrintInstance.printText(`備註`);
671
+ yield IminPrintInstance.printText(od.orderData.user_info.note);
672
+ }
673
+ yield IminPrintInstance.printAndFeedPaper(140);
674
+ }
675
+ });
676
+ }
560
677
  }