fx-platform-ui 1.0.3 → 1.0.4-alpha1
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/lib/components/upload/index.d.ts +2 -0
- package/lib/components/upload/src/hook/useUpload.d.ts +20 -0
- package/lib/components/upload/src/plat-upload-props.d.ts +131 -0
- package/lib/components/upload/src/types/acceptMax.d.ts +5 -0
- package/lib/components/upload/src/types/index.d.ts +1 -0
- package/lib/fx-platform-ui.mjs +4288 -83048
- package/lib/fx-platform-ui.umd.js +1 -202
- package/lib/style.css +1 -1
- package/package.json +19 -3
- package/packages/component.ts +13 -2
- package/packages/components/form/src/plat-form-props.ts +2 -1
- package/packages/components/table/src/index.vue +6 -2
- package/packages/components/table/src/plat-table-props.ts +6 -1
- package/packages/components/upload/index.ts +10 -0
- package/packages/components/upload/src/hook/useUpload.ts +133 -0
- package/packages/components/upload/src/index.vue +158 -0
- package/packages/components/upload/src/plat-upload-props.ts +80 -0
- package/packages/components/upload/src/types/acceptMax.ts +5 -0
- package/packages/components/upload/src/types/index.ts +1 -0
- package/lib/packages/components/table/src/hook/useTableMethods.d.ts +0 -21
- package/lib/src/env.d.ts +0 -8
- /package/lib/{packages/components → components}/area/index.d.ts +0 -0
- /package/lib/{packages/components → components}/area/src/index.vue.d.ts +0 -0
- /package/lib/{packages/components → components}/confirm/index.d.ts +0 -0
- /package/lib/{packages/components → components}/confirm/src/confirm.vue.d.ts +0 -0
- /package/lib/{packages/components → components}/confirm/src/index.d.ts +0 -0
- /package/lib/{packages/components → components}/editor/index.d.ts +0 -0
- /package/lib/{packages/components → components}/editor/src/hook/index.d.ts +0 -0
- /package/lib/{packages/components → components}/editor/src/hook/useEditorState.d.ts +0 -0
- /package/lib/{packages/components → components}/editor/src/index.vue.d.ts +0 -0
- /package/lib/{packages/components → components}/editor/src/plat-editor-emits.d.ts +0 -0
- /package/lib/{packages/components → components}/editor/src/plat-editor-props.d.ts +0 -0
- /package/lib/{packages/components → components}/editor/src/type/index.d.ts +0 -0
- /package/lib/{packages/components → components}/form/index.d.ts +0 -0
- /package/lib/{packages/components → components}/form/src/hook/index.d.ts +0 -0
- /package/lib/{packages/components → components}/form/src/hook/useFormContext.d.ts +0 -0
- /package/lib/{packages/components → components}/form/src/hook/useFormEvents.d.ts +0 -0
- /package/lib/{packages/components → components}/form/src/hook/useFormLabel.d.ts +0 -0
- /package/lib/{packages/components → components}/form/src/hook/useFormMethods.d.ts +0 -0
- /package/lib/{packages/components → components}/form/src/methods.d.ts +0 -0
- /package/lib/{packages/components → components}/form/src/plat-form-emits.d.ts +0 -0
- /package/lib/{packages/components → components}/form/src/types/form.d.ts +0 -0
- /package/lib/{packages/components → components}/form/src/types/index.d.ts +0 -0
- /package/lib/{packages/components → components}/modal/index.d.ts +0 -0
- /package/lib/{packages/components → components}/modal/src/confirm-modal.vue.d.ts +0 -0
- /package/lib/{packages/components → components}/modal/src/content.vue.d.ts +0 -0
- /package/lib/{packages/components → components}/modal/src/index.d.ts +0 -0
- /package/lib/{packages/components → components}/table/index.d.ts +0 -0
- /package/lib/{packages/components → components}/table/src/components/index.d.ts +0 -0
- /package/lib/{packages/components → components}/table/src/components/table-action.vue.d.ts +0 -0
- /package/lib/{packages/components → components}/table/src/components/tool-bar.vue.d.ts +0 -0
- /package/lib/{packages/components → components}/table/src/hook/index.d.ts +0 -0
- /package/lib/{packages/components → components}/table/src/hook/useTableForm.d.ts +0 -0
- /package/lib/{packages/components → components}/table/src/plat-table-emits.d.ts +0 -0
- /package/lib/{packages/components → components}/table/src/type/column.d.ts +0 -0
- /package/lib/{packages/components → components}/table/src/type/index.d.ts +0 -0
- /package/lib/{packages/components → components}/table/src/type/table.d.ts +0 -0
- /package/lib/{packages/components → components}/table/src/type/tableAction.d.ts +0 -0
- /package/lib/{packages/components → components}/tag-input/index.d.ts +0 -0
- /package/lib/{packages/components → components}/tag-input/src/index.vue.d.ts +0 -0
- /package/lib/{packages/index.d.ts → index.d.ts} +0 -0
- /package/lib/{packages/types → types}/global.d.ts +0 -0
- /package/lib/{packages/types → types}/index.d.ts +0 -0
- /package/lib/{packages/utils → utils}/dateUtil.d.ts +0 -0
- /package/lib/{packages/utils → utils}/index.d.ts +0 -0
- /package/lib/{packages/utils → utils}/is/index.d.ts +0 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div>
|
|
3
|
+
<a-upload
|
|
4
|
+
:accept="getStringAccept"
|
|
5
|
+
v-bind="omit(getProps, ['accept', 'api', 'onChange'])"
|
|
6
|
+
:before-upload="beforeUploadFn"
|
|
7
|
+
:custom-request="customRequest"
|
|
8
|
+
@change="uploadOnChange"
|
|
9
|
+
>
|
|
10
|
+
<template #default>
|
|
11
|
+
<a-button v-bind="getProps.uploadButtonProps">
|
|
12
|
+
<upload-outlined></upload-outlined> {{ getProps.uploadTitle }}
|
|
13
|
+
</a-button>
|
|
14
|
+
</template>
|
|
15
|
+
<template v-for="item in Object.keys($slots)" #[item]="data" :key="item">
|
|
16
|
+
<slot :name="item" v-bind="data || {}"></slot>
|
|
17
|
+
</template>
|
|
18
|
+
</a-upload>
|
|
19
|
+
</div>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script lang="ts" setup>
|
|
23
|
+
import { computed } from 'vue'
|
|
24
|
+
import { UploadOutlined } from '@ant-design/icons-vue'
|
|
25
|
+
import { omit, throttle } from 'lodash-es'
|
|
26
|
+
import { message, Upload } from 'ant-design-vue'
|
|
27
|
+
import { isFunction } from '../../../utils/is'
|
|
28
|
+
import { platUploadProps } from './plat-upload-props'
|
|
29
|
+
import { useUpload } from './hook/useUpload'
|
|
30
|
+
|
|
31
|
+
defineOptions({
|
|
32
|
+
name: 'PlUpload'
|
|
33
|
+
})
|
|
34
|
+
const props = defineProps(platUploadProps)
|
|
35
|
+
const emit = defineEmits(['change', 'beforeChange', 'error'])
|
|
36
|
+
|
|
37
|
+
const getProps = computed(() => props as Recordable)
|
|
38
|
+
|
|
39
|
+
const {
|
|
40
|
+
getStringAccept,
|
|
41
|
+
checkFileSize,
|
|
42
|
+
checkFileNumber,
|
|
43
|
+
checkFileNameLength,
|
|
44
|
+
checkFileType,
|
|
45
|
+
checkFileLimit
|
|
46
|
+
} = useUpload({
|
|
47
|
+
props
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
// 自定义上传判断
|
|
51
|
+
const customRequest = computed(() => {
|
|
52
|
+
// 没有api 且 当前属于循环上传
|
|
53
|
+
if (!isFunction(props.api) && props.polling) {
|
|
54
|
+
return null
|
|
55
|
+
}
|
|
56
|
+
return customRequestApi
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
// 计算属性判断是否循环上传,不同上传方式走的逻辑不一样
|
|
60
|
+
const beforeUploadFn = computed(() => {
|
|
61
|
+
if (props.polling) {
|
|
62
|
+
return beforeUpload
|
|
63
|
+
}
|
|
64
|
+
return beforeAllUpload
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
// 校验成功的文件
|
|
68
|
+
const uploadedSuccessFiles = new Set()
|
|
69
|
+
const beforeAllUpload = async (file, fileList) => {
|
|
70
|
+
if (file.uid === fileList[0].uid) {
|
|
71
|
+
uploadedSuccessFiles.clear()
|
|
72
|
+
}
|
|
73
|
+
try {
|
|
74
|
+
await Promise.all([
|
|
75
|
+
checkFileSize(file),
|
|
76
|
+
checkFileNumber(fileList),
|
|
77
|
+
checkFileNameLength(file),
|
|
78
|
+
checkFileType(file)
|
|
79
|
+
])
|
|
80
|
+
uploadedSuccessFiles.add(file)
|
|
81
|
+
} catch (error: any) {
|
|
82
|
+
emit('error', error)
|
|
83
|
+
const { text } = error
|
|
84
|
+
if (props.showErrorMsg) {
|
|
85
|
+
throttledShowErrorMessage(text)
|
|
86
|
+
}
|
|
87
|
+
return Upload.LIST_IGNORE
|
|
88
|
+
}
|
|
89
|
+
if (uploadedSuccessFiles.size === fileList.length) {
|
|
90
|
+
emit('beforeChange', fileList, uploadedSuccessFiles)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// 添加节流 防止多次弹窗
|
|
95
|
+
const throttledShowErrorMessage = throttle(
|
|
96
|
+
(text) => {
|
|
97
|
+
message.error(text)
|
|
98
|
+
},
|
|
99
|
+
1000,
|
|
100
|
+
{
|
|
101
|
+
leading: true,
|
|
102
|
+
trailing: false
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
// 上传前校验
|
|
107
|
+
const beforeUpload = async (file, fileList) => {
|
|
108
|
+
// promise.all全部判断
|
|
109
|
+
try {
|
|
110
|
+
const res = await Promise.all([
|
|
111
|
+
checkFileSize(file),
|
|
112
|
+
checkFileNumber(fileList),
|
|
113
|
+
checkFileNameLength(file),
|
|
114
|
+
checkFileType(file),
|
|
115
|
+
checkFileLimit(fileList)
|
|
116
|
+
])
|
|
117
|
+
return res
|
|
118
|
+
} catch (error: any) {
|
|
119
|
+
emit('error', error)
|
|
120
|
+
const { text } = error
|
|
121
|
+
if (props.showErrorMsg) {
|
|
122
|
+
throttledShowErrorMessage(text)
|
|
123
|
+
}
|
|
124
|
+
return Upload.LIST_IGNORE
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const uploadOnChange = (file) => {
|
|
129
|
+
emit('change', file)
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const customRequestApi = async (file) => {
|
|
133
|
+
if (!props.polling) {
|
|
134
|
+
return null
|
|
135
|
+
}
|
|
136
|
+
try {
|
|
137
|
+
const { data } = await props.api(
|
|
138
|
+
{
|
|
139
|
+
data: {
|
|
140
|
+
...(props.uploadParams || {})
|
|
141
|
+
},
|
|
142
|
+
file: file.file,
|
|
143
|
+
name: props.name
|
|
144
|
+
},
|
|
145
|
+
function onUploadProgress(progressEvent: ProgressEvent) {
|
|
146
|
+
const complete =
|
|
147
|
+
((progressEvent.loaded / progressEvent.total) * 100) | 0
|
|
148
|
+
file.onProgress({ percent: complete }, file)
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
file.onSuccess(data, file)
|
|
152
|
+
} catch (e) {
|
|
153
|
+
file.onError(e, file)
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
</script>
|
|
157
|
+
|
|
158
|
+
<style lang="less" scoped></style>
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { PropType, ExtractPropTypes } from 'vue'
|
|
2
|
+
import { uploadProps } from 'ant-design-vue/es/upload/interface'
|
|
3
|
+
import type { ButtonType } from 'ant-design-vue/es/button/buttonTypes'
|
|
4
|
+
import type { AcceptMax } from './types'
|
|
5
|
+
|
|
6
|
+
export const platUploadProps = {
|
|
7
|
+
...uploadProps(),
|
|
8
|
+
// 上传按钮名称
|
|
9
|
+
uploadTitle: {
|
|
10
|
+
type: String as PropType<string>,
|
|
11
|
+
default: '上传附件'
|
|
12
|
+
},
|
|
13
|
+
// 根据后缀,或者其他
|
|
14
|
+
accept: {
|
|
15
|
+
type: Array as PropType<string[]>,
|
|
16
|
+
default: () => []
|
|
17
|
+
},
|
|
18
|
+
// 上传提示
|
|
19
|
+
uploadTips: {
|
|
20
|
+
type: String as PropType<string>,
|
|
21
|
+
default: ''
|
|
22
|
+
},
|
|
23
|
+
// 文件最大多少 单位MB 默认2MB
|
|
24
|
+
maxSize: {
|
|
25
|
+
type: Number as PropType<number>,
|
|
26
|
+
default: 2
|
|
27
|
+
},
|
|
28
|
+
// 最大数量的文件 默认10个
|
|
29
|
+
maxNumber: {
|
|
30
|
+
type: Number as PropType<number>,
|
|
31
|
+
default: 10
|
|
32
|
+
},
|
|
33
|
+
// 上传附件的名称字符长度限制
|
|
34
|
+
maxFileNameLength: {
|
|
35
|
+
type: Number as PropType<number>,
|
|
36
|
+
default: 100
|
|
37
|
+
},
|
|
38
|
+
// 允许上传多个文件
|
|
39
|
+
multiple: {
|
|
40
|
+
type: Boolean as PropType<boolean>,
|
|
41
|
+
default: true
|
|
42
|
+
},
|
|
43
|
+
// 上传参数
|
|
44
|
+
uploadParams: {
|
|
45
|
+
type: Object as PropType<any>,
|
|
46
|
+
default: {}
|
|
47
|
+
},
|
|
48
|
+
// 上传api
|
|
49
|
+
api: {
|
|
50
|
+
type: Function as PropType<PromiseFn>,
|
|
51
|
+
default: null
|
|
52
|
+
},
|
|
53
|
+
// 发到后台的文件参数名
|
|
54
|
+
name: {
|
|
55
|
+
type: String as PropType<string>,
|
|
56
|
+
default: 'file'
|
|
57
|
+
},
|
|
58
|
+
// 是否循环上传,默认循环上传
|
|
59
|
+
polling: {
|
|
60
|
+
type: Boolean as PropType<boolean>,
|
|
61
|
+
default: true
|
|
62
|
+
},
|
|
63
|
+
// rms项目上传模式
|
|
64
|
+
rmsMaxFileArr: {
|
|
65
|
+
type: Array as PropType<AcceptMax[]>,
|
|
66
|
+
default: []
|
|
67
|
+
},
|
|
68
|
+
// 上传按钮配置项
|
|
69
|
+
uploadButtonProps: {
|
|
70
|
+
type: Object as PropType<Partial<ButtonType>>,
|
|
71
|
+
default: () => ({})
|
|
72
|
+
},
|
|
73
|
+
// 使用组件错误提示
|
|
74
|
+
showErrorMsg: {
|
|
75
|
+
type: Boolean as PropType<boolean>,
|
|
76
|
+
default: true
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export type PlatUploadProps = Partial<ExtractPropTypes<typeof platUploadProps>>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './acceptMax'
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { TableState } from './useTableState';
|
|
2
|
-
import type { PlatTableProps } from '../plat-table-props';
|
|
3
|
-
import type { VNode } from 'vue';
|
|
4
|
-
import type { OnChangeCallbackParams, TableColumn } from '../type';
|
|
5
|
-
export declare type UseTableMethodsContext = {
|
|
6
|
-
state: TableState;
|
|
7
|
-
props: PlatTableProps;
|
|
8
|
-
emit: any;
|
|
9
|
-
};
|
|
10
|
-
export declare const useTableMethods: ({ state, props, emit }: UseTableMethodsContext) => {
|
|
11
|
-
setProps: (props: any) => void;
|
|
12
|
-
getComponent: (comp: VNode | string) => VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
13
|
-
[key: string]: any;
|
|
14
|
-
}>;
|
|
15
|
-
handleSubmit: (params: any, page?: number) => void;
|
|
16
|
-
handleTableChange: (...rest: OnChangeCallbackParams) => Promise<void>;
|
|
17
|
-
getColumnKey: (column: TableColumn) => string | number;
|
|
18
|
-
fetchData: (params?: {}, rest?: OnChangeCallbackParams) => any;
|
|
19
|
-
getQueryFormRef: () => any;
|
|
20
|
-
reload: (resetPageIndex?: boolean) => any;
|
|
21
|
-
};
|
package/lib/src/env.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/// <reference types="vite/client" />
|
|
2
|
-
|
|
3
|
-
declare module '*.vue' {
|
|
4
|
-
import type { DefineComponent } from 'vue'
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/ban-types
|
|
6
|
-
const component: DefineComponent<{}, {}, any>
|
|
7
|
-
export default component
|
|
8
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|