ts-glitter 16.1.8 → 16.2.0
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-widget.js +7 -0
- package/lowcode/backend-manager/bg-widget.ts +7 -0
- package/lowcode/cms-plugin/module/order-setting.js +261 -0
- package/lowcode/cms-plugin/module/order-setting.ts +302 -0
- package/lowcode/cms-plugin/module/product-excel.js +12 -7
- package/lowcode/cms-plugin/module/product-excel.ts +17 -14
- package/lowcode/cms-plugin/module/product-setting.js +1 -1
- package/lowcode/cms-plugin/module/product-setting.ts +1 -1
- package/lowcode/cms-plugin/shopping-order-manager.js +96 -36
- package/lowcode/cms-plugin/shopping-order-manager.ts +113 -54
- package/lowcode/cms-plugin/shopping-product-setting.js +17 -26
- package/lowcode/cms-plugin/shopping-product-setting.ts +18 -26
- package/lowcode/cms-plugin/stock-history.js +649 -103
- package/lowcode/cms-plugin/stock-history.ts +748 -123
- package/lowcode/css/editor.css +30 -1
- package/lowcode/glitter-base/route/stock.js +12 -0
- package/lowcode/glitter-base/route/stock.ts +14 -1
- package/package.json +1 -1
- package/src/api-public/controllers/ai-chat.js.map +1 -1
- package/src/api-public/controllers/app-release.js.map +1 -1
- package/src/api-public/controllers/article.js.map +1 -1
- package/src/api-public/controllers/post.js.map +1 -1
- package/src/api-public/controllers/stock.js +13 -0
- package/src/api-public/controllers/stock.js.map +1 -1
- package/src/api-public/controllers/stock.ts +12 -0
- package/src/api-public/controllers/user.js.map +1 -1
- package/src/api-public/services/ai-robot.js.map +1 -1
- package/src/api-public/services/delivery.js.map +1 -1
- package/src/api-public/services/post.js.map +1 -1
- package/src/api-public/services/public-table-check.js.map +1 -1
- package/src/api-public/services/recommend.js.map +1 -1
- package/src/api-public/services/schedule.js.map +1 -1
- package/src/api-public/services/shopping.js +31 -8
- package/src/api-public/services/shopping.js.map +1 -1
- package/src/api-public/services/shopping.ts +48 -12
- package/src/api-public/services/stock.d.ts +4 -0
- package/src/api-public/services/stock.js +58 -6
- package/src/api-public/services/stock.js.map +1 -1
- package/src/api-public/services/stock.ts +78 -6
- package/src/index.js +82 -61
- package/src/index.js.map +1 -1
- package/src/index.ts +210 -178
- package/src/services/app.js +1 -2
- package/src/services/app.js.map +1 -1
- package/src/services/app.ts +2 -2
package/lowcode/Entry.js
CHANGED
|
@@ -79,7 +79,7 @@ export class Entry {
|
|
|
79
79
|
}
|
|
80
80
|
window.renderClock = (_a = window.renderClock) !== null && _a !== void 0 ? _a : clockF();
|
|
81
81
|
console.log(`Entry-time:`, window.renderClock.stop());
|
|
82
|
-
glitter.share.editerVersion = 'V_16.
|
|
82
|
+
glitter.share.editerVersion = 'V_16.2.0';
|
|
83
83
|
glitter.share.start = new Date();
|
|
84
84
|
const vm = {
|
|
85
85
|
appConfig: [],
|
package/lowcode/Entry.ts
CHANGED
|
@@ -78,7 +78,7 @@ export class Entry {
|
|
|
78
78
|
}
|
|
79
79
|
(window as any).renderClock = (window as any).renderClock ?? clockF();
|
|
80
80
|
console.log(`Entry-time:`, (window as any).renderClock.stop());
|
|
81
|
-
glitter.share.editerVersion = 'V_16.
|
|
81
|
+
glitter.share.editerVersion = 'V_16.2.0';
|
|
82
82
|
glitter.share.start = new Date();
|
|
83
83
|
const vm: {
|
|
84
84
|
appConfig: any;
|
|
@@ -111,6 +111,13 @@ export class BgWidget {
|
|
|
111
111
|
</button>
|
|
112
112
|
`;
|
|
113
113
|
}
|
|
114
|
+
static disableButton(text, obj) {
|
|
115
|
+
var _a;
|
|
116
|
+
return html ` <button class="btn btn-gray-disable" style="" type="button">
|
|
117
|
+
<i class="${obj && obj.icon && obj.icon.length > 0 ? obj.icon : 'd-none'}" style="color: #393939"></i>
|
|
118
|
+
${text.length > 0 ? html `<span class="tx_700" style="${(_a = obj === null || obj === void 0 ? void 0 : obj.textStyle) !== null && _a !== void 0 ? _a : ''}">${text}</span>` : ''}
|
|
119
|
+
</button>`;
|
|
120
|
+
}
|
|
114
121
|
static grayButton(text, event, obj) {
|
|
115
122
|
var _a;
|
|
116
123
|
return html ` <button class="btn btn-gray" style="" type="button" onclick="${event}">
|
|
@@ -175,6 +175,13 @@ export class BgWidget {
|
|
|
175
175
|
`;
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
+
static disableButton(text: string, obj?: { icon?: string; textStyle?: string }) {
|
|
179
|
+
return html` <button class="btn btn-gray-disable" style="" type="button">
|
|
180
|
+
<i class="${obj && obj.icon && obj.icon.length > 0 ? obj.icon : 'd-none'}" style="color: #393939"></i>
|
|
181
|
+
${text.length > 0 ? html`<span class="tx_700" style="${obj?.textStyle ?? ''}">${text}</span>` : ''}
|
|
182
|
+
</button>`;
|
|
183
|
+
}
|
|
184
|
+
|
|
178
185
|
static grayButton(text: string, event: string, obj?: { icon?: string; textStyle?: string }) {
|
|
179
186
|
return html` <button class="btn btn-gray" style="" type="button" onclick="${event}">
|
|
180
187
|
<i class="${obj && obj.icon && obj.icon.length > 0 ? obj.icon : 'd-none'}" style="color: #393939"></i>
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { BgWidget } from "../../backend-manager/bg-widget.js";
|
|
2
|
+
import { ApiUser } from "../../glitter-base/route/user.js";
|
|
3
|
+
import { ShareDialog } from "../../dialog/ShareDialog.js";
|
|
4
|
+
import { ApiShop } from "../../glitter-base/route/shopping.js";
|
|
5
|
+
export class OrderSetting {
|
|
6
|
+
static showEditShip(obj) {
|
|
7
|
+
let stockList = [];
|
|
8
|
+
function getPreviewImage(img) {
|
|
9
|
+
return img || BgWidget.noImageURL;
|
|
10
|
+
}
|
|
11
|
+
const html = String.raw;
|
|
12
|
+
let loading = true;
|
|
13
|
+
let productLoading = true;
|
|
14
|
+
let postMD = obj.postMD;
|
|
15
|
+
let productData = {};
|
|
16
|
+
let topGVC = window.parent.glitter.pageConfig[window.parent.glitter.pageConfig.length - 1].gvc;
|
|
17
|
+
const dialog = new ShareDialog(obj.gvc.glitter);
|
|
18
|
+
topGVC.glitter.innerDialog((gvc) => {
|
|
19
|
+
function getStockStore() {
|
|
20
|
+
if (stockList.length == 0) {
|
|
21
|
+
ApiUser.getPublicConfig('store_manager', 'manager').then((storeData) => {
|
|
22
|
+
if (storeData.result) {
|
|
23
|
+
stockList = storeData.response.value.list;
|
|
24
|
+
loading = false;
|
|
25
|
+
if (!loading && !productLoading) {
|
|
26
|
+
gvc.notifyDataChange('editDialog');
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
ApiShop.getProduct({
|
|
32
|
+
limit: 99,
|
|
33
|
+
page: 0,
|
|
34
|
+
productType: "all",
|
|
35
|
+
id_list: postMD.map((dd) => {
|
|
36
|
+
return dd.id;
|
|
37
|
+
})
|
|
38
|
+
}).then(r => {
|
|
39
|
+
productLoading = false;
|
|
40
|
+
productData = r.response.data;
|
|
41
|
+
if (!loading && !productLoading) {
|
|
42
|
+
gvc.notifyDataChange('editDialog');
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
let dialog = new ShareDialog(topGVC.glitter);
|
|
47
|
+
let origData = JSON.parse(JSON.stringify(postMD));
|
|
48
|
+
getStockStore();
|
|
49
|
+
let selected = [];
|
|
50
|
+
return gvc.bindView({
|
|
51
|
+
bind: "editDialog",
|
|
52
|
+
view: () => {
|
|
53
|
+
const titleLength = 250;
|
|
54
|
+
const elementLength = 100;
|
|
55
|
+
if (loading && productLoading) {
|
|
56
|
+
dialog.dataLoading({
|
|
57
|
+
visible: true
|
|
58
|
+
});
|
|
59
|
+
return ``;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
dialog.dataLoading({
|
|
63
|
+
visible: false
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
if (!productLoading) {
|
|
67
|
+
postMD.map((dd) => {
|
|
68
|
+
const product = productData.find((product) => {
|
|
69
|
+
return product.id == dd.id;
|
|
70
|
+
});
|
|
71
|
+
if (product) {
|
|
72
|
+
const variant = product.content.variants.find((variant) => {
|
|
73
|
+
return JSON.stringify(variant.spec) == JSON.stringify(dd.spec);
|
|
74
|
+
});
|
|
75
|
+
dd.stockList = variant.stockList;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
return html `
|
|
80
|
+
<div class="d-flex flex-column position-relative"
|
|
81
|
+
style="width: 80%;height:70%;background:white;border-radius: 10px;">
|
|
82
|
+
<div class="d-flex align-items-center"
|
|
83
|
+
style="height: 60px;width: 100%;border-bottom: solid 1px #DDD;font-size: 16px;font-style: normal;font-weight: 700;color: #393939;background: #F2F2F2;border-radius: 10px 10px 0px 0px;">
|
|
84
|
+
|
|
85
|
+
<div class="flex-fill"
|
|
86
|
+
style="padding: 19px 32px;">
|
|
87
|
+
分倉出貨
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
<div class="overflow-scroll" style="padding:20px;margin-right:30px;">
|
|
91
|
+
<div class="d-flex "
|
|
92
|
+
style="margin-bottom:16px;gap:44px;position: relative;">
|
|
93
|
+
<div class="d-flex flex-shrink-0 align-items-center "
|
|
94
|
+
style="width:${titleLength}px;font-size: 16px;font-style: normal;font-weight: 700;">
|
|
95
|
+
商品
|
|
96
|
+
</div>
|
|
97
|
+
${(() => {
|
|
98
|
+
let titleArray = [
|
|
99
|
+
{
|
|
100
|
+
title: "下單數量",
|
|
101
|
+
width: `${elementLength}px`
|
|
102
|
+
}, {
|
|
103
|
+
title: "庫存",
|
|
104
|
+
width: `${elementLength}px`
|
|
105
|
+
},
|
|
106
|
+
];
|
|
107
|
+
function insertSubStocks(titleArray, subStocks) {
|
|
108
|
+
const targetIndex = titleArray.findIndex(item => item.title === "庫存");
|
|
109
|
+
if (targetIndex !== -1) {
|
|
110
|
+
const formattedSubStocks = subStocks.map(stockTitle => ({
|
|
111
|
+
title: stockTitle,
|
|
112
|
+
width: titleArray[targetIndex].width
|
|
113
|
+
}));
|
|
114
|
+
titleArray.splice(targetIndex, 1, ...formattedSubStocks);
|
|
115
|
+
}
|
|
116
|
+
return titleArray;
|
|
117
|
+
}
|
|
118
|
+
titleArray = insertSubStocks(titleArray, stockList.flatMap((item) => {
|
|
119
|
+
return [
|
|
120
|
+
html `
|
|
121
|
+
<div class="" style="text-align: center;">
|
|
122
|
+
${item.name}<br>庫存數量
|
|
123
|
+
</div>`,
|
|
124
|
+
html `
|
|
125
|
+
<div class="" style="text-align: center;">
|
|
126
|
+
${item.name}<br>出貨數量
|
|
127
|
+
</div>`
|
|
128
|
+
];
|
|
129
|
+
}));
|
|
130
|
+
return titleArray.map((title) => {
|
|
131
|
+
return html `
|
|
132
|
+
<div class="d-flex flex-shrink-0 align-items-center ${title.title == '下單數量' ? 'justify-content-end' : ''} ${(title.title != '商品' && title.title != '下單數量' ? 'justify-content-center' : '')}"
|
|
133
|
+
style="width:${title.width};font-size: 16px;font-style: normal;font-weight: 700;;${(title.title == '商品' ? 'position:absolute;left: 0;top: 0;' : '')}">
|
|
134
|
+
${title.title}
|
|
135
|
+
</div>
|
|
136
|
+
`;
|
|
137
|
+
}).join('');
|
|
138
|
+
})()}
|
|
139
|
+
</div>
|
|
140
|
+
${(() => {
|
|
141
|
+
const id = topGVC.glitter.getUUID();
|
|
142
|
+
return gvc.bindView({
|
|
143
|
+
bind: id,
|
|
144
|
+
view: () => {
|
|
145
|
+
return postMD.map((item) => {
|
|
146
|
+
if (item.deduction_log && Object.keys(item.deduction_log).length === 0) {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
return html `
|
|
150
|
+
<div class="d-flex align-items-center" style="gap:44px;">
|
|
151
|
+
<div class="d-flex align-items-center flex-shrink-0"
|
|
152
|
+
style="width: ${titleLength}px;gap: 12px">
|
|
153
|
+
<img style="height: 54px;width: 54px;border-radius: 5px;"
|
|
154
|
+
src="${item.preview_image}">
|
|
155
|
+
<div class="d-flex flex-column"
|
|
156
|
+
style="font-size: 16px;">
|
|
157
|
+
<div>${item.title}</div>
|
|
158
|
+
<div style="color: #8D8D8D;font-size: 14px;">
|
|
159
|
+
${(item.spec.length == 0 ? `單一規格` : item.spec.join(`,`))}
|
|
160
|
+
</div>
|
|
161
|
+
<div style="color: #8D8D8D;font-size: 14px;">存貨單位 (SKU):
|
|
162
|
+
${item.sku}
|
|
163
|
+
</div>
|
|
164
|
+
</div>
|
|
165
|
+
</div>
|
|
166
|
+
<div class="d-flex align-items-center justify-content-end flex-shrink-0"
|
|
167
|
+
" style="width: ${elementLength}px;gap: 12px">
|
|
168
|
+
${item.count}
|
|
169
|
+
</div>
|
|
170
|
+
${stockList.flatMap((stock) => {
|
|
171
|
+
var _a, _b, _c, _d, _e, _f;
|
|
172
|
+
const limit = (_c = (_b = (_a = item.stockList) === null || _a === void 0 ? void 0 : _a[stock.id]) === null || _b === void 0 ? void 0 : _b.count) !== null && _c !== void 0 ? _c : 0;
|
|
173
|
+
return [html `
|
|
174
|
+
<div class="d-flex align-items-center justify-content-end flex-shrink-0" style="width: ${elementLength}px;gap: 12px;">
|
|
175
|
+
${parseInt(limit) + (parseInt((_d = item.deduction_log[stock.id]) !== null && _d !== void 0 ? _d : "0"))}
|
|
176
|
+
</div>`,
|
|
177
|
+
html `
|
|
178
|
+
<div class="d-flex align-items-center justify-content-end flex-shrink-0"" style="width: ${elementLength}px;gap: 12px">
|
|
179
|
+
<input class="w-100"
|
|
180
|
+
style="border-radius: 10px;border: 1px solid #DDD;background: #FFF;text-align: center;padding:0 18px;height:40px;"
|
|
181
|
+
max="${limit + ((_e = item.deduction_log[stock.id]) !== null && _e !== void 0 ? _e : 0)}"
|
|
182
|
+
min="0"
|
|
183
|
+
value="${(_f = item.deduction_log[stock.id]) !== null && _f !== void 0 ? _f : 0}"
|
|
184
|
+
type="number"
|
|
185
|
+
onchange="${gvc.event((e) => {
|
|
186
|
+
const previewNum = item.deduction_log[stock.id];
|
|
187
|
+
let still = 0;
|
|
188
|
+
item.deduction_log[stock.id] = 0;
|
|
189
|
+
Object.values(item.deduction_log).forEach((dd) => {
|
|
190
|
+
still += dd;
|
|
191
|
+
});
|
|
192
|
+
still = item.count - still;
|
|
193
|
+
item.deduction_log;
|
|
194
|
+
if (e.value > still) {
|
|
195
|
+
e.value = still;
|
|
196
|
+
}
|
|
197
|
+
item.deduction_log[stock.id] = parseInt(e.value);
|
|
198
|
+
gvc.notifyDataChange('id');
|
|
199
|
+
console.log("item -- ", item);
|
|
200
|
+
})}">
|
|
201
|
+
</div>`];
|
|
202
|
+
}).join('')}
|
|
203
|
+
</div>
|
|
204
|
+
`;
|
|
205
|
+
}).join('');
|
|
206
|
+
}, divCreate: { class: "d-flex flex-column", style: "margin-bottom:80px;gap:12px;" }
|
|
207
|
+
});
|
|
208
|
+
})()}
|
|
209
|
+
</div>
|
|
210
|
+
<div class="w-100 justify-content-end d-flex bg-white"
|
|
211
|
+
style="margin-top:100px;position: absolute;left: 0;bottom: 0;gap:14px;padding-right:24px;padding-bottom:20px;padding-top: 10px;border-radius: 0px 0px 10px 10px;">
|
|
212
|
+
${BgWidget.cancel(gvc.event(() => {
|
|
213
|
+
postMD = origData;
|
|
214
|
+
topGVC.glitter.closeDiaLog();
|
|
215
|
+
}))}
|
|
216
|
+
${BgWidget.save(gvc.event(() => {
|
|
217
|
+
console.log("postMD -- ", postMD);
|
|
218
|
+
let errorProduct = [];
|
|
219
|
+
let pass = true;
|
|
220
|
+
postMD.forEach((data) => {
|
|
221
|
+
let count = 0;
|
|
222
|
+
if (Object.keys(data.deduction_log).length != 0) {
|
|
223
|
+
Object.values(data.deduction_log).forEach((log) => {
|
|
224
|
+
count += log;
|
|
225
|
+
});
|
|
226
|
+
if (count != data.count) {
|
|
227
|
+
pass = false;
|
|
228
|
+
errorProduct.push(data.title + "-" + data.spec.join(','));
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
});
|
|
232
|
+
if (pass) {
|
|
233
|
+
topGVC.glitter.closeDiaLog();
|
|
234
|
+
if (obj.callback) {
|
|
235
|
+
obj.callback();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
dialog.errorMessage({
|
|
240
|
+
text: html `
|
|
241
|
+
<div class="d-flex flex-column">
|
|
242
|
+
出貨數量異常
|
|
243
|
+
</div>
|
|
244
|
+
`
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
}))}
|
|
248
|
+
</div>
|
|
249
|
+
</div>
|
|
250
|
+
`;
|
|
251
|
+
},
|
|
252
|
+
divCreate: {
|
|
253
|
+
style: `width: 100vw;height:100vh;`,
|
|
254
|
+
class: `d-flex align-items-center justify-content-center`
|
|
255
|
+
},
|
|
256
|
+
onCreate: () => {
|
|
257
|
+
}
|
|
258
|
+
});
|
|
259
|
+
}, "batchEdit");
|
|
260
|
+
}
|
|
261
|
+
}
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import {GVC} from "../../glitterBundle/GVController.js";
|
|
2
|
+
import {Variant} from "./product-excel.js";
|
|
3
|
+
import {BgWidget} from "../../backend-manager/bg-widget.js";
|
|
4
|
+
import {Tool} from "../../modules/tool.js";
|
|
5
|
+
import {ApiUser} from "../../glitter-base/route/user.js";
|
|
6
|
+
import {ShareDialog} from "../../dialog/ShareDialog.js";
|
|
7
|
+
import {ApiShop} from "../../glitter-base/route/shopping.js";
|
|
8
|
+
|
|
9
|
+
export class OrderSetting {
|
|
10
|
+
public static showEditShip(obj: {
|
|
11
|
+
gvc: GVC,
|
|
12
|
+
postMD: any,
|
|
13
|
+
callback?: () => void
|
|
14
|
+
}) {
|
|
15
|
+
let stockList: any = [];
|
|
16
|
+
|
|
17
|
+
function getPreviewImage(img?: string) {
|
|
18
|
+
return img || BgWidget.noImageURL;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const html = String.raw;
|
|
22
|
+
|
|
23
|
+
let loading = true;
|
|
24
|
+
let productLoading = true
|
|
25
|
+
let postMD = obj.postMD;
|
|
26
|
+
let productData:any={}
|
|
27
|
+
let topGVC = (window.parent as any).glitter.pageConfig[(window.parent as any).glitter.pageConfig.length - 1].gvc
|
|
28
|
+
const dialog = new ShareDialog(obj.gvc.glitter);
|
|
29
|
+
|
|
30
|
+
topGVC.glitter.innerDialog((gvc: GVC) => {
|
|
31
|
+
|
|
32
|
+
function getStockStore() {
|
|
33
|
+
if (stockList.length == 0) {
|
|
34
|
+
ApiUser.getPublicConfig('store_manager',
|
|
35
|
+
'manager'
|
|
36
|
+
).then((storeData: any) => {
|
|
37
|
+
if (storeData.result) {
|
|
38
|
+
stockList = storeData.response.value.list;
|
|
39
|
+
loading = false;
|
|
40
|
+
if (!loading && !productLoading){
|
|
41
|
+
gvc.notifyDataChange('editDialog');
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
ApiShop.getProduct({
|
|
48
|
+
limit: 99,
|
|
49
|
+
page: 0,
|
|
50
|
+
productType:"all",
|
|
51
|
+
id_list: postMD.map((dd: any) => {
|
|
52
|
+
return dd.id;
|
|
53
|
+
})
|
|
54
|
+
}).then(r => {
|
|
55
|
+
productLoading = false;
|
|
56
|
+
|
|
57
|
+
productData = r.response.data;
|
|
58
|
+
if (!loading && !productLoading){
|
|
59
|
+
gvc.notifyDataChange('editDialog');
|
|
60
|
+
}
|
|
61
|
+
})
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
let dialog = new ShareDialog(topGVC.glitter);
|
|
66
|
+
let origData = JSON.parse(JSON.stringify(postMD))
|
|
67
|
+
getStockStore()
|
|
68
|
+
let selected: any[] = [];
|
|
69
|
+
return gvc.bindView({
|
|
70
|
+
bind: "editDialog",
|
|
71
|
+
view: () => {
|
|
72
|
+
const titleLength = 250;
|
|
73
|
+
const elementLength = 100;
|
|
74
|
+
if (loading && productLoading){
|
|
75
|
+
dialog.dataLoading({
|
|
76
|
+
visible:true
|
|
77
|
+
})
|
|
78
|
+
return ``
|
|
79
|
+
}else {
|
|
80
|
+
dialog.dataLoading({
|
|
81
|
+
visible:false
|
|
82
|
+
})
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (!productLoading){
|
|
86
|
+
postMD.map((dd: any) => {
|
|
87
|
+
const product = productData.find((product: any) => {
|
|
88
|
+
return product.id == dd.id;
|
|
89
|
+
})
|
|
90
|
+
if (product){
|
|
91
|
+
const variant = product.content.variants.find((variant: any) => {
|
|
92
|
+
return JSON.stringify(variant.spec) == JSON.stringify(dd.spec)
|
|
93
|
+
})
|
|
94
|
+
dd.stockList = variant.stockList;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return html`
|
|
103
|
+
<div class="d-flex flex-column position-relative"
|
|
104
|
+
style="width: 80%;height:70%;background:white;border-radius: 10px;">
|
|
105
|
+
<div class="d-flex align-items-center"
|
|
106
|
+
style="height: 60px;width: 100%;border-bottom: solid 1px #DDD;font-size: 16px;font-style: normal;font-weight: 700;color: #393939;background: #F2F2F2;border-radius: 10px 10px 0px 0px;">
|
|
107
|
+
|
|
108
|
+
<div class="flex-fill"
|
|
109
|
+
style="padding: 19px 32px;">
|
|
110
|
+
分倉出貨
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
<div class="overflow-scroll" style="padding:20px;margin-right:30px;">
|
|
114
|
+
<div class="d-flex "
|
|
115
|
+
style="margin-bottom:16px;gap:44px;position: relative;">
|
|
116
|
+
<div class="d-flex flex-shrink-0 align-items-center "
|
|
117
|
+
style="width:${titleLength}px;font-size: 16px;font-style: normal;font-weight: 700;">
|
|
118
|
+
商品
|
|
119
|
+
</div>
|
|
120
|
+
${(() => {
|
|
121
|
+
type TitleItem = {
|
|
122
|
+
title: string;
|
|
123
|
+
width: string;
|
|
124
|
+
};
|
|
125
|
+
let titleArray: TitleItem[] = [
|
|
126
|
+
{
|
|
127
|
+
title: "下單數量",
|
|
128
|
+
width: `${elementLength}px`
|
|
129
|
+
}, {
|
|
130
|
+
title: "庫存",
|
|
131
|
+
width: `${elementLength}px`
|
|
132
|
+
},
|
|
133
|
+
];
|
|
134
|
+
|
|
135
|
+
function insertSubStocks(titleArray: TitleItem[], subStocks: string[]): TitleItem[] {
|
|
136
|
+
const targetIndex = titleArray.findIndex(item => item.title === "庫存");
|
|
137
|
+
if (targetIndex !== -1) {
|
|
138
|
+
// 格式化細分庫存
|
|
139
|
+
const formattedSubStocks: TitleItem[] = subStocks.map(stockTitle => ({
|
|
140
|
+
title: stockTitle,
|
|
141
|
+
width: titleArray[targetIndex].width // 使用原"庫存"的寬度
|
|
142
|
+
}));
|
|
143
|
+
|
|
144
|
+
// 替換 "庫存" 為細分庫存
|
|
145
|
+
titleArray.splice(targetIndex, 1, ...formattedSubStocks);
|
|
146
|
+
}
|
|
147
|
+
return titleArray;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
titleArray = insertSubStocks(titleArray, stockList.flatMap((item: any) => {
|
|
151
|
+
return [
|
|
152
|
+
html`
|
|
153
|
+
<div class="" style="text-align: center;">
|
|
154
|
+
${item.name}<br>庫存數量
|
|
155
|
+
</div>`,
|
|
156
|
+
html`
|
|
157
|
+
<div class="" style="text-align: center;">
|
|
158
|
+
${item.name}<br>出貨數量
|
|
159
|
+
</div>`
|
|
160
|
+
]
|
|
161
|
+
}));
|
|
162
|
+
return titleArray.map((title) => {
|
|
163
|
+
return html`
|
|
164
|
+
<div class="d-flex flex-shrink-0 align-items-center ${title.title == '下單數量'?'justify-content-end':''} ${(title.title != '商品' && title.title != '下單數量'? 'justify-content-center' : '')}"
|
|
165
|
+
style="width:${title.width};font-size: 16px;font-style: normal;font-weight: 700;;${(title.title == '商品' ? 'position:absolute;left: 0;top: 0;' : '')}">
|
|
166
|
+
${title.title}
|
|
167
|
+
</div>
|
|
168
|
+
`
|
|
169
|
+
}).join('')
|
|
170
|
+
})()}
|
|
171
|
+
</div>
|
|
172
|
+
${(() => {
|
|
173
|
+
const id = topGVC.glitter.getUUID();
|
|
174
|
+
return gvc.bindView({
|
|
175
|
+
bind:id,
|
|
176
|
+
view:()=>{
|
|
177
|
+
return postMD.map((item: any) => {
|
|
178
|
+
|
|
179
|
+
if (item.deduction_log && Object.keys(item.deduction_log).length === 0) {
|
|
180
|
+
return
|
|
181
|
+
}
|
|
182
|
+
return html`
|
|
183
|
+
<div class="d-flex align-items-center" style="gap:44px;">
|
|
184
|
+
<div class="d-flex align-items-center flex-shrink-0"
|
|
185
|
+
style="width: ${titleLength}px;gap: 12px">
|
|
186
|
+
<img style="height: 54px;width: 54px;border-radius: 5px;"
|
|
187
|
+
src="${item.preview_image}">
|
|
188
|
+
<div class="d-flex flex-column"
|
|
189
|
+
style="font-size: 16px;">
|
|
190
|
+
<div>${item.title}</div>
|
|
191
|
+
<div style="color: #8D8D8D;font-size: 14px;">
|
|
192
|
+
${(item.spec.length == 0 ? `單一規格` : item.spec.join(`,`))}
|
|
193
|
+
</div>
|
|
194
|
+
<div style="color: #8D8D8D;font-size: 14px;">存貨單位 (SKU):
|
|
195
|
+
${item.sku}
|
|
196
|
+
</div>
|
|
197
|
+
</div>
|
|
198
|
+
</div>
|
|
199
|
+
<div class="d-flex align-items-center justify-content-end flex-shrink-0"
|
|
200
|
+
" style="width: ${elementLength}px;gap: 12px">
|
|
201
|
+
${item.count}
|
|
202
|
+
</div>
|
|
203
|
+
${stockList.flatMap((stock: any) => {
|
|
204
|
+
const limit = item.stockList?.[stock.id]?.count??0;
|
|
205
|
+
return [html`
|
|
206
|
+
<div class="d-flex align-items-center justify-content-end flex-shrink-0" style="width: ${elementLength}px;gap: 12px;">
|
|
207
|
+
${parseInt(limit) + (parseInt(item.deduction_log[stock.id]??"0"))}
|
|
208
|
+
</div>`,
|
|
209
|
+
html`
|
|
210
|
+
<div class="d-flex align-items-center justify-content-end flex-shrink-0"" style="width: ${elementLength}px;gap: 12px">
|
|
211
|
+
<input class="w-100"
|
|
212
|
+
style="border-radius: 10px;border: 1px solid #DDD;background: #FFF;text-align: center;padding:0 18px;height:40px;"
|
|
213
|
+
max="${limit + (item.deduction_log[stock.id]??0)}"
|
|
214
|
+
min="0"
|
|
215
|
+
value="${item.deduction_log[stock.id]??0}"
|
|
216
|
+
type="number"
|
|
217
|
+
onchange="${gvc.event((e: any) => {
|
|
218
|
+
const previewNum = item.deduction_log[stock.id];
|
|
219
|
+
let still = 0;
|
|
220
|
+
item.deduction_log[stock.id] = 0;
|
|
221
|
+
Object.values(item.deduction_log).forEach((dd: any) => {
|
|
222
|
+
still += dd;
|
|
223
|
+
})
|
|
224
|
+
still = item.count - still
|
|
225
|
+
item.deduction_log
|
|
226
|
+
|
|
227
|
+
if (e.value > still){
|
|
228
|
+
e.value = still
|
|
229
|
+
}
|
|
230
|
+
item.deduction_log[stock.id] = parseInt(e.value);
|
|
231
|
+
gvc.notifyDataChange('id')
|
|
232
|
+
console.log("item -- " , item);
|
|
233
|
+
})}">
|
|
234
|
+
</div>`]
|
|
235
|
+
}).join('')}
|
|
236
|
+
</div>
|
|
237
|
+
`
|
|
238
|
+
}).join('')
|
|
239
|
+
},divCreate:{class:"d-flex flex-column" , style:"margin-bottom:80px;gap:12px;"}
|
|
240
|
+
})
|
|
241
|
+
|
|
242
|
+
})()}
|
|
243
|
+
</div>
|
|
244
|
+
<div class="w-100 justify-content-end d-flex bg-white"
|
|
245
|
+
style="margin-top:100px;position: absolute;left: 0;bottom: 0;gap:14px;padding-right:24px;padding-bottom:20px;padding-top: 10px;border-radius: 0px 0px 10px 10px;">
|
|
246
|
+
${BgWidget.cancel(
|
|
247
|
+
gvc.event(() => {
|
|
248
|
+
postMD = origData;
|
|
249
|
+
topGVC.glitter.closeDiaLog();
|
|
250
|
+
})
|
|
251
|
+
)}
|
|
252
|
+
${BgWidget.save(gvc.event(() => {
|
|
253
|
+
console.log("postMD -- ", postMD)
|
|
254
|
+
let errorProduct : any = [];
|
|
255
|
+
let pass = true;
|
|
256
|
+
postMD.forEach((data:any)=>{
|
|
257
|
+
let count = 0;
|
|
258
|
+
if (Object.keys(data.deduction_log).length != 0) {
|
|
259
|
+
Object.values(data.deduction_log).forEach((log:any)=>{
|
|
260
|
+
count += log ;
|
|
261
|
+
});
|
|
262
|
+
if (count != data.count){
|
|
263
|
+
pass = false;
|
|
264
|
+
errorProduct.push(data.title + "-" + data.spec.join(','));
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
})
|
|
269
|
+
if (pass){
|
|
270
|
+
topGVC.glitter.closeDiaLog();
|
|
271
|
+
|
|
272
|
+
if (obj.callback) {
|
|
273
|
+
obj.callback();
|
|
274
|
+
}
|
|
275
|
+
}else {
|
|
276
|
+
|
|
277
|
+
dialog.errorMessage({
|
|
278
|
+
text : html`
|
|
279
|
+
<div class="d-flex flex-column">
|
|
280
|
+
出貨數量異常
|
|
281
|
+
</div>
|
|
282
|
+
`
|
|
283
|
+
})
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
}))}
|
|
287
|
+
</div>
|
|
288
|
+
</div>
|
|
289
|
+
`
|
|
290
|
+
},
|
|
291
|
+
divCreate: {
|
|
292
|
+
style: `width: 100vw;height:100vh;`,
|
|
293
|
+
class: `d-flex align-items-center justify-content-center`
|
|
294
|
+
},
|
|
295
|
+
onCreate: () => {
|
|
296
|
+
|
|
297
|
+
}
|
|
298
|
+
})
|
|
299
|
+
|
|
300
|
+
}, "batchEdit");
|
|
301
|
+
}
|
|
302
|
+
}
|