ct-component-plus 2.2.5 → 3.0.2

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.2.5",
4
+ "version": "3.0.2",
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.4.4",
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 '../../../hooks';
2
- import clearIcon from './clear-icon.vue';
3
- import dateIcon from './date-icon.vue';
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: 'x'
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
+ };
@@ -3,6 +3,7 @@ import radio from './radio';
3
3
  import checkbox from './checkbox';
4
4
  import input from './input';
5
5
  import inputRange from './input-range';
6
+ import numberInputRange from './number-input-range';
6
7
  import select from './select';
7
8
  import pagingSelect from './paging-select';
8
9
  import yearSelect from './year-select';
@@ -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,
@@ -62,7 +62,7 @@ defineExpose({
62
62
  ref: inputRef,
63
63
  });
64
64
  </script>
65
- <style lang='less'>
65
+ <style lang="less">
66
66
  .ct-input {
67
67
  @R: .ct-input;
68
68
  --ct-input-focus-color: var(--ct-color-primary);
@@ -104,4 +104,4 @@ defineExpose({
104
104
  }
105
105
  }
106
106
  }
107
- </style>
107
+ </style>
@@ -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,168 @@
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 normalizePair = (left, right) => {
51
+ const l = left;
52
+ const r = right;
53
+ if (l !== undefined && r !== undefined && l > r) {
54
+ return [r, l];
55
+ }
56
+ return [l, r];
57
+ };
58
+
59
+ const leftModel = computed({
60
+ get() {
61
+ return Array.isArray(props.modelValue) ? props.modelValue[0] : undefined;
62
+ },
63
+ set(newValue) {
64
+ const right = Array.isArray(props.modelValue)
65
+ ? props.modelValue[1]
66
+ : undefined;
67
+ emit("update:modelValue", [newValue, right]);
68
+ },
69
+ });
70
+ const rightModel = computed({
71
+ get() {
72
+ return Array.isArray(props.modelValue) ? props.modelValue[1] : undefined;
73
+ },
74
+ set(newValue) {
75
+ const left = Array.isArray(props.modelValue)
76
+ ? props.modelValue[0]
77
+ : undefined;
78
+ emit("update:modelValue", [left, newValue]);
79
+ },
80
+ });
81
+
82
+ const handleChange = (val, index) => {
83
+ const currentLeft = index === 0
84
+ ? val
85
+ : (Array.isArray(props.modelValue) ? props.modelValue[0] : undefined);
86
+ const currentRight = index === 1
87
+ ? val
88
+ : (Array.isArray(props.modelValue) ? props.modelValue[1] : undefined);
89
+ const bothFilled = typeof currentLeft === "number" && !isNaN(currentLeft)
90
+ && typeof currentRight === "number" && !isNaN(currentRight);
91
+ if (bothFilled) {
92
+ const normalized = normalizePair(currentLeft, currentRight);
93
+ emit("update:modelValue", normalized);
94
+ emit("change", normalized, index, val);
95
+ } else {
96
+ emit("change", [currentLeft, currentRight], index, val);
97
+ }
98
+ };
99
+
100
+ defineExpose({
101
+ ref: [inputRef1, inputRef2],
102
+ });
103
+ </script>
104
+
105
+ <style lang="less">
106
+ .ct-number-input-range {
107
+ position: relative;
108
+ display: inline-flex;
109
+ width: var(--ct-component-width);
110
+ font-size: var(--ct-font-size);
111
+ color: var(--ct-border-color);
112
+ box-sizing: border-box;
113
+ vertical-align: middle;
114
+ @R: .ct-number-input-range;
115
+ &.is-disabled {
116
+ cursor: not-allowed;
117
+ --ct-component-fill-color: var(--ct-component-disabled-bg-color);
118
+ @{R}__wrapper {
119
+ .el-input__wrapper {
120
+ height: var(--ct-component-inner-height);
121
+ padding: 1px var(--ct-component-inner-padding);
122
+ box-shadow: unset;
123
+ border-radius: 0;
124
+ }
125
+ }
126
+ }
127
+ &:not(.is-disabled):hover {
128
+ --ct-component-border-color: var(--ct-component-hover-border-color);
129
+ }
130
+ &__wrapper {
131
+ display: inline-flex;
132
+ flex-grow: 1;
133
+ align-items: center;
134
+ justify-content: center;
135
+ padding: 1px 0;
136
+ background-color: var(--ct-component-fill-color);
137
+ background-image: none;
138
+ border-radius: var(--ct-component-border-radius);
139
+ transition: var(--el-transition-box-shadow);
140
+ transform: translate3d(0, 0, 0);
141
+ box-shadow: 0 0 0 1px var(--ct-component-border-color) inset;
142
+ &:focus-within {
143
+ --ct-component-border-color: var(--ct-color-primary);
144
+ }
145
+ .el-input-number {
146
+ width: calc(50% - 8px);
147
+ &.is-controls-right .el-input__wrapper {
148
+ padding: 1px var(--ct-component-inner-padding);
149
+ }
150
+ .el-input__wrapper {
151
+ padding: 1px var(--ct-component-inner-padding);
152
+ box-shadow: unset;
153
+ border-radius: 0;
154
+ }
155
+ .el-input__inner {
156
+ color: var(--ct-component-color);
157
+ font-size: inherit;
158
+ }
159
+ span[role="button"] {
160
+ display: none;
161
+ }
162
+ }
163
+ }
164
+ &__separator {
165
+ color: var(--ct-color-grey-sub);
166
+ }
167
+ }
168
+ </style>
@@ -200,7 +200,7 @@ watch(
200
200
  (newVal) => {
201
201
  if (!selectRef.value) return;
202
202
  selectRef.value.selectedLabel = newVal;
203
- }
203
+ },
204
204
  );
205
205
  watch(optionsByApi, () => {
206
206
  const arr = optionsByApi.value || [];
@@ -298,7 +298,7 @@ const watchServiceHandle = async (reset = false) => {
298
298
  try {
299
299
  const defineSearchHandle = await cbs.defineSearch(
300
300
  optionsByApi,
301
- valueModel
301
+ valueModel,
302
302
  );
303
303
  if (defineSearchHandle === false) return;
304
304
  if (defineSearchHandle) {
@@ -319,7 +319,7 @@ watch(
319
319
  },
320
320
  {
321
321
  immediate: true,
322
- }
322
+ },
323
323
  );
324
324
  // watch(
325
325
  // () => keyword.value,
@@ -1,12 +1,13 @@
1
- import CtSearchBox from './src/search-box.vue';
1
+ import CtSearchBox from "./src/search-box.vue";
2
2
 
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';
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 CtNumberInputRange from "../number-input-range";
10
+ import CtPagingSelect from "../paging-select";
10
11
 
11
12
  export const searchComponents = {
12
13
  CtInput,
@@ -15,15 +16,16 @@ export const searchComponents = {
15
16
  CtCascader,
16
17
  CtYearSelect,
17
18
  CtRadio,
19
+ CtNumberInputRange,
18
20
  CtPagingSelect,
19
- }
21
+ };
20
22
 
21
23
  /* istanbul ignore next */
22
24
  CtSearchBox.install = function (Vue) {
23
- Vue.component('CtSearchBox', CtSearchBox);
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 v-for="(item, index) in searchList" :class="[
6
- ns.e('item'),
7
- ...getComponentClass(item),
8
- ns.is('outer-border', outerBorder),
9
- ]" :key="item.param || index" :style="{ ...getComponentStyle(item) }" @click="clickItem(item)">
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 :class="[
14
- ns.e('item-label'),
15
- ns.is('required', item.required),
16
- ns.is('outer-border', outerBorder),
17
- ]">
18
- <el-tooltip :disabled="judgeIsHideLabelTooltip(item)" class="box-item" effect="dark" :content="item.label"
19
- placement="bottom">
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 :name="item.componentName || item.param" v-bind="getComponentSlotScope(item)">
26
- <component :is="getComponent(item.type)" v-model="searchParamsCurrent[item.param]"
27
- v-bind="getComponentProps(item)">
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">重置</ct-button>
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>
@@ -77,7 +98,7 @@ const judgeIsHideLabelTooltip = (item) => {
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) {
@@ -103,9 +124,9 @@ const componentAll = computed(() => {
103
124
  CtCascader,
104
125
  CtYearSelect,
105
126
  CtRadio,
127
+ CtNumberInputRange,
106
128
  CtPagingSelect,
107
- } =
108
- searchComponents;
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
  };
@@ -181,36 +203,34 @@ defineExpose({
181
203
  buriedParams,
182
204
  doSearch,
183
205
  });
184
- onMounted(() => { });
206
+ onMounted(() => {});
185
207
  </script>
186
208
  <style lang="less">
187
209
  .ct-search-box {
188
210
  --ct-search-box-item-margin-right: 16px;
189
211
  --ct-search-box-item-margin-top: 14px;
190
-
191
212
  .el-input {
192
213
  --ct-input-default-width: auto;
193
214
  }
194
-
195
215
  &__list {
196
216
  display: flex;
197
217
  align-items: center;
198
218
  flex-wrap: wrap;
199
219
  margin-right: calc(-1 * var(--ct-search-box-item-margin-right));
200
220
  margin-top: calc(-1 * var(--ct-search-box-item-margin-top));
201
-
202
- >* {
221
+ > * {
203
222
  margin-right: var(--ct-search-box-item-margin-right);
204
223
  margin-top: var(--ct-search-box-item-margin-top);
205
224
  }
206
225
  }
207
-
208
226
  &__item {
209
227
  display: flex;
210
228
  align-items: center;
211
- width: calc((100% - v-bind(rowNumber) * var(--ct-search-box-item-margin-right)) / v-bind(rowNumber));
229
+ width: calc(
230
+ (100% - v-bind(rowNumber) * var(--ct-search-box-item-margin-right)) /
231
+ v-bind(rowNumber)
232
+ );
212
233
  --ct-search-box-item-component-width: 100%;
213
-
214
234
  &.is-outer-border {
215
235
  --ct-font-size: 13px;
216
236
  --el-font-size-base: var(--ct-font-size, 13px);
@@ -221,55 +241,46 @@ onMounted(() => { });
221
241
  padding-left: 14px;
222
242
  box-shadow: 0 0 0 1px var(--ct-search-box-border-color);
223
243
  border-radius: var(--ct-border-radius);
224
-
225
244
  &:hover {
226
245
  --ct-search-box-border-color: var(--ct-color-grey-sub);
227
246
  }
228
-
229
247
  &:focus-within {
230
248
  --ct-search-box-border-color: var(--ct-color-primary);
231
249
  }
232
-
233
250
  .el-input__wrapper,
234
251
  .el-select__wrapper,
235
- .ct-year-select__wrapper {
236
- --el-select-input-focus-border-color: var(--ct-search-box-inner-border-color);
252
+ .ct-year-select__wrapper,
253
+ .ct-number-input-range__wrapper {
254
+ --el-select-input-focus-border-color: var(
255
+ --ct-search-box-inner-border-color
256
+ );
237
257
  box-shadow: 0 0 0 1px var(--ct-search-box-inner-border-color) !important;
238
258
  }
239
259
  }
240
-
241
260
  .ct-radio {
242
261
  padding: 0 var(--ct-component-inner-padding);
243
-
244
262
  .el-radio {
245
263
  margin-right: 12px;
246
-
247
264
  &:last-child {
248
265
  margin-right: 0;
249
266
  }
250
267
  }
251
268
  }
252
-
253
269
  &-label {
254
270
  line-height: 1;
255
-
256
271
  &.is-outer-border {
257
272
  color: var(--ct-color-grey-sub);
258
273
  }
259
274
  }
260
-
261
275
  &-component {
262
276
  flex: 1;
263
-
264
- >* {
277
+ > * {
265
278
  width: var(--ct-search-box-item-component-width) !important;
266
279
  }
267
280
  }
268
281
  }
269
-
270
282
  &__buttons {
271
283
  margin-left: auto;
272
-
273
284
  button {
274
285
  width: 96px;
275
286
  padding: 0;
@@ -5,14 +5,14 @@
5
5
  :class="[ns.b(), ns.is('multiple', multiple)]"
6
6
  v-model="valueModel"
7
7
  collapse-tags
8
- v-bind="rawAttr"
8
+ v-bind="bindAttrs"
9
9
  :multiple="multiple"
10
10
  :filterable="filterable"
11
11
  :clear-icon="clearIcon"
12
12
  :suffix-icon="suffixIcon"
13
13
  :fit-input-width="fitInputWidth"
14
14
  :select-text="selectText"
15
- :popper-class="ns.e('popper')"
15
+ :popper-class="popperClass"
16
16
  @focus="showSearchPrefix"
17
17
  @blur="hideSearchPrefix"
18
18
  @click="focusSearchInput"
@@ -35,7 +35,7 @@
35
35
  </template>
36
36
  </el-input>
37
37
  </div>
38
- <div :class="[ns.e('select')]" v-if="!rawAttr.multipleLimit">
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,70 @@ 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
+ // 剔除已在组件内部显式处理的属性,避免 v-bind 覆盖或冲突
121
+ delete merged["popper-class"];
122
+ delete merged["popperClass"];
123
+
124
+ if (merged.onChange) {
125
+ const original = merged.onChange;
126
+ merged.onChange = (val) => {
127
+ let realVal = val;
128
+ if (Array.isArray(val)) {
129
+ realVal = val.map((v) => (v === EMPTY_VALUE ? "" : v));
130
+ } else {
131
+ if (realVal === EMPTY_VALUE) realVal = "";
132
+ }
133
+ original(realVal);
134
+ };
135
+ }
136
+ return merged;
137
+ });
138
+
107
139
  const showOptions = computed(() => {
108
- return optionsByApi.value.length ? optionsByApi.value : props.options;
140
+ const opts = optionsByApi.value.length ? optionsByApi.value : props.options;
141
+ return opts.map((item) => {
142
+ if (item.value === "") {
143
+ return { ...item, value: EMPTY_VALUE };
144
+ }
145
+ return item;
146
+ });
109
147
  });
110
148
  const valueModel = computed({
111
149
  get() {
112
- return props.modelValue || (props.multiple ? [] : props.modelValue);
150
+ const val = props.modelValue;
151
+ const hasEmptyOption = showOptions.value.some(
152
+ (item) => item.value === EMPTY_VALUE
153
+ );
154
+ if (props.multiple) {
155
+ if (Array.isArray(val)) {
156
+ return val.map((v) => {
157
+ if (v === "") {
158
+ return hasEmptyOption ? EMPTY_VALUE : "";
159
+ }
160
+ return v;
161
+ });
162
+ }
163
+ return [];
164
+ }
165
+ if (val === "") {
166
+ return hasEmptyOption ? EMPTY_VALUE : "";
167
+ }
168
+ return val ?? "";
113
169
  },
114
170
  set(newValue) {
115
- emit("update:modelValue", newValue);
171
+ let emitVal = newValue;
172
+ if (Array.isArray(emitVal)) {
173
+ emitVal = emitVal.map((v) => (v === EMPTY_VALUE ? "" : v));
174
+ } else {
175
+ if (emitVal === EMPTY_VALUE) emitVal = "";
176
+ }
177
+ emit("update:modelValue", emitVal);
116
178
  },
117
179
  });
118
180
  const keyword = ref("");
@@ -155,9 +217,9 @@ const selectText = computed(() => {
155
217
  result = selectObj.value.map((item) => item.label).join(cnt);
156
218
  }
157
219
  }
158
- nextTick(() => {
159
- selectRef.value.$refs.reference.input.value = result;
160
- });
220
+ // nextTick(() => {
221
+ // selectRef.value.$refs.reference.input.value = result;
222
+ // });
161
223
  return result;
162
224
  });
163
225
  const emptyText = computed(() => {
@@ -165,6 +227,14 @@ const emptyText = computed(() => {
165
227
  ? props.noMatchText || "暂无匹配数据"
166
228
  : props.noDataText || "暂无数据";
167
229
  });
230
+
231
+ const popperClass = computed(() => {
232
+ const defaultClass = ns.e("popper");
233
+ const merged = { ...attrs, ...props.rawAttr };
234
+ const userClass = merged["popper-class"] || merged["popperClass"] || "";
235
+ return `${defaultClass} ${userClass}`.trim();
236
+ });
237
+
168
238
  const getUseLabel = (label) => {
169
239
  return typeof label === "string" ? label : String(label);
170
240
  };
@@ -361,7 +431,21 @@ defineExpose({
361
431
  </script>
362
432
  <style lang="less">
363
433
  .ct-select {
364
- width: 214px;
434
+ &.el-select {
435
+ position: relative;
436
+ width: 214px;
437
+ &__selected-item {
438
+ &:nth-child(1) {
439
+ display: none;
440
+ }
441
+ &:nth-child(2) {
442
+ display: none;
443
+ }
444
+ &:nth-child(3) {
445
+ display: flex;
446
+ }
447
+ }
448
+ }
365
449
  &__top {
366
450
  padding: 0 16px;
367
451
  font-size: var(--ct-font-size);
@@ -410,7 +494,7 @@ defineExpose({
410
494
  z-index: 3;
411
495
  right: var(--ct-component-inner-padding);
412
496
  top: 50%;
413
- height: calc(var(--ct-component-size) - 2px);
497
+ height: calc(var(--ct-component-size) - 8px);
414
498
  transform: translateY(-50%);
415
499
  background-color: #fff;
416
500
  }
@@ -422,18 +506,25 @@ defineExpose({
422
506
  color: var(--ct-color-grey-sub);
423
507
  }
424
508
  &.is-multiple {
425
- // &::after {
426
- // content: attr(select-text);
427
- // position: absolute;
428
- // left: var(--ct-component-inner-padding);
429
- // right: calc(var(--ct-component-inner-padding) * 2);
430
- // top: 50%;
431
- // transform: translateY(-50%);
432
- // text-overflow: ellipsis;
433
- // overflow: hidden;
434
- // white-space: nowrap;
435
- // cursor: pointer;
436
- // }
509
+ &::after {
510
+ content: attr(select-text);
511
+ position: absolute;
512
+ left: var(--ct-component-inner-padding);
513
+ right: calc(var(--ct-component-inner-padding) * 2);
514
+ top: 50%;
515
+ transform: translateY(-50%);
516
+ text-overflow: ellipsis;
517
+ overflow: hidden;
518
+ white-space: nowrap;
519
+ cursor: pointer;
520
+ pointer-events: none;
521
+ }
522
+ .el-select__placeholder.is-transparent {
523
+ display: block;
524
+ }
525
+ .el-select__selected-item {
526
+ display: none;
527
+ }
437
528
  }
438
529
  }
439
530
  </style>
@@ -1,13 +1,13 @@
1
- import { buriedParamsKey, searchComponentProps } from '../../../hooks';
1
+ import { buriedParamsKey, searchComponentProps } from "../../../hooks";
2
2
 
3
3
  export const yearSelectEmits = [
4
4
  "update:modelValue",
5
5
  buriedParamsKey,
6
- 'change',
7
- 'change-select',
8
- 'visible-change',
9
- 'blur',
10
- 'focus'
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
+ };
@@ -135,9 +135,12 @@ const getYearList = () => {
135
135
  }
136
136
  yearList.value = yearArr;
137
137
  };
138
- watch(() => props.range, () => {
139
- getYearList();
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='less'>
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;
@@ -273,5 +276,15 @@ onMounted(() => {
273
276
  }
274
277
  }
275
278
  }
279
+ .el-select__wrapper {
280
+ padding: 1px 12px;
281
+ min-height: 30px;
282
+ box-shadow: var(--ct-year-select-select-inner-box-shadow);
283
+ &.is-focused,
284
+ &.is-hovering:not(.is-focused),
285
+ &.is-disabled {
286
+ box-shadow: var(--ct-year-select-select-inner-box-shadow);
287
+ }
288
+ }
276
289
  }
277
- </style>
290
+ </style>
@@ -93,7 +93,6 @@
93
93
  padding: 1px var(--ct-component-inner-padding);
94
94
 
95
95
  &:focus-within {
96
-
97
96
  .ct-icon,
98
97
  .el-icon {
99
98
  color: var(--ct-color-primary);
@@ -178,7 +177,6 @@
178
177
  .el-input {
179
178
  &.is-focus {
180
179
  .el-input__suffix {
181
-
182
180
  .el-icon,
183
181
  .ct-icon {
184
182
  color: var(--ct-select-focus-icon-color);
@@ -192,7 +190,6 @@
192
190
  .el-input {
193
191
  &.is-focus {
194
192
  .el-input__wrapper {
195
-
196
193
  .el-icon,
197
194
  .ct-icon {
198
195
  color: var(--ct-color-primary);
@@ -201,7 +198,8 @@
201
198
  }
202
199
  }
203
200
 
204
- &__dropdown {}
201
+ &__dropdown {
202
+ }
205
203
 
206
204
  &-menu {
207
205
  &__list {
@@ -210,7 +208,7 @@
210
208
  }
211
209
 
212
210
  &-panel {
213
- --el-cascader-menu-border: 1px solid #F0F3F9;
211
+ --el-cascader-menu-border: 1px solid #f0f3f9;
214
212
  }
215
213
 
216
214
  &-node {
@@ -245,8 +243,8 @@
245
243
  }
246
244
  }
247
245
 
248
- >.el-radio,
249
- >.el-checkbox {
246
+ > .el-radio,
247
+ > .el-checkbox {
250
248
  margin-left: 10px;
251
249
  margin-right: -2px;
252
250
  }
@@ -276,7 +274,6 @@
276
274
  &-date-editor {
277
275
  &.el-range-editor {
278
276
  &:not(.is-active):focus-within {
279
-
280
277
  .ct-icon,
281
278
  .el-icon {
282
279
  color: var(--el-input-icon-color);
@@ -285,7 +282,6 @@
285
282
  }
286
283
 
287
284
  &.is-active {
288
-
289
285
  .ct-icon,
290
286
  .el-icon {
291
287
  color: var(--ct-color-primary);
@@ -325,7 +321,7 @@
325
321
 
326
322
  &-date-picker {
327
323
  --el-datepicker-header-text-color: var(--ct-color-grey-transition);
328
- --ct-datepicker-border-color: #F0F3F9;
324
+ --ct-datepicker-border-color: #f0f3f9;
329
325
  width: 304px;
330
326
  @R: .el-picker-panel;
331
327
 
@@ -367,7 +363,7 @@
367
363
  td {
368
364
  padding: 9px;
369
365
 
370
- >div {
366
+ > div {
371
367
  height: 26px;
372
368
  padding: 0;
373
369
  }
@@ -397,8 +393,8 @@
397
393
  }
398
394
 
399
395
  &-date-range-picker {
400
- --ct-datepicker-border-color: #F0F3F9;
401
- --el-datepicker-inrange-bg-color: #F5F7FC;
396
+ --ct-datepicker-border-color: #f0f3f9;
397
+ --el-datepicker-inrange-bg-color: #f5f7fc;
402
398
  --el-datepicker-inner-border-color: var(--ct-datepicker-border-color);
403
399
  --el-datepicker-header-text-color: var(--ct-color-grey-transition);
404
400
  width: 608px;
@@ -444,7 +440,6 @@
444
440
  &:first-of-type {
445
441
  .el-date-table-cell {
446
442
  border-radius: 4px 0 0 4px;
447
-
448
443
  }
449
444
  }
450
445
 
@@ -568,7 +563,6 @@
568
563
  box-shadow: none;
569
564
  }
570
565
  }
571
-
572
566
  }
573
567
 
574
568
  &__jump {
@@ -588,11 +582,12 @@
588
582
  @R: .el-table;
589
583
  font-size: 15px;
590
584
  --el-table-header-text-color: var(--ct-font-color);
591
- --el-table-header-bg-color: #F0F3F9;
585
+ --el-table-header-bg-color: #f0f3f9;
592
586
  // --el-table-row-hover-bg-color: #F7F9FD;
593
- --el-table-row-hover-bg-color: #FAFAFC;
587
+ --el-table-row-hover-bg-color: #fafafc;
594
588
 
595
- .cell {}
589
+ .cell {
590
+ }
596
591
 
597
592
  & @{R}__cell {
598
593
  padding: 16px 0;
@@ -702,6 +697,12 @@
702
697
  right: 16px;
703
698
  color: var(--ct-border-color);
704
699
  }
700
+ // 消息关闭按钮位置展示
701
+ .el-icon.el-message__closeBtn {
702
+ position: absolute;
703
+ top: 50%;
704
+ transform: translateY(-50%);
705
+ }
705
706
  }
706
707
 
707
708
  &-message.ct-message--success {
@@ -723,4 +724,4 @@
723
724
  background-color: var(--ct-color-danger-bg);
724
725
  border: var(--ct-color-danger-border) 1px solid;
725
726
  }
726
- }
727
+ }