@ctzy-web-client/plugin-component-vue 1.0.38 → 1.0.40

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.
@@ -1,9 +1,10 @@
1
- import { defineComponent, useAttrs, computed, ref, inject, unref, openBlock, createElementBlock, normalizeClass, toDisplayString, createCommentVNode, createVNode, withCtx, Fragment, renderList, createBlock, createElementVNode, normalizeStyle } from 'vue';
1
+ import { defineComponent, useAttrs, computed, ref, inject, onMounted, unref, openBlock, createElementBlock, normalizeClass, toDisplayString, createCommentVNode, createVNode, withCtx, renderSlot, Fragment, renderList, createBlock, createElementVNode, normalizeStyle } from 'vue';
2
2
  import { ElSelect, ElOption } from 'element-plus';
3
3
  import { useService, HttpRequest, useNamespace, filterPanelItemKey } from '@ctzy-web-client/web-base-client-vue';
4
4
  import { dataProps } from '../../hooks/use-data/index.mjs';
5
5
  import { pinyin } from 'pinyin-pro';
6
- import './pct-multiple-menu-condition2.vue_vue_type_style_index_0_scoped_0a08184f_lang.mjs';
6
+ import '../../advance-select/advance-option.mjs';
7
+ import './pct-multiple-menu-condition2.vue_vue_type_style_index_0_scoped_c5c05287_lang.mjs';
7
8
  import _export_sfc from '../../_virtual/_plugin-vue_export-helper.mjs';
8
9
 
9
10
  // Inject __name helper
@@ -45,7 +46,6 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
45
46
  },
46
47
  emits: ["update:modelValue", "search", "visible-change"],
47
48
  setup(__props, { emit: __emit }) {
48
- var _a;
49
49
  const httpRequest = useService(HttpRequest);
50
50
  ;
51
51
  const props = __props;
@@ -57,40 +57,46 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
57
57
  const emit = __emit;
58
58
  const filterPanelItem = inject(filterPanelItemKey, null);
59
59
  const column = computed(() => {
60
- var _a2;
61
- return (_a2 = filterPanelItem == null ? void 0 : filterPanelItem.column) != null ? _a2 : null;
60
+ var _a;
61
+ return (_a = filterPanelItem == null ? void 0 : filterPanelItem.column) != null ? _a : null;
62
+ });
63
+ onMounted(() => {
64
+ var _a, _b, _c;
65
+ if (props.itfInfo && column.value) {
66
+ column.value.componentProps = {
67
+ itfInfo: props.itfInfo,
68
+ labelAttr: props.labelAttr,
69
+ valueAttr: props.valueAttr,
70
+ searchAttr: props.searchAttr,
71
+ showLetterAvatar: props.showLetterAvatar
72
+ };
73
+ }
74
+ if (!((_b = (_a = column.value) == null ? void 0 : _a.componentProps) == null ? void 0 : _b.itfInfo)) {
75
+ data.value = (_c = props.options) != null ? _c : [];
76
+ }
62
77
  });
63
- if (props.itfInfo && column.value) {
64
- column.value.componentProps = {
65
- itfInfo: props.itfInfo,
66
- labelAttr: props.labelAttr,
67
- valueAttr: props.valueAttr,
68
- searchAttr: props.searchAttr,
69
- showLetterAvatar: props.showLetterAvatar
70
- };
71
- }
72
78
  const placeholderStr = computed(
73
79
  () => {
74
- var _a2;
75
- return showTitle.value ? props.placeholder : (_a2 = column.value) == null ? void 0 : _a2.title;
80
+ var _a;
81
+ return showTitle.value ? props.placeholder : (_a = column.value) == null ? void 0 : _a.title;
76
82
  }
77
83
  );
78
84
  const labelPropStr = computed(
79
85
  () => {
80
- var _a2, _b;
81
- return ((_b = (_a2 = column.value) == null ? void 0 : _a2.componentProps) == null ? void 0 : _b.labelAttr) || props.labelProp;
86
+ var _a, _b;
87
+ return ((_b = (_a = column.value) == null ? void 0 : _a.componentProps) == null ? void 0 : _b.labelAttr) || props.labelProp;
82
88
  }
83
89
  );
84
90
  const valuePropStr = computed(
85
91
  () => {
86
- var _a2, _b;
87
- return ((_b = (_a2 = column.value) == null ? void 0 : _a2.componentProps) == null ? void 0 : _b.valueAttr) || props.valueProp;
92
+ var _a, _b;
93
+ return ((_b = (_a = column.value) == null ? void 0 : _a.componentProps) == null ? void 0 : _b.valueAttr) || props.valueProp;
88
94
  }
89
95
  );
90
96
  const showLetterAvatarStatus = computed(
91
97
  () => {
92
- var _a2, _b;
93
- return ((_b = (_a2 = column.value) == null ? void 0 : _a2.componentProps) == null ? void 0 : _b.showLetterAvatar) || props.showLetterAvatar;
98
+ var _a, _b;
99
+ return ((_b = (_a = column.value) == null ? void 0 : _a.componentProps) == null ? void 0 : _b.showLetterAvatar) || props.showLetterAvatar;
94
100
  }
95
101
  );
96
102
  const COLOR_POOL = ["#2DC86D", "#19BBFF", "#FFA901"];
@@ -110,46 +116,51 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
110
116
  }
111
117
  return { firstLetter: letter, color };
112
118
  }
113
- const getData = async (query) => {
114
- var _a2, _b, _c;
115
- if (!((_a2 = column.value) == null ? void 0 : _a2.componentProps)) {
116
- data.value = (_b = props.options) != null ? _b : [];
117
- loading.value = false;
119
+ const getData = async (query = "") => {
120
+ var _a, _b, _c;
121
+ if (!((_b = (_a = column.value) == null ? void 0 : _a.componentProps) == null ? void 0 : _b.itfInfo)) {
122
+ data.value = (_c = props.options) != null ? _c : [];
118
123
  return;
119
124
  }
120
125
  loading.value = true;
121
126
  try {
122
127
  const { itfInfo, searchAttr } = column.value.componentProps;
123
- const { url, method, options, params } = {
124
- url: unref(itfInfo).url,
125
- method: unref(itfInfo).method || "POST",
126
- options: unref(itfInfo).options || {},
127
- params: { ...unref(itfInfo).params, [searchAttr]: query || "" }
128
- };
129
- data.value = ((_c = await unref(httpRequest)[method.toLowerCase()](url, params, options)) == null ? void 0 : _c.data) || [];
128
+ const method = unref(itfInfo).method || "POST";
129
+ const url = unref(itfInfo).url;
130
+ const params = { ...unref(itfInfo).params, [searchAttr]: query };
131
+ const res = await unref(httpRequest)[method.toLowerCase()](url, params);
132
+ data.value = (res == null ? void 0 : res.data) || [];
130
133
  } catch (err) {
134
+ console.error("\u8BF7\u6C42\u5931\u8D25:", err);
131
135
  data.value = [];
132
136
  } finally {
133
137
  loading.value = false;
134
138
  }
135
139
  };
136
- data.value = (_a = props.options) != null ? _a : [];
137
140
  const visibleChange = (val) => {
138
- var _a2;
141
+ var _a, _b;
139
142
  emit("visible-change", val);
140
- if (val && props.isRequiredByVisibleChange)
141
- emit("search", "");
142
- if (val && ((_a2 = column.value) == null ? void 0 : _a2.componentProps))
143
- getData();
143
+ if (val) {
144
+ if (props.isRequiredByVisibleChange) {
145
+ emit("search", "");
146
+ }
147
+ if ((_b = (_a = column.value) == null ? void 0 : _a.componentProps) == null ? void 0 : _b.itfInfo) {
148
+ getData("");
149
+ }
150
+ }
144
151
  };
145
152
  const handleFieldSearch = (query) => {
146
- var _a2;
147
- ((_a2 = column.value) == null ? void 0 : _a2.componentProps) ? getData(query) : emit("search", query);
153
+ var _a, _b;
154
+ if ((_b = (_a = column.value) == null ? void 0 : _a.componentProps) == null ? void 0 : _b.itfInfo) {
155
+ getData(query);
156
+ } else {
157
+ emit("search", query);
158
+ }
148
159
  };
149
160
  const modelValue = computed({
150
161
  get: () => {
151
- var _a2;
152
- return props.multiple ? Array.isArray(props.modelValue) ? props.modelValue : [] : (_a2 = props.modelValue) != null ? _a2 : "";
162
+ var _a;
163
+ return props.multiple ? Array.isArray(props.modelValue) ? props.modelValue : [] : (_a = props.modelValue) != null ? _a : "";
153
164
  },
154
165
  set: (v) => emit("update:modelValue", v)
155
166
  });
@@ -179,33 +190,34 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
179
190
  "no-data-text": "\u6682\u65E0\u6570\u636E"
180
191
  }, {
181
192
  default: withCtx(() => [
182
- (openBlock(true), createElementBlock(Fragment, null, renderList(data.value, (item) => {
183
- return openBlock(), createBlock(unref(ElOption), {
184
- key: item[valuePropStr.value],
185
- value: item[valuePropStr.value],
186
- label: item[labelPropStr.value]
187
- }, {
188
- default: withCtx(() => [
189
- createCommentVNode(" \u6587\u5B57\u5934\u50CF "),
190
- createElementVNode("div", _hoisted_1, [
191
- showLetterAvatarStatus.value ? (openBlock(), createElementBlock("div", {
192
- key: 0,
193
- class: "letter-circle",
194
- style: normalizeStyle({ backgroundColor: processLabel(item[labelPropStr.value]).color })
195
- }, toDisplayString(processLabel(item[labelPropStr.value]).firstLetter), 5)) : createCommentVNode("v-if", true),
196
- createElementVNode("span", _hoisted_2, toDisplayString(item[labelPropStr.value]), 1)
197
- ])
198
- ]),
199
- _: 2
200
- }, 1032, ["value", "label"]);
201
- }), 128))
193
+ renderSlot(_ctx.$slots, "default", {}, () => [
194
+ (openBlock(true), createElementBlock(Fragment, null, renderList(data.value, (item) => {
195
+ return openBlock(), createBlock(unref(ElOption), {
196
+ key: item[valuePropStr.value],
197
+ value: item[valuePropStr.value],
198
+ label: item[labelPropStr.value]
199
+ }, {
200
+ default: withCtx(() => [
201
+ createElementVNode("div", _hoisted_1, [
202
+ showLetterAvatarStatus.value ? (openBlock(), createElementBlock("div", {
203
+ key: 0,
204
+ class: "letter-circle",
205
+ style: normalizeStyle({ backgroundColor: processLabel(item[labelPropStr.value]).color })
206
+ }, toDisplayString(processLabel(item[labelPropStr.value]).firstLetter), 5)) : createCommentVNode("v-if", true),
207
+ createElementVNode("span", _hoisted_2, toDisplayString(item[labelPropStr.value]), 1)
208
+ ])
209
+ ]),
210
+ _: 2
211
+ }, 1032, ["value", "label"]);
212
+ }), 128))
213
+ ], true)
202
214
  ]),
203
- _: 1
215
+ _: 3
204
216
  }, 8, ["modelValue", "multiple", "filterable", "placeholder", "loading", "remote", "size", "class"])
205
217
  ], 2);
206
218
  };
207
219
  }
208
220
  });
209
- var PctMultipleMenuCondition = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-0a08184f"], ["__file", "pct-multiple-menu-condition2.vue"]]);
221
+ var PctMultipleMenuCondition = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-c5c05287"], ["__file", "pct-multiple-menu-condition2.vue"]]);
210
222
 
211
223
  export { PctMultipleMenuCondition as default };
package/es/plugins.css ADDED
@@ -0,0 +1 @@
1
+ .letter-circle[data-v-9ba46efc]{font-size:14px;height:24px;margin-right:8px;width:24px}.letter-circle[data-v-9ba46efc],.letter-circle[data-v-c5c05287]{align-items:center;border-radius:50%;color:#fff;display:flex;justify-content:center}.letter-circle[data-v-c5c05287]{flex-shrink:0;font-size:12px;height:22px;width:22px}
@@ -7,7 +7,8 @@ var ElementPlus = require('element-plus');
7
7
  var webBaseClientVue = require('@ctzy-web-client/web-base-client-vue');
8
8
  var index = require('../../hooks/use-data/index.js');
9
9
  var pinyinPro = require('pinyin-pro');
10
- require('./pct-multiple-menu-condition2.vue_vue_type_style_index_0_scoped_0a08184f_lang.js');
10
+ require('../../advance-select/advance-option.js');
11
+ require('./pct-multiple-menu-condition2.vue_vue_type_style_index_0_scoped_c5c05287_lang.js');
11
12
  var _pluginVue_exportHelper = require('../../_virtual/_plugin-vue_export-helper.js');
12
13
 
13
14
  // Inject __name helper
@@ -49,7 +50,6 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
49
50
  },
50
51
  emits: ["update:modelValue", "search", "visible-change"],
51
52
  setup(__props, { emit: __emit }) {
52
- var _a;
53
53
  const httpRequest = webBaseClientVue.useService(webBaseClientVue.HttpRequest);
54
54
  ;
55
55
  const props = __props;
@@ -61,40 +61,46 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
61
61
  const emit = __emit;
62
62
  const filterPanelItem = vue.inject(webBaseClientVue.filterPanelItemKey, null);
63
63
  const column = vue.computed(() => {
64
- var _a2;
65
- return (_a2 = filterPanelItem == null ? void 0 : filterPanelItem.column) != null ? _a2 : null;
64
+ var _a;
65
+ return (_a = filterPanelItem == null ? void 0 : filterPanelItem.column) != null ? _a : null;
66
+ });
67
+ vue.onMounted(() => {
68
+ var _a, _b, _c;
69
+ if (props.itfInfo && column.value) {
70
+ column.value.componentProps = {
71
+ itfInfo: props.itfInfo,
72
+ labelAttr: props.labelAttr,
73
+ valueAttr: props.valueAttr,
74
+ searchAttr: props.searchAttr,
75
+ showLetterAvatar: props.showLetterAvatar
76
+ };
77
+ }
78
+ if (!((_b = (_a = column.value) == null ? void 0 : _a.componentProps) == null ? void 0 : _b.itfInfo)) {
79
+ data.value = (_c = props.options) != null ? _c : [];
80
+ }
66
81
  });
67
- if (props.itfInfo && column.value) {
68
- column.value.componentProps = {
69
- itfInfo: props.itfInfo,
70
- labelAttr: props.labelAttr,
71
- valueAttr: props.valueAttr,
72
- searchAttr: props.searchAttr,
73
- showLetterAvatar: props.showLetterAvatar
74
- };
75
- }
76
82
  const placeholderStr = vue.computed(
77
83
  () => {
78
- var _a2;
79
- return showTitle.value ? props.placeholder : (_a2 = column.value) == null ? void 0 : _a2.title;
84
+ var _a;
85
+ return showTitle.value ? props.placeholder : (_a = column.value) == null ? void 0 : _a.title;
80
86
  }
81
87
  );
82
88
  const labelPropStr = vue.computed(
83
89
  () => {
84
- var _a2, _b;
85
- return ((_b = (_a2 = column.value) == null ? void 0 : _a2.componentProps) == null ? void 0 : _b.labelAttr) || props.labelProp;
90
+ var _a, _b;
91
+ return ((_b = (_a = column.value) == null ? void 0 : _a.componentProps) == null ? void 0 : _b.labelAttr) || props.labelProp;
86
92
  }
87
93
  );
88
94
  const valuePropStr = vue.computed(
89
95
  () => {
90
- var _a2, _b;
91
- return ((_b = (_a2 = column.value) == null ? void 0 : _a2.componentProps) == null ? void 0 : _b.valueAttr) || props.valueProp;
96
+ var _a, _b;
97
+ return ((_b = (_a = column.value) == null ? void 0 : _a.componentProps) == null ? void 0 : _b.valueAttr) || props.valueProp;
92
98
  }
93
99
  );
94
100
  const showLetterAvatarStatus = vue.computed(
95
101
  () => {
96
- var _a2, _b;
97
- return ((_b = (_a2 = column.value) == null ? void 0 : _a2.componentProps) == null ? void 0 : _b.showLetterAvatar) || props.showLetterAvatar;
102
+ var _a, _b;
103
+ return ((_b = (_a = column.value) == null ? void 0 : _a.componentProps) == null ? void 0 : _b.showLetterAvatar) || props.showLetterAvatar;
98
104
  }
99
105
  );
100
106
  const COLOR_POOL = ["#2DC86D", "#19BBFF", "#FFA901"];
@@ -114,46 +120,51 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
114
120
  }
115
121
  return { firstLetter: letter, color };
116
122
  }
117
- const getData = async (query) => {
118
- var _a2, _b, _c;
119
- if (!((_a2 = column.value) == null ? void 0 : _a2.componentProps)) {
120
- data.value = (_b = props.options) != null ? _b : [];
121
- loading.value = false;
123
+ const getData = async (query = "") => {
124
+ var _a, _b, _c;
125
+ if (!((_b = (_a = column.value) == null ? void 0 : _a.componentProps) == null ? void 0 : _b.itfInfo)) {
126
+ data.value = (_c = props.options) != null ? _c : [];
122
127
  return;
123
128
  }
124
129
  loading.value = true;
125
130
  try {
126
131
  const { itfInfo, searchAttr } = column.value.componentProps;
127
- const { url, method, options, params } = {
128
- url: vue.unref(itfInfo).url,
129
- method: vue.unref(itfInfo).method || "POST",
130
- options: vue.unref(itfInfo).options || {},
131
- params: { ...vue.unref(itfInfo).params, [searchAttr]: query || "" }
132
- };
133
- data.value = ((_c = await vue.unref(httpRequest)[method.toLowerCase()](url, params, options)) == null ? void 0 : _c.data) || [];
132
+ const method = vue.unref(itfInfo).method || "POST";
133
+ const url = vue.unref(itfInfo).url;
134
+ const params = { ...vue.unref(itfInfo).params, [searchAttr]: query };
135
+ const res = await vue.unref(httpRequest)[method.toLowerCase()](url, params);
136
+ data.value = (res == null ? void 0 : res.data) || [];
134
137
  } catch (err) {
138
+ console.error("\u8BF7\u6C42\u5931\u8D25:", err);
135
139
  data.value = [];
136
140
  } finally {
137
141
  loading.value = false;
138
142
  }
139
143
  };
140
- data.value = (_a = props.options) != null ? _a : [];
141
144
  const visibleChange = (val) => {
142
- var _a2;
145
+ var _a, _b;
143
146
  emit("visible-change", val);
144
- if (val && props.isRequiredByVisibleChange)
145
- emit("search", "");
146
- if (val && ((_a2 = column.value) == null ? void 0 : _a2.componentProps))
147
- getData();
147
+ if (val) {
148
+ if (props.isRequiredByVisibleChange) {
149
+ emit("search", "");
150
+ }
151
+ if ((_b = (_a = column.value) == null ? void 0 : _a.componentProps) == null ? void 0 : _b.itfInfo) {
152
+ getData("");
153
+ }
154
+ }
148
155
  };
149
156
  const handleFieldSearch = (query) => {
150
- var _a2;
151
- ((_a2 = column.value) == null ? void 0 : _a2.componentProps) ? getData(query) : emit("search", query);
157
+ var _a, _b;
158
+ if ((_b = (_a = column.value) == null ? void 0 : _a.componentProps) == null ? void 0 : _b.itfInfo) {
159
+ getData(query);
160
+ } else {
161
+ emit("search", query);
162
+ }
152
163
  };
153
164
  const modelValue = vue.computed({
154
165
  get: () => {
155
- var _a2;
156
- return props.multiple ? Array.isArray(props.modelValue) ? props.modelValue : [] : (_a2 = props.modelValue) != null ? _a2 : "";
166
+ var _a;
167
+ return props.multiple ? Array.isArray(props.modelValue) ? props.modelValue : [] : (_a = props.modelValue) != null ? _a : "";
157
168
  },
158
169
  set: (v) => emit("update:modelValue", v)
159
170
  });
@@ -183,33 +194,34 @@ const _sfc_main = /* @__PURE__ */ Object.assign(__default__, {
183
194
  "no-data-text": "\u6682\u65E0\u6570\u636E"
184
195
  }, {
185
196
  default: vue.withCtx(() => [
186
- (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(data.value, (item) => {
187
- return vue.openBlock(), vue.createBlock(vue.unref(ElementPlus.ElOption), {
188
- key: item[valuePropStr.value],
189
- value: item[valuePropStr.value],
190
- label: item[labelPropStr.value]
191
- }, {
192
- default: vue.withCtx(() => [
193
- vue.createCommentVNode(" \u6587\u5B57\u5934\u50CF "),
194
- vue.createElementVNode("div", _hoisted_1, [
195
- showLetterAvatarStatus.value ? (vue.openBlock(), vue.createElementBlock("div", {
196
- key: 0,
197
- class: "letter-circle",
198
- style: vue.normalizeStyle({ backgroundColor: processLabel(item[labelPropStr.value]).color })
199
- }, vue.toDisplayString(processLabel(item[labelPropStr.value]).firstLetter), 5)) : vue.createCommentVNode("v-if", true),
200
- vue.createElementVNode("span", _hoisted_2, vue.toDisplayString(item[labelPropStr.value]), 1)
201
- ])
202
- ]),
203
- _: 2
204
- }, 1032, ["value", "label"]);
205
- }), 128))
197
+ vue.renderSlot(_ctx.$slots, "default", {}, () => [
198
+ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(data.value, (item) => {
199
+ return vue.openBlock(), vue.createBlock(vue.unref(ElementPlus.ElOption), {
200
+ key: item[valuePropStr.value],
201
+ value: item[valuePropStr.value],
202
+ label: item[labelPropStr.value]
203
+ }, {
204
+ default: vue.withCtx(() => [
205
+ vue.createElementVNode("div", _hoisted_1, [
206
+ showLetterAvatarStatus.value ? (vue.openBlock(), vue.createElementBlock("div", {
207
+ key: 0,
208
+ class: "letter-circle",
209
+ style: vue.normalizeStyle({ backgroundColor: processLabel(item[labelPropStr.value]).color })
210
+ }, vue.toDisplayString(processLabel(item[labelPropStr.value]).firstLetter), 5)) : vue.createCommentVNode("v-if", true),
211
+ vue.createElementVNode("span", _hoisted_2, vue.toDisplayString(item[labelPropStr.value]), 1)
212
+ ])
213
+ ]),
214
+ _: 2
215
+ }, 1032, ["value", "label"]);
216
+ }), 128))
217
+ ], true)
206
218
  ]),
207
- _: 1
219
+ _: 3
208
220
  }, 8, ["modelValue", "multiple", "filterable", "placeholder", "loading", "remote", "size", "class"])
209
221
  ], 2);
210
222
  };
211
223
  }
212
224
  });
213
- var PctMultipleMenuCondition = /* @__PURE__ */ _pluginVue_exportHelper["default"](_sfc_main, [["__scopeId", "data-v-0a08184f"], ["__file", "pct-multiple-menu-condition2.vue"]]);
225
+ var PctMultipleMenuCondition = /* @__PURE__ */ _pluginVue_exportHelper["default"](_sfc_main, [["__scopeId", "data-v-c5c05287"], ["__file", "pct-multiple-menu-condition2.vue"]]);
214
226
 
215
227
  exports["default"] = PctMultipleMenuCondition;
@@ -0,0 +1 @@
1
+ .letter-circle[data-v-9ba46efc]{font-size:14px;height:24px;margin-right:8px;width:24px}.letter-circle[data-v-9ba46efc],.letter-circle[data-v-c5c05287]{align-items:center;border-radius:50%;color:#fff;display:flex;justify-content:center}.letter-circle[data-v-c5c05287]{flex-shrink:0;font-size:12px;height:22px;width:22px}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctzy-web-client/plugin-component-vue",
3
- "version": "1.0.38",
3
+ "version": "1.0.40",
4
4
  "main": "lib/index.js",
5
5
  "module": "es/index.mjs",
6
6
  "exports": {
@@ -18,24 +18,26 @@
18
18
  collapse-tags-tooltip
19
19
  no-data-text="暂无数据"
20
20
  >
21
- <ElOption
22
- v-for="item in data"
23
- :key="item[valuePropStr]"
24
- :value="item[valuePropStr]"
25
- :label="item[labelPropStr]"
26
- >
27
- <!-- 文字头像 -->
28
- <div style="display: flex; align-items: center">
29
- <div
30
- v-if="showLetterAvatarStatus"
31
- class="letter-circle"
32
- :style="{ backgroundColor: processLabel(item[labelPropStr]).color }"
33
- >
34
- {{ processLabel(item[labelPropStr]).firstLetter }}
21
+ <slot>
22
+ <ElOption
23
+ v-for="item in data"
24
+ :key="item[valuePropStr]"
25
+ :value="item[valuePropStr]"
26
+ :label="item[labelPropStr]"
27
+ >
28
+ <div style="display: flex; align-items: center">
29
+ <div
30
+ v-if="showLetterAvatarStatus"
31
+ class="letter-circle"
32
+ :style="{ backgroundColor: processLabel(item[labelPropStr]).color }"
33
+ >
34
+ {{ processLabel(item[labelPropStr]).firstLetter }}
35
+ </div>
36
+ <span style="margin-left: 8px">{{ item[labelPropStr] }}</span>
35
37
  </div>
36
- <span style="margin-left: 8px">{{ item[labelPropStr] }}</span>
37
- </div>
38
- </ElOption>
38
+ </ElOption>
39
+ </slot>
40
+
39
41
  </ElSelect>
40
42
  </div>
41
43
  </template>
@@ -43,7 +45,7 @@
43
45
  <script setup>
44
46
  import { ElOption, ElSelect } from 'element-plus';
45
47
  import { useNamespace } from '@ctzy-web-client/web-base-client-vue';
46
- import { computed, unref, defineEmits, inject, ref, useAttrs } from 'vue';
48
+ import { computed, unref, defineEmits, inject, ref, useAttrs, watch, onMounted } from 'vue';
47
49
  import { dataProps } from '../../hooks/use-data';
48
50
  import {
49
51
  useService,
@@ -51,6 +53,7 @@ import {
51
53
  filterPanelItemKey,
52
54
  } from '@ctzy-web-client/web-base-client-vue';
53
55
  import { pinyin } from 'pinyin-pro';
56
+ import BwaAdvanceOption from "../../advance-select/advance-option.vue";
54
57
 
55
58
  const httpRequest = useService(HttpRequest);
56
59
 
@@ -90,16 +93,22 @@ const emit = defineEmits(['update:modelValue', 'search', 'visible-change']);
90
93
  const filterPanelItem = inject(filterPanelItemKey, null);
91
94
  const column = computed(() => filterPanelItem?.column ?? null);
92
95
 
93
- // ====================== 配置覆盖 ======================
94
- if (props.itfInfo && column.value) {
95
- column.value.componentProps = {
96
- itfInfo: props.itfInfo,
97
- labelAttr: props.labelAttr,
98
- valueAttr: props.valueAttr,
99
- searchAttr: props.searchAttr,
100
- showLetterAvatar: props.showLetterAvatar,
101
- };
102
- }
96
+ // 修复1:在 onMounted 中赋值 itfInfo,此时 column 已初始化
97
+ onMounted(() => {
98
+ if (props.itfInfo && column.value) {
99
+ column.value.componentProps = {
100
+ itfInfo: props.itfInfo,
101
+ labelAttr: props.labelAttr,
102
+ valueAttr: props.valueAttr,
103
+ searchAttr: props.searchAttr,
104
+ showLetterAvatar: props.showLetterAvatar,
105
+ };
106
+ }
107
+ // 初始化数据
108
+ if (!column.value?.componentProps?.itfInfo) {
109
+ data.value = props.options ?? [];
110
+ }
111
+ });
103
112
 
104
113
  const placeholderStr = computed(() =>
105
114
  showTitle.value ? props.placeholder : column.value?.title
@@ -114,7 +123,7 @@ const showLetterAvatarStatus = computed(
114
123
  () => column.value?.componentProps?.showLetterAvatar || props.showLetterAvatar
115
124
  );
116
125
 
117
- // ====================== 文字头像 ======================
126
+ // 文字头像逻辑
118
127
  const COLOR_POOL = ['#2DC86D', '#19BBFF', '#FFA901'];
119
128
  function processLabel(label = '') {
120
129
  const match = (label + '').match(/^(.*)\(/);
@@ -133,45 +142,54 @@ function processLabel(label = '') {
133
142
  return { firstLetter: letter, color };
134
143
  }
135
144
 
136
- // ====================== 数据请求 ======================
137
- const getData = async (query) => {
138
- if (!column.value?.componentProps) {
145
+ // 修复2:getData 函数,处理 URL 拼接,避免 404
146
+ const getData = async (query = '') => {
147
+ if (!column.value?.componentProps?.itfInfo) {
139
148
  data.value = props.options ?? [];
140
- loading.value = false;
141
149
  return;
142
150
  }
143
-
144
151
  loading.value = true;
145
152
  try {
146
153
  const { itfInfo, searchAttr } = column.value.componentProps;
147
- const { url, method, options, params } = {
148
- url: unref(itfInfo).url,
149
- method: unref(itfInfo).method || 'POST',
150
- options: unref(itfInfo).options || {},
151
- params: { ...unref(itfInfo).params, [searchAttr]: query || '' } || {},
152
- };
153
- data.value = (await unref(httpRequest)[method.toLowerCase()](url, params, options))?.data || [];
154
+ const method = unref(itfInfo).method || 'POST';
155
+ const url = unref(itfInfo).url;
156
+ const params = { ...unref(itfInfo).params, [searchAttr]: query };
157
+
158
+ // 关键修复:移除多余的 baseURL 选项,避免重复拼接
159
+ const res = await unref(httpRequest)[method.toLowerCase()](url, params);
160
+ data.value = res?.data || [];
154
161
  } catch (err) {
162
+ console.error('请求失败:', err);
155
163
  data.value = [];
156
164
  } finally {
157
165
  loading.value = false;
158
166
  }
159
167
  };
160
168
 
161
- // 初始化
162
- data.value = props.options ?? [];
163
-
169
+ // 修复3:visibleChange 逻辑,确保请求能正常触发
164
170
  const visibleChange = (val) => {
165
171
  emit('visible-change', val);
166
- if (val && props.isRequiredByVisibleChange) emit('search', '');
167
- if (val && column.value?.componentProps) getData();
172
+ if (val) {
173
+ // 展开时触发空搜索
174
+ if (props.isRequiredByVisibleChange) {
175
+ emit('search', '');
176
+ }
177
+ // 只有配置了 itfInfo 才请求接口
178
+ if (column.value?.componentProps?.itfInfo) {
179
+ getData('');
180
+ }
181
+ }
168
182
  };
169
183
 
170
184
  const handleFieldSearch = (query) => {
171
- column.value?.componentProps ? getData(query) : emit('search', query);
185
+ if (column.value?.componentProps?.itfInfo) {
186
+ getData(query);
187
+ } else {
188
+ emit('search', query);
189
+ }
172
190
  };
173
191
 
174
- // ====================== 双向绑定 ======================
192
+ // 双向绑定
175
193
  const modelValue = computed({
176
194
  get: () => props.multiple
177
195
  ? (Array.isArray(props.modelValue) ? props.modelValue : [])
package/es/index.css DELETED
@@ -1 +0,0 @@
1
- .letter-circle[data-v-9ba46efc]{font-size:14px;height:24px;margin-right:8px;width:24px}.letter-circle[data-v-0a08184f],.letter-circle[data-v-9ba46efc]{align-items:center;border-radius:50%;color:#fff;display:flex;justify-content:center}.letter-circle[data-v-0a08184f]{flex-shrink:0;font-size:12px;height:22px;width:22px}
package/lib/index.css DELETED
@@ -1 +0,0 @@
1
- .letter-circle[data-v-9ba46efc]{font-size:14px;height:24px;margin-right:8px;width:24px}.letter-circle[data-v-0a08184f],.letter-circle[data-v-9ba46efc]{align-items:center;border-radius:50%;color:#fff;display:flex;justify-content:center}.letter-circle[data-v-0a08184f]{flex-shrink:0;font-size:12px;height:22px;width:22px}