@jari-ace/element-plus-component 0.3.4 → 0.4.1

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.
Files changed (127) hide show
  1. package/dist/components/autoComplete/JaAutoComplete.vue.d.ts +543 -686
  2. package/dist/components/autoComplete/JaAutoComplete.vue.d.ts.map +1 -1
  3. package/dist/components/autoComplete/JaAutoComplete.vue.js +10 -2
  4. package/dist/components/autoComplete/JaAutoComplete.vue.js.map +1 -1
  5. package/dist/components/avatar/JaAvatar.vue.d.ts +4 -3
  6. package/dist/components/avatar/JaAvatar.vue.d.ts.map +1 -1
  7. package/dist/components/avatar/JaAvatar.vue.js +10 -2
  8. package/dist/components/avatar/JaAvatar.vue.js.map +1 -1
  9. package/dist/components/button/JaButton.vue.d.ts +184 -250
  10. package/dist/components/button/JaButton.vue.d.ts.map +1 -1
  11. package/dist/components/button/JaButton.vue.js +11 -3
  12. package/dist/components/button/JaButton.vue.js.map +1 -1
  13. package/dist/components/checkbox/JaCheckbox.vue.d.ts +164 -1068
  14. package/dist/components/checkbox/JaCheckbox.vue.d.ts.map +1 -1
  15. package/dist/components/checkbox/JaCheckbox.vue.js +9 -24
  16. package/dist/components/checkbox/JaCheckbox.vue.js.map +1 -1
  17. package/dist/components/checkboxGroup/JaCheckboxGroup.vue.d.ts +158 -163
  18. package/dist/components/checkboxGroup/JaCheckboxGroup.vue.d.ts.map +1 -1
  19. package/dist/components/checkboxGroup/JaCheckboxGroup.vue.js +14 -5
  20. package/dist/components/checkboxGroup/JaCheckboxGroup.vue.js.map +1 -1
  21. package/dist/components/datePicker/JaDatePicker.vue.d.ts +7 -4
  22. package/dist/components/datePicker/JaDatePicker.vue.d.ts.map +1 -1
  23. package/dist/components/datePicker/JaDatePicker.vue.js +18 -7
  24. package/dist/components/datePicker/JaDatePicker.vue.js.map +1 -1
  25. package/dist/components/dropdownButton/JaDropdownButton.vue.d.ts +324 -399
  26. package/dist/components/dropdownButton/JaDropdownButton.vue.d.ts.map +1 -1
  27. package/dist/components/dropdownButton/JaDropdownButton.vue.js +4 -2
  28. package/dist/components/dropdownButton/JaDropdownButton.vue.js.map +1 -1
  29. package/dist/components/form/JaForm.vue.d.ts +52 -3
  30. package/dist/components/form/JaForm.vue.d.ts.map +1 -1
  31. package/dist/components/form/JaForm.vue.js +4 -2
  32. package/dist/components/form/JaForm.vue.js.map +1 -1
  33. package/dist/components/formItem/JaFormItem.vue.d.ts +168 -133
  34. package/dist/components/formItem/JaFormItem.vue.d.ts.map +1 -1
  35. package/dist/components/formItem/JaFormItem.vue.js.map +1 -1
  36. package/dist/components/input/JaInput.vue.d.ts +274 -421
  37. package/dist/components/input/JaInput.vue.d.ts.map +1 -1
  38. package/dist/components/input/JaInput.vue.js +20 -60
  39. package/dist/components/input/JaInput.vue.js.map +1 -1
  40. package/dist/components/inputI18n/JaInputI18n.vue.d.ts +70 -70
  41. package/dist/components/inputNumber/JaInputNumber.vue.d.ts +203 -217
  42. package/dist/components/inputNumber/JaInputNumber.vue.d.ts.map +1 -1
  43. package/dist/components/inputNumber/JaInputNumber.vue.js +16 -37
  44. package/dist/components/inputNumber/JaInputNumber.vue.js.map +1 -1
  45. package/dist/components/radioGroup/JaRadioGroup.vue.d.ts +148 -121
  46. package/dist/components/radioGroup/JaRadioGroup.vue.d.ts.map +1 -1
  47. package/dist/components/radioGroup/JaRadioGroup.vue.js +14 -5
  48. package/dist/components/radioGroup/JaRadioGroup.vue.js.map +1 -1
  49. package/dist/components/scrollbar/Scrollbar.vue.d.ts +5 -2
  50. package/dist/components/scrollbar/Scrollbar.vue.d.ts.map +1 -1
  51. package/dist/components/scrollbar/Scrollbar.vue.js +11 -3
  52. package/dist/components/scrollbar/Scrollbar.vue.js.map +1 -1
  53. package/dist/components/select/JaSelect.vue.d.ts +70 -70
  54. package/dist/components/select/JaSelect.vue.js +14 -5
  55. package/dist/components/select/JaSelect.vue.js.map +1 -1
  56. package/dist/components/switch/JaSwitch.vue.d.ts +174 -205
  57. package/dist/components/switch/JaSwitch.vue.d.ts.map +1 -1
  58. package/dist/components/switch/JaSwitch.vue.js +13 -4
  59. package/dist/components/switch/JaSwitch.vue.js.map +1 -1
  60. package/dist/components/timePicker/JaTimePicker.vue.d.ts +5 -2
  61. package/dist/components/timePicker/JaTimePicker.vue.d.ts.map +1 -1
  62. package/dist/components/timePicker/JaTimePicker.vue.js +18 -7
  63. package/dist/components/timePicker/JaTimePicker.vue.js.map +1 -1
  64. package/dist/components/tip/index.d.ts +3 -12
  65. package/dist/components/tip/index.d.ts.map +1 -1
  66. package/dist/components/tip/src/AceTip.vue.d.ts +9 -3
  67. package/dist/components/tip/src/AceTip.vue.d.ts.map +1 -1
  68. package/dist/components/tip/src/AceTip.vue.js.map +1 -1
  69. package/dist/components/upload/FilePreviewer.vue.d.ts +59 -0
  70. package/dist/components/upload/FilePreviewer.vue.d.ts.map +1 -0
  71. package/dist/components/upload/FilePreviewer.vue.js +169 -0
  72. package/dist/components/upload/FilePreviewer.vue.js.map +1 -0
  73. package/dist/components/upload/JaUploader.vue.d.ts +74 -14
  74. package/dist/components/upload/JaUploader.vue.d.ts.map +1 -1
  75. package/dist/components/upload/JaUploader.vue.js +3 -5
  76. package/dist/components/upload/JaUploader.vue.js.map +1 -1
  77. package/dist/components/upload/index.d.ts +102 -25
  78. package/dist/components/upload/index.d.ts.map +1 -1
  79. package/dist/components/upload/index.js +2 -0
  80. package/dist/components/upload/index.js.map +1 -1
  81. package/dist/components/upload/uploader.vue.d.ts +16 -0
  82. package/dist/components/upload/uploader.vue.d.ts.map +1 -1
  83. package/dist/components/upload/uploader.vue.js +46 -41
  84. package/dist/components/upload/uploader.vue.js.map +1 -1
  85. package/lib/index.css +2 -2
  86. package/lib/index.js +7439 -6984
  87. package/lib/index.umd.cjs +34 -34
  88. package/package.json +1 -1
  89. package/packages/components/autoComplete/JaAutoComplete.vue +19 -9
  90. package/packages/components/autoComplete/README.md +35 -0
  91. package/packages/components/avatar/JaAvatar.vue +16 -7
  92. package/packages/components/avatar/README.md +45 -0
  93. package/packages/components/button/JaButton.vue +32 -7
  94. package/packages/components/button/README.md +57 -0
  95. package/packages/components/checkbox/JaCheckbox.vue +15 -25
  96. package/packages/components/checkbox/README.md +21 -0
  97. package/packages/components/checkboxGroup/JaCheckboxGroup.vue +16 -5
  98. package/packages/components/checkboxGroup/README.md +24 -0
  99. package/packages/components/datePicker/JaDatePicker.vue +23 -10
  100. package/packages/components/datePicker/README.md +21 -0
  101. package/packages/components/dropdownButton/JaDropdownButton.vue +25 -7
  102. package/packages/components/dropdownButton/README.md +30 -0
  103. package/packages/components/form/JaForm.vue +60 -20
  104. package/packages/components/form/README.md +30 -0
  105. package/packages/components/formItem/JaFormItem.vue +43 -7
  106. package/packages/components/formItem/README.md +28 -0
  107. package/packages/components/input/JaInput.vue +30 -66
  108. package/packages/components/input/README.md +23 -0
  109. package/packages/components/inputNumber/JaInputNumber.vue +25 -45
  110. package/packages/components/inputNumber/README.md +21 -0
  111. package/packages/components/radioGroup/JaRadioGroup.vue +16 -5
  112. package/packages/components/radioGroup/README.md +24 -0
  113. package/packages/components/scrollbar/README.md +23 -0
  114. package/packages/components/scrollbar/Scrollbar.vue +14 -3
  115. package/packages/components/select/JaSelect.vue +22 -10
  116. package/packages/components/select/README.md +24 -0
  117. package/packages/components/switch/JaSwitch.vue +16 -5
  118. package/packages/components/switch/README.md +21 -0
  119. package/packages/components/timePicker/JaTimePicker.vue +21 -8
  120. package/packages/components/timePicker/README.md +21 -0
  121. package/packages/components/tip/README.md +20 -0
  122. package/packages/components/tip/src/AceTip.vue +10 -2
  123. package/packages/components/upload/FilePreviewer.vue +245 -0
  124. package/packages/components/upload/JaUploader.vue +9 -8
  125. package/packages/components/upload/README.md +24 -0
  126. package/packages/components/upload/index.ts +2 -0
  127. package/packages/components/upload/uploader.vue +68 -44
@@ -0,0 +1,24 @@
1
+ # JaRadioGroup 单选框组组件
2
+
3
+ `JaRadioGroup` 是对 Element Plus `ElRadioGroup` 的封装,集成了 `JaForm` 表单上下文注入。
4
+
5
+ ## 组件用途
6
+
7
+ 用于在 `JaForm` 中创建单选框组,自动绑定数据模型。
8
+
9
+ ## 属性 API
10
+
11
+ 该组件继承了 [ElRadioGroup](https://element-plus.org/zh-CN/component/radio.html#radiogroup-attributes) 的所有属性。
12
+
13
+ | 属性名 | 类型 | 默认值 | 说明 |
14
+ | :--- | :--- | :--- | :--- |
15
+ | - | - | - | 支持所有 ElRadioGroup 属性 |
16
+
17
+ ## 使用示例
18
+
19
+ ```vue
20
+ <ja-radio-group>
21
+ <el-radio :label="3">Option A</el-radio>
22
+ <el-radio :label="6">Option B</el-radio>
23
+ </ja-radio-group>
24
+ ```
@@ -0,0 +1,23 @@
1
+ # Scrollbar 滚动条组件
2
+
3
+ `Scrollbar` 是对 Element Plus `ElScrollbar` 的扩展,支持可视区域检测(Intersection Observer)。
4
+
5
+ ## 组件用途
6
+
7
+ 用于内容滚动,并支持检测子元素是否在可视区域内(用于懒加载等场景)。
8
+
9
+ ## 属性 API
10
+
11
+ 该组件继承了 [ElScrollbar](https://element-plus.org/zh-CN/component/scrollbar.html#scrollbar-attributes) 的所有属性。
12
+
13
+ | 属性名 | 类型 | 默认值 | 说明 |
14
+ | :--- | :--- | :--- | :--- |
15
+ | - | - | - | 支持所有 ElScrollbar 属性 |
16
+
17
+ ## 使用示例
18
+
19
+ ```vue
20
+ <scrollbar height="400px">
21
+ <div v-for="item in 100" :key="item">{{ item }}</div>
22
+ </scrollbar>
23
+ ```
@@ -1,11 +1,18 @@
1
1
  <script setup lang="ts">
2
2
  import {ElScrollbar} from "element-plus";
3
- import {nextTick, onMounted, onUnmounted, provide, type Ref, ref, watch} from "vue";
3
+ import type { ScrollbarProps } from "element-plus";
4
+ import {nextTick, onMounted, onUnmounted, provide, type Ref, ref, watch, computed} from "vue";
4
5
  import {
5
6
  SCROLL_BAR_WRAPPED_INJECT_KEY,
6
7
  type ScrollbarWrapped
7
8
  } from "./utils";
8
9
 
10
+ export interface JaScrollbarProps extends Partial<ScrollbarProps> {
11
+ // Custom props if any
12
+ }
13
+
14
+ const props = defineProps<JaScrollbarProps>()
15
+
9
16
  const scroll = ref<InstanceType<typeof ElScrollbar>>();
10
17
  const wrappedItems: Ref<ScrollbarWrapped[]> = ref([]);
11
18
  const wrappedItemsMap: Map<Element, ScrollbarWrapped> = new Map();
@@ -35,7 +42,7 @@ const observer = new IntersectionObserver((entries) => {
35
42
  async function observeWrappedItemInView() {
36
43
  await nextTick();
37
44
  const wrap = scroll.value?.$el;
38
- if (!wrappedItems.value) return;
45
+ if (!wrappedItems.value || !wrap) return;
39
46
  try {
40
47
  for (let i = 0; i < wrappedItems.value.length; i++) {
41
48
  if (wrappedItems.value[i]) {
@@ -74,11 +81,15 @@ onUnmounted(() => {
74
81
  })
75
82
  })
76
83
 
84
+ const elementProps = computed(() => {
85
+ return props
86
+ })
87
+
77
88
  </script>
78
89
 
79
90
  <template>
80
91
  <el-scrollbar ref="scroll" class="scroll-container"
81
- v-bind="$attrs">
92
+ v-bind="{ ...elementProps, ...$attrs }">
82
93
  <template v-for="(_, name) in $slots" v-slot:[name]>
83
94
  <slot :name="name"></slot>
84
95
  </template>
@@ -1,36 +1,48 @@
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 {ElSelect} from "element-plus";
5
+ import type { SelectProps } from 'element-plus'
5
6
  import type {EpPropFinalized} from "element-plus/es/utils";
6
7
  import {getValue, setValue} from "../../utils/objectUtils";
7
8
 
8
- const input = ref<typeof ElSelect>({} as typeof ElSelect)
9
+ const input = ref<InstanceType<typeof ElSelect>>()
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
12
13
  const emit = defineEmits<{
13
- change: [value: string]
14
+ change: [value: any]
14
15
  }>()
15
16
 
16
- function onChange(value: string) {
17
+ export interface JaSelectProps extends Partial<SelectProps> {
18
+ }
19
+
20
+ const props = defineProps<JaSelectProps>()
21
+
22
+ function onChange(value: any) {
17
23
  validator.removeFieldError(prop)
18
24
  setValue(model.formData, prop, mv.value);
19
25
  emit('change', value)
20
26
  }
21
27
 
22
- type modelType = EpPropFinalized<(ArrayConstructor | ObjectConstructor | NumberConstructor | BooleanConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
28
+ // type modelType = EpPropFinalized<(ArrayConstructor | ObjectConstructor | NumberConstructor | BooleanConstructor | StringConstructor)[], unknown, unknown, undefined, boolean>;
29
+ type ModelType = any; // Select value can be complex
23
30
 
24
- const mv = ref(getValue(model.formData, prop) as modelType);
31
+ const mv = ref(getValue(model.formData, prop) as ModelType);
25
32
  watch(() => model.formData, () => {
26
- mv.value = getValue(model.formData, prop) as modelType
33
+ mv.value = getValue(model.formData, prop) as ModelType
27
34
  }, {
28
35
  deep: true
29
36
  })
30
37
 
38
+ const elementProps = computed(() => {
39
+ const { modelValue, ...rest } = props as any
40
+ return rest
41
+ })
42
+
31
43
  defineExpose({
32
- focus: () => input.value.focus(),
33
- blur: () => input.value.blur(),
44
+ focus: () => input.value?.focus?.(),
45
+ blur: () => input.value?.blur?.(),
34
46
  elSelect: input
35
47
  })
36
48
  </script>
@@ -40,7 +52,7 @@ defineExpose({
40
52
  ref="input"
41
53
  v-model="mv"
42
54
  @change="onChange"
43
- v-bind="$attrs">
55
+ v-bind="{ ...elementProps, ...$attrs }">
44
56
  <template v-for="(_, name) in $slots" v-slot:[name]>
45
57
  <slot :name="name"></slot>
46
58
  </template>
@@ -0,0 +1,24 @@
1
+ # JaSelect 选择器组件
2
+
3
+ `JaSelect` 是对 Element Plus `ElSelect` 的封装,集成了 `JaForm` 表单上下文注入。
4
+
5
+ ## 组件用途
6
+
7
+ 用于在 `JaForm` 中进行选择,自动绑定数据模型。
8
+
9
+ ## 属性 API
10
+
11
+ 该组件继承了 [ElSelect](https://element-plus.org/zh-CN/component/select.html#select-attributes) 的所有属性。
12
+
13
+ | 属性名 | 类型 | 默认值 | 说明 |
14
+ | :--- | :--- | :--- | :--- |
15
+ | - | - | - | 支持所有 ElSelect 属性 |
16
+
17
+ ## 使用示例
18
+
19
+ ```vue
20
+ <ja-select>
21
+ <el-option label="Zone 1" value="shanghai" />
22
+ <el-option label="Zone 2" value="beijing" />
23
+ </ja-select>
24
+ ```
@@ -1,11 +1,12 @@
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 {ElSwitch} from "element-plus";
5
+ import type { SwitchProps } from 'element-plus'
5
6
  import {getValue, setValue} from "../../utils/objectUtils";
6
7
  import type {EpPropMergeType} from "element-plus/es/utils";
7
8
 
8
- const input = ref<typeof ElSwitch>()
9
+ const input = ref<InstanceType<typeof ElSwitch>>()
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
@@ -13,6 +14,11 @@ const emit = defineEmits<{
13
14
  change: [value: boolean | string | number]
14
15
  }>()
15
16
 
17
+ export interface JaSwitchProps extends Partial<SwitchProps> {
18
+ }
19
+
20
+ const props = defineProps<JaSwitchProps>()
21
+
16
22
  function onChange(value: boolean | string | number) {
17
23
  validator.removeFieldError(prop)
18
24
  setValue(model.formData, prop, mv.value);
@@ -30,9 +36,14 @@ watch(() => model.formData, () => {
30
36
  deep: true
31
37
  })
32
38
 
39
+ const elementProps = computed(() => {
40
+ const { modelValue, ...rest } = props
41
+ return rest
42
+ })
43
+
33
44
  defineExpose({
34
- focus: () => input.value?.focus(),
35
- blur: () => input.value?.blur(),
45
+ focus: () => (input.value as any)?.focus?.(),
46
+ blur: () => (input.value as any)?.blur?.(),
36
47
  elSwitch: input
37
48
  })
38
49
  </script>
@@ -42,7 +53,7 @@ defineExpose({
42
53
  ref="input"
43
54
  v-model="mv"
44
55
  @change="onChange"
45
- v-bind="$attrs">
56
+ v-bind="{ ...elementProps, ...$attrs }">
46
57
  <template v-for="(_, name) in $slots" v-slot:[name]>
47
58
  <slot :name="name"></slot>
48
59
  </template>
@@ -0,0 +1,21 @@
1
+ # JaSwitch 开关组件
2
+
3
+ `JaSwitch` 是对 Element Plus `ElSwitch` 的封装,集成了 `JaForm` 表单上下文注入。
4
+
5
+ ## 组件用途
6
+
7
+ 用于在 `JaForm` 中切换状态,自动绑定数据模型。
8
+
9
+ ## 属性 API
10
+
11
+ 该组件继承了 [ElSwitch](https://element-plus.org/zh-CN/component/switch.html#switch-attributes) 的所有属性。
12
+
13
+ | 属性名 | 类型 | 默认值 | 说明 |
14
+ | :--- | :--- | :--- | :--- |
15
+ | - | - | - | 支持所有 ElSwitch 属性 |
16
+
17
+ ## 使用示例
18
+
19
+ ```vue
20
+ <ja-switch />
21
+ ```
@@ -1,10 +1,11 @@
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 {ElTimePicker} from "element-plus";
5
+ import type { TimePickerDefaultProps } from 'element-plus'
5
6
  import {getValue, setValue} from "../../utils/objectUtils";
6
7
 
7
- const input = ref<typeof ElTimePicker>({} as typeof ElTimePicker)
8
+ const input = ref<InstanceType<typeof ElTimePicker>>()
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
@@ -12,6 +13,11 @@ const emit = defineEmits<{
12
13
  change: [value: string]
13
14
  }>()
14
15
 
16
+ export interface JaTimePickerProps extends Partial<TimePickerDefaultProps> {
17
+ }
18
+
19
+ const props = defineProps<JaTimePickerProps>()
20
+
15
21
  const exposeMethods = ref<any>({})
16
22
 
17
23
  function onChange(value: string) {
@@ -20,7 +26,7 @@ function onChange(value: string) {
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
- const refMethods = Object.entries(input.value).filter(([_, v]) => v instanceof Function);
34
- refMethods.forEach(([key, val]) => {
35
- exposeMethods.value[key] = val;
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="$attrs">
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
+ # JaTimePicker 时间选择器组件
2
+
3
+ `JaTimePicker` 是对 Element Plus `ElTimePicker` 的封装,集成了 `JaForm` 表单上下文注入。
4
+
5
+ ## 组件用途
6
+
7
+ 用于在 `JaForm` 中选择时间,自动绑定数据模型。
8
+
9
+ ## 属性 API
10
+
11
+ 该组件继承了 [ElTimePicker](https://element-plus.org/zh-CN/component/time-picker.html#timepicker-attributes) 的所有属性。
12
+
13
+ | 属性名 | 类型 | 默认值 | 说明 |
14
+ | :--- | :--- | :--- | :--- |
15
+ | - | - | - | 支持所有 ElTimePicker 属性 |
16
+
17
+ ## 使用示例
18
+
19
+ ```vue
20
+ <ja-time-picker placeholder="Arbitrary time" />
21
+ ```
@@ -0,0 +1,20 @@
1
+ # AceTip 提示组件
2
+
3
+ `AceTip` 是一个简单的提示信息展示组件。
4
+
5
+ ## 组件用途
6
+
7
+ 用于显示警告、提示或说明信息。
8
+
9
+ ## 属性 API
10
+
11
+ | 属性名 | 类型 | 默认值 | 说明 |
12
+ | :--- | :--- | :--- | :--- |
13
+ | `type` | `'primary' \| 'success' \| 'warning' \| 'danger' \| 'info'` | `'primary'` | 提示类型(颜色) |
14
+ | `text` | `string` | `''` | 提示文本 |
15
+
16
+ ## 使用示例
17
+
18
+ ```vue
19
+ <ace-tip type="warning" text="请注意,此操作不可逆!" />
20
+ ```
@@ -14,10 +14,18 @@
14
14
  </template>
15
15
 
16
16
  <script setup lang="ts">
17
- const props = withDefaults(defineProps<{
17
+ export interface AceTipProps {
18
+ /**
19
+ * 提示类型
20
+ */
18
21
  type?: "primary" | "success" | "warning" | "danger" | "info";
22
+ /**
23
+ * 提示文本
24
+ */
19
25
  text?: string;
20
- }>(), {
26
+ }
27
+
28
+ const props = withDefaults(defineProps<AceTipProps>(), {
21
29
  type: "primary",
22
30
  text: "",
23
31
  });
@@ -0,0 +1,245 @@
1
+ <!--
2
+ - 版权所有 (c) 2026 江苏杰瑞信息科技有限公司
3
+ -
4
+ - 此文件属于JARI.ACE平台项目,修改、分发必须遵守杰瑞信科商业软件许可协议
5
+ -
6
+ -->
7
+
8
+ <!--
9
+ * FilePreviewer 组件
10
+ *
11
+ * 用途:用于根据 attachToken 预览附件列表中的第一个可预览文件
12
+ *
13
+ * 功能特点:
14
+ * - 自动获取附件列表并识别可预览文件
15
+ * - 支持多种文件格式预览(PDF、Office文档、图片等)
16
+ * - 使用 Element Plus 按钮组件,支持完整的外观自定义
17
+ * - 集成 PdfViewerModal 进行文件预览
18
+ *
19
+ * 使用示例:
20
+ *
21
+ * 基础用法:
22
+ * <FilePreviewer attachToken="your-attach-token" />
23
+ *
24
+ * 自定义按钮外观:
25
+ * <FilePreviewer
26
+ * attachToken="your-attach-token"
27
+ * buttonType="primary"
28
+ * buttonSize="medium"
29
+ * buttonText="查看文件"
30
+ * buttonIcon="View"
31
+ * />
32
+ *
33
+ * 高级自定义:
34
+ * <FilePreviewer
35
+ * attachToken="your-attach-token"
36
+ * buttonClass="my-custom-button"
37
+ * buttonRound
38
+ * buttonPlain={false}
39
+ * />
40
+ -->
41
+
42
+ <script setup lang="ts">
43
+ import {createAxiosWithoutCache, type FileInfo, useFilesApi} from "@jari-ace/app-bolts";
44
+ import {computed, ref} from "vue";
45
+ import {ElButton} from "element-plus";
46
+ import PdfViewerModal from "./pdf-viewer/PdfViewerModal.vue";
47
+
48
+ /**
49
+ * FilePreviewer 组件属性定义
50
+ *
51
+ * @property {string} attachToken - 附件令牌,用于获取文件列表(必需)
52
+ * @property {string} [buttonType='warning'] - 按钮类型,可选值:primary/success/warning/danger/info
53
+ * @property {string} [buttonSize='small'] - 按钮尺寸,可选值:large/medium/small
54
+ * @property {boolean} [buttonPlain=true] - 是否使用朴素按钮样式
55
+ * @property {boolean} [buttonRound=false] - 是否圆角按钮
56
+ * @property {boolean} [buttonCircle=false] - 是否圆形按钮
57
+ * @property {boolean} [buttonDisabled=false] - 按钮是否禁用
58
+ * @property {any} [buttonIcon] - 按钮图标,可以是 Element Plus 图标组件
59
+ * @property {string} [buttonText='预览'] - 按钮文本内容
60
+ * @property {string} [buttonClass] - 自定义按钮 CSS 类名
61
+ */
62
+ const props = defineProps<{
63
+ /**
64
+ * 附件令牌
65
+ */
66
+ attachToken: string,
67
+ /**
68
+ * 按钮类型
69
+ */
70
+ buttonType?: 'primary' | 'success' | 'warning' | 'danger' | 'info' | 'text' | 'default',
71
+ /**
72
+ * 按钮尺寸
73
+ */
74
+ buttonSize?: string,
75
+ /**
76
+ * 按钮是否朴素
77
+ */
78
+ buttonPlain?: boolean,
79
+ /**
80
+ * 按钮是否圆角
81
+ */
82
+ buttonRound?: boolean,
83
+ /**
84
+ * 按钮是否圆形
85
+ */
86
+ buttonCircle?: boolean,
87
+ /**
88
+ * 按钮是否禁用
89
+ */
90
+ buttonDisabled?: boolean,
91
+ /**
92
+ * 按钮图标
93
+ */
94
+ buttonIcon?: any,
95
+ /**
96
+ * 按钮文本
97
+ */
98
+ buttonText?: string,
99
+ /**
100
+ * 按钮类名
101
+ */
102
+ buttonClass?: string,
103
+ }>();
104
+
105
+ /**
106
+ * 组件内部状态管理
107
+ */
108
+ const axios = createAxiosWithoutCache();
109
+ const api = useFilesApi(axios);
110
+ const files = ref<FileInfo[]>([]); // 存储文件列表
111
+ const pdfViewerVisible = ref(false); // 控制 PDF 查看器模态框显示
112
+ const pdfSrc = ref(""); // PDF 文件源地址
113
+ const loading = ref(false); // 加载状态
114
+
115
+ /**
116
+ * 按钮属性计算属性
117
+ * 用于处理 Element Plus 按钮的类型安全
118
+ */
119
+ const buttonProps = computed(() => (
120
+ {
121
+ type: (
122
+ props.buttonType || 'warning'
123
+ ) as any,
124
+ size: (
125
+ props.buttonSize || 'small'
126
+ ) as any
127
+ }
128
+ ));
129
+
130
+ /**
131
+ * 可预览文件扩展名列表
132
+ * 支持多种文档格式:Office文档、PDF、图片、文本等
133
+ */
134
+ const previewableFileExts = [".doc", ".docx", ".xls", ".xlsx", ".wps", ".et",
135
+ ".csv", ".txt", ".rtf", ".odt", "ods", ".mht", ".ppt", ".pptx", ".odp", ".pdf", "xps", "."];
136
+
137
+ /**
138
+ * 计算属性:检查是否存在可预览的文件
139
+ * 遍历文件列表,检查是否有文件扩展名在可预览列表中
140
+ */
141
+ const hasPreviewableFiles = computed(() => {
142
+ return files.value.some(file => previewableFileExts.some(ext => file.fileName.endsWith(ext)));
143
+ });
144
+
145
+ /**
146
+ * 计算属性:获取第一个可预览的文件
147
+ * 用于确定要预览哪个文件
148
+ */
149
+ const firstPreviewableFile = computed(() => {
150
+ return files.value.find(file => previewableFileExts.some(ext => file.fileName.endsWith(ext)));
151
+ });
152
+
153
+ /**
154
+ * 加载文件列表
155
+ * 根据 attachToken 从服务器获取关联的文件列表
156
+ *
157
+ * @async
158
+ * @returns {Promise<void>}
159
+ */
160
+ async function loadFileInfos() {
161
+ if (!props.attachToken) {
162
+ files.value = [];
163
+ return;
164
+ }
165
+
166
+ try {
167
+ loading.value = true;
168
+ files.value = await api.getFileList(props.attachToken);
169
+ } catch (error) {
170
+ console.error('Failed to load file list:', error);
171
+ files.value = [];
172
+ } finally {
173
+ loading.value = false;
174
+ }
175
+ }
176
+
177
+ /**
178
+ * 预览第一个可预览的文件
179
+ * 构建预览 URL 并显示 PDF 查看器模态框
180
+ *
181
+ * @returns {void}
182
+ */
183
+ function previewFirstFile() {
184
+ const file = firstPreviewableFile.value;
185
+ if (!file) {
186
+ console.warn('No previewable files found');
187
+ return;
188
+ }
189
+
190
+ // 构建预览 URL,使用文件 token 或 ID
191
+ pdfSrc.value = new URL("uploads/preview/" + (
192
+ file.token || file.id
193
+ ), location.origin).toString();
194
+ pdfViewerVisible.value = true;
195
+ }
196
+
197
+ /**
198
+ * 组件初始化
199
+ * 自动加载文件列表
200
+ */
201
+ loadFileInfos();
202
+ </script>
203
+
204
+ <template>
205
+ <div class="file-previewer">
206
+ <!--
207
+ * 预览按钮
208
+ * 支持完整的 Element Plus 按钮属性自定义
209
+ * 当没有可预览文件时会自动禁用
210
+ * 点击时触发 previewFirstFile 函数
211
+ -->
212
+ <ElButton
213
+ :type="buttonProps.type"
214
+ :size="buttonProps.size"
215
+ :plain="buttonPlain !== undefined ? buttonPlain : true"
216
+ :round="buttonRound"
217
+ :circle="buttonCircle"
218
+ :loading="loading"
219
+ :disabled="buttonDisabled || !hasPreviewableFiles"
220
+ :icon="buttonIcon"
221
+ :class="buttonClass"
222
+ @click="previewFirstFile"
223
+ link>
224
+ {{ buttonText || '预览' }}
225
+ </ElButton>
226
+
227
+ <!--
228
+ * PDF 查看器模态框
229
+ * 用于显示可预览文件的内容
230
+ * 支持全屏显示和响应式布局
231
+ -->
232
+ <PdfViewerModal :src="pdfSrc" v-model="pdfViewerVisible"></PdfViewerModal>
233
+ </div>
234
+ </template>
235
+
236
+ <style lang="scss" scoped>
237
+ /**
238
+ * FilePreviewer 组件样式
239
+ * 使用内联块级显示,使按钮可以与其他元素并排显示
240
+ * 保持简洁的样式,让按钮本身的样式起主导作用
241
+ */
242
+ .file-previewer {
243
+ display: inline-block;
244
+ }
245
+ </style>
@@ -1,9 +1,10 @@
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 {getValue, setValue} from "../../utils/objectUtils";
5
5
  import Uploader from "./uploader.vue";
6
- const props = defineProps<{
6
+
7
+ export interface JaUploaderProps {
7
8
  /**
8
9
  * 应用名
9
10
  */
@@ -17,7 +18,7 @@ const props = defineProps<{
17
18
  */
18
19
  attachToken?: string,
19
20
  /**
20
- * 数据密集
21
+ * 数据密级
21
22
  */
22
23
  classificationLevel?: number,
23
24
  /**
@@ -28,8 +29,10 @@ const props = defineProps<{
28
29
  * 文件列表最大高度
29
30
  */
30
31
  maxHeight?: string | number
31
- }>();
32
- const input = ref<typeof Uploader>({} as typeof Uploader)
32
+ }
33
+
34
+ const props = defineProps<JaUploaderProps>();
35
+ const input = ref<InstanceType<typeof Uploader>>()
33
36
  const model = inject('aceFormModel') as Record<string, any>
34
37
  const prop = inject('aceFormItemProp') as string
35
38
  const validator = inject('aceFormValidator') as ValidationInstance
@@ -53,9 +56,7 @@ watch(() => model.formData, () => {
53
56
  })
54
57
 
55
58
  defineExpose({
56
- focus: () => input.value.focus(),
57
- blur: () => input.value.blur(),
58
- elSelect: input
59
+ uploader: input
59
60
  })
60
61
  </script>
61
62