ct-component-plus 2.1.5 → 2.1.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/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ct-component-plus",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.7",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "packages/components/index.js",
|
|
7
7
|
"files": [
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"cingta-icon": "^2.1.6",
|
|
19
|
-
"element-plus": "2.
|
|
19
|
+
"element-plus": "^2.11.0",
|
|
20
20
|
"vue": "^3.2.47"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
<el-date-picker
|
|
3
3
|
:class="[ns.b()]"
|
|
4
4
|
v-model="showValue"
|
|
5
|
+
:name="componentName"
|
|
5
6
|
:value-format="valueFormat"
|
|
6
7
|
:range-separator="rangeSeparator"
|
|
7
8
|
:clear-icon="clearIcon"
|
|
8
9
|
:prefix-icon="prefixIcon"
|
|
9
10
|
:unlink-panels="unlinkPanels"
|
|
10
|
-
v-bind="rawAttr"
|
|
11
|
+
v-bind="rawAttr"
|
|
12
|
+
>
|
|
11
13
|
<template #default="cell">
|
|
12
14
|
<slot v-bind="cell"></slot>
|
|
13
15
|
</template>
|
|
@@ -24,6 +26,15 @@ const emit = defineEmits(datePickerEmits);
|
|
|
24
26
|
const attr = useAttrs();
|
|
25
27
|
const ns = useNamespace("date-picker");
|
|
26
28
|
|
|
29
|
+
const componentName = computed(() => {
|
|
30
|
+
const rawType = props.rawAttr?.type || attr.type;
|
|
31
|
+
if (isArray(props.name)) return props.name;
|
|
32
|
+
if (rawType && rawType.includes("range")) {
|
|
33
|
+
return props.name ? [props.name, props.name] : [];
|
|
34
|
+
}
|
|
35
|
+
return props.name;
|
|
36
|
+
});
|
|
37
|
+
|
|
27
38
|
const showValue = computed({
|
|
28
39
|
get() {
|
|
29
40
|
return props.modelValue;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { buriedParamsKey, searchComponentProps } from
|
|
2
|
-
import clearIcon from
|
|
3
|
-
import dateIcon from
|
|
1
|
+
import { buriedParamsKey, searchComponentProps } from "../../../hooks";
|
|
2
|
+
import clearIcon from "./clear-icon.vue";
|
|
3
|
+
import dateIcon from "./date-icon.vue";
|
|
4
4
|
|
|
5
5
|
export const datePickerEmits = ["update:modelValue", buriedParamsKey];
|
|
6
6
|
export const datePickerProps = {
|
|
@@ -8,27 +8,31 @@ export const datePickerProps = {
|
|
|
8
8
|
modelValue: [Date, Number, String, Array],
|
|
9
9
|
valueFormat: {
|
|
10
10
|
type: String,
|
|
11
|
-
default:
|
|
11
|
+
default: "x",
|
|
12
12
|
},
|
|
13
13
|
addTimestamp: [Number, String, Array, Function],
|
|
14
14
|
rangeSeparator: {
|
|
15
15
|
type: String,
|
|
16
|
-
default:
|
|
16
|
+
default: "至",
|
|
17
17
|
},
|
|
18
18
|
clearIcon: {
|
|
19
19
|
type: [String, Object],
|
|
20
20
|
default() {
|
|
21
|
-
return clearIcon
|
|
22
|
-
}
|
|
21
|
+
return clearIcon;
|
|
22
|
+
},
|
|
23
23
|
},
|
|
24
24
|
prefixIcon: {
|
|
25
25
|
type: [String, Object],
|
|
26
26
|
default() {
|
|
27
|
-
return dateIcon
|
|
28
|
-
}
|
|
27
|
+
return dateIcon;
|
|
28
|
+
},
|
|
29
29
|
},
|
|
30
30
|
unlinkPanels: {
|
|
31
31
|
type: Boolean,
|
|
32
|
-
default: true
|
|
33
|
-
}
|
|
34
|
-
|
|
32
|
+
default: true,
|
|
33
|
+
},
|
|
34
|
+
name: {
|
|
35
|
+
type: [String, Array],
|
|
36
|
+
default: "",
|
|
37
|
+
},
|
|
38
|
+
};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
:class="[ns.b(), ns.is('multiple', multiple)]"
|
|
6
6
|
v-model="valueModel"
|
|
7
7
|
collapse-tags
|
|
8
|
-
v-bind="
|
|
8
|
+
v-bind="bindAttrs"
|
|
9
9
|
:multiple="multiple"
|
|
10
10
|
:filterable="filterable"
|
|
11
11
|
:clear-icon="clearIcon"
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
</template>
|
|
36
36
|
</el-input>
|
|
37
37
|
</div>
|
|
38
|
-
<div :class="[ns.e('select')]" v-if="!
|
|
38
|
+
<div :class="[ns.e('select')]" v-if="!bindAttrs.multipleLimit">
|
|
39
39
|
<span :class="[ns.e('select-title')]">
|
|
40
40
|
<span v-if="!keyword">已选{{ selectLength }}项</span>
|
|
41
41
|
<span v-else>检索结果</span>
|
|
@@ -74,6 +74,12 @@
|
|
|
74
74
|
</el-select>
|
|
75
75
|
</template>
|
|
76
76
|
|
|
77
|
+
<script>
|
|
78
|
+
export default {
|
|
79
|
+
inheritAttrs: false,
|
|
80
|
+
};
|
|
81
|
+
</script>
|
|
82
|
+
|
|
77
83
|
<script setup>
|
|
78
84
|
import {
|
|
79
85
|
onMounted,
|
|
@@ -83,6 +89,7 @@ import {
|
|
|
83
89
|
inject,
|
|
84
90
|
watchEffect,
|
|
85
91
|
nextTick,
|
|
92
|
+
useAttrs,
|
|
86
93
|
} from "vue";
|
|
87
94
|
import { selectEmits, selectProps } from "./index";
|
|
88
95
|
import { useNamespace, useBuriedParams, useCheckedAll } from "../../../hooks";
|
|
@@ -104,15 +111,66 @@ const emit = defineEmits(selectEmits);
|
|
|
104
111
|
// };
|
|
105
112
|
const ns = useNamespace("select");
|
|
106
113
|
const optionsByApi = ref([]);
|
|
114
|
+
|
|
115
|
+
const EMPTY_VALUE = "___CT_EMPTY_STRING___";
|
|
116
|
+
const attrs = useAttrs();
|
|
117
|
+
|
|
118
|
+
const bindAttrs = computed(() => {
|
|
119
|
+
const merged = { ...attrs, ...props.rawAttr };
|
|
120
|
+
if (merged.onChange) {
|
|
121
|
+
const original = merged.onChange;
|
|
122
|
+
merged.onChange = (val) => {
|
|
123
|
+
let realVal = val;
|
|
124
|
+
if (Array.isArray(val)) {
|
|
125
|
+
realVal = val.map((v) => (v === EMPTY_VALUE ? "" : v));
|
|
126
|
+
} else {
|
|
127
|
+
if (realVal === EMPTY_VALUE) realVal = "";
|
|
128
|
+
}
|
|
129
|
+
original(realVal);
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
return merged;
|
|
133
|
+
});
|
|
134
|
+
|
|
107
135
|
const showOptions = computed(() => {
|
|
108
|
-
|
|
136
|
+
const opts = optionsByApi.value.length ? optionsByApi.value : props.options;
|
|
137
|
+
return opts.map((item) => {
|
|
138
|
+
if (item.value === "") {
|
|
139
|
+
return { ...item, value: EMPTY_VALUE };
|
|
140
|
+
}
|
|
141
|
+
return item;
|
|
142
|
+
});
|
|
109
143
|
});
|
|
110
144
|
const valueModel = computed({
|
|
111
145
|
get() {
|
|
112
|
-
|
|
146
|
+
const val = props.modelValue;
|
|
147
|
+
const hasEmptyOption = showOptions.value.some(
|
|
148
|
+
(item) => item.value === EMPTY_VALUE
|
|
149
|
+
);
|
|
150
|
+
if (props.multiple) {
|
|
151
|
+
if (Array.isArray(val)) {
|
|
152
|
+
return val.map((v) => {
|
|
153
|
+
if (v === "") {
|
|
154
|
+
return hasEmptyOption ? EMPTY_VALUE : "";
|
|
155
|
+
}
|
|
156
|
+
return v;
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
return [];
|
|
160
|
+
}
|
|
161
|
+
if (val === "") {
|
|
162
|
+
return hasEmptyOption ? EMPTY_VALUE : "";
|
|
163
|
+
}
|
|
164
|
+
return val ?? "";
|
|
113
165
|
},
|
|
114
166
|
set(newValue) {
|
|
115
|
-
|
|
167
|
+
let emitVal = newValue;
|
|
168
|
+
if (Array.isArray(emitVal)) {
|
|
169
|
+
emitVal = emitVal.map((v) => (v === EMPTY_VALUE ? "" : v));
|
|
170
|
+
} else {
|
|
171
|
+
if (emitVal === EMPTY_VALUE) emitVal = "";
|
|
172
|
+
}
|
|
173
|
+
emit("update:modelValue", emitVal);
|
|
116
174
|
},
|
|
117
175
|
});
|
|
118
176
|
const keyword = ref("");
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { buriedParamsKey, searchComponentProps } from
|
|
1
|
+
import { buriedParamsKey, searchComponentProps } from "../../../hooks";
|
|
2
2
|
|
|
3
3
|
export const yearSelectEmits = [
|
|
4
4
|
"update:modelValue",
|
|
5
5
|
buriedParamsKey,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
"change",
|
|
7
|
+
"changeSelect",
|
|
8
|
+
"visible-change",
|
|
9
|
+
"blur",
|
|
10
|
+
"focus",
|
|
11
11
|
];
|
|
12
12
|
export const yearSelectProps = {
|
|
13
13
|
...searchComponentProps,
|
|
@@ -15,7 +15,7 @@ export const yearSelectProps = {
|
|
|
15
15
|
disabled: Boolean,
|
|
16
16
|
multiple: {
|
|
17
17
|
type: Boolean,
|
|
18
|
-
default: true
|
|
18
|
+
default: true,
|
|
19
19
|
},
|
|
20
20
|
startPlaceholder: String,
|
|
21
21
|
endPlaceholder: String,
|
|
@@ -42,4 +42,4 @@ export const yearSelectProps = {
|
|
|
42
42
|
type: [String, Object],
|
|
43
43
|
default: "至",
|
|
44
44
|
},
|
|
45
|
-
}
|
|
45
|
+
};
|