ts-glitter 20.5.3 → 20.5.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.
@@ -35,27 +35,20 @@ type DashboardData = {
35
35
  export class OrderSetting {
36
36
  // 付款名稱
37
37
  static getPaymentMethodText(orderData: OrderData) {
38
- if (orderData.orderSource === 'POS') {
39
- return '門市POS付款';
40
- }
41
- switch (orderData.customer_info.payment_select) {
42
- case 'off_line':
43
- return '線下付款';
44
- case 'newWebPay':
45
- return '藍新金流';
46
- case 'ecPay':
47
- return '綠界金流';
48
- case 'line_pay':
49
- return 'Line Pay';
50
- case 'atm':
51
- return '銀行轉帳';
52
- case 'line':
53
- return 'Line 轉帳';
54
- case 'cash_on_delivery':
55
- return '貨到付款';
56
- default:
57
- return '線下付款';
58
- }
38
+ const paymentMethods: Record<string, string> = {
39
+ POS: '門市POS付款',
40
+ off_line: '線下付款',
41
+ newWebPay: '藍新金流',
42
+ ecPay: '綠界金流',
43
+ line_pay: 'Line Pay',
44
+ atm: '銀行轉帳',
45
+ line: 'Line 轉帳',
46
+ cash_on_delivery: '貨到付款',
47
+ };
48
+
49
+ return orderData.orderSource === 'POS'
50
+ ? paymentMethods['POS']
51
+ : paymentMethods[orderData.customer_info.payment_select] || '線下付款';
59
52
  }
60
53
 
61
54
  // 配送名稱
@@ -1659,7 +1652,7 @@ export class OrderSetting {
1659
1652
  const orderCreateUnit = new OrderDetail(0, 0);
1660
1653
  assignOrder(orderCreateUnit);
1661
1654
  const splitOrderArray: OrderDetail[] = [structuredClone(orderCreateUnit)];
1662
- const passData = structuredClone(orderCreateUnit);//修改後的
1655
+ const passData = structuredClone(orderCreateUnit); //修改後的
1663
1656
  const isDesktop = document.body.clientWidth > 768;
1664
1657
 
1665
1658
  const vm = {
@@ -1877,7 +1870,6 @@ export class OrderSetting {
1877
1870
 
1878
1871
  const closeDialog = () => glitter.closeDiaLog();
1879
1872
 
1880
-
1881
1873
  const renderHeader = (gvc: GVC) =>
1882
1874
  gvc.bindView({
1883
1875
  bind: ids.header,
@@ -1899,33 +1891,35 @@ export class OrderSetting {
1899
1891
 
1900
1892
  const handleSave = () => {
1901
1893
  const alertHTML = html`
1902
- <div class="d-flex flex-column">
1903
- <div class="tx_normal text-start">您即將拆分訂單,系統將產生 ${splitOrderArray.length} 筆子訂單,拆分後:</div>
1904
- <ul class="${gClass('dialog-ul')}">
1905
- <li>原訂單調整金額與折扣,運費及附加費維持不變。子訂單按比例分配優惠。</li>
1906
- <li>子訂單繼承母訂單設定,發票需手動作廢與重開。 </li>
1907
- <li>代收金額更新,已建立的出貨單需取消並重新建立。</li>
1908
- </ul>
1909
- </div>
1910
- `
1894
+ <div class="d-flex flex-column">
1895
+ <div class="tx_normal text-start">
1896
+ 您即將拆分訂單,系統將產生 ${splitOrderArray.length} 筆子訂單,拆分後:
1897
+ </div>
1898
+ <ul class="${gClass('dialog-ul')}">
1899
+ <li>原訂單調整金額與折扣,運費及附加費維持不變。子訂單按比例分配優惠。</li>
1900
+ <li>子訂單繼承母訂單設定,發票需手動作廢與重開。</li>
1901
+ <li>代收金額更新,已建立的出貨單需取消並重新建立。</li>
1902
+ </ul>
1903
+ </div>
1904
+ `;
1911
1905
 
1912
1906
  dialog.checkYesOrNotWithCustomWidth({
1913
1907
  callback: bool => {
1914
1908
  if (bool) {
1915
- orderData.lineItems.forEach((lineItem:any,index:number)=>{
1909
+ orderData.lineItems.forEach((lineItem: any, index: number) => {
1916
1910
  let count = 0;
1917
- count = splitOrderArray.reduce((total,order)=>{return total += Number(order.lineItems[index].count)},0)
1911
+ count = splitOrderArray.reduce((total, order) => {
1912
+ return (total += Number(order.lineItems[index].count));
1913
+ }, 0);
1918
1914
  lineItem.count -= count;
1919
- })
1915
+ });
1920
1916
  const passData = {
1921
- orderData : orderData,
1922
- splitOrderArray : splitOrderArray
1923
- }
1924
-
1917
+ orderData: orderData,
1918
+ splitOrderArray: splitOrderArray,
1919
+ };
1925
1920
 
1926
1921
  ApiShop.combineOrder(vm.dataObject).then(r => {
1927
1922
  if (r.result && r.response) {
1928
-
1929
1923
  }
1930
1924
  });
1931
1925
  dialog.dataLoading({ visible: true });
@@ -1945,24 +1939,24 @@ export class OrderSetting {
1945
1939
  });
1946
1940
  };
1947
1941
 
1948
- const renderFooter = (gvc: GVC) => gvc.bindView({
1949
- bind:ids.footer,
1950
- view:()=>{
1951
- const allOrdersHaveZeroItems = splitOrderArray.every(order =>
1952
- order.lineItems.every(item => item.count === 0)
1953
- );
1954
- let checkBTN = ``;
1955
- if (!allOrdersHaveZeroItems) {
1956
- checkBTN = BgWidget.save(gvc.event(handleSave), '拆分訂單')
1957
- } else {
1958
- checkBTN = BgWidget.disableSave('拆分訂單')
1959
- }
1942
+ const renderFooter = (gvc: GVC) =>
1943
+ gvc.bindView({
1944
+ bind: ids.footer,
1945
+ view: () => {
1946
+ const allOrdersHaveZeroItems = splitOrderArray.every(order =>
1947
+ order.lineItems.every(item => item.count === 0)
1948
+ );
1949
+ let checkBTN = ``;
1950
+ if (!allOrdersHaveZeroItems) {
1951
+ checkBTN = BgWidget.save(gvc.event(handleSave), '拆分訂單');
1952
+ } else {
1953
+ checkBTN = BgWidget.disableSave('拆分訂單');
1954
+ }
1960
1955
 
1961
- return html`
1962
- ${BgWidget.cancel(gvc.event(closeDialog))} ${checkBTN}
1963
- `
1964
- },divCreate:{class:`${gClass('footer')}`}
1965
- });
1956
+ return html` ${BgWidget.cancel(gvc.event(closeDialog))} ${checkBTN} `;
1957
+ },
1958
+ divCreate: { class: `${gClass('footer')}` },
1959
+ });
1966
1960
 
1967
1961
  const renderHint = (gvc: GVC) => {
1968
1962
  // mainCard 手機版專用
@@ -1996,27 +1990,33 @@ export class OrderSetting {
1996
1990
  })
1997
1991
  .join('')}
1998
1992
  </ul>
1999
- <div class="${gClass('split-rule')} ms-auto d-flex align-items-end" onclick="${gvc.event(()=>{
2000
- BgWidget.settingDialog({
2001
- gvc: gvc,
2002
- title: '拆單需知',
2003
- width: 766,
2004
- innerHTML: gvc => {
2005
- return html`
2006
- <ul class="${gClass('dialog-ul')}">
2007
- <li>原訂單將保留剩餘商品,訂單金額與折扣將調整;子訂單將包含選定商品,並按比例分配優惠折扣</li>
1993
+ <div
1994
+ class="${gClass('split-rule')} ms-auto d-flex align-items-end"
1995
+ onclick="${gvc.event(() => {
1996
+ BgWidget.settingDialog({
1997
+ gvc: gvc,
1998
+ title: '拆單需知',
1999
+ width: 766,
2000
+ innerHTML: gvc => {
2001
+ return html` <ul class="${gClass('dialog-ul')}">
2002
+ <li>
2003
+ 原訂單將保留剩餘商品,訂單金額與折扣將調整;子訂單將包含選定商品,並按比例分配優惠折扣
2004
+ </li>
2008
2005
  <li>拆單後運費及附加費用不變,將保留於原訂單內,如需更改,請手動編輯訂單新增費用</li>
2009
2006
  <li>子訂單會預設繼承母訂單的配送與付款方式,如需更改,請手動編輯訂單內容</li>
2010
2007
  <li>子訂單若要重新開立發票,請至發票頁面手動建立</li>
2011
2008
  <li>若發票已開立,系統不會自動作廢,需至訂單頁面手動作廢並重新開立</li>
2012
2009
  <li>代收金額將更新,已建立的出貨單需取消並重新建立</li>
2013
2010
  </ul>`;
2014
- },
2015
- footer_html: (gvc: GVC) => {
2016
- return '';
2017
- },
2018
- });
2019
- })}">詳細拆單規則</div>
2011
+ },
2012
+ footer_html: (gvc: GVC) => {
2013
+ return '';
2014
+ },
2015
+ });
2016
+ })}"
2017
+ >
2018
+ 詳細拆單規則
2019
+ </div>
2020
2020
  </div>
2021
2021
  </div>
2022
2022
  `)}
@@ -2028,7 +2028,7 @@ export class OrderSetting {
2028
2028
  const renderItemList = (gvc: GVC) => {
2029
2029
  function newSplitOrder() {
2030
2030
  splitOrderArray.push(structuredClone(orderCreateUnit));
2031
- gvc.notifyDataChange([ids.itemList, ids.summary , ids.footer]);
2031
+ gvc.notifyDataChange([ids.itemList, ids.summary, ids.footer]);
2032
2032
  }
2033
2033
  function drawSplitOrder() {
2034
2034
  const titleDom = {
@@ -2071,7 +2071,7 @@ export class OrderSetting {
2071
2071
  } else {
2072
2072
  item.count = temp;
2073
2073
  }
2074
- gvc.notifyDataChange([ids.itemList, ids.summary , ids.footer]);
2074
+ gvc.notifyDataChange([ids.itemList, ids.summary, ids.footer]);
2075
2075
  })}"
2076
2076
  />
2077
2077
  `;
@@ -2138,7 +2138,7 @@ export class OrderSetting {
2138
2138
  <img class="${gClass('product-preview-img')}" src="${item.preview_image}" alt="產品圖片" />
2139
2139
  <div class="d-flex flex-column flex-grow-1" style="gap:2px;">
2140
2140
  <div class="tx_normal_14" style="white-space: normal;line-height: normal;">
2141
- ${Tool.truncateString(item.title??"", 10)} -${spec}
2141
+ ${Tool.truncateString(item.title ?? '', 10)} -${spec}
2142
2142
  </div>
2143
2143
  <div class="tx_normal_14 ${gClass('font-gray')}">
2144
2144
  存貨單位 (SKU): ${item.sku ?? '無SKU'}
@@ -2231,9 +2231,11 @@ export class OrderSetting {
2231
2231
  };
2232
2232
 
2233
2233
  const renderBlock = (gvc: GVC) => {
2234
- const subBlock = splitOrderArray.map((order, index) => {
2235
- return html`<div class="${gClass('summary-subSummary')}"></div>`
2236
- }).join('')
2234
+ const subBlock = splitOrderArray
2235
+ .map((order, index) => {
2236
+ return html`<div class="${gClass('summary-subSummary')}"></div>`;
2237
+ })
2238
+ .join('');
2237
2239
  return html`
2238
2240
  <div class="d-flex" style="height:27px;">
2239
2241
  <div class="${gClass('summary-title')}"></div>
@@ -2303,7 +2305,9 @@ export class OrderSetting {
2303
2305
  <div class="d-flex align-items-center">
2304
2306
  <span class="text-decoration-line-through">${orderData.total}</span
2305
2307
  ><i class="fa-solid fa-arrow-right ${gClass('font-blue')} ${gClass('summary-right')}"></i
2306
- ><span class="${gClass('font-blue')}">${sale_price - split_price - discount + orderData.shipment_fee}</span>
2308
+ ><span class="${gClass('font-blue')}"
2309
+ >${sale_price - split_price - discount + orderData.shipment_fee}</span
2310
+ >
2307
2311
  </div>
2308
2312
  `;
2309
2313
  }
@@ -2319,7 +2323,7 @@ export class OrderSetting {
2319
2323
  0
2320
2324
  );
2321
2325
  const rate = total / orderData.total;
2322
- order.discount = Math.round(orderData.discount*rate)
2326
+ order.discount = Math.round(orderData.discount * rate);
2323
2327
  //產品總價-折扣
2324
2328
  order.total = total - order.discount;
2325
2329
  switch (rawIndex) {
@@ -24,7 +24,7 @@ import { UserList } from './user-list.js';
24
24
  import { FilterOptions } from './filter-options.js';
25
25
  import { ListHeaderOption } from './list-header-option.js';
26
26
  import { ShoppingInvoiceManager } from './shopping-invoice-manager.js';
27
- import { CartData, LineItem } from './module/data.js';
27
+ import { LineItem } from './module/data.js';
28
28
  import { OrderModule } from './order/order-module.js';
29
29
 
30
30
  const html = String.raw;
@@ -238,7 +238,8 @@ export class PdClass {
238
238
  >
239
239
  <div
240
240
  class="w-100 d-flex align-items-center p-3 border-bottom"
241
- style="position: sticky; top: 0; background: #fff;z-index:12;height: calc(60px + ${gvc.glitter.share.top_inset}px);
241
+ style="position: sticky; top: 0; background: #fff;z-index:12;height: calc(60px + ${gvc.glitter.share
242
+ .top_inset}px);
242
243
  ${gvc.glitter.share.top_inset ? `padding-top: ${gvc.glitter.share.top_inset}px !important;` : ``}
243
244
 
244
245
  "
@@ -471,6 +472,19 @@ export class PdClass {
471
472
  return prod.variants.find(item => PdClass.ObjCompare(item.spec, vm.specs, true));
472
473
  }
473
474
  }
475
+ static showCanBuyStock(variant, titleFontColor) {
476
+ if (variant && variant.show_understocking !== 'false' && window.store_info.stock_view) {
477
+ const stockInt = parseInt(`${variant.stock}`, 10);
478
+ const stockValue = !isNaN(stockInt) && stockInt > 0 ? stockInt : 0;
479
+ const stockClass = stockValue === 0 ? 'text-danger' : '';
480
+ return html `
481
+ <div class="${stockClass} fw-500 mt-2 mb-1 fs-6" style="color: ${titleFontColor};">
482
+ ${Language.text('can_buy')}:${stockValue}
483
+ </div>
484
+ `;
485
+ }
486
+ return html `<div class=" fw-500 mt-2 mb-1 fs-6">&ensp;</div>`;
487
+ }
474
488
  static selectSpec(obj) {
475
489
  var _a, _b;
476
490
  const gvc = obj.gvc;
@@ -725,27 +739,12 @@ export class PdClass {
725
739
  },
726
740
  };
727
741
  }),
728
- gvc.bindView(() => {
729
- return {
730
- bind: ids.stock_count,
731
- view: () => {
732
- return [
733
- (() => {
734
- const variant = PdClass.getVariant(prod, vm);
735
- if (variant && variant.show_understocking !== 'false' && window.store_info.stock_view) {
736
- const stockClass = `${variant.stock}` === '0' ? 'text-danger' : '';
737
- return html `
738
- <div class="${stockClass} fw-500 mt-2" style="font-size: 14px; color: ${titleFontColor};">
739
- ${Language.text('can_buy')}:${variant.stock}
740
- </div>
741
- `;
742
- }
743
- return '';
744
- })(),
745
- ].join('');
746
- },
747
- divCreate: {},
748
- };
742
+ gvc.bindView({
743
+ bind: ids.stock_count,
744
+ view: () => {
745
+ const variant = PdClass.getVariant(prod, vm);
746
+ return this.showCanBuyStock(variant, titleFontColor);
747
+ },
749
748
  }),
750
749
  gvc.bindView({
751
750
  bind: ids.addCartButton,
@@ -1182,29 +1181,12 @@ export class PdClass {
1182
1181
  <div class="mt-3"></div>`;
1183
1182
  })
1184
1183
  .join(''),
1185
- gvc.bindView(() => {
1186
- return {
1187
- bind: ids.stock_count,
1188
- view: () => {
1189
- return [
1190
- (() => {
1191
- const variant = PdClass.getVariant(prod, vm);
1192
- if (variant &&
1193
- variant.show_understocking !== 'false' &&
1194
- window.store_info.stock_view) {
1195
- const stockClass = `${variant.stock}` === '0' ? 'text-danger' : '';
1196
- return html `
1197
- <div class="${stockClass} fw-500 mt-2" style="font-size: 14px; color: ${titleFontColor};">
1198
- ${Language.text('can_buy')}:${variant.stock}
1199
- </div>
1200
- `;
1201
- }
1202
- return '';
1203
- })(),
1204
- ].join('');
1205
- },
1206
- divCreate: {},
1207
- };
1184
+ gvc.bindView({
1185
+ bind: ids.stock_count,
1186
+ view: () => {
1187
+ const variant = PdClass.getVariant(prod, vm);
1188
+ return this.showCanBuyStock(variant, titleFontColor);
1189
+ },
1208
1190
  }),
1209
1191
  gvc.bindView({
1210
1192
  bind: ids.addCartButton,
@@ -365,8 +365,9 @@ export class PdClass {
365
365
  >
366
366
  <div
367
367
  class="w-100 d-flex align-items-center p-3 border-bottom"
368
- style="position: sticky; top: 0; background: #fff;z-index:12;height: calc(60px + ${gvc.glitter.share.top_inset}px);
369
- ${gvc.glitter.share.top_inset ? `padding-top: ${gvc.glitter.share.top_inset}px !important;`:``}
368
+ style="position: sticky; top: 0; background: #fff;z-index:12;height: calc(60px + ${gvc.glitter.share
369
+ .top_inset}px);
370
+ ${gvc.glitter.share.top_inset ? `padding-top: ${gvc.glitter.share.top_inset}px !important;` : ``}
370
371
 
371
372
  "
372
373
  >
@@ -631,6 +632,22 @@ export class PdClass {
631
632
  }
632
633
  }
633
634
 
635
+ static showCanBuyStock(variant: any, titleFontColor: string) {
636
+ if (variant && variant.show_understocking !== 'false' && (window as any).store_info.stock_view) {
637
+ const stockInt = parseInt(`${variant.stock}`, 10);
638
+ const stockValue = !isNaN(stockInt) && stockInt > 0 ? stockInt : 0;
639
+ const stockClass = stockValue === 0 ? 'text-danger' : '';
640
+
641
+ return html`
642
+ <div class="${stockClass} fw-500 mt-2 mb-1 fs-6" style="color: ${titleFontColor};">
643
+ ${Language.text('can_buy')}:${stockValue}
644
+ </div>
645
+ `;
646
+ }
647
+
648
+ return html`<div class=" fw-500 mt-2 mb-1 fs-6">&ensp;</div>`;
649
+ }
650
+
634
651
  static selectSpec(obj: {
635
652
  gvc: GVC;
636
653
  titleFontColor: string;
@@ -916,29 +933,12 @@ export class PdClass {
916
933
  };
917
934
  }),
918
935
  //庫存顯示
919
- gvc.bindView(() => {
920
- return {
921
- bind: ids.stock_count,
922
- view: () => {
923
- return [
924
- (() => {
925
- const variant = PdClass.getVariant(prod, vm);
926
-
927
- if (variant && variant.show_understocking !== 'false' && (window as any).store_info.stock_view) {
928
- const stockClass = `${variant.stock}` === '0' ? 'text-danger' : '';
929
- return html`
930
- <div class="${stockClass} fw-500 mt-2" style="font-size: 14px; color: ${titleFontColor};">
931
- ${Language.text('can_buy')}:${variant.stock}
932
- </div>
933
- `;
934
- }
935
-
936
- return '';
937
- })(),
938
- ].join('');
939
- },
940
- divCreate: {},
941
- };
936
+ gvc.bindView({
937
+ bind: ids.stock_count,
938
+ view: () => {
939
+ const variant = PdClass.getVariant(prod, vm);
940
+ return this.showCanBuyStock(variant, titleFontColor);
941
+ },
942
942
  }),
943
943
  //購物車按鈕
944
944
  gvc.bindView({
@@ -1023,7 +1023,7 @@ export class PdClass {
1023
1023
  style="height:44px;width:44px;"
1024
1024
  onclick="${gvc.event(() => {
1025
1025
  if (!GlobalUser.token) {
1026
- gvc.glitter.href='/login'
1026
+ gvc.glitter.href = '/login';
1027
1027
  }
1028
1028
  const userID = (() => {
1029
1029
  if (GlobalUser.token) {
@@ -1422,33 +1422,12 @@ export class PdClass {
1422
1422
  })
1423
1423
  .join(''),
1424
1424
  //庫存顯示
1425
- gvc.bindView(() => {
1426
- return {
1427
- bind: ids.stock_count,
1428
- view: () => {
1429
- return [
1430
- (() => {
1431
- const variant = PdClass.getVariant(prod, vm);
1432
-
1433
- if (
1434
- variant &&
1435
- variant.show_understocking !== 'false' &&
1436
- (window as any).store_info.stock_view
1437
- ) {
1438
- const stockClass = `${variant.stock}` === '0' ? 'text-danger' : '';
1439
- return html`
1440
- <div class="${stockClass} fw-500 mt-2" style="font-size: 14px; color: ${titleFontColor};">
1441
- ${Language.text('can_buy')}:${variant.stock}
1442
- </div>
1443
- `;
1444
- }
1445
-
1446
- return '';
1447
- })(),
1448
- ].join('');
1449
- },
1450
- divCreate: {},
1451
- };
1425
+ gvc.bindView({
1426
+ bind: ids.stock_count,
1427
+ view: () => {
1428
+ const variant = PdClass.getVariant(prod, vm);
1429
+ return this.showCanBuyStock(variant, titleFontColor);
1430
+ },
1452
1431
  }),
1453
1432
  //購物車按鈕
1454
1433
  gvc.bindView({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-glitter",
3
- "version": "20.5.3",
3
+ "version": "20.5.5",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {