@jari-ace/element-plus-component 0.4.0 → 0.4.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/dist/components/autoComplete/JaAutoComplete.vue.d.ts +543 -686
- package/dist/components/autoComplete/JaAutoComplete.vue.d.ts.map +1 -1
- package/dist/components/autoComplete/JaAutoComplete.vue.js +10 -2
- package/dist/components/autoComplete/JaAutoComplete.vue.js.map +1 -1
- package/dist/components/avatar/JaAvatar.vue.d.ts +4 -3
- package/dist/components/avatar/JaAvatar.vue.d.ts.map +1 -1
- package/dist/components/avatar/JaAvatar.vue.js +10 -2
- package/dist/components/avatar/JaAvatar.vue.js.map +1 -1
- package/dist/components/button/JaButton.vue.d.ts +184 -250
- package/dist/components/button/JaButton.vue.d.ts.map +1 -1
- package/dist/components/button/JaButton.vue.js +11 -3
- package/dist/components/button/JaButton.vue.js.map +1 -1
- package/dist/components/checkbox/JaCheckbox.vue.d.ts +164 -1068
- package/dist/components/checkbox/JaCheckbox.vue.d.ts.map +1 -1
- package/dist/components/checkbox/JaCheckbox.vue.js +9 -24
- package/dist/components/checkbox/JaCheckbox.vue.js.map +1 -1
- package/dist/components/checkboxGroup/JaCheckboxGroup.vue.d.ts +158 -163
- package/dist/components/checkboxGroup/JaCheckboxGroup.vue.d.ts.map +1 -1
- package/dist/components/checkboxGroup/JaCheckboxGroup.vue.js +14 -5
- package/dist/components/checkboxGroup/JaCheckboxGroup.vue.js.map +1 -1
- package/dist/components/datePicker/JaDatePicker.vue.d.ts +7 -4
- package/dist/components/datePicker/JaDatePicker.vue.d.ts.map +1 -1
- package/dist/components/datePicker/JaDatePicker.vue.js +18 -7
- package/dist/components/datePicker/JaDatePicker.vue.js.map +1 -1
- package/dist/components/dropdownButton/JaDropdownButton.vue.d.ts +324 -399
- package/dist/components/dropdownButton/JaDropdownButton.vue.d.ts.map +1 -1
- package/dist/components/dropdownButton/JaDropdownButton.vue.js +4 -2
- package/dist/components/dropdownButton/JaDropdownButton.vue.js.map +1 -1
- package/dist/components/form/JaForm.vue.d.ts +52 -3
- package/dist/components/form/JaForm.vue.d.ts.map +1 -1
- package/dist/components/form/JaForm.vue.js +4 -2
- package/dist/components/form/JaForm.vue.js.map +1 -1
- package/dist/components/formItem/JaFormItem.vue.d.ts +168 -133
- package/dist/components/formItem/JaFormItem.vue.d.ts.map +1 -1
- package/dist/components/formItem/JaFormItem.vue.js.map +1 -1
- package/dist/components/input/JaInput.vue.d.ts +274 -421
- package/dist/components/input/JaInput.vue.d.ts.map +1 -1
- package/dist/components/input/JaInput.vue.js +20 -60
- package/dist/components/input/JaInput.vue.js.map +1 -1
- package/dist/components/inputI18n/JaInputI18n.vue.d.ts +70 -70
- package/dist/components/inputNumber/JaInputNumber.vue.d.ts +203 -217
- package/dist/components/inputNumber/JaInputNumber.vue.d.ts.map +1 -1
- package/dist/components/inputNumber/JaInputNumber.vue.js +16 -37
- package/dist/components/inputNumber/JaInputNumber.vue.js.map +1 -1
- package/dist/components/radioGroup/JaRadioGroup.vue.d.ts +148 -121
- package/dist/components/radioGroup/JaRadioGroup.vue.d.ts.map +1 -1
- package/dist/components/radioGroup/JaRadioGroup.vue.js +14 -5
- package/dist/components/radioGroup/JaRadioGroup.vue.js.map +1 -1
- package/dist/components/scrollbar/Scrollbar.vue.d.ts +5 -2
- package/dist/components/scrollbar/Scrollbar.vue.d.ts.map +1 -1
- package/dist/components/scrollbar/Scrollbar.vue.js +11 -3
- package/dist/components/scrollbar/Scrollbar.vue.js.map +1 -1
- package/dist/components/select/JaSelect.vue.d.ts +70 -70
- package/dist/components/select/JaSelect.vue.js +14 -5
- package/dist/components/select/JaSelect.vue.js.map +1 -1
- package/dist/components/switch/JaSwitch.vue.d.ts +174 -205
- package/dist/components/switch/JaSwitch.vue.d.ts.map +1 -1
- package/dist/components/switch/JaSwitch.vue.js +13 -4
- package/dist/components/switch/JaSwitch.vue.js.map +1 -1
- package/dist/components/timePicker/JaTimePicker.vue.d.ts +5 -2
- package/dist/components/timePicker/JaTimePicker.vue.d.ts.map +1 -1
- package/dist/components/timePicker/JaTimePicker.vue.js +18 -7
- package/dist/components/timePicker/JaTimePicker.vue.js.map +1 -1
- package/dist/components/tip/index.d.ts +3 -12
- package/dist/components/tip/index.d.ts.map +1 -1
- package/dist/components/tip/src/AceTip.vue.d.ts +9 -3
- package/dist/components/tip/src/AceTip.vue.d.ts.map +1 -1
- package/dist/components/tip/src/AceTip.vue.js.map +1 -1
- package/dist/components/upload/JaUploader.vue.d.ts +74 -14
- package/dist/components/upload/JaUploader.vue.d.ts.map +1 -1
- package/dist/components/upload/JaUploader.vue.js +3 -5
- package/dist/components/upload/JaUploader.vue.js.map +1 -1
- package/dist/components/upload/index.d.ts +79 -25
- package/dist/components/upload/index.d.ts.map +1 -1
- package/dist/components/upload/uploader.vue.d.ts +16 -0
- package/dist/components/upload/uploader.vue.d.ts.map +1 -1
- package/dist/components/upload/uploader.vue.js +137 -95
- package/dist/components/upload/uploader.vue.js.map +1 -1
- package/dist/components/userGroupTree/src/userGroupTree.vue.d.ts +50 -36
- package/dist/components/userGroupTree/src/userGroupTree.vue.d.ts.map +1 -1
- package/dist/components/userGroupTree/src/userGroupTree.vue.js +26 -1
- package/dist/components/userGroupTree/src/userGroupTree.vue.js.map +1 -1
- package/lib/index.css +2 -2
- package/lib/index.js +8291 -7887
- package/lib/index.umd.cjs +36 -36
- package/package.json +2 -2
- package/packages/components/autoComplete/JaAutoComplete.vue +19 -9
- package/packages/components/autoComplete/README.md +35 -0
- package/packages/components/avatar/JaAvatar.vue +16 -7
- package/packages/components/avatar/README.md +45 -0
- package/packages/components/button/JaButton.vue +32 -7
- package/packages/components/button/README.md +57 -0
- package/packages/components/checkbox/JaCheckbox.vue +15 -25
- package/packages/components/checkbox/README.md +21 -0
- package/packages/components/checkboxGroup/JaCheckboxGroup.vue +16 -5
- package/packages/components/checkboxGroup/README.md +24 -0
- package/packages/components/datePicker/JaDatePicker.vue +23 -10
- package/packages/components/datePicker/README.md +21 -0
- package/packages/components/dropdownButton/JaDropdownButton.vue +25 -7
- package/packages/components/dropdownButton/README.md +30 -0
- package/packages/components/form/JaForm.vue +60 -20
- package/packages/components/form/README.md +30 -0
- package/packages/components/formItem/JaFormItem.vue +43 -7
- package/packages/components/formItem/README.md +28 -0
- package/packages/components/input/JaInput.vue +30 -66
- package/packages/components/input/README.md +23 -0
- package/packages/components/inputNumber/JaInputNumber.vue +25 -45
- package/packages/components/inputNumber/README.md +21 -0
- package/packages/components/radioGroup/JaRadioGroup.vue +16 -5
- package/packages/components/radioGroup/README.md +24 -0
- package/packages/components/scrollbar/README.md +23 -0
- package/packages/components/scrollbar/Scrollbar.vue +14 -3
- package/packages/components/select/JaSelect.vue +22 -10
- package/packages/components/select/README.md +24 -0
- package/packages/components/switch/JaSwitch.vue +16 -5
- package/packages/components/switch/README.md +21 -0
- package/packages/components/timePicker/JaTimePicker.vue +21 -8
- package/packages/components/timePicker/README.md +21 -0
- package/packages/components/tip/README.md +20 -0
- package/packages/components/tip/src/AceTip.vue +10 -2
- package/packages/components/upload/JaUploader.vue +9 -8
- package/packages/components/upload/README.md +24 -0
- package/packages/components/upload/uploader.vue +95 -58
- package/packages/components/userGroupTree/src/userGroupTree.vue +9 -2
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jari-ace/element-plus-component",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.2",
|
|
5
5
|
"main": "lib/index.umd.cjs",
|
|
6
6
|
"module": "lib/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"animate.css": "^4.1.1",
|
|
26
26
|
"pretty-bytes": "^7.1.0",
|
|
27
27
|
"vue-pdf-embed": "^2.1.3",
|
|
28
|
-
"@jari-ace/app-bolts": "0.
|
|
28
|
+
"@jari-ace/app-bolts": "0.6.3"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/lodash-es": "^4.17.12",
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {ElAutocomplete} from "element-plus";
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import type {
|
|
6
|
-
import {
|
|
2
|
+
import { ElAutocomplete } from "element-plus";
|
|
3
|
+
import type { AutocompleteProps } from "element-plus";
|
|
4
|
+
import { inject, ref, watch, computed } from "vue";
|
|
5
|
+
import type { ValidationInstance } from "../../hooks/useBackendValidations";
|
|
6
|
+
import type { EpPropMergeType } from "element-plus/es/utils";
|
|
7
|
+
import { getValue, setValue } from "../../utils/objectUtils";
|
|
7
8
|
|
|
8
|
-
const input = ref<typeof ElAutocomplete
|
|
9
|
+
const input = ref<InstanceType<typeof ElAutocomplete>>()
|
|
9
10
|
const model = inject('aceFormModel') as Record<string, any>
|
|
10
11
|
const prop = inject('aceFormItemProp') as string
|
|
11
12
|
const validator = inject('aceFormValidator') as ValidationInstance
|
|
@@ -19,8 +20,7 @@ function onChange(value: string) {
|
|
|
19
20
|
emit('change', value)
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
type modelType =
|
|
23
|
-
EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
|
|
23
|
+
type modelType = EpPropMergeType<readonly [StringConstructor, NumberConstructor], unknown, unknown> | undefined;
|
|
24
24
|
|
|
25
25
|
const mv = ref(getValue(model.formData, prop) as modelType);
|
|
26
26
|
watch(() => model.formData, () => {
|
|
@@ -32,6 +32,16 @@ defineExpose({
|
|
|
32
32
|
elAutocomplete: input
|
|
33
33
|
})
|
|
34
34
|
|
|
35
|
+
export interface JaAutoCompleteProps extends Partial<AutocompleteProps> {
|
|
36
|
+
// Custom props can be added here if needed
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const props = defineProps<JaAutoCompleteProps>()
|
|
40
|
+
|
|
41
|
+
const elementProps = computed(() => {
|
|
42
|
+
return props
|
|
43
|
+
})
|
|
44
|
+
|
|
35
45
|
</script>
|
|
36
46
|
|
|
37
47
|
<template>
|
|
@@ -39,7 +49,7 @@ defineExpose({
|
|
|
39
49
|
ref="input"
|
|
40
50
|
v-model="mv"
|
|
41
51
|
@change="onChange"
|
|
42
|
-
v-bind="
|
|
52
|
+
v-bind="{ ...elementProps, ...$attrs }">
|
|
43
53
|
<template v-for="(_, name) in $slots" v-slot:[name]>
|
|
44
54
|
<slot :name="name"></slot>
|
|
45
55
|
</template>
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# JaAutoComplete 自动补全组件
|
|
2
|
+
|
|
3
|
+
`JaAutoComplete` 是对 Element Plus `ElAutocomplete` 的封装,集成了表单上下文注入和验证功能。
|
|
4
|
+
|
|
5
|
+
## 组件用途
|
|
6
|
+
|
|
7
|
+
主要用于在 `JaForm` 表单中使用,自动绑定表单数据模型和验证规则。
|
|
8
|
+
|
|
9
|
+
## 属性 API
|
|
10
|
+
|
|
11
|
+
该组件继承了 [ElAutocomplete](https://element-plus.org/zh-CN/component/autocomplete.html#autocomplete-attributes) 的所有属性。
|
|
12
|
+
|
|
13
|
+
| 属性名 | 类型 | 默认值 | 说明 |
|
|
14
|
+
| :--- | :--- | :--- | :--- |
|
|
15
|
+
| - | - | - | 支持所有 ElAutocomplete 属性 |
|
|
16
|
+
|
|
17
|
+
## 使用示例
|
|
18
|
+
|
|
19
|
+
```vue
|
|
20
|
+
<template>
|
|
21
|
+
<ja-form :model="formData">
|
|
22
|
+
<ja-form-item prop="city" label="城市">
|
|
23
|
+
<ja-auto-complete
|
|
24
|
+
:fetch-suggestions="querySearch"
|
|
25
|
+
placeholder="请输入城市"
|
|
26
|
+
/>
|
|
27
|
+
</ja-form-item>
|
|
28
|
+
</ja-form>
|
|
29
|
+
</template>
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 注意事项
|
|
33
|
+
|
|
34
|
+
- 该组件设计为在 `JaForm` 内部使用,依赖 `aceFormModel` 等注入。
|
|
35
|
+
- 自动处理 `v-model` 绑定,无需手动传入 `v-model`,只需确保在 `JaFormItem` 中指定 `prop`。
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {getAvatarToken} from "./avatarToken";
|
|
3
|
-
import {ElAvatar, ElImage} from "element-plus";
|
|
2
|
+
import { getAvatarToken } from "./avatarToken";
|
|
3
|
+
import { ElAvatar, ElImage } from "element-plus";
|
|
4
|
+
import type { AvatarProps } from "element-plus";
|
|
4
5
|
import {
|
|
5
6
|
computed,
|
|
6
|
-
defineProps,
|
|
7
7
|
nextTick,
|
|
8
8
|
onMounted, onUnmounted,
|
|
9
9
|
ref,
|
|
10
10
|
watch,
|
|
11
11
|
withDefaults
|
|
12
12
|
} from "vue";
|
|
13
|
-
import {defaultImg} from "./defaultImg";
|
|
13
|
+
import { defaultImg } from "./defaultImg";
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
export interface JaAvatarProps extends Partial<AvatarProps> {
|
|
16
16
|
/**
|
|
17
17
|
* 用户id
|
|
18
18
|
*/
|
|
@@ -35,7 +35,9 @@ const props = withDefaults(defineProps<{
|
|
|
35
35
|
hasAvatar?: boolean,
|
|
36
36
|
|
|
37
37
|
firstName?: string
|
|
38
|
-
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const props = withDefaults(defineProps<JaAvatarProps>(), {
|
|
39
41
|
doNotLoadAvatar: false
|
|
40
42
|
})
|
|
41
43
|
|
|
@@ -51,6 +53,7 @@ if (!scrollbarWrappedItems) {
|
|
|
51
53
|
onMounted(async () => {
|
|
52
54
|
await nextTick();
|
|
53
55
|
if (scrollbarWrappedItems) {
|
|
56
|
+
// @ts-ignore
|
|
54
57
|
scrollbarWrappedItems.value?.push({
|
|
55
58
|
childElement: avatar.value?.$el,
|
|
56
59
|
onInView(isInView: boolean) {
|
|
@@ -91,15 +94,21 @@ function adjustFontSize(element?: HTMLElement) {
|
|
|
91
94
|
|
|
92
95
|
onUnmounted(() => {
|
|
93
96
|
if (scrollbarWrappedItems) {
|
|
97
|
+
// @ts-ignore
|
|
94
98
|
scrollbarWrappedItems.value = undefined;
|
|
95
99
|
}
|
|
96
100
|
})
|
|
97
101
|
|
|
98
102
|
watch(usernameSpan, () => adjustFontSize(usernameSpan.value))
|
|
103
|
+
|
|
104
|
+
const elementProps = computed(() => {
|
|
105
|
+
const { userId, username, realm, doNotLoadAvatar, hasAvatar, firstName, ...rest } = props
|
|
106
|
+
return rest
|
|
107
|
+
})
|
|
99
108
|
</script>
|
|
100
109
|
|
|
101
110
|
<template>
|
|
102
|
-
<el-avatar :src="lazyUrl" v-bind="
|
|
111
|
+
<el-avatar :src="lazyUrl" v-bind="{ ...elementProps, ...$attrs }" ref="avatar" class="ja-avatar">
|
|
103
112
|
<span v-if="props.firstName && props.firstName.length > 0" class="user-name-avatar"
|
|
104
113
|
ref="usernameSpan">
|
|
105
114
|
{{ firstName }}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# JaAvatar 头像组件
|
|
2
|
+
|
|
3
|
+
`JaAvatar` 是对 Element Plus `ElAvatar` 的扩展,支持根据用户信息自动加载头像,支持显示用户首字母。
|
|
4
|
+
|
|
5
|
+
## 组件用途
|
|
6
|
+
|
|
7
|
+
用于显示用户头像,支持通过 userId 或 username/realm 自动获取头像图片,并在加载失败或无头像时显示默认图片或首字母。
|
|
8
|
+
|
|
9
|
+
## 属性 API
|
|
10
|
+
|
|
11
|
+
该组件继承了 [ElAvatar](https://element-plus.org/zh-CN/component/avatar.html#avatar-attributes) 的所有属性,并额外支持以下属性:
|
|
12
|
+
|
|
13
|
+
| 属性名 | 类型 | 默认值 | 说明 |
|
|
14
|
+
| :--- | :--- | :--- | :--- |
|
|
15
|
+
| `userId` | `string` | - | 用户 ID,用于构建头像 URL |
|
|
16
|
+
| `username` | `string` | - | 用户名,用于构建头像 URL(需配合 realm) |
|
|
17
|
+
| `realm` | `string` | - | 用户域,用于构建头像 URL |
|
|
18
|
+
| `firstName` | `string` | - | 用户首名,当无头像图片时显示此文字 |
|
|
19
|
+
| `hasAvatar` | `boolean` | - | 用户是否设置了头像 |
|
|
20
|
+
| `doNotLoadAvatar` | `boolean` | `false` | 是否强制不加载头像图片(仅显示 Tag 模式时使用) |
|
|
21
|
+
|
|
22
|
+
## 使用示例
|
|
23
|
+
|
|
24
|
+
```vue
|
|
25
|
+
<template>
|
|
26
|
+
<!-- 通过 User ID 加载 -->
|
|
27
|
+
<ja-avatar :userId="user.id" :hasAvatar="true" />
|
|
28
|
+
|
|
29
|
+
<!-- 显示首字母 -->
|
|
30
|
+
<ja-avatar firstName="John" />
|
|
31
|
+
|
|
32
|
+
<!-- 完整信息 -->
|
|
33
|
+
<ja-avatar
|
|
34
|
+
:userId="user.id"
|
|
35
|
+
:firstName="user.firstName"
|
|
36
|
+
:hasAvatar="user.hasAvatar"
|
|
37
|
+
size="large"
|
|
38
|
+
/>
|
|
39
|
+
</template>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## 注意事项
|
|
43
|
+
|
|
44
|
+
- 组件内置了懒加载逻辑,只有当头像进入视图区域时才开始加载图片。
|
|
45
|
+
- 自动处理开发环境 (`isDevMode`) 下的代理路径。
|
|
@@ -1,21 +1,41 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import dShortcut from "../../directives/shortcut";
|
|
3
3
|
import vAuth from "../../directives/auth";
|
|
4
|
-
import {ElButton, ElTooltip} from "element-plus";
|
|
5
|
-
import {
|
|
4
|
+
import { ElButton, ElTooltip } from "element-plus";
|
|
5
|
+
import type { ButtonProps } from "element-plus";
|
|
6
|
+
import { ref, computed } from "vue";
|
|
7
|
+
|
|
8
|
+
const input = ref<InstanceType<typeof ElButton>>()
|
|
6
9
|
|
|
7
|
-
const input = ref<typeof ElButton>({} as typeof ElButton)
|
|
8
10
|
type AuthModifier = {
|
|
9
11
|
disable: boolean;
|
|
10
12
|
any: boolean
|
|
11
13
|
}
|
|
12
|
-
|
|
14
|
+
|
|
15
|
+
export interface JaButtonProps extends Partial<ButtonProps> {
|
|
16
|
+
/**
|
|
17
|
+
* 按钮文字提示
|
|
18
|
+
*/
|
|
13
19
|
tooltip?: string
|
|
20
|
+
/**
|
|
21
|
+
* 快捷键
|
|
22
|
+
*/
|
|
14
23
|
shortcut?: string
|
|
24
|
+
/**
|
|
25
|
+
* 权限标识
|
|
26
|
+
*/
|
|
15
27
|
auth?: string | string[]
|
|
28
|
+
/**
|
|
29
|
+
* 权限修饰符
|
|
30
|
+
*/
|
|
16
31
|
authModifiers?: AuthModifier
|
|
32
|
+
/**
|
|
33
|
+
* 提示位置
|
|
34
|
+
*/
|
|
17
35
|
tooltipPlacement?: 'top' | 'bottom'
|
|
18
|
-
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const props = withDefaults(defineProps<JaButtonProps>(), {
|
|
19
39
|
tooltipPlacement: 'bottom',
|
|
20
40
|
authModifiers: () => ({
|
|
21
41
|
disable: true,
|
|
@@ -25,6 +45,11 @@ const props = withDefaults(defineProps<{
|
|
|
25
45
|
|
|
26
46
|
const vShortcut = dShortcut
|
|
27
47
|
|
|
48
|
+
const elementProps = computed(() => {
|
|
49
|
+
const { tooltip, shortcut, auth, authModifiers, tooltipPlacement, ...rest } = props
|
|
50
|
+
return rest
|
|
51
|
+
})
|
|
52
|
+
|
|
28
53
|
defineExpose({
|
|
29
54
|
elButton: input
|
|
30
55
|
})
|
|
@@ -32,12 +57,12 @@ defineExpose({
|
|
|
32
57
|
</script>
|
|
33
58
|
|
|
34
59
|
<template>
|
|
35
|
-
<el-tooltip :placement="tooltipPlacement" append-to="body">
|
|
60
|
+
<el-tooltip :placement="tooltipPlacement" append-to="body" :disabled="!tooltip && !shortcut">
|
|
36
61
|
<el-button
|
|
37
62
|
ref="input"
|
|
38
63
|
v-auth:[authModifiers]="auth"
|
|
39
64
|
v-shortcut:[shortcut]
|
|
40
|
-
v-bind="
|
|
65
|
+
v-bind="{ ...elementProps, ...$attrs }">
|
|
41
66
|
<template v-for="(_, name) in $slots" v-slot:[name]>
|
|
42
67
|
<slot :name="name"></slot>
|
|
43
68
|
</template>
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# JaButton 按钮组件
|
|
2
|
+
|
|
3
|
+
`JaButton` 是对 Element Plus `ElButton` 的扩展封装,增加了工具提示、快捷键绑定和权限控制功能。
|
|
4
|
+
|
|
5
|
+
## 组件用途
|
|
6
|
+
|
|
7
|
+
用于在页面中执行操作,支持通过配置快速添加 Tooltip 提示和键盘快捷键,同时集成了权限指令。
|
|
8
|
+
|
|
9
|
+
## 属性 API
|
|
10
|
+
|
|
11
|
+
该组件继承了 [ElButton](https://element-plus.org/zh-CN/component/button.html#button-attributes) 的所有属性,并额外支持以下属性:
|
|
12
|
+
|
|
13
|
+
| 属性名 | 类型 | 默认值 | 说明 |
|
|
14
|
+
| :--- | :--- | :--- | :--- |
|
|
15
|
+
| `tooltip` | `string` | - | 按钮的文字提示内容 |
|
|
16
|
+
| `shortcut` | `string` | - | 绑定的快捷键(如 'Ctrl+S') |
|
|
17
|
+
| `auth` | `string \| string[]` | - | 权限标识,用于控制按钮显示/禁用 |
|
|
18
|
+
| `authModifiers` | `AuthModifier` | `{ disable: true, any: false }` | 权限修饰符,`disable`为真时无权限禁用而非隐藏 |
|
|
19
|
+
| `tooltipPlacement` | `'top' \| 'bottom'` | `'bottom'` | Tooltip 提示出现的位置 |
|
|
20
|
+
|
|
21
|
+
### AuthModifier 类型定义
|
|
22
|
+
```typescript
|
|
23
|
+
type AuthModifier = {
|
|
24
|
+
disable: boolean;
|
|
25
|
+
any: boolean
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## 使用示例
|
|
30
|
+
|
|
31
|
+
```vue
|
|
32
|
+
<template>
|
|
33
|
+
<ja-button
|
|
34
|
+
type="primary"
|
|
35
|
+
tooltip="保存当前更改"
|
|
36
|
+
shortcut="Ctrl+S"
|
|
37
|
+
@click="handleSave"
|
|
38
|
+
>
|
|
39
|
+
保存
|
|
40
|
+
</ja-button>
|
|
41
|
+
|
|
42
|
+
<ja-button
|
|
43
|
+
type="danger"
|
|
44
|
+
auth="user:delete"
|
|
45
|
+
:authModifiers="{ disable: true }"
|
|
46
|
+
@click="handleDelete"
|
|
47
|
+
>
|
|
48
|
+
删除用户
|
|
49
|
+
</ja-button>
|
|
50
|
+
</template>
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## 注意事项
|
|
54
|
+
|
|
55
|
+
- 当设置了 `tooltip` 或 `shortcut` 时,组件会自动包裹 `ElTooltip`。
|
|
56
|
+
- `shortcut` 需要配合 `v-shortcut` 指令工作(组件内部已集成)。
|
|
57
|
+
- 所有未显式定义的属性将透传给内部的 `ElButton`。
|
|
@@ -1,23 +1,16 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {inject, ref, watch} from 'vue'
|
|
2
|
+
import {inject, ref, watch, computed} from 'vue'
|
|
3
3
|
import {type CheckboxValueType, ElCheckbox} from 'element-plus'
|
|
4
|
+
import type { CheckboxProps } from 'element-plus'
|
|
4
5
|
import type {ValidationInstance} from '../../hooks/useBackendValidations'
|
|
5
6
|
import {getValue, setValue} from "../../utils/objectUtils";
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
border?: boolean
|
|
13
|
-
size?: 'large' | 'default' | 'small'
|
|
14
|
-
name?: string
|
|
15
|
-
checked?: boolean
|
|
16
|
-
indeterminate?: boolean
|
|
17
|
-
validateEvent?: boolean
|
|
18
|
-
}>(), {
|
|
8
|
+
export interface JaCheckboxProps extends Partial<CheckboxProps> {
|
|
9
|
+
// Custom props or overrides if any
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const props = withDefaults(defineProps<JaCheckboxProps>(), {
|
|
19
13
|
disabled: false,
|
|
20
|
-
border: false,
|
|
21
14
|
checked: false,
|
|
22
15
|
indeterminate: false,
|
|
23
16
|
validateEvent: true
|
|
@@ -26,7 +19,7 @@ const props = withDefaults(defineProps<{
|
|
|
26
19
|
const model = inject('aceFormModel') as Record<string, any>
|
|
27
20
|
const prop = inject('aceFormItemProp') as string
|
|
28
21
|
const validator = inject('aceFormValidator') as ValidationInstance
|
|
29
|
-
const checkbox = ref<typeof ElCheckbox
|
|
22
|
+
const checkbox = ref<InstanceType<typeof ElCheckbox>>()
|
|
30
23
|
const emit = defineEmits<{
|
|
31
24
|
change: [value: CheckboxValueType]
|
|
32
25
|
}>()
|
|
@@ -43,6 +36,12 @@ const mv = ref(getValue(model.formData, prop) as ModelType);
|
|
|
43
36
|
watch(() => model.formData, () => {
|
|
44
37
|
mv.value = getValue(model.formData, prop) as ModelType
|
|
45
38
|
})
|
|
39
|
+
|
|
40
|
+
const elementProps = computed(() => {
|
|
41
|
+
const { modelValue, ...rest } = props
|
|
42
|
+
return rest
|
|
43
|
+
})
|
|
44
|
+
|
|
46
45
|
defineExpose({
|
|
47
46
|
elCheckbox: checkbox
|
|
48
47
|
})
|
|
@@ -52,17 +51,8 @@ defineExpose({
|
|
|
52
51
|
<el-checkbox
|
|
53
52
|
ref="checkbox"
|
|
54
53
|
v-model="mv"
|
|
55
|
-
:disabled="disabled"
|
|
56
|
-
:true-label="trueLabel"
|
|
57
|
-
:false-label="falseLabel"
|
|
58
|
-
:border="border"
|
|
59
|
-
:size="size"
|
|
60
|
-
:name="name"
|
|
61
|
-
:checked="checked"
|
|
62
|
-
:indeterminate="indeterminate"
|
|
63
|
-
:validate-event="validateEvent"
|
|
64
|
-
:label="label"
|
|
65
54
|
@change="onChange"
|
|
55
|
+
v-bind="{ ...elementProps, ...$attrs }"
|
|
66
56
|
>
|
|
67
57
|
<slot></slot>
|
|
68
58
|
</el-checkbox>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# JaCheckbox 复选框组件
|
|
2
|
+
|
|
3
|
+
`JaCheckbox` 是对 Element Plus `ElCheckbox` 的封装,集成了 `JaForm` 表单上下文注入。
|
|
4
|
+
|
|
5
|
+
## 组件用途
|
|
6
|
+
|
|
7
|
+
用于在 `JaForm` 中创建复选框,自动绑定数据模型。
|
|
8
|
+
|
|
9
|
+
## 属性 API
|
|
10
|
+
|
|
11
|
+
该组件继承了 [ElCheckbox](https://element-plus.org/zh-CN/component/checkbox.html#checkbox-attributes) 的所有属性。
|
|
12
|
+
|
|
13
|
+
| 属性名 | 类型 | 默认值 | 说明 |
|
|
14
|
+
| :--- | :--- | :--- | :--- |
|
|
15
|
+
| - | - | - | 支持所有 ElCheckbox 属性 |
|
|
16
|
+
|
|
17
|
+
## 使用示例
|
|
18
|
+
|
|
19
|
+
```vue
|
|
20
|
+
<ja-checkbox label="Option 1" />
|
|
21
|
+
```
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type {ValidationInstance} from '../../hooks/useBackendValidations'
|
|
3
|
-
import {inject, ref, watch} from "vue";
|
|
3
|
+
import {inject, ref, watch, computed} from "vue";
|
|
4
4
|
import {type CheckboxGroupValueType, ElCheckboxGroup} from "element-plus";
|
|
5
|
+
import type { CheckboxGroupProps } from 'element-plus'
|
|
5
6
|
import {getValue, setValue} from "../../utils/objectUtils";
|
|
6
7
|
|
|
7
|
-
const input = ref<typeof ElCheckboxGroup
|
|
8
|
+
const input = ref<InstanceType<typeof ElCheckboxGroup>>()
|
|
8
9
|
const model = inject('aceFormModel') as Record<string, never>
|
|
9
10
|
const prop = inject('aceFormItemProp') as string
|
|
10
11
|
const validator = inject('aceFormValidator') as ValidationInstance
|
|
@@ -12,6 +13,11 @@ const emit = defineEmits<{
|
|
|
12
13
|
change: [value: CheckboxGroupValueType]
|
|
13
14
|
}>()
|
|
14
15
|
|
|
16
|
+
export interface JaCheckboxGroupProps extends Partial<CheckboxGroupProps> {
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const props = defineProps<JaCheckboxGroupProps>()
|
|
20
|
+
|
|
15
21
|
function onChange(val: CheckboxGroupValueType) {
|
|
16
22
|
validator.removeFieldError(prop)
|
|
17
23
|
setValue(model.formData, prop, mv.value);
|
|
@@ -25,9 +31,14 @@ watch(() => model.formData, () => {
|
|
|
25
31
|
deep: true
|
|
26
32
|
})
|
|
27
33
|
|
|
34
|
+
const elementProps = computed(() => {
|
|
35
|
+
const { modelValue, ...rest } = props
|
|
36
|
+
return rest
|
|
37
|
+
})
|
|
38
|
+
|
|
28
39
|
defineExpose({
|
|
29
|
-
focus: () => input.value
|
|
30
|
-
blur: () => input.value
|
|
40
|
+
focus: () => (input.value as any)?.focus?.(), // Optional chaining in case ref is not ready or method missing
|
|
41
|
+
blur: () => (input.value as any)?.blur?.(), // CheckboxGroup might not expose blur directly on type, but runtime it might
|
|
31
42
|
elCheckboxGroup: input
|
|
32
43
|
})
|
|
33
44
|
</script>
|
|
@@ -37,7 +48,7 @@ defineExpose({
|
|
|
37
48
|
ref="input"
|
|
38
49
|
v-model="mv"
|
|
39
50
|
@change="onChange"
|
|
40
|
-
v-bind="
|
|
51
|
+
v-bind="{ ...elementProps, ...$attrs }">
|
|
41
52
|
<template v-for="(_, name) in $slots" v-slot:[name]>
|
|
42
53
|
<slot :name="name"></slot>
|
|
43
54
|
</template>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# JaCheckboxGroup 复选框组组件
|
|
2
|
+
|
|
3
|
+
`JaCheckboxGroup` 是对 Element Plus `ElCheckboxGroup` 的封装,集成了 `JaForm` 表单上下文注入。
|
|
4
|
+
|
|
5
|
+
## 组件用途
|
|
6
|
+
|
|
7
|
+
用于在 `JaForm` 中创建复选框组,自动绑定数据模型。
|
|
8
|
+
|
|
9
|
+
## 属性 API
|
|
10
|
+
|
|
11
|
+
该组件继承了 [ElCheckboxGroup](https://element-plus.org/zh-CN/component/checkbox.html#checkboxgroup-attributes) 的所有属性。
|
|
12
|
+
|
|
13
|
+
| 属性名 | 类型 | 默认值 | 说明 |
|
|
14
|
+
| :--- | :--- | :--- | :--- |
|
|
15
|
+
| - | - | - | 支持所有 ElCheckboxGroup 属性 |
|
|
16
|
+
|
|
17
|
+
## 使用示例
|
|
18
|
+
|
|
19
|
+
```vue
|
|
20
|
+
<ja-checkbox-group>
|
|
21
|
+
<ja-checkbox label="Option A" />
|
|
22
|
+
<ja-checkbox label="Option B" />
|
|
23
|
+
</ja-checkbox-group>
|
|
24
|
+
```
|
|
@@ -1,26 +1,32 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import type {ValidationInstance} from '../../hooks/useBackendValidations'
|
|
3
|
-
import {inject, onMounted, ref, watch} from "vue";
|
|
3
|
+
import {inject, onMounted, ref, watch, computed} from "vue";
|
|
4
4
|
import {ElDatePicker} from "element-plus";
|
|
5
|
+
import type { DatePickerProps } from "element-plus";
|
|
5
6
|
import {getValue, setValue} from "../../utils/objectUtils";
|
|
6
7
|
|
|
7
|
-
const input = ref<typeof ElDatePicker
|
|
8
|
+
const input = ref<InstanceType<typeof ElDatePicker>>()
|
|
8
9
|
const model = inject('aceFormModel') as Record<string, any>
|
|
9
10
|
const prop = inject('aceFormItemProp') as string
|
|
10
11
|
const validator = inject('aceFormValidator') as ValidationInstance
|
|
11
12
|
const emit = defineEmits<{
|
|
12
|
-
change: [value: string
|
|
13
|
+
change: [value: any] // DatePicker change value can be Date | string | number | array
|
|
13
14
|
}>()
|
|
14
15
|
|
|
16
|
+
export interface JaDatePickerProps extends Partial<DatePickerProps> {
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const props = defineProps<JaDatePickerProps>()
|
|
20
|
+
|
|
15
21
|
const exposeMethods = ref<any>({})
|
|
16
22
|
|
|
17
|
-
function onChange(value:
|
|
23
|
+
function onChange(value: any) {
|
|
18
24
|
validator.removeFieldError(prop);
|
|
19
25
|
setValue(model.formData, prop, mv.value);
|
|
20
26
|
emit('change', value);
|
|
21
27
|
}
|
|
22
28
|
|
|
23
|
-
type ModelType = string | number | object;
|
|
29
|
+
type ModelType = string | number | object | any;
|
|
24
30
|
|
|
25
31
|
const mv = ref(getValue(model.formData, prop) as ModelType);
|
|
26
32
|
watch(() => model.formData, () => {
|
|
@@ -29,11 +35,18 @@ watch(() => model.formData, () => {
|
|
|
29
35
|
deep: true
|
|
30
36
|
})
|
|
31
37
|
|
|
38
|
+
const elementProps = computed(() => {
|
|
39
|
+
const { modelValue, ...rest } = props
|
|
40
|
+
return rest
|
|
41
|
+
})
|
|
42
|
+
|
|
32
43
|
onMounted(() => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
44
|
+
if (input.value) {
|
|
45
|
+
const refMethods = Object.entries(input.value).filter(([_, v]) => v instanceof Function);
|
|
46
|
+
refMethods.forEach(([key, val]) => {
|
|
47
|
+
exposeMethods.value[key] = val;
|
|
48
|
+
})
|
|
49
|
+
}
|
|
37
50
|
})
|
|
38
51
|
|
|
39
52
|
defineExpose(exposeMethods.value);
|
|
@@ -44,7 +57,7 @@ defineExpose(exposeMethods.value);
|
|
|
44
57
|
ref="input"
|
|
45
58
|
v-model="model.formData[prop]"
|
|
46
59
|
@change="onChange"
|
|
47
|
-
v-bind="
|
|
60
|
+
v-bind="{ ...elementProps, ...$attrs }">
|
|
48
61
|
<template v-for="(_, name) in $slots" v-slot:[name]>
|
|
49
62
|
<slot :name="name"></slot>
|
|
50
63
|
</template>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# JaDatePicker 日期选择器组件
|
|
2
|
+
|
|
3
|
+
`JaDatePicker` 是对 Element Plus `ElDatePicker` 的封装,集成了 `JaForm` 表单上下文注入。
|
|
4
|
+
|
|
5
|
+
## 组件用途
|
|
6
|
+
|
|
7
|
+
用于在 `JaForm` 中选择日期,自动绑定数据模型。
|
|
8
|
+
|
|
9
|
+
## 属性 API
|
|
10
|
+
|
|
11
|
+
该组件继承了 [ElDatePicker](https://element-plus.org/zh-CN/component/date-picker.html#datepicker-attributes) 的所有属性。
|
|
12
|
+
|
|
13
|
+
| 属性名 | 类型 | 默认值 | 说明 |
|
|
14
|
+
| :--- | :--- | :--- | :--- |
|
|
15
|
+
| - | - | - | 支持所有 ElDatePicker 属性 |
|
|
16
|
+
|
|
17
|
+
## 使用示例
|
|
18
|
+
|
|
19
|
+
```vue
|
|
20
|
+
<ja-date-picker type="date" placeholder="Pick a day" />
|
|
21
|
+
```
|
|
@@ -1,18 +1,36 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import dShortcut from "../../directives/shortcut";
|
|
3
3
|
import {ElButton, ElTooltip, ElDropdown, ElIcon} from "element-plus";
|
|
4
|
-
import {ref} from "vue";
|
|
4
|
+
import {ref, withDefaults, defineProps} from "vue";
|
|
5
5
|
import {ArrowDown} from "@element-plus/icons-vue";
|
|
6
6
|
|
|
7
|
-
const input = ref<typeof ElButton
|
|
8
|
-
const dropdown = ref<typeof ElDropdown
|
|
9
|
-
|
|
7
|
+
const input = ref<InstanceType<typeof ElButton>>()
|
|
8
|
+
const dropdown = ref<InstanceType<typeof ElDropdown>>()
|
|
9
|
+
|
|
10
|
+
export interface JaDropdownButtonProps {
|
|
11
|
+
/**
|
|
12
|
+
* 按钮提示
|
|
13
|
+
*/
|
|
10
14
|
tooltip?: string
|
|
15
|
+
/**
|
|
16
|
+
* 快捷键
|
|
17
|
+
*/
|
|
11
18
|
shortcut?: string
|
|
19
|
+
/**
|
|
20
|
+
* 按钮文本
|
|
21
|
+
*/
|
|
12
22
|
buttonText?: string
|
|
23
|
+
/**
|
|
24
|
+
* 提示位置
|
|
25
|
+
*/
|
|
13
26
|
tooltipPlacement?: 'top' | 'bottom'
|
|
27
|
+
/**
|
|
28
|
+
* 按钮类型
|
|
29
|
+
*/
|
|
14
30
|
type?: "default" | "success" | "warning" | "info" | "text" | "primary" | "danger"
|
|
15
|
-
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const props = withDefaults(defineProps<JaDropdownButtonProps>(), {
|
|
16
34
|
tooltipPlacement: 'top',
|
|
17
35
|
type: "default"
|
|
18
36
|
})
|
|
@@ -30,13 +48,13 @@ function onShortCut(el: HTMLElement) {
|
|
|
30
48
|
</script>
|
|
31
49
|
|
|
32
50
|
<template>
|
|
33
|
-
<el-tooltip :placement="tooltipPlacement">
|
|
51
|
+
<el-tooltip :placement="tooltipPlacement" :disabled="!tooltip && !shortcut">
|
|
34
52
|
<el-dropdown
|
|
35
53
|
size="default"
|
|
36
54
|
ref="dropdown"
|
|
37
55
|
trigger="click"
|
|
38
56
|
v-bind="$attrs">
|
|
39
|
-
<el-button ref="input" :type="type" size="default"
|
|
57
|
+
<el-button ref="input" :type="type" size="default"
|
|
40
58
|
v-shortcut:[shortcut]="onShortCut">
|
|
41
59
|
<template #default>
|
|
42
60
|
{{ props.buttonText }}
|