ts-glitter 14.2.4 → 14.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 (107) hide show
  1. package/lowcode/Entry.js +1 -1
  2. package/lowcode/Entry.ts +1 -1
  3. package/lowcode/backend-manager/bg-product.js +2 -1
  4. package/lowcode/backend-manager/bg-product.ts +2 -1
  5. package/lowcode/cms-plugin/filter-options.js +1 -3
  6. package/lowcode/cms-plugin/filter-options.ts +1 -3
  7. package/lowcode/cms-plugin/module/product-excel.js +537 -0
  8. package/lowcode/cms-plugin/module/product-excel.ts +652 -0
  9. package/lowcode/cms-plugin/shopping-allowance-manager.js +12 -5
  10. package/lowcode/cms-plugin/shopping-allowance-manager.ts +12 -5
  11. package/lowcode/cms-plugin/shopping-discount-setting.js +1 -1
  12. package/lowcode/cms-plugin/shopping-discount-setting.ts +1 -1
  13. package/lowcode/cms-plugin/shopping-finance-setting.js +0 -7
  14. package/lowcode/cms-plugin/shopping-finance-setting.ts +8 -8
  15. package/lowcode/cms-plugin/shopping-invoice-manager.js +5 -1
  16. package/lowcode/cms-plugin/shopping-invoice-manager.ts +5 -2
  17. package/lowcode/cms-plugin/shopping-order-manager.js +8 -0
  18. package/lowcode/cms-plugin/shopping-order-manager.ts +8 -0
  19. package/lowcode/cms-plugin/shopping-product-setting.js +61 -638
  20. package/lowcode/cms-plugin/shopping-product-setting.ts +67 -790
  21. package/lowcode/jspage/main.ts +0 -1
  22. package/lowcode/public-components/blogs/blogs-01.js +4 -0
  23. package/lowcode/public-components/checkout/index.js +967 -209
  24. package/lowcode/public-components/checkout/index.ts +977 -214
  25. package/lowcode/public-components/checkout/index_.js +1724 -412
  26. package/lowcode/public-components/checkout/index_.ts +2032 -704
  27. package/lowcode/public-components/product/pd-class.js +68 -13
  28. package/lowcode/public-components/product/pd-class.ts +74 -14
  29. package/lowcode/public-components/product/product-detail.js +1 -1
  30. package/lowcode/public-components/product/product-detail.ts +7 -3
  31. package/lowcode/public-components/product/product-list.js +55 -0
  32. package/lowcode/public-components/product/product-list.ts +62 -1
  33. package/lowcode/public-components/public/ad.js +14 -0
  34. package/lowcode/public-components/public/ad.ts +15 -0
  35. package/package.json +7 -4
  36. package/src/api-public/controllers/ai-chat.js.map +1 -1
  37. package/src/api-public/controllers/app-release.js.map +1 -1
  38. package/src/api-public/controllers/article.js.map +1 -1
  39. package/src/api-public/controllers/fcm.js.map +1 -1
  40. package/src/api-public/controllers/post.js.map +1 -1
  41. package/src/api-public/controllers/rebate.js.map +1 -1
  42. package/src/api-public/controllers/shop.js +16 -0
  43. package/src/api-public/controllers/shop.js.map +1 -1
  44. package/src/api-public/controllers/shop.ts +27 -3
  45. package/src/api-public/controllers/user.js.map +1 -1
  46. package/src/api-public/services/EcInvoice.js +18 -12
  47. package/src/api-public/services/EcInvoice.js.map +1 -1
  48. package/src/api-public/services/EcInvoice.ts +19 -14
  49. package/src/api-public/services/ai-robot.d.ts +0 -1
  50. package/src/api-public/services/ai-robot.js.map +1 -1
  51. package/src/api-public/services/auto-send-email.js.map +1 -1
  52. package/src/api-public/services/chat.js.map +1 -1
  53. package/src/api-public/services/custom-code.js.map +1 -1
  54. package/src/api-public/services/delivery.js.map +1 -1
  55. package/src/api-public/services/ezpay/tool.d.ts +1 -0
  56. package/src/api-public/services/fb-message.js.map +1 -1
  57. package/src/api-public/services/financial-service.d.ts +49 -1
  58. package/src/api-public/services/financial-service.js +226 -1
  59. package/src/api-public/services/financial-service.js.map +1 -1
  60. package/src/api-public/services/financial-service.ts +282 -1
  61. package/src/api-public/services/line-message.js.map +1 -1
  62. package/src/api-public/services/monitor.d.ts +1 -0
  63. package/src/api-public/services/post.js.map +1 -1
  64. package/src/api-public/services/rebate.js.map +1 -1
  65. package/src/api-public/services/schedule.js.map +1 -1
  66. package/src/api-public/services/share-permission.js.map +1 -1
  67. package/src/api-public/services/shopping.d.ts +3 -1
  68. package/src/api-public/services/shopping.js +57 -58
  69. package/src/api-public/services/shopping.js.map +1 -1
  70. package/src/api-public/services/shopping.ts +77 -76
  71. package/src/api-public/services/sms.js.map +1 -1
  72. package/src/api-public/services/user.js.map +1 -1
  73. package/src/api-public/utils/ut-permission.d.ts +1 -0
  74. package/src/app-project/serverless/src/modules/database.d.ts +1 -1
  75. package/src/app-project/serverless/src/modules/redis.d.ts +1 -1
  76. package/src/config.d.ts +1 -1
  77. package/src/config.js.map +1 -1
  78. package/src/controllers/ai.js.map +1 -1
  79. package/src/controllers/filemanager.js.map +1 -1
  80. package/src/firebase/message.js +2 -1
  81. package/src/firebase/message.js.map +1 -1
  82. package/src/helper/app_creater.js +2 -1
  83. package/src/helper/app_creater.js.map +1 -1
  84. package/src/helper/glitter-util.js.map +3 -3
  85. package/src/index.js +111 -92
  86. package/src/index.js.map +1 -5
  87. package/src/index.ts +424 -397
  88. package/src/lambda/interface.d.ts +1 -1
  89. package/src/lambda/interface.js +2 -2
  90. package/src/lambda/interface.js.map +1 -1
  91. package/src/modules/AWSLib.js +3 -2
  92. package/src/modules/AWSLib.js.map +1 -1
  93. package/src/modules/database.d.ts +1 -1
  94. package/src/modules/redis.d.ts +1 -1
  95. package/src/modules/tool.js +2 -1
  96. package/src/modules/tool.js.map +1 -1
  97. package/src/run.js +2 -1
  98. package/src/run.js.map +1 -1
  99. package/src/services/backend-service.js.map +1 -1
  100. package/src/services/create-instance.js +4 -3
  101. package/src/services/create-instance.js.map +1 -1
  102. package/src/services/saas-table-check.js +2 -2
  103. package/src/services/saas-table-check.js.map +1 -1
  104. package/src/services/ses.js +2 -1
  105. package/src/services/ses.js.map +1 -1
  106. package/src/services/tool.js +3 -2
  107. package/src/services/tool.js.map +1 -1
@@ -20,354 +20,13 @@ import { Tool } from '../modules/tool.js';
20
20
  import { CheckInput } from '../modules/checkInput.js';
21
21
  import { imageLibrary } from '../modules/image-library.js';
22
22
  import { ProductAi } from './ai-generator/product-ai.js';
23
- class Excel {
24
- constructor(gvc, headers, lineName) {
25
- this.gvc = gvc;
26
- this.headers = headers;
27
- this.lineName = lineName;
28
- }
29
- loadScript() {
30
- return new Promise((resolve) => {
31
- if (window.ExcelJS) {
32
- this.initExcel();
33
- resolve(true);
34
- }
35
- else {
36
- this.gvc.addMtScript([{ src: 'https://cdnjs.cloudflare.com/ajax/libs/exceljs/4.3.0/exceljs.min.js' }], () => {
37
- if (window.XLSX) {
38
- this.initExcel();
39
- resolve(true);
40
- }
41
- }, () => { });
42
- }
43
- });
44
- }
45
- initExcel() {
46
- this.ExcelJS = window.ExcelJS;
47
- this.workbook = new this.ExcelJS.Workbook();
48
- this.worksheet = this.workbook.addWorksheet('Sheet1');
49
- }
50
- importData(notifyId, file) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- yield this.loadScript();
53
- const reader = new FileReader();
54
- const dialog = new ShareDialog(this.gvc.glitter);
55
- dialog.dataLoading({ visible: true, text: '資料處理中' });
56
- reader.onload = (e) => __awaiter(this, void 0, void 0, function* () {
57
- const arrayBuffer = e.target.result;
58
- const workbook = new this.ExcelJS.Workbook();
59
- yield workbook.xlsx.load(arrayBuffer);
60
- const worksheet = workbook.getWorksheet(1);
61
- const data = [];
62
- worksheet.eachRow({ includeEmpty: true }, (row, rowNumber) => {
63
- const rowData = [];
64
- row.eachCell({ includeEmpty: true }, (cell, colNumber) => {
65
- rowData.push(cell.value);
66
- });
67
- const isEmptyRow = rowData.every((cellValue) => cellValue === null || cellValue === '');
68
- if (!isEmptyRow) {
69
- data.push(rowData);
70
- }
71
- });
72
- let error = false;
73
- let addCollection = [];
74
- let postMD = [];
75
- let productData = {};
76
- let variantData = {
77
- barcode: '',
78
- compare_price: 0,
79
- cost: 0,
80
- preview_image: '',
81
- profit: 0,
82
- sale_price: 0,
83
- shipment_type: 'weight',
84
- show_understocking: '',
85
- sku: '',
86
- spec: [],
87
- stock: 0,
88
- type: '',
89
- v_height: 0,
90
- v_length: 0,
91
- v_width: 0,
92
- weight: 0,
93
- };
94
- data.forEach((row, index) => {
95
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
96
- variantData = {
97
- barcode: '',
98
- compare_price: 0,
99
- cost: 0,
100
- preview_image: '',
101
- profit: 0,
102
- sale_price: 0,
103
- shipment_type: 'weight',
104
- show_understocking: '',
105
- sku: '',
106
- spec: [],
107
- stock: 0,
108
- type: '',
109
- v_height: 0,
110
- v_length: 0,
111
- v_width: 0,
112
- weight: 0,
113
- };
114
- if (index != 0) {
115
- if (row[1]) {
116
- if (Object.keys(productData).length != 0) {
117
- postMD.push(productData);
118
- }
119
- addCollection = [];
120
- productData = {
121
- title: '',
122
- productType: {
123
- product: true,
124
- addProduct: false,
125
- giveaway: false,
126
- },
127
- content: '',
128
- status: 'active',
129
- collection: [],
130
- hideIndex: 'false',
131
- preview_image: '',
132
- specs: [],
133
- variants: [],
134
- seo: {
135
- title: '',
136
- content: '',
137
- keywords: '',
138
- },
139
- template: '',
140
- };
141
- productData.title = (_a = row[0]) !== null && _a !== void 0 ? _a : '';
142
- productData.status = row[1] == '上架' ? 'active' : 'draft';
143
- productData.collection = (_b = row[2].split(',')) !== null && _b !== void 0 ? _b : [];
144
- const regex = /[\s\/\\]+/g;
145
- productData.collection = productData.collection.map((item) => item.replace(/\s+/g, ''));
146
- productData.collection.forEach((row) => {
147
- let collection = row.replace(/\s+/g, '');
148
- if (regex.test(collection)) {
149
- error = true;
150
- const dialog = new ShareDialog(this.gvc.glitter);
151
- dialog.infoMessage({ text: `第${index + 1}行的類別名稱不可包含空白格與以下符號:「 / 」「 \\ 」,並以「 , 」區分不同類別` });
152
- return;
153
- }
154
- function splitStringIncrementally(input) {
155
- const parts = input.split('/');
156
- const result = [];
157
- parts.reduce((acc, part) => {
158
- const newAcc = acc ? `${acc}/${part}` : part;
159
- result.push(newAcc);
160
- return newAcc;
161
- }, '');
162
- return result;
163
- }
164
- if (collection.split('/').length > 1) {
165
- let check = splitStringIncrementally(collection);
166
- const newItems = check.filter((item) => !productData.collection.includes(item));
167
- addCollection.push(...newItems);
168
- }
169
- addCollection.push(collection);
170
- });
171
- productData.collection = addCollection;
172
- productData.productType.addProduct = row[3].includes('加購品');
173
- productData.productType.product = row[3].includes('商品');
174
- productData.productType.giveaway = row[3].includes('贈品');
175
- productData.preview_image = row[4] ? [row[4]] : ['商品圖片'];
176
- productData.seo.title = (_c = row[5]) !== null && _c !== void 0 ? _c : '';
177
- productData.seo.content = (_d = row[6]) !== null && _d !== void 0 ? _d : '';
178
- productData.seo.keywords = (_e = row[7]) !== null && _e !== void 0 ? _e : '';
179
- let indices = [8, 10, 12];
180
- indices.forEach((index) => {
181
- if (row[index]) {
182
- productData.specs.push({
183
- title: row[index],
184
- option: [],
185
- });
186
- }
187
- });
188
- }
189
- let indices = [9, 11, 13];
190
- indices.forEach((rowindex, key) => {
191
- var _a;
192
- if (row[rowindex] && productData.specs.length > key) {
193
- productData.specs[key].option = (_a = productData.specs[key].option) !== null && _a !== void 0 ? _a : [];
194
- const exists = productData.specs[key].option.some((item) => item.title === row[rowindex]);
195
- if (!exists) {
196
- productData.specs[key].option.push({ title: row[rowindex], expand: true });
197
- }
198
- variantData.spec.push(row[rowindex]);
199
- }
200
- });
201
- variantData.sku = (_f = row[14]) !== null && _f !== void 0 ? _f : '';
202
- variantData.cost = (_g = row[15]) !== null && _g !== void 0 ? _g : '';
203
- variantData.sale_price = (_h = row[16]) !== null && _h !== void 0 ? _h : 0;
204
- variantData.compare_price = (_j = row[17]) !== null && _j !== void 0 ? _j : 0;
205
- variantData.profit = (_k = row[18]) !== null && _k !== void 0 ? _k : 0;
206
- const shipmentTypeMap = {
207
- 依材積計算: 'volume',
208
- 不計算運費: 'none',
209
- };
210
- variantData.shipment_type = shipmentTypeMap[row[19]] || 'weight';
211
- variantData.v_length = (_l = row[20]) !== null && _l !== void 0 ? _l : 0;
212
- variantData.v_width = (_m = row[21]) !== null && _m !== void 0 ? _m : 0;
213
- variantData.v_height = (_o = row[22]) !== null && _o !== void 0 ? _o : 0;
214
- variantData.weight = (_p = row[23]) !== null && _p !== void 0 ? _p : 0;
215
- variantData.show_understocking = row[25] == '追蹤' ? 'true' : 'false';
216
- variantData.stock = (_q = row[26]) !== null && _q !== void 0 ? _q : 0;
217
- variantData.save_stock = (_r = row[27]) !== null && _r !== void 0 ? _r : 0;
218
- variantData.barcode = (_s = row[28]) !== null && _s !== void 0 ? _s : '';
219
- productData.variants.push(JSON.parse(JSON.stringify(variantData)));
220
- }
221
- });
222
- postMD.push(productData);
223
- productData.reverse;
224
- let passData = {
225
- data: postMD,
226
- collection: addCollection,
227
- };
228
- dialog.dataLoading({ visible: false });
229
- if (!error) {
230
- dialog.dataLoading({ visible: true, text: '上傳資料中' });
231
- yield ApiShop.postMultiProduct({
232
- data: passData,
233
- token: window.parent.config.token,
234
- }).then(() => {
235
- dialog.dataLoading({ visible: false });
236
- dialog.successMessage({ text: '上傳成功' });
237
- this.gvc.glitter.closeDiaLog();
238
- this.gvc.notifyDataChange(notifyId);
239
- });
240
- }
241
- });
242
- reader.readAsArrayBuffer(file);
243
- });
244
- }
245
- static getFileTime() {
246
- const now = new Date();
247
- const year = now.getFullYear();
248
- const month = String(now.getMonth() + 1).padStart(2, '0');
249
- const day = String(now.getDate()).padStart(2, '0');
250
- const hours = String(now.getHours()).padStart(2, '0');
251
- const minutes = String(now.getMinutes()).padStart(2, '0');
252
- return `${year}${month}${day}${hours}${minutes}`;
253
- }
254
- exportData(data, name) {
255
- return __awaiter(this, void 0, void 0, function* () {
256
- yield this.loadScript();
257
- this.setHeader();
258
- this.insertData(data);
259
- this.setHeaderStyle();
260
- this.setRowHeight();
261
- this.setFontAndAlignmentStyle();
262
- this.adjustColumnWidths(data);
263
- const buffer = yield this.workbook.xlsx.writeBuffer();
264
- let fileName = name !== null && name !== void 0 ? name : `example_${new Date().toISOString()}`;
265
- this.saveAsExcelFile(buffer, `${fileName}.xlsx`);
266
- });
267
- }
268
- insertData(data) {
269
- data.forEach((row) => {
270
- this.worksheet.addRow(Object.values(row));
271
- });
272
- }
273
- setHeader() {
274
- this.worksheet.addRow(this.headers);
275
- }
276
- setHeaderStyle() {
277
- this.worksheet.getRow(1).eachCell((cell) => {
278
- cell.font = { name: 'Microsoft JhengHei', bold: true };
279
- cell.alignment = { vertical: 'middle', horizontal: 'center' };
280
- cell.fill = { type: 'pattern', pattern: 'solid', fgColor: { argb: 'FFE1E1E1' } };
281
- });
282
- }
283
- setRowHeight() {
284
- this.worksheet.eachRow((row) => {
285
- row.height = 18;
286
- });
287
- }
288
- setFontAndAlignmentStyle() {
289
- this.worksheet.eachRow((row) => {
290
- row.eachCell((cell) => {
291
- cell.font = { name: 'Microsoft JhengHei' };
292
- cell.alignment = { vertical: 'middle', horizontal: 'center' };
293
- });
294
- });
295
- }
296
- exportToExcel() {
297
- return __awaiter(this, void 0, void 0, function* () {
298
- const buffer = yield this.workbook.xlsx.writeBuffer();
299
- this.saveAsExcelFile(buffer, `example_${new Date().toISOString()}.xlsx`);
300
- });
301
- }
302
- saveAsExcelFile(buffer, fileName) {
303
- const saasConfig = window.saasConfig;
304
- const dialog = new ShareDialog(this.gvc.glitter);
305
- saasConfig.api.uploadFile(fileName).then((data) => {
306
- const EXCEL_TYPE = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=UTF-8';
307
- const blobData = new Blob([buffer], { type: EXCEL_TYPE });
308
- const data1 = data.response;
309
- dialog.dataLoading({ visible: true });
310
- $.ajax({
311
- url: data1.url,
312
- type: 'put',
313
- data: blobData,
314
- processData: false,
315
- headers: {
316
- 'Content-Type': data1.type,
317
- },
318
- crossDomain: true,
319
- success: () => {
320
- dialog.dataLoading({ visible: false });
321
- const link = document.createElement('a');
322
- link.href = data1.fullUrl;
323
- link.download = fileName;
324
- link.click();
325
- },
326
- error: () => {
327
- dialog.dataLoading({ visible: false });
328
- dialog.errorMessage({ text: '上傳失敗' });
329
- },
330
- });
331
- });
332
- }
333
- getByteLength(str) {
334
- let byteLength = 0;
335
- for (let i = 0; i < str.length; i++) {
336
- const charCode = str.charCodeAt(i);
337
- if (charCode <= 0x007f) {
338
- byteLength += 1;
339
- }
340
- else if (charCode <= 0x07ff) {
341
- byteLength += 2;
342
- }
343
- else if (charCode <= 0xffff) {
344
- byteLength += 3;
345
- }
346
- else {
347
- byteLength += 4;
348
- }
349
- }
350
- return byteLength;
351
- }
352
- adjustColumnWidths(sheetData) {
353
- const maxLengths = this.headers.map((header) => this.getByteLength(header));
354
- sheetData.forEach((row) => {
355
- Object.values(row).forEach((value, index) => {
356
- const valueLength = this.getByteLength(value);
357
- if (valueLength > maxLengths[index]) {
358
- maxLengths[index] = valueLength;
359
- }
360
- });
361
- });
362
- this.worksheet.columns = this.headers.map((header, index) => {
363
- return { header, width: maxLengths[index] + 2 };
364
- });
365
- }
366
- }
23
+ import { ProductExcel } from './module/product-excel.js';
367
24
  export class ShoppingProductSetting {
368
25
  static main(gvc, type = 'product') {
369
26
  const html = String.raw;
370
27
  const glitter = gvc.glitter;
28
+ const dialog = new ShareDialog(glitter);
29
+ const excelHeader = ProductExcel.exampleHeader();
371
30
  const vm = {
372
31
  id: glitter.getUUID(),
373
32
  tableId: glitter.getUUID(),
@@ -387,9 +46,9 @@ export class ShoppingProductSetting {
387
46
  category: '',
388
47
  productType: ``,
389
48
  img: '',
49
+ SEO_domain: '',
390
50
  SEO_title: '',
391
51
  SEO_desc: '',
392
- SEO_keyword: '',
393
52
  spec1: '',
394
53
  spec1Value: '',
395
54
  spec2: '',
@@ -412,41 +71,8 @@ export class ShoppingProductSetting {
412
71
  save_stock: '',
413
72
  barcode: '',
414
73
  };
415
- const excel = new Excel(gvc, [
416
- '商品ID',
417
- '商品名稱',
418
- '啟用狀態',
419
- '商品類別',
420
- '商品類型',
421
- '商品圖片',
422
- 'SEO標題',
423
- 'SEO內文',
424
- 'SEO關鍵字',
425
- '規格1',
426
- '規格詳細',
427
- '規格2',
428
- '規格詳細',
429
- '規格3',
430
- '規格詳細',
431
- 'sku',
432
- '成本',
433
- '售價',
434
- '原價',
435
- '利潤',
436
- '運費計算方式',
437
- '長度',
438
- '寬度',
439
- '高度',
440
- '商品重量',
441
- '重量單位',
442
- '庫存政策',
443
- '庫存',
444
- '安全庫存',
445
- '商品條碼',
446
- ], Object.keys(rowInitData));
447
- let dialog = new ShareDialog(glitter);
74
+ const excel = new ProductExcel(gvc, excelHeader.filter((item) => item !== '商品ID'), Object.keys(rowInitData));
448
75
  const ListComp = new BgListComponent(gvc, vm, FilterOptions.productFilterFrame);
449
- gvc.addMtScript([{ src: 'https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.16.9/xlsx.full.min.js' }], () => { }, () => { });
450
76
  vm.filter = ListComp.getFilterObject();
451
77
  return gvc.bindView(() => {
452
78
  return {
@@ -483,7 +109,6 @@ export class ShoppingProductSetting {
483
109
  window.parent.glitter.share.checkData = () => {
484
110
  return true;
485
111
  };
486
- const filterID = gvc.glitter.getUUID();
487
112
  vm.tableId = gvc.glitter.getUUID();
488
113
  vm.dataList = [];
489
114
  const vmlist = {
@@ -544,157 +169,7 @@ export class ShoppingProductSetting {
544
169
  class="cursor_pointer"
545
170
  style="color: #36B; font-size: 14px; font-style: normal; font-weight: 400; line-height: normal; text-decoration-line: underline;"
546
171
  onclick="${gvc.event(() => {
547
- let sample = [
548
- [
549
- '產品1',
550
- '啟用',
551
- '商品',
552
- '精品/手套',
553
- 'image1',
554
- 'SEO標題',
555
- 'SEO內文',
556
- 'SEO關鍵字',
557
- '大小',
558
- 'S',
559
- '形狀',
560
- '長方形',
561
- '顏色',
562
- '白色',
563
- 'product-1-variant-1',
564
- '5000',
565
- '13000',
566
- '12000',
567
- '7000',
568
- '依重量計算',
569
- '10',
570
- '15',
571
- '10',
572
- '7',
573
- 'KG',
574
- '追蹤商品庫存',
575
- '13',
576
- '35',
577
- '001001001',
578
- ],
579
- [
580
- '產品1',
581
- '',
582
- '',
583
- '',
584
- 'image2',
585
- '',
586
- 'S',
587
- '',
588
- '長方形',
589
- '',
590
- '黑色',
591
- 'product-1-variant-2',
592
- '5000',
593
- '13000',
594
- '12000',
595
- '7000',
596
- '依重量計算',
597
- '10',
598
- '15',
599
- '10',
600
- '7',
601
- 'KG',
602
- '追蹤商品庫存',
603
- '13',
604
- '35',
605
- '001001002',
606
- ],
607
- [
608
- '產品1',
609
- '',
610
- '',
611
- '',
612
- 'image3',
613
- '',
614
- 'L',
615
- '',
616
- '正方形',
617
- '',
618
- '黑色',
619
- 'product-1-variant-3',
620
- '4300',
621
- '12000',
622
- '11000',
623
- '7000',
624
- '依重量計算',
625
- '10',
626
- '10',
627
- '10',
628
- '6',
629
- 'KG',
630
- '追蹤商品庫存',
631
- '13',
632
- '35',
633
- '001001003',
634
- ],
635
- [
636
- '產品2',
637
- '啟用',
638
- '商品',
639
- '工具/餐具',
640
- 'image1-1',
641
- 'SEO標題',
642
- 'SEO內文',
643
- 'SEO關鍵字',
644
- '材質',
645
- '木頭',
646
- '形狀',
647
- '長方形',
648
- '',
649
- '',
650
- 'product-2-variant-1',
651
- '700',
652
- '1300',
653
- '1200',
654
- '700',
655
- '依體積計算',
656
- '5',
657
- '5',
658
- '6',
659
- '2',
660
- 'KG',
661
- '不追蹤',
662
- '5',
663
- '35',
664
- '001002001',
665
- ],
666
- [
667
- '產品2',
668
- '',
669
- '',
670
- '工具/',
671
- 'image1-2',
672
- '',
673
- '金屬',
674
- '',
675
- '長方形',
676
- '',
677
- '',
678
- 'product-2-variant-2',
679
- '700',
680
- '1300',
681
- '1200',
682
- '700',
683
- '依體積計算',
684
- '5',
685
- '5',
686
- '6',
687
- '3',
688
- 'KG',
689
- '不追蹤',
690
- '5',
691
- '35',
692
- '001002002',
693
- ],
694
- ];
695
- excel.exportData(sample, '商品詳細列表_範例').then(() => {
696
- dialog.successMessage({ text: '匯出成功' });
697
- });
172
+ excel.exportData(ProductExcel.exampleSheet(), `範例_商品詳細列表_${ProductExcel.getFileTime()}`);
698
173
  })}"
699
174
  >
700
175
  下載範例
@@ -868,111 +343,60 @@ export class ShoppingProductSetting {
868
343
  })();
869
344
  ApiShop.getProduct(getFormData).then((response) => {
870
345
  dialog.dataLoading({ visible: false });
346
+ const expo = new ProductExcel(gvc, excelHeader, Object.keys(rowInitData));
871
347
  let exportData = [];
872
- response.response.data.map((productData) => {
873
- var _a;
874
- let rowData = {
875
- id: '',
876
- name: (_a = productData.content.title) !== null && _a !== void 0 ? _a : '未命名商品',
877
- status: '',
878
- category: '',
879
- productType: ``,
880
- img: '',
881
- SEO_title: '',
882
- SEO_desc: '',
883
- SEO_keyword: '',
884
- spec1: '',
885
- spec1Value: '',
886
- spec2: '',
887
- spec2Value: '',
888
- spec3: '',
889
- spec3Value: '',
890
- sku: '',
891
- cost: '',
892
- sale_price: '',
893
- compare_price: '',
894
- benefit: '',
895
- shipment_type: '',
896
- length: '',
897
- width: '',
898
- height: '',
899
- weight: '',
900
- weightUnit: '',
901
- stockPolicy: '',
902
- stock: '',
903
- save_stock: '',
904
- barcode: '',
348
+ response.response.data.forEach((productData) => {
349
+ const baseRowData = (index) => {
350
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6;
351
+ return ({
352
+ id: index === 0 ? productData.content.id || '' : '',
353
+ name: index === 0 ? productData.content.title || '未命名商品' : '',
354
+ status: index === 0 ? (((_a = productData.content) === null || _a === void 0 ? void 0 : _a.status) === 'active' ? '啟用' : '草稿') : '',
355
+ category: index === 0 ? expo.checkString(productData.content.collection.join(' , ')) : '',
356
+ productType: index === 0 ? expo.checkString(this.getProductTypeString(productData.content)) : '',
357
+ img: index === 0 ? expo.checkString(productData.content.preview_image[0]) : '',
358
+ SEO_domain: index === 0 ? expo.checkString((_c = (_b = productData.content) === null || _b === void 0 ? void 0 : _b.seo) === null || _c === void 0 ? void 0 : _c.domain) : '',
359
+ SEO_title: index === 0 ? expo.checkString((_e = (_d = productData.content) === null || _d === void 0 ? void 0 : _d.seo) === null || _e === void 0 ? void 0 : _e.title) : '',
360
+ SEO_desc: index === 0 ? expo.checkString((_g = (_f = productData.content) === null || _f === void 0 ? void 0 : _f.seo) === null || _g === void 0 ? void 0 : _g.content) : '',
361
+ spec1: index === 0 ? expo.checkString((_j = (_h = productData.content) === null || _h === void 0 ? void 0 : _h.specs[0]) === null || _j === void 0 ? void 0 : _j.title) : '',
362
+ spec1Value: expo.checkString((_k = productData.content.variants[index]) === null || _k === void 0 ? void 0 : _k.spec[0]),
363
+ spec2: index === 0 ? expo.checkString((_m = (_l = productData.content) === null || _l === void 0 ? void 0 : _l.specs[1]) === null || _m === void 0 ? void 0 : _m.title) : '',
364
+ spec2Value: expo.checkString((_o = productData.content.variants[index]) === null || _o === void 0 ? void 0 : _o.spec[1]),
365
+ spec3: index === 0 ? expo.checkString((_q = (_p = productData.content) === null || _p === void 0 ? void 0 : _p.specs[2]) === null || _q === void 0 ? void 0 : _q.title) : '',
366
+ spec3Value: expo.checkString((_r = productData.content.variants[index]) === null || _r === void 0 ? void 0 : _r.spec[2]),
367
+ sku: expo.checkString((_s = productData.content.variants[index]) === null || _s === void 0 ? void 0 : _s.sku),
368
+ cost: expo.checkNumber((_t = productData.content.variants[index]) === null || _t === void 0 ? void 0 : _t.cost),
369
+ sale_price: expo.checkNumber((_u = productData.content.variants[index]) === null || _u === void 0 ? void 0 : _u.sale_price),
370
+ compare_price: expo.checkNumber((_v = productData.content.variants[index]) === null || _v === void 0 ? void 0 : _v.compare_price),
371
+ benefit: expo.checkNumber((_w = productData.content.variants[index]) === null || _w === void 0 ? void 0 : _w.profit),
372
+ shipment_type: getShipmentType((_x = productData.content.variants[index]) === null || _x === void 0 ? void 0 : _x.shipment_type),
373
+ length: expo.checkNumber(((_y = productData.content.variants[index]) === null || _y === void 0 ? void 0 : _y.v_length) || 0),
374
+ width: expo.checkNumber(((_z = productData.content.variants[index]) === null || _z === void 0 ? void 0 : _z.v_width) || 0),
375
+ height: expo.checkNumber(((_0 = productData.content.variants[index]) === null || _0 === void 0 ? void 0 : _0.v_height) || 0),
376
+ weight: expo.checkNumber(((_1 = productData.content.variants[index]) === null || _1 === void 0 ? void 0 : _1.weight) || 0),
377
+ weightUnit: expo.checkString(((_2 = productData.content.variants[index]) === null || _2 === void 0 ? void 0 : _2.weightUnit) || 'KG'),
378
+ stockPolicy: ((_3 = productData.content.variants[index]) === null || _3 === void 0 ? void 0 : _3.show_understocking) === 'true' ? '追蹤' : '不追蹤',
379
+ stock: expo.checkNumber((_4 = productData.content.variants[index]) === null || _4 === void 0 ? void 0 : _4.stock),
380
+ save_stock: expo.checkNumber((_5 = productData.content.variants[index]) === null || _5 === void 0 ? void 0 : _5.save_stock),
381
+ barcode: expo.checkString((_6 = productData.content.variants[index]) === null || _6 === void 0 ? void 0 : _6.barcode),
382
+ });
905
383
  };
906
- productData.content.variants.map((variant, index) => {
907
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19;
908
- if (index == 0) {
909
- rowData.SEO_title = (_c = (_b = (_a = productData.content) === null || _a === void 0 ? void 0 : _a.seo) === null || _b === void 0 ? void 0 : _b.title) !== null && _c !== void 0 ? _c : '';
910
- rowData.SEO_desc = (_f = (_e = (_d = productData.content) === null || _d === void 0 ? void 0 : _d.seo) === null || _e === void 0 ? void 0 : _e.content) !== null && _f !== void 0 ? _f : '';
911
- rowData.SEO_keyword = (_j = (_h = (_g = productData.content) === null || _g === void 0 ? void 0 : _g.seo) === null || _h === void 0 ? void 0 : _h.keyword) !== null && _j !== void 0 ? _j : '';
912
- rowData.category = (_k = productData.content.collection.join(' , ')) !== null && _k !== void 0 ? _k : '';
913
- rowData.productType = `${((_m = (_l = productData.content) === null || _l === void 0 ? void 0 : _l.productType) === null || _m === void 0 ? void 0 : _m.product) ? '商品' : ''} ${((_p = (_o = productData.content) === null || _o === void 0 ? void 0 : _o.productType) === null || _p === void 0 ? void 0 : _p.addProduct) ? '加購品' : ''} ${((_r = (_q = productData.content) === null || _q === void 0 ? void 0 : _q.productType) === null || _r === void 0 ? void 0 : _r.giveaway) ? '贈品' : ''}`;
914
- rowData.status = ((_s = productData.content) === null || _s === void 0 ? void 0 : _s.status) == 'active' ? '上架' : '下架';
915
- rowData.spec1 = (_v = (_u = (_t = productData.content) === null || _t === void 0 ? void 0 : _t.specs[0]) === null || _u === void 0 ? void 0 : _u.title) !== null && _v !== void 0 ? _v : '';
916
- rowData.spec2 = (_y = (_x = (_w = productData.content) === null || _w === void 0 ? void 0 : _w.specs[1]) === null || _x === void 0 ? void 0 : _x.title) !== null && _y !== void 0 ? _y : '';
917
- rowData.spec3 = (_1 = (_0 = (_z = productData.content) === null || _z === void 0 ? void 0 : _z.specs[2]) === null || _0 === void 0 ? void 0 : _0.title) !== null && _1 !== void 0 ? _1 : '';
918
- rowData.img = productData.content.preview_image[0];
919
- }
920
- else {
921
- rowData.category = ``;
922
- rowData.productType = ``;
923
- rowData.status = ``;
924
- rowData.spec1 = '';
925
- rowData.spec2 = '';
926
- rowData.spec3 = '';
927
- rowData.img = '';
928
- rowData.SEO_title = '';
929
- rowData.SEO_desc = '';
930
- rowData.SEO_keyword = '';
931
- }
932
- rowData.img = (_3 = (_2 = rowData.img) !== null && _2 !== void 0 ? _2 : variant.preview_image) !== null && _3 !== void 0 ? _3 : '';
933
- rowData.spec1Value = (_4 = variant.spec[0]) !== null && _4 !== void 0 ? _4 : '';
934
- rowData.spec2Value = (_5 = variant.spec[1]) !== null && _5 !== void 0 ? _5 : '';
935
- rowData.spec3Value = (_6 = variant.spec[2]) !== null && _6 !== void 0 ? _6 : '';
936
- rowData.sku = (_7 = variant.sku) !== null && _7 !== void 0 ? _7 : '';
937
- rowData.cost = (_8 = variant.cost) !== null && _8 !== void 0 ? _8 : '';
938
- rowData.sale_price = (_9 = variant.sale_price) !== null && _9 !== void 0 ? _9 : '';
939
- rowData.benefit = (_10 = variant.profit) !== null && _10 !== void 0 ? _10 : '';
940
- rowData.compare_price = (_11 = variant.compare_price) !== null && _11 !== void 0 ? _11 : '';
941
- rowData.width = (_12 = variant === null || variant === void 0 ? void 0 : variant.v_width) !== null && _12 !== void 0 ? _12 : '0';
942
- rowData.height = (_13 = variant === null || variant === void 0 ? void 0 : variant.v_height) !== null && _13 !== void 0 ? _13 : '0';
943
- rowData.length = (_14 = variant === null || variant === void 0 ? void 0 : variant.v_length) !== null && _14 !== void 0 ? _14 : '0';
944
- rowData.weight = (_15 = variant.weight) !== null && _15 !== void 0 ? _15 : '0';
945
- rowData.weightUnit = (_16 = variant.weightUnit) !== null && _16 !== void 0 ? _16 : 'KG';
946
- rowData.stockPolicy = variant.show_understocking ? '追蹤' : '不追蹤';
947
- rowData.stock = (_17 = variant.stock) !== null && _17 !== void 0 ? _17 : '0';
948
- rowData.save_stock = (_18 = variant.save_stock) !== null && _18 !== void 0 ? _18 : '0';
949
- rowData.barcode = (_19 = variant.barcode) !== null && _19 !== void 0 ? _19 : '';
950
- rowData.id = productData.content.id;
951
- if (variant.shipment_type) {
952
- switch (variant.shipment_type) {
953
- case 'volume': {
954
- rowData.shipment_type = '依材積計算';
955
- break;
956
- }
957
- case 'none': {
958
- rowData.shipment_type = '不計算運費';
959
- break;
960
- }
961
- default: {
962
- rowData.shipment_type = '依重量計算';
963
- }
964
- }
965
- }
966
- else {
967
- rowData.shipment_type = '依重量計算';
384
+ const getShipmentType = (type) => {
385
+ switch (type) {
386
+ case 'volume':
387
+ return '依材積計算';
388
+ case 'none':
389
+ return '不計算運費';
390
+ default:
391
+ return '依重量計算';
968
392
  }
969
- exportData.push(JSON.parse(JSON.stringify(rowData)));
393
+ };
394
+ productData.content.variants.forEach((variant, index) => {
395
+ const rowData = baseRowData(index);
396
+ exportData.push(rowData);
970
397
  });
971
398
  });
972
- ``;
973
- excel.exportData(exportData, `商品詳細列表_${Excel.getFileTime()}`).then(() => {
974
- dialog.successMessage({ text: '匯出成功' });
975
- });
399
+ expo.exportData(exportData, `商品詳細列表_${ProductExcel.getFileTime()}`);
976
400
  });
977
401
  }), '匯出')}
978
402
  </div>
@@ -1127,7 +551,7 @@ export class ShoppingProductSetting {
1127
551
  return {
1128
552
  bind: id,
1129
553
  view: () => {
1130
- BgWidget.switchTextButton(gvc, dd.content.status === 'active', { left: dd.content.status === 'active' ? '上架' : '下架' }, (bool) => {
554
+ BgWidget.switchTextButton(gvc, dd.content.status === 'active', { left: dd.content.status === 'active' ? '啟用' : '草稿' }, (bool) => {
1131
555
  dd.content.status = bool ? 'active' : 'draft';
1132
556
  ApiPost.put({
1133
557
  postData: dd.content,
@@ -1138,8 +562,8 @@ export class ShoppingProductSetting {
1138
562
  });
1139
563
  });
1140
564
  return dd.content.status === 'active'
1141
- ? BgWidget.successInsignia('上架')
1142
- : BgWidget.secondaryInsignia('下架');
565
+ ? BgWidget.successInsignia('啟用')
566
+ : BgWidget.secondaryInsignia('草稿');
1143
567
  },
1144
568
  divCreate: {
1145
569
  option: [
@@ -1174,7 +598,7 @@ export class ShoppingProductSetting {
1174
598
  },
1175
599
  filter: [
1176
600
  {
1177
- name: '上架',
601
+ name: '啟用',
1178
602
  event: (checkedData) => {
1179
603
  const selCount = checkedData.length;
1180
604
  dialog.dataLoading({ visible: true });
@@ -1206,7 +630,7 @@ export class ShoppingProductSetting {
1206
630
  option: true,
1207
631
  },
1208
632
  {
1209
- name: '下架',
633
+ name: '草稿',
1210
634
  event: (checkedData) => {
1211
635
  const selCount = checkedData.length;
1212
636
  dialog.dataLoading({ visible: true });
@@ -1310,6 +734,7 @@ export class ShoppingProductSetting {
1310
734
  divCreate: {
1311
735
  class: `w-100 h-100`,
1312
736
  },
737
+ onCreate: () => { },
1313
738
  };
1314
739
  });
1315
740
  }
@@ -4308,8 +3733,6 @@ ${(_c = postMD.seo.content) !== null && _c !== void 0 ? _c : ''}</textarea
4308
3733
  ShoppingProductSetting.postEvent(postMD, obj.gvc, obj.vm);
4309
3734
  }
4310
3735
  }
4311
- else {
4312
- }
4313
3736
  }, 500);
4314
3737
  }), '儲存', 'guide5-8')}
4315
3738
  </div>`,