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