@elementplus-kit/uikit 1.4.0 → 1.6.0
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/dist/index.css +1 -0
- package/dist/index.mjs +1079 -0
- package/dist/index.umd.js +1 -0
- package/package.json +14 -4
- package/aaaindex.ts +0 -55
- package/build.log +0 -0
- package/components/button/index.ts +0 -4
- package/components/button/src/constants.ts +0 -50
- package/components/button/src/index.ts +0 -264
- package/components/button/style/index.scss +0 -3
- package/components/config.ts +0 -4
- package/components/dialog/index.ts +0 -6
- package/components/dialog/src/constants.ts +0 -3
- package/components/dialog/src/index.ts +0 -54
- package/components/dialog/style/index.scss +0 -18
- package/components/dictLabel/index.ts +0 -4
- package/components/dictLabel/src/index.vue +0 -21
- package/components/drawer/index.ts +0 -4
- package/components/drawer/src/constants.ts +0 -3
- package/components/drawer/src/index.ts +0 -53
- package/components/drawer/style/index.scss +0 -18
- package/components/form/index.ts +0 -4
- package/components/form/src/FormItem.ts +0 -397
- package/components/form/src/constants.ts +0 -161
- package/components/form/src/index.ts +0 -207
- package/components/form/src/types.ts +0 -39
- package/components/form/src/utils.ts +0 -4
- package/components/form/style/index.scss +0 -5
- package/components/pagination/index.ts +0 -4
- package/components/pagination/src/constants.ts +0 -5
- package/components/pagination/src/index.ts +0 -50
- package/components/search/index.ts +0 -4
- package/components/search/src/index.tsx +0 -276
- package/components/search/style/index.scss +0 -101
- package/components/table/index.ts +0 -4
- package/components/table/src/TableColumn.ts +0 -116
- package/components/table/src/constants.ts +0 -42
- package/components/table/src/index.ts +0 -250
- package/components/table/src/index2.ts +0 -219
- package/components/table/src/index3.ts +0 -233
- package/components/table/src/tableDictLabel.vue +0 -21
- package/components/table/src/tableaa.ts +0 -71
- package/components/table/src/type.ts +0 -0
- package/components/table/type/index.scss +0 -0
- package/components/table2/index.ts +0 -4
- package/components/table2/src/config.ts +0 -5
- package/components/table2/src/index.ts +0 -12
- package/components/table2/src/render.ts +0 -136
- package/components/table2/src/types.ts +0 -39
- package/components/table2/style/index.scss +0 -0
- package/components//346/250/241/346/235/277/index.tsx +0 -57
- package/components//346/250/241/346/235/277/ttt.ts +0 -66
- package/components//346/250/241/346/235/277/ttt.vue +0 -18
- package/index.ts +0 -2
- package/vite.config.ts +0 -26
- package//345/205/266/344/273/226/core/dialog/elementPlus/dialogWarp.vue +0 -151
- package//345/205/266/344/273/226/core/dialog/index.ts +0 -10
- package//345/205/266/344/273/226/core/form/elementPlus/elementWarp.ts +0 -15
- package//345/205/266/344/273/226/core/form/elementPlus/elementWarp.vue +0 -16
- package//345/205/266/344/273/226/core/form/elementPlus/formRender.ts +0 -55
- package//345/205/266/344/273/226/core/form/index.ts +0 -10
- package//345/205/266/344/273/226/core/table/config.ts +0 -5
- package//345/205/266/344/273/226/core/table/render.ts +0 -91
- package//345/205/266/344/273/226/core/table/warp.ts +0 -11
- package//345/205/266/344/273/226/core/utils/fetch.ts +0 -58
- package//345/205/266/344/273/226/useMessage.ts +0 -95
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineComponent,
|
|
3
|
-
ref,
|
|
4
|
-
h,
|
|
5
|
-
computed,
|
|
6
|
-
toRefs,
|
|
7
|
-
getCurrentInstance,
|
|
8
|
-
provide,
|
|
9
|
-
type ExtractPropTypes,
|
|
10
|
-
type PropType,
|
|
11
|
-
} from "vue";
|
|
12
|
-
import { ElConfigProvider, ElForm, ElRow, ElCol } from "element-plus";
|
|
13
|
-
import zhCn from "element-plus/es/locale/lang/zh-cn";
|
|
14
|
-
import CFormItem from "./FormItem.ts";
|
|
15
|
-
import { has, isArray, isBoolean, isFunction, isNumber } from "lodash-es";
|
|
16
|
-
import { getEmits } from "./constants"; // 获取所有的事件
|
|
17
|
-
import "../style/index.scss";
|
|
18
|
-
const propsAttrs = {
|
|
19
|
-
// 表单数据
|
|
20
|
-
model: { type: Object, default: () => ({}) },
|
|
21
|
-
// 表单项
|
|
22
|
-
formOptions: { type: Array, default: () => [] },
|
|
23
|
-
// 只读
|
|
24
|
-
readonly: { type: Boolean, default: false },
|
|
25
|
-
// row 间距
|
|
26
|
-
gutter: {
|
|
27
|
-
// tode 类型错误警告
|
|
28
|
-
type: (Number as PropType<number>) || (String as PropType<string>),
|
|
29
|
-
default: undefined,
|
|
30
|
-
},
|
|
31
|
-
// row 列数
|
|
32
|
-
col: { type: Number, default: undefined },
|
|
33
|
-
// 额外业务全局参数
|
|
34
|
-
params: { type: Object, default: () => ({}) },
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export type PropsAttrs = ExtractPropTypes<typeof propsAttrs>;
|
|
38
|
-
|
|
39
|
-
export default defineComponent({
|
|
40
|
-
props: propsAttrs,
|
|
41
|
-
emits: [...getEmits()],
|
|
42
|
-
setup(props: PropsAttrs, { attrs: $attrs, emit, slots, expose }) {
|
|
43
|
-
provide("formContext", {
|
|
44
|
-
formSlots: slots,
|
|
45
|
-
events: (eProp, ...args: any) => {
|
|
46
|
-
// 按钮 reset 事件
|
|
47
|
-
// if (e == 'reset') {
|
|
48
|
-
// formRef.value?.resetFields()
|
|
49
|
-
// }
|
|
50
|
-
emit(eProp, ...args);
|
|
51
|
-
},
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
// 各个表单组件的 ref
|
|
55
|
-
const optionsRef = ref<any>({});
|
|
56
|
-
|
|
57
|
-
// 暴露方法
|
|
58
|
-
expose({
|
|
59
|
-
optionsRef,
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
// 解构props
|
|
63
|
-
const { model, formOptions, readonly, gutter, col } = toRefs(props);
|
|
64
|
-
|
|
65
|
-
// 暴露elForm组件上的方法
|
|
66
|
-
const vm = getCurrentInstance(); // 获取虚拟DOM实例
|
|
67
|
-
const cFormFnRef = (el) => {
|
|
68
|
-
if (!el) return;
|
|
69
|
-
vm.exposed = el; // 设置暴露对象
|
|
70
|
-
vm.exposeProxy = el; // 设置代理暴露对象
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
// 全部只读
|
|
74
|
-
const allReadonly = computed(() => readonly.value);
|
|
75
|
-
|
|
76
|
-
// 是否 row 布局 || ['', 0].includes(gutter.value)
|
|
77
|
-
const isLayout = computed(
|
|
78
|
-
() =>
|
|
79
|
-
["", 0].includes(gutter?.value) ||
|
|
80
|
-
col?.value ||
|
|
81
|
-
formOptions?.value.some((item) => has(item, "col"))
|
|
82
|
-
);
|
|
83
|
-
|
|
84
|
-
// 渲染 row
|
|
85
|
-
const renderRow = () => {
|
|
86
|
-
const formItemVdom = renderFormItem();
|
|
87
|
-
if (isLayout.value) {
|
|
88
|
-
return h(
|
|
89
|
-
ElRow,
|
|
90
|
-
{
|
|
91
|
-
class: "c-row",
|
|
92
|
-
// gutter: gutter.value === 0 || gutter.value ? gutter.value : 10,
|
|
93
|
-
gutter: gutter.value || 20,
|
|
94
|
-
...$attrs,
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
default: () => formItemVdom,
|
|
98
|
-
}
|
|
99
|
-
);
|
|
100
|
-
} else {
|
|
101
|
-
return formItemVdom;
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
// 合并 formData 和 params
|
|
105
|
-
const mergeParams = computed(() => {
|
|
106
|
-
return { formData: model.value, params: props.params };
|
|
107
|
-
});
|
|
108
|
-
// 渲染表单项
|
|
109
|
-
const renderFormItem = () => {
|
|
110
|
-
// 过滤权限
|
|
111
|
-
const list = [];
|
|
112
|
-
|
|
113
|
-
formOptions.value.map((item) => {
|
|
114
|
-
// 处理 vIf true 显示 false 隐藏
|
|
115
|
-
if (
|
|
116
|
-
isFunction(item?.vIf) &&
|
|
117
|
-
item.vIf(mergeParams.value) !== undefined
|
|
118
|
-
) {
|
|
119
|
-
if (item.vIf(mergeParams.value)) {
|
|
120
|
-
list.push(item);
|
|
121
|
-
}
|
|
122
|
-
} else {
|
|
123
|
-
list.push(item);
|
|
124
|
-
}
|
|
125
|
-
});
|
|
126
|
-
return list.map((item) => {
|
|
127
|
-
// const { label, prop, type, required, col, formItem, attrs } = item
|
|
128
|
-
// const { label, prop, type, required, col, formItem, attrs, ...args } = item
|
|
129
|
-
const rFormItem = () => {
|
|
130
|
-
return h(CFormItem, {
|
|
131
|
-
class: "c-form-itme",
|
|
132
|
-
model: model.value,
|
|
133
|
-
allReadonly,
|
|
134
|
-
mergeParams: mergeParams.value,
|
|
135
|
-
...item,
|
|
136
|
-
optionsRef: optionsRef.value,
|
|
137
|
-
});
|
|
138
|
-
};
|
|
139
|
-
if (isLayout.value) {
|
|
140
|
-
// 是否有 col 插槽
|
|
141
|
-
let colSlot = undefined;
|
|
142
|
-
let colSlotName = `col.${item.prop}`;
|
|
143
|
-
// 手动开启 col 插槽
|
|
144
|
-
if (item?.colSlot) {
|
|
145
|
-
if (has(slots, colSlotName)) {
|
|
146
|
-
colSlot = slots[colSlotName];
|
|
147
|
-
} else {
|
|
148
|
-
colSlot = () => "col插槽模板未定义";
|
|
149
|
-
}
|
|
150
|
-
} else {
|
|
151
|
-
// 自动开启 col 插槽
|
|
152
|
-
if (has(slots, colSlotName)) {
|
|
153
|
-
colSlot = slots[colSlotName];
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return h(
|
|
158
|
-
ElCol,
|
|
159
|
-
{
|
|
160
|
-
class: "c-col",
|
|
161
|
-
span: has(item, "col")
|
|
162
|
-
? item.col
|
|
163
|
-
: col?.value
|
|
164
|
-
? col?.value
|
|
165
|
-
: isLayout.value
|
|
166
|
-
? 8
|
|
167
|
-
: undefined,
|
|
168
|
-
},
|
|
169
|
-
{
|
|
170
|
-
default: () => (colSlot ? colSlot() : rFormItem()),
|
|
171
|
-
}
|
|
172
|
-
);
|
|
173
|
-
} else {
|
|
174
|
-
return rFormItem();
|
|
175
|
-
}
|
|
176
|
-
});
|
|
177
|
-
};
|
|
178
|
-
|
|
179
|
-
// 渲染表单
|
|
180
|
-
const renderForm = () => {
|
|
181
|
-
return h(
|
|
182
|
-
ElConfigProvider,
|
|
183
|
-
{
|
|
184
|
-
locale: zhCn,
|
|
185
|
-
},
|
|
186
|
-
{
|
|
187
|
-
default: () =>
|
|
188
|
-
h(
|
|
189
|
-
ElForm,
|
|
190
|
-
{
|
|
191
|
-
ref: cFormFnRef,
|
|
192
|
-
...$attrs,
|
|
193
|
-
model: model.value,
|
|
194
|
-
class: allReadonly.value ? "isReadonly c-form" : "c-form", // 放在 $attrs 后面可自动合并 放在 $attrs 前面会被 $attrs.class 覆盖, h函数渲染的是标签就会覆盖 是组件就会合并不用管顺序
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
default: () => renderRow(),
|
|
198
|
-
}
|
|
199
|
-
),
|
|
200
|
-
}
|
|
201
|
-
);
|
|
202
|
-
};
|
|
203
|
-
|
|
204
|
-
// 返回渲染函数
|
|
205
|
-
return () => renderForm();
|
|
206
|
-
},
|
|
207
|
-
});
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export interface FormItemListItem {
|
|
2
|
-
type: string
|
|
3
|
-
label?: string
|
|
4
|
-
prop: string
|
|
5
|
-
required?: Boolean
|
|
6
|
-
vIf?: boolean | ((item: FormItemListItem) => boolean)
|
|
7
|
-
dictType?: string
|
|
8
|
-
options?: Array<Object>
|
|
9
|
-
col?: Number
|
|
10
|
-
formItem?: Object
|
|
11
|
-
attrs?: Object
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface FormItemList {
|
|
15
|
-
module: Object
|
|
16
|
-
formOpsions: FormItemListItem[]
|
|
17
|
-
readonly: boolean
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export type formType =
|
|
21
|
-
| 'input'
|
|
22
|
-
| 'textarea'
|
|
23
|
-
| 'input-number'
|
|
24
|
-
| 'select'
|
|
25
|
-
| 'select-v2'
|
|
26
|
-
| 'cascader'
|
|
27
|
-
| 'tree-select'
|
|
28
|
-
| 'radio'
|
|
29
|
-
| 'checkbox'
|
|
30
|
-
| 'time-select'
|
|
31
|
-
| 'date-picker'
|
|
32
|
-
| 'time-picker'
|
|
33
|
-
| 'rate'
|
|
34
|
-
| 'color-picker'
|
|
35
|
-
| 'slider'
|
|
36
|
-
| 'switch'
|
|
37
|
-
| 'text'
|
|
38
|
-
| 'html'
|
|
39
|
-
| 'slot'
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineComponent,
|
|
3
|
-
ref,
|
|
4
|
-
h,
|
|
5
|
-
computed,
|
|
6
|
-
toRefs,
|
|
7
|
-
type ExtractPropTypes,
|
|
8
|
-
} from "vue";
|
|
9
|
-
import { ElPagination } from "element-plus";
|
|
10
|
-
import { get, has, isArray, isBoolean, isFunction, isNumber } from "lodash-es";
|
|
11
|
-
import { defaultAttrs } from "./constants.ts";
|
|
12
|
-
|
|
13
|
-
const propsAttrs = {};
|
|
14
|
-
|
|
15
|
-
export type PropsAttrs = ExtractPropTypes<typeof propsAttrs>;
|
|
16
|
-
|
|
17
|
-
export default defineComponent({
|
|
18
|
-
// props: propsAttrs,
|
|
19
|
-
// emits: eventList,
|
|
20
|
-
|
|
21
|
-
// attrs, emit会继承, slots需要设置
|
|
22
|
-
setup(props: PropsAttrs, { attrs, emit, slots, expose }) {
|
|
23
|
-
// const pageRef = ref();
|
|
24
|
-
|
|
25
|
-
// 暴露方法
|
|
26
|
-
// expose({
|
|
27
|
-
// pageRef,
|
|
28
|
-
// });
|
|
29
|
-
|
|
30
|
-
// 属性处理
|
|
31
|
-
const getAttrs = () => {
|
|
32
|
-
const obj = {
|
|
33
|
-
...defaultAttrs, // 设置默认值
|
|
34
|
-
// ...attrs, // 当前传入覆盖默认值 第一层标签就是组件可以不用传入
|
|
35
|
-
};
|
|
36
|
-
return obj;
|
|
37
|
-
};
|
|
38
|
-
// 渲染表单
|
|
39
|
-
const render = () => {
|
|
40
|
-
return h(ElPagination, {
|
|
41
|
-
// ref: pageRef,
|
|
42
|
-
...getAttrs(),
|
|
43
|
-
class: "c-pagination",
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
// 返回渲染函数
|
|
48
|
-
return () => render();
|
|
49
|
-
},
|
|
50
|
-
});
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
import { ref, defineComponent, onMounted, onUnmounted, nextTick } from "vue";
|
|
2
|
-
|
|
3
|
-
import { CForm, CDrawer } from "@elementplus-kit/uikit";
|
|
4
|
-
import { ArrowUpBold } from "@element-plus/icons-vue";
|
|
5
|
-
import "../style/index.scss";
|
|
6
|
-
|
|
7
|
-
export default defineComponent({
|
|
8
|
-
props: {
|
|
9
|
-
modelValue: {
|
|
10
|
-
type: Object,
|
|
11
|
-
default: {},
|
|
12
|
-
},
|
|
13
|
-
formOptions: {
|
|
14
|
-
type: Array,
|
|
15
|
-
default: () => [],
|
|
16
|
-
},
|
|
17
|
-
isDrawer: {
|
|
18
|
-
type: Boolean,
|
|
19
|
-
default: false,
|
|
20
|
-
},
|
|
21
|
-
},
|
|
22
|
-
emits: ["update:modelValue", "search", "reset", "close"],
|
|
23
|
-
|
|
24
|
-
setup(props, { emit, slots, attrs, expose }) {
|
|
25
|
-
// 自己的 slot
|
|
26
|
-
const slotsList = ["active", "btn-left", "btn-right"];
|
|
27
|
-
// 解析 attrs 中的事件
|
|
28
|
-
const getEvent = () => {
|
|
29
|
-
let formObj: any = {};
|
|
30
|
-
Object.keys(attrs)?.forEach((name) => {
|
|
31
|
-
if (name.indexOf("on") === 0) {
|
|
32
|
-
formObj[name] = attrs[name];
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
return formObj;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// 解析插槽
|
|
39
|
-
const getSlot = () => {
|
|
40
|
-
let formObj = {};
|
|
41
|
-
Object.keys(slots).forEach((key) => {
|
|
42
|
-
if (!slotsList.includes(key)) {
|
|
43
|
-
formObj[key] = slots[key];
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
return formObj;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// 搜索
|
|
50
|
-
const handleSearch = () => {
|
|
51
|
-
emit("search");
|
|
52
|
-
showSearchForm.value = false;
|
|
53
|
-
document.removeEventListener("click", handleClickOutside); // 销毁点击事件
|
|
54
|
-
};
|
|
55
|
-
// 重置
|
|
56
|
-
const handleReset = () => {
|
|
57
|
-
emit("reset");
|
|
58
|
-
};
|
|
59
|
-
// 关闭
|
|
60
|
-
const handleClose = () => {
|
|
61
|
-
showSearchForm.value = false;
|
|
62
|
-
document.removeEventListener("click", handleClickOutside); // 销毁点击事件
|
|
63
|
-
emit("close");
|
|
64
|
-
};
|
|
65
|
-
// 点击元素外关闭
|
|
66
|
-
const dropdownRef = ref<HTMLElement | null>(null); // 下拉表单的 ref
|
|
67
|
-
// 判断点击事件是否在 targetElement 外部
|
|
68
|
-
const isClickOutside = (event, targetElement) => {
|
|
69
|
-
console.log("🚀 ~ isClickOutside ~ targetElement:", targetElement);
|
|
70
|
-
return !targetElement.contains(event.target);
|
|
71
|
-
};
|
|
72
|
-
// 点击外部关闭函数
|
|
73
|
-
const handleClickOutside = (event: MouseEvent) => {
|
|
74
|
-
// 如果下拉表单可见,且点击事件不在下拉表单内部
|
|
75
|
-
if (
|
|
76
|
-
showSearchForm.value &&
|
|
77
|
-
dropdownRef.value &&
|
|
78
|
-
!dropdownRef.value?.$el?.contains(event.target)
|
|
79
|
-
) {
|
|
80
|
-
showSearchForm.value = false; // 关闭下拉表单
|
|
81
|
-
document.removeEventListener("click", handleClickOutside); // 销毁点击事件
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
// 显示隐藏折叠搜索表单
|
|
85
|
-
const showSearchForm = ref(false);
|
|
86
|
-
const handleShow = () => {
|
|
87
|
-
if (showSearchForm.value) {
|
|
88
|
-
showSearchForm.value = false;
|
|
89
|
-
document.removeEventListener("click", handleClickOutside); // 销毁点击事件
|
|
90
|
-
} else {
|
|
91
|
-
showSearchForm.value = true;
|
|
92
|
-
setTimeout(() => {
|
|
93
|
-
document.addEventListener("click", handleClickOutside); // 注册点击事件
|
|
94
|
-
}, 0);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
const showCount = ref(6); // 显示个数
|
|
99
|
-
const simpleRef = ref<HTMLDivElement>(null);
|
|
100
|
-
const simpleFormRef = ref<HTMLDivElement>(null);
|
|
101
|
-
const simpleBtnRef = ref<HTMLDivElement>(null);
|
|
102
|
-
const cFormRef = ref<HTMLDivElement>(null);
|
|
103
|
-
const calcFlg = ref(false); // 计算宽度后再显示表单
|
|
104
|
-
const childW = ref([]);
|
|
105
|
-
|
|
106
|
-
// 设置节流
|
|
107
|
-
let timer: any = null;
|
|
108
|
-
const searchResize = () => {
|
|
109
|
-
if (timer) {
|
|
110
|
-
clearTimeout(timer);
|
|
111
|
-
}
|
|
112
|
-
timer = setTimeout(() => {
|
|
113
|
-
calcSunResize();
|
|
114
|
-
}, 200);
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
// 初次计算显示个数
|
|
118
|
-
const calcSunInit = () => {
|
|
119
|
-
if (simpleFormRef.value) {
|
|
120
|
-
// 寻找cForm 先写死 后期做成动态寻找
|
|
121
|
-
const cFormDom = simpleFormRef.value.children[0];
|
|
122
|
-
const cFormW = cFormDom.offsetWidth;
|
|
123
|
-
// 收集子元素宽度并保存到数组中
|
|
124
|
-
const cW = [];
|
|
125
|
-
// const marginR = [];
|
|
126
|
-
Array.from(cFormDom.children).map((child) => {
|
|
127
|
-
const computedStyles = window.getComputedStyle(child); // 获取元素 css 样式
|
|
128
|
-
const mg = computedStyles.marginRight; // 获取元素 margin-right 样式值 有单位
|
|
129
|
-
const mgValue = parseFloat(mg); // 转换为数值
|
|
130
|
-
// marginR.push(mgValue);
|
|
131
|
-
cW.push(child.offsetWidth + mgValue); // 把mg加上 mg 一般不会变 为了避免多次计算
|
|
132
|
-
});
|
|
133
|
-
childW.value = cW; // 储存子元素宽度
|
|
134
|
-
childW.value.reduce((pre, cur, index) => {
|
|
135
|
-
if (pre > cFormW) {
|
|
136
|
-
return 10000; // 终止累加
|
|
137
|
-
}
|
|
138
|
-
if (pre + cur > cFormW) {
|
|
139
|
-
showCount.value = index;
|
|
140
|
-
return pre + cur;
|
|
141
|
-
}
|
|
142
|
-
return pre + cur;
|
|
143
|
-
}, 0);
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
// 变化时计算显示个数
|
|
147
|
-
const calcSunResize = () => {
|
|
148
|
-
if (simpleFormRef.value) {
|
|
149
|
-
// 寻找cForm 先写死 后期做成动态寻找
|
|
150
|
-
const cFormDom = simpleFormRef.value.children[0];
|
|
151
|
-
const cFormW = cFormDom.offsetWidth;
|
|
152
|
-
childW.value.reduce((pre, cur, index) => {
|
|
153
|
-
if (pre > cFormW) {
|
|
154
|
-
return 10000; // 终止累加
|
|
155
|
-
}
|
|
156
|
-
if (pre + cur > cFormW) {
|
|
157
|
-
showCount.value = index;
|
|
158
|
-
return pre + cur;
|
|
159
|
-
}
|
|
160
|
-
return pre + cur;
|
|
161
|
-
}, 0);
|
|
162
|
-
}
|
|
163
|
-
};
|
|
164
|
-
|
|
165
|
-
onMounted(() => {
|
|
166
|
-
// 初始化执行一次
|
|
167
|
-
calcSunInit();
|
|
168
|
-
// 注册页面大小函数
|
|
169
|
-
window.addEventListener("resize", searchResize);
|
|
170
|
-
});
|
|
171
|
-
// 销毁
|
|
172
|
-
onUnmounted(() => {
|
|
173
|
-
window.removeEventListener("resize", searchResize);
|
|
174
|
-
document.removeEventListener("click", handleClickOutside); // 销毁点击事件
|
|
175
|
-
});
|
|
176
|
-
return () => {
|
|
177
|
-
return (
|
|
178
|
-
<div className="c-search">
|
|
179
|
-
<div
|
|
180
|
-
className="c-search-simple"
|
|
181
|
-
ref={simpleRef}
|
|
182
|
-
>
|
|
183
|
-
<div className="c-search-simple-form" ref={simpleFormRef}>
|
|
184
|
-
<CForm
|
|
185
|
-
ref={(el) => (cFormRef.value = el)}
|
|
186
|
-
{...getEvent()}
|
|
187
|
-
inline
|
|
188
|
-
model={props.modelValue}
|
|
189
|
-
formOptions={props.formOptions?.filter(
|
|
190
|
-
(item, index) => index < showCount.value
|
|
191
|
-
)}
|
|
192
|
-
>
|
|
193
|
-
{getSlot()}
|
|
194
|
-
</CForm>
|
|
195
|
-
</div>
|
|
196
|
-
<div className="c-search-simple-btn" ref={simpleBtnRef}>
|
|
197
|
-
{slots["btn-left"]?.()}
|
|
198
|
-
{showCount.value < props.formOptions?.length && (
|
|
199
|
-
<div
|
|
200
|
-
className={`c-search-simple-icon ${showSearchForm.value ? "icon-rotate" : ""
|
|
201
|
-
}`}
|
|
202
|
-
onClick={handleShow}
|
|
203
|
-
>
|
|
204
|
-
<el-icon className="el-icon c-search-icon">
|
|
205
|
-
<ArrowUpBold />
|
|
206
|
-
</el-icon>
|
|
207
|
-
</div>
|
|
208
|
-
)}
|
|
209
|
-
<el-button type="primary" onClick={handleSearch}>
|
|
210
|
-
搜索
|
|
211
|
-
</el-button>
|
|
212
|
-
<el-button type="primary" onClick={handleReset}>
|
|
213
|
-
重置
|
|
214
|
-
</el-button>
|
|
215
|
-
{slots["btn-right"]?.()}
|
|
216
|
-
</div>
|
|
217
|
-
</div>
|
|
218
|
-
|
|
219
|
-
{/* 下拉悬浮 */}
|
|
220
|
-
{!props.isDrawer && showSearchForm.value && (
|
|
221
|
-
<transition name="search-form-transition">
|
|
222
|
-
<el-card
|
|
223
|
-
ref={dropdownRef}
|
|
224
|
-
className="c-search-form el-card is-always-shadow"
|
|
225
|
-
>
|
|
226
|
-
<CForm
|
|
227
|
-
{...getEvent()}
|
|
228
|
-
inline
|
|
229
|
-
model={props.modelValue}
|
|
230
|
-
formOptions={props.formOptions.filter(
|
|
231
|
-
(item, index) => index >= showCount.value
|
|
232
|
-
)}
|
|
233
|
-
ref="formRef"
|
|
234
|
-
>
|
|
235
|
-
{getSlot()}
|
|
236
|
-
</CForm>
|
|
237
|
-
<div style="text-align: right;">
|
|
238
|
-
<el-button type="primary" onClick={handleSearch}>
|
|
239
|
-
搜索
|
|
240
|
-
</el-button>
|
|
241
|
-
<el-button type="primary" onClick={handleClose}>
|
|
242
|
-
关闭
|
|
243
|
-
</el-button>
|
|
244
|
-
</div>
|
|
245
|
-
</el-card>
|
|
246
|
-
</transition>
|
|
247
|
-
)}
|
|
248
|
-
|
|
249
|
-
{props.isDrawer && (
|
|
250
|
-
<CDrawer title="搜索" v-model={showSearchForm.value} size="660px">
|
|
251
|
-
<CForm
|
|
252
|
-
{...getEvent()}
|
|
253
|
-
col={12}
|
|
254
|
-
model={props.modelValue}
|
|
255
|
-
formOptions={props.formOptions.filter(
|
|
256
|
-
(item, index) => index >= showCount.value
|
|
257
|
-
)}
|
|
258
|
-
ref="formRef"
|
|
259
|
-
>
|
|
260
|
-
{getSlot()}
|
|
261
|
-
</CForm>
|
|
262
|
-
<div style="text-align: right;">
|
|
263
|
-
<el-button type="primary" onClick={handleSearch}>
|
|
264
|
-
搜索
|
|
265
|
-
</el-button>
|
|
266
|
-
<el-button type="primary" onClick={handleClose}>
|
|
267
|
-
关闭
|
|
268
|
-
</el-button>
|
|
269
|
-
</div>
|
|
270
|
-
</CDrawer>
|
|
271
|
-
)}
|
|
272
|
-
</div>
|
|
273
|
-
);
|
|
274
|
-
};
|
|
275
|
-
},
|
|
276
|
-
});
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
.search-btn {
|
|
2
|
-
margin-right: 20px;
|
|
3
|
-
margin-left: auto;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.c-search {
|
|
7
|
-
position: relative;
|
|
8
|
-
height: 50px;
|
|
9
|
-
|
|
10
|
-
.c-search-simple {
|
|
11
|
-
display: flex;
|
|
12
|
-
justify-content: space-between;
|
|
13
|
-
}
|
|
14
|
-
.c-search-simple-form {
|
|
15
|
-
flex: 1; // 占满剩余空间
|
|
16
|
-
overflow: auto; // 开启滚动条
|
|
17
|
-
// 滚动条宽度
|
|
18
|
-
scrollbar-width: none; // 隐藏滚动条
|
|
19
|
-
> .c-form {
|
|
20
|
-
white-space: nowrap; // 防止表单内容换行
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
.c-search-simple-btn {
|
|
24
|
-
display: flex;
|
|
25
|
-
margin-left: auto;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.c-search-simple-icon {
|
|
29
|
-
display: flex;
|
|
30
|
-
justify-content: center;
|
|
31
|
-
align-items: center;
|
|
32
|
-
cursor: pointer;
|
|
33
|
-
height: 32px;
|
|
34
|
-
width: 32px;
|
|
35
|
-
margin-right: 10px;
|
|
36
|
-
border-radius: 4px;
|
|
37
|
-
background-color: #409eff;
|
|
38
|
-
transition: all 0.2s;
|
|
39
|
-
|
|
40
|
-
&:hover {
|
|
41
|
-
background-color: rgb(121, 187, 255);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
&:active {
|
|
45
|
-
background-color: rgb(51, 126, 204);
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
.c-search-icon {
|
|
50
|
-
// 添加鼠标悬停效果
|
|
51
|
-
color: #fff;
|
|
52
|
-
transition: all 0.2s;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.icon-rotate {
|
|
56
|
-
background-color: rgb(51, 126, 204);
|
|
57
|
-
.c-search-icon {
|
|
58
|
-
transform: rotate(180deg);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
.c-search-form {
|
|
63
|
-
width: 100%;
|
|
64
|
-
position: absolute;
|
|
65
|
-
top: 50px;
|
|
66
|
-
left: 0;
|
|
67
|
-
overflow: hidden;
|
|
68
|
-
z-index: 10;
|
|
69
|
-
background-color: #fff;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/* 下拉动画效果 */
|
|
74
|
-
.search-form-transition {
|
|
75
|
-
&-enter-active,
|
|
76
|
-
&-leave-active {
|
|
77
|
-
transition: all 0.3s ease;
|
|
78
|
-
/* 动画过渡时间和缓动函数 */
|
|
79
|
-
overflow: hidden;
|
|
80
|
-
max-height: 500px;
|
|
81
|
-
/* 确保足够大的最大高度以容纳内容 */
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
&-enter-from {
|
|
85
|
-
max-height: 0;
|
|
86
|
-
/* 入场开始时高度为0 */
|
|
87
|
-
opacity: 0;
|
|
88
|
-
/* 可以添加透明度效果增强视觉体验 */
|
|
89
|
-
padding-top: 0;
|
|
90
|
-
padding-bottom: 0;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
&-leave-to {
|
|
94
|
-
max-height: 0;
|
|
95
|
-
/* 出场结束时高度为0 */
|
|
96
|
-
opacity: 0;
|
|
97
|
-
/* 可以添加透明度效果增强视觉体验 */
|
|
98
|
-
padding-top: 0;
|
|
99
|
-
padding-bottom: 0;
|
|
100
|
-
}
|
|
101
|
-
}
|