@vrojs/element-plus 0.0.1 → 0.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 +3 -3
- package/src/index.ts +5 -0
- package/src/locale/lang/zh-cn.ts +24 -0
- package/src/style/deps.ts +5 -0
- package/src/style/index.scss +5 -0
- package/src/vro-el-config-provider/types.ts +1 -1
- package/src/vro-el-radio-group/README.md +83 -0
- package/src/vro-el-radio-group/index.ts +16 -0
- package/src/vro-el-radio-group/style/css.ts +2 -0
- package/src/vro-el-radio-group/style/deps.ts +2 -0
- package/src/vro-el-radio-group/style/index.scss +1 -0
- package/src/vro-el-radio-group/style/index.ts +2 -0
- package/src/vro-el-radio-group/types.ts +29 -0
- package/src/vro-el-radio-group/vro-el-radio-group.vue +34 -0
- package/src/vro-el-schema-filter/README.md +146 -0
- package/src/vro-el-schema-filter/index.ts +16 -0
- package/src/vro-el-schema-filter/style/css.ts +3 -0
- package/src/vro-el-schema-filter/style/deps.ts +4 -0
- package/src/vro-el-schema-filter/style/index.scss +20 -0
- package/src/vro-el-schema-filter/style/index.ts +2 -0
- package/src/vro-el-schema-filter/types.ts +31 -0
- package/src/vro-el-schema-filter/vro-el-schema-filter.vue +64 -0
- package/src/vro-el-schema-form/README.md +207 -0
- package/src/vro-el-schema-form/defineVroElSchemaFormCreateField.ts +12 -0
- package/src/vro-el-schema-form/defineVroElSchemaFormFieldTrigger.ts +9 -0
- package/src/vro-el-schema-form/index.ts +20 -0
- package/src/vro-el-schema-form/style/css.ts +9 -0
- package/src/vro-el-schema-form/style/deps.ts +20 -0
- package/src/vro-el-schema-form/style/index.scss +4 -0
- package/src/vro-el-schema-form/style/index.ts +2 -0
- package/src/vro-el-schema-form/types.ts +171 -0
- package/src/vro-el-schema-form/useVroElSchemaForm.ts +48 -0
- package/src/vro-el-schema-form/vro-el-schema-form.vue +177 -0
- package/src/vro-el-schema-form/vroElSchemaFormFieldManager.ts +59 -0
- package/src/vro-el-schema-form-dialog/README.md +114 -5
- package/src/vro-el-schema-form-dialog/function-call.ts +11 -3
- package/src/vro-el-schema-form-dialog/index.ts +6 -1
- package/src/vro-el-schema-form-dialog/injection.ts +10 -0
- package/src/vro-el-schema-form-dialog/style/css.ts +2 -0
- package/src/vro-el-schema-form-dialog/style/deps.ts +4 -0
- package/src/vro-el-schema-form-dialog/style/index.scss +4 -1
- package/src/vro-el-schema-form-dialog/types.ts +70 -2
- package/src/vro-el-schema-form-dialog/useVroElSchemaFormDialog.ts +52 -0
- package/src/vro-el-schema-form-dialog/vro-el-schema-form-dialog.vue +119 -9
- package/src/vro-el-tags/README.md +73 -0
- package/src/vro-el-tags/index.ts +16 -0
- package/src/vro-el-tags/style/css.ts +2 -0
- package/src/vro-el-tags/style/deps.ts +3 -0
- package/src/vro-el-tags/style/index.scss +1 -0
- package/src/vro-el-tags/style/index.ts +2 -0
- package/src/vro-el-tags/types.ts +21 -0
- package/src/vro-el-tags/vro-el-tags.vue +69 -0
- package/src/vro-el-tree/README.md +85 -0
- package/src/vro-el-tree/index.ts +16 -0
- package/src/vro-el-tree/style/css.ts +2 -0
- package/src/vro-el-tree/style/deps.ts +1 -0
- package/src/vro-el-tree/style/index.scss +3 -0
- package/src/vro-el-tree/style/index.ts +2 -0
- package/src/vro-el-tree/types.ts +38 -0
- package/src/vro-el-tree/vro-el-tree.vue +78 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vrojs/element-plus",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "vrojs ui",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"rimraf": "^6.0.1",
|
|
47
47
|
"typescript": "^5.9.3",
|
|
48
48
|
"vue": "^3.5.22",
|
|
49
|
-
"@vrojs/
|
|
50
|
-
"@vrojs/
|
|
49
|
+
"@vrojs/base": "0.0.1",
|
|
50
|
+
"@vrojs/use": "0.0.1"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"release": "dsc publish --pnpm",
|
package/src/index.ts
CHANGED
|
@@ -7,7 +7,12 @@ export * from './vro-el-config-provider'
|
|
|
7
7
|
export * from './vro-el-file-upload'
|
|
8
8
|
export * from './vro-el-icon'
|
|
9
9
|
export * from './vro-el-image-upload'
|
|
10
|
+
export * from './vro-el-radio-group'
|
|
11
|
+
export * from './vro-el-schema-filter'
|
|
12
|
+
export * from './vro-el-schema-form'
|
|
10
13
|
export * from './vro-el-schema-form-dialog'
|
|
11
14
|
export * from './vro-el-select'
|
|
12
15
|
export * from './vro-el-skeleton'
|
|
16
|
+
export * from './vro-el-tags'
|
|
17
|
+
export * from './vro-el-tree'
|
|
13
18
|
export * from './vro-el-with-config'
|
package/src/locale/lang/zh-cn.ts
CHANGED
|
@@ -18,5 +18,29 @@ export default {
|
|
|
18
18
|
imageUpload: {
|
|
19
19
|
compressText: '是否压缩',
|
|
20
20
|
},
|
|
21
|
+
tags: {
|
|
22
|
+
addText: '新增',
|
|
23
|
+
},
|
|
24
|
+
schemaForm: {
|
|
25
|
+
ElInput: {
|
|
26
|
+
placeholder: '请填写',
|
|
27
|
+
},
|
|
28
|
+
ElSelect: {
|
|
29
|
+
placeholder: '请选择',
|
|
30
|
+
},
|
|
31
|
+
ElDatePicker: {
|
|
32
|
+
placeholder: '请选择',
|
|
33
|
+
startPlaceholder: '请选择',
|
|
34
|
+
endPlaceholder: '请选择',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
schemaFilter: {
|
|
38
|
+
searchText: '搜索',
|
|
39
|
+
resetText: '重置',
|
|
40
|
+
},
|
|
41
|
+
schemaFormDialog: {
|
|
42
|
+
cancelText: '取消',
|
|
43
|
+
confirmText: '确认',
|
|
44
|
+
},
|
|
21
45
|
},
|
|
22
46
|
}
|
package/src/style/deps.ts
CHANGED
|
@@ -3,7 +3,12 @@ import '../vro-el-config-provider/style/deps'
|
|
|
3
3
|
import '../vro-el-file-upload/style/deps'
|
|
4
4
|
import '../vro-el-icon/style/deps'
|
|
5
5
|
import '../vro-el-image-upload/style/deps'
|
|
6
|
+
import '../vro-el-radio-group/style/deps'
|
|
7
|
+
import '../vro-el-schema-filter/style/deps'
|
|
8
|
+
import '../vro-el-schema-form/style/deps'
|
|
6
9
|
import '../vro-el-schema-form-dialog/style/deps'
|
|
7
10
|
import '../vro-el-select/style/deps'
|
|
8
11
|
import '../vro-el-skeleton/style/deps'
|
|
12
|
+
import '../vro-el-tags/style/deps'
|
|
13
|
+
import '../vro-el-tree/style/deps'
|
|
9
14
|
import '../vro-el-with-config/style/deps'
|
package/src/style/index.scss
CHANGED
|
@@ -6,7 +6,12 @@
|
|
|
6
6
|
@use '../vro-el-file-upload/style/index.scss' as *;
|
|
7
7
|
@use '../vro-el-icon/style/index.scss' as *;
|
|
8
8
|
@use '../vro-el-image-upload/style/index.scss' as *;
|
|
9
|
+
@use '../vro-el-radio-group/style/index.scss' as *;
|
|
10
|
+
@use '../vro-el-schema-filter/style/index.scss' as *;
|
|
11
|
+
@use '../vro-el-schema-form/style/index.scss' as *;
|
|
9
12
|
@use '../vro-el-schema-form-dialog/style/index.scss' as *;
|
|
10
13
|
@use '../vro-el-select/style/index.scss' as *;
|
|
11
14
|
@use '../vro-el-skeleton/style/index.scss' as *;
|
|
15
|
+
@use '../vro-el-tags/style/index.scss' as *;
|
|
16
|
+
@use '../vro-el-tree/style/index.scss' as *;
|
|
12
17
|
@use '../vro-el-with-config/style/index.scss' as *;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# VroElRadioGroup
|
|
2
|
+
|
|
3
|
+
### 介绍
|
|
4
|
+
|
|
5
|
+
基于 `ElRadioGroup` 和 `ElRadio` 的选项化封装。适合通过 `options` 快速渲染单选项,同时保留 Element Plus RadioGroup 的原有属性和事件。
|
|
6
|
+
|
|
7
|
+
## 代码演示
|
|
8
|
+
|
|
9
|
+
### 基础用法
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<template>
|
|
13
|
+
<vro-el-radio-group v-model="value" :options="options" />
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<script setup lang="ts">
|
|
17
|
+
import { ref } from 'vue'
|
|
18
|
+
|
|
19
|
+
const value = ref('daily')
|
|
20
|
+
const options = [
|
|
21
|
+
{ label: '每天', value: 'daily' },
|
|
22
|
+
{ label: '每周', value: 'weekly' },
|
|
23
|
+
{ label: '每月', value: 'monthly', props: { disabled: true } },
|
|
24
|
+
]
|
|
25
|
+
</script>
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 自定义字段名
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<vro-el-radio-group v-model="value" :options="options" label-key="name" value-key="id" />
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## API
|
|
35
|
+
|
|
36
|
+
### 属性 Props
|
|
37
|
+
|
|
38
|
+
<table>
|
|
39
|
+
<tbody>
|
|
40
|
+
<tr>
|
|
41
|
+
<td>名称</td>
|
|
42
|
+
<td>类型</td>
|
|
43
|
+
<td>默认值</td>
|
|
44
|
+
</tr>
|
|
45
|
+
<tr v-for="(item, key) in vroElRadioGroupProps" :key="key">
|
|
46
|
+
<td>{{ key }}</td>
|
|
47
|
+
<td>{{ parseType(item.type || item) }}</td>
|
|
48
|
+
<td>{{ reserve(item.default, '-') }}</td>
|
|
49
|
+
</tr>
|
|
50
|
+
</tbody>
|
|
51
|
+
</table>
|
|
52
|
+
|
|
53
|
+
### 插槽 Slots
|
|
54
|
+
|
|
55
|
+
暂无。
|
|
56
|
+
|
|
57
|
+
### 事件 Events
|
|
58
|
+
|
|
59
|
+
<table>
|
|
60
|
+
<tbody>
|
|
61
|
+
<tr>
|
|
62
|
+
<td>名称</td>
|
|
63
|
+
<td>参数</td>
|
|
64
|
+
<td>说明</td>
|
|
65
|
+
</tr>
|
|
66
|
+
<tr>
|
|
67
|
+
<td>update:modelValue</td>
|
|
68
|
+
<td>value</td>
|
|
69
|
+
<td>选中值变化时触发</td>
|
|
70
|
+
</tr>
|
|
71
|
+
<tr>
|
|
72
|
+
<td>change</td>
|
|
73
|
+
<td>value</td>
|
|
74
|
+
<td>同 Element Plus RadioGroup change 事件</td>
|
|
75
|
+
</tr>
|
|
76
|
+
</tbody>
|
|
77
|
+
</table>
|
|
78
|
+
|
|
79
|
+
<script setup lang="ts">
|
|
80
|
+
import { reserve } from '@daysnap/utils'
|
|
81
|
+
import { VroElRadioGroup, vroElRadioGroupProps } from '.'
|
|
82
|
+
import { parseType } from '../utils'
|
|
83
|
+
</script>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { withInstall } from '@vrojs/base'
|
|
2
|
+
|
|
3
|
+
import Component from './vro-el-radio-group.vue'
|
|
4
|
+
|
|
5
|
+
export * from './types'
|
|
6
|
+
|
|
7
|
+
export const VroElRadioGroup = withInstall<typeof Component>(Component)
|
|
8
|
+
export default VroElRadioGroup
|
|
9
|
+
|
|
10
|
+
export type VroElRadioGroupInstance = InstanceType<typeof VroElRadioGroup>
|
|
11
|
+
|
|
12
|
+
declare module 'vue' {
|
|
13
|
+
export interface GlobalComponents {
|
|
14
|
+
VroElRadioGroup: typeof VroElRadioGroup
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.vro-el-radio-group { }
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { radioGroupProps } from 'element-plus'
|
|
2
|
+
import type { ExtractPropTypes, PropType } from 'vue'
|
|
3
|
+
|
|
4
|
+
export const vroElRadioGroupProps = {
|
|
5
|
+
...radioGroupProps,
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* 选项列表,支持基础值或对象配置。
|
|
9
|
+
*/
|
|
10
|
+
options: Array as PropType<any[]>,
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 选项展示文本的字段名。
|
|
14
|
+
*/
|
|
15
|
+
labelKey: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: 'label',
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 选项绑定值的字段名。
|
|
22
|
+
*/
|
|
23
|
+
valueKey: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: 'value',
|
|
26
|
+
},
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export type VroElRadioGroupProps = ExtractPropTypes<typeof vroElRadioGroupProps>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<el-radio-group
|
|
3
|
+
v-bind="restProps"
|
|
4
|
+
class="vro-el-radio-group"
|
|
5
|
+
@update:model-value="$emit('update:modelValue', $event)"
|
|
6
|
+
@change="$emit('change', $event)"
|
|
7
|
+
>
|
|
8
|
+
<el-radio
|
|
9
|
+
v-for="(option, index) in options"
|
|
10
|
+
v-bind="option.props"
|
|
11
|
+
:key="index"
|
|
12
|
+
:value="option[valueKey || 'value'] ?? option"
|
|
13
|
+
>
|
|
14
|
+
{{ option[labelKey || 'label'] ?? option }}
|
|
15
|
+
</el-radio>
|
|
16
|
+
</el-radio-group>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<script setup lang="ts">
|
|
20
|
+
import { pick } from '@daysnap/utils'
|
|
21
|
+
import { ElRadio, ElRadioGroup, radioGroupProps } from 'element-plus'
|
|
22
|
+
import { computed } from 'vue'
|
|
23
|
+
|
|
24
|
+
import { vroElRadioGroupProps } from './types'
|
|
25
|
+
|
|
26
|
+
defineOptions({ name: 'VroElRadioGroup' })
|
|
27
|
+
|
|
28
|
+
defineEmits(['update:modelValue', 'change'])
|
|
29
|
+
const props = defineProps(vroElRadioGroupProps)
|
|
30
|
+
|
|
31
|
+
const restProps = computed(() => {
|
|
32
|
+
return pick(props, Object.keys(radioGroupProps) as any[])
|
|
33
|
+
})
|
|
34
|
+
</script>
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# VroElSchemaFilter
|
|
2
|
+
|
|
3
|
+
### 介绍
|
|
4
|
+
|
|
5
|
+
基于 `VroElSchemaForm` 的筛选表单组件。组件会根据 `schema` 渲染筛选项,并内置搜索、重置按钮,适合列表页、表格页的查询条件区域。
|
|
6
|
+
|
|
7
|
+
## 代码演示
|
|
8
|
+
|
|
9
|
+
### 基础用法
|
|
10
|
+
|
|
11
|
+
```html
|
|
12
|
+
<template>
|
|
13
|
+
<vro-el-schema-filter
|
|
14
|
+
:schema="schema"
|
|
15
|
+
:form-props="{ labelWidth: '90px' }"
|
|
16
|
+
@query="handleQuery"
|
|
17
|
+
@reset="handleReset"
|
|
18
|
+
/>
|
|
19
|
+
</template>
|
|
20
|
+
|
|
21
|
+
<script setup lang="ts">
|
|
22
|
+
import { ref } from 'vue'
|
|
23
|
+
import type { VroElSchemaFormSchema } from '@vrojs/element-plus'
|
|
24
|
+
|
|
25
|
+
const schema = ref<VroElSchemaFormSchema>({
|
|
26
|
+
keyword: {
|
|
27
|
+
label: '关键词',
|
|
28
|
+
value: '',
|
|
29
|
+
is: 'ElInput',
|
|
30
|
+
props: {
|
|
31
|
+
placeholder: '请输入关键词',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
status: {
|
|
35
|
+
label: '状态',
|
|
36
|
+
value: '',
|
|
37
|
+
defaultValue: '',
|
|
38
|
+
is: 'VroElSelect',
|
|
39
|
+
options: [
|
|
40
|
+
{ label: '启用', value: 'enabled' },
|
|
41
|
+
{ label: '停用', value: 'disabled' },
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const handleQuery = (value) => {
|
|
47
|
+
console.log(value)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const handleReset = () => {
|
|
51
|
+
console.log('reset')
|
|
52
|
+
}
|
|
53
|
+
</script>
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### 重置默认值
|
|
57
|
+
|
|
58
|
+
字段存在 `defaultValue` 时,点击重置会恢复为 `defaultValue`;否则会根据当前值类型重置为空字符串、空数组或空对象。
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
const schema = {
|
|
62
|
+
type: {
|
|
63
|
+
label: '类型',
|
|
64
|
+
value: 'all',
|
|
65
|
+
defaultValue: 'all',
|
|
66
|
+
is: 'VroElRadioGroup',
|
|
67
|
+
options: [
|
|
68
|
+
{ label: '全部', value: 'all' },
|
|
69
|
+
{ label: '个人', value: 'personal' },
|
|
70
|
+
{ label: '企业', value: 'company' },
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### 自定义按钮区域
|
|
77
|
+
|
|
78
|
+
默认插槽会追加到搜索、重置按钮后面。
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<vro-el-schema-filter :schema="schema">
|
|
82
|
+
<el-button>导出</el-button>
|
|
83
|
+
</vro-el-schema-filter>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## API
|
|
87
|
+
|
|
88
|
+
### 属性 Props
|
|
89
|
+
|
|
90
|
+
<table>
|
|
91
|
+
<tbody>
|
|
92
|
+
<tr>
|
|
93
|
+
<td>名称</td>
|
|
94
|
+
<td>类型</td>
|
|
95
|
+
<td>默认值</td>
|
|
96
|
+
</tr>
|
|
97
|
+
<tr v-for="(item, key) in vroElSchemaFilterProps" :key="key">
|
|
98
|
+
<td>{{ key }}</td>
|
|
99
|
+
<td>{{ parseType(item.type || item) }}</td>
|
|
100
|
+
<td>{{ reserve(item.default, '-') }}</td>
|
|
101
|
+
</tr>
|
|
102
|
+
</tbody>
|
|
103
|
+
</table>
|
|
104
|
+
|
|
105
|
+
### 插槽 Slots
|
|
106
|
+
|
|
107
|
+
<table>
|
|
108
|
+
<tbody>
|
|
109
|
+
<tr>
|
|
110
|
+
<td>名称</td>
|
|
111
|
+
<td>说明</td>
|
|
112
|
+
</tr>
|
|
113
|
+
<tr>
|
|
114
|
+
<td>default</td>
|
|
115
|
+
<td>搜索、重置按钮后的自定义内容</td>
|
|
116
|
+
</tr>
|
|
117
|
+
</tbody>
|
|
118
|
+
</table>
|
|
119
|
+
|
|
120
|
+
### 事件 Events
|
|
121
|
+
|
|
122
|
+
<table>
|
|
123
|
+
<tbody>
|
|
124
|
+
<tr>
|
|
125
|
+
<td>名称</td>
|
|
126
|
+
<td>参数</td>
|
|
127
|
+
<td>说明</td>
|
|
128
|
+
</tr>
|
|
129
|
+
<tr>
|
|
130
|
+
<td>query</td>
|
|
131
|
+
<td>value</td>
|
|
132
|
+
<td>点击搜索或回车查询时触发,参数为过滤空值后的表单值</td>
|
|
133
|
+
</tr>
|
|
134
|
+
<tr>
|
|
135
|
+
<td>reset</td>
|
|
136
|
+
<td>-</td>
|
|
137
|
+
<td>点击重置时触发</td>
|
|
138
|
+
</tr>
|
|
139
|
+
</tbody>
|
|
140
|
+
</table>
|
|
141
|
+
|
|
142
|
+
<script setup lang="ts">
|
|
143
|
+
import { reserve } from '@daysnap/utils'
|
|
144
|
+
import { VroElSchemaFilter, vroElSchemaFilterProps } from '.'
|
|
145
|
+
import { parseType } from '../utils'
|
|
146
|
+
</script>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { withInstall } from '@vrojs/base'
|
|
2
|
+
|
|
3
|
+
import Component from './vro-el-schema-filter.vue'
|
|
4
|
+
|
|
5
|
+
export * from './types'
|
|
6
|
+
|
|
7
|
+
export const VroElSchemaFilter = withInstall<typeof Component>(Component)
|
|
8
|
+
export default VroElSchemaFilter
|
|
9
|
+
|
|
10
|
+
export type VroElSchemaFilterInstance = InstanceType<typeof VroElSchemaFilter>
|
|
11
|
+
|
|
12
|
+
declare module 'vue' {
|
|
13
|
+
export interface GlobalComponents {
|
|
14
|
+
VroElSchemaFilter: typeof VroElSchemaFilter
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
.vro-el-schema-filter {
|
|
2
|
+
display: block;
|
|
3
|
+
box-sizing: border-box;
|
|
4
|
+
overflow: hidden;
|
|
5
|
+
padding: 0 16px 16px;
|
|
6
|
+
background-color: var(--el-bg-color);
|
|
7
|
+
.el-form-item__label {
|
|
8
|
+
display: flex;
|
|
9
|
+
align-items: center;
|
|
10
|
+
text-align: right;
|
|
11
|
+
line-height: 1.1;
|
|
12
|
+
margin-bottom: 0;
|
|
13
|
+
}
|
|
14
|
+
.el-form-item {
|
|
15
|
+
margin-bottom: 0;
|
|
16
|
+
}
|
|
17
|
+
.el-col {
|
|
18
|
+
margin-top: 16px;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ColProps } from 'element-plus'
|
|
2
|
+
import type { ExtractPropTypes, PropType } from 'vue'
|
|
3
|
+
|
|
4
|
+
import { vroElSchemaFormProps } from '../vro-el-schema-form'
|
|
5
|
+
|
|
6
|
+
export const vroElSchemaFilterProps = {
|
|
7
|
+
...vroElSchemaFormProps,
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 筛选项默认栅格配置。
|
|
11
|
+
*/
|
|
12
|
+
colProps: {
|
|
13
|
+
type: Object as PropType<Partial<ColProps>>,
|
|
14
|
+
default: () => ({ span: 8 }),
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 表单标签宽度,透传给内部 VroElSchemaForm。
|
|
19
|
+
*/
|
|
20
|
+
labelWidth: {
|
|
21
|
+
type: [String, Number] as PropType<string | number>,
|
|
22
|
+
default: '120px',
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 查询和重置按钮 loading 状态。
|
|
27
|
+
*/
|
|
28
|
+
loading: Boolean,
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export type VroElSchemaFilterProps = ExtractPropTypes<typeof vroElSchemaFilterProps>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<vro-el-schema-form
|
|
3
|
+
v-bind="props"
|
|
4
|
+
ref="refVroElSchemaForm"
|
|
5
|
+
class="vro-el-schema-filter"
|
|
6
|
+
@submit.prevent
|
|
7
|
+
@keyup.enter="handleQuery"
|
|
8
|
+
>
|
|
9
|
+
<el-col v-bind="colProps">
|
|
10
|
+
<el-form-item v-bind="formItemProps">
|
|
11
|
+
<el-button type="primary" :icon="Search" :loading="loading" @click="handleQuery">
|
|
12
|
+
{{ t('schemaFilter.searchText') }}
|
|
13
|
+
</el-button>
|
|
14
|
+
<el-button :icon="RefreshRight" :loading="loading" @click="handleReset">
|
|
15
|
+
{{ t('schemaFilter.resetText') }}
|
|
16
|
+
</el-button>
|
|
17
|
+
<slot></slot>
|
|
18
|
+
</el-form-item>
|
|
19
|
+
</el-col>
|
|
20
|
+
</vro-el-schema-form>
|
|
21
|
+
</template>
|
|
22
|
+
|
|
23
|
+
<script setup lang="ts">
|
|
24
|
+
import { filterEmptyValue, isArray, isFunction, isObject, isUndefined } from '@daysnap/utils'
|
|
25
|
+
import { RefreshRight, Search } from '@element-plus/icons-vue'
|
|
26
|
+
import { ElButton, ElCol, ElFormItem } from 'element-plus'
|
|
27
|
+
import { useTemplateRef } from 'vue'
|
|
28
|
+
|
|
29
|
+
import { useLocale } from '../locale'
|
|
30
|
+
import { VroElSchemaForm } from '../vro-el-schema-form'
|
|
31
|
+
import { vroElSchemaFilterProps } from './types'
|
|
32
|
+
|
|
33
|
+
defineOptions({ name: 'VroElSchemaFilter' })
|
|
34
|
+
|
|
35
|
+
const emit = defineEmits(['query', 'reset'])
|
|
36
|
+
const props = defineProps(vroElSchemaFilterProps)
|
|
37
|
+
const { t } = useLocale()
|
|
38
|
+
|
|
39
|
+
const refVroElSchemaForm = useTemplateRef('refVroElSchemaForm')
|
|
40
|
+
|
|
41
|
+
const handleQuery = async () => {
|
|
42
|
+
const data = (await refVroElSchemaForm.value?.extractValues()) ?? {}
|
|
43
|
+
emit('query', filterEmptyValue(data, true))
|
|
44
|
+
}
|
|
45
|
+
const handleReset = () => {
|
|
46
|
+
Object.values(props.schema).forEach((filed) => {
|
|
47
|
+
// eslint-disable-next-line prefer-const
|
|
48
|
+
let { value, resetValue } = filed
|
|
49
|
+
if (!isUndefined(resetValue)) {
|
|
50
|
+
value = isFunction(resetValue) ? resetValue(value) : resetValue
|
|
51
|
+
} else if (isArray(value)) {
|
|
52
|
+
value = []
|
|
53
|
+
} else if (isObject(value)) {
|
|
54
|
+
value = {}
|
|
55
|
+
} else {
|
|
56
|
+
value = ''
|
|
57
|
+
}
|
|
58
|
+
filed.value = value
|
|
59
|
+
})
|
|
60
|
+
refVroElSchemaForm.value?.resetFields()
|
|
61
|
+
emit('reset')
|
|
62
|
+
handleQuery()
|
|
63
|
+
}
|
|
64
|
+
</script>
|