ct-component-plus 2.2.5 → 2.2.7
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/README.md +15 -2
- package/package.json +3 -3
- package/packages/components/cascader/src/cascader.vue +22 -22
- package/packages/components/index.js +47 -43
- package/packages/components/number-input-range/index.js +9 -0
- package/packages/components/number-input-range/src/index.js +31 -0
- package/packages/components/number-input-range/src/number-input-range.vue +145 -0
- package/packages/components/search-box/index.js +13 -11
- package/packages/components/search-box/src/search-box.vue +69 -27
- package/packages/components/year-select/src/year-select.vue +13 -10
package/README.md
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
#
|
|
1
|
+
# v2.2.7版本更新内容:
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
1. 优化级联选择器没有默认值报错的情况
|
|
4
|
+
|
|
5
|
+
# v2.2.6版本更新内容:
|
|
6
|
+
|
|
7
|
+
1. 新增数字区间组件
|
|
8
|
+
2. 优化search-box中年份区间及数字区间的大小排序问题
|
|
9
|
+
|
|
10
|
+
# v2.2.3版本更新内容:
|
|
11
|
+
|
|
12
|
+
1. 新增分页选择器组件
|
|
13
|
+
|
|
14
|
+
# v2.2.0版本更新内容:
|
|
15
|
+
|
|
16
|
+
1. 新增单选框可以通过接口获取数据的功能
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ct-component-plus",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.2.
|
|
4
|
+
"version": "2.2.7",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "packages/components/index.js",
|
|
7
7
|
"files": [
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"docs:build": "vuepress build docs"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"cingta-icon": "^2.
|
|
18
|
+
"cingta-icon": "^2.3.2",
|
|
19
19
|
"element-plus": "2.4.4",
|
|
20
20
|
"vue": "^3.2.47"
|
|
21
21
|
},
|
|
@@ -33,4 +33,4 @@
|
|
|
33
33
|
"vuepress": "^2.0.0-beta.63",
|
|
34
34
|
"vuepress-plugin-demo-container": "^0.2.0"
|
|
35
35
|
}
|
|
36
|
-
}
|
|
36
|
+
}
|
|
@@ -1,22 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<el-cascader
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
v-model="showValue"
|
|
11
|
-
:props="propsShow"
|
|
12
|
-
:options="optionsShow"
|
|
13
|
-
:show-all-levels="showAllLevels"
|
|
14
|
-
:filterable="filterable"
|
|
15
|
-
:clearable="clearable"
|
|
16
|
-
:disabled="disabled"
|
|
17
|
-
:popper-class="popperClassShow"
|
|
18
|
-
v-bind="{ ...$attrs, ...rawAttr }"
|
|
19
|
-
/>
|
|
2
|
+
<el-cascader ref="cascaderRef" :class="[
|
|
3
|
+
ns.b(),
|
|
4
|
+
ns.is('disabled', disabled),
|
|
5
|
+
ns.is('filterable', filterable),
|
|
6
|
+
componentId,
|
|
7
|
+
]" v-model="showValue" :props="propsShow" :options="optionsShow" :show-all-levels="showAllLevels"
|
|
8
|
+
:filterable="filterable" :clearable="clearable" :disabled="disabled" :popper-class="popperClassShow"
|
|
9
|
+
v-bind="{ ...$attrs, ...rawAttr }" />
|
|
20
10
|
<!-- <Teleport :to="appendPanelDom">
|
|
21
11
|
<span>大写的六</span>
|
|
22
12
|
</Teleport> -->
|
|
@@ -60,7 +50,7 @@ const optionsShow = computed(() => {
|
|
|
60
50
|
});
|
|
61
51
|
const showValue = computed({
|
|
62
52
|
get() {
|
|
63
|
-
return props.modelValue;
|
|
53
|
+
return props.modelValue || [];
|
|
64
54
|
},
|
|
65
55
|
set(newValue) {
|
|
66
56
|
emit("update:modelValue", newValue);
|
|
@@ -163,7 +153,7 @@ watchEffect(async () => {
|
|
|
163
153
|
cbs.afterSearch(res, optionsByApi, showValue);
|
|
164
154
|
}
|
|
165
155
|
});
|
|
166
|
-
} catch (error) {}
|
|
156
|
+
} catch (error) { }
|
|
167
157
|
}
|
|
168
158
|
if (isFunction(cbs.defineSearch)) {
|
|
169
159
|
try {
|
|
@@ -175,14 +165,14 @@ watchEffect(async () => {
|
|
|
175
165
|
if (defineSearchHandle) {
|
|
176
166
|
optionsByApi.value = defineSearchHandle;
|
|
177
167
|
}
|
|
178
|
-
} catch (error) {}
|
|
168
|
+
} catch (error) { }
|
|
179
169
|
}
|
|
180
170
|
});
|
|
181
171
|
function findLabelsByValues(tree, values) {
|
|
182
172
|
// 通过value值的数组获取label并返回一个包含label的数组
|
|
183
173
|
const result = [];
|
|
184
174
|
function traverse(node) {
|
|
185
|
-
if (values.includes(node[props.mapObj?.value || "value"])) {
|
|
175
|
+
if (!values && values.includes(node[props.mapObj?.value || "value"])) {
|
|
186
176
|
result.push(node[props.mapObj?.label || "label"]);
|
|
187
177
|
}
|
|
188
178
|
|
|
@@ -218,6 +208,7 @@ onMounted(() => {
|
|
|
218
208
|
.ct-cascader {
|
|
219
209
|
width: var(--ct-component-width);
|
|
220
210
|
--ct-cascader-inner-height: var(--ct-component-inner-height);
|
|
211
|
+
|
|
221
212
|
&.is-filterable {
|
|
222
213
|
.el-cascader__tags {
|
|
223
214
|
&:focus-within {
|
|
@@ -227,6 +218,7 @@ onMounted(() => {
|
|
|
227
218
|
}
|
|
228
219
|
}
|
|
229
220
|
}
|
|
221
|
+
|
|
230
222
|
.el-cascader__tags {
|
|
231
223
|
display: inline-flex;
|
|
232
224
|
// display: inline-block;
|
|
@@ -237,6 +229,7 @@ onMounted(() => {
|
|
|
237
229
|
text-overflow: ellipsis;
|
|
238
230
|
overflow: hidden;
|
|
239
231
|
white-space: nowrap;
|
|
232
|
+
|
|
240
233
|
.el-tag {
|
|
241
234
|
display: inline;
|
|
242
235
|
height: auto;
|
|
@@ -245,14 +238,17 @@ onMounted(() => {
|
|
|
245
238
|
background-color: inherit;
|
|
246
239
|
font-size: var(--ct-font-size);
|
|
247
240
|
color: var(--ct-color-black);
|
|
241
|
+
|
|
248
242
|
&:not(:last-of-type)::after {
|
|
249
243
|
content: "、";
|
|
250
244
|
}
|
|
251
245
|
}
|
|
246
|
+
|
|
252
247
|
.el-tag__close {
|
|
253
248
|
display: none;
|
|
254
249
|
}
|
|
255
250
|
}
|
|
251
|
+
|
|
256
252
|
&__dropdown {
|
|
257
253
|
&:not(.is-multiple) {
|
|
258
254
|
.el-cascader__suggestion-item {
|
|
@@ -264,6 +260,7 @@ onMounted(() => {
|
|
|
264
260
|
}
|
|
265
261
|
}
|
|
266
262
|
}
|
|
263
|
+
|
|
267
264
|
.el-cascader__search-input {
|
|
268
265
|
position: absolute;
|
|
269
266
|
left: var(--ct-component-inner-padding);
|
|
@@ -274,11 +271,14 @@ onMounted(() => {
|
|
|
274
271
|
font-size: var(--ct-font-size);
|
|
275
272
|
margin: 0;
|
|
276
273
|
}
|
|
274
|
+
|
|
277
275
|
.el-input__wrapper {
|
|
278
276
|
position: relative;
|
|
277
|
+
|
|
279
278
|
.el-input__inner {
|
|
280
279
|
height: var(--ct-cascader-inner-height) !important;
|
|
281
280
|
}
|
|
281
|
+
|
|
282
282
|
&::after {
|
|
283
283
|
position: absolute;
|
|
284
284
|
content: v-bind(checkedText);
|
|
@@ -1,32 +1,33 @@
|
|
|
1
|
-
import button from
|
|
2
|
-
import radio from
|
|
3
|
-
import checkbox from
|
|
4
|
-
import input from
|
|
5
|
-
import inputRange from
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
1
|
+
import button from "./button";
|
|
2
|
+
import radio from "./radio";
|
|
3
|
+
import checkbox from "./checkbox";
|
|
4
|
+
import input from "./input";
|
|
5
|
+
import inputRange from "./input-range";
|
|
6
|
+
import numberInputRange from "./number-input-range";
|
|
7
|
+
import select from "./select";
|
|
8
|
+
import pagingSelect from "./paging-select";
|
|
9
|
+
import yearSelect from "./year-select";
|
|
10
|
+
import datePicker from "./date-picker";
|
|
11
|
+
import cascader from "./cascader";
|
|
12
|
+
import tabs from "./tabs";
|
|
13
|
+
import pagination from "./pagination";
|
|
14
|
+
import menu from "./menu";
|
|
14
15
|
|
|
15
|
-
import searchBox from
|
|
16
|
-
import table from
|
|
16
|
+
import searchBox from "./search-box";
|
|
17
|
+
import table from "./table";
|
|
17
18
|
import empty from "./empty";
|
|
18
19
|
import dialog from "./dialog";
|
|
19
|
-
import messageBox from
|
|
20
|
-
import CtMessage from
|
|
20
|
+
import messageBox from "./message-box";
|
|
21
|
+
import CtMessage from "./message";
|
|
21
22
|
|
|
22
|
-
import CtLoading from
|
|
23
|
-
import CtPage from
|
|
23
|
+
import CtLoading from "./loading";
|
|
24
|
+
import CtPage from "./page";
|
|
24
25
|
|
|
25
|
-
import ElementPlus from
|
|
26
|
-
import zhCn from
|
|
27
|
-
import cingtaIcon from
|
|
26
|
+
import ElementPlus from "element-plus";
|
|
27
|
+
import zhCn from "element-plus/dist/locale/zh-cn.mjs";
|
|
28
|
+
import cingtaIcon from "cingta-icon";
|
|
28
29
|
// import cingtaIcon from '../../icon/components/index';
|
|
29
|
-
import { isObject } from
|
|
30
|
+
import { isObject } from "../utils";
|
|
30
31
|
// import '../style';
|
|
31
32
|
|
|
32
33
|
const components = [
|
|
@@ -35,6 +36,7 @@ const components = [
|
|
|
35
36
|
checkbox,
|
|
36
37
|
input,
|
|
37
38
|
inputRange,
|
|
39
|
+
numberInputRange,
|
|
38
40
|
select,
|
|
39
41
|
pagingSelect,
|
|
40
42
|
yearSelect,
|
|
@@ -50,35 +52,37 @@ const components = [
|
|
|
50
52
|
messageBox,
|
|
51
53
|
CtMessage,
|
|
52
54
|
CtLoading,
|
|
53
|
-
CtPage
|
|
54
|
-
]
|
|
55
|
+
CtPage,
|
|
56
|
+
];
|
|
55
57
|
|
|
56
58
|
const serviceConfig = {
|
|
57
|
-
defaultMethod:
|
|
58
|
-
}
|
|
59
|
+
defaultMethod: "post",
|
|
60
|
+
};
|
|
59
61
|
|
|
60
62
|
const install = function (app, options) {
|
|
61
|
-
components.forEach(c => app.use(c))
|
|
62
|
-
app.use(ElementPlus, { locale: zhCn
|
|
63
|
-
app.use(cingtaIcon)
|
|
64
|
-
let serviceOptions = {}
|
|
63
|
+
components.forEach((c) => app.use(c));
|
|
64
|
+
app.use(ElementPlus, { locale: zhCn });
|
|
65
|
+
app.use(cingtaIcon);
|
|
66
|
+
let serviceOptions = {};
|
|
65
67
|
if (isObject(options)) {
|
|
66
68
|
const { tableEmptyDom, selectTooltip = false } = options;
|
|
67
69
|
if (!options.baseDao) {
|
|
68
|
-
console.warn(
|
|
70
|
+
console.warn("当前使用的组件库没有配置baseDao");
|
|
69
71
|
} else {
|
|
70
|
-
app.provide(
|
|
72
|
+
app.provide("$ctBaseDao", options.baseDao);
|
|
71
73
|
}
|
|
72
|
-
app.provide(
|
|
73
|
-
if (isObject(options.serviceOptions))
|
|
74
|
-
|
|
75
|
-
if (isObject(
|
|
74
|
+
app.provide("$selectTooltip", selectTooltip);
|
|
75
|
+
if (isObject(options.serviceOptions))
|
|
76
|
+
serviceOptions = options.serviceOptions;
|
|
77
|
+
if (isObject(options.searchBoxComponent))
|
|
78
|
+
app.provide("$userDefinedSearchComponent", options.searchBoxComponent);
|
|
79
|
+
if (isObject(tableEmptyDom)) app.provide("$tableEmptyDom", tableEmptyDom);
|
|
76
80
|
}
|
|
77
|
-
app.provide(
|
|
78
|
-
}
|
|
81
|
+
app.provide("$ctServiceConfig", { ...serviceConfig, ...serviceOptions });
|
|
82
|
+
};
|
|
79
83
|
|
|
80
84
|
export default {
|
|
81
|
-
install
|
|
82
|
-
}
|
|
83
|
-
export { CtMessage }
|
|
84
|
-
export * from
|
|
85
|
+
install,
|
|
86
|
+
};
|
|
87
|
+
export { CtMessage };
|
|
88
|
+
export * from "element-plus";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import CtNumberInputRange from "./src/number-input-range.vue";
|
|
2
|
+
|
|
3
|
+
/* istanbul ignore next */
|
|
4
|
+
CtNumberInputRange.install = function (Vue) {
|
|
5
|
+
// TODO 这里D组件名是这这里写死的,不是使用CtNumberInputRange.name的形式,因为setup里面不可以直接什么组件的name属性,故而这里没有这个属性,后续可以考虑使用defineOptions(需要安装unplugin-vue-macros插件)
|
|
6
|
+
Vue.component("CtNumberInputRange", CtNumberInputRange);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default CtNumberInputRange;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { buriedParamsKey, searchComponentProps } from "../../../hooks";
|
|
2
|
+
|
|
3
|
+
export const numberInputRangeEmits = [
|
|
4
|
+
"update:modelValue",
|
|
5
|
+
buriedParamsKey,
|
|
6
|
+
"change",
|
|
7
|
+
];
|
|
8
|
+
export const numberInputRangeProps = {
|
|
9
|
+
...searchComponentProps,
|
|
10
|
+
modelValue: Array,
|
|
11
|
+
min: Number,
|
|
12
|
+
max: Number,
|
|
13
|
+
step: {
|
|
14
|
+
type: Number,
|
|
15
|
+
default: 1,
|
|
16
|
+
},
|
|
17
|
+
precision: Number,
|
|
18
|
+
disabled: Boolean,
|
|
19
|
+
separator: {
|
|
20
|
+
type: String,
|
|
21
|
+
default: "--",
|
|
22
|
+
},
|
|
23
|
+
controlsPosition: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: "right",
|
|
26
|
+
},
|
|
27
|
+
placeholder: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: "请输入数字",
|
|
30
|
+
},
|
|
31
|
+
};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="[ns.b(), ns.is('disabled', disabled)]">
|
|
3
|
+
<div :class="[ns.e('wrapper')]">
|
|
4
|
+
<el-input-number
|
|
5
|
+
ref="inputRef1"
|
|
6
|
+
v-model="leftModel"
|
|
7
|
+
:placeholder="placeholder"
|
|
8
|
+
:min="min"
|
|
9
|
+
:max="max"
|
|
10
|
+
:step="step"
|
|
11
|
+
:precision="precision"
|
|
12
|
+
:disabled="disabled"
|
|
13
|
+
v-bind="rawAttr"
|
|
14
|
+
:controls-position="controlsPosition"
|
|
15
|
+
@change="handleChange($event, 0)"
|
|
16
|
+
/>
|
|
17
|
+
<span :class="[ns.e('separator')]">
|
|
18
|
+
<slot name="separator">{{ separator }}</slot>
|
|
19
|
+
</span>
|
|
20
|
+
<el-input-number
|
|
21
|
+
ref="inputRef2"
|
|
22
|
+
v-model="rightModel"
|
|
23
|
+
:placeholder="placeholder"
|
|
24
|
+
:min="min"
|
|
25
|
+
:max="max"
|
|
26
|
+
:step="step"
|
|
27
|
+
:precision="precision"
|
|
28
|
+
:disabled="disabled"
|
|
29
|
+
v-bind="rawAttr"
|
|
30
|
+
:controls-position="controlsPosition"
|
|
31
|
+
@change="handleChange($event, 1)"
|
|
32
|
+
/>
|
|
33
|
+
</div>
|
|
34
|
+
</div>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<script setup>
|
|
38
|
+
import { computed, ref } from "vue";
|
|
39
|
+
import { useNamespace, useBuriedParams } from "../../../hooks";
|
|
40
|
+
import { numberInputRangeEmits, numberInputRangeProps } from "./index";
|
|
41
|
+
const props = defineProps(numberInputRangeProps);
|
|
42
|
+
const emit = defineEmits(numberInputRangeEmits);
|
|
43
|
+
|
|
44
|
+
useBuriedParams(props, emit);
|
|
45
|
+
const ns = useNamespace("number-input-range");
|
|
46
|
+
|
|
47
|
+
const inputRef1 = ref(null);
|
|
48
|
+
const inputRef2 = ref(null);
|
|
49
|
+
|
|
50
|
+
const leftModel = computed({
|
|
51
|
+
get() {
|
|
52
|
+
return Array.isArray(props.modelValue) ? props.modelValue[0] : undefined;
|
|
53
|
+
},
|
|
54
|
+
set(newValue) {
|
|
55
|
+
const right = Array.isArray(props.modelValue)
|
|
56
|
+
? props.modelValue[1]
|
|
57
|
+
: undefined;
|
|
58
|
+
emit("update:modelValue", [newValue, right]);
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
const rightModel = computed({
|
|
62
|
+
get() {
|
|
63
|
+
return Array.isArray(props.modelValue) ? props.modelValue[1] : undefined;
|
|
64
|
+
},
|
|
65
|
+
set(newValue) {
|
|
66
|
+
const left = Array.isArray(props.modelValue)
|
|
67
|
+
? props.modelValue[0]
|
|
68
|
+
: undefined;
|
|
69
|
+
emit("update:modelValue", [left, newValue]);
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const handleChange = (val, index) => {
|
|
74
|
+
emit("change", props.modelValue, index, val);
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
defineExpose({
|
|
78
|
+
ref: [inputRef1, inputRef2],
|
|
79
|
+
});
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<style lang="less">
|
|
83
|
+
.ct-number-input-range {
|
|
84
|
+
position: relative;
|
|
85
|
+
display: inline-flex;
|
|
86
|
+
width: var(--ct-component-width);
|
|
87
|
+
font-size: var(--ct-font-size);
|
|
88
|
+
color: var(--ct-border-color);
|
|
89
|
+
box-sizing: border-box;
|
|
90
|
+
vertical-align: middle;
|
|
91
|
+
@R: .ct-number-input-range;
|
|
92
|
+
&.is-disabled {
|
|
93
|
+
cursor: not-allowed;
|
|
94
|
+
--ct-component-fill-color: var(--ct-component-disabled-bg-color);
|
|
95
|
+
@{R}__wrapper {
|
|
96
|
+
.el-input__wrapper {
|
|
97
|
+
height: var(--ct-component-inner-height);
|
|
98
|
+
padding: 1px var(--ct-component-inner-padding);
|
|
99
|
+
box-shadow: unset;
|
|
100
|
+
border-radius: 0;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
&:not(.is-disabled):hover {
|
|
105
|
+
--ct-component-border-color: var(--ct-component-hover-border-color);
|
|
106
|
+
}
|
|
107
|
+
&__wrapper {
|
|
108
|
+
display: inline-flex;
|
|
109
|
+
flex-grow: 1;
|
|
110
|
+
align-items: center;
|
|
111
|
+
justify-content: center;
|
|
112
|
+
padding: 1px 0;
|
|
113
|
+
background-color: var(--ct-component-fill-color);
|
|
114
|
+
background-image: none;
|
|
115
|
+
border-radius: var(--ct-component-border-radius);
|
|
116
|
+
transition: var(--el-transition-box-shadow);
|
|
117
|
+
transform: translate3d(0, 0, 0);
|
|
118
|
+
box-shadow: 0 0 0 1px var(--ct-component-border-color) inset;
|
|
119
|
+
&:focus-within {
|
|
120
|
+
--ct-component-border-color: var(--ct-color-primary);
|
|
121
|
+
}
|
|
122
|
+
.el-input-number {
|
|
123
|
+
width: calc(50% - 8px);
|
|
124
|
+
&.is-controls-right .el-input__wrapper {
|
|
125
|
+
padding: 1px var(--ct-component-inner-padding);
|
|
126
|
+
}
|
|
127
|
+
.el-input__wrapper {
|
|
128
|
+
padding: 1px var(--ct-component-inner-padding);
|
|
129
|
+
box-shadow: unset;
|
|
130
|
+
border-radius: 0;
|
|
131
|
+
}
|
|
132
|
+
.el-input__inner {
|
|
133
|
+
color: var(--ct-component-color);
|
|
134
|
+
font-size: inherit;
|
|
135
|
+
}
|
|
136
|
+
span[role="button"] {
|
|
137
|
+
display: none;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
&__separator {
|
|
142
|
+
color: var(--ct-color-grey-sub);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
</style>
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import CtSearchBox from
|
|
1
|
+
import CtSearchBox from "./src/search-box.vue";
|
|
2
2
|
|
|
3
|
-
import CtInput from
|
|
4
|
-
import CtSelect from
|
|
5
|
-
import CtDatePicker from
|
|
6
|
-
import CtCascader from
|
|
7
|
-
import CtYearSelect from
|
|
8
|
-
import CtRadio from
|
|
9
|
-
import CtPagingSelect from
|
|
3
|
+
import CtInput from "../input";
|
|
4
|
+
import CtSelect from "../select";
|
|
5
|
+
import CtDatePicker from "../date-picker";
|
|
6
|
+
import CtCascader from "../cascader";
|
|
7
|
+
import CtYearSelect from "../year-select";
|
|
8
|
+
import CtRadio from "../radio";
|
|
9
|
+
import CtPagingSelect from "../paging-select";
|
|
10
|
+
import CtNumberInputRange from "../number-input-range";
|
|
10
11
|
|
|
11
12
|
export const searchComponents = {
|
|
12
13
|
CtInput,
|
|
@@ -16,14 +17,15 @@ export const searchComponents = {
|
|
|
16
17
|
CtYearSelect,
|
|
17
18
|
CtRadio,
|
|
18
19
|
CtPagingSelect,
|
|
19
|
-
|
|
20
|
+
CtNumberInputRange,
|
|
21
|
+
};
|
|
20
22
|
|
|
21
23
|
/* istanbul ignore next */
|
|
22
24
|
CtSearchBox.install = function (Vue) {
|
|
23
|
-
Vue.component(
|
|
25
|
+
Vue.component("CtSearchBox", CtSearchBox);
|
|
24
26
|
// for (const key in searchComponents) {
|
|
25
27
|
// Vue.component(key, searchComponents[key]);
|
|
26
28
|
// }
|
|
27
29
|
};
|
|
28
30
|
|
|
29
|
-
export default CtSearchBox;
|
|
31
|
+
export default CtSearchBox;
|
|
@@ -2,29 +2,48 @@
|
|
|
2
2
|
<div :class="[ns.b()]">
|
|
3
3
|
<div :class="[ns.e('container')]">
|
|
4
4
|
<div :class="[ns.e('list')]">
|
|
5
|
-
<div
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
<div
|
|
6
|
+
v-for="(item, index) in searchList"
|
|
7
|
+
:class="[
|
|
8
|
+
ns.e('item'),
|
|
9
|
+
...getComponentClass(item),
|
|
10
|
+
ns.is('outer-border', outerBorder),
|
|
11
|
+
]"
|
|
12
|
+
:key="item.param || index"
|
|
13
|
+
:style="{ ...getComponentStyle(item) }"
|
|
14
|
+
@click="clickItem(item)"
|
|
15
|
+
>
|
|
10
16
|
<slot v-bind="getComponentSlotScope(item)">
|
|
11
17
|
<slot name="item-before" v-bind="getComponentSlotScope(item)">
|
|
12
18
|
</slot>
|
|
13
|
-
<span
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
<span
|
|
20
|
+
:class="[
|
|
21
|
+
ns.e('item-label'),
|
|
22
|
+
ns.is('required', item.required),
|
|
23
|
+
ns.is('outer-border', outerBorder),
|
|
24
|
+
]"
|
|
25
|
+
>
|
|
26
|
+
<el-tooltip
|
|
27
|
+
:disabled="judgeIsHideLabelTooltip(item)"
|
|
28
|
+
class="box-item"
|
|
29
|
+
effect="dark"
|
|
30
|
+
:content="item.label"
|
|
31
|
+
placement="bottom"
|
|
32
|
+
>
|
|
20
33
|
<span>{{ item.label }}</span>
|
|
21
34
|
</el-tooltip>
|
|
22
35
|
<span :class="[ns.is('required')]" v-if="!outerBorder">:</span>
|
|
23
36
|
</span>
|
|
24
37
|
<div :class="[ns.e('item-component')]">
|
|
25
|
-
<slot
|
|
26
|
-
|
|
27
|
-
|
|
38
|
+
<slot
|
|
39
|
+
:name="item.componentName || item.param"
|
|
40
|
+
v-bind="getComponentSlotScope(item)"
|
|
41
|
+
>
|
|
42
|
+
<component
|
|
43
|
+
:is="getComponent(item.type)"
|
|
44
|
+
v-model="searchParamsCurrent[item.param]"
|
|
45
|
+
v-bind="getComponentProps(item)"
|
|
46
|
+
>
|
|
28
47
|
</component>
|
|
29
48
|
</slot>
|
|
30
49
|
</div>
|
|
@@ -33,7 +52,9 @@
|
|
|
33
52
|
</div>
|
|
34
53
|
<div :class="[ns.e('buttons')]">
|
|
35
54
|
<slot name="solt-search">
|
|
36
|
-
<ct-button type="border-plain" @click="resetData" v-if="haveReset"
|
|
55
|
+
<ct-button type="border-plain" @click="resetData" v-if="haveReset"
|
|
56
|
+
>重置</ct-button
|
|
57
|
+
>
|
|
37
58
|
<ct-button type="border" @click="doSearch">{{
|
|
38
59
|
searchBtnName
|
|
39
60
|
}}</ct-button>
|
|
@@ -66,18 +87,18 @@ watch(
|
|
|
66
87
|
(newValue) => {
|
|
67
88
|
searchParamsCurrent.value = newValue || {};
|
|
68
89
|
},
|
|
69
|
-
{ immediate: true }
|
|
90
|
+
{ immediate: true },
|
|
70
91
|
);
|
|
71
92
|
|
|
72
93
|
const judgeIsHideLabelTooltip = (item) => {
|
|
73
94
|
if (isString(item.label)) {
|
|
74
|
-
return item.label.length <=
|
|
95
|
+
return item.label.length <= 6;
|
|
75
96
|
}
|
|
76
97
|
};
|
|
77
98
|
|
|
78
99
|
const clickItem = (item) => {
|
|
79
100
|
emit("clickItem", item);
|
|
80
|
-
}
|
|
101
|
+
};
|
|
81
102
|
const getComponentClass = (item) => {
|
|
82
103
|
const classList = [];
|
|
83
104
|
if (item.componentClass) {
|
|
@@ -104,8 +125,8 @@ const componentAll = computed(() => {
|
|
|
104
125
|
CtYearSelect,
|
|
105
126
|
CtRadio,
|
|
106
127
|
CtPagingSelect,
|
|
107
|
-
|
|
108
|
-
|
|
128
|
+
CtNumberInputRange,
|
|
129
|
+
} = searchComponents;
|
|
109
130
|
const componentMap = {
|
|
110
131
|
0: CtInput,
|
|
111
132
|
1: CtSelect,
|
|
@@ -114,6 +135,7 @@ const componentAll = computed(() => {
|
|
|
114
135
|
12: CtYearSelect,
|
|
115
136
|
13: "div",
|
|
116
137
|
20: CtRadio,
|
|
138
|
+
21: CtNumberInputRange,
|
|
117
139
|
22: CtPagingSelect,
|
|
118
140
|
...userDefinedSearchComponent,
|
|
119
141
|
};
|
|
@@ -170,6 +192,20 @@ const resetData = () => {
|
|
|
170
192
|
emit("doReset");
|
|
171
193
|
};
|
|
172
194
|
const doSearch = () => {
|
|
195
|
+
// 遍历当前搜索参数,处理需要排序的数组项
|
|
196
|
+
Object.keys(searchParamsCurrent.value).forEach((key) => {
|
|
197
|
+
const val = searchParamsCurrent.value[key];
|
|
198
|
+
if (Array.isArray(val) && val.length === 2) {
|
|
199
|
+
const [first, second] = val;
|
|
200
|
+
// 判断是否均为数字且需要交换顺序
|
|
201
|
+
if (typeof first === "number" && typeof second === "number") {
|
|
202
|
+
if (first > second) {
|
|
203
|
+
searchParamsCurrent.value[key] = [second, first];
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
|
|
173
209
|
emit("update:searchParams", searchParamsCurrent);
|
|
174
210
|
emit("doSearch", searchParamsCurrent.value);
|
|
175
211
|
};
|
|
@@ -181,7 +217,7 @@ defineExpose({
|
|
|
181
217
|
buriedParams,
|
|
182
218
|
doSearch,
|
|
183
219
|
});
|
|
184
|
-
onMounted(() => {
|
|
220
|
+
onMounted(() => {});
|
|
185
221
|
</script>
|
|
186
222
|
<style lang="less">
|
|
187
223
|
.ct-search-box {
|
|
@@ -199,7 +235,7 @@ onMounted(() => { });
|
|
|
199
235
|
margin-right: calc(-1 * var(--ct-search-box-item-margin-right));
|
|
200
236
|
margin-top: calc(-1 * var(--ct-search-box-item-margin-top));
|
|
201
237
|
|
|
202
|
-
|
|
238
|
+
> * {
|
|
203
239
|
margin-right: var(--ct-search-box-item-margin-right);
|
|
204
240
|
margin-top: var(--ct-search-box-item-margin-top);
|
|
205
241
|
}
|
|
@@ -208,7 +244,10 @@ onMounted(() => { });
|
|
|
208
244
|
&__item {
|
|
209
245
|
display: flex;
|
|
210
246
|
align-items: center;
|
|
211
|
-
width: calc(
|
|
247
|
+
width: calc(
|
|
248
|
+
(100% - v-bind(rowNumber) * var(--ct-search-box-item-margin-right)) /
|
|
249
|
+
v-bind(rowNumber)
|
|
250
|
+
);
|
|
212
251
|
--ct-search-box-item-component-width: 100%;
|
|
213
252
|
|
|
214
253
|
&.is-outer-border {
|
|
@@ -232,8 +271,11 @@ onMounted(() => { });
|
|
|
232
271
|
|
|
233
272
|
.el-input__wrapper,
|
|
234
273
|
.el-select__wrapper,
|
|
235
|
-
.ct-year-select__wrapper
|
|
236
|
-
|
|
274
|
+
.ct-year-select__wrapper,
|
|
275
|
+
.ct-number-input-range__wrapper {
|
|
276
|
+
--el-select-input-focus-border-color: var(
|
|
277
|
+
--ct-search-box-inner-border-color
|
|
278
|
+
);
|
|
237
279
|
box-shadow: 0 0 0 1px var(--ct-search-box-inner-border-color) !important;
|
|
238
280
|
}
|
|
239
281
|
}
|
|
@@ -261,7 +303,7 @@ onMounted(() => { });
|
|
|
261
303
|
&-component {
|
|
262
304
|
flex: 1;
|
|
263
305
|
|
|
264
|
-
|
|
306
|
+
> * {
|
|
265
307
|
width: var(--ct-search-box-item-component-width) !important;
|
|
266
308
|
}
|
|
267
309
|
}
|
|
@@ -104,11 +104,11 @@ const selectYearE = computed({
|
|
|
104
104
|
|
|
105
105
|
const handleNewValue = (newValue) => {
|
|
106
106
|
let newArr = JSON.parse(JSON.stringify(newValue));
|
|
107
|
-
if (isArray(newValue)) {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
}
|
|
107
|
+
// if (isArray(newValue)) {
|
|
108
|
+
// if (newArr[0] && newArr[1] && newArr[0] > newArr[1]) {
|
|
109
|
+
// newArr = [newValue[1], newValue[0]];
|
|
110
|
+
// }
|
|
111
|
+
// }
|
|
112
112
|
emit("update:modelValue", newArr);
|
|
113
113
|
emit("change", newArr);
|
|
114
114
|
};
|
|
@@ -135,9 +135,12 @@ const getYearList = () => {
|
|
|
135
135
|
}
|
|
136
136
|
yearList.value = yearArr;
|
|
137
137
|
};
|
|
138
|
-
watch(
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
watch(
|
|
139
|
+
() => props.range,
|
|
140
|
+
() => {
|
|
141
|
+
getYearList();
|
|
142
|
+
},
|
|
143
|
+
);
|
|
141
144
|
const filterHandleE = (str) => {
|
|
142
145
|
//处理结束年
|
|
143
146
|
if (judgeYear(str) && judgeRange(str)) {
|
|
@@ -207,7 +210,7 @@ onMounted(() => {
|
|
|
207
210
|
getYearList();
|
|
208
211
|
});
|
|
209
212
|
</script>
|
|
210
|
-
<style lang=
|
|
213
|
+
<style lang="less">
|
|
211
214
|
.ct-year-select {
|
|
212
215
|
--el-select-input-focus-border-color: transparent;
|
|
213
216
|
--ct-year-select-select-inner-box-shadow: none;
|
|
@@ -274,4 +277,4 @@ onMounted(() => {
|
|
|
274
277
|
}
|
|
275
278
|
}
|
|
276
279
|
}
|
|
277
|
-
</style>
|
|
280
|
+
</style>
|