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

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 (27) hide show
  1. package/es/advance-select/advance-option.mjs +2 -2
  2. package/es/data-table/data-table.mjs +4 -3
  3. package/es/index.css +1 -0
  4. package/es/pct-filter-panel/pct-compents/index.mjs +1 -1
  5. package/es/pct-filter-panel/pct-compents/pct-multiple-menu-condition.mjs +2 -2
  6. package/es/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.mjs +131 -77
  7. package/es/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.vue_vue_type_style_index_0_scoped_0a08184f_lang.mjs +13 -0
  8. package/lib/advance-select/advance-option.js +2 -2
  9. package/lib/data-table/data-table.js +4 -3
  10. package/lib/index.css +1 -0
  11. package/lib/pct-filter-panel/pct-compents/index.js +2 -2
  12. package/lib/pct-filter-panel/pct-compents/pct-multiple-menu-condition.js +2 -2
  13. package/lib/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.js +130 -76
  14. package/lib/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.vue_vue_type_style_index_0_scoped_0a08184f_lang.js +17 -0
  15. package/package.json +1 -1
  16. package/src/advance-select/advance-option.vue +4 -4
  17. package/src/data-table/data-table.vue +4 -4
  18. package/src/pct-filter-panel/pct-compents/index.js +1 -1
  19. package/src/pct-filter-panel/pct-compents/pct-multiple-menu-condition.vue +4 -4
  20. package/src/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.vue +148 -96
  21. package/style/index.css +1 -1
  22. package/style/src/var.scss +2 -0
  23. package/style/var.css +1 -1
  24. package/es/components.css +0 -1
  25. package/lib/components.css +0 -1
  26. /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
  27. /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,185 @@
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
  >
19
- <ElOption
20
- v-for="(item, index) in data"
21
- :key="item[valueProp] + index"
22
- :value="item[valueProp] + ''"
23
- :label="item[labelProp]"
24
- />
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 }}
35
+ </div>
36
+ <span style="margin-left: 8px">{{ item[labelPropStr] }}</span>
37
+ </div>
38
+ </ElOption>
25
39
  </ElSelect>
40
+ </div>
26
41
  </template>
27
42
 
28
43
  <script setup>
29
- import {ElOption, ElSelect} from 'element-plus';
44
+ import { ElOption, ElSelect } from 'element-plus';
30
45
  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";
46
+ import { computed, unref, defineEmits, inject, ref, useAttrs } from 'vue';
47
+ import { dataProps } from '../../hooks/use-data';
33
48
  import {
34
- useService,
35
- HttpRequest,
36
- filterPanelItemKey,
49
+ useService,
50
+ HttpRequest,
51
+ filterPanelItemKey,
37
52
  } from '@ctzy-web-client/web-base-client-vue';
53
+ import { pinyin } from 'pinyin-pro';
38
54
 
39
55
  const httpRequest = useService(HttpRequest);
56
+
40
57
  defineOptions({
41
- name: 'BwaPctMultipleMenuCondition',
42
- __conditionTitle__: '多选菜单-PZ',
43
- __conditionDefault__: () => [],
58
+ name: 'BwaPctMultipleMenuCondition',
59
+ __conditionTitle__: '多选菜单',
60
+ __conditionDefault__: () => [],
44
61
  });
45
62
 
46
-
47
63
  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
- }
64
+ ...dataProps,
65
+ modelValue: { type: null },
66
+ options: { type: Array, default: () => [] },
67
+ labelProp: { type: String, default: 'label' },
68
+ valueProp: { type: String, default: 'value' },
69
+ multiple: { type: Boolean, default: true },
70
+ showSearch: { type: Boolean, default: true },
71
+ filterable: { type: Boolean, default: true },
72
+ placeholder: { type: String, default: '请选择' },
73
+ remote: { type: Boolean, default: true },
74
+ showLetterAvatar: { type: Boolean, default: false },
75
+ size: { type: String, default: '' },
76
+ searchPlaceholder: { type: String, default: '' },
77
+ labelAttr: { type: String, default: '' },
78
+ valueAttr: { type: String, default: '' },
79
+ searchAttr: { type: String, default: '' },
80
+ itfInfo: { type: Object, default: null },
81
+ isRequiredByVisibleChange: { type: Boolean, default: false },
84
82
  });
85
- const ns = useNamespace('pctfilterpanel-item');
86
83
 
84
+ const ns = useNamespace('pctfilterpanel-item');
87
85
  const attrs = useAttrs();
88
- const showTitle = computed(() => attrs.showTitle)
89
-
90
- const data = ref([])
91
- const loading = ref(false)
86
+ const showTitle = computed(() => attrs.showTitle);
87
+ const data = ref([]);
88
+ const loading = ref(false);
92
89
  const emit = defineEmits(['update:modelValue', 'search', 'visible-change']);
93
-
94
90
  const filterPanelItem = inject(filterPanelItemKey, null);
95
91
  const column = computed(() => filterPanelItem?.column ?? null);
96
92
 
97
- const placeholderStr = computed(() => showTitle.value ? props.placeholder : column.value.title)
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
+ }
98
103
 
104
+ const placeholderStr = computed(() =>
105
+ showTitle.value ? props.placeholder : column.value?.title
106
+ );
107
+ const labelPropStr = computed(
108
+ () => column.value?.componentProps?.labelAttr || props.labelProp
109
+ );
110
+ const valuePropStr = computed(
111
+ () => column.value?.componentProps?.valueAttr || props.valueProp
112
+ );
113
+ const showLetterAvatarStatus = computed(
114
+ () => column.value?.componentProps?.showLetterAvatar || props.showLetterAvatar
115
+ );
99
116
 
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
117
+ // ====================== 文字头像 ======================
118
+ const COLOR_POOL = ['#2DC86D', '#19BBFF', '#FFA901'];
119
+ function processLabel(label = '') {
120
+ const match = (label + '').match(/^(.*)\(/);
121
+ const txt = match ? match[1] : label;
122
+ const first = txt.charAt(0);
123
+ let letter = '#';
124
+ if (/[\u4e00-\u9fa5]/.test(first)) {
125
+ letter = pinyin(first, { pattern: 'first' }).toUpperCase();
126
+ } else if (/[a-zA-Z]/.test(first)) {
127
+ letter = first.toUpperCase();
128
+ }
129
+ let color = COLOR_POOL[0];
130
+ if (/[A-Z]/.test(letter)) {
131
+ color = COLOR_POOL[(letter.charCodeAt(0) - 65) % 3];
132
+ }
133
+ return { firstLetter: letter, color };
111
134
  }
112
- if (column.value?.componentProps) {
113
135
 
114
- } else {
115
- data.value = props.options ?? []
116
- }
136
+ // ====================== 数据请求 ======================
137
+ const getData = async (query) => {
138
+ if (!column.value?.componentProps) {
139
+ data.value = props.options ?? [];
140
+ loading.value = false;
141
+ return;
142
+ }
143
+
144
+ loading.value = true;
145
+ try {
146
+ 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
+ } catch (err) {
155
+ data.value = [];
156
+ } finally {
157
+ loading.value = false;
158
+ }
159
+ };
160
+
161
+ // 初始化
162
+ data.value = props.options ?? [];
163
+
117
164
  const visibleChange = (val) => {
118
- if (!val || !column.value.componentProps) return
119
- getData()
120
- }
165
+ emit('visible-change', val);
166
+ if (val && props.isRequiredByVisibleChange) emit('search', '');
167
+ if (val && column.value?.componentProps) getData();
168
+ };
121
169
 
122
- const remoteMethod = (query) => {
123
- if (column.value.componentProps) {
124
- getData(query)
125
- } else {
126
- emit('search', query)
127
- }
128
- }
170
+ const handleFieldSearch = (query) => {
171
+ column.value?.componentProps ? getData(query) : emit('search', query);
172
+ };
129
173
 
174
+ // ====================== 双向绑定 ======================
130
175
  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),
176
+ get: () => props.multiple
177
+ ? (Array.isArray(props.modelValue) ? props.modelValue : [])
178
+ : (props.modelValue ?? ''),
179
+ set: (v) => emit('update:modelValue', v),
141
180
  });
142
181
  </script>
143
182
 
183
+ <style scoped>
184
+ .letter-circle {
185
+ width: 22px;
186
+ height: 22px;
187
+ border-radius: 50%;
188
+ color: #fff;
189
+ display: flex;
190
+ align-items: center;
191
+ justify-content: center;
192
+ font-size: 12px;
193
+ flex-shrink: 0;
194
+ }
195
+ </style>