ct-component-plus 2.2.4 → 2.2.6

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.4",
4
+ "version": "2.2.6",
5
5
  "type": "module",
6
6
  "main": "packages/components/index.js",
7
7
  "files": [
@@ -15,8 +15,8 @@
15
15
  "docs:build": "vuepress build docs"
16
16
  },
17
17
  "dependencies": {
18
- "cingta-icon": "^2.1.6",
19
- "element-plus": "~2.4.4",
18
+ "cingta-icon": "^2.3.2",
19
+ "element-plus": "2.4.4",
20
20
  "vue": "^3.2.47"
21
21
  },
22
22
  "devDependencies": {
@@ -1,32 +1,33 @@
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 select from './select';
7
- import pagingSelect from './paging-select';
8
- import yearSelect from './year-select';
9
- import datePicker from './date-picker';
10
- import cascader from './cascader';
11
- import tabs from './tabs';
12
- import pagination from './pagination';
13
- import menu from './menu';
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 './search-box';
16
- import table from './table';
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 './message-box';
20
- import CtMessage from './message';
20
+ import messageBox from "./message-box";
21
+ import CtMessage from "./message";
21
22
 
22
- import CtLoading from './loading';
23
- import CtPage from './page';
23
+ import CtLoading from "./loading";
24
+ import CtPage from "./page";
24
25
 
25
- import ElementPlus from 'element-plus'
26
- import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
27
- import cingtaIcon from 'cingta-icon';
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 '../utils';
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: 'post'
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('当前使用的组件库没有配置baseDao')
70
+ console.warn("当前使用的组件库没有配置baseDao");
69
71
  } else {
70
- app.provide('$ctBaseDao', options.baseDao)
72
+ app.provide("$ctBaseDao", options.baseDao);
71
73
  }
72
- app.provide('$selectTooltip', selectTooltip)
73
- if (isObject(options.serviceOptions)) serviceOptions = options.serviceOptions;
74
- if (isObject(options.searchBoxComponent)) app.provide('$userDefinedSearchComponent', options.searchBoxComponent)
75
- if (isObject(tableEmptyDom)) app.provide('$tableEmptyDom', tableEmptyDom)
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('$ctServiceConfig', { ...serviceConfig, ...serviceOptions })
78
- }
81
+ app.provide("$ctServiceConfig", { ...serviceConfig, ...serviceOptions });
82
+ };
79
83
 
80
84
  export default {
81
- install
82
- }
83
- export { CtMessage }
84
- export * from 'element-plus'
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>
@@ -110,7 +110,7 @@ const props = defineProps(selectProps);
110
110
  const emit = defineEmits(selectEmits);
111
111
  const attrs = useAttrs();
112
112
 
113
- const ns = useNamespace("select");
113
+ const ns = useNamespace("paging-select");
114
114
  const optionsByApi = ref([]);
115
115
  const showOptions = computed(() => {
116
116
  return optionsByApi.value;
@@ -401,7 +401,7 @@ defineExpose({
401
401
  });
402
402
  </script>
403
403
  <style lang="less">
404
- .ct-select {
404
+ .ct-paging-select {
405
405
  width: 214px;
406
406
  &.el-select {
407
407
  position: relative;
@@ -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 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('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>
@@ -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 <= 4;
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
- searchComponents;
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((100% - v-bind(rowNumber) * var(--ct-search-box-item-margin-right)) / v-bind(rowNumber));
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
- --el-select-input-focus-border-color: var(--ct-search-box-inner-border-color);
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
- if (newArr[0] && newArr[1] && newArr[0] > newArr[1]) {
109
- newArr = [newValue[1], newValue[0]];
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(() => 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;
@@ -274,4 +277,4 @@ onMounted(() => {
274
277
  }
275
278
  }
276
279
  }
277
- </style>
280
+ </style>