@meethive/components 0.0.2 → 0.0.4
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/AutoComplete/AutoComplete.js +71 -80
- package/es/BadgeStatus/Badge.js +38 -47
- package/es/CardSelect/CardSelect.js +115 -137
- package/es/CheckButton/CheckButton.js +102 -118
- package/es/ConfigProvider/ConfigProvider.js +44 -68
- package/es/DragModal/DragModal.js +191 -212
- package/es/EditTable/Body.js +158 -189
- package/es/EditTable/CellRender.js +10 -12
- package/es/EditTable/EditTable.js +385 -434
- package/es/EditTable/FormItem.js +140 -169
- package/es/EditTable/Group.js +171 -204
- package/es/EditTable/Header.js +57 -63
- package/es/EditTable/HeaderRender.js +10 -12
- package/es/EditTable/components/ContextMenu/Menu.js +78 -86
- package/es/EditTable/components/Search/Search.js +151 -163
- package/es/EditTable/components/Search/Sort.js +104 -119
- package/es/Ellipsis/Ellipsis.js +144 -148
- package/es/Empty/Empty.js +51 -57
- package/es/FullPage/FullPage.js +20 -19
- package/es/Icon/Icon.js +42 -49
- package/es/LocaleProvider/LocaleProvider.js +38 -31
- package/es/Markdown/Markdown.js +101 -118
- package/es/PermissionButton/PermissionButton.js +118 -118
- package/es/ProLayout/Basic/BasicLayout.js +301 -418
- package/es/ProLayout/Basic/Header.js +91 -111
- package/es/ProLayout/PageContainer/index.js +267 -344
- package/es/ProLayout/SiderMenu/BaseMenu.js +186 -240
- package/es/ProTable/Alert.js +39 -40
- package/es/ProTable/Content.js +84 -97
- package/es/ProTable/Header.js +32 -33
- package/es/ProTable/Pagination.js +56 -55
- package/es/ProTable/ProTable.js +256 -276
- package/es/RadioButton/RadioButton.js +48 -53
- package/es/Scrollbar/Bar.js +65 -76
- package/es/Scrollbar/Scrollbar.js +129 -161
- package/es/Scrollbar/Thumb.js +101 -150
- package/es/Search/Item.js +208 -236
- package/es/Search/Search.js +90 -90
- package/es/Skeleton/Skeleton.js +26 -27
- package/es/Skeleton/components/DashBoardCard.js +26 -27
- package/es/Skeleton/components/DashBoardChart.js +26 -27
- package/es/Skeleton/components/Detail.js +26 -27
- package/es/Skeleton/components/Drawer.js +26 -27
- package/es/Skeleton/components/Item.js +55 -54
- package/es/Skeleton/components/List.js +29 -27
- package/es/Skeleton/components/ListCard.js +28 -28
- package/es/Skeleton/components/ListCardItem.js +20 -20
- package/es/Skeleton/components/ListTable.js +26 -27
- package/es/Skeleton/components/Page.js +27 -26
- package/es/Skeleton/components/Search.js +16 -16
- package/es/Skeleton/components/Tree.js +26 -27
- package/es/TimeFormat/TimeFormat.js +32 -36
- package/es/Title/Title.js +23 -26
- package/es/ValueItem/ValueItem.js +100 -113
- package/es/VirtualTable/VirtualTable.js +235 -271
- package/lib/AutoComplete/AutoComplete.js +71 -80
- package/lib/BadgeStatus/Badge.js +38 -47
- package/lib/CardSelect/CardSelect.js +115 -137
- package/lib/CheckButton/CheckButton.js +102 -118
- package/lib/ConfigProvider/ConfigProvider.js +44 -68
- package/lib/DragModal/DragModal.js +191 -212
- package/lib/EditTable/Body.js +158 -189
- package/lib/EditTable/CellRender.js +10 -12
- package/lib/EditTable/EditTable.js +385 -434
- package/lib/EditTable/FormItem.js +140 -169
- package/lib/EditTable/Group.js +171 -204
- package/lib/EditTable/Header.js +57 -63
- package/lib/EditTable/HeaderRender.js +10 -12
- package/lib/EditTable/components/ContextMenu/Menu.js +78 -86
- package/lib/EditTable/components/Search/Search.js +151 -163
- package/lib/EditTable/components/Search/Sort.js +104 -119
- package/lib/Ellipsis/Ellipsis.js +144 -148
- package/lib/Empty/Empty.js +51 -57
- package/lib/FullPage/FullPage.js +20 -19
- package/lib/Icon/Icon.js +42 -49
- package/lib/LocaleProvider/LocaleProvider.js +38 -31
- package/lib/Markdown/Markdown.js +101 -118
- package/lib/PermissionButton/PermissionButton.js +118 -118
- package/lib/ProLayout/Basic/BasicLayout.js +301 -418
- package/lib/ProLayout/Basic/Header.js +91 -111
- package/lib/ProLayout/PageContainer/index.js +267 -344
- package/lib/ProLayout/SiderMenu/BaseMenu.js +186 -240
- package/lib/ProTable/Alert.js +39 -40
- package/lib/ProTable/Content.js +84 -97
- package/lib/ProTable/Header.js +32 -33
- package/lib/ProTable/Pagination.js +56 -55
- package/lib/ProTable/ProTable.js +256 -276
- package/lib/RadioButton/RadioButton.js +48 -53
- package/lib/Scrollbar/Bar.js +65 -76
- package/lib/Scrollbar/Scrollbar.js +129 -161
- package/lib/Scrollbar/Thumb.js +101 -150
- package/lib/Search/Item.js +208 -236
- package/lib/Search/Search.js +90 -90
- package/lib/Skeleton/Skeleton.js +26 -27
- package/lib/Skeleton/components/DashBoardCard.js +26 -27
- package/lib/Skeleton/components/DashBoardChart.js +26 -27
- package/lib/Skeleton/components/Detail.js +26 -27
- package/lib/Skeleton/components/Drawer.js +26 -27
- package/lib/Skeleton/components/Item.js +55 -54
- package/lib/Skeleton/components/List.js +29 -27
- package/lib/Skeleton/components/ListCard.js +28 -28
- package/lib/Skeleton/components/ListCardItem.js +20 -20
- package/lib/Skeleton/components/ListTable.js +26 -27
- package/lib/Skeleton/components/Page.js +27 -26
- package/lib/Skeleton/components/Search.js +16 -16
- package/lib/Skeleton/components/Tree.js +26 -27
- package/lib/TimeFormat/TimeFormat.js +32 -36
- package/lib/Title/Title.js +23 -26
- package/lib/ValueItem/ValueItem.js +100 -113
- package/lib/VirtualTable/VirtualTable.js +235 -271
- package/package.json +1 -1
package/es/Search/Item.js
CHANGED
|
@@ -1,239 +1,211 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
props: {
|
|
15
|
-
column: {
|
|
16
|
-
type: String
|
|
17
|
-
},
|
|
18
|
-
value: {
|
|
19
|
-
type: String
|
|
20
|
-
},
|
|
21
|
-
termType: {
|
|
22
|
-
type: String,
|
|
23
|
-
default: 'like'
|
|
24
|
-
},
|
|
25
|
-
type: {
|
|
26
|
-
type: String,
|
|
27
|
-
default: 'or'
|
|
28
|
-
},
|
|
29
|
-
expand: {
|
|
30
|
-
type: Boolean,
|
|
31
|
-
default: false
|
|
32
|
-
},
|
|
33
|
-
onlyValue: {
|
|
34
|
-
type: Boolean,
|
|
35
|
-
default: true
|
|
36
|
-
},
|
|
37
|
-
labelWidth: {
|
|
38
|
-
type: Number,
|
|
39
|
-
default: 40
|
|
40
|
-
},
|
|
41
|
-
index: {
|
|
42
|
-
type: Number,
|
|
43
|
-
default: 1
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
emits: ['update:value', 'update:termType', 'update:type', 'update:column'],
|
|
47
|
-
setup(props, {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
const
|
|
58
|
-
const
|
|
59
|
-
|
|
60
|
-
const targetComponents = ref({})
|
|
61
|
-
const valueOptions = ref()
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const findItemByColumn = () => {
|
|
97
|
-
return columnsMap.value[termsModel.column ]
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const findOptionsByColumn = () => {
|
|
101
|
-
return optionsMap.value[termsModel.column ]
|
|
102
|
-
}
|
|
103
|
-
|
|
1
|
+
import { defineComponent, computed, ref, reactive, watch, isRef } from 'vue';
|
|
2
|
+
import { Select } from 'ant-design-vue';
|
|
3
|
+
import { componentProps, componentType, typeOptions } from './setting';
|
|
4
|
+
import { getTermOptions, getItemDefaultValue } from './util';
|
|
5
|
+
import { useLocaleReceiver } from '../LocaleReciver';
|
|
6
|
+
import { useColumnsMap, useDefaultValue, useOptionMap } from './hooks';
|
|
7
|
+
import { isArray, isFunction } from 'lodash-es';
|
|
8
|
+
import useSearchStyle from './style';
|
|
9
|
+
export default defineComponent({
|
|
10
|
+
name: 'JSearchItem',
|
|
11
|
+
components: {
|
|
12
|
+
Select
|
|
13
|
+
},
|
|
14
|
+
props: {
|
|
15
|
+
column: {
|
|
16
|
+
type: String
|
|
17
|
+
},
|
|
18
|
+
value: {
|
|
19
|
+
type: String
|
|
20
|
+
},
|
|
21
|
+
termType: {
|
|
22
|
+
type: String,
|
|
23
|
+
default: 'like'
|
|
24
|
+
},
|
|
25
|
+
type: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: 'or'
|
|
28
|
+
},
|
|
29
|
+
expand: {
|
|
30
|
+
type: Boolean,
|
|
31
|
+
default: false
|
|
32
|
+
},
|
|
33
|
+
onlyValue: {
|
|
34
|
+
type: Boolean,
|
|
35
|
+
default: true
|
|
36
|
+
},
|
|
37
|
+
labelWidth: {
|
|
38
|
+
type: Number,
|
|
39
|
+
default: 40
|
|
40
|
+
},
|
|
41
|
+
index: {
|
|
42
|
+
type: Number,
|
|
43
|
+
default: 1
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
emits: ['update:value', 'update:termType', 'update:type', 'update:column'],
|
|
47
|
+
setup(props, {
|
|
48
|
+
emit
|
|
49
|
+
}) {
|
|
50
|
+
const termsModel = reactive({
|
|
51
|
+
type: props.type || 'or',
|
|
52
|
+
value: props.value || '',
|
|
53
|
+
termType: props.termType || 'like',
|
|
54
|
+
column: props.column || undefined
|
|
55
|
+
});
|
|
56
|
+
const [contextLocale] = useLocaleReceiver('Search');
|
|
57
|
+
const optionsMap = useOptionMap();
|
|
58
|
+
const columnsMap = useColumnsMap();
|
|
59
|
+
const columnsValues = useDefaultValue();
|
|
60
|
+
const targetComponents = ref({});
|
|
61
|
+
const valueOptions = ref();
|
|
62
|
+
const btwKeys = computed(() => {
|
|
63
|
+
const record = findItemByColumn();
|
|
64
|
+
if (record.search.isBtw && Array.isArray(record.search.isBtw)) {
|
|
65
|
+
return [...record.search.isBtw, 'in', 'nin'];
|
|
66
|
+
}
|
|
67
|
+
return ['in', 'nin'];
|
|
68
|
+
});
|
|
69
|
+
const prefixCls = computed(() => 'JSearch');
|
|
70
|
+
const [wrapSSR, hashId] = useSearchStyle(prefixCls);
|
|
71
|
+
const termTypeOptions = computed(() => {
|
|
72
|
+
const columnTarget = findItemByColumn();
|
|
73
|
+
const columnSearch = columnTarget?.search;
|
|
74
|
+
let _termsOptions = getTermOptions(targetComponents.value.type, contextLocale.value);
|
|
75
|
+
if (columnSearch?.termOptions) {
|
|
76
|
+
_termsOptions = columnSearch.termOptions;
|
|
77
|
+
} else if (columnSearch?.termFilter?.length) {
|
|
78
|
+
_termsOptions = _termsOptions.filter(item => !columnSearch.termFilter?.includes(item.value));
|
|
79
|
+
}
|
|
80
|
+
return _termsOptions;
|
|
81
|
+
});
|
|
82
|
+
const columnOptions = computed(() => {
|
|
83
|
+
return Object.values(columnsMap.value).sort((a, b) => a._sort_index - b._sort_index).map(item => ({
|
|
84
|
+
label: item.title,
|
|
85
|
+
value: item.dataIndex
|
|
86
|
+
}));
|
|
87
|
+
});
|
|
88
|
+
const findItemByColumn = () => {
|
|
89
|
+
return columnsMap.value[termsModel.column];
|
|
90
|
+
};
|
|
91
|
+
const findOptionsByColumn = () => {
|
|
92
|
+
return optionsMap.value[termsModel.column];
|
|
93
|
+
};
|
|
94
|
+
|
|
104
95
|
/**
|
|
105
96
|
* 处理options
|
|
106
97
|
* @param _options
|
|
107
|
-
*/
|
|
108
|
-
const handleColumnsOptions = async
|
|
109
|
-
if (isFunction(_options)) {
|
|
110
|
-
valueOptions.value = await _options()
|
|
111
|
-
optionsMap.value[props.column
|
|
112
|
-
} else if (isArray(_options)) {
|
|
113
|
-
valueOptions.value = _options
|
|
114
|
-
} else if (isRef(_options) ||
|
|
115
|
-
valueOptions.value = _options.value
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
//
|
|
128
|
-
termsModel.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if (
|
|
158
|
-
termsModel.value =
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
}
|
|
222
|
-
)
|
|
223
|
-
|
|
224
|
-
return {
|
|
225
|
-
termsModel,
|
|
226
|
-
contextLocale,
|
|
227
|
-
targetComponents,
|
|
228
|
-
valueOptions,
|
|
229
|
-
hashId,
|
|
230
|
-
termTypeOptions,
|
|
231
|
-
columnOptions,
|
|
232
|
-
typeOptions,
|
|
233
|
-
onTypeChange,
|
|
234
|
-
onColumnChange,
|
|
235
|
-
onTermTypeChange,
|
|
236
|
-
onValueChange
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
})
|
|
98
|
+
*/
|
|
99
|
+
const handleColumnsOptions = async _options => {
|
|
100
|
+
if (isFunction(_options)) {
|
|
101
|
+
valueOptions.value = await _options();
|
|
102
|
+
optionsMap.value[props.column] = [...valueOptions.value];
|
|
103
|
+
} else if (isArray(_options)) {
|
|
104
|
+
valueOptions.value = _options;
|
|
105
|
+
} else if (isRef(_options) || typeof _options === 'object' && 'value' in _options) {
|
|
106
|
+
valueOptions.value = _options.value;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
const onTypeChange = () => {
|
|
110
|
+
emit('update:type', termsModel.type);
|
|
111
|
+
};
|
|
112
|
+
const onColumnChange = () => {
|
|
113
|
+
const record = findItemByColumn();
|
|
114
|
+
const defaultValue = getItemDefaultValue(record, columnsValues.value);
|
|
115
|
+
|
|
116
|
+
// 处理默认选项
|
|
117
|
+
termsModel.termType = defaultValue.termType;
|
|
118
|
+
// 处理默认值
|
|
119
|
+
termsModel.value = defaultValue.value;
|
|
120
|
+
emit('update:column', termsModel.column);
|
|
121
|
+
onTermTypeChange();
|
|
122
|
+
onValueChange();
|
|
123
|
+
};
|
|
124
|
+
const onTermTypeChange = () => {
|
|
125
|
+
const isBtw = btwKeys.value.includes(termsModel.termType);
|
|
126
|
+
if (!isBtw && termsModel.value && Array.isArray(termsModel.value)) {
|
|
127
|
+
termsModel.value = termsModel.value[0];
|
|
128
|
+
onValueChange();
|
|
129
|
+
} else if (isBtw && termsModel.value && !Array.isArray(termsModel.value)) {
|
|
130
|
+
termsModel.value = [termsModel.value];
|
|
131
|
+
onValueChange();
|
|
132
|
+
}
|
|
133
|
+
emit('update:termType', termsModel.termType);
|
|
134
|
+
};
|
|
135
|
+
const onValueChange = () => {
|
|
136
|
+
emit('update:value', termsModel.value);
|
|
137
|
+
};
|
|
138
|
+
const handleTermsModelValue = isBtw => {
|
|
139
|
+
if (isBtw) {
|
|
140
|
+
if (termsModel.value && !Array.isArray(termsModel.value)) {
|
|
141
|
+
termsModel.value = [termsModel.value];
|
|
142
|
+
} else if (!termsModel.value) {
|
|
143
|
+
termsModel.value = [];
|
|
144
|
+
}
|
|
145
|
+
} else {
|
|
146
|
+
if (termsModel.value && Array.isArray(termsModel.value)) {
|
|
147
|
+
termsModel.value = termsModel.value[0];
|
|
148
|
+
} else if (!termsModel.value) {
|
|
149
|
+
termsModel.value = undefined;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
watch(() => [targetComponents.value.name, termsModel.termType], () => {
|
|
154
|
+
const isBtw = btwKeys.value.includes(termsModel.termType);
|
|
155
|
+
if (targetComponents.value.type === componentType.treeSelect) {
|
|
156
|
+
targetComponents.value.props = {
|
|
157
|
+
...targetComponents.value.props,
|
|
158
|
+
multiple: isBtw
|
|
159
|
+
};
|
|
160
|
+
handleTermsModelValue(isBtw);
|
|
161
|
+
} else if (targetComponents.value.type === componentType.select) {
|
|
162
|
+
targetComponents.value.props = {
|
|
163
|
+
...targetComponents.value.props,
|
|
164
|
+
mode: isBtw ? 'multiple' : 'combobox'
|
|
165
|
+
};
|
|
166
|
+
handleTermsModelValue(isBtw);
|
|
167
|
+
}
|
|
168
|
+
}, {
|
|
169
|
+
immediate: true,
|
|
170
|
+
deep: true
|
|
171
|
+
});
|
|
172
|
+
watch(() => [termsModel.column, columnsMap.value], async () => {
|
|
173
|
+
// 根据column从map中获取record,再解析search属性
|
|
174
|
+
const record = findItemByColumn();
|
|
175
|
+
if (!record) return;
|
|
176
|
+
const options = findOptionsByColumn();
|
|
177
|
+
targetComponents.value = componentProps(record.search);
|
|
178
|
+
targetComponents.value.label = record.title;
|
|
179
|
+
|
|
180
|
+
// 处理options
|
|
181
|
+
if (options) {
|
|
182
|
+
valueOptions.value = options;
|
|
183
|
+
} else {
|
|
184
|
+
await handleColumnsOptions(record.search.options);
|
|
185
|
+
}
|
|
186
|
+
}, {
|
|
187
|
+
immediate: true,
|
|
188
|
+
deep: true
|
|
189
|
+
});
|
|
190
|
+
watch(() => [props.value, props.termType, props.column, props.type], () => {
|
|
191
|
+
termsModel.value = props.value;
|
|
192
|
+
termsModel.termType = props.termType;
|
|
193
|
+
termsModel.column = props.column;
|
|
194
|
+
termsModel.type = props.type;
|
|
195
|
+
});
|
|
196
|
+
return {
|
|
197
|
+
termsModel,
|
|
198
|
+
contextLocale,
|
|
199
|
+
targetComponents,
|
|
200
|
+
valueOptions,
|
|
201
|
+
hashId,
|
|
202
|
+
termTypeOptions,
|
|
203
|
+
columnOptions,
|
|
204
|
+
typeOptions,
|
|
205
|
+
onTypeChange,
|
|
206
|
+
onColumnChange,
|
|
207
|
+
onTermTypeChange,
|
|
208
|
+
onValueChange
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
});
|
package/es/Search/Search.js
CHANGED
|
@@ -1,90 +1,90 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
const columnsOptionMap = ref({}) // 存储每个columnItem的option
|
|
32
|
-
const terms = reactive({
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return {
|
|
81
|
-
contextLocale,
|
|
82
|
-
attrs,
|
|
83
|
-
terms,
|
|
84
|
-
hashId,
|
|
85
|
-
footerStyles,
|
|
86
|
-
searchSubmit,
|
|
87
|
-
reset
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
})
|
|
1
|
+
import { defineComponent, reactive, ref, computed, inject, useAttrs } from 'vue';
|
|
2
|
+
import { searchProps } from './setting';
|
|
3
|
+
import { useLocaleReceiver } from '../LocaleReciver';
|
|
4
|
+
import { Button, Col, Form, FormItemRest, Row } from 'ant-design-vue';
|
|
5
|
+
import { SearchConfig } from '../utils/constants';
|
|
6
|
+
import Item from './Item.js';
|
|
7
|
+
import { useHandleColumns, useOptionMapContent } from './hooks';
|
|
8
|
+
import { termsParamsFormat } from './util';
|
|
9
|
+
import useSearchStyle from './style';
|
|
10
|
+
export default defineComponent({
|
|
11
|
+
name: 'JSearch',
|
|
12
|
+
components: {
|
|
13
|
+
Button,
|
|
14
|
+
Col,
|
|
15
|
+
Form,
|
|
16
|
+
FormItemRest,
|
|
17
|
+
Row,
|
|
18
|
+
Item
|
|
19
|
+
},
|
|
20
|
+
inheritAttrs: false,
|
|
21
|
+
props: {
|
|
22
|
+
...searchProps()
|
|
23
|
+
},
|
|
24
|
+
emits: ['search'],
|
|
25
|
+
setup(props, {
|
|
26
|
+
emit,
|
|
27
|
+
expose
|
|
28
|
+
}) {
|
|
29
|
+
const [contextLocale] = useLocaleReceiver('Search');
|
|
30
|
+
const attrs = useAttrs();
|
|
31
|
+
const columnsOptionMap = ref({}); // 存储每个columnItem的option
|
|
32
|
+
const terms = reactive({
|
|
33
|
+
terms: []
|
|
34
|
+
}); // 当前查询条件
|
|
35
|
+
|
|
36
|
+
const context = inject(SearchConfig, {
|
|
37
|
+
align: props.align
|
|
38
|
+
});
|
|
39
|
+
const {
|
|
40
|
+
initValues,
|
|
41
|
+
columnsMap
|
|
42
|
+
} = useHandleColumns(props, terms);
|
|
43
|
+
const prefixCls = computed(() => 'JSearch');
|
|
44
|
+
const [wrapSSR, hashId] = useSearchStyle(prefixCls);
|
|
45
|
+
useOptionMapContent(columnsOptionMap);
|
|
46
|
+
const footerStyles = computed(() => {
|
|
47
|
+
const align = context.align || props.align;
|
|
48
|
+
if (align === 'value') {
|
|
49
|
+
return {
|
|
50
|
+
paddingLeft: `${props.labelWidth + 8}px`
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return {};
|
|
54
|
+
});
|
|
55
|
+
const searchSubmit = () => {
|
|
56
|
+
emit('search', termsParamsFormat(terms, columnsMap.value, 'low', props.type));
|
|
57
|
+
};
|
|
58
|
+
const reset = () => {
|
|
59
|
+
initValues();
|
|
60
|
+
};
|
|
61
|
+
const handleDefaultValues = value => {
|
|
62
|
+
const isObject = Object.prototype.toString.call(value) === '[object Object]';
|
|
63
|
+
let _params = isObject ? Object.keys(value).map(key => ({
|
|
64
|
+
column: key,
|
|
65
|
+
value: value[key],
|
|
66
|
+
termType: 'eq'
|
|
67
|
+
})) : [...value];
|
|
68
|
+
terms.terms.forEach(item => {
|
|
69
|
+
const paramsItem = _params.find(paramsItem => paramsItem.column === item.column);
|
|
70
|
+
if (paramsItem) {
|
|
71
|
+
item.value = paramsItem.value;
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
emit('search', termsParamsFormat(terms, columnsMap.value));
|
|
75
|
+
};
|
|
76
|
+
expose({
|
|
77
|
+
setValues: handleDefaultValues,
|
|
78
|
+
reset
|
|
79
|
+
});
|
|
80
|
+
return {
|
|
81
|
+
contextLocale,
|
|
82
|
+
attrs,
|
|
83
|
+
terms,
|
|
84
|
+
hashId,
|
|
85
|
+
footerStyles,
|
|
86
|
+
searchSubmit,
|
|
87
|
+
reset
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
});
|