@yoooloo42/joker 1.0.67 → 1.0.68

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/dist/index.esm.js CHANGED
@@ -41810,22 +41810,27 @@ const _hoisted_9$3 = { class: "select-submit" };
41810
41810
 
41811
41811
  var script$5 = {
41812
41812
  __name: 'index',
41813
- props: ["myProps"],
41813
+ props: {
41814
+ myProps: {
41815
+ type: Object,
41816
+ default: () => ({ readOnly: false, value: '', _id: null }) // 提供清晰的默认值
41817
+ }
41818
+ },
41814
41819
  emits: ['get-value'],
41815
41820
  setup(__props, { emit: __emit }) {
41816
41821
 
41817
41822
  const props = __props;
41818
41823
  const emit = __emit;
41819
41824
 
41820
- const value = ref(Object.assign({
41825
+ const value = reactive({
41821
41826
  code2: '',
41822
41827
  text2: '',
41823
41828
  code4: '',
41824
41829
  text4: '',
41825
41830
  code6: '',
41826
41831
  text6: '',
41827
- }, {code6: props.myProps.value}));
41828
- const popup = ref({
41832
+ });
41833
+ const popup = reactive({
41829
41834
  visible: false,
41830
41835
  select: {
41831
41836
  arrCode2: [],
@@ -41837,107 +41842,101 @@ const popup = ref({
41837
41842
  }
41838
41843
  });
41839
41844
 
41840
- onMounted(()=>{
41841
- request.ly0.storpro({
41845
+ onMounted(async ()=>{
41846
+ // 异步函数直接在 onMounted 顶层调用是允许的
41847
+ const result = await request.ly0.storpro({
41842
41848
  noSession: true,
41843
41849
  storproName: 'ly0d3.gbt2260code2.init',
41844
- }).then(result=>{
41845
- popup.value.select.arrCode2 = result.arrCode2;
41846
41850
  });
41851
+ popup.select.arrCode2 = result.arrCode2;
41847
41852
  });
41848
41853
 
41849
41854
  watch(() => props.myProps.value,
41850
- (valNew, valOld) => {
41851
- request.ly0.storpro({
41855
+ async (valNew, valOld) => {
41856
+ // 只有当传入的值有效时才进行网络请求
41857
+ if (!valNew) return;
41858
+
41859
+ const result = await request.ly0.storpro({
41852
41860
  noSession: true,
41853
41861
  storproName: 'ly0d3.gbt2260code6.get',
41854
- data: {
41855
- code6: valNew,
41856
- },
41857
- }).then(result=>{
41858
- if(result.itemCode6){
41859
- value.value = result.itemCode6;
41860
- }
41862
+ data: { code6: valNew },
41861
41863
  });
41864
+
41865
+ if(result.itemCode6){
41866
+ // 保持响应式
41867
+ Object.assign(value, result.itemCode6);
41868
+
41869
+ // 确保按顺序加载级联数据
41870
+ if (value.code2) {
41871
+ await hdlChangeCode2(value.code2);
41872
+ }
41873
+ if (value.code4) {
41874
+ await hdlChangeCode4(value.code4);
41875
+ }
41876
+ }
41862
41877
  },
41863
- {
41864
- immediate: true // 关键:让它在组件初始化时立即运行
41865
- }
41878
+ { immediate: true }
41866
41879
  );
41867
41880
 
41868
- const hdlPopup = () => {
41881
+ const hdlPopup = async () => {
41869
41882
  if (!props.myProps.readOnly) {
41870
- popup.value.select.code2 = value.value.code2;
41871
- hdlChangeCode2(popup.value.select.code2).then(() => {
41872
- popup.value.select.code4 = value.value.code4;
41873
- hdlChangeCode4(popup.value.select.code4).then(() => {
41874
- popup.value.select.code6 = value.value.code6;
41875
- popup.value.visible = true;
41876
- });
41877
- });
41883
+ popup.select.code2 = value.code2;
41884
+ await hdlChangeCode2(popup.select.code2);
41885
+
41886
+ popup.select.code4 = value.code4;
41887
+ await hdlChangeCode4(popup.select.code4);
41888
+
41889
+ popup.select.code6 = value.code6;
41890
+ popup.visible = true;
41878
41891
  }
41879
41892
  };
41880
41893
 
41881
- const hdlChangeCode2 = value => {
41882
- return new Promise((resolve, reject) => {
41883
- request.ly0.storpro({
41884
- noSession: true,
41885
- storproName: 'ly0d3.gbt2260code4.code2',
41886
- data: {code2: value},
41887
- }).then(result => {
41888
- popup.value.select.arrCode4 = result.arrCode4;
41889
- popup.value.select.code4 = '';
41890
- popup.value.select.arrCode6 = [];
41891
- popup.value.select.code6 = '';
41892
- resolve();
41893
- });
41894
- })
41894
+ const hdlChangeCode2 = async value => { // 使用 async 标记
41895
+ const result = await request.ly0.storpro({
41896
+ noSession: true,
41897
+ storproName: 'ly0d3.gbt2260code4.code2',
41898
+ data: {code2: value},
41899
+ });
41900
+
41901
+ popup.select.arrCode4 = result.arrCode4;
41902
+ popup.select.code4 = '';
41903
+ popup.select.arrCode6 = [];
41904
+ popup.select.code6 = '';
41895
41905
  };
41896
41906
 
41897
- const hdlChangeCode4 = value => {
41898
- return new Promise((resolve, reject) => {
41899
- request.ly0.storpro({
41900
- noSession: true,
41901
- storproName: 'ly0d3.gbt2260code6.code4',
41902
- data: {code4: value},
41903
- }).then(result => {
41904
- popup.value.select.arrCode6 = result.arrCode6;
41905
- popup.value.select.code6 = '';
41906
- resolve();
41907
- });
41908
- })
41907
+ const hdlChangeCode4 = async value => {
41908
+ const result = await request.ly0.storpro({
41909
+ noSession: true,
41910
+ storproName: 'ly0d3.gbt2260code6.code4',
41911
+ data: {code4: value},
41912
+ });
41913
+
41914
+ popup.select.arrCode6 = result.arrCode6;
41915
+ popup.select.code6 = '';
41909
41916
  };
41910
41917
 
41911
41918
  const hdlSubmit = () => {
41912
- value.value.code2 = popup.value.select.code2;
41913
- value.value.text2 = value.value.code2
41914
- ? popup.value.select.arrCode2.find(i => {
41915
- return i.code2 === value.value.code2
41916
- }).text2
41917
- : '';
41918
- value.value.code4 = popup.value.select.code4;
41919
- value.value.text4 = value.value.code4
41920
- ? popup.value.select.arrCode4.find(i => {
41921
- return i.code4 === value.value.code4
41922
- }).text4
41923
- : '';
41924
- value.value.code6 = popup.value.select.code6;
41925
- value.value.text6 = value.value.code6
41926
- ? popup.value.select.arrCode6.find(i => {
41927
- return i.code6 === value.value.code6
41928
- }).text6
41929
- : '';
41919
+ // ... (安全查找逻辑) ...
41920
+ value.code2 = popup.select.code2;
41921
+ const foundItem2 = popup.select.arrCode2.find(i => i.code2 === value.code2);
41922
+ value.text2 = foundItem2 ? foundItem2.text2 : '';
41923
+ value.code4 = popup.select.code4;
41924
+ const foundItem4 = popup.select.arrCode4.find(i => i.code4 === value.code4);
41925
+ value.text4 = foundItem4 ? foundItem4.text4 : '';
41926
+ value.code6 = popup.select.code6;
41927
+ const foundItem6 = popup.select.arrCode6.find(i => i.code6 === value.code6);
41928
+ value.text6 = foundItem6 ? foundItem6.text6 : '';
41930
41929
  emit("get-value", {
41931
- code6: value.value.code6
41932
- ? value.value.code6
41933
- : value.value.code4
41934
- ? value.value.code4
41935
- : value.value.code2
41936
- ? value.value.code2
41930
+ code6: value.code6
41931
+ ? value.code6
41932
+ : value.code4
41933
+ ? value.code4
41934
+ : value.code2
41935
+ ? value.code2
41937
41936
  : '',
41938
41937
  _id: '_id' in props.myProps ? props.myProps._id : null,
41939
41938
  });
41940
- popup.value.visible = false;
41939
+ popup.visible = false;
41941
41940
  };
41942
41941
 
41943
41942
  return (_ctx, _cache) => {
@@ -41966,35 +41965,35 @@ return (_ctx, _cache) => {
41966
41965
  : createCommentVNode("v-if", true)
41967
41966
  ]),
41968
41967
  createElementVNode("td", null, [
41969
- createElementVNode("span", _hoisted_1$5, toDisplayString('[' + (value.value.code2 ? value.value.code2 : '省') + ']'), 1 /* TEXT */)
41968
+ createElementVNode("span", _hoisted_1$5, toDisplayString('[' + (value.code2 ? value.code2 : '省') + ']'), 1 /* TEXT */)
41970
41969
  ]),
41971
41970
  createElementVNode("td", null, [
41972
- createElementVNode("span", _hoisted_2$5, toDisplayString(value.value.text2 ? value.value.text2 : ''), 1 /* TEXT */)
41971
+ createElementVNode("span", _hoisted_2$5, toDisplayString(value.text2 ? value.text2 : ''), 1 /* TEXT */)
41973
41972
  ])
41974
41973
  ]),
41975
41974
  createElementVNode("tr", null, [
41976
41975
  _cache[4] || (_cache[4] = createElementVNode("td", null, null, -1 /* CACHED */)),
41977
41976
  createElementVNode("td", null, [
41978
- createElementVNode("span", _hoisted_3$5, toDisplayString('[' + (value.value.code4 ? value.value.code4 : '市') + ']'), 1 /* TEXT */)
41977
+ createElementVNode("span", _hoisted_3$5, toDisplayString('[' + (value.code4 ? value.code4 : '市') + ']'), 1 /* TEXT */)
41979
41978
  ]),
41980
41979
  createElementVNode("td", null, [
41981
- createElementVNode("span", _hoisted_4$5, toDisplayString(value.value.text4 ? value.value.text4 : ''), 1 /* TEXT */)
41980
+ createElementVNode("span", _hoisted_4$5, toDisplayString(value.text4 ? value.text4 : ''), 1 /* TEXT */)
41982
41981
  ])
41983
41982
  ]),
41984
41983
  createElementVNode("tr", null, [
41985
41984
  _cache[5] || (_cache[5] = createElementVNode("td", null, null, -1 /* CACHED */)),
41986
41985
  createElementVNode("td", null, [
41987
- createElementVNode("span", _hoisted_5$5, toDisplayString('[' + (value.value.code6 ? value.value.code6 : '县') + ']'), 1 /* TEXT */)
41986
+ createElementVNode("span", _hoisted_5$5, toDisplayString('[' + (value.code6 ? value.code6 : '县') + ']'), 1 /* TEXT */)
41988
41987
  ]),
41989
41988
  createElementVNode("td", null, [
41990
- createElementVNode("span", _hoisted_6$5, toDisplayString(value.value.text6 ? value.value.text6 : ''), 1 /* TEXT */)
41989
+ createElementVNode("span", _hoisted_6$5, toDisplayString(value.text6 ? value.text6 : ''), 1 /* TEXT */)
41991
41990
  ])
41992
41991
  ])
41993
41992
  ])
41994
41993
  ]),
41995
41994
  createVNode(_component_el_dialog, {
41996
- modelValue: popup.value.visible,
41997
- "onUpdate:modelValue": _cache[3] || (_cache[3] = $event => ((popup.value.visible) = $event)),
41995
+ modelValue: popup.visible,
41996
+ "onUpdate:modelValue": _cache[3] || (_cache[3] = $event => ((popup.visible) = $event)),
41998
41997
  "custom-class": 'code-template-dialog',
41999
41998
  "close-on-press-escape": true,
42000
41999
  "append-to-body": "",
@@ -42011,18 +42010,18 @@ return (_ctx, _cache) => {
42011
42010
  ], -1 /* CACHED */)),
42012
42011
  createElementVNode("td", null, [
42013
42012
  createVNode(_component_el_select, {
42014
- modelValue: popup.value.select.code2,
42015
- "onUpdate:modelValue": _cache[0] || (_cache[0] = $event => ((popup.value.select.code2) = $event)),
42013
+ modelValue: popup.select.code2,
42014
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = $event => ((popup.select.code2) = $event)),
42016
42015
  filterable: "",
42017
42016
  class: "select",
42018
42017
  onChange: hdlChangeCode2
42019
42018
  }, {
42020
42019
  default: withCtx(() => [
42021
- (openBlock(true), createElementBlock(Fragment, null, renderList(popup.value.select.arrCode2, (item, index) => {
42020
+ (openBlock(true), createElementBlock(Fragment, null, renderList(popup.select.arrCode2, (item, index) => {
42022
42021
  return (openBlock(), createBlock(_component_el_option, {
42023
42022
  label: item.text2,
42024
42023
  value: item.code2,
42025
- key: index
42024
+ key: item.code2
42026
42025
  }, null, 8 /* PROPS */, ["label", "value"]))
42027
42026
  }), 128 /* KEYED_FRAGMENT */))
42028
42027
  ]),
@@ -42036,18 +42035,18 @@ return (_ctx, _cache) => {
42036
42035
  ], -1 /* CACHED */)),
42037
42036
  createElementVNode("td", null, [
42038
42037
  createVNode(_component_el_select, {
42039
- modelValue: popup.value.select.code4,
42040
- "onUpdate:modelValue": _cache[1] || (_cache[1] = $event => ((popup.value.select.code4) = $event)),
42038
+ modelValue: popup.select.code4,
42039
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = $event => ((popup.select.code4) = $event)),
42041
42040
  filterable: "",
42042
42041
  class: "select",
42043
42042
  onChange: hdlChangeCode4
42044
42043
  }, {
42045
42044
  default: withCtx(() => [
42046
- (openBlock(true), createElementBlock(Fragment, null, renderList(popup.value.select.arrCode4, (item, index) => {
42045
+ (openBlock(true), createElementBlock(Fragment, null, renderList(popup.select.arrCode4, (item, index) => {
42047
42046
  return (openBlock(), createBlock(_component_el_option, {
42048
42047
  label: item.text4,
42049
42048
  value: item.code4,
42050
- key: index
42049
+ key: item.code4
42051
42050
  }, null, 8 /* PROPS */, ["label", "value"]))
42052
42051
  }), 128 /* KEYED_FRAGMENT */))
42053
42052
  ]),
@@ -42061,17 +42060,17 @@ return (_ctx, _cache) => {
42061
42060
  ], -1 /* CACHED */)),
42062
42061
  createElementVNode("td", null, [
42063
42062
  createVNode(_component_el_select, {
42064
- modelValue: popup.value.select.code6,
42065
- "onUpdate:modelValue": _cache[2] || (_cache[2] = $event => ((popup.value.select.code6) = $event)),
42063
+ modelValue: popup.select.code6,
42064
+ "onUpdate:modelValue": _cache[2] || (_cache[2] = $event => ((popup.select.code6) = $event)),
42066
42065
  filterable: "",
42067
42066
  class: "select"
42068
42067
  }, {
42069
42068
  default: withCtx(() => [
42070
- (openBlock(true), createElementBlock(Fragment, null, renderList(popup.value.select.arrCode6, (item, index) => {
42069
+ (openBlock(true), createElementBlock(Fragment, null, renderList(popup.select.arrCode6, (item, index) => {
42071
42070
  return (openBlock(), createBlock(_component_el_option, {
42072
42071
  label: item.text6,
42073
42072
  value: item.code6,
42074
- key: index
42073
+ key: item.code6
42075
42074
  }, null, 8 /* PROPS */, ["label", "value"]))
42076
42075
  }), 128 /* KEYED_FRAGMENT */))
42077
42076
  ]),