ts-glitter 16.5.1 → 16.5.3

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
@@ -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.5.1';
82
+ glitter.share.editerVersion = 'V_16.5.3';
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.5.1';
81
+ glitter.share.editerVersion = 'V_16.5.3';
82
82
  glitter.share.start = new Date();
83
83
  const vm: {
84
84
  appConfig: any;
@@ -751,19 +751,21 @@ export class BgRecommend {
751
751
  gvc.bindView({
752
752
  bind: 'listProduct',
753
753
  view: () => {
754
- let returnHTML = '';
755
- if (newOrder.productCheck.length) {
756
- newOrder.productCheck.map((product, index) => {
757
- var _a;
758
- let selectVariant = product.content.variants[parseInt((_a = product.selectIndex) !== null && _a !== void 0 ? _a : 0)];
759
- let productIMG = typeof selectVariant.preview_image == 'string' ? selectVariant.preview_image : selectVariant.preview_image[0];
760
- productIMG = productIMG
761
- ? productIMG
762
- : product.content.preview_image[0]
763
- ? product.content.preview_image[0]
764
- : BgWidget.noImageURL;
765
- selectVariant.qty = selectVariant.qty || 1;
766
- returnHTML += html `
754
+ try {
755
+ let returnHTML = '';
756
+ if (newOrder.productCheck.length) {
757
+ newOrder.productCheck.map((product, index) => {
758
+ var _a, _b;
759
+ let selectVariant = product.content.variants[parseInt((_a = product.selectIndex) !== null && _a !== void 0 ? _a : 0)];
760
+ selectVariant.preview_image = (_b = selectVariant.preview_image) !== null && _b !== void 0 ? _b : '';
761
+ let productIMG = typeof selectVariant.preview_image == 'string' ? selectVariant.preview_image : selectVariant.preview_image[0];
762
+ productIMG = productIMG
763
+ ? productIMG
764
+ : product.content.preview_image[0]
765
+ ? product.content.preview_image[0]
766
+ : BgWidget.noImageURL;
767
+ selectVariant.qty = selectVariant.qty || 1;
768
+ returnHTML += html `
767
769
  <div style="width: 100%;display: flex;align-items: center;position: relative;padding-right: 20px;">
768
770
  <div class="flex-fill d-flex align-items-center col-5" style="font-size: 16px;font-weight: 700;gap: 12px;">
769
771
  <div style="width: 54px;height: 54px; background: url('${productIMG}') lightgray 50% / cover no-repeat;"></div>
@@ -773,33 +775,6 @@ export class BgRecommend {
773
775
  <div style="text-overflow: ellipsis;white-space: nowrap;overflow: hidden;width: 100%;">
774
776
  ${product.content.title}
775
777
  </div>
776
- <div class="d-flex" style="gap:8px;font-weight: 400;">
777
- ${(() => {
778
- if (selectVariant.spec.length > 0) {
779
- let tempHTML = ``;
780
- selectVariant.spec.map((spec) => {
781
- tempHTML += html ` <div
782
- style="display: flex;height: 22px;padding: 4px 6px;justify-content: center;align-items: center;gap: 10px;border-radius: 7px;background: #EAEAEA;"
783
- >
784
- ${spec}
785
- </div>`;
786
- });
787
- return tempHTML;
788
- }
789
- else {
790
- return html `
791
- <div
792
- style="display: flex;height: 22px;padding: 4px 6px;justify-content: center;align-items: center;gap: 10px;border-radius: 7px;background: #EAEAEA;"
793
- >
794
- 單一規格
795
- </div>
796
- `;
797
- }
798
- })()}
799
- </div>
800
- <div style="color: #8D8D8D;font-size: 14px;font-weight: 400;">
801
- 存貨單位 (SKU): ${selectVariant.sku.length ? selectVariant.sku : 'sku未指定'}
802
- </div>
803
778
  </div>
804
779
  </div>
805
780
  <div
@@ -807,9 +782,9 @@ export class BgRecommend {
807
782
  style="display: flex;padding-right: 40px;align-items: flex-start;font-size: 16px;font-weight: 400;"
808
783
  >
809
784
  $${(() => {
810
- const price = parseInt(`${selectVariant.sale_price}`, 10);
811
- return isNaN(price) ? 0 : price.toLocaleString();
812
- })()}
785
+ const price = parseInt(`${selectVariant.sale_price}`, 10);
786
+ return isNaN(price) ? 0 : price.toLocaleString();
787
+ })()}
813
788
  </div>
814
789
  <div style="min-width: 6%;font-size: 16px;font-weight: 400;width: 100px;text-align: right;">
815
790
  <span>$${(selectVariant.sale_price * selectVariant.qty).toLocaleString()}</span>
@@ -817,9 +792,9 @@ export class BgRecommend {
817
792
  class="d-flex align-items-center cursor_pointer"
818
793
  style="position: absolute;right:0;top:50%;transform: translateY(-50%)"
819
794
  onclick="${gvc.event(() => {
820
- newOrder.productCheck.splice(index, 1);
821
- gvc.notifyDataChange('listProduct');
822
- })}"
795
+ newOrder.productCheck.splice(index, 1);
796
+ gvc.notifyDataChange('listProduct');
797
+ })}"
823
798
  >
824
799
  <svg xmlns="http://www.w3.org/2000/svg" width="11" height="10" viewBox="0 0 11 10" fill="none">
825
800
  <path
@@ -839,9 +814,14 @@ export class BgRecommend {
839
814
  </div>
840
815
  </div>
841
816
  `;
842
- });
817
+ });
818
+ }
819
+ return returnHTML;
820
+ }
821
+ catch (e) {
822
+ console.log(e);
823
+ return `error`;
843
824
  }
844
- return returnHTML;
845
825
  },
846
826
  divCreate: {
847
827
  style: `display: flex;flex-direction: column;align-items: flex-start;gap: 18px;align-self: stretch;`,
@@ -854,271 +834,32 @@ export class BgRecommend {
854
834
  return html `
855
835
  <div
856
836
  class="w-100 d-flex justify-content-center align-items-center"
857
- style="color: #36B;"
837
+ style="color: #36B;gap:5px;"
858
838
  onclick="${gvc.event(() => {
859
839
  let confirm = true;
860
- window.parent.glitter.innerDialog((gvc) => {
861
- newOrder.query = '';
862
- newOrder.search = '';
863
- newOrder.productArray = [];
864
- return gvc.bindView({
865
- bind: 'addDialog',
866
- view: () => {
867
- var _a;
868
- let width = window.innerWidth > 1000 ? 690 : 350;
869
- let searchLoading = false;
870
- return html ` <div
871
- style="display: flex;width: ${width}px;flex-direction: column;align-items: flex-start;gap: 18px;border-radius: 10px;background: #FFF;"
872
- >
873
- <div
874
- class="w-100"
875
- style="display: flex;height: 46px;padding: 20px 20px 12px;align-items: center;align-self: stretch;color: #393939;font-size: 16px;font-weight: 700;"
876
- >
877
- 搜尋商品
878
- </div>
879
- <div class="w-100" style="display: flex;flex-direction: column;align-items: flex-start;gap: 12px;">
880
- <div
881
- class="w-100"
882
- style="display: flex;padding: 0px 24px;flex-direction: column;align-items: center;gap: 18px;"
883
- >
884
- <div
885
- style="display: flex;justify-content: center;align-items: flex-start;gap: 12px;align-self: stretch;"
886
- >
887
- <div class="w-100 position-relative">
888
- <i
889
- class="fa-regular fa-magnifying-glass"
890
- style="font-size: 18px; color: #A0A0A0; position: absolute; left: 18px; top: 50%; transform: translateY(-50%);"
891
- aria-hidden="true"
892
- ></i>
893
- <input
894
- class="form-control h-100"
895
- style="border-radius: 10px; border: 1px solid #DDD; padding-left: 50px;"
896
- placeholder="輸入商品名稱或商品貨號"
897
- oninput="${gvc.event((e) => {
898
- searchLoading = false;
899
- newOrder.query = e.value;
900
- newOrder.productArray = [];
901
- gvc.notifyDataChange('productArray');
902
- })}"
903
- value="${(_a = newOrder.query) !== null && _a !== void 0 ? _a : ''}"
904
- />
905
- </div>
906
-
907
- ${BgWidget.updownFilter({
908
- gvc,
909
- callback: (value) => {
910
- searchLoading = false;
911
- newOrder.orderString = value;
912
- newOrder.productArray = [];
913
- gvc.notifyDataChange('productArray');
914
- },
915
- default: newOrder.orderString || 'default',
916
- options: FilterOptions.productOrderBy,
917
- })}
918
- </div>
919
- <div
920
- style="height:350px;display: flex;justify-content: center;align-items: flex-start;padding-right: 24px;align-self: stretch;overflow-y: scroll;"
921
- >
922
- ${gvc.bindView({
923
- bind: 'productArray',
924
- view: () => {
925
- if (!searchLoading) {
926
- ApiShop.getProduct({
927
- page: 0,
928
- limit: 20,
929
- search: newOrder.query,
930
- orderBy: newOrder.orderString,
931
- }).then((data) => {
932
- searchLoading = true;
933
- newOrder.productArray = data.response.data;
934
- gvc.notifyDataChange('productArray');
935
- });
936
- return BgWidget.spinner();
937
- }
938
- if (newOrder.productArray.length == 0) {
939
- return html ` <div
940
- class="w-100 h-100 d-flex align-items-center justify-content-center"
941
- style="color:#8D8D8D;"
942
- >
943
- 查無此商品
944
- </div>`;
945
- }
946
- return newOrder.productArray
947
- .map((product, productIndex) => {
948
- return gvc.bindView({
949
- bind: `product${productIndex}`,
950
- view: () => {
951
- return html `
952
- ${(() => {
953
- if (product.select) {
954
- return html ` <svg
955
- xmlns="http://www.w3.org/2000/svg"
956
- width="16"
957
- height="16"
958
- viewBox="0 0 16 16"
959
- fill="none"
960
- onclick="${gvc.event(() => {
961
- product.select = false;
962
- gvc.notifyDataChange(`product${productIndex}`);
963
- })}"
964
- >
965
- <rect
966
- width="16"
967
- height="16"
968
- rx="3"
969
- fill="#393939"
970
- />
971
- <path
972
- d="M4.5 8.5L7 11L11.5 5"
973
- stroke="white"
974
- stroke-width="2"
975
- stroke-linecap="round"
976
- stroke-linejoin="round"
977
- />
978
- </svg>`;
979
- }
980
- else {
981
- return html `
982
- <div
983
- style="display: flex;align-items: center;justify-content: center;height: 60px;width: 16px;cursor: pointer;"
984
- onclick="${gvc.event(() => {
985
- product.select = true;
986
- if (product.content.variants.length > 1) {
987
- product.selectIndex = window.parent.document.querySelector('.varitantSelect').value;
988
- }
989
- gvc.notifyDataChange(`product${productIndex}`);
990
- })}"
991
- >
992
- <div
993
- style="width: 16px;height: 16px;border-radius: 3px;border: 1px solid #DDD;cursor: pointer;"
994
- ></div>
995
- </div>
996
- `;
997
- }
998
- })()}
999
- <div
1000
- style="width: 50px;height: 50px;border-radius: 5px;background: url('${product
1001
- .content
1002
- .preview_image[0]}') lightgray 50% / cover no-repeat;"
1003
- ></div>
1004
- <div class="flex-fill d-flex flex-column">
1005
- <div
1006
- style="color:#393939;font-size: 14px;font-weight: 400;margin-bottom: 4px;"
1007
- >
1008
- ${product.content.title}
1009
- </div>
1010
- ${(() => {
1011
- if (product.content.variants.length > 1) {
1012
- return html `
1013
- <select
1014
- class="w-100 d-flex align-items-center form-select varitantSelect"
1015
- style="border-radius: 10px;border: 1px solid #DDD;padding: 6px 18px;"
1016
- onchange="${gvc.event((e) => {
1017
- product.selectIndex = e.value;
1018
- })}"
1019
- >
1020
- ${(() => {
1021
- let optionHTML = ``;
1022
- product.content.variants.map((variant, index) => {
1023
- optionHTML += html `
1024
- <option
1025
- value="${index}"
1026
- ${(() => {
1027
- if (product.selectIndex ==
1028
- index)
1029
- return `selected`;
1030
- else
1031
- return ``;
1032
- })()}
1033
- >
1034
- ${variant.spec.join(', ')}
1035
- </option>
1036
- `;
1037
- });
1038
- return optionHTML;
1039
- })()}
1040
- </select>
1041
- `;
1042
- }
1043
- else {
1044
- return `<div class="d-flex align-items-center" style="height: 34px;color: #8D8D8D;font-size: 14px;font-weight: 400;">單一規格</div>`;
1045
- }
1046
- })()}
1047
- </div>
1048
- `;
1049
- },
1050
- divCreate: {
1051
- style: `display: flex;padding: 0px 12px;align-items: center;gap: 18px;align-self: stretch;`,
1052
- },
1053
- });
1054
- })
1055
- .join('');
1056
- },
1057
- divCreate: {
1058
- class: `d-flex flex-column h-100`,
1059
- style: `gap: 18px;width:100%;`,
1060
- },
1061
- })}
1062
- </div>
1063
- </div>
1064
- <div
1065
- class="w-100"
1066
- style="display: flex;padding: 12px 20px;align-items: center;justify-content: end;gap: 10px;"
1067
- >
1068
- ${BgWidget.cancel(gvc.event(() => {
1069
- confirm = false;
1070
- gvc.closeDialog();
1071
- }))}
1072
- ${BgWidget.save(gvc.event(() => {
1073
- confirm = true;
1074
- newOrder.productTemp = [];
1075
- newOrder.productArray.map((product) => {
1076
- if (product.select) {
1077
- newOrder.productTemp.push(product);
1078
- }
1079
- });
1080
- gvc.closeDialog();
1081
- }))}
1082
- </div>
1083
- </div>
1084
- </div>`;
1085
- },
1086
- divCreate: {},
1087
- });
1088
- }, 'addProduct', {
1089
- dismiss: () => {
1090
- if (confirm) {
1091
- if (newOrder.productCheck.length > 0) {
1092
- const updateProductCheck = (tempData) => {
1093
- var _a;
1094
- const productData = newOrder.productCheck.find((p) => {
1095
- return p.id === tempData.id && p.selectIndex === tempData.selectIndex;
1096
- });
1097
- if (productData) {
1098
- const index = parseInt((_a = productData.selectIndex) !== null && _a !== void 0 ? _a : '0', 10);
1099
- productData.content.variants[index].qty++;
1100
- tempData.add = true;
1101
- }
1102
- else {
1103
- newOrder.productCheck.push(tempData);
1104
- }
1105
- };
1106
- newOrder.productTemp.forEach(updateProductCheck);
1107
- }
1108
- else {
1109
- newOrder.productCheck = newOrder.productTemp;
1110
- }
1111
- gvc.notifyDataChange(['listProduct', 'addProduct']);
1112
- }
840
+ BgProduct.productsDialog({
841
+ gvc: gvc,
842
+ default: newOrder.productCheck.map((dd) => {
843
+ return dd.id;
844
+ }),
845
+ callback: (value) => __awaiter(this, void 0, void 0, function* () {
846
+ const dialog = new ShareDialog(glitter);
847
+ dialog.dataLoading({ visible: true });
848
+ const pd = yield ApiShop.getProduct({ limit: 1000, page: 0, id_list: value.join(',') });
849
+ newOrder.productCheck = pd.response.data;
850
+ dialog.dataLoading({ visible: false });
851
+ gvc.notifyDataChange(id);
852
+ }),
853
+ filter: (d1) => {
854
+ return !newOrder.productCheck.find((dd) => {
855
+ return dd.id === d1;
856
+ });
1113
857
  },
1114
858
  });
1115
859
  })}"
1116
860
  >
1117
- 新增一個商品
1118
- <svg style="margin-left: 5px;" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="none">
1119
- <path d="M1.5 7.23926H12.5" stroke="#3366BB" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
1120
- <path d="M6.76172 1.5L6.76172 12.5" stroke="#3366BB" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
1121
- </svg>
861
+ 設定分潤商品
862
+ <i class="fa-duotone fa-solid fa-gear"></i>
1122
863
  </div>
1123
864
  `;
1124
865
  },