ts-glitter 17.6.7 → 17.6.8

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 CHANGED
@@ -89,7 +89,7 @@ export class Entry {
89
89
  }
90
90
  window.renderClock = (_b = window.renderClock) !== null && _b !== void 0 ? _b : clockF();
91
91
  console.log(`Entry-time:`, window.renderClock.stop());
92
- glitter.share.editerVersion = 'V_17.6.7';
92
+ glitter.share.editerVersion = 'V_17.6.8';
93
93
  glitter.share.start = new Date();
94
94
  const vm = {
95
95
  appConfig: [],
package/lowcode/Entry.ts CHANGED
@@ -90,7 +90,7 @@ export class Entry {
90
90
  }
91
91
  (window as any).renderClock = (window as any).renderClock ?? clockF();
92
92
  console.log(`Entry-time:`, (window as any).renderClock.stop());
93
- glitter.share.editerVersion = 'V_17.6.7';
93
+ glitter.share.editerVersion = 'V_17.6.8';
94
94
  glitter.share.start = new Date();
95
95
  const vm: {
96
96
  appConfig: any;
@@ -126,7 +126,6 @@ export type ViewModel = {
126
126
  query: string;
127
127
  order: any;
128
128
  productSearch: any[];
129
- searchable: boolean;
130
129
  categorySearch: boolean;
131
130
  categories: any[];
132
131
  loading: boolean;
@@ -21,6 +21,26 @@ export class ProductsPage {
21
21
  const orderDetail = obj.orderDetail;
22
22
  const dialog = new ShareDialog(gvc.glitter);
23
23
  orderDetail.total = orderDetail.total || 0;
24
+ function loadData() {
25
+ let category = vm.categories.find((category) => {
26
+ return category.select == true;
27
+ });
28
+ dialog.dataLoading({ visible: true });
29
+ ApiShop.getProduct({
30
+ page: 0,
31
+ collection: (category.key == 'all' ? '' : category.key),
32
+ limit: 50,
33
+ search: vm.query,
34
+ status: 'inRange',
35
+ channel: 'pos',
36
+ orderBy: 'created_time_desc'
37
+ }).then(res => {
38
+ vm.productSearch = res.response.data;
39
+ dialog.dataLoading({ visible: false });
40
+ gvc.notifyDataChange(`productShow`);
41
+ });
42
+ }
43
+ loadData();
24
44
  return html `
25
45
  <div class="left-panel"
26
46
  style="${(document.body.offsetWidth < 800) ? `width:calc(100%);padding-top: 42px` : `width:calc(100% - 352px);padding-top: 32px ;padding-bottom:32px;`}overflow: hidden;">
@@ -48,7 +68,7 @@ export class ProductsPage {
48
68
  category.select = false;
49
69
  });
50
70
  data.select = true;
51
- vm.searchable = true;
71
+ loadData();
52
72
  gvc.notifyDataChange(['category', 'productShow']);
53
73
  })}">
54
74
  ${data.value}
@@ -66,87 +86,68 @@ export class ProductsPage {
66
86
  style: `width:100%;overflow: scroll;padding-bottom:32px;${(document.body.clientWidth > 992) ? `padding-left:32px !important;padding-right:32px !important;` : `padding-top:20px;`}`
67
87
  }
68
88
  })}
69
- ${gvc.bindView({
70
- bind: `productShow`,
71
- view: () => {
72
- let image = 'https://d3jnmi1tfjgtti.cloudfront.net/file/234285319/1722936949034-default_image.jpg';
73
- let parent = document.querySelector(`.left-panel`);
74
- let rowItem = Math.floor((parent.offsetWidth - 72) / 188);
75
- rowItem = (rowItem * 188 + 26 * (rowItem - 1) > (parent.offsetWidth - 72)) ? rowItem - 1 : rowItem;
76
- if (document.body.offsetWidth < 600) {
77
- rowItem = 2;
78
- }
79
- let maxwidth = (parent.offsetWidth - 72 - (rowItem - 1) * 26) / rowItem;
80
- if (document.body.offsetWidth < 600) {
81
- maxwidth += 10;
82
- }
83
- let category = vm.categories.find((category) => {
84
- return category.select == true;
85
- });
86
- function arraysEqual(arr1, arr2) {
87
- if (arr1.length !== arr2.length)
88
- return false;
89
- return arr1.every((value, index) => value === arr2[index]);
90
- }
91
- function changeSelectVariant(product) {
92
- let emptyArray = [];
93
- product.content.specs.forEach((spec) => {
94
- emptyArray.push(spec.option.find((opt) => {
95
- return opt.select == true;
96
- }).title);
97
- });
98
- return product.content.variants.find((variant) => {
99
- return arraysEqual(variant.spec, emptyArray);
100
- });
101
- }
102
- if (vm.searchable) {
103
- dialog.dataLoading({ visible: true });
104
- ApiShop.getProduct({
105
- page: 0,
106
- collection: (category.key == 'all' ? '' : category.key),
107
- limit: 50000,
108
- search: vm.query,
109
- status: 'inRange',
110
- channel: 'pos',
111
- orderBy: 'created_time_desc'
112
- }).then(res => {
113
- vm.searchable = false;
114
- vm.productSearch = res.response.data;
115
- dialog.dataLoading({ visible: false });
116
- gvc.notifyDataChange(`productShow`);
117
- });
118
- }
119
- if (vm.productSearch.length > 0) {
120
- return vm.productSearch.map((data) => {
121
- var _a, _b, _c, _d;
122
- let selectVariant = data.content.variants[0];
123
- selectVariant.show_understocking = (selectVariant.show_understocking) === 'true';
124
- let count = 1;
125
- data.content.specs.forEach((spec) => {
126
- spec.option[0].select = true;
89
+ ${gvc.bindView(() => {
90
+ return {
91
+ bind: `productShow`,
92
+ view: () => {
93
+ let image = 'https://d3jnmi1tfjgtti.cloudfront.net/file/234285319/1722936949034-default_image.jpg';
94
+ let parent = document.querySelector(`.left-panel`);
95
+ let rowItem = Math.floor((parent.offsetWidth - 72) / 188);
96
+ rowItem = (rowItem * 188 + 26 * (rowItem - 1) > (parent.offsetWidth - 72)) ? rowItem - 1 : rowItem;
97
+ if (document.body.offsetWidth < 600) {
98
+ rowItem = 2;
99
+ }
100
+ let maxwidth = (parent.offsetWidth - 72 - (rowItem - 1) * 26) / rowItem;
101
+ if (document.body.offsetWidth < 600) {
102
+ maxwidth += 10;
103
+ }
104
+ function arraysEqual(arr1, arr2) {
105
+ if (arr1.length !== arr2.length)
106
+ return false;
107
+ return arr1.every((value, index) => value === arr2[index]);
108
+ }
109
+ function changeSelectVariant(product) {
110
+ let emptyArray = [];
111
+ product.content.specs.forEach((spec) => {
112
+ emptyArray.push(spec.option.find((opt) => {
113
+ return opt.select == true;
114
+ }).title);
127
115
  });
128
- return html `
116
+ return product.content.variants.find((variant) => {
117
+ return arraysEqual(variant.spec, emptyArray);
118
+ });
119
+ }
120
+ if (vm.productSearch.length > 0) {
121
+ return vm.productSearch.map((data) => {
122
+ var _a, _b, _c, _d;
123
+ let selectVariant = data.content.variants[0];
124
+ selectVariant.show_understocking = (selectVariant.show_understocking) === 'true';
125
+ let count = 1;
126
+ data.content.specs.forEach((spec) => {
127
+ spec.option[0].select = true;
128
+ });
129
+ return html `
129
130
  <div class="d-flex flex-column mb-4 mb-sm-0"
130
131
  style="max-width:${maxwidth}px;flex-basis: 188px;flex-grow: 1;border-radius: 10px;box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.08);"
131
132
  onclick="${gvc.event(() => {
132
- gvc.glitter.innerDialog((gvc) => {
133
- return gvc.bindView({
134
- bind: `productDialog`,
135
- view: () => {
136
- var _a;
137
- try {
138
- selectVariant.preview_image = selectVariant.preview_image || [];
139
- selectVariant.stock = (selectVariant.stockList[POSSetting.config.where_store] && parseInt(selectVariant.stockList[POSSetting.config.where_store].count, 10)) || 0;
140
- return html `
133
+ gvc.glitter.innerDialog((gvc) => {
134
+ return gvc.bindView({
135
+ bind: `productDialog`,
136
+ view: () => {
137
+ var _a;
138
+ try {
139
+ selectVariant.preview_image = selectVariant.preview_image || [];
140
+ selectVariant.stock = (selectVariant.stockList[POSSetting.config.where_store] && parseInt(selectVariant.stockList[POSSetting.config.where_store].count, 10)) || 0;
141
+ return html `
141
142
  <div class="w-100 h-100 d-flex align-items-center justify-content-center"
142
143
  onclick="${gvc.event(() => {
143
- gvc.glitter.closeDiaLog();
144
- })}">
144
+ gvc.glitter.closeDiaLog();
145
+ })}">
145
146
  <div class="d-flex flex-column position-relative"
146
147
  style="width: 542px;padding: 32px;background-color: white;border-radius: 10px;max-width: calc(100% - 20px);overflow-y:auto;max-height:calc(100% - 20px);"
147
148
  onclick="${gvc.event((e, event) => {
148
- event.stopPropagation();
149
- })}">
149
+ event.stopPropagation();
150
+ })}">
150
151
  <div class="w-100 d-block d-sm-flex flex-column flex-sm-row m"
151
152
  style="gap:24px;">
152
153
  <div class="rounded-3 d-none"
@@ -159,63 +160,63 @@ export class ProductsPage {
159
160
  NT.${parseInt(selectVariant.sale_price, 10).toLocaleString()}
160
161
  </div>
161
162
  ${gvc.bindView({
162
- bind: `productSpec`,
163
- view: () => {
164
- if (data.content.specs.length > 0) {
165
- return data.content.specs.map((spec) => {
166
- return html `
163
+ bind: `productSpec`,
164
+ view: () => {
165
+ if (data.content.specs.length > 0) {
166
+ return data.content.specs.map((spec) => {
167
+ return html `
167
168
  <div style="font-size: 16px;font-style: normal;font-weight: 500;color: #8D8D8D;">
168
169
  ${spec.title}
169
170
  </div>
170
171
  <select class="w-100 form-select"
171
172
  style="border-radius: 5px;border: 1px solid #DDD;padding: 10px 18px;font-size: 18px;"
172
173
  onchange="${gvc.event((e) => {
173
- spec.option.forEach((option) => {
174
- option.select = false;
175
- });
176
- spec.option[e.value].select = true;
177
- selectVariant = changeSelectVariant(data);
178
- gvc.notifyDataChange('productDialog');
179
- })}">
174
+ spec.option.forEach((option) => {
175
+ option.select = false;
176
+ });
177
+ spec.option[e.value].select = true;
178
+ selectVariant = changeSelectVariant(data);
179
+ gvc.notifyDataChange('productDialog');
180
+ })}">
180
181
  ${(() => {
181
- return spec.option.map((option, index) => {
182
- return html `
182
+ return spec.option.map((option, index) => {
183
+ return html `
183
184
  <option class="d-flex align-items-center justify-content-center"
184
185
  value="${index}"
185
186
  ${(option.select) ? 'selected' : ''}
186
187
  style="border-radius: 5px;padding: 10px 18px;color: #393939;font-size: 18px;font-weight: 500;letter-spacing: 0.72px;"
187
188
  onclick="${gvc.event(() => {
188
- })}">
189
+ })}">
189
190
  ${option.title}
190
191
  </option>`;
191
- }).join('');
192
- })()}
192
+ }).join('');
193
+ })()}
193
194
  </select>
194
195
  `;
195
- }).join('');
196
- }
197
- else {
198
- return ``;
196
+ }).join('');
197
+ }
198
+ else {
199
+ return ``;
200
+ }
201
+ },
202
+ divCreate: {
203
+ style: `gap:8px;margin-bottom:${data.content.specs.length ? `24px` : `0px`};margin-top:16px;`,
204
+ class: `d-flex flex-column`
199
205
  }
200
- },
201
- divCreate: {
202
- style: `gap:8px;margin-bottom:${data.content.specs.length ? `24px` : `0px`};margin-top:16px;`,
203
- class: `d-flex flex-column`
204
- }
205
- })}
206
+ })}
206
207
  ${gvc.bindView(() => {
207
- return {
208
- bind: 'count_bt',
209
- view: () => {
210
- return html `
208
+ return {
209
+ bind: 'count_bt',
210
+ view: () => {
211
+ return html `
211
212
  <div class="d-flex align-items-center justify-content-between"
212
213
  style="gap: 10px;padding: 10px 18px;border-radius: 5px;border: 1px solid #DDD;">
213
214
  <div class="d-flex align-items-center justify-content-center"
214
215
  style="border-radius: 10px;cursor: pointer;"
215
216
  onclick="${gvc.event(() => {
216
- count = (count == 1) ? count : count - 1;
217
- gvc.notifyDataChange(`productDialog`);
218
- })}">
217
+ count = (count == 1) ? count : count - 1;
218
+ gvc.notifyDataChange(`productDialog`);
219
+ })}">
219
220
  <svg xmlns="http://www.w3.org/2000/svg"
220
221
  width="13"
221
222
  height="3"
@@ -229,15 +230,15 @@ export class ProductsPage {
229
230
  style="text-align: center;width: 30px;"
230
231
  value="${count}"
231
232
  onchange="${gvc.event((e) => {
232
- count = e.value;
233
- gvc.notifyDataChange(['count_bt', 'product_btn']);
234
- })}">
233
+ count = e.value;
234
+ gvc.notifyDataChange(['count_bt', 'product_btn']);
235
+ })}">
235
236
  <div class="d-flex align-items-center justify-content-center"
236
237
  style="border-radius: 10px;cursor: pointer;"
237
238
  onclick="${gvc.event(() => {
238
- count++;
239
- gvc.notifyDataChange(['count_bt', 'product_btn']);
240
- })}">
239
+ count++;
240
+ gvc.notifyDataChange(['count_bt', 'product_btn']);
241
+ })}">
241
242
  <svg xmlns="http://www.w3.org/2000/svg"
242
243
  width="14"
243
244
  height="15"
@@ -252,121 +253,121 @@ export class ProductsPage {
252
253
  <span>${`${selectVariant.show_understocking}` === 'false' ? `此商品未追蹤庫存數量` : `庫存數量:${selectVariant.stock}`}</span>
253
254
  </div>
254
255
  `;
255
- },
256
- divCreate: {
257
- class: `d-flex flex-column`,
258
- style: ``
259
- }
260
- };
261
- })}
256
+ },
257
+ divCreate: {
258
+ class: `d-flex flex-column`,
259
+ style: ``
260
+ }
261
+ };
262
+ })}
262
263
  </div>
263
264
  </div>
264
265
  <div class="d-flex mt-4 justify-content-between"
265
266
  style="gap:10px;">
266
267
  ${gvc.bindView(() => {
267
- return {
268
- bind: 'close',
269
- view: () => {
270
- return `取消`;
271
- },
272
- divCreate: () => {
273
- return {
274
- class: `d-flex align-items-center justify-content-center`,
275
- style: `flex:1;padding: 12px 24px;font-size: 20px;color: #FFF;font-weight: 500;border-radius: 10px;min-height: 58px;background:gray;`,
276
- option: [
277
- {
278
- key: 'onclick',
279
- value: gvc.event(() => {
280
- gvc.glitter.closeDiaLog();
281
- })
282
- }
283
- ]
284
- };
285
- }
286
- };
287
- })}
288
- ${gvc.bindView(() => {
289
- return {
290
- bind: 'product_btn',
291
- view: () => {
292
- if (selectVariant.show_understocking && selectVariant.stock === 0) {
293
- return `預購商品`;
268
+ return {
269
+ bind: 'close',
270
+ view: () => {
271
+ return `取消`;
272
+ },
273
+ divCreate: () => {
274
+ return {
275
+ class: `d-flex align-items-center justify-content-center`,
276
+ style: `flex:1;padding: 12px 24px;font-size: 20px;color: #FFF;font-weight: 500;border-radius: 10px;min-height: 58px;background:gray;`,
277
+ option: [
278
+ {
279
+ key: 'onclick',
280
+ value: gvc.event(() => {
281
+ gvc.glitter.closeDiaLog();
282
+ })
283
+ }
284
+ ]
285
+ };
294
286
  }
295
- return `加入購物車`;
296
- },
297
- divCreate: () => {
298
- return {
299
- class: `d-flex align-items-center justify-content-center`,
300
- style: `flex:1;padding: 12px 24px;font-size: 20px;color: #FFF;font-weight: 500;border-radius: 10px;background: ${(selectVariant.show_understocking && selectVariant.stock === 0) ? `#FF6C02;` : `#393939;`}min-height: 58px;`,
301
- option: [
302
- {
303
- key: 'onclick',
304
- value: gvc.event(() => {
305
- function next() {
306
- let addItem = orderDetail.lineItems.find((item) => {
307
- console.log(data);
308
- console.log(item);
309
- console.log(selectVariant);
310
- return data.content.title == item.title && arraysEqual(item.spec, selectVariant.spec);
311
- });
312
- if (addItem) {
313
- addItem.count += count;
287
+ };
288
+ })}
289
+ ${gvc.bindView(() => {
290
+ return {
291
+ bind: 'product_btn',
292
+ view: () => {
293
+ if (selectVariant.show_understocking && selectVariant.stock === 0) {
294
+ return `預購商品`;
295
+ }
296
+ return `加入購物車`;
297
+ },
298
+ divCreate: () => {
299
+ return {
300
+ class: `d-flex align-items-center justify-content-center`,
301
+ style: `flex:1;padding: 12px 24px;font-size: 20px;color: #FFF;font-weight: 500;border-radius: 10px;background: ${(selectVariant.show_understocking && selectVariant.stock === 0) ? `#FF6C02;` : `#393939;`}min-height: 58px;`,
302
+ option: [
303
+ {
304
+ key: 'onclick',
305
+ value: gvc.event(() => {
306
+ function next() {
307
+ let addItem = orderDetail.lineItems.find((item) => {
308
+ console.log(data);
309
+ console.log(item);
310
+ console.log(selectVariant);
311
+ return data.content.title == item.title && arraysEqual(item.spec, selectVariant.spec);
312
+ });
313
+ if (addItem) {
314
+ addItem.count += count;
315
+ }
316
+ else {
317
+ orderDetail.lineItems.push({
318
+ id: data.id,
319
+ title: data.content.title,
320
+ preview_image: (selectVariant.preview_image.length > 1) ? selectVariant.preview_image : data.content.preview_image[0],
321
+ spec: selectVariant.spec,
322
+ count: count,
323
+ sale_price: selectVariant.sale_price,
324
+ sku: selectVariant.sku
325
+ });
326
+ }
327
+ if (document.querySelector('.js-cart-count')) {
328
+ document.querySelector('.js-cart-count').recreateView();
329
+ }
330
+ gvc.glitter.share.checkStock();
331
+ gvc.glitter.closeDiaLog();
314
332
  }
315
- else {
316
- orderDetail.lineItems.push({
317
- id: data.id,
318
- title: data.content.title,
319
- preview_image: (selectVariant.preview_image.length > 1) ? selectVariant.preview_image : data.content.preview_image[0],
320
- spec: selectVariant.spec,
321
- count: count,
322
- sale_price: selectVariant.sale_price,
323
- sku: selectVariant.sku
333
+ if (selectVariant.show_understocking && selectVariant.stock === 0) {
334
+ const dialog = new ShareDialog(gvc.glitter);
335
+ dialog.checkYesOrNot({
336
+ text: ' 庫存數量不足,是否進行預購?',
337
+ callback: (response) => {
338
+ if (response) {
339
+ next();
340
+ }
341
+ }
324
342
  });
343
+ return;
325
344
  }
326
- if (document.querySelector('.js-cart-count')) {
327
- document.querySelector('.js-cart-count').recreateView();
345
+ else {
346
+ next();
328
347
  }
329
- gvc.glitter.share.checkStock();
330
- gvc.glitter.closeDiaLog();
331
- }
332
- if (selectVariant.show_understocking && selectVariant.stock === 0) {
333
- const dialog = new ShareDialog(gvc.glitter);
334
- dialog.checkYesOrNot({
335
- text: ' 庫存數量不足,是否進行預購?',
336
- callback: (response) => {
337
- if (response) {
338
- next();
339
- }
340
- }
341
- });
342
- return;
343
- }
344
- else {
345
- next();
346
- }
347
- })
348
- }
349
- ]
350
- };
351
- }
352
- };
353
- })}
348
+ })
349
+ }
350
+ ]
351
+ };
352
+ }
353
+ };
354
+ })}
354
355
  </div>
355
356
  </div>
356
357
  </div>`;
357
- }
358
- catch (e) {
359
- console.log(e);
360
- return ``;
361
- }
362
- }, divCreate: { class: `w-100 h-100 ` }
358
+ }
359
+ catch (e) {
360
+ console.log(e);
361
+ return ``;
362
+ }
363
+ }, divCreate: { class: `w-100 h-100 ` }
364
+ });
365
+ }, 'product', {
366
+ dismiss: () => {
367
+ gvc.notifyDataChange('order');
368
+ }
363
369
  });
364
- }, 'product', {
365
- dismiss: () => {
366
- gvc.notifyDataChange('order');
367
- }
368
- });
369
- })}">
370
+ })}">
370
371
  <div class="w-100"
371
372
  style="border-radius: 10px 10px 0 0;;padding-bottom: 116px;background: 50%/cover no-repeat url('${(_b = (_a = data.content.preview_image[0]) !== null && _a !== void 0 ? _a : image) !== null && _b !== void 0 ? _b : image}');"></div>
372
373
  <div class="d-flex flex-column"
@@ -381,27 +382,28 @@ export class ProductsPage {
381
382
  </div>
382
383
  </div>
383
384
  `;
384
- }).join('');
385
- }
386
- else {
387
- return POSSetting.emptyView('查無相關商品');
388
- }
389
- return html ``;
390
- },
391
- divCreate: () => {
392
- if (document.body.offsetWidth < 800) {
393
- return {
394
- class: `d-flex flex-wrap w-100 product-show`,
395
- style: `overflow:scroll;max-height:100%;padding-left:24px;padding-right:24px;justify-content: space-between;padding-bottom:100px;`
396
- };
397
- }
398
- else {
399
- return {
400
- class: `d-flex flex-wrap w-100 product-show p-2`,
401
- style: `gap:26px;overflow:scroll;max-height:100%;padding-bottom:100px !important;margin-left:32px;margin-right:32px;`
402
- };
385
+ }).join('');
386
+ }
387
+ else {
388
+ return POSSetting.emptyView('查無相關商品');
389
+ }
390
+ return html ``;
391
+ },
392
+ divCreate: () => {
393
+ if (document.body.offsetWidth < 800) {
394
+ return {
395
+ class: `d-flex flex-wrap w-100 product-show`,
396
+ style: `overflow:scroll;max-height:100%;padding-left:24px;padding-right:24px;justify-content: space-between;padding-bottom:100px;`
397
+ };
398
+ }
399
+ else {
400
+ return {
401
+ class: `d-flex flex-wrap w-100 product-show p-2`,
402
+ style: `gap:26px;overflow:scroll;max-height:100%;padding-bottom:100px !important;margin-left:32px;margin-right:32px;`
403
+ };
404
+ }
403
405
  }
404
- }
406
+ };
405
407
  })}
406
408
  </div>
407
409
  ${(() => {