@ctzy-web-client/plugin-component-vue 1.0.39 → 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.
- package/es/advance-select/advance-option.mjs +2 -2
- package/es/pct-filter-panel/pct-compents/index.mjs +1 -1
- package/es/pct-filter-panel/pct-compents/pct-multiple-menu-condition.mjs +2 -2
- package/es/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.mjs +145 -79
- package/es/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.vue_vue_type_style_index_0_scoped_c5c05287_lang.mjs +13 -0
- package/es/plugins.css +1 -0
- package/lib/advance-select/advance-option.js +2 -2
- package/lib/pct-filter-panel/pct-compents/index.js +2 -2
- package/lib/pct-filter-panel/pct-compents/pct-multiple-menu-condition.js +2 -2
- package/lib/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.js +144 -78
- package/lib/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.vue_vue_type_style_index_0_scoped_c5c05287_lang.js +17 -0
- package/lib/plugins.css +1 -0
- package/package.json +1 -1
- package/src/advance-select/advance-option.vue +4 -4
- package/src/pct-filter-panel/pct-compents/index.js +1 -1
- package/src/pct-filter-panel/pct-compents/pct-multiple-menu-condition.vue +4 -4
- package/src/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.vue +165 -95
- package/style/index.css +1 -1
- package/style/src/var.scss +2 -0
- package/style/var.css +1 -1
- package/es/make-installer.css +0 -1
- package/lib/make-installer.css +0 -1
- /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
- /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
|
-
|
|
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="
|
|
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="
|
|
21
|
-
:key="item[
|
|
22
|
-
:value="item[
|
|
23
|
-
:label="item[
|
|
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
|
|
48
|
+
import { computed, unref, defineEmits, inject, ref, useAttrs, watch, onMounted } from 'vue';
|
|
49
|
+
import { dataProps } from '../../hooks/use-data';
|
|
33
50
|
import {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
61
|
+
name: 'BwaPctMultipleMenuCondition',
|
|
62
|
+
__conditionTitle__: '多选菜单',
|
|
63
|
+
__conditionDefault__: () => [],
|
|
44
64
|
});
|
|
45
65
|
|
|
46
|
-
|
|
47
66
|
const props = defineProps({
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
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>
|