ts-glitter 22.0.4 → 22.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/lowcode/Entry.js +1 -1
  2. package/lowcode/Entry.ts +1 -1
  3. package/lowcode/cms-plugin/shopping-collections.js +82 -100
  4. package/lowcode/cms-plugin/shopping-collections.ts +152 -172
  5. package/lowcode/cms-plugin/shopping-finance-setting.js +8 -12
  6. package/lowcode/cms-plugin/shopping-finance-setting.ts +8 -12
  7. package/lowcode/cms-plugin/shopping-product-setting.js +51 -33
  8. package/lowcode/cms-plugin/shopping-product-setting.ts +73 -64
  9. package/lowcode/cms-plugin/shopping-product-stock.js +70 -0
  10. package/lowcode/cms-plugin/shopping-product-stock.ts +86 -0
  11. package/lowcode/css/editor.css +2 -2
  12. package/lowcode/dialog/image-preview.js +33 -0
  13. package/lowcode/dialog/image-preview.ts +39 -0
  14. package/lowcode/glitter-base/route/shopping.js +1 -1
  15. package/lowcode/glitter-base/route/shopping.ts +3 -3
  16. package/lowcode/glitterBundle/Glitter.js +31 -0
  17. package/lowcode/glitterBundle/Glitter.ts +36 -0
  18. package/lowcode/jslib/barcode-min.js +2 -0
  19. package/lowcode/public-components/product/pd-class.js +4 -1
  20. package/lowcode/public-components/product/pd-class.ts +6 -1
  21. package/package.json +1 -1
  22. package/src/api-public/controllers/rebate.js +3 -1
  23. package/src/api-public/controllers/rebate.js.map +1 -1
  24. package/src/api-public/controllers/rebate.ts +97 -91
  25. package/src/api-public/services/rebate.js +1 -1
  26. package/src/api-public/services/rebate.js.map +1 -1
  27. package/src/api-public/services/rebate.ts +2 -3
  28. package/src/api-public/services/shopping.js +0 -1
  29. package/src/api-public/services/shopping.js.map +1 -1
  30. package/src/api-public/services/shopping.ts +0 -2
@@ -999,44 +999,62 @@ export class ShoppingProductSetting {
999
999
  <div class="flex-fill"></div>
1000
1000
  ${(() => {
1001
1001
  const ba = [];
1002
- if (window.parent.glitter.share.PayConfig.deviceType === 'pos') {
1002
+ ba.push(BgWidget.grayButton('一維條碼列印', gvc.event((e, event) => {
1003
+ event.stopPropagation();
1003
1004
  if (window.parent.glitter.share.PayConfig.posType === 'SUNMI') {
1004
- ba.push(BgWidget.grayButton('ㄧ條碼列印', gvc.event(() => {
1005
- IminModule.printCodeSumi(`variants-` + variant.barcode);
1006
- }), { icon: `fa-solid fa-rectangle-barcode` }));
1007
- ba.push(BgWidget.grayButton('QRCODE列印', gvc.event(() => {
1008
- IminModule.printQrCodeSumi(`variants-` + variant.barcode);
1009
- }), { icon: `fa-solid fa-qrcode` }));
1005
+ IminModule.printCodeSumi(`variants-` + variant.barcode);
1010
1006
  }
1011
1007
  else {
1012
- ba.push(BgWidget.grayButton('條碼列印', gvc.event(() => {
1013
- IminModule.printCode(`variants-` + variant.barcode);
1014
- }), { icon: `fa-solid fa-rectangle-barcode` }));
1008
+ const dialog = new ShareDialog(gvc.glitter);
1009
+ if (!variant.barcode) {
1010
+ dialog.errorMessage({ text: '請先設定商品條碼' });
1011
+ return;
1012
+ }
1013
+ window.parent.glitter.addMtScript([
1014
+ {
1015
+ src: gvc.glitter.root_path + 'jslib/barcode-min.js',
1016
+ },
1017
+ ], () => {
1018
+ if (!window.parent.document.querySelector("#barcode_preview")) {
1019
+ window.parent.glitter.$('body').append('<svg id="barcode_preview" style="display:none;"></svg>');
1020
+ }
1021
+ window.parent.JsBarcode("#barcode_preview", variant.barcode);
1022
+ var svg = window.parent.glitter.$("#barcode_preview")[0];
1023
+ var xml = new XMLSerializer().serializeToString(svg);
1024
+ var base64 = 'data:image/svg+xml;base64,' + btoa(xml);
1025
+ gvc.glitter.ut.print_img(base64);
1026
+ }, () => { });
1015
1027
  }
1016
- }
1017
- ba.push(BgWidget.grayButton('商品條碼', gvc.event(() => {
1018
- const dialog = new ShareDialog(gvc.glitter);
1019
- if (!variant.barcode) {
1020
- dialog.errorMessage({ text: '請先設定商品條碼' });
1021
- return;
1028
+ }), { icon: `fa-solid fa-rectangle-barcode` }));
1029
+ ba.push(BgWidget.grayButton('QRCODE列印', gvc.event((e, event) => {
1030
+ event.stopPropagation();
1031
+ if (window.parent.glitter.share.PayConfig.posType === 'SUNMI') {
1032
+ IminModule.printQrCodeSumi(`variants-` + variant.barcode);
1022
1033
  }
1023
- window.parent.glitter.addMtScript([
1024
- {
1025
- src: 'https://cdn.jsdelivr.net/npm/qrcode/build/qrcode.min.js',
1026
- },
1027
- ], () => {
1028
- window.parent.QRCode.toDataURL(`variants-` + variant.barcode, {
1029
- width: 200,
1030
- margin: 2,
1031
- }, function (err, url) {
1032
- if (err) {
1033
- console.error(err);
1034
- return;
1035
- }
1036
- window.parent.glitter.openDiaLog(new URL('../dialog/image-preview.js', import.meta.url).href, 'preview', url);
1037
- });
1038
- }, () => { });
1039
- }), { icon: `fa-regular fa-eye` }));
1034
+ else {
1035
+ const dialog = new ShareDialog(gvc.glitter);
1036
+ if (!variant.barcode) {
1037
+ dialog.errorMessage({ text: '請先設定商品條碼' });
1038
+ return;
1039
+ }
1040
+ window.parent.glitter.addMtScript([
1041
+ {
1042
+ src: 'https://cdn.jsdelivr.net/npm/qrcode/build/qrcode.min.js',
1043
+ },
1044
+ ], () => {
1045
+ window.parent.QRCode.toDataURL(`variants-` + variant.barcode, {
1046
+ width: 200,
1047
+ margin: 2,
1048
+ }, function (err, url) {
1049
+ if (err) {
1050
+ console.error(err);
1051
+ return;
1052
+ }
1053
+ gvc.glitter.ut.print_img(url);
1054
+ });
1055
+ }, () => { });
1056
+ }
1057
+ }), { icon: `fa-solid fa-qrcode` }));
1040
1058
  return ba.join(`<div class="mx-2"></div>`);
1041
1059
  })()}
1042
1060
  </div>
@@ -1144,77 +1144,86 @@ export class ShoppingProductSetting {
1144
1144
  <div class="flex-fill"></div>
1145
1145
  ${(() => {
1146
1146
  const ba = [];
1147
- if ((window.parent as any).glitter.share.PayConfig.deviceType === 'pos') {
1148
- if ((window.parent as any).glitter.share.PayConfig.posType === 'SUNMI') {
1149
- ba.push(
1150
- BgWidget.grayButton(
1151
- 'ㄧ條碼列印',
1152
- gvc.event(() => {
1153
- IminModule.printCodeSumi(`variants-` + variant.barcode);
1154
- }),
1155
- { icon: `fa-solid fa-rectangle-barcode` }
1156
- )
1157
- );
1158
- ba.push(
1159
- BgWidget.grayButton(
1160
- 'QRCODE列印',
1161
- gvc.event(() => {
1162
- IminModule.printQrCodeSumi(`variants-` + variant.barcode);
1163
- }),
1164
- { icon: `fa-solid fa-qrcode` }
1165
- )
1166
- );
1167
- } else {
1168
- ba.push(
1169
- BgWidget.grayButton(
1170
- '條碼列印',
1171
- gvc.event(() => {
1172
- IminModule.printCode(`variants-` + variant.barcode);
1173
- }),
1174
- { icon: `fa-solid fa-rectangle-barcode` }
1175
- )
1176
- );
1177
- }
1178
- }
1179
1147
  ba.push(
1180
1148
  BgWidget.grayButton(
1181
- '商品條碼',
1182
- gvc.event(() => {
1183
- const dialog = new ShareDialog(gvc.glitter);
1184
- if (!variant.barcode) {
1185
- dialog.errorMessage({ text: '請先設定商品條碼' });
1186
- return;
1187
- }
1188
- (window.parent as any).glitter.addMtScript(
1189
- [
1190
- {
1191
- src: 'https://cdn.jsdelivr.net/npm/qrcode/build/qrcode.min.js',
1149
+ '一維條碼列印',
1150
+ gvc.event((e,event) => {
1151
+ event.stopPropagation();
1152
+ if ((window.parent as any).glitter.share.PayConfig.posType === 'SUNMI'){
1153
+ IminModule.printCodeSumi(`variants-` + variant.barcode);
1154
+ }else{
1155
+ const dialog = new ShareDialog(gvc.glitter);
1156
+ if (!variant.barcode) {
1157
+ dialog.errorMessage({ text: '請先設定商品條碼' });
1158
+ return;
1159
+ }
1160
+ (window.parent as any).glitter.addMtScript(
1161
+ [
1162
+ {
1163
+ src: gvc.glitter.root_path+'jslib/barcode-min.js',
1164
+ },
1165
+ ],
1166
+ () => {
1167
+ if(! (window.parent as any).document.querySelector("#barcode_preview")){
1168
+ (window.parent as any).glitter.$('body').append('<svg id="barcode_preview" style="display:none;"></svg>');
1169
+ }
1170
+ (window.parent as any).JsBarcode("#barcode_preview", variant.barcode);
1171
+
1172
+ var svg = (window.parent as any).glitter.$("#barcode_preview")[0];
1173
+
1174
+ var xml = new XMLSerializer().serializeToString(svg);
1175
+
1176
+ var base64 = 'data:image/svg+xml;base64,' + btoa(xml);
1177
+
1178
+ gvc.glitter.ut.print_img(base64)
1192
1179
  },
1193
- ],
1194
- () => {
1195
- (window.parent as any).QRCode.toDataURL(
1196
- `variants-` + variant.barcode,
1180
+ () => {}
1181
+ );
1182
+ }
1183
+ }),
1184
+ { icon: `fa-solid fa-rectangle-barcode` }
1185
+ )
1186
+ );
1187
+ ba.push(
1188
+ BgWidget.grayButton(
1189
+ 'QRCODE列印',
1190
+ gvc.event((e,event) => {
1191
+ event.stopPropagation();
1192
+ if ((window.parent as any).glitter.share.PayConfig.posType === 'SUNMI'){
1193
+ IminModule.printQrCodeSumi(`variants-` + variant.barcode);
1194
+ }else{
1195
+ const dialog = new ShareDialog(gvc.glitter);
1196
+ if (!variant.barcode) {
1197
+ dialog.errorMessage({ text: '請先設定商品條碼' });
1198
+ return;
1199
+ }
1200
+ (window.parent as any).glitter.addMtScript(
1201
+ [
1197
1202
  {
1198
- width: 200,
1199
- margin: 2,
1203
+ src: 'https://cdn.jsdelivr.net/npm/qrcode/build/qrcode.min.js',
1200
1204
  },
1201
- function (err: any, url: any) {
1202
- if (err) {
1203
- console.error(err);
1204
- return;
1205
+ ],
1206
+ () => {
1207
+ (window.parent as any).QRCode.toDataURL(
1208
+ `variants-` + variant.barcode,
1209
+ {
1210
+ width: 200,
1211
+ margin: 2,
1212
+ },
1213
+ function (err: any, url: any) {
1214
+ if (err) {
1215
+ console.error(err);
1216
+ return;
1217
+ }
1218
+ gvc.glitter.ut.print_img(url)
1205
1219
  }
1206
- (window.parent as any).glitter.openDiaLog(
1207
- new URL('../dialog/image-preview.js', import.meta.url).href,
1208
- 'preview',
1209
- url
1210
- );
1211
- }
1212
- );
1213
- },
1214
- () => {}
1215
- );
1220
+ );
1221
+ },
1222
+ () => {}
1223
+ );
1224
+ }
1216
1225
  }),
1217
- { icon: `fa-regular fa-eye` }
1226
+ { icon: `fa-solid fa-qrcode` }
1218
1227
  )
1219
1228
  );
1220
1229
  return ba.join(`<div class="mx-2"></div>`);
@@ -8,6 +8,7 @@ import { BgProduct } from '../backend-manager/bg-product.js';
8
8
  import { ShoppingProductSetting } from './shopping-product-setting.js';
9
9
  import { Tool } from '../modules/tool.js';
10
10
  import { TableStorage } from './module/table-storage.js';
11
+ import { IminModule } from './pos-pages/imin-module.js';
11
12
  const html = String.raw;
12
13
  export class StockList {
13
14
  static main(gvc, option = {
@@ -87,6 +88,75 @@ export class StockList {
87
88
  dd.product_content.preview_image[0];
88
89
  }
89
90
  return [
91
+ {
92
+ key: '條碼列印',
93
+ value: `<div class="d-flex" style="gap:5px;">
94
+ ${[
95
+ `<div class="c_filter_view" style="cursor:pointer;" onclick="${gvc.event((e, event) => {
96
+ event.stopPropagation();
97
+ const variant = dd.variant_content;
98
+ if (window.parent.glitter.share.PayConfig.posType === 'SUNMI') {
99
+ IminModule.printCodeSumi(`variants-` + dd.variant_content.barcode);
100
+ }
101
+ else {
102
+ const dialog = new ShareDialog(gvc.glitter);
103
+ if (!variant.barcode) {
104
+ dialog.errorMessage({ text: '請先設定商品條碼' });
105
+ return;
106
+ }
107
+ window.parent.glitter.addMtScript([
108
+ {
109
+ src: gvc.glitter.root_path + 'jslib/barcode-min.js',
110
+ },
111
+ ], () => {
112
+ if (!window.parent.document.querySelector("#barcode_preview")) {
113
+ window.parent.glitter.$('body').append('<svg id="barcode_preview" style="display:none;"></svg>');
114
+ }
115
+ window.parent.JsBarcode("#barcode_preview", dd.variant_content.barcode);
116
+ var svg = window.parent.glitter.$("#barcode_preview")[0];
117
+ var xml = new XMLSerializer().serializeToString(svg);
118
+ var base64 = 'data:image/svg+xml;base64,' + btoa(xml);
119
+ gvc.glitter.ut.print_img(base64);
120
+ }, () => { });
121
+ }
122
+ })}">
123
+ <i class="fa-solid fa-rectangle-barcode" aria-hidden="true"></i>
124
+ </div>`,
125
+ `<div class="c_filter_view" style="cursor:pointer;" onclick="${gvc.event((e, event) => {
126
+ event.stopPropagation();
127
+ const variant = dd.variant_content;
128
+ if (window.parent.glitter.share.PayConfig.posType === 'SUNMI') {
129
+ IminModule.printQrCodeSumi(`variants-` + dd.variant_content.barcode);
130
+ }
131
+ else {
132
+ const dialog = new ShareDialog(gvc.glitter);
133
+ if (!variant.barcode) {
134
+ dialog.errorMessage({ text: '請先設定商品條碼' });
135
+ return;
136
+ }
137
+ window.parent.glitter.addMtScript([
138
+ {
139
+ src: 'https://cdn.jsdelivr.net/npm/qrcode/build/qrcode.min.js',
140
+ },
141
+ ], () => {
142
+ window.parent.QRCode.toDataURL(`variants-` + variant.barcode, {
143
+ width: 200,
144
+ margin: 2,
145
+ }, function (err, url) {
146
+ if (err) {
147
+ console.error(err);
148
+ return;
149
+ }
150
+ gvc.glitter.ut.print_img(url);
151
+ });
152
+ }, () => { });
153
+ }
154
+ })}">
155
+ <i class="fa-solid fa-qrcode" aria-hidden="true"></i>
156
+ </div>`
157
+ ].join('')}
158
+ </div>`
159
+ },
90
160
  {
91
161
  key: '商品名稱',
92
162
  value: html ` <div class="d-flex align-items-center gap-3" style="min-width: 250px;">
@@ -9,6 +9,7 @@ import { BgProduct, OptionsItem } from '../backend-manager/bg-product.js';
9
9
  import { ShoppingProductSetting } from './shopping-product-setting.js';
10
10
  import { Tool } from '../modules/tool.js';
11
11
  import { TableStorage } from './module/table-storage.js';
12
+ import { IminModule } from './pos-pages/imin-module.js';
12
13
 
13
14
  const html = String.raw;
14
15
 
@@ -136,6 +137,91 @@ export class StockList {
136
137
  dd.product_content.preview_image[0];
137
138
  }
138
139
  return [
140
+ {
141
+ key: '條碼列印',
142
+ value: `<div class="d-flex" style="gap:5px;">
143
+ ${
144
+ [
145
+ `<div class="c_filter_view" style="cursor:pointer;" onclick="${ gvc.event((e,event) => {
146
+ event.stopPropagation();
147
+ const variant = dd.variant_content;
148
+ if ((window.parent as any).glitter.share.PayConfig.posType === 'SUNMI'){
149
+ IminModule.printCodeSumi(`variants-` + dd.variant_content.barcode);
150
+ }else{
151
+ const dialog = new ShareDialog(gvc.glitter);
152
+ if (!variant.barcode) {
153
+ dialog.errorMessage({ text: '請先設定商品條碼' });
154
+ return;
155
+ }
156
+ (window.parent as any).glitter.addMtScript(
157
+ [
158
+ {
159
+ src: gvc.glitter.root_path+'jslib/barcode-min.js',
160
+ },
161
+ ],
162
+ () => {
163
+ if(! (window.parent as any).document.querySelector("#barcode_preview")){
164
+ (window.parent as any).glitter.$('body').append('<svg id="barcode_preview" style="display:none;"></svg>');
165
+ }
166
+ (window.parent as any).JsBarcode("#barcode_preview", dd.variant_content.barcode);
167
+
168
+ var svg = (window.parent as any).glitter.$("#barcode_preview")[0];
169
+
170
+ var xml = new XMLSerializer().serializeToString(svg);
171
+
172
+ var base64 = 'data:image/svg+xml;base64,' + btoa(xml);
173
+
174
+ gvc.glitter.ut.print_img(base64)
175
+ },
176
+ () => {}
177
+ );
178
+ }
179
+ })}">
180
+ <i class="fa-solid fa-rectangle-barcode" aria-hidden="true"></i>
181
+ </div>`,
182
+ `<div class="c_filter_view" style="cursor:pointer;" onclick="${gvc.event((e,event) => {
183
+ event.stopPropagation();
184
+ const variant = dd.variant_content;
185
+ if ((window.parent as any).glitter.share.PayConfig.posType === 'SUNMI'){
186
+ IminModule.printQrCodeSumi(`variants-` + dd.variant_content.barcode);
187
+ }else{
188
+ const dialog = new ShareDialog(gvc.glitter);
189
+ if (!variant.barcode) {
190
+ dialog.errorMessage({ text: '請先設定商品條碼' });
191
+ return;
192
+ }
193
+ (window.parent as any).glitter.addMtScript(
194
+ [
195
+ {
196
+ src: 'https://cdn.jsdelivr.net/npm/qrcode/build/qrcode.min.js',
197
+ },
198
+ ],
199
+ () => {
200
+ (window.parent as any).QRCode.toDataURL(
201
+ `variants-` + variant.barcode,
202
+ {
203
+ width: 200,
204
+ margin: 2,
205
+ },
206
+ function (err: any, url: any) {
207
+ if (err) {
208
+ console.error(err);
209
+ return;
210
+ }
211
+ gvc.glitter.ut.print_img(url)
212
+ }
213
+ );
214
+ },
215
+ () => {}
216
+ );
217
+ }
218
+ })}">
219
+ <i class="fa-solid fa-qrcode" aria-hidden="true"></i>
220
+ </div>`
221
+ ].join('')
222
+ }
223
+ </div>`
224
+ },
139
225
  {
140
226
  key: '商品名稱',
141
227
  value: html` <div class="d-flex align-items-center gap-3" style="min-width: 250px;">
@@ -29,7 +29,7 @@
29
29
  --main-orange-2: #ffb400;
30
30
  --main-orange-3: #ff6c02;
31
31
  --main-green: #10931d;
32
- --main-yellow: #FFB21C;
32
+ --main-yellow: #ffb21c;
33
33
 
34
34
  --item-primary: #4d86db;
35
35
  --item-success: #d8ecda;
@@ -1130,7 +1130,7 @@ h6 {
1130
1130
  .insignia-sm {
1131
1131
  border-radius: 0.25rem;
1132
1132
  min-height: 20px;
1133
- padding: 3px 4px;
1133
+ padding: 3px 6px;
1134
1134
  font-size: 12px;
1135
1135
  }
1136
1136
 
@@ -31,6 +31,39 @@ init(import.meta.url, (gvc, glitter, gBundle) => {
31
31
  style="background-color: rgba(0,0,0,0.5);">
32
32
  <div id="${hd}" style="height:50px;right:0;top:${gvc.glitter.share.top_inset || 0}px;"
33
33
  class="m-2 position-absolute d-flex align-items-center justify-content-center gap-2">
34
+ <div class="btn btn-gray" onclick="${gvc.event(() => {
35
+ const printWindow = window.open('', '', 'width=800,height=600');
36
+ const imgSrc = gBundle;
37
+ printWindow.document.write(`
38
+ <html>
39
+ <head>
40
+ <title>列印圖片</title>
41
+ <style>
42
+ img {
43
+ max-width: 100%;
44
+ height: auto;
45
+ }
46
+ @media print {
47
+ body {
48
+ margin: 0;
49
+ padding: 0;
50
+ }
51
+ }
52
+ </style>
53
+ </head>
54
+ <body>
55
+ <img src="${imgSrc}" />
56
+ </body>
57
+ </html>
58
+ `);
59
+ printWindow.document.querySelector('img').onload = function () {
60
+ printWindow.focus();
61
+ printWindow.print();
62
+ printWindow.close();
63
+ };
64
+ })}">
65
+ <span class="tx_700" >列印</span>
66
+ </div>
34
67
  <div class="btn btn-gray" href="${gBundle}" onclick="${gvc.event(() => {
35
68
  const link = document.createElement('a');
36
69
  link.href = gBundle;
@@ -45,6 +45,45 @@ gvc.addStyle(`.btn-gray {
45
45
  style="background-color: rgba(0,0,0,0.5);">
46
46
  <div id="${hd}" style="height:50px;right:0;top:${gvc.glitter.share.top_inset || 0}px;"
47
47
  class="m-2 position-absolute d-flex align-items-center justify-content-center gap-2">
48
+ <div class="btn btn-gray" onclick="${gvc.event(()=>{
49
+ // 創建一個新的列印窗口
50
+ const printWindow:any = window.open('', '', 'width=800,height=600');
51
+ const imgSrc = gBundle;
52
+
53
+ // 設置列印窗口的內容
54
+ printWindow.document.write(`
55
+ <html>
56
+ <head>
57
+ <title>列印圖片</title>
58
+ <style>
59
+ img {
60
+ max-width: 100%;
61
+ height: auto;
62
+ }
63
+ @media print {
64
+ body {
65
+ margin: 0;
66
+ padding: 0;
67
+ }
68
+ }
69
+ </style>
70
+ </head>
71
+ <body>
72
+ <img src="${imgSrc}" />
73
+ </body>
74
+ </html>
75
+ `);
76
+
77
+ // 等待圖片加載完成後執行列印
78
+ printWindow.document.querySelector('img').onload = function() {
79
+ printWindow.focus();
80
+ printWindow.print();
81
+ printWindow.close();
82
+ };
83
+
84
+ })}">
85
+ <span class="tx_700" >列印</span>
86
+ </div>
48
87
  <div class="btn btn-gray" href="${gBundle}" onclick="${gvc.event(()=>{
49
88
  const link = document.createElement('a');
50
89
  link.href = gBundle;
@@ -790,7 +790,7 @@ export class ApiShop {
790
790
  });
791
791
  }
792
792
  static getCollection() {
793
- return new Promise((resolve, reject) => {
793
+ return new Promise(resolve => {
794
794
  var _a;
795
795
  window.glitter.share._public_config = (_a = window.glitter.share._public_config) !== null && _a !== void 0 ? _a : {};
796
796
  const config = window.glitter.share._public_config;
@@ -654,8 +654,8 @@ export class ApiShop {
654
654
  valid?: boolean;
655
655
  is_shipment?: boolean;
656
656
  is_reconciliation?: boolean;
657
- buyer_name?:string,
658
- buyer_phone?:string
657
+ buyer_name?: string;
658
+ buyer_phone?: string;
659
659
  }) {
660
660
  const filterString = this.orderListFilterString(json.filter);
661
661
  return BaseApi.create({
@@ -936,7 +936,7 @@ export class ApiShop {
936
936
  }
937
937
 
938
938
  static getCollection() {
939
- return new Promise<{ result: boolean; response: any }>((resolve, reject) => {
939
+ return new Promise<{ result: boolean; response: any }>(resolve => {
940
940
  (window as any).glitter.share._public_config = (window as any).glitter.share._public_config ?? {};
941
941
  const config = (window as any).glitter.share._public_config;
942
942
  if (config[`collection-manager`] && (window as any).glitter.getUrlParameter('cms') !== 'true') {
@@ -78,6 +78,37 @@ export class Glitter {
78
78
  this.ut = {
79
79
  glitter: this,
80
80
  queue: {},
81
+ print_img: (base64) => {
82
+ const printWindow = (this.window).open('', '', 'width=800,height=600');
83
+ const imgSrc = base64;
84
+ printWindow.document.write(`
85
+ <html>
86
+ <head>
87
+ <title>列印圖片</title>
88
+ <style>
89
+ img {
90
+ max-width: 100%;
91
+ height: auto;
92
+ }
93
+ @media print {
94
+ body {
95
+ margin: 0;
96
+ padding: 0;
97
+ }
98
+ }
99
+ </style>
100
+ </head>
101
+ <body>
102
+ <img src="${imgSrc}" />
103
+ </body>
104
+ </html>
105
+ `);
106
+ printWindow.document.querySelector('img').onload = function () {
107
+ printWindow.focus();
108
+ printWindow.print();
109
+ printWindow.close();
110
+ };
111
+ },
81
112
  resize_img_url: (link) => {
82
113
  let rela_link = link;
83
114
  function findClosestNumbers(arr, target) {
@@ -750,6 +750,42 @@ ${(!error.message) ? `` : `錯誤訊息:${error.message}`}${(!error.lineNumber)
750
750
  public ut = {
751
751
  glitter: this,
752
752
  queue: {},
753
+ print_img:(base64:string)=>{
754
+ // 創建一個新的列印窗口
755
+ const printWindow:any = (this.window).open('', '', 'width=800,height=600');
756
+ const imgSrc = base64;
757
+
758
+ // 設置列印窗口的內容
759
+ printWindow.document.write(`
760
+ <html>
761
+ <head>
762
+ <title>列印圖片</title>
763
+ <style>
764
+ img {
765
+ max-width: 100%;
766
+ height: auto;
767
+ }
768
+ @media print {
769
+ body {
770
+ margin: 0;
771
+ padding: 0;
772
+ }
773
+ }
774
+ </style>
775
+ </head>
776
+ <body>
777
+ <img src="${imgSrc}" />
778
+ </body>
779
+ </html>
780
+ `);
781
+
782
+ // 等待圖片加載完成後執行列印
783
+ printWindow.document.querySelector('img').onload = function() {
784
+ printWindow.focus();
785
+ printWindow.print();
786
+ printWindow.close();
787
+ };
788
+ },
753
789
  resize_img_url: (link: string) => {
754
790
  let rela_link = link;
755
791
  function findClosestNumbers(arr:any, target:number) {