@ctzy-web-client/plugin-component-vue 1.0.39 → 1.0.41

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.
Files changed (24) hide show
  1. package/es/advance-select/advance-option.mjs +2 -2
  2. package/es/pct-filter-panel/pct-compents/index.mjs +1 -1
  3. package/es/pct-filter-panel/pct-compents/pct-multiple-menu-condition.mjs +2 -2
  4. package/es/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.mjs +145 -79
  5. package/es/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.vue_vue_type_style_index_0_scoped_c5c05287_lang.mjs +13 -0
  6. package/es/plugins.css +1 -0
  7. package/lib/advance-select/advance-option.js +2 -2
  8. package/lib/pct-filter-panel/pct-compents/index.js +2 -2
  9. package/lib/pct-filter-panel/pct-compents/pct-multiple-menu-condition.js +2 -2
  10. package/lib/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.js +144 -78
  11. package/lib/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.vue_vue_type_style_index_0_scoped_c5c05287_lang.js +17 -0
  12. package/lib/plugins.css +1 -0
  13. package/package.json +1 -1
  14. package/src/advance-select/advance-option.vue +4 -4
  15. package/src/pct-filter-panel/pct-compents/index.js +1 -1
  16. package/src/pct-filter-panel/pct-compents/pct-multiple-menu-condition.vue +4 -4
  17. package/src/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.vue +165 -95
  18. package/style/index.css +1 -1
  19. package/style/src/var.scss +2 -0
  20. package/style/var.css +1 -1
  21. package/es/make-installer.css +0 -1
  22. package/lib/make-installer.css +0 -1
  23. /package/es/advance-select/{advance-option.vue_vue_type_style_index_0_scoped_1e505c71_lang.mjs → advance-option.vue_vue_type_style_index_0_scoped_9ba46efc_lang.mjs} +0 -0
  24. /package/lib/advance-select/{advance-option.vue_vue_type_style_index_0_scoped_1e505c71_lang.js → advance-option.vue_vue_type_style_index_0_scoped_9ba46efc_lang.js} +0 -0
@@ -1,5 +1,7 @@
1
1
  <template>
2
- <span v-if="showTitle" :class="ns.e('title')">{{column.title}}</span>
2
+ <div :class="ns.e('conditbox')">
3
+ <span v-if="showTitle" :class="ns.e('title')">{{ column.title }}</span>
4
+
3
5
  <ElSelect
4
6
  v-model="modelValue"
5
7
  clearable
@@ -9,135 +11,203 @@
9
11
  :loading="loading"
10
12
  @visible-change="visibleChange"
11
13
  :remote="remote"
12
- :remote-method="remoteMethod"
14
+ :remote-method="handleFieldSearch"
13
15
  :size="size"
14
16
  :class="ns.e('multiple')"
15
17
  collapse-tags
16
18
  collapse-tags-tooltip
17
19
  no-data-text="暂无数据"
18
20
  >
21
+ <slot>
19
22
  <ElOption
20
- v-for="(item, index) in data"
21
- :key="item[valueProp] + index"
22
- :value="item[valueProp] + ''"
23
- :label="item[labelProp]"
24
- />
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>
37
+ </div>
38
+ </ElOption>
39
+ </slot>
40
+
25
41
  </ElSelect>
42
+ </div>
26
43
  </template>
27
44
 
28
45
  <script setup>
29
- import {ElOption, ElSelect} from 'element-plus';
46
+ import { ElOption, ElSelect } from 'element-plus';
30
47
  import { useNamespace } from '@ctzy-web-client/web-base-client-vue';
31
- import {computed, unref, defineEmits, inject, ref, useAttrs} from 'vue';
32
- import {dataProps} from "../../hooks/use-data";
48
+ import { computed, unref, defineEmits, inject, ref, useAttrs, watch, onMounted } from 'vue';
49
+ import { dataProps } from '../../hooks/use-data';
33
50
  import {
34
- useService,
35
- HttpRequest,
36
- filterPanelItemKey,
51
+ useService,
52
+ HttpRequest,
53
+ filterPanelItemKey,
37
54
  } from '@ctzy-web-client/web-base-client-vue';
55
+ import { pinyin } from 'pinyin-pro';
56
+ import BwaAdvanceOption from "../../advance-select/advance-option.vue";
38
57
 
39
58
  const httpRequest = useService(HttpRequest);
59
+
40
60
  defineOptions({
41
- name: 'BwaPctMultipleMenuCondition',
42
- __conditionTitle__: '多选菜单-PZ',
43
- __conditionDefault__: () => [],
61
+ name: 'BwaPctMultipleMenuCondition',
62
+ __conditionTitle__: '多选菜单',
63
+ __conditionDefault__: () => [],
44
64
  });
45
65
 
46
-
47
66
  const props = defineProps({
48
- ...dataProps,
49
- modelValue: {
50
- type: null,
51
- },
52
- options: {
53
- type: Array,
54
- default: () => [],
55
- },
56
- labelProp: {
57
- type: String,
58
- default: 'label',
59
- },
60
- valueProp: {
61
- type: String,
62
- default: 'value',
63
- },
64
- multiple: {
65
- type: Boolean,
66
- default: false,
67
- },
68
- filterable: {
69
- type: Boolean,
70
- default: true,
71
- },
72
- placeholder: {
73
- type: String,
74
- default: '请选择',
75
- },
76
- remote: {
77
- type: Boolean,
78
- default: true,
79
- },
80
- size: {
81
- type: String,
82
- default: 'small',
83
- }
67
+ ...dataProps,
68
+ modelValue: { type: null },
69
+ options: { type: Array, default: () => [] },
70
+ labelProp: { type: String, default: 'label' },
71
+ valueProp: { type: String, default: 'value' },
72
+ multiple: { type: Boolean, default: true },
73
+ showSearch: { type: Boolean, default: true },
74
+ filterable: { type: Boolean, default: true },
75
+ placeholder: { type: String, default: '请选择' },
76
+ remote: { type: Boolean, default: true },
77
+ showLetterAvatar: { type: Boolean, default: false },
78
+ size: { type: String, default: '' },
79
+ searchPlaceholder: { type: String, default: '' },
80
+ labelAttr: { type: String, default: '' },
81
+ valueAttr: { type: String, default: '' },
82
+ searchAttr: { type: String, default: '' },
83
+ itfInfo: { type: Object, default: null },
84
+ isRequiredByVisibleChange: { type: Boolean, default: false },
84
85
  });
85
- const ns = useNamespace('pctfilterpanel-item');
86
86
 
87
+ const ns = useNamespace('pctfilterpanel-item');
87
88
  const attrs = useAttrs();
88
- const showTitle = computed(() => attrs.showTitle)
89
-
90
- const data = ref([])
91
- const loading = ref(false)
89
+ const showTitle = computed(() => attrs.showTitle);
90
+ const data = ref([]);
91
+ const loading = ref(false);
92
92
  const emit = defineEmits(['update:modelValue', 'search', 'visible-change']);
93
-
94
93
  const filterPanelItem = inject(filterPanelItemKey, null);
95
94
  const column = computed(() => filterPanelItem?.column ?? null);
96
95
 
97
- const placeholderStr = computed(() => showTitle.value ? props.placeholder : column.value.title)
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
+ });
98
112
 
113
+ const placeholderStr = computed(() =>
114
+ showTitle.value ? props.placeholder : column.value?.title
115
+ );
116
+ const labelPropStr = computed(
117
+ () => column.value?.componentProps?.labelAttr || props.labelProp
118
+ );
119
+ const valuePropStr = computed(
120
+ () => column.value?.componentProps?.valueAttr || props.valueProp
121
+ );
122
+ const showLetterAvatarStatus = computed(
123
+ () => column.value?.componentProps?.showLetterAvatar || props.showLetterAvatar
124
+ );
99
125
 
100
- const getData = async (query) => {
101
- loading.value = true
102
- const { itfInfo, searchAttr } = column.value.componentProps
103
- const {url, method, options, params } = {
104
- url: unref(itfInfo).url,
105
- method: unref(itfInfo).method || 'POST',
106
- options: unref(itfInfo).options || {},
107
- params: { ...unref(itfInfo).params, [searchAttr]: query || ''} || {},
108
- }
109
- data.value = (await unref(httpRequest)[method.toLowerCase()](url, params, options))?.data
110
- loading.value = false
126
+ // 文字头像逻辑
127
+ const COLOR_POOL = ['#2DC86D', '#19BBFF', '#FFA901'];
128
+ function processLabel(label = '') {
129
+ const match = (label + '').match(/^(.*)\(/);
130
+ const txt = match ? match[1] : label;
131
+ const first = txt.charAt(0);
132
+ let letter = '#';
133
+ if (/[\u4e00-\u9fa5]/.test(first)) {
134
+ letter = pinyin(first, { pattern: 'first' }).toUpperCase();
135
+ } else if (/[a-zA-Z]/.test(first)) {
136
+ letter = first.toUpperCase();
137
+ }
138
+ let color = COLOR_POOL[0];
139
+ if (/[A-Z]/.test(letter)) {
140
+ color = COLOR_POOL[(letter.charCodeAt(0) - 65) % 3];
141
+ }
142
+ return { firstLetter: letter, color };
111
143
  }
112
- if (column.value?.componentProps) {
113
144
 
114
- } else {
115
- data.value = props.options ?? []
116
- }
117
- const visibleChange = (val) => {
118
- if (!val || !column.value.componentProps) return
119
- getData()
120
- }
145
+ // 修复2:getData 函数,处理 URL 拼接,避免 404
146
+ const getData = async (query = '') => {
147
+ if (!column.value?.componentProps?.itfInfo) {
148
+ data.value = props.options ?? [];
149
+ return;
150
+ }
151
+ loading.value = true;
152
+ try {
153
+ const { itfInfo, searchAttr } = column.value.componentProps;
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 || [];
161
+ } catch (err) {
162
+ console.error('请求失败:', err);
163
+ data.value = [];
164
+ } finally {
165
+ loading.value = false;
166
+ }
167
+ };
121
168
 
122
- const remoteMethod = (query) => {
123
- if (column.value.componentProps) {
124
- getData(query)
125
- } else {
126
- emit('search', query)
169
+ // 修复3:visibleChange 逻辑,确保请求能正常触发
170
+ const visibleChange = (val) => {
171
+ emit('visible-change', val);
172
+ if (val) {
173
+ // 展开时触发空搜索
174
+ if (props.isRequiredByVisibleChange) {
175
+ emit('search', '');
127
176
  }
128
- }
177
+ // 只有配置了 itfInfo 才请求接口
178
+ if (column.value?.componentProps?.itfInfo) {
179
+ getData('');
180
+ }
181
+ }
182
+ };
129
183
 
184
+ const handleFieldSearch = (query) => {
185
+ if (column.value?.componentProps?.itfInfo) {
186
+ getData(query);
187
+ } else {
188
+ emit('search', query);
189
+ }
190
+ };
191
+
192
+ // 双向绑定
130
193
  const modelValue = computed({
131
- get: () => {
132
- if (props.multiple) {
133
- return Array.isArray(props.modelValue)
134
- ? props.modelValue.map((item) => item + '')
135
- : [];
136
- } else {
137
- return props.modelValue == null ? '' : props.modelValue + '';
138
- }
139
- },
140
- set: (v) => emit('update:modelValue', v),
194
+ get: () => props.multiple
195
+ ? (Array.isArray(props.modelValue) ? props.modelValue : [])
196
+ : (props.modelValue ?? ''),
197
+ set: (v) => emit('update:modelValue', v),
141
198
  });
142
199
  </script>
143
200
 
201
+ <style scoped>
202
+ .letter-circle {
203
+ width: 22px;
204
+ height: 22px;
205
+ border-radius: 50%;
206
+ color: #fff;
207
+ display: flex;
208
+ align-items: center;
209
+ justify-content: center;
210
+ font-size: 12px;
211
+ flex-shrink: 0;
212
+ }
213
+ </style>