ts-glitter 21.6.2 → 21.6.5
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.
- package/lowcode/Entry.js +1 -1
- package/lowcode/Entry.ts +1 -1
- package/lowcode/backend-manager/bg-blog.js +186 -8
- package/lowcode/backend-manager/bg-blog.ts +206 -11
- package/lowcode/backend-manager/bg-widget.js +20 -17
- package/lowcode/backend-manager/bg-widget.ts +23 -19
- package/lowcode/cms-plugin/permission-setting.js +2 -3
- package/lowcode/cms-plugin/permission-setting.ts +2 -3
- package/lowcode/cms-plugin/shopping-discount-setting.js +1711 -341
- package/lowcode/cms-plugin/shopping-discount-setting.ts +1938 -327
- package/lowcode/editor-components/global-widget/bridge.js +30 -0
- package/lowcode/editor-components/global-widget/bridge.ts +131 -2
- package/lowcode/form-view/e-commerce/product-select.js +6 -16
- package/lowcode/form-view/e-commerce/product-select.ts +16 -18
- package/lowcode/glitter-base/global/language.js +2 -0
- package/lowcode/glitter-base/global/language.ts +2 -0
- package/lowcode/glitterBundle/html-component/global-widget.js +0 -74
- package/lowcode/glitterBundle/html-component/global-widget.ts +1 -81
- package/lowcode/official_view_component/official/component.ts +0 -2
- package/lowcode/public-components/checkout/index.js +1 -1
- package/lowcode/public-components/checkout/index.ts +1 -1
- package/lowcode/public-components/user-manager/um-info.js +4 -0
- package/lowcode/public-components/user-manager/um-info.ts +4 -1
- package/lowcode/public-components/user-manager/um-login.js +3 -3
- package/lowcode/public-components/user-manager/um-login.ts +3 -6
- package/lowcode/public-components/user-manager/um-rebate.js +6 -2
- package/lowcode/public-components/user-manager/um-rebate.ts +28 -2
- package/package.json +1 -1
- package/src/api-public/controllers/shop.js +1 -0
- package/src/api-public/controllers/shop.js.map +1 -1
- package/src/api-public/controllers/shop.ts +1 -0
- package/src/api-public/services/data-analyze.d.ts +1 -1
- package/src/api-public/services/rebate.d.ts +14 -2
- package/src/api-public/services/rebate.js +66 -24
- package/src/api-public/services/rebate.js.map +1 -1
- package/src/api-public/services/rebate.ts +91 -24
- package/src/api-public/services/schedule.js +1 -3
- package/src/api-public/services/schedule.js.map +1 -1
- package/src/api-public/services/schedule.ts +1 -1
- package/src/api-public/services/shopping.js +35 -6
- package/src/api-public/services/shopping.js.map +1 -1
- package/src/api-public/services/shopping.ts +45 -12
- package/src/index.js +17 -7
- package/src/index.js.map +1 -1
- package/src/modules/database.js +1 -1
- package/src/modules/database.js.map +1 -1
- package/src/modules/database.ts +1 -1
- package/src/run.js +1 -1
- package/src/run.js.map +1 -1
- package/src/run.ts +1 -1
- package/src/services/system-schedule.js +1 -1
- package/src/services/system-schedule.js.map +1 -1
- package/src/services/system-schedule.ts +3 -2
|
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
+
var _a;
|
|
10
11
|
import { BgWidget } from '../backend-manager/bg-widget.js';
|
|
11
12
|
import { BgProduct } from '../backend-manager/bg-product.js';
|
|
12
13
|
import { ApiShop } from '../glitter-base/route/shopping.js';
|
|
@@ -19,7 +20,7 @@ import { ShipmentConfig } from '../glitter-base/global/shipment-config.js';
|
|
|
19
20
|
const html = String.raw;
|
|
20
21
|
export class ShoppingDiscountSetting {
|
|
21
22
|
static getLabel(voucher_type) {
|
|
22
|
-
var
|
|
23
|
+
var _b;
|
|
23
24
|
const labels = {
|
|
24
25
|
giveaway: '贈品活動',
|
|
25
26
|
add_on_items: '加價購活動',
|
|
@@ -27,7 +28,7 @@ export class ShoppingDiscountSetting {
|
|
|
27
28
|
rebate: '回饋金活動',
|
|
28
29
|
shipment_free: '免運費活動',
|
|
29
30
|
};
|
|
30
|
-
return (
|
|
31
|
+
return (_b = labels[voucher_type]) !== null && _b !== void 0 ? _b : '未知活動';
|
|
31
32
|
}
|
|
32
33
|
static main(gvc, voucher_type) {
|
|
33
34
|
const glitter = gvc.glitter;
|
|
@@ -76,7 +77,7 @@ export class ShoppingDiscountSetting {
|
|
|
76
77
|
};
|
|
77
78
|
function getDatalist() {
|
|
78
79
|
return data.response.data.map((dd) => {
|
|
79
|
-
var
|
|
80
|
+
var _b, _c;
|
|
80
81
|
return [
|
|
81
82
|
{
|
|
82
83
|
key: '標題',
|
|
@@ -93,13 +94,13 @@ export class ShoppingDiscountSetting {
|
|
|
93
94
|
{
|
|
94
95
|
key: '觸發方式',
|
|
95
96
|
value: html `<span class="fs-7">
|
|
96
|
-
${(
|
|
97
|
+
${(_b = triggerLabels[dd.content.trigger]) !== null && _b !== void 0 ? _b : '尚未設定'}
|
|
97
98
|
</span>`,
|
|
98
99
|
},
|
|
99
100
|
{
|
|
100
101
|
key: '套用至',
|
|
101
102
|
value: html `<span class="fs-7"
|
|
102
|
-
>${(
|
|
103
|
+
>${(_c = ShoppingDiscountSetting.productForList.find(item => item.value === dd.content.for)) === null || _c === void 0 ? void 0 : _c.title}</span
|
|
103
104
|
>`,
|
|
104
105
|
},
|
|
105
106
|
{
|
|
@@ -165,7 +166,7 @@ export class ShoppingDiscountSetting {
|
|
|
165
166
|
`);
|
|
166
167
|
}
|
|
167
168
|
else if (vm.type == 'replace') {
|
|
168
|
-
return this.
|
|
169
|
+
return this.voucherEditorV2({
|
|
169
170
|
vm: vm,
|
|
170
171
|
gvc: gvc,
|
|
171
172
|
type: 'replace',
|
|
@@ -173,7 +174,7 @@ export class ShoppingDiscountSetting {
|
|
|
173
174
|
});
|
|
174
175
|
}
|
|
175
176
|
else {
|
|
176
|
-
return this.
|
|
177
|
+
return this.voucherEditorV2({
|
|
177
178
|
vm: vm,
|
|
178
179
|
gvc: gvc,
|
|
179
180
|
type: 'add',
|
|
@@ -184,6 +185,78 @@ export class ShoppingDiscountSetting {
|
|
|
184
185
|
};
|
|
185
186
|
});
|
|
186
187
|
}
|
|
188
|
+
static summaryTextList(voucherData) {
|
|
189
|
+
var _b, _c;
|
|
190
|
+
return [
|
|
191
|
+
`活動標題:${voucherData.title && voucherData.title.length > 0 ? voucherData.title : '尚無標題'}`,
|
|
192
|
+
`適用商品:${(() => {
|
|
193
|
+
const forData = ShoppingDiscountSetting.productForList.find(item => item.value === voucherData.for);
|
|
194
|
+
return forData ? forData.title : '';
|
|
195
|
+
})()}`,
|
|
196
|
+
`活動方式:${(() => {
|
|
197
|
+
var _b;
|
|
198
|
+
if (voucherData.trigger === 'auto')
|
|
199
|
+
return '自動折扣';
|
|
200
|
+
if (voucherData.trigger === 'distribution')
|
|
201
|
+
return '分銷連結';
|
|
202
|
+
if (voucherData.trigger === 'code')
|
|
203
|
+
return `優惠代碼「${(_b = voucherData.code) !== null && _b !== void 0 ? _b : ''}」`;
|
|
204
|
+
return '';
|
|
205
|
+
})()}`,
|
|
206
|
+
`活動對象:${(() => {
|
|
207
|
+
const targetMapping = {
|
|
208
|
+
customer: '特定顧客',
|
|
209
|
+
levels: '會員等級',
|
|
210
|
+
group: '顧客分群',
|
|
211
|
+
all: '所有顧客',
|
|
212
|
+
};
|
|
213
|
+
return targetMapping[voucherData.target] || targetMapping.all;
|
|
214
|
+
})()}`,
|
|
215
|
+
'',
|
|
216
|
+
`消費條件:${(() => {
|
|
217
|
+
if (voucherData.rule === 'min_price')
|
|
218
|
+
return '最少消費金額';
|
|
219
|
+
if (voucherData.rule === 'min_count')
|
|
220
|
+
return '最少購買數量';
|
|
221
|
+
return '';
|
|
222
|
+
})()}`,
|
|
223
|
+
`條件值:${(() => {
|
|
224
|
+
if (voucherData.rule === 'min_price')
|
|
225
|
+
return voucherData.ruleValue + ' 元';
|
|
226
|
+
if (voucherData.rule === 'min_count')
|
|
227
|
+
return voucherData.ruleValue + ' 個';
|
|
228
|
+
return '';
|
|
229
|
+
})()}`,
|
|
230
|
+
`折扣優惠:${(() => {
|
|
231
|
+
const voucherMessages = {
|
|
232
|
+
rebate: (method, value) => method === 'fixed' ? `${value} 點購物金` : `符合條件商品總額的 ${value} %作為購物金`,
|
|
233
|
+
discount: (method, value) => (method === 'fixed' ? `折扣 ${value} 元` : `符合條件商品折扣 ${value} %`),
|
|
234
|
+
shipment_free: () => '免運費',
|
|
235
|
+
};
|
|
236
|
+
const messageFunction = voucherMessages[voucherData.reBackType];
|
|
237
|
+
return messageFunction ? messageFunction(voucherData.method, voucherData.value) : '';
|
|
238
|
+
})()}`,
|
|
239
|
+
`將此優惠套用至:${(() => {
|
|
240
|
+
var _b, _c;
|
|
241
|
+
const length = (_c = (_b = voucherData.forKey) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
|
|
242
|
+
const forMaps = {
|
|
243
|
+
collection: `指定 ${length} 種商品分類`,
|
|
244
|
+
product: `指定 ${length} 個商品`,
|
|
245
|
+
all: '所有商品',
|
|
246
|
+
};
|
|
247
|
+
return forMaps[voucherData.for] || forMaps.all;
|
|
248
|
+
})()}`,
|
|
249
|
+
'',
|
|
250
|
+
voucherData.overlay ? '可以疊加,套用最大優惠' : '不可疊加',
|
|
251
|
+
`啟用時間:${(_b = voucherData.startDate) !== null && _b !== void 0 ? _b : '未設定日期'} ${(_c = voucherData.startTime) !== null && _c !== void 0 ? _c : '尚未設定時間'}`,
|
|
252
|
+
`結束時間:${(() => {
|
|
253
|
+
var _b, _c;
|
|
254
|
+
if (!voucherData.endDate)
|
|
255
|
+
return '無期限';
|
|
256
|
+
return `${(_b = voucherData.endDate) !== null && _b !== void 0 ? _b : '未設定日期'} ${(_c = voucherData.endTime) !== null && _c !== void 0 ? _c : '尚未設定時間'}`;
|
|
257
|
+
})()}`,
|
|
258
|
+
];
|
|
259
|
+
}
|
|
187
260
|
static voucherEditor(obj) {
|
|
188
261
|
const gvc = obj.gvc;
|
|
189
262
|
const glitter = gvc.glitter;
|
|
@@ -197,7 +270,7 @@ export class ShoppingDiscountSetting {
|
|
|
197
270
|
};
|
|
198
271
|
const voucherData = Object.assign({ title: '', code: '', trigger: 'auto', method: 'fixed', value: '0', for: 'all', forKey: [], device: ['normal'], rule: 'min_price', ruleValue: 1000, startDate: this.getDateTime().date, startTime: this.getDateTime().time, endDate: undefined, endTime: undefined, status: 1, type: 'voucher', overlay: false, start_ISO_Date: '', end_ISO_Date: '', reBackType: obj.reBackType, rebateEndDay: '30', target: 'all', targetList: [], macroLimited: 0, microLimited: 0, counting: 'single', conditionType: 'order', includeDiscount: 'before', productOffStart: 'price_desc', selectShipment: { type: 'all', list: [] } }, vm.data);
|
|
199
272
|
function summaryTextList() {
|
|
200
|
-
var
|
|
273
|
+
var _b, _c;
|
|
201
274
|
return [
|
|
202
275
|
`活動標題:${voucherData.title && voucherData.title.length > 0 ? voucherData.title : '尚無標題'}`,
|
|
203
276
|
`適用商品:${(() => {
|
|
@@ -205,13 +278,13 @@ export class ShoppingDiscountSetting {
|
|
|
205
278
|
return forData ? forData.title : '';
|
|
206
279
|
})()}`,
|
|
207
280
|
`活動方式:${(() => {
|
|
208
|
-
var
|
|
281
|
+
var _b;
|
|
209
282
|
if (voucherData.trigger === 'auto')
|
|
210
283
|
return '自動折扣';
|
|
211
284
|
if (voucherData.trigger === 'distribution')
|
|
212
285
|
return '分銷連結';
|
|
213
286
|
if (voucherData.trigger === 'code')
|
|
214
|
-
return `優惠代碼「${(
|
|
287
|
+
return `優惠代碼「${(_b = voucherData.code) !== null && _b !== void 0 ? _b : ''}」`;
|
|
215
288
|
return '';
|
|
216
289
|
})()}`,
|
|
217
290
|
`活動對象:${(() => {
|
|
@@ -248,8 +321,8 @@ export class ShoppingDiscountSetting {
|
|
|
248
321
|
return messageFunction ? messageFunction(voucherData.method, voucherData.value) : '';
|
|
249
322
|
})()}`,
|
|
250
323
|
`將此優惠套用至:${(() => {
|
|
251
|
-
var
|
|
252
|
-
const length = (
|
|
324
|
+
var _b, _c;
|
|
325
|
+
const length = (_c = (_b = voucherData.forKey) === null || _b === void 0 ? void 0 : _b.length) !== null && _c !== void 0 ? _c : 0;
|
|
253
326
|
const forMaps = {
|
|
254
327
|
collection: `指定 ${length} 種商品分類`,
|
|
255
328
|
product: `指定 ${length} 個商品`,
|
|
@@ -259,12 +332,12 @@ export class ShoppingDiscountSetting {
|
|
|
259
332
|
})()}`,
|
|
260
333
|
'',
|
|
261
334
|
voucherData.overlay ? '可以疊加,套用最大優惠' : '不可疊加',
|
|
262
|
-
`啟用時間:${(
|
|
335
|
+
`啟用時間:${(_b = voucherData.startDate) !== null && _b !== void 0 ? _b : '未設定日期'} ${(_c = voucherData.startTime) !== null && _c !== void 0 ? _c : '尚未設定時間'}`,
|
|
263
336
|
`結束時間:${(() => {
|
|
264
|
-
var
|
|
337
|
+
var _b, _c;
|
|
265
338
|
if (!voucherData.endDate)
|
|
266
339
|
return '無期限';
|
|
267
|
-
return `${(
|
|
340
|
+
return `${(_b = voucherData.endDate) !== null && _b !== void 0 ? _b : '未設定日期'} ${(_c = voucherData.endTime) !== null && _c !== void 0 ? _c : '尚未設定時間'}`;
|
|
268
341
|
})()}`,
|
|
269
342
|
];
|
|
270
343
|
}
|
|
@@ -309,13 +382,13 @@ export class ShoppingDiscountSetting {
|
|
|
309
382
|
return gvc.bindView({
|
|
310
383
|
bind: id,
|
|
311
384
|
view: () => {
|
|
312
|
-
var
|
|
385
|
+
var _b;
|
|
313
386
|
return gvc.map([
|
|
314
387
|
BgWidget.grayNote('顧客可在結帳時輸入優惠代碼,來獲得折扣'),
|
|
315
388
|
BgWidget.editeInput({
|
|
316
389
|
gvc: gvc,
|
|
317
390
|
title: '',
|
|
318
|
-
default: (
|
|
391
|
+
default: (_b = voucherData.code) !== null && _b !== void 0 ? _b : '',
|
|
319
392
|
placeHolder: '請輸入優惠券代碼',
|
|
320
393
|
callback: text => {
|
|
321
394
|
voucherData.code = text.toUpperCase();
|
|
@@ -356,7 +429,7 @@ export class ShoppingDiscountSetting {
|
|
|
356
429
|
return {
|
|
357
430
|
bind: id,
|
|
358
431
|
view: () => {
|
|
359
|
-
var
|
|
432
|
+
var _b;
|
|
360
433
|
return html `
|
|
361
434
|
<div style="display: flex; flex-direction: column; gap: 8px;">
|
|
362
435
|
${BgWidget.selectFilter({
|
|
@@ -365,7 +438,7 @@ export class ShoppingDiscountSetting {
|
|
|
365
438
|
voucherData.target = text;
|
|
366
439
|
gvc.notifyDataChange(id);
|
|
367
440
|
},
|
|
368
|
-
default: (
|
|
441
|
+
default: (_b = voucherData.target) !== null && _b !== void 0 ? _b : 'all',
|
|
369
442
|
options: [
|
|
370
443
|
{
|
|
371
444
|
key: 'all',
|
|
@@ -410,7 +483,7 @@ export class ShoppingDiscountSetting {
|
|
|
410
483
|
<div class="tx_normal">顧客名稱</div>
|
|
411
484
|
</div>
|
|
412
485
|
${BgWidget.grayButton('查看全部', gvc.event(() => {
|
|
413
|
-
var
|
|
486
|
+
var _b;
|
|
414
487
|
BgWidget.selectDropDialog({
|
|
415
488
|
gvc: gvc,
|
|
416
489
|
title: '搜尋特定顧客',
|
|
@@ -421,7 +494,7 @@ export class ShoppingDiscountSetting {
|
|
|
421
494
|
customVM.loading = true;
|
|
422
495
|
gvc.notifyDataChange(customVM.id);
|
|
423
496
|
},
|
|
424
|
-
default: ((
|
|
497
|
+
default: ((_b = voucherData.targetList) !== null && _b !== void 0 ? _b : []).map(id => id.toString()),
|
|
425
498
|
api: (data) => {
|
|
426
499
|
return new Promise(resolve => {
|
|
427
500
|
ApiUser.getUserListOrders({
|
|
@@ -433,10 +506,10 @@ export class ShoppingDiscountSetting {
|
|
|
433
506
|
}).then(dd => {
|
|
434
507
|
if (dd.response.data) {
|
|
435
508
|
resolve(dd.response.data.map((item) => {
|
|
436
|
-
var
|
|
509
|
+
var _b;
|
|
437
510
|
return {
|
|
438
511
|
key: item.userID,
|
|
439
|
-
value: (
|
|
512
|
+
value: (_b = item.userData.name) !== null && _b !== void 0 ? _b : '(尚無姓名)',
|
|
440
513
|
note: item.userData.email,
|
|
441
514
|
};
|
|
442
515
|
}));
|
|
@@ -500,7 +573,7 @@ export class ShoppingDiscountSetting {
|
|
|
500
573
|
return gvc.bindView({
|
|
501
574
|
bind: levelVM.id,
|
|
502
575
|
view: () => {
|
|
503
|
-
var
|
|
576
|
+
var _b;
|
|
504
577
|
if (levelVM.loading) {
|
|
505
578
|
return BgWidget.spinner({ text: { visible: false } });
|
|
506
579
|
}
|
|
@@ -511,7 +584,7 @@ export class ShoppingDiscountSetting {
|
|
|
511
584
|
voucherData.targetList = value;
|
|
512
585
|
gvc.notifyDataChange(id);
|
|
513
586
|
},
|
|
514
|
-
default: ((
|
|
587
|
+
default: ((_b = voucherData.targetList) !== null && _b !== void 0 ? _b : []).map(id => id.toString()),
|
|
515
588
|
options: levelVM.dataList,
|
|
516
589
|
style: 'width: 100%;',
|
|
517
590
|
});
|
|
@@ -548,7 +621,7 @@ export class ShoppingDiscountSetting {
|
|
|
548
621
|
return gvc.bindView({
|
|
549
622
|
bind: levelVM.id,
|
|
550
623
|
view: () => {
|
|
551
|
-
var
|
|
624
|
+
var _b;
|
|
552
625
|
if (levelVM.loading) {
|
|
553
626
|
return BgWidget.spinner({ text: { visible: false } });
|
|
554
627
|
}
|
|
@@ -559,7 +632,7 @@ export class ShoppingDiscountSetting {
|
|
|
559
632
|
voucherData.targetList = value;
|
|
560
633
|
gvc.notifyDataChange(id);
|
|
561
634
|
},
|
|
562
|
-
default: ((
|
|
635
|
+
default: ((_b = voucherData.targetList) !== null && _b !== void 0 ? _b : []).map(id => id.toString()),
|
|
563
636
|
options: levelVM.dataList,
|
|
564
637
|
style: 'width: 100%;',
|
|
565
638
|
});
|
|
@@ -602,13 +675,13 @@ export class ShoppingDiscountSetting {
|
|
|
602
675
|
})}`;
|
|
603
676
|
}
|
|
604
677
|
function device() {
|
|
605
|
-
var
|
|
678
|
+
var _b;
|
|
606
679
|
return html ` <div class="tx_700">可使用訂單來源</div>
|
|
607
680
|
${BgWidget.mbContainer(18)}
|
|
608
681
|
${BgWidget.multiCheckboxContainer(gvc, [
|
|
609
682
|
{ key: 'normal', name: 'APP & 官網' },
|
|
610
683
|
{ key: 'pos', name: 'POS' },
|
|
611
|
-
], (
|
|
684
|
+
], (_b = voucherData.device) !== null && _b !== void 0 ? _b : ['normal'], text => {
|
|
612
685
|
voucherData.device = text;
|
|
613
686
|
gvc.notifyDataChange(pageVM.viewID);
|
|
614
687
|
}, { single: false })}`;
|
|
@@ -618,7 +691,7 @@ export class ShoppingDiscountSetting {
|
|
|
618
691
|
return gvc.bindView({
|
|
619
692
|
bind: id,
|
|
620
693
|
view: () => {
|
|
621
|
-
var
|
|
694
|
+
var _b;
|
|
622
695
|
return html ` <div class="tx_700">可使用物流</div>
|
|
623
696
|
${BgWidget.mbContainer(18)}
|
|
624
697
|
${[
|
|
@@ -641,7 +714,7 @@ export class ShoppingDiscountSetting {
|
|
|
641
714
|
callback: value => {
|
|
642
715
|
voucherData.selectShipment.list = value;
|
|
643
716
|
},
|
|
644
|
-
default: (
|
|
717
|
+
default: (_b = voucherData.selectShipment.list) !== null && _b !== void 0 ? _b : [],
|
|
645
718
|
options: ShipmentConfig.list.map(item => {
|
|
646
719
|
return {
|
|
647
720
|
key: item.value,
|
|
@@ -685,10 +758,10 @@ export class ShoppingDiscountSetting {
|
|
|
685
758
|
<div class="tx_normal">商品列表</div>
|
|
686
759
|
</div>
|
|
687
760
|
${BgWidget.grayButton('選擇商品', gvc.event(() => {
|
|
688
|
-
var
|
|
761
|
+
var _b;
|
|
689
762
|
BgProduct.productsDialog({
|
|
690
763
|
gvc: gvc,
|
|
691
|
-
default: (
|
|
764
|
+
default: (_b = voucherData.add_on_products) !== null && _b !== void 0 ? _b : [],
|
|
692
765
|
callback: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
693
766
|
voucherData.add_on_products = value;
|
|
694
767
|
gvc.notifyDataChange(id);
|
|
@@ -780,312 +853,320 @@ export class ShoppingDiscountSetting {
|
|
|
780
853
|
.filter(Boolean)
|
|
781
854
|
.map(str => html `<div>${str}</div>`)
|
|
782
855
|
.join(BgWidget.horizontalLine())),
|
|
783
|
-
...(['shipment_free', 'add_on_items', 'giveaway'].includes(voucherData.reBackType)
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
856
|
+
...(['shipment_free', 'add_on_items', 'giveaway'].includes(voucherData.reBackType)
|
|
857
|
+
? []
|
|
858
|
+
: [
|
|
859
|
+
BgWidget.mainCard(gvc.bindView(() => {
|
|
860
|
+
var _b;
|
|
861
|
+
const id = glitter.getUUID();
|
|
862
|
+
const originForType = String(voucherData.for);
|
|
863
|
+
voucherData.forKey = (_b = voucherData.forKey) !== null && _b !== void 0 ? _b : [];
|
|
864
|
+
let defKeys = {
|
|
865
|
+
collection: JSON.parse(JSON.stringify(voucherData.forKey)),
|
|
866
|
+
product: JSON.parse(JSON.stringify(voucherData.forKey)),
|
|
867
|
+
manager_tag: JSON.parse(JSON.stringify(voucherData.forKey)),
|
|
868
|
+
};
|
|
869
|
+
return {
|
|
870
|
+
bind: id,
|
|
871
|
+
dataList: [
|
|
872
|
+
{ obj: voucherData, key: 'method' },
|
|
873
|
+
{ obj: voucherData, key: 'reBackType' },
|
|
874
|
+
],
|
|
875
|
+
view: () => {
|
|
876
|
+
return [
|
|
877
|
+
...(() => {
|
|
878
|
+
if (['shipment_free', 'add_on_items', 'giveaway'].includes(voucherData.reBackType)) {
|
|
879
|
+
return [];
|
|
880
|
+
}
|
|
881
|
+
const valueInput = (obj) => {
|
|
882
|
+
return BgWidget.editeInput({
|
|
883
|
+
gvc: gvc,
|
|
884
|
+
type: 'number',
|
|
885
|
+
divStyle: 'width:150px;',
|
|
886
|
+
title: '',
|
|
887
|
+
default: voucherData.value,
|
|
888
|
+
placeHolder: '',
|
|
889
|
+
callback: text => {
|
|
890
|
+
const texInt = parseInt(text, 10);
|
|
891
|
+
if (voucherData.method === 'percent' && (texInt > 100 || texInt < 0)) {
|
|
892
|
+
dialog.infoMessage({ text: '數值需介於0~100' });
|
|
893
|
+
gvc.notifyDataChange(id);
|
|
894
|
+
gvc.notifyDataChange(pageVM.countingID);
|
|
895
|
+
}
|
|
896
|
+
else {
|
|
897
|
+
voucherData.value = text;
|
|
898
|
+
}
|
|
899
|
+
},
|
|
900
|
+
startText: obj.startText,
|
|
901
|
+
endText: obj.endText,
|
|
902
|
+
});
|
|
903
|
+
};
|
|
904
|
+
return [
|
|
905
|
+
html ` <div>
|
|
906
|
+
<div class="tx_700">折扣金額</div>
|
|
907
|
+
${BgWidget.mbContainer(18)}
|
|
908
|
+
${BgWidget.multiCheckboxContainer(gvc, [
|
|
909
|
+
{
|
|
910
|
+
key: 'fixed',
|
|
911
|
+
name: '固定金額',
|
|
912
|
+
innerHtml: valueInput({ startText: '$' }),
|
|
913
|
+
},
|
|
914
|
+
{
|
|
915
|
+
key: 'percent',
|
|
916
|
+
name: '百分比',
|
|
917
|
+
innerHtml: valueInput({ endText: '%' }),
|
|
918
|
+
},
|
|
919
|
+
], [voucherData.method], text => {
|
|
920
|
+
voucherData.value = '0';
|
|
921
|
+
voucherData.method = text[0];
|
|
922
|
+
gvc.notifyDataChange(pageVM.conditionID);
|
|
923
|
+
}, { single: true })}
|
|
924
|
+
</div>`,
|
|
925
|
+
];
|
|
926
|
+
})(),
|
|
927
|
+
...(() => {
|
|
928
|
+
var _b;
|
|
929
|
+
if (voucherData.trigger === 'distribution') {
|
|
930
|
+
return [];
|
|
931
|
+
}
|
|
932
|
+
return [
|
|
933
|
+
html `
|
|
934
|
+
<div class="tx_700">套用至</div>
|
|
935
|
+
${BgWidget.mbContainer(18)}
|
|
936
|
+
${EditorElem.radio({
|
|
937
|
+
gvc: gvc,
|
|
938
|
+
title: '',
|
|
939
|
+
def: (_b = voucherData.for) !== null && _b !== void 0 ? _b : 'all',
|
|
940
|
+
array: ShoppingDiscountSetting.productForList,
|
|
941
|
+
callback: text => {
|
|
942
|
+
voucherData.forKey = defKeys[text];
|
|
943
|
+
voucherData.for = text;
|
|
818
944
|
gvc.notifyDataChange(id);
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
return [
|
|
858
|
-
html `
|
|
859
|
-
<div class="tx_700">套用至</div>
|
|
860
|
-
${BgWidget.mbContainer(18)}
|
|
861
|
-
${EditorElem.radio({
|
|
862
|
-
gvc: gvc,
|
|
863
|
-
title: '',
|
|
864
|
-
def: (_a = voucherData.for) !== null && _a !== void 0 ? _a : 'all',
|
|
865
|
-
array: ShoppingDiscountSetting.productForList,
|
|
866
|
-
callback: text => {
|
|
867
|
-
voucherData.forKey = defKeys[text];
|
|
868
|
-
voucherData.for = text;
|
|
869
|
-
gvc.notifyDataChange(id);
|
|
870
|
-
},
|
|
871
|
-
oneLine: true,
|
|
872
|
-
})}
|
|
873
|
-
${BgWidget.mbContainer(8)}
|
|
874
|
-
${(() => {
|
|
875
|
-
switch (voucherData.for) {
|
|
876
|
-
case 'manager_tag':
|
|
877
|
-
return gvc.bindView(() => {
|
|
878
|
-
const subVM = {
|
|
879
|
-
id: gvc.glitter.getUUID(),
|
|
880
|
-
dataList: originForType === 'manager_tag' ? [...defKeys.manager_tag] : [],
|
|
881
|
-
};
|
|
882
|
-
return {
|
|
883
|
-
bind: subVM.id,
|
|
884
|
-
view: () => {
|
|
885
|
-
return html `
|
|
886
|
-
<div class="d-flex flex-column p-2" style="gap: 18px;">
|
|
887
|
-
<div
|
|
888
|
-
class="d-flex align-items-center gray-bottom-line-18"
|
|
889
|
-
style="gap: 24px; justify-content: space-between;"
|
|
890
|
-
>
|
|
891
|
-
<div class="form-check-label c_updown_label">
|
|
892
|
-
<div class="tx_normal">標籤列表</div>
|
|
893
|
-
</div>
|
|
894
|
-
${BgWidget.grayButton('選擇標籤', gvc.event(() => {
|
|
895
|
-
BgProduct.useProductTags({
|
|
896
|
-
gvc,
|
|
897
|
-
config_key: 'product_manager_tags',
|
|
898
|
-
def: originForType === 'manager_tag' && voucherData.forKey
|
|
899
|
-
? voucherData.forKey.map(item => `${item}`)
|
|
900
|
-
: [],
|
|
901
|
-
callback: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
902
|
-
voucherData.forKey = value;
|
|
903
|
-
defKeys.manager_tag = value;
|
|
904
|
-
subVM.dataList = value;
|
|
905
|
-
gvc.notifyDataChange(subVM.id);
|
|
906
|
-
}),
|
|
907
|
-
});
|
|
908
|
-
}), { textStyle: 'font-weight: 400;' })}
|
|
909
|
-
</div>
|
|
910
|
-
${obj.gvc.map(subVM.dataList.map((opt, index) => {
|
|
911
|
-
return html ` <div
|
|
912
|
-
class="d-flex align-items-center form-check-label c_updown_label gap-3"
|
|
913
|
-
>
|
|
914
|
-
<span class="tx_normal">${index + 1}. #${opt}</span>
|
|
915
|
-
</div>`;
|
|
916
|
-
}))}
|
|
917
|
-
</div>
|
|
918
|
-
`;
|
|
919
|
-
},
|
|
920
|
-
};
|
|
921
|
-
});
|
|
922
|
-
case 'collection':
|
|
923
|
-
return gvc.bindView(() => {
|
|
924
|
-
const subVM = {
|
|
925
|
-
id: gvc.glitter.getUUID(),
|
|
926
|
-
loading: true,
|
|
927
|
-
dataList: [],
|
|
928
|
-
};
|
|
929
|
-
return {
|
|
930
|
-
bind: subVM.id,
|
|
931
|
-
view: () => {
|
|
932
|
-
if (subVM.loading) {
|
|
933
|
-
return BgWidget.spinner();
|
|
934
|
-
}
|
|
935
|
-
return html `
|
|
936
|
-
<div class="d-flex flex-column p-2" style="gap: 18px;">
|
|
937
|
-
<div
|
|
938
|
-
class="d-flex align-items-center gray-bottom-line-18"
|
|
939
|
-
style="gap: 24px; justify-content: space-between;"
|
|
940
|
-
>
|
|
941
|
-
<div class="form-check-label c_updown_label">
|
|
942
|
-
<div class="tx_normal">分類列表</div>
|
|
943
|
-
</div>
|
|
944
|
-
${BgWidget.grayButton('選擇分類', gvc.event(() => {
|
|
945
|
-
var _a;
|
|
946
|
-
BgProduct.collectionsDialog({
|
|
947
|
-
gvc: gvc,
|
|
948
|
-
default: (_a = voucherData.forKey) !== null && _a !== void 0 ? _a : [],
|
|
949
|
-
callback: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
950
|
-
voucherData.forKey = value;
|
|
951
|
-
defKeys.collection = value;
|
|
952
|
-
subVM.dataList = yield BgProduct.getCollectiosOpts(value);
|
|
953
|
-
subVM.loading = true;
|
|
954
|
-
gvc.notifyDataChange(subVM.id);
|
|
955
|
-
}),
|
|
956
|
-
});
|
|
957
|
-
}), { textStyle: 'font-weight: 400;' })}
|
|
958
|
-
</div>
|
|
959
|
-
${obj.gvc.map(subVM.dataList.map((opt, index) => {
|
|
960
|
-
return html ` <div
|
|
961
|
-
class="d-flex align-items-center form-check-label c_updown_label gap-3"
|
|
962
|
-
>
|
|
963
|
-
<span class="tx_normal">${index + 1}. ${opt.value}</span>
|
|
964
|
-
${opt.note
|
|
965
|
-
? html ` <span class="tx_gray_12 ms-2">${opt.note}</span> `
|
|
966
|
-
: ''}
|
|
967
|
-
</div>`;
|
|
968
|
-
}))}
|
|
969
|
-
</div>
|
|
970
|
-
`;
|
|
971
|
-
},
|
|
972
|
-
onCreate: () => {
|
|
973
|
-
if (subVM.loading) {
|
|
974
|
-
if (voucherData.forKey.length === 0) {
|
|
975
|
-
setTimeout(() => {
|
|
976
|
-
subVM.dataList = [];
|
|
977
|
-
subVM.loading = false;
|
|
978
|
-
gvc.notifyDataChange(subVM.id);
|
|
979
|
-
}, 200);
|
|
980
|
-
}
|
|
981
|
-
else {
|
|
982
|
-
new Promise(resolve => {
|
|
983
|
-
resolve(BgProduct.getCollectiosOpts(voucherData.forKey));
|
|
984
|
-
}).then(data => {
|
|
985
|
-
subVM.dataList = data;
|
|
986
|
-
subVM.loading = false;
|
|
987
|
-
gvc.notifyDataChange(subVM.id);
|
|
945
|
+
},
|
|
946
|
+
oneLine: true,
|
|
947
|
+
})}
|
|
948
|
+
${BgWidget.mbContainer(8)}
|
|
949
|
+
${(() => {
|
|
950
|
+
switch (voucherData.for) {
|
|
951
|
+
case 'manager_tag':
|
|
952
|
+
return gvc.bindView(() => {
|
|
953
|
+
const subVM = {
|
|
954
|
+
id: gvc.glitter.getUUID(),
|
|
955
|
+
dataList: originForType === 'manager_tag' ? [...defKeys.manager_tag] : [],
|
|
956
|
+
};
|
|
957
|
+
return {
|
|
958
|
+
bind: subVM.id,
|
|
959
|
+
view: () => {
|
|
960
|
+
return html `
|
|
961
|
+
<div class="d-flex flex-column p-2" style="gap: 18px;">
|
|
962
|
+
<div
|
|
963
|
+
class="d-flex align-items-center gray-bottom-line-18"
|
|
964
|
+
style="gap: 24px; justify-content: space-between;"
|
|
965
|
+
>
|
|
966
|
+
<div class="form-check-label c_updown_label">
|
|
967
|
+
<div class="tx_normal">標籤列表</div>
|
|
968
|
+
</div>
|
|
969
|
+
${BgWidget.grayButton('選擇標籤', gvc.event(() => {
|
|
970
|
+
BgProduct.useProductTags({
|
|
971
|
+
gvc,
|
|
972
|
+
config_key: 'product_manager_tags',
|
|
973
|
+
def: originForType === 'manager_tag' &&
|
|
974
|
+
voucherData.forKey
|
|
975
|
+
? voucherData.forKey.map(item => `${item}`)
|
|
976
|
+
: [],
|
|
977
|
+
callback: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
978
|
+
voucherData.forKey = value;
|
|
979
|
+
defKeys.manager_tag = value;
|
|
980
|
+
subVM.dataList = value;
|
|
981
|
+
gvc.notifyDataChange(subVM.id);
|
|
982
|
+
}),
|
|
988
983
|
});
|
|
984
|
+
}), { textStyle: 'font-weight: 400;' })}
|
|
985
|
+
</div>
|
|
986
|
+
${obj.gvc.map(subVM.dataList.map((opt, index) => {
|
|
987
|
+
return html ` <div
|
|
988
|
+
class="d-flex align-items-center form-check-label c_updown_label gap-3"
|
|
989
|
+
>
|
|
990
|
+
<span class="tx_normal">${index + 1}. #${opt}</span>
|
|
991
|
+
</div>`;
|
|
992
|
+
}))}
|
|
993
|
+
</div>
|
|
994
|
+
`;
|
|
995
|
+
},
|
|
996
|
+
};
|
|
997
|
+
});
|
|
998
|
+
case 'collection':
|
|
999
|
+
return gvc.bindView(() => {
|
|
1000
|
+
const subVM = {
|
|
1001
|
+
id: gvc.glitter.getUUID(),
|
|
1002
|
+
loading: true,
|
|
1003
|
+
dataList: [],
|
|
1004
|
+
};
|
|
1005
|
+
return {
|
|
1006
|
+
bind: subVM.id,
|
|
1007
|
+
view: () => {
|
|
1008
|
+
if (subVM.loading) {
|
|
1009
|
+
return BgWidget.spinner();
|
|
989
1010
|
}
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
<div class="tx_normal">商品列表</div>
|
|
1015
|
-
</div>
|
|
1016
|
-
${BgWidget.grayButton('選擇商品', gvc.event(() => {
|
|
1017
|
-
var _a;
|
|
1018
|
-
BgProduct.productsDialog({
|
|
1019
|
-
gvc: gvc,
|
|
1020
|
-
default: (_a = voucherData.forKey) !== null && _a !== void 0 ? _a : [],
|
|
1021
|
-
callback: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
1022
|
-
voucherData.forKey = value;
|
|
1023
|
-
defKeys.product = value;
|
|
1024
|
-
subVM.dataList = yield BgProduct.getProductOpts(voucherData.forKey);
|
|
1025
|
-
subVM.loading = true;
|
|
1026
|
-
gvc.notifyDataChange(subVM.id);
|
|
1027
|
-
}),
|
|
1028
|
-
});
|
|
1029
|
-
}), { textStyle: 'font-weight: 400;' })}
|
|
1030
|
-
</div>
|
|
1031
|
-
${subVM.dataList
|
|
1032
|
-
.map((opt, index) => {
|
|
1033
|
-
return html ` <div
|
|
1034
|
-
class="d-flex align-items-center form-check-label c_updown_label gap-3"
|
|
1035
|
-
>
|
|
1036
|
-
<span class="tx_normal">${index + 1}.</span>
|
|
1037
|
-
${BgWidget.validImageBox({
|
|
1038
|
-
gvc: gvc,
|
|
1039
|
-
image: opt.image,
|
|
1040
|
-
width: 40,
|
|
1041
|
-
})}
|
|
1042
|
-
<div class="tx_normal ${opt.note ? 'mb-1' : ''}">
|
|
1043
|
-
${opt.value}
|
|
1011
|
+
return html `
|
|
1012
|
+
<div class="d-flex flex-column p-2" style="gap: 18px;">
|
|
1013
|
+
<div
|
|
1014
|
+
class="d-flex align-items-center gray-bottom-line-18"
|
|
1015
|
+
style="gap: 24px; justify-content: space-between;"
|
|
1016
|
+
>
|
|
1017
|
+
<div class="form-check-label c_updown_label">
|
|
1018
|
+
<div class="tx_normal">分類列表</div>
|
|
1019
|
+
</div>
|
|
1020
|
+
${BgWidget.grayButton('選擇分類', gvc.event(() => {
|
|
1021
|
+
var _b;
|
|
1022
|
+
BgProduct.collectionsDialog({
|
|
1023
|
+
gvc: gvc,
|
|
1024
|
+
default: (_b = voucherData.forKey) !== null && _b !== void 0 ? _b : [],
|
|
1025
|
+
callback: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
1026
|
+
voucherData.forKey = value;
|
|
1027
|
+
defKeys.collection = value;
|
|
1028
|
+
subVM.dataList =
|
|
1029
|
+
yield BgProduct.getCollectiosOpts(value);
|
|
1030
|
+
subVM.loading = true;
|
|
1031
|
+
gvc.notifyDataChange(subVM.id);
|
|
1032
|
+
}),
|
|
1033
|
+
});
|
|
1034
|
+
}), { textStyle: 'font-weight: 400;' })}
|
|
1044
1035
|
</div>
|
|
1045
|
-
${opt
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1036
|
+
${obj.gvc.map(subVM.dataList.map((opt, index) => {
|
|
1037
|
+
return html ` <div
|
|
1038
|
+
class="d-flex align-items-center form-check-label c_updown_label gap-3"
|
|
1039
|
+
>
|
|
1040
|
+
<span class="tx_normal"
|
|
1041
|
+
>${index + 1}. ${opt.value}</span
|
|
1042
|
+
>
|
|
1043
|
+
${opt.note
|
|
1044
|
+
? html `
|
|
1045
|
+
<span class="tx_gray_12 ms-2">${opt.note}</span>
|
|
1046
|
+
`
|
|
1047
|
+
: ''}
|
|
1048
|
+
</div>`;
|
|
1049
|
+
}))}
|
|
1050
|
+
</div>
|
|
1051
|
+
`;
|
|
1052
|
+
},
|
|
1053
|
+
onCreate: () => {
|
|
1054
|
+
if (subVM.loading) {
|
|
1055
|
+
if (voucherData.forKey.length === 0) {
|
|
1056
|
+
setTimeout(() => {
|
|
1057
|
+
subVM.dataList = [];
|
|
1058
|
+
subVM.loading = false;
|
|
1059
|
+
gvc.notifyDataChange(subVM.id);
|
|
1060
|
+
}, 200);
|
|
1061
|
+
}
|
|
1062
|
+
else {
|
|
1063
|
+
new Promise(resolve => {
|
|
1064
|
+
resolve(BgProduct.getCollectiosOpts(voucherData.forKey));
|
|
1065
|
+
}).then(data => {
|
|
1066
|
+
subVM.dataList = data;
|
|
1067
|
+
subVM.loading = false;
|
|
1068
|
+
gvc.notifyDataChange(subVM.id);
|
|
1069
|
+
});
|
|
1070
|
+
}
|
|
1062
1071
|
}
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1072
|
+
},
|
|
1073
|
+
};
|
|
1074
|
+
});
|
|
1075
|
+
case 'product':
|
|
1076
|
+
return gvc.bindView(() => {
|
|
1077
|
+
const subVM = {
|
|
1078
|
+
id: gvc.glitter.getUUID(),
|
|
1079
|
+
loading: true,
|
|
1080
|
+
dataList: [],
|
|
1081
|
+
};
|
|
1082
|
+
return {
|
|
1083
|
+
bind: subVM.id,
|
|
1084
|
+
view: () => {
|
|
1085
|
+
if (subVM.loading) {
|
|
1086
|
+
return BgWidget.spinner();
|
|
1087
|
+
}
|
|
1088
|
+
return html `
|
|
1089
|
+
<div class="d-flex flex-column p-2" style="gap: 18px;">
|
|
1090
|
+
<div
|
|
1091
|
+
class="d-flex align-items-center gray-bottom-line-18"
|
|
1092
|
+
style="gap: 24px; justify-content: space-between;"
|
|
1093
|
+
>
|
|
1094
|
+
<div class="form-check-label c_updown_label">
|
|
1095
|
+
<div class="tx_normal">商品列表</div>
|
|
1096
|
+
</div>
|
|
1097
|
+
${BgWidget.grayButton('選擇商品', gvc.event(() => {
|
|
1098
|
+
var _b;
|
|
1099
|
+
BgProduct.productsDialog({
|
|
1100
|
+
gvc: gvc,
|
|
1101
|
+
default: (_b = voucherData.forKey) !== null && _b !== void 0 ? _b : [],
|
|
1102
|
+
callback: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
1103
|
+
voucherData.forKey = value;
|
|
1104
|
+
defKeys.product = value;
|
|
1105
|
+
subVM.dataList = yield BgProduct.getProductOpts(voucherData.forKey);
|
|
1106
|
+
subVM.loading = true;
|
|
1107
|
+
gvc.notifyDataChange(subVM.id);
|
|
1108
|
+
}),
|
|
1070
1109
|
});
|
|
1110
|
+
}), { textStyle: 'font-weight: 400;' })}
|
|
1111
|
+
</div>
|
|
1112
|
+
${subVM.dataList
|
|
1113
|
+
.map((opt, index) => {
|
|
1114
|
+
return html ` <div
|
|
1115
|
+
class="d-flex align-items-center form-check-label c_updown_label gap-3"
|
|
1116
|
+
>
|
|
1117
|
+
<span class="tx_normal">${index + 1}.</span>
|
|
1118
|
+
${BgWidget.validImageBox({
|
|
1119
|
+
gvc: gvc,
|
|
1120
|
+
image: opt.image,
|
|
1121
|
+
width: 40,
|
|
1122
|
+
})}
|
|
1123
|
+
<div class="tx_normal ${opt.note ? 'mb-1' : ''}">
|
|
1124
|
+
${opt.value}
|
|
1125
|
+
</div>
|
|
1126
|
+
${opt.note
|
|
1127
|
+
? html ` <div class="tx_gray_12">${opt.note}</div> `
|
|
1128
|
+
: ''}
|
|
1129
|
+
</div>`;
|
|
1130
|
+
})
|
|
1131
|
+
.join(``)}
|
|
1132
|
+
</div>
|
|
1133
|
+
`;
|
|
1134
|
+
},
|
|
1135
|
+
onCreate: () => {
|
|
1136
|
+
if (subVM.loading) {
|
|
1137
|
+
if (voucherData.forKey.length === 0) {
|
|
1138
|
+
setTimeout(() => {
|
|
1139
|
+
subVM.dataList = [];
|
|
1140
|
+
subVM.loading = false;
|
|
1141
|
+
gvc.notifyDataChange(subVM.id);
|
|
1142
|
+
}, 200);
|
|
1143
|
+
}
|
|
1144
|
+
else {
|
|
1145
|
+
new Promise(resolve => {
|
|
1146
|
+
resolve(BgProduct.getProductOpts(voucherData.forKey));
|
|
1147
|
+
}).then(data => {
|
|
1148
|
+
subVM.dataList = data;
|
|
1149
|
+
subVM.loading = false;
|
|
1150
|
+
gvc.notifyDataChange(subVM.id);
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1071
1153
|
}
|
|
1072
|
-
}
|
|
1073
|
-
}
|
|
1074
|
-
};
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
}
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
],
|
|
1154
|
+
},
|
|
1155
|
+
};
|
|
1156
|
+
});
|
|
1157
|
+
case 'all':
|
|
1158
|
+
default:
|
|
1159
|
+
return '';
|
|
1160
|
+
}
|
|
1161
|
+
})()}
|
|
1162
|
+
`,
|
|
1163
|
+
];
|
|
1164
|
+
})(),
|
|
1165
|
+
].join(BgWidget.horizontalLine());
|
|
1166
|
+
},
|
|
1167
|
+
};
|
|
1168
|
+
})),
|
|
1169
|
+
]),
|
|
1089
1170
|
['giveaway', 'add_on_items'].includes(voucherData.reBackType)
|
|
1090
1171
|
? BgWidget.mainCard(rebackProduct())
|
|
1091
1172
|
: '',
|
|
@@ -1094,12 +1175,12 @@ export class ShoppingDiscountSetting {
|
|
|
1094
1175
|
bind: pageVM.conditionID,
|
|
1095
1176
|
view: () => {
|
|
1096
1177
|
const conditionInput = (text) => {
|
|
1097
|
-
var
|
|
1178
|
+
var _b;
|
|
1098
1179
|
return BgWidget.editeInput({
|
|
1099
1180
|
gvc: gvc,
|
|
1100
1181
|
title: '',
|
|
1101
1182
|
divStyle: 'width:150px;',
|
|
1102
|
-
default: `${(
|
|
1183
|
+
default: `${(_b = voucherData.ruleValue) !== null && _b !== void 0 ? _b : 0}`,
|
|
1103
1184
|
placeHolder: '',
|
|
1104
1185
|
callback: value => {
|
|
1105
1186
|
voucherData.ruleValue = parseInt(value, 10);
|
|
@@ -1289,7 +1370,7 @@ export class ShoppingDiscountSetting {
|
|
|
1289
1370
|
bind: id,
|
|
1290
1371
|
view: () => {
|
|
1291
1372
|
function storeUseTimeLimit() {
|
|
1292
|
-
var
|
|
1373
|
+
var _b;
|
|
1293
1374
|
return html ` <div class="tx_700">全館總使用次數</div>
|
|
1294
1375
|
${BgWidget.mbContainer(18)}
|
|
1295
1376
|
${BgWidget.multiCheckboxContainer(gvc, [
|
|
@@ -1307,7 +1388,7 @@ export class ShoppingDiscountSetting {
|
|
|
1307
1388
|
title: '',
|
|
1308
1389
|
type: 'number',
|
|
1309
1390
|
divStyle: 'width: 150px;',
|
|
1310
|
-
default: `${(
|
|
1391
|
+
default: `${(_b = voucherData.macroLimited) !== null && _b !== void 0 ? _b : 0}`,
|
|
1311
1392
|
placeHolder: '',
|
|
1312
1393
|
callback: text => {
|
|
1313
1394
|
voucherData.macroLimited = parseInt(text, 10);
|
|
@@ -1323,7 +1404,7 @@ export class ShoppingDiscountSetting {
|
|
|
1323
1404
|
}, { single: true })}`;
|
|
1324
1405
|
}
|
|
1325
1406
|
function memberUseTimeLimit() {
|
|
1326
|
-
var
|
|
1407
|
+
var _b;
|
|
1327
1408
|
return html ` <div class="tx_700">個人總使用次數</div>
|
|
1328
1409
|
${BgWidget.mbContainer(18)}
|
|
1329
1410
|
${BgWidget.multiCheckboxContainer(gvc, [
|
|
@@ -1341,7 +1422,7 @@ export class ShoppingDiscountSetting {
|
|
|
1341
1422
|
title: '',
|
|
1342
1423
|
type: 'number',
|
|
1343
1424
|
divStyle: 'width: 150px;',
|
|
1344
|
-
default: `${(
|
|
1425
|
+
default: `${(_b = voucherData.microLimited) !== null && _b !== void 0 ? _b : 0}`,
|
|
1345
1426
|
placeHolder: '',
|
|
1346
1427
|
callback: text => {
|
|
1347
1428
|
voucherData.microLimited = parseInt(text, 10);
|
|
@@ -1443,7 +1524,7 @@ export class ShoppingDiscountSetting {
|
|
|
1443
1524
|
}, { single: true })}`;
|
|
1444
1525
|
}
|
|
1445
1526
|
function rebateEndDay() {
|
|
1446
|
-
var
|
|
1527
|
+
var _b, _c;
|
|
1447
1528
|
return [
|
|
1448
1529
|
html `<div class="tx_700">購物金有效天數</div>`,
|
|
1449
1530
|
BgWidget.multiCheckboxContainer(gvc, [
|
|
@@ -1466,7 +1547,7 @@ export class ShoppingDiscountSetting {
|
|
|
1466
1547
|
title: '',
|
|
1467
1548
|
type: 'number',
|
|
1468
1549
|
style: inputStyle,
|
|
1469
|
-
default: `${(
|
|
1550
|
+
default: `${(_b = voucherData.rebateEndDay) !== null && _b !== void 0 ? _b : ''}`,
|
|
1470
1551
|
placeHolder: '0則為無期限',
|
|
1471
1552
|
callback: text => {
|
|
1472
1553
|
voucherData.rebateEndDay = text;
|
|
@@ -1477,7 +1558,7 @@ export class ShoppingDiscountSetting {
|
|
|
1477
1558
|
</div>
|
|
1478
1559
|
</div>`,
|
|
1479
1560
|
},
|
|
1480
|
-
], [parseInt((
|
|
1561
|
+
], [parseInt((_c = voucherData.rebateEndDay) !== null && _c !== void 0 ? _c : '0', 10) ? `withEnd` : `noEnd`], text => {
|
|
1481
1562
|
if (text[0] === 'noEnd') {
|
|
1482
1563
|
voucherData.rebateEndDay = '0';
|
|
1483
1564
|
}
|
|
@@ -1610,7 +1691,1262 @@ export class ShoppingDiscountSetting {
|
|
|
1610
1691
|
};
|
|
1611
1692
|
});
|
|
1612
1693
|
}
|
|
1694
|
+
static voucherEditorV2(obj) {
|
|
1695
|
+
const gvc = obj.gvc;
|
|
1696
|
+
const vm = obj.vm;
|
|
1697
|
+
const glitter = gvc.glitter;
|
|
1698
|
+
const dialog = new ShareDialog(glitter);
|
|
1699
|
+
const getUUID = glitter.getUUID;
|
|
1700
|
+
const pageVM = {
|
|
1701
|
+
viewID: getUUID(),
|
|
1702
|
+
};
|
|
1703
|
+
const voucherData = Object.assign(Object.assign({}, this.emptyVoucher(obj.reBackType)), vm.data);
|
|
1704
|
+
const cloneForKey = (key) => JSON.parse(JSON.stringify(key));
|
|
1705
|
+
const setTitle = (title) => html `<div class="tx_700">${title}</div>`;
|
|
1706
|
+
const voucherSettingCard = (array) => BgWidget.mainCard(array
|
|
1707
|
+
.map(stringArray => stringArray.filter(Boolean))
|
|
1708
|
+
.filter(stringArray => stringArray.length > 0)
|
|
1709
|
+
.map(stringArray => stringArray.join(BgWidget.mbContainer(18)))
|
|
1710
|
+
.join(BgWidget.horizontalLine({ margin: '18px 0' })));
|
|
1711
|
+
return gvc.bindView({
|
|
1712
|
+
bind: pageVM.viewID,
|
|
1713
|
+
view: () => {
|
|
1714
|
+
const ruleValue = voucherData.ruleValue;
|
|
1715
|
+
const isPercentMethod = voucherData.method === 'percent';
|
|
1716
|
+
const isShipmentFree = voucherData.reBackType === 'shipment_free';
|
|
1717
|
+
const floor = Math.floor(ruleValue / 2);
|
|
1718
|
+
if (isPercentMethod || isShipmentFree) {
|
|
1719
|
+
voucherData.counting = 'single';
|
|
1720
|
+
}
|
|
1721
|
+
if (isShipmentFree) {
|
|
1722
|
+
voucherData.conditionType = 'order';
|
|
1723
|
+
}
|
|
1724
|
+
if (!voucherData.forKey) {
|
|
1725
|
+
voucherData.forKey = [];
|
|
1726
|
+
}
|
|
1727
|
+
if (!Array.isArray(voucherData.add_on_products)) {
|
|
1728
|
+
voucherData.add_on_products = [];
|
|
1729
|
+
}
|
|
1730
|
+
const defKeys = {
|
|
1731
|
+
all: [],
|
|
1732
|
+
collection: cloneForKey(voucherData.forKey),
|
|
1733
|
+
product: cloneForKey(voucherData.forKey),
|
|
1734
|
+
manager_tag: cloneForKey(voucherData.forKey),
|
|
1735
|
+
};
|
|
1736
|
+
function status() {
|
|
1737
|
+
return html `<div class="d-flex gap-1">
|
|
1738
|
+
<div class="tx_normal">活動啟用</div>
|
|
1739
|
+
${BgWidget.switchTextButton(gvc, voucherData.status === 1, {}, bool => {
|
|
1740
|
+
voucherData.status = bool ? 1 : 0;
|
|
1741
|
+
})}
|
|
1742
|
+
</div>`;
|
|
1743
|
+
}
|
|
1744
|
+
function title() {
|
|
1745
|
+
return html ` <div class="tx_normal">活動標題 ${BgWidget.requiredStar()}</div>
|
|
1746
|
+
${BgWidget.mbContainer(8)}
|
|
1747
|
+
${BgWidget.editeInput({
|
|
1748
|
+
gvc: gvc,
|
|
1749
|
+
title: '',
|
|
1750
|
+
default: voucherData.title,
|
|
1751
|
+
placeHolder: '請輸入活動標題',
|
|
1752
|
+
callback: text => {
|
|
1753
|
+
voucherData.title = text;
|
|
1754
|
+
},
|
|
1755
|
+
})}`;
|
|
1756
|
+
}
|
|
1757
|
+
function trigger() {
|
|
1758
|
+
return BgWidget.multiCheckboxContainer(gvc, [
|
|
1759
|
+
{
|
|
1760
|
+
key: 'auto',
|
|
1761
|
+
name: '自動折扣',
|
|
1762
|
+
innerHtml: BgWidget.grayNote('顧客將在結帳時自動獲得折扣'),
|
|
1763
|
+
},
|
|
1764
|
+
{
|
|
1765
|
+
key: 'code',
|
|
1766
|
+
name: '優惠代碼',
|
|
1767
|
+
innerHtml: (() => {
|
|
1768
|
+
const id = getUUID();
|
|
1769
|
+
return gvc.bindView({
|
|
1770
|
+
bind: id,
|
|
1771
|
+
view: () => {
|
|
1772
|
+
var _b;
|
|
1773
|
+
return gvc.map([
|
|
1774
|
+
BgWidget.grayNote('顧客可在結帳時輸入優惠代碼,來獲得折扣'),
|
|
1775
|
+
BgWidget.editeInput({
|
|
1776
|
+
gvc: gvc,
|
|
1777
|
+
title: '',
|
|
1778
|
+
default: (_b = voucherData.code) !== null && _b !== void 0 ? _b : '',
|
|
1779
|
+
placeHolder: '請輸入優惠券代碼',
|
|
1780
|
+
callback: text => {
|
|
1781
|
+
voucherData.code = text.toUpperCase();
|
|
1782
|
+
},
|
|
1783
|
+
endText: html ` <div class="d-flex justify-content-end">
|
|
1784
|
+
${BgWidget.mbContainer(8)}
|
|
1785
|
+
${BgWidget.blueNote(document.body.clientWidth > 768 ? '隨機產生優惠代碼' : '隨機產生', gvc.event(() => {
|
|
1786
|
+
voucherData.code = Tool.randomString(6).toUpperCase();
|
|
1787
|
+
gvc.notifyDataChange(id);
|
|
1788
|
+
}))}
|
|
1789
|
+
</div>`,
|
|
1790
|
+
}),
|
|
1791
|
+
]);
|
|
1792
|
+
},
|
|
1793
|
+
});
|
|
1794
|
+
})(),
|
|
1795
|
+
},
|
|
1796
|
+
{
|
|
1797
|
+
key: 'distribution',
|
|
1798
|
+
name: '供特定賣場優惠使用',
|
|
1799
|
+
innerHtml: BgWidget.grayNote('僅限於隱形賣場 / 一頁商店 / 拼團賣場 / 分銷連結使用'),
|
|
1800
|
+
},
|
|
1801
|
+
], [voucherData.trigger], text => {
|
|
1802
|
+
if (text[0] === 'auto') {
|
|
1803
|
+
voucherData.code = undefined;
|
|
1804
|
+
}
|
|
1805
|
+
if (text[0] === 'distribution') {
|
|
1806
|
+
voucherData.for = 'all';
|
|
1807
|
+
}
|
|
1808
|
+
voucherData.trigger = text[0];
|
|
1809
|
+
gvc.notifyDataChange(pageVM.viewID);
|
|
1810
|
+
}, { single: true });
|
|
1811
|
+
}
|
|
1812
|
+
function target() {
|
|
1813
|
+
return gvc.bindView(() => {
|
|
1814
|
+
const id = getUUID();
|
|
1815
|
+
return {
|
|
1816
|
+
bind: id,
|
|
1817
|
+
view: () => {
|
|
1818
|
+
var _b;
|
|
1819
|
+
return html `
|
|
1820
|
+
<div style="display: flex; flex-direction: column; gap: 8px;">
|
|
1821
|
+
${BgWidget.selectFilter({
|
|
1822
|
+
gvc: gvc,
|
|
1823
|
+
callback: text => {
|
|
1824
|
+
voucherData.target = text;
|
|
1825
|
+
gvc.notifyDataChange(id);
|
|
1826
|
+
},
|
|
1827
|
+
default: (_b = voucherData.target) !== null && _b !== void 0 ? _b : 'all',
|
|
1828
|
+
options: [
|
|
1829
|
+
{
|
|
1830
|
+
key: 'all',
|
|
1831
|
+
value: '所有顧客',
|
|
1832
|
+
},
|
|
1833
|
+
{
|
|
1834
|
+
key: 'customer',
|
|
1835
|
+
value: '特定顧客',
|
|
1836
|
+
},
|
|
1837
|
+
{
|
|
1838
|
+
key: 'levels',
|
|
1839
|
+
value: '會員等級',
|
|
1840
|
+
},
|
|
1841
|
+
],
|
|
1842
|
+
style: 'width: 100%;',
|
|
1843
|
+
})}
|
|
1844
|
+
<div>
|
|
1845
|
+
${(() => {
|
|
1846
|
+
switch (voucherData.target) {
|
|
1847
|
+
case 'all':
|
|
1848
|
+
return '';
|
|
1849
|
+
case 'customer':
|
|
1850
|
+
return gvc.bindView(() => {
|
|
1851
|
+
const customVM = {
|
|
1852
|
+
id: getUUID(),
|
|
1853
|
+
loading: true,
|
|
1854
|
+
dataList: [],
|
|
1855
|
+
};
|
|
1856
|
+
return {
|
|
1857
|
+
bind: customVM.id,
|
|
1858
|
+
view: () => {
|
|
1859
|
+
if (customVM.loading) {
|
|
1860
|
+
return BgWidget.spinner();
|
|
1861
|
+
}
|
|
1862
|
+
return html `
|
|
1863
|
+
<div class="d-flex flex-column p-2" style="gap: 18px;">
|
|
1864
|
+
<div
|
|
1865
|
+
class="d-flex align-items-center gray-bottom-line-18"
|
|
1866
|
+
style="justify-content: space-between;"
|
|
1867
|
+
>
|
|
1868
|
+
<div class="form-check-label c_updown_label">
|
|
1869
|
+
<div class="tx_normal">顧客名稱</div>
|
|
1870
|
+
</div>
|
|
1871
|
+
${BgWidget.grayButton('查看全部', gvc.event(() => {
|
|
1872
|
+
var _b;
|
|
1873
|
+
BgWidget.selectDropDialog({
|
|
1874
|
+
gvc: gvc,
|
|
1875
|
+
title: '搜尋特定顧客',
|
|
1876
|
+
tag: 'select_users',
|
|
1877
|
+
updownOptions: FilterOptions.userOrderBy,
|
|
1878
|
+
callback: value => {
|
|
1879
|
+
voucherData.targetList = value;
|
|
1880
|
+
customVM.loading = true;
|
|
1881
|
+
gvc.notifyDataChange(customVM.id);
|
|
1882
|
+
},
|
|
1883
|
+
default: ((_b = voucherData.targetList) !== null && _b !== void 0 ? _b : []).map(id => id.toString()),
|
|
1884
|
+
api: (data) => {
|
|
1885
|
+
return new Promise(resolve => {
|
|
1886
|
+
ApiUser.getUserListOrders({
|
|
1887
|
+
page: 0,
|
|
1888
|
+
limit: 99999,
|
|
1889
|
+
search: data.query,
|
|
1890
|
+
orderString: data.orderString,
|
|
1891
|
+
only_id: true,
|
|
1892
|
+
}).then(dd => {
|
|
1893
|
+
if (dd.response.data) {
|
|
1894
|
+
resolve(dd.response.data.map((item) => {
|
|
1895
|
+
var _b;
|
|
1896
|
+
return {
|
|
1897
|
+
key: item.userID,
|
|
1898
|
+
value: (_b = item.userData.name) !== null && _b !== void 0 ? _b : '(尚無姓名)',
|
|
1899
|
+
note: item.userData.email,
|
|
1900
|
+
};
|
|
1901
|
+
}));
|
|
1902
|
+
}
|
|
1903
|
+
});
|
|
1904
|
+
});
|
|
1905
|
+
},
|
|
1906
|
+
style: 'width: 100%;',
|
|
1907
|
+
});
|
|
1908
|
+
}), { textStyle: 'font-weight: 400;' })}
|
|
1909
|
+
</div>
|
|
1910
|
+
${obj.gvc.map(customVM.dataList.map((opt, index) => {
|
|
1911
|
+
return html ` <div class="form-check-label c_updown_label">
|
|
1912
|
+
<span class="tx_normal">${index + 1}. ${opt.value}</span>
|
|
1913
|
+
${opt.note ? html ` <span class="tx_gray_12 ms-2">${opt.note}</span> ` : ''}
|
|
1914
|
+
</div>`;
|
|
1915
|
+
}))}
|
|
1916
|
+
</div>
|
|
1917
|
+
`;
|
|
1918
|
+
},
|
|
1919
|
+
onCreate: () => {
|
|
1920
|
+
if (customVM.loading) {
|
|
1921
|
+
if (voucherData.targetList.length === 0) {
|
|
1922
|
+
setTimeout(() => {
|
|
1923
|
+
customVM.dataList = [];
|
|
1924
|
+
customVM.loading = false;
|
|
1925
|
+
gvc.notifyDataChange(customVM.id);
|
|
1926
|
+
}, 200);
|
|
1927
|
+
}
|
|
1928
|
+
else {
|
|
1929
|
+
ApiUser.getUserList({
|
|
1930
|
+
page: 0,
|
|
1931
|
+
limit: 99999,
|
|
1932
|
+
id: voucherData.targetList.join(','),
|
|
1933
|
+
only_id: true,
|
|
1934
|
+
}).then(dd => {
|
|
1935
|
+
if (dd.response.data) {
|
|
1936
|
+
customVM.dataList = dd.response.data.map((item) => {
|
|
1937
|
+
return {
|
|
1938
|
+
key: item.userID,
|
|
1939
|
+
value: item.userData.name,
|
|
1940
|
+
note: item.userData.email,
|
|
1941
|
+
};
|
|
1942
|
+
});
|
|
1943
|
+
}
|
|
1944
|
+
customVM.loading = false;
|
|
1945
|
+
gvc.notifyDataChange(customVM.id);
|
|
1946
|
+
});
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
},
|
|
1950
|
+
};
|
|
1951
|
+
});
|
|
1952
|
+
case 'levels':
|
|
1953
|
+
return (() => {
|
|
1954
|
+
const levelVM = {
|
|
1955
|
+
id: getUUID(),
|
|
1956
|
+
loading: true,
|
|
1957
|
+
dataList: [],
|
|
1958
|
+
};
|
|
1959
|
+
return gvc.bindView({
|
|
1960
|
+
bind: levelVM.id,
|
|
1961
|
+
view: () => {
|
|
1962
|
+
var _b;
|
|
1963
|
+
if (levelVM.loading) {
|
|
1964
|
+
return BgWidget.spinner({ text: { visible: false } });
|
|
1965
|
+
}
|
|
1966
|
+
else {
|
|
1967
|
+
return BgWidget.selectDropList({
|
|
1968
|
+
gvc: gvc,
|
|
1969
|
+
callback: value => {
|
|
1970
|
+
voucherData.targetList = value;
|
|
1971
|
+
gvc.notifyDataChange(id);
|
|
1972
|
+
},
|
|
1973
|
+
default: ((_b = voucherData.targetList) !== null && _b !== void 0 ? _b : []).map(id => id.toString()),
|
|
1974
|
+
options: levelVM.dataList,
|
|
1975
|
+
style: 'width: 100%;',
|
|
1976
|
+
});
|
|
1977
|
+
}
|
|
1978
|
+
},
|
|
1979
|
+
divCreate: {
|
|
1980
|
+
style: 'width: 100%;',
|
|
1981
|
+
},
|
|
1982
|
+
onCreate: () => {
|
|
1983
|
+
if (levelVM.loading) {
|
|
1984
|
+
ApiUser.getPublicConfig('member_level_config', 'manager').then((dd) => {
|
|
1985
|
+
if (dd.result && dd.response.value) {
|
|
1986
|
+
levelVM.dataList = dd.response.value.levels.map((item) => {
|
|
1987
|
+
return {
|
|
1988
|
+
key: item.id,
|
|
1989
|
+
value: item.tag_name,
|
|
1990
|
+
};
|
|
1991
|
+
});
|
|
1992
|
+
levelVM.loading = false;
|
|
1993
|
+
gvc.notifyDataChange(levelVM.id);
|
|
1994
|
+
}
|
|
1995
|
+
});
|
|
1996
|
+
}
|
|
1997
|
+
},
|
|
1998
|
+
});
|
|
1999
|
+
})();
|
|
2000
|
+
case 'group':
|
|
2001
|
+
return (() => {
|
|
2002
|
+
const levelVM = {
|
|
2003
|
+
id: getUUID(),
|
|
2004
|
+
loading: true,
|
|
2005
|
+
dataList: [],
|
|
2006
|
+
};
|
|
2007
|
+
return gvc.bindView({
|
|
2008
|
+
bind: levelVM.id,
|
|
2009
|
+
view: () => {
|
|
2010
|
+
var _b;
|
|
2011
|
+
if (levelVM.loading) {
|
|
2012
|
+
return BgWidget.spinner({ text: { visible: false } });
|
|
2013
|
+
}
|
|
2014
|
+
else {
|
|
2015
|
+
return BgWidget.selectDropList({
|
|
2016
|
+
gvc: gvc,
|
|
2017
|
+
callback: (value) => {
|
|
2018
|
+
voucherData.targetList = value;
|
|
2019
|
+
gvc.notifyDataChange(id);
|
|
2020
|
+
},
|
|
2021
|
+
default: ((_b = voucherData.targetList) !== null && _b !== void 0 ? _b : []).map(id => id.toString()),
|
|
2022
|
+
options: levelVM.dataList,
|
|
2023
|
+
style: 'width: 100%;',
|
|
2024
|
+
});
|
|
2025
|
+
}
|
|
2026
|
+
},
|
|
2027
|
+
divCreate: {
|
|
2028
|
+
style: 'width: 100%;',
|
|
2029
|
+
},
|
|
2030
|
+
onCreate: () => {
|
|
2031
|
+
if (levelVM.loading) {
|
|
2032
|
+
ApiUser.getUserGroupList().then((dd) => {
|
|
2033
|
+
if (dd.result && dd.response.data) {
|
|
2034
|
+
levelVM.dataList = dd.response.data
|
|
2035
|
+
.filter((item) => {
|
|
2036
|
+
return item.type !== 'level';
|
|
2037
|
+
})
|
|
2038
|
+
.map((item) => {
|
|
2039
|
+
return {
|
|
2040
|
+
key: item.type,
|
|
2041
|
+
value: item.title,
|
|
2042
|
+
};
|
|
2043
|
+
});
|
|
2044
|
+
levelVM.loading = false;
|
|
2045
|
+
gvc.notifyDataChange(levelVM.id);
|
|
2046
|
+
}
|
|
2047
|
+
});
|
|
2048
|
+
}
|
|
2049
|
+
},
|
|
2050
|
+
});
|
|
2051
|
+
})();
|
|
2052
|
+
default:
|
|
2053
|
+
return '';
|
|
2054
|
+
}
|
|
2055
|
+
})()}
|
|
2056
|
+
</div>
|
|
2057
|
+
</div>
|
|
2058
|
+
`;
|
|
2059
|
+
},
|
|
2060
|
+
};
|
|
2061
|
+
});
|
|
2062
|
+
}
|
|
2063
|
+
function device() {
|
|
2064
|
+
var _b;
|
|
2065
|
+
return BgWidget.multiCheckboxContainer(gvc, [
|
|
2066
|
+
{ key: 'normal', name: '官網 & APP 訂單' },
|
|
2067
|
+
{ key: 'pos', name: 'POS 訂單' },
|
|
2068
|
+
], (_b = voucherData.device) !== null && _b !== void 0 ? _b : ['normal'], text => {
|
|
2069
|
+
voucherData.device = text;
|
|
2070
|
+
gvc.notifyDataChange(pageVM.viewID);
|
|
2071
|
+
}, { single: false });
|
|
2072
|
+
}
|
|
2073
|
+
function selectShipment() {
|
|
2074
|
+
if (voucherData.reBackType !== 'shipment_free') {
|
|
2075
|
+
return '';
|
|
2076
|
+
}
|
|
2077
|
+
const id = getUUID();
|
|
2078
|
+
return gvc.bindView({
|
|
2079
|
+
bind: id,
|
|
2080
|
+
view: () => {
|
|
2081
|
+
var _b;
|
|
2082
|
+
return [
|
|
2083
|
+
BgWidget.select({
|
|
2084
|
+
gvc,
|
|
2085
|
+
callback: value => {
|
|
2086
|
+
voucherData.selectShipment.type = value;
|
|
2087
|
+
gvc.notifyDataChange(id);
|
|
2088
|
+
},
|
|
2089
|
+
default: voucherData.selectShipment.type,
|
|
2090
|
+
options: [
|
|
2091
|
+
{ key: 'all', value: '所有物流' },
|
|
2092
|
+
{ key: 'select', value: '指定物流' },
|
|
2093
|
+
],
|
|
2094
|
+
}),
|
|
2095
|
+
voucherData.selectShipment.type === 'all'
|
|
2096
|
+
? ''
|
|
2097
|
+
: BgWidget.selectDropList({
|
|
2098
|
+
gvc: gvc,
|
|
2099
|
+
callback: value => {
|
|
2100
|
+
voucherData.selectShipment.list = value;
|
|
2101
|
+
},
|
|
2102
|
+
default: (_b = voucherData.selectShipment.list) !== null && _b !== void 0 ? _b : [],
|
|
2103
|
+
options: ShipmentConfig.list.map(item => {
|
|
2104
|
+
return {
|
|
2105
|
+
key: item.value,
|
|
2106
|
+
value: item.title,
|
|
2107
|
+
};
|
|
2108
|
+
}),
|
|
2109
|
+
style: 'width: 100%;',
|
|
2110
|
+
}),
|
|
2111
|
+
]
|
|
2112
|
+
.filter(Boolean)
|
|
2113
|
+
.join(BgWidget.mbContainer(8));
|
|
2114
|
+
},
|
|
2115
|
+
});
|
|
2116
|
+
}
|
|
2117
|
+
function setVoucherFor() {
|
|
2118
|
+
var _b;
|
|
2119
|
+
return EditorElem.radio({
|
|
2120
|
+
gvc: gvc,
|
|
2121
|
+
title: '',
|
|
2122
|
+
def: (_b = voucherData.for) !== null && _b !== void 0 ? _b : 'all',
|
|
2123
|
+
array: ShoppingDiscountSetting.productForList,
|
|
2124
|
+
callback: text => {
|
|
2125
|
+
voucherData.forKey = defKeys[text];
|
|
2126
|
+
voucherData.for = text;
|
|
2127
|
+
gvc.notifyDataChange(pageVM.viewID);
|
|
2128
|
+
},
|
|
2129
|
+
oneLine: true,
|
|
2130
|
+
});
|
|
2131
|
+
}
|
|
2132
|
+
function selectProduct() {
|
|
2133
|
+
if (voucherData.trigger === 'distribution') {
|
|
2134
|
+
return '';
|
|
2135
|
+
}
|
|
2136
|
+
switch (voucherData.for) {
|
|
2137
|
+
case 'manager_tag':
|
|
2138
|
+
return gvc.bindView(() => {
|
|
2139
|
+
const subVM = {
|
|
2140
|
+
id: getUUID(),
|
|
2141
|
+
dataList: String(voucherData.for) === 'manager_tag' ? [...defKeys.manager_tag] : [],
|
|
2142
|
+
};
|
|
2143
|
+
return {
|
|
2144
|
+
bind: subVM.id,
|
|
2145
|
+
view: () => {
|
|
2146
|
+
return html `
|
|
2147
|
+
<div class="d-flex flex-column p-2" style="gap: 18px;">
|
|
2148
|
+
<div
|
|
2149
|
+
class="d-flex align-items-center gray-bottom-line-18"
|
|
2150
|
+
style="gap: 24px; justify-content: space-between;"
|
|
2151
|
+
>
|
|
2152
|
+
<div class="form-check-label c_updown_label">
|
|
2153
|
+
<div class="tx_normal">標籤列表</div>
|
|
2154
|
+
</div>
|
|
2155
|
+
${BgWidget.grayButton('選擇標籤', gvc.event(() => {
|
|
2156
|
+
BgProduct.useProductTags({
|
|
2157
|
+
gvc,
|
|
2158
|
+
config_key: 'product_manager_tags',
|
|
2159
|
+
def: String(voucherData.for) === 'manager_tag' && voucherData.forKey
|
|
2160
|
+
? voucherData.forKey.map(item => `${item}`)
|
|
2161
|
+
: [],
|
|
2162
|
+
callback: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
2163
|
+
voucherData.forKey = value;
|
|
2164
|
+
defKeys.manager_tag = value;
|
|
2165
|
+
subVM.dataList = value;
|
|
2166
|
+
gvc.notifyDataChange(subVM.id);
|
|
2167
|
+
}),
|
|
2168
|
+
});
|
|
2169
|
+
}), { textStyle: 'font-weight: 400;' })}
|
|
2170
|
+
</div>
|
|
2171
|
+
${obj.gvc.map(subVM.dataList.map((opt, index) => {
|
|
2172
|
+
return html ` <div class="d-flex align-items-center form-check-label c_updown_label gap-3">
|
|
2173
|
+
<span class="tx_normal">${index + 1}. #${opt}</span>
|
|
2174
|
+
</div>`;
|
|
2175
|
+
}))}
|
|
2176
|
+
</div>
|
|
2177
|
+
`;
|
|
2178
|
+
},
|
|
2179
|
+
};
|
|
2180
|
+
});
|
|
2181
|
+
case 'collection':
|
|
2182
|
+
return gvc.bindView(() => {
|
|
2183
|
+
const subVM = {
|
|
2184
|
+
id: getUUID(),
|
|
2185
|
+
loading: true,
|
|
2186
|
+
dataList: [],
|
|
2187
|
+
};
|
|
2188
|
+
return {
|
|
2189
|
+
bind: subVM.id,
|
|
2190
|
+
view: () => {
|
|
2191
|
+
if (subVM.loading) {
|
|
2192
|
+
return BgWidget.spinner();
|
|
2193
|
+
}
|
|
2194
|
+
return html `
|
|
2195
|
+
<div class="d-flex flex-column p-2" style="gap: 18px;">
|
|
2196
|
+
<div
|
|
2197
|
+
class="d-flex align-items-center gray-bottom-line-18"
|
|
2198
|
+
style="gap: 24px; justify-content: space-between;"
|
|
2199
|
+
>
|
|
2200
|
+
<div class="form-check-label c_updown_label">
|
|
2201
|
+
<div class="tx_normal">分類列表</div>
|
|
2202
|
+
</div>
|
|
2203
|
+
${BgWidget.grayButton('選擇分類', gvc.event(() => {
|
|
2204
|
+
var _b;
|
|
2205
|
+
BgProduct.collectionsDialog({
|
|
2206
|
+
gvc: gvc,
|
|
2207
|
+
default: (_b = voucherData.forKey) !== null && _b !== void 0 ? _b : [],
|
|
2208
|
+
callback: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
2209
|
+
voucherData.forKey = value;
|
|
2210
|
+
defKeys.collection = value;
|
|
2211
|
+
subVM.dataList = yield BgProduct.getCollectiosOpts(value);
|
|
2212
|
+
subVM.loading = true;
|
|
2213
|
+
gvc.notifyDataChange(subVM.id);
|
|
2214
|
+
}),
|
|
2215
|
+
});
|
|
2216
|
+
}), { textStyle: 'font-weight: 400;' })}
|
|
2217
|
+
</div>
|
|
2218
|
+
${obj.gvc.map(subVM.dataList.map((opt, index) => {
|
|
2219
|
+
return html ` <div class="d-flex align-items-center form-check-label c_updown_label gap-3">
|
|
2220
|
+
<span class="tx_normal">${index + 1}. ${opt.value}</span>
|
|
2221
|
+
${opt.note ? html ` <span class="tx_gray_12 ms-2">${opt.note}</span> ` : ''}
|
|
2222
|
+
</div>`;
|
|
2223
|
+
}))}
|
|
2224
|
+
</div>
|
|
2225
|
+
`;
|
|
2226
|
+
},
|
|
2227
|
+
onCreate: () => {
|
|
2228
|
+
if (subVM.loading) {
|
|
2229
|
+
if (voucherData.forKey.length === 0) {
|
|
2230
|
+
setTimeout(() => {
|
|
2231
|
+
subVM.dataList = [];
|
|
2232
|
+
subVM.loading = false;
|
|
2233
|
+
gvc.notifyDataChange(subVM.id);
|
|
2234
|
+
}, 200);
|
|
2235
|
+
}
|
|
2236
|
+
else {
|
|
2237
|
+
new Promise(resolve => {
|
|
2238
|
+
resolve(BgProduct.getCollectiosOpts(voucherData.forKey));
|
|
2239
|
+
}).then(data => {
|
|
2240
|
+
subVM.dataList = data;
|
|
2241
|
+
subVM.loading = false;
|
|
2242
|
+
gvc.notifyDataChange(subVM.id);
|
|
2243
|
+
});
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
},
|
|
2247
|
+
};
|
|
2248
|
+
});
|
|
2249
|
+
case 'product':
|
|
2250
|
+
return gvc.bindView(() => {
|
|
2251
|
+
const subVM = {
|
|
2252
|
+
id: getUUID(),
|
|
2253
|
+
loading: true,
|
|
2254
|
+
dataList: [],
|
|
2255
|
+
};
|
|
2256
|
+
return {
|
|
2257
|
+
bind: subVM.id,
|
|
2258
|
+
view: () => {
|
|
2259
|
+
if (subVM.loading) {
|
|
2260
|
+
return BgWidget.spinner();
|
|
2261
|
+
}
|
|
2262
|
+
return html `
|
|
2263
|
+
<div class="d-flex flex-column p-2" style="gap: 18px;">
|
|
2264
|
+
<div
|
|
2265
|
+
class="d-flex align-items-center gray-bottom-line-18"
|
|
2266
|
+
style="gap: 24px; justify-content: space-between;"
|
|
2267
|
+
>
|
|
2268
|
+
<div class="form-check-label c_updown_label">
|
|
2269
|
+
<div class="tx_normal">商品列表</div>
|
|
2270
|
+
</div>
|
|
2271
|
+
${BgWidget.grayButton('選擇商品', gvc.event(() => {
|
|
2272
|
+
var _b;
|
|
2273
|
+
BgProduct.productsDialog({
|
|
2274
|
+
gvc: gvc,
|
|
2275
|
+
default: (_b = voucherData.forKey) !== null && _b !== void 0 ? _b : [],
|
|
2276
|
+
callback: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
2277
|
+
voucherData.forKey = value;
|
|
2278
|
+
defKeys.product = value;
|
|
2279
|
+
subVM.dataList = yield BgProduct.getProductOpts(voucherData.forKey);
|
|
2280
|
+
subVM.loading = true;
|
|
2281
|
+
gvc.notifyDataChange(subVM.id);
|
|
2282
|
+
}),
|
|
2283
|
+
});
|
|
2284
|
+
}), { textStyle: 'font-weight: 400;' })}
|
|
2285
|
+
</div>
|
|
2286
|
+
${subVM.dataList
|
|
2287
|
+
.map((opt, index) => {
|
|
2288
|
+
return html ` <div class="d-flex align-items-center form-check-label c_updown_label gap-3">
|
|
2289
|
+
<span class="tx_normal">${index + 1}.</span>
|
|
2290
|
+
${BgWidget.validImageBox({
|
|
2291
|
+
gvc: gvc,
|
|
2292
|
+
image: opt.image,
|
|
2293
|
+
width: 40,
|
|
2294
|
+
})}
|
|
2295
|
+
<div class="tx_normal ${opt.note ? 'mb-1' : ''}">${opt.value}</div>
|
|
2296
|
+
${opt.note ? html ` <div class="tx_gray_12">${opt.note}</div> ` : ''}
|
|
2297
|
+
</div>`;
|
|
2298
|
+
})
|
|
2299
|
+
.join(``)}
|
|
2300
|
+
</div>
|
|
2301
|
+
`;
|
|
2302
|
+
},
|
|
2303
|
+
onCreate: () => {
|
|
2304
|
+
if (subVM.loading) {
|
|
2305
|
+
if (voucherData.forKey.length === 0) {
|
|
2306
|
+
setTimeout(() => {
|
|
2307
|
+
subVM.dataList = [];
|
|
2308
|
+
subVM.loading = false;
|
|
2309
|
+
gvc.notifyDataChange(subVM.id);
|
|
2310
|
+
}, 200);
|
|
2311
|
+
}
|
|
2312
|
+
else {
|
|
2313
|
+
new Promise(resolve => {
|
|
2314
|
+
resolve(BgProduct.getProductOpts(voucherData.forKey));
|
|
2315
|
+
}).then(data => {
|
|
2316
|
+
subVM.dataList = data;
|
|
2317
|
+
subVM.loading = false;
|
|
2318
|
+
gvc.notifyDataChange(subVM.id);
|
|
2319
|
+
});
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2322
|
+
},
|
|
2323
|
+
};
|
|
2324
|
+
});
|
|
2325
|
+
case 'all':
|
|
2326
|
+
return '';
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
function addProductView() {
|
|
2330
|
+
return obj.gvc.bindView(() => {
|
|
2331
|
+
const id = getUUID();
|
|
2332
|
+
return {
|
|
2333
|
+
bind: id,
|
|
2334
|
+
view: () => {
|
|
2335
|
+
try {
|
|
2336
|
+
return html `
|
|
2337
|
+
<div
|
|
2338
|
+
class="d-flex align-items-center gray-bottom-line-18"
|
|
2339
|
+
style="gap: 24px; justify-content: space-between;"
|
|
2340
|
+
>
|
|
2341
|
+
<div class="form-check-label c_updown_label">
|
|
2342
|
+
<div class="tx_normal">商品列表</div>
|
|
2343
|
+
</div>
|
|
2344
|
+
${BgWidget.grayButton('選擇商品', gvc.event(() => {
|
|
2345
|
+
var _b;
|
|
2346
|
+
BgProduct.productsDialog({
|
|
2347
|
+
gvc: gvc,
|
|
2348
|
+
default: (_b = voucherData.add_on_products) !== null && _b !== void 0 ? _b : [],
|
|
2349
|
+
callback: (value) => __awaiter(this, void 0, void 0, function* () {
|
|
2350
|
+
voucherData.add_on_products = value;
|
|
2351
|
+
gvc.notifyDataChange(id);
|
|
2352
|
+
}),
|
|
2353
|
+
filter: dd => {
|
|
2354
|
+
return true;
|
|
2355
|
+
},
|
|
2356
|
+
productType: voucherData.reBackType === 'add_on_items' ? 'addProduct' : 'giveaway',
|
|
2357
|
+
});
|
|
2358
|
+
}), { textStyle: 'font-weight: 400;' })}
|
|
2359
|
+
</div>
|
|
2360
|
+
${gvc.bindView(() => {
|
|
2361
|
+
const vm = {
|
|
2362
|
+
viewID: getUUID(),
|
|
2363
|
+
loading: true,
|
|
2364
|
+
data: [],
|
|
2365
|
+
};
|
|
2366
|
+
BgProduct.getProductOpts(voucherData.add_on_products, voucherData.reBackType === 'add_on_items' ? 'addProduct' : 'giveaway').then(res => {
|
|
2367
|
+
vm.data = res;
|
|
2368
|
+
vm.loading = false;
|
|
2369
|
+
gvc.notifyDataChange(vm.viewID);
|
|
2370
|
+
});
|
|
2371
|
+
return {
|
|
2372
|
+
bind: vm.viewID,
|
|
2373
|
+
view: () => __awaiter(this, void 0, void 0, function* () {
|
|
2374
|
+
if (vm.loading) {
|
|
2375
|
+
return BgWidget.spinner();
|
|
2376
|
+
}
|
|
2377
|
+
return vm.data
|
|
2378
|
+
.map((opt, index) => {
|
|
2379
|
+
return html ` <div class="d-flex align-items-center form-check-label c_updown_label gap-3">
|
|
2380
|
+
<span class="tx_normal">${index + 1}.</span>
|
|
2381
|
+
${BgWidget.validImageBox({
|
|
2382
|
+
gvc: gvc,
|
|
2383
|
+
image: opt.image,
|
|
2384
|
+
width: 40,
|
|
2385
|
+
})}
|
|
2386
|
+
<div class="tx_normal ${opt.note ? 'mb-1' : ''}">${opt.value}</div>
|
|
2387
|
+
${opt.note ? html ` <div class="tx_gray_12">${opt.note}</div> ` : ''}
|
|
2388
|
+
</div>`;
|
|
2389
|
+
})
|
|
2390
|
+
.join('');
|
|
2391
|
+
}),
|
|
2392
|
+
divCreate: {
|
|
2393
|
+
class: `d-flex py-2 flex-column`,
|
|
2394
|
+
style: `gap:10px;`,
|
|
2395
|
+
},
|
|
2396
|
+
};
|
|
2397
|
+
})}
|
|
2398
|
+
`;
|
|
2399
|
+
}
|
|
2400
|
+
catch (e) {
|
|
2401
|
+
console.error(e);
|
|
2402
|
+
return '';
|
|
2403
|
+
}
|
|
2404
|
+
},
|
|
2405
|
+
divCreate: {
|
|
2406
|
+
class: `w-100`,
|
|
2407
|
+
},
|
|
2408
|
+
};
|
|
2409
|
+
});
|
|
2410
|
+
}
|
|
2411
|
+
function storeUseTimeLimit() {
|
|
2412
|
+
var _b;
|
|
2413
|
+
return BgWidget.multiCheckboxContainer(gvc, [
|
|
2414
|
+
{
|
|
2415
|
+
key: 'noLimited',
|
|
2416
|
+
name: '無限制',
|
|
2417
|
+
},
|
|
2418
|
+
{
|
|
2419
|
+
key: 'hasLimited',
|
|
2420
|
+
name: '限制次數',
|
|
2421
|
+
innerHtml: html ` <div class="d-flex align-items-center">
|
|
2422
|
+
<span class="tx_normal me-2">可使用次數</span>
|
|
2423
|
+
${BgWidget.editeInput({
|
|
2424
|
+
gvc: gvc,
|
|
2425
|
+
title: '',
|
|
2426
|
+
type: 'number',
|
|
2427
|
+
divStyle: 'width: 150px;',
|
|
2428
|
+
default: `${(_b = voucherData.macroLimited) !== null && _b !== void 0 ? _b : 0}`,
|
|
2429
|
+
placeHolder: '',
|
|
2430
|
+
callback: text => {
|
|
2431
|
+
voucherData.macroLimited = parseInt(text, 10);
|
|
2432
|
+
},
|
|
2433
|
+
endText: '次',
|
|
2434
|
+
})}
|
|
2435
|
+
</div>`,
|
|
2436
|
+
},
|
|
2437
|
+
], [voucherData.macroLimited === 0 ? 'noLimited' : 'hasLimited'], text => {
|
|
2438
|
+
if (text[0] === 'noLimited') {
|
|
2439
|
+
voucherData.macroLimited = 0;
|
|
2440
|
+
}
|
|
2441
|
+
}, { single: true });
|
|
2442
|
+
}
|
|
2443
|
+
function memberUseTimeLimit() {
|
|
2444
|
+
var _b;
|
|
2445
|
+
return BgWidget.multiCheckboxContainer(gvc, [
|
|
2446
|
+
{
|
|
2447
|
+
key: 'noLimited',
|
|
2448
|
+
name: '無限制',
|
|
2449
|
+
},
|
|
2450
|
+
{
|
|
2451
|
+
key: 'hasLimited',
|
|
2452
|
+
name: '限制次數',
|
|
2453
|
+
innerHtml: html ` <div class="d-flex align-items-center">
|
|
2454
|
+
<span class="tx_normal me-2">可使用次數</span>
|
|
2455
|
+
${BgWidget.editeInput({
|
|
2456
|
+
gvc: gvc,
|
|
2457
|
+
title: '',
|
|
2458
|
+
type: 'number',
|
|
2459
|
+
divStyle: 'width: 150px;',
|
|
2460
|
+
default: `${(_b = voucherData.microLimited) !== null && _b !== void 0 ? _b : 0}`,
|
|
2461
|
+
placeHolder: '',
|
|
2462
|
+
callback: text => {
|
|
2463
|
+
voucherData.microLimited = parseInt(text, 10);
|
|
2464
|
+
},
|
|
2465
|
+
endText: '次',
|
|
2466
|
+
})}
|
|
2467
|
+
</div>`,
|
|
2468
|
+
},
|
|
2469
|
+
], [voucherData.microLimited === 0 ? 'noLimited' : 'hasLimited'], text => {
|
|
2470
|
+
if (text[0] === 'noLimited') {
|
|
2471
|
+
voucherData.microLimited = 0;
|
|
2472
|
+
}
|
|
2473
|
+
}, { single: true });
|
|
2474
|
+
}
|
|
2475
|
+
function startDateTime() {
|
|
2476
|
+
const inputStyle = 'display: block; width: 200px;';
|
|
2477
|
+
return html ` <div
|
|
2478
|
+
class="d-flex mb-2 ${document.body.clientWidth < 768 ? 'flex-column' : ''}"
|
|
2479
|
+
style="gap: 12px"
|
|
2480
|
+
>
|
|
2481
|
+
<div class="d-flex align-items-center">
|
|
2482
|
+
<span class="tx_normal me-2">開始日期</span>
|
|
2483
|
+
${BgWidget.editeInput({
|
|
2484
|
+
gvc: gvc,
|
|
2485
|
+
title: '',
|
|
2486
|
+
type: 'date',
|
|
2487
|
+
style: inputStyle,
|
|
2488
|
+
default: `${voucherData.startDate}`,
|
|
2489
|
+
placeHolder: '',
|
|
2490
|
+
callback: text => {
|
|
2491
|
+
voucherData.startDate = text;
|
|
2492
|
+
},
|
|
2493
|
+
})}
|
|
2494
|
+
</div>
|
|
2495
|
+
<div class="d-flex align-items-center">
|
|
2496
|
+
<span class="tx_normal me-2">開始時間</span>
|
|
2497
|
+
${BgWidget.editeInput({
|
|
2498
|
+
gvc: gvc,
|
|
2499
|
+
title: '',
|
|
2500
|
+
type: 'time',
|
|
2501
|
+
style: inputStyle,
|
|
2502
|
+
default: `${voucherData.startTime}`,
|
|
2503
|
+
placeHolder: '',
|
|
2504
|
+
callback: text => {
|
|
2505
|
+
voucherData.startTime = text;
|
|
2506
|
+
},
|
|
2507
|
+
})}
|
|
2508
|
+
</div>
|
|
2509
|
+
</div>
|
|
2510
|
+
${BgWidget.multiCheckboxContainer(gvc, [
|
|
2511
|
+
{
|
|
2512
|
+
key: 'noEnd',
|
|
2513
|
+
name: '無期限',
|
|
2514
|
+
},
|
|
2515
|
+
{
|
|
2516
|
+
key: 'withEnd',
|
|
2517
|
+
name: '有效期限',
|
|
2518
|
+
innerHtml: html ` <div
|
|
2519
|
+
class="d-flex mt-0 mt-md-3 ${document.body.clientWidth < 768 ? 'flex-column' : ''}"
|
|
2520
|
+
style="gap: 12px"
|
|
2521
|
+
>
|
|
2522
|
+
<div class="d-flex align-items-center">
|
|
2523
|
+
<span class="tx_normal me-2">結束日期</span>
|
|
2524
|
+
${BgWidget.editeInput({
|
|
2525
|
+
gvc: gvc,
|
|
2526
|
+
title: '',
|
|
2527
|
+
type: 'date',
|
|
2528
|
+
style: inputStyle,
|
|
2529
|
+
default: `${voucherData.endDate}`,
|
|
2530
|
+
placeHolder: '',
|
|
2531
|
+
callback: text => {
|
|
2532
|
+
voucherData.endDate = text;
|
|
2533
|
+
},
|
|
2534
|
+
})}
|
|
2535
|
+
</div>
|
|
2536
|
+
<div class="d-flex align-items-center">
|
|
2537
|
+
<span class="tx_normal me-2">結束時間</span>
|
|
2538
|
+
${BgWidget.editeInput({
|
|
2539
|
+
gvc: gvc,
|
|
2540
|
+
title: '',
|
|
2541
|
+
type: 'time',
|
|
2542
|
+
style: inputStyle,
|
|
2543
|
+
default: `${voucherData.endTime}`,
|
|
2544
|
+
placeHolder: '',
|
|
2545
|
+
callback: text => {
|
|
2546
|
+
voucherData.endTime = text;
|
|
2547
|
+
},
|
|
2548
|
+
})}
|
|
2549
|
+
</div>
|
|
2550
|
+
</div>`,
|
|
2551
|
+
},
|
|
2552
|
+
], [voucherData.endDate ? `withEnd` : `noEnd`], text => {
|
|
2553
|
+
if (text[0] === 'noEnd') {
|
|
2554
|
+
voucherData.endDate = undefined;
|
|
2555
|
+
voucherData.endTime = undefined;
|
|
2556
|
+
}
|
|
2557
|
+
}, { single: true })}`;
|
|
2558
|
+
}
|
|
2559
|
+
function rebateEndDay() {
|
|
2560
|
+
var _b, _c;
|
|
2561
|
+
if (voucherData.reBackType !== 'rebate') {
|
|
2562
|
+
return '';
|
|
2563
|
+
}
|
|
2564
|
+
const inputStyle = 'display: block; width: 200px;';
|
|
2565
|
+
return BgWidget.multiCheckboxContainer(gvc, [
|
|
2566
|
+
{
|
|
2567
|
+
key: 'noEnd',
|
|
2568
|
+
name: '無期限',
|
|
2569
|
+
},
|
|
2570
|
+
{
|
|
2571
|
+
key: 'withEnd',
|
|
2572
|
+
name: '有效期限',
|
|
2573
|
+
innerHtml: html ` <div
|
|
2574
|
+
class="d-flex mt-0 mt-md-3 ${document.body.clientWidth < 768 ? 'flex-column' : ''}"
|
|
2575
|
+
style="gap: 12px"
|
|
2576
|
+
>
|
|
2577
|
+
<div class="d-flex align-items-center" style="gap:10px;">
|
|
2578
|
+
${BgWidget.editeInput({
|
|
2579
|
+
gvc: gvc,
|
|
2580
|
+
title: '',
|
|
2581
|
+
type: 'number',
|
|
2582
|
+
style: inputStyle,
|
|
2583
|
+
default: `${(_b = voucherData.rebateEndDay) !== null && _b !== void 0 ? _b : ''}`,
|
|
2584
|
+
placeHolder: '0則為無期限',
|
|
2585
|
+
callback: text => {
|
|
2586
|
+
voucherData.rebateEndDay = text;
|
|
2587
|
+
gvc.notifyDataChange(pageVM.viewID);
|
|
2588
|
+
},
|
|
2589
|
+
})}
|
|
2590
|
+
<span class="tx_normal me-2">天</span>
|
|
2591
|
+
</div>
|
|
2592
|
+
</div>`,
|
|
2593
|
+
},
|
|
2594
|
+
], [parseInt((_c = voucherData.rebateEndDay) !== null && _c !== void 0 ? _c : '0', 10) ? `withEnd` : `noEnd`], text => {
|
|
2595
|
+
if (text[0] === 'noEnd') {
|
|
2596
|
+
voucherData.rebateEndDay = '0';
|
|
2597
|
+
}
|
|
2598
|
+
}, { single: true });
|
|
2599
|
+
}
|
|
2600
|
+
function overlay() {
|
|
2601
|
+
return BgWidget.multiCheckboxContainer(gvc, [
|
|
2602
|
+
{
|
|
2603
|
+
key: 'false',
|
|
2604
|
+
name: '不可疊加',
|
|
2605
|
+
innerHtml: BgWidget.grayNote('系統將以最大優惠排序進行判定'),
|
|
2606
|
+
},
|
|
2607
|
+
{
|
|
2608
|
+
key: 'true',
|
|
2609
|
+
name: '可以疊加',
|
|
2610
|
+
},
|
|
2611
|
+
], [voucherData.overlay ? 'true' : 'false'], text => {
|
|
2612
|
+
voucherData.overlay = text[0] === 'true';
|
|
2613
|
+
gvc.notifyDataChange(pageVM.viewID);
|
|
2614
|
+
}, { single: true });
|
|
2615
|
+
}
|
|
2616
|
+
function offStart() {
|
|
2617
|
+
const bool = voucherData.method === 'percent' &&
|
|
2618
|
+
voucherData.conditionType === 'order' &&
|
|
2619
|
+
voucherData.rule === 'min_count' &&
|
|
2620
|
+
voucherData.reBackType === 'discount';
|
|
2621
|
+
if (!bool) {
|
|
2622
|
+
return '';
|
|
2623
|
+
}
|
|
2624
|
+
return BgWidget.multiCheckboxContainer(gvc, [
|
|
2625
|
+
{
|
|
2626
|
+
key: 'price_desc',
|
|
2627
|
+
name: '從最高價的商品打折',
|
|
2628
|
+
innerHtml: BgWidget.grayNote(`購物車訂單將會從最高價且符合優惠的${ruleText(ruleValue)}商品進行打折`),
|
|
2629
|
+
},
|
|
2630
|
+
{
|
|
2631
|
+
key: 'price_asc',
|
|
2632
|
+
name: '從最低價的商品打折',
|
|
2633
|
+
innerHtml: BgWidget.grayNote(`購物車訂單將會從最低價且符合優惠的${ruleText(ruleValue)}商品進行打折`),
|
|
2634
|
+
},
|
|
2635
|
+
{
|
|
2636
|
+
key: 'price_all',
|
|
2637
|
+
name: '符合優惠的商品全部打折',
|
|
2638
|
+
innerHtml: BgWidget.grayNote(`購物車訂單符合優惠的商品進行打折`),
|
|
2639
|
+
},
|
|
2640
|
+
], [voucherData.productOffStart], text => {
|
|
2641
|
+
voucherData.productOffStart = text[0];
|
|
2642
|
+
gvc.notifyDataChange(pageVM.viewID);
|
|
2643
|
+
}, {
|
|
2644
|
+
single: true,
|
|
2645
|
+
});
|
|
2646
|
+
}
|
|
2647
|
+
function isIncludeDiscount() {
|
|
2648
|
+
if (!voucherData.overlay) {
|
|
2649
|
+
return '';
|
|
2650
|
+
}
|
|
2651
|
+
return BgWidget.multiCheckboxContainer(gvc, [
|
|
2652
|
+
{
|
|
2653
|
+
key: 'before',
|
|
2654
|
+
name: '觸發前',
|
|
2655
|
+
innerHtml: BgWidget.grayNote('在其他折扣觸發前,訂單的消費金額將做為達成消費條件的金額,來判斷是否可使用此優惠券'),
|
|
2656
|
+
},
|
|
2657
|
+
{
|
|
2658
|
+
key: 'after',
|
|
2659
|
+
name: '觸發後',
|
|
2660
|
+
innerHtml: BgWidget.grayNote('將訂單的消費金額包含其他折扣後,做為達成消費條件的金額,來判斷是否可使用此優惠券'),
|
|
2661
|
+
},
|
|
2662
|
+
], [voucherData.includeDiscount], text => {
|
|
2663
|
+
voucherData.includeDiscount = text[0];
|
|
2664
|
+
gvc.notifyDataChange(pageVM.viewID);
|
|
2665
|
+
}, {
|
|
2666
|
+
single: true,
|
|
2667
|
+
});
|
|
2668
|
+
}
|
|
2669
|
+
function countingBoolean() {
|
|
2670
|
+
if (voucherData.method === 'percent' || voucherData.reBackType === 'shipment_free') {
|
|
2671
|
+
return '';
|
|
2672
|
+
}
|
|
2673
|
+
return BgWidget.multiCheckboxContainer(gvc, [
|
|
2674
|
+
{
|
|
2675
|
+
key: 'single',
|
|
2676
|
+
name: '不重複',
|
|
2677
|
+
innerHtml: BgWidget.grayNote(`購買${ruleText(ruleValue)}折Y元,額外購買至${ruleText(ruleValue * 2)}或${ruleText(ruleValue * 3)}依然是折Y元`),
|
|
2678
|
+
},
|
|
2679
|
+
{
|
|
2680
|
+
key: 'each',
|
|
2681
|
+
name: '重複',
|
|
2682
|
+
innerHtml: BgWidget.grayNote(`購買${ruleText(ruleValue)}折Y元,購買${ruleText(ruleValue * 2)}則折Y * 2元,購買${ruleText(ruleValue * 3)}則折Y * 3元,以此類推`),
|
|
2683
|
+
},
|
|
2684
|
+
], [voucherData.counting], text => {
|
|
2685
|
+
voucherData.counting = text[0];
|
|
2686
|
+
gvc.notifyDataChange(pageVM.viewID);
|
|
2687
|
+
}, {
|
|
2688
|
+
single: true,
|
|
2689
|
+
});
|
|
2690
|
+
}
|
|
2691
|
+
function conditionType() {
|
|
2692
|
+
return BgWidget.multiCheckboxContainer(gvc, [
|
|
2693
|
+
{
|
|
2694
|
+
key: 'order',
|
|
2695
|
+
name: '以整份訂單計算',
|
|
2696
|
+
innerHtml: BgWidget.grayNote((() => {
|
|
2697
|
+
if (voucherData.reBackType === 'shipment_free') {
|
|
2698
|
+
return '優惠條件為整份訂單免運費';
|
|
2699
|
+
}
|
|
2700
|
+
return `若商品A購買${ruleText(floor)},加上商品B購買${ruleText(ruleValue - floor)},可觸發優惠`;
|
|
2701
|
+
})()),
|
|
2702
|
+
},
|
|
2703
|
+
{
|
|
2704
|
+
key: 'item',
|
|
2705
|
+
name: '以商品計算',
|
|
2706
|
+
innerHtml: BgWidget.grayNote(`需要商品A購買滿${ruleText(ruleValue)},或商品B購買滿${ruleText(ruleValue)},即可觸發優惠<br/>若商品A購買${ruleText(floor)},加上商品B購買${ruleText(ruleValue - floor)},無法觸發優惠`),
|
|
2707
|
+
},
|
|
2708
|
+
], [voucherData.conditionType], text => {
|
|
2709
|
+
voucherData.conditionType = text[0];
|
|
2710
|
+
gvc.notifyDataChange(pageVM.viewID);
|
|
2711
|
+
}, {
|
|
2712
|
+
single: true,
|
|
2713
|
+
readonly: voucherData.reBackType === 'shipment_free',
|
|
2714
|
+
});
|
|
2715
|
+
}
|
|
2716
|
+
function method() {
|
|
2717
|
+
if (['shipment_free', 'add_on_items', 'giveaway'].includes(voucherData.reBackType)) {
|
|
2718
|
+
return '';
|
|
2719
|
+
}
|
|
2720
|
+
return BgWidget.multiCheckboxContainer(gvc, [
|
|
2721
|
+
{
|
|
2722
|
+
key: 'fixed',
|
|
2723
|
+
name: '固定金額',
|
|
2724
|
+
innerHtml: valueInput({ startText: '$' }),
|
|
2725
|
+
},
|
|
2726
|
+
{
|
|
2727
|
+
key: 'percent',
|
|
2728
|
+
name: '百分比',
|
|
2729
|
+
innerHtml: valueInput({ endText: '%' }),
|
|
2730
|
+
},
|
|
2731
|
+
], [voucherData.method], text => {
|
|
2732
|
+
voucherData.value = '0';
|
|
2733
|
+
voucherData.method = text[0];
|
|
2734
|
+
gvc.notifyDataChange(pageVM.viewID);
|
|
2735
|
+
}, { single: true });
|
|
2736
|
+
}
|
|
2737
|
+
function conditionInput(text) {
|
|
2738
|
+
var _b;
|
|
2739
|
+
return BgWidget.editeInput({
|
|
2740
|
+
gvc: gvc,
|
|
2741
|
+
title: '',
|
|
2742
|
+
divStyle: 'width: 150px;',
|
|
2743
|
+
default: `${(_b = voucherData.ruleValue) !== null && _b !== void 0 ? _b : 0}`,
|
|
2744
|
+
placeHolder: '',
|
|
2745
|
+
callback: value => {
|
|
2746
|
+
voucherData.ruleValue = parseInt(value, 10);
|
|
2747
|
+
gvc.notifyDataChange(pageVM.viewID);
|
|
2748
|
+
},
|
|
2749
|
+
endText: text,
|
|
2750
|
+
});
|
|
2751
|
+
}
|
|
2752
|
+
function rule() {
|
|
2753
|
+
return BgWidget.multiCheckboxContainer(gvc, [
|
|
2754
|
+
{
|
|
2755
|
+
key: 'min_price',
|
|
2756
|
+
name: '最低消費金額',
|
|
2757
|
+
innerHtml: conditionInput('元'),
|
|
2758
|
+
},
|
|
2759
|
+
{
|
|
2760
|
+
key: 'min_count',
|
|
2761
|
+
name: '最少購買數量',
|
|
2762
|
+
innerHtml: conditionInput('個'),
|
|
2763
|
+
},
|
|
2764
|
+
], [voucherData.rule], text => {
|
|
2765
|
+
voucherData.ruleValue = 0;
|
|
2766
|
+
voucherData.rule = text[0];
|
|
2767
|
+
gvc.notifyDataChange(pageVM.viewID);
|
|
2768
|
+
}, { single: true });
|
|
2769
|
+
}
|
|
2770
|
+
function ruleText(sum) {
|
|
2771
|
+
return `${sum}${voucherData.rule === 'min_count' ? '個' : '元'}`;
|
|
2772
|
+
}
|
|
2773
|
+
function valueInput(obj) {
|
|
2774
|
+
return BgWidget.editeInput({
|
|
2775
|
+
gvc: gvc,
|
|
2776
|
+
type: 'number',
|
|
2777
|
+
divStyle: 'width: 150px;',
|
|
2778
|
+
title: '',
|
|
2779
|
+
default: voucherData.value,
|
|
2780
|
+
placeHolder: '',
|
|
2781
|
+
callback: text => {
|
|
2782
|
+
const texInt = parseInt(text, 10);
|
|
2783
|
+
if (voucherData.method === 'percent' && (texInt > 100 || texInt < 0)) {
|
|
2784
|
+
dialog.infoMessage({ text: '數值需介於0~100' });
|
|
2785
|
+
gvc.notifyDataChange(pageVM.viewID);
|
|
2786
|
+
}
|
|
2787
|
+
else {
|
|
2788
|
+
voucherData.value = text;
|
|
2789
|
+
}
|
|
2790
|
+
},
|
|
2791
|
+
startText: obj.startText,
|
|
2792
|
+
endText: obj.endText,
|
|
2793
|
+
});
|
|
2794
|
+
}
|
|
2795
|
+
const reBackProductView = {
|
|
2796
|
+
rebate: { title: '活動商品', html: voucherData.for === 'all' ? '' : selectProduct() },
|
|
2797
|
+
discount: { title: '活動商品', html: voucherData.for === 'all' ? '' : selectProduct() },
|
|
2798
|
+
shipment_free: { title: '活動商品', html: '' },
|
|
2799
|
+
add_on_items: { title: '加購品項', html: addProductView() },
|
|
2800
|
+
giveaway: { title: '贈品品項', html: addProductView() },
|
|
2801
|
+
};
|
|
2802
|
+
const viewList = [
|
|
2803
|
+
[
|
|
2804
|
+
{ title: '活動設定', html: [status(), title()] },
|
|
2805
|
+
{ title: '折扣方式', html: trigger() },
|
|
2806
|
+
{ title: '適用訂單類型', html: device() },
|
|
2807
|
+
],
|
|
2808
|
+
[
|
|
2809
|
+
{ title: '折扣設定', html: method() },
|
|
2810
|
+
{ title: '使用條件', html: rule() },
|
|
2811
|
+
],
|
|
2812
|
+
[
|
|
2813
|
+
{ title: '活動對象', html: target() },
|
|
2814
|
+
{ title: '優惠套用至', html: setVoucherFor() },
|
|
2815
|
+
reBackProductView[voucherData.reBackType],
|
|
2816
|
+
{ title: '可使用物流', html: selectShipment() },
|
|
2817
|
+
],
|
|
2818
|
+
[
|
|
2819
|
+
{ title: '計算單位', html: conditionType() },
|
|
2820
|
+
{ title: '打折範圍', html: offStart() },
|
|
2821
|
+
{ title: '重複觸發', html: countingBoolean() },
|
|
2822
|
+
{ title: '是否與其他優惠券疊加使用', html: overlay() },
|
|
2823
|
+
{ title: '消費金額於其他折扣觸發時機', html: isIncludeDiscount() },
|
|
2824
|
+
],
|
|
2825
|
+
[
|
|
2826
|
+
{ title: '全館總使用次數', html: storeUseTimeLimit() },
|
|
2827
|
+
{ title: '個人總使用次數', html: memberUseTimeLimit() },
|
|
2828
|
+
{ title: '購物金有效天數', html: rebateEndDay() },
|
|
2829
|
+
{ title: '優惠卷有效日期', html: startDateTime() },
|
|
2830
|
+
],
|
|
2831
|
+
];
|
|
2832
|
+
return BgWidget.container([
|
|
2833
|
+
html ` <div class="title-container">
|
|
2834
|
+
${[
|
|
2835
|
+
BgWidget.goBack(gvc.event(() => {
|
|
2836
|
+
vm.type = 'list';
|
|
2837
|
+
})),
|
|
2838
|
+
BgWidget.title(`${obj.type === 'add' ? '新增' : '編輯'}${ShoppingDiscountSetting.getLabel(obj.reBackType)}`),
|
|
2839
|
+
].join('')}
|
|
2840
|
+
</div>`,
|
|
2841
|
+
BgWidget.container1x2({
|
|
2842
|
+
html: viewList
|
|
2843
|
+
.map(viewData => {
|
|
2844
|
+
return voucherSettingCard(viewData.map(view => {
|
|
2845
|
+
if (!view.html) {
|
|
2846
|
+
return [];
|
|
2847
|
+
}
|
|
2848
|
+
else if (Array.isArray(view.html)) {
|
|
2849
|
+
return [setTitle(view.title), ...view.html];
|
|
2850
|
+
}
|
|
2851
|
+
else {
|
|
2852
|
+
return [setTitle(view.title), view.html];
|
|
2853
|
+
}
|
|
2854
|
+
}));
|
|
2855
|
+
})
|
|
2856
|
+
.join(BgWidget.mbContainer(24)),
|
|
2857
|
+
ratio: 68,
|
|
2858
|
+
}, {
|
|
2859
|
+
html: gvc.bindView({
|
|
2860
|
+
bind: getUUID(),
|
|
2861
|
+
dataList: Object.keys(voucherData).map(key => ({ obj: voucherData, key })),
|
|
2862
|
+
view: () => {
|
|
2863
|
+
const getSummary = this.summaryTextList(voucherData)
|
|
2864
|
+
.map(text => {
|
|
2865
|
+
const className = text.length > 0 ? 'tx_normal' : 'gray-top-bottom-line-6';
|
|
2866
|
+
return html `<div class="${className}">${text}</div>`;
|
|
2867
|
+
})
|
|
2868
|
+
.join('');
|
|
2869
|
+
return BgWidget.mainCard([
|
|
2870
|
+
setTitle('摘要'),
|
|
2871
|
+
BgWidget.mbContainer(18),
|
|
2872
|
+
html `<div style="display: flex; gap: 12px; flex-direction: column;">${getSummary}</div>`,
|
|
2873
|
+
].join(''));
|
|
2874
|
+
},
|
|
2875
|
+
divCreate: {
|
|
2876
|
+
class: 'summary-card p-0',
|
|
2877
|
+
},
|
|
2878
|
+
}),
|
|
2879
|
+
ratio: 32,
|
|
2880
|
+
}),
|
|
2881
|
+
BgWidget.mbContainer(240),
|
|
2882
|
+
html ` <div class="update-bar-container">
|
|
2883
|
+
${obj.type === 'replace'
|
|
2884
|
+
? BgWidget.cancel(gvc.event(() => {
|
|
2885
|
+
dialog.checkYesOrNot({
|
|
2886
|
+
text: '是否確認刪除優惠券?',
|
|
2887
|
+
callback: response => {
|
|
2888
|
+
if (response) {
|
|
2889
|
+
const id = voucherData.id;
|
|
2890
|
+
dialog.dataLoading({ visible: true });
|
|
2891
|
+
ApiShop.deleteVoucher({ id }).then(res => {
|
|
2892
|
+
dialog.dataLoading({ visible: false });
|
|
2893
|
+
if (res.result) {
|
|
2894
|
+
vm.type = 'list';
|
|
2895
|
+
}
|
|
2896
|
+
else {
|
|
2897
|
+
dialog.errorMessage({ text: '刪除失敗' });
|
|
2898
|
+
}
|
|
2899
|
+
});
|
|
2900
|
+
}
|
|
2901
|
+
},
|
|
2902
|
+
});
|
|
2903
|
+
}), '刪除優惠券')
|
|
2904
|
+
: ''}
|
|
2905
|
+
${BgWidget.cancel(gvc.event(() => {
|
|
2906
|
+
vm.type = 'list';
|
|
2907
|
+
}))}
|
|
2908
|
+
${BgWidget.save(gvc.event(() => {
|
|
2909
|
+
voucherData.start_ISO_Date = '';
|
|
2910
|
+
voucherData.end_ISO_Date = '';
|
|
2911
|
+
glitter.ut.tryMethod([
|
|
2912
|
+
() => {
|
|
2913
|
+
voucherData.start_ISO_Date = new Date(`${voucherData.startDate} ${voucherData.startTime}`).toISOString();
|
|
2914
|
+
},
|
|
2915
|
+
() => {
|
|
2916
|
+
voucherData.end_ISO_Date = new Date(`${voucherData.endDate} ${voucherData.endTime}`).toISOString();
|
|
2917
|
+
},
|
|
2918
|
+
]);
|
|
2919
|
+
const requestBody = {
|
|
2920
|
+
postData: voucherData,
|
|
2921
|
+
token: window.parent.saasConfig.config.token,
|
|
2922
|
+
type: 'manager',
|
|
2923
|
+
};
|
|
2924
|
+
function responseEvent(res) {
|
|
2925
|
+
dialog.dataLoading({ visible: false });
|
|
2926
|
+
if (res.result) {
|
|
2927
|
+
vm.type = 'list';
|
|
2928
|
+
dialog.successMessage({ text: '上傳成功' });
|
|
2929
|
+
}
|
|
2930
|
+
else {
|
|
2931
|
+
dialog.errorMessage({ text: '上傳失敗' });
|
|
2932
|
+
}
|
|
2933
|
+
}
|
|
2934
|
+
if (obj.type === 'replace') {
|
|
2935
|
+
dialog.dataLoading({ text: '正在更新優惠券', visible: true });
|
|
2936
|
+
ApiShop.putVoucher(requestBody).then(res => responseEvent(res));
|
|
2937
|
+
}
|
|
2938
|
+
else {
|
|
2939
|
+
dialog.dataLoading({ text: '正在新增優惠券', visible: true });
|
|
2940
|
+
ApiShop.postVoucher(requestBody).then(res => responseEvent(res));
|
|
2941
|
+
}
|
|
2942
|
+
}))}
|
|
2943
|
+
</div>`,
|
|
2944
|
+
].join(BgWidget.mbContainer(24)));
|
|
2945
|
+
},
|
|
2946
|
+
});
|
|
2947
|
+
}
|
|
1613
2948
|
}
|
|
2949
|
+
_a = ShoppingDiscountSetting;
|
|
1614
2950
|
ShoppingDiscountSetting.getDateTime = (n = 0) => {
|
|
1615
2951
|
const now = new Date();
|
|
1616
2952
|
now.setDate(now.getDate() + n);
|
|
@@ -1628,4 +2964,38 @@ ShoppingDiscountSetting.productForList = [
|
|
|
1628
2964
|
{ title: '管理員標籤', value: 'manager_tag' },
|
|
1629
2965
|
{ title: '特定商品', value: 'product' },
|
|
1630
2966
|
];
|
|
2967
|
+
ShoppingDiscountSetting.emptyVoucher = (reBackType) => {
|
|
2968
|
+
return {
|
|
2969
|
+
title: '',
|
|
2970
|
+
code: '',
|
|
2971
|
+
trigger: 'auto',
|
|
2972
|
+
method: 'fixed',
|
|
2973
|
+
value: '0',
|
|
2974
|
+
for: 'all',
|
|
2975
|
+
forKey: [],
|
|
2976
|
+
device: ['normal'],
|
|
2977
|
+
rule: 'min_price',
|
|
2978
|
+
ruleValue: 1000,
|
|
2979
|
+
startDate: _a.getDateTime().date,
|
|
2980
|
+
startTime: _a.getDateTime().time,
|
|
2981
|
+
endDate: undefined,
|
|
2982
|
+
endTime: undefined,
|
|
2983
|
+
status: 1,
|
|
2984
|
+
type: 'voucher',
|
|
2985
|
+
overlay: false,
|
|
2986
|
+
start_ISO_Date: '',
|
|
2987
|
+
end_ISO_Date: '',
|
|
2988
|
+
reBackType: reBackType,
|
|
2989
|
+
rebateEndDay: '30',
|
|
2990
|
+
target: 'all',
|
|
2991
|
+
targetList: [],
|
|
2992
|
+
macroLimited: 0,
|
|
2993
|
+
microLimited: 0,
|
|
2994
|
+
counting: 'single',
|
|
2995
|
+
conditionType: 'order',
|
|
2996
|
+
includeDiscount: 'before',
|
|
2997
|
+
productOffStart: 'price_desc',
|
|
2998
|
+
selectShipment: { type: 'all', list: [] },
|
|
2999
|
+
};
|
|
3000
|
+
};
|
|
1631
3001
|
window.glitter.setModule(import.meta.url, ShoppingDiscountSetting);
|