adtec-core-package 0.4.2 → 0.4.3
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/README.en.md +36 -36
- package/package.json +59 -59
- package/src/api/BasicApi.ts +17 -17
- package/src/api/DocumentApi.ts +27 -27
- package/src/api/SysDictCacheApi.ts +26 -26
- package/src/api/SysUserApi.ts +35 -35
- package/src/api/framework.ts +12 -12
- package/src/assets/style/ant.scss +19 -19
- package/src/assets/style/index.less +180 -180
- package/src/components/ElFlex/ElFlex.vue +297 -297
- package/src/components/OperationAuth/operationAuth.vue +26 -26
- package/src/components/Search/ElIconSearch.vue +260 -260
- package/src/components/Search/ElSearch.vue +154 -154
- package/src/components/Table/ElTableColumnEdit.vue +218 -218
- package/src/components/Title/ElTitle.vue +49 -49
- package/src/components/autoToolTip/ElAutoToolTip.vue +61 -61
- package/src/components/baseEcharts/index.vue +48 -48
- package/src/components/business/userSelect.vue +412 -412
- package/src/components/upload/ElUploads.vue +286 -286
- package/src/components/upload/FileView.vue +158 -158
- package/src/components/upload/FileViewComponents.vue +57 -57
- package/src/config/ElementPlusConfig.ts +95 -95
- package/src/css/elementUI/autocomplete.scss +89 -89
- package/src/css/elementUI/common/var.scss +1549 -1549
- package/src/css/elementUI/date-picker/picker.scss +219 -219
- package/src/css/elementUI/drawer.scss +164 -164
- package/src/css/elementUI/table.scss +694 -694
- package/src/css/elementUI/tabs.scss +659 -659
- package/src/directives/vKeydown.ts +93 -93
- package/src/hooks/useDictHooks.ts +78 -79
- package/src/hooks/useEcharts.ts +58 -58
- package/src/hooks/useFileView.ts +34 -34
- package/src/hooks/useMessageHooks.ts +132 -132
- package/src/hooks/useResetRefHooks.ts +18 -18
- package/src/interface/BaseEntity.ts +28 -28
- package/src/interface/IMdmDept.ts +82 -82
- package/src/interface/IOrgDeptInfo.ts +12 -12
- package/src/interface/ISysDictDataCacheVo.ts +46 -46
- package/src/interface/ISysDictType.ts +37 -37
- package/src/interface/ISysMenuDataVo.ts +22 -22
- package/src/interface/ISysMenuInfoVo.ts +83 -83
- package/src/interface/ISysMenuOperationVo.ts +21 -21
- package/src/interface/ISysUploadFiles.ts +16 -16
- package/src/interface/ISysUserInfo.ts +70 -70
- package/src/interface/IUserPermissionVo.ts +34 -34
- package/src/interface/Message.ts +69 -69
- package/src/interface/PageData.ts +17 -17
- package/src/interface/ResponseData.ts +16 -16
- package/src/interface/dictMapType.ts +11 -11
- package/src/interface/enum/MessageEnum.ts +41 -41
- package/src/mixin/globalMixin.ts +37 -37
- package/src/packages/index.ts +18 -18
- package/src/packages/text.vue +13 -13
- package/src/plugins/echartsConfig.ts +73 -73
- package/src/plugins/plugins.ts +12 -12
- package/src/stores/dictStore.ts +27 -27
- package/src/stores/messageStore.ts +49 -49
- package/src/stores/permissionStore.ts +108 -108
- package/src/stores/storeConfig.ts +23 -23
- package/src/stores/userInfoStore.ts +31 -31
- package/src/utils/AxiosConfig.ts +216 -216
|
@@ -1,286 +1,286 @@
|
|
|
1
|
-
<!--创建人 丁盼-->
|
|
2
|
-
<!--说明: 文档上传组件-->
|
|
3
|
-
<!--创建时间: 2024/12/2 下午1:59-->
|
|
4
|
-
<!--修改时间: 2024/12/2 下午1:59-->
|
|
5
|
-
<template>
|
|
6
|
-
<el-flex v-if="!isEdlt" :vertical="vertical">
|
|
7
|
-
<el-flex
|
|
8
|
-
v-for="item of uploadFilesList"
|
|
9
|
-
:key="item.id"
|
|
10
|
-
class="file-class"
|
|
11
|
-
@click="fileView(item.id)"
|
|
12
|
-
:width="itemWidth"
|
|
13
|
-
>
|
|
14
|
-
<el-flex align="center" justify="flex-start">
|
|
15
|
-
<el-tooltip class="box-item" :content="item.name" placement="top">
|
|
16
|
-
<el-text truncated style="cursor: pointer"
|
|
17
|
-
><el-icons :model-value="getIcon(item.name)" style="margin-right: 5px"></el-icons
|
|
18
|
-
>{{ item.name }}</el-text
|
|
19
|
-
>
|
|
20
|
-
</el-tooltip>
|
|
21
|
-
</el-flex>
|
|
22
|
-
</el-flex>
|
|
23
|
-
</el-flex>
|
|
24
|
-
<el-upload
|
|
25
|
-
v-else
|
|
26
|
-
ref="ref_upload"
|
|
27
|
-
:file-list="uploadFilesList"
|
|
28
|
-
@success="success"
|
|
29
|
-
@remove="remove"
|
|
30
|
-
@preview="preview"
|
|
31
|
-
@error="error"
|
|
32
|
-
@exceed="exceed"
|
|
33
|
-
:before-upload="beforeUpload"
|
|
34
|
-
drag
|
|
35
|
-
:accept="getAccept"
|
|
36
|
-
:action="'/api/doc/uploadFile/' + business + '/' + businessId + '/' + association"
|
|
37
|
-
multiple
|
|
38
|
-
:limit="limit"
|
|
39
|
-
:headers="uploadHeaders"
|
|
40
|
-
>
|
|
41
|
-
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
|
|
42
|
-
<div class="el-upload__text">拖动文件或<em>点击上传</em></div>
|
|
43
|
-
<div class="el-upload__tip">最大上传文件大小{{ size }}MB</div>
|
|
44
|
-
<template #file="{ file }">
|
|
45
|
-
<el-flex
|
|
46
|
-
class="file-class"
|
|
47
|
-
@mousemove="mousemove(file.name)"
|
|
48
|
-
@mouseout="mouseout"
|
|
49
|
-
@click="preview(file)"
|
|
50
|
-
height="20px"
|
|
51
|
-
:width="itemWidth"
|
|
52
|
-
>
|
|
53
|
-
<el-flex align="center" justify="flex-start">
|
|
54
|
-
<el-tooltip class="box-item" :content="file.name" placement="top">
|
|
55
|
-
<el-text truncated style="cursor: pointer"
|
|
56
|
-
><el-icons :model-value="getIcon(file.name)" style="margin-right: 5px"></el-icons
|
|
57
|
-
>{{ file.name }}</el-text
|
|
58
|
-
>
|
|
59
|
-
</el-tooltip>
|
|
60
|
-
</el-flex>
|
|
61
|
-
<el-flex align="center" justify="flex-end" width="50px">
|
|
62
|
-
<el-text v-if="!file?.businessId && file.percentage !== 100"
|
|
63
|
-
>{{ file.percentage }}%</el-text
|
|
64
|
-
>
|
|
65
|
-
<el-icons
|
|
66
|
-
v-if="file?.businessId || file.percentage === 100"
|
|
67
|
-
@click.prevent.stop="fileClick(file)"
|
|
68
|
-
:model-value="file.name === hoverfileName ? 'adtec-close' : 'adtec-success'"
|
|
69
|
-
style="color: var(--el-color-success); font-size: 14px"
|
|
70
|
-
:style="{
|
|
71
|
-
color:
|
|
72
|
-
file.name === hoverfileName ? 'var(--el-color-danger)' : 'var(--el-color-success)',
|
|
73
|
-
}"
|
|
74
|
-
></el-icons>
|
|
75
|
-
</el-flex>
|
|
76
|
-
</el-flex>
|
|
77
|
-
</template>
|
|
78
|
-
</el-upload>
|
|
79
|
-
</template>
|
|
80
|
-
|
|
81
|
-
<script setup lang="ts">
|
|
82
|
-
import { UploadFilled } from '@element-plus/icons-vue'
|
|
83
|
-
import { computed, onMounted, ref } from 'vue'
|
|
84
|
-
import { ElMessage, type UploadFile, type UploadFiles, type UploadUserFile } from 'element-plus'
|
|
85
|
-
import type { ISysUploadFiles } from '../../interface/ISysUploadFiles'
|
|
86
|
-
//@ts-ignore
|
|
87
|
-
import useFileView from '../../hooks/useFileView.ts'
|
|
88
|
-
import documentApi from '../../api/DocumentApi.ts'
|
|
89
|
-
|
|
90
|
-
const { fileView: fileView } = useFileView()
|
|
91
|
-
const uploadHeaders = ref({
|
|
92
|
-
Authorization: '',
|
|
93
|
-
})
|
|
94
|
-
const ref_upload = ref()
|
|
95
|
-
const hoverfileName = ref('')
|
|
96
|
-
const props = defineProps({
|
|
97
|
-
/**
|
|
98
|
-
* @description 上传文件数量
|
|
99
|
-
* @default 1
|
|
100
|
-
*/
|
|
101
|
-
limit: {
|
|
102
|
-
type: Number,
|
|
103
|
-
default: 1,
|
|
104
|
-
},
|
|
105
|
-
/**
|
|
106
|
-
* @description 纵向排列
|
|
107
|
-
* @default false
|
|
108
|
-
*/
|
|
109
|
-
vertical: {
|
|
110
|
-
type: Boolean,
|
|
111
|
-
default: false,
|
|
112
|
-
},
|
|
113
|
-
/**
|
|
114
|
-
* @description 上传文件类型
|
|
115
|
-
* @default ''
|
|
116
|
-
* @type {'images'|'document'|'txt'|'pdf'|'word'|'excel'|'ppt'}
|
|
117
|
-
*/
|
|
118
|
-
accept: {
|
|
119
|
-
type: String,
|
|
120
|
-
default: '',
|
|
121
|
-
},
|
|
122
|
-
/**
|
|
123
|
-
* @description 业务类型
|
|
124
|
-
* @default 'default'
|
|
125
|
-
*/
|
|
126
|
-
business: {
|
|
127
|
-
type: String,
|
|
128
|
-
default: 'default',
|
|
129
|
-
},
|
|
130
|
-
/**
|
|
131
|
-
* @description 业务id
|
|
132
|
-
* @default ''
|
|
133
|
-
*/
|
|
134
|
-
businessId: {
|
|
135
|
-
type: String,
|
|
136
|
-
default: 'default',
|
|
137
|
-
},
|
|
138
|
-
/**
|
|
139
|
-
* 文件列表
|
|
140
|
-
*/
|
|
141
|
-
uploadFilesList: {
|
|
142
|
-
type: Array<ISysUploadFiles>,
|
|
143
|
-
default: () => [],
|
|
144
|
-
},
|
|
145
|
-
/**
|
|
146
|
-
* @description 是否编辑状态
|
|
147
|
-
* @default 'true'
|
|
148
|
-
* @type {true|false}
|
|
149
|
-
*/
|
|
150
|
-
isEdlt: {
|
|
151
|
-
type: Boolean,
|
|
152
|
-
default: true,
|
|
153
|
-
},
|
|
154
|
-
/**
|
|
155
|
-
* @description 文档上传是否默认关联,默认不关联
|
|
156
|
-
* @default 'false'
|
|
157
|
-
* @type {true|false}
|
|
158
|
-
*/
|
|
159
|
-
association: {
|
|
160
|
-
type: Boolean,
|
|
161
|
-
default: false,
|
|
162
|
-
},
|
|
163
|
-
size: {
|
|
164
|
-
type: Number,
|
|
165
|
-
default: 50,
|
|
166
|
-
},
|
|
167
|
-
//附件宽度
|
|
168
|
-
itemWidth: {
|
|
169
|
-
type: String,
|
|
170
|
-
default: '100%',
|
|
171
|
-
},
|
|
172
|
-
})
|
|
173
|
-
const mousemove = (fileName: string) => {
|
|
174
|
-
hoverfileName.value = fileName
|
|
175
|
-
}
|
|
176
|
-
const mouseout = () => {
|
|
177
|
-
hoverfileName.value = ''
|
|
178
|
-
}
|
|
179
|
-
const getAccept = computed(() => {
|
|
180
|
-
if (props.accept === 'images') {
|
|
181
|
-
return '.jpg,.jpeg,.png,.gif,.bmp,.JPG,.JPEG,.PBG,.GIF,.BMP'
|
|
182
|
-
} else if (props.accept === 'document') {
|
|
183
|
-
return '.txt,.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx'
|
|
184
|
-
} else if (props.accept === 'txt') {
|
|
185
|
-
return '.txt'
|
|
186
|
-
} else if (props.accept === 'pdf') {
|
|
187
|
-
return '.pdf'
|
|
188
|
-
} else if (props.accept === 'word') {
|
|
189
|
-
return '.doc,.docx'
|
|
190
|
-
} else if (props.accept === 'excel') {
|
|
191
|
-
return '.xls,.xlsx'
|
|
192
|
-
} else if (props.accept === 'ppt') {
|
|
193
|
-
return '.ppt,.pptx'
|
|
194
|
-
} else {
|
|
195
|
-
return ''
|
|
196
|
-
}
|
|
197
|
-
})
|
|
198
|
-
const getIcon = (fileName: string) => {
|
|
199
|
-
const type: string = fileName.split('.').pop() + ''
|
|
200
|
-
if ('.jpg,.jpeg,.png,.gif,.bmp,.JPG,.JPEG,.PBG,.GIF,.BMP'.includes(type)) {
|
|
201
|
-
return 'adtec-image'
|
|
202
|
-
} else if ('txt'.includes(type)) {
|
|
203
|
-
return 'adtec-text'
|
|
204
|
-
} else if ('pdf'.includes(type)) {
|
|
205
|
-
return 'adtec-pdf'
|
|
206
|
-
} else if ('doc,docx'.includes(type)) {
|
|
207
|
-
return 'adtec-word'
|
|
208
|
-
} else if ('xls,xlsx'.includes(type)) {
|
|
209
|
-
return 'adtec-excel'
|
|
210
|
-
} else if ('ppt,pptx'.includes(type)) {
|
|
211
|
-
return 'adtec-ppt'
|
|
212
|
-
} else {
|
|
213
|
-
return 'adtec-text'
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
const success = (response: any, uploadFile: UploadFile, uploadFiles: UploadFiles) => {
|
|
217
|
-
if (response.code === '0') {
|
|
218
|
-
props.uploadFilesList.push(response.data as ISysUploadFiles)
|
|
219
|
-
} else {
|
|
220
|
-
ElMessage.error(response.msg)
|
|
221
|
-
ref_upload.value?.handleRemove(uploadFile)
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
const beforeUpload = (file: File) => {
|
|
225
|
-
const f = props.uploadFilesList.find((c) => c.name === file.name)
|
|
226
|
-
if (f) {
|
|
227
|
-
ElMessage.warning(file.name + ',文件已存在')
|
|
228
|
-
return false
|
|
229
|
-
} else if (file.size > props.size * 1024 * 1024) {
|
|
230
|
-
ElMessage.warning('文件大小不能超过' + props.size + 'MB')
|
|
231
|
-
return false
|
|
232
|
-
}
|
|
233
|
-
return true
|
|
234
|
-
}
|
|
235
|
-
const fileClick = (file: UploadFile) => {
|
|
236
|
-
if (file.name === hoverfileName.value) {
|
|
237
|
-
ref_upload.value?.handleRemove(file)
|
|
238
|
-
} else {
|
|
239
|
-
preview(file)
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
const exceed = (files: File[], uploadFiles: UploadUserFile[]) => {
|
|
243
|
-
ElMessage.warning('最多上传' + props.limit + '个文件,上传文件数量已达到限制')
|
|
244
|
-
}
|
|
245
|
-
const error = () => {
|
|
246
|
-
ElMessage.error('上传失败')
|
|
247
|
-
}
|
|
248
|
-
const preview = async (uploadFile: UploadFile) => {
|
|
249
|
-
console.log('preview', uploadFile)
|
|
250
|
-
const file = props.uploadFilesList.find((c) => c.name === uploadFile.name)
|
|
251
|
-
if (file) {
|
|
252
|
-
//if ((uploadFile.response as any).code === '0') {
|
|
253
|
-
// const data = (uploadFile.response as any).data as ISysUploadFiles
|
|
254
|
-
fileView(file.id)
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
const remove = async (file: UploadFile) => {
|
|
258
|
-
// if ((file.response as any).code === '0') {
|
|
259
|
-
// const data = (file.response as any).data as ISysUploadFiles
|
|
260
|
-
const find = props.uploadFilesList.find((c) => c.name === file.name)
|
|
261
|
-
if (find) {
|
|
262
|
-
try {
|
|
263
|
-
await documentApi.delSysUploadFile(find.id)
|
|
264
|
-
props.uploadFilesList.splice(props.uploadFilesList.indexOf(find), 1)
|
|
265
|
-
} catch (error: any) {
|
|
266
|
-
ElMessage.error(error.msg)
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
// }
|
|
270
|
-
}
|
|
271
|
-
onMounted(() => {
|
|
272
|
-
uploadHeaders.value.Authorization = sessionStorage.getItem('Authorization') + ''
|
|
273
|
-
})
|
|
274
|
-
</script>
|
|
275
|
-
<style scoped lang="scss">
|
|
276
|
-
.file-class {
|
|
277
|
-
}
|
|
278
|
-
.file-class :hover {
|
|
279
|
-
color: var(--el-color-primary);
|
|
280
|
-
}
|
|
281
|
-
:deep {
|
|
282
|
-
.el-icon--upload {
|
|
283
|
-
margin-bottom: 0;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
</style>
|
|
1
|
+
<!--创建人 丁盼-->
|
|
2
|
+
<!--说明: 文档上传组件-->
|
|
3
|
+
<!--创建时间: 2024/12/2 下午1:59-->
|
|
4
|
+
<!--修改时间: 2024/12/2 下午1:59-->
|
|
5
|
+
<template>
|
|
6
|
+
<el-flex v-if="!isEdlt" :vertical="vertical">
|
|
7
|
+
<el-flex
|
|
8
|
+
v-for="item of uploadFilesList"
|
|
9
|
+
:key="item.id"
|
|
10
|
+
class="file-class"
|
|
11
|
+
@click="fileView(item.id)"
|
|
12
|
+
:width="itemWidth"
|
|
13
|
+
>
|
|
14
|
+
<el-flex align="center" justify="flex-start">
|
|
15
|
+
<el-tooltip class="box-item" :content="item.name" placement="top">
|
|
16
|
+
<el-text truncated style="cursor: pointer"
|
|
17
|
+
><el-icons :model-value="getIcon(item.name)" style="margin-right: 5px"></el-icons
|
|
18
|
+
>{{ item.name }}</el-text
|
|
19
|
+
>
|
|
20
|
+
</el-tooltip>
|
|
21
|
+
</el-flex>
|
|
22
|
+
</el-flex>
|
|
23
|
+
</el-flex>
|
|
24
|
+
<el-upload
|
|
25
|
+
v-else
|
|
26
|
+
ref="ref_upload"
|
|
27
|
+
:file-list="uploadFilesList"
|
|
28
|
+
@success="success"
|
|
29
|
+
@remove="remove"
|
|
30
|
+
@preview="preview"
|
|
31
|
+
@error="error"
|
|
32
|
+
@exceed="exceed"
|
|
33
|
+
:before-upload="beforeUpload"
|
|
34
|
+
drag
|
|
35
|
+
:accept="getAccept"
|
|
36
|
+
:action="'/api/doc/uploadFile/' + business + '/' + businessId + '/' + association"
|
|
37
|
+
multiple
|
|
38
|
+
:limit="limit"
|
|
39
|
+
:headers="uploadHeaders"
|
|
40
|
+
>
|
|
41
|
+
<el-icon class="el-icon--upload"><upload-filled /></el-icon>
|
|
42
|
+
<div class="el-upload__text">拖动文件或<em>点击上传</em></div>
|
|
43
|
+
<div class="el-upload__tip">最大上传文件大小{{ size }}MB</div>
|
|
44
|
+
<template #file="{ file }">
|
|
45
|
+
<el-flex
|
|
46
|
+
class="file-class"
|
|
47
|
+
@mousemove="mousemove(file.name)"
|
|
48
|
+
@mouseout="mouseout"
|
|
49
|
+
@click="preview(file)"
|
|
50
|
+
height="20px"
|
|
51
|
+
:width="itemWidth"
|
|
52
|
+
>
|
|
53
|
+
<el-flex align="center" justify="flex-start">
|
|
54
|
+
<el-tooltip class="box-item" :content="file.name" placement="top">
|
|
55
|
+
<el-text truncated style="cursor: pointer"
|
|
56
|
+
><el-icons :model-value="getIcon(file.name)" style="margin-right: 5px"></el-icons
|
|
57
|
+
>{{ file.name }}</el-text
|
|
58
|
+
>
|
|
59
|
+
</el-tooltip>
|
|
60
|
+
</el-flex>
|
|
61
|
+
<el-flex align="center" justify="flex-end" width="50px">
|
|
62
|
+
<el-text v-if="!file?.businessId && file.percentage !== 100"
|
|
63
|
+
>{{ file.percentage }}%</el-text
|
|
64
|
+
>
|
|
65
|
+
<el-icons
|
|
66
|
+
v-if="file?.businessId || file.percentage === 100"
|
|
67
|
+
@click.prevent.stop="fileClick(file)"
|
|
68
|
+
:model-value="file.name === hoverfileName ? 'adtec-close' : 'adtec-success'"
|
|
69
|
+
style="color: var(--el-color-success); font-size: 14px"
|
|
70
|
+
:style="{
|
|
71
|
+
color:
|
|
72
|
+
file.name === hoverfileName ? 'var(--el-color-danger)' : 'var(--el-color-success)',
|
|
73
|
+
}"
|
|
74
|
+
></el-icons>
|
|
75
|
+
</el-flex>
|
|
76
|
+
</el-flex>
|
|
77
|
+
</template>
|
|
78
|
+
</el-upload>
|
|
79
|
+
</template>
|
|
80
|
+
|
|
81
|
+
<script setup lang="ts">
|
|
82
|
+
import { UploadFilled } from '@element-plus/icons-vue'
|
|
83
|
+
import { computed, onMounted, ref } from 'vue'
|
|
84
|
+
import { ElMessage, type UploadFile, type UploadFiles, type UploadUserFile } from 'element-plus'
|
|
85
|
+
import type { ISysUploadFiles } from '../../interface/ISysUploadFiles'
|
|
86
|
+
//@ts-ignore
|
|
87
|
+
import useFileView from '../../hooks/useFileView.ts'
|
|
88
|
+
import documentApi from '../../api/DocumentApi.ts'
|
|
89
|
+
|
|
90
|
+
const { fileView: fileView } = useFileView()
|
|
91
|
+
const uploadHeaders = ref({
|
|
92
|
+
Authorization: '',
|
|
93
|
+
})
|
|
94
|
+
const ref_upload = ref()
|
|
95
|
+
const hoverfileName = ref('')
|
|
96
|
+
const props = defineProps({
|
|
97
|
+
/**
|
|
98
|
+
* @description 上传文件数量
|
|
99
|
+
* @default 1
|
|
100
|
+
*/
|
|
101
|
+
limit: {
|
|
102
|
+
type: Number,
|
|
103
|
+
default: 1,
|
|
104
|
+
},
|
|
105
|
+
/**
|
|
106
|
+
* @description 纵向排列
|
|
107
|
+
* @default false
|
|
108
|
+
*/
|
|
109
|
+
vertical: {
|
|
110
|
+
type: Boolean,
|
|
111
|
+
default: false,
|
|
112
|
+
},
|
|
113
|
+
/**
|
|
114
|
+
* @description 上传文件类型
|
|
115
|
+
* @default ''
|
|
116
|
+
* @type {'images'|'document'|'txt'|'pdf'|'word'|'excel'|'ppt'}
|
|
117
|
+
*/
|
|
118
|
+
accept: {
|
|
119
|
+
type: String,
|
|
120
|
+
default: '',
|
|
121
|
+
},
|
|
122
|
+
/**
|
|
123
|
+
* @description 业务类型
|
|
124
|
+
* @default 'default'
|
|
125
|
+
*/
|
|
126
|
+
business: {
|
|
127
|
+
type: String,
|
|
128
|
+
default: 'default',
|
|
129
|
+
},
|
|
130
|
+
/**
|
|
131
|
+
* @description 业务id
|
|
132
|
+
* @default ''
|
|
133
|
+
*/
|
|
134
|
+
businessId: {
|
|
135
|
+
type: String,
|
|
136
|
+
default: 'default',
|
|
137
|
+
},
|
|
138
|
+
/**
|
|
139
|
+
* 文件列表
|
|
140
|
+
*/
|
|
141
|
+
uploadFilesList: {
|
|
142
|
+
type: Array<ISysUploadFiles>,
|
|
143
|
+
default: () => [],
|
|
144
|
+
},
|
|
145
|
+
/**
|
|
146
|
+
* @description 是否编辑状态
|
|
147
|
+
* @default 'true'
|
|
148
|
+
* @type {true|false}
|
|
149
|
+
*/
|
|
150
|
+
isEdlt: {
|
|
151
|
+
type: Boolean,
|
|
152
|
+
default: true,
|
|
153
|
+
},
|
|
154
|
+
/**
|
|
155
|
+
* @description 文档上传是否默认关联,默认不关联
|
|
156
|
+
* @default 'false'
|
|
157
|
+
* @type {true|false}
|
|
158
|
+
*/
|
|
159
|
+
association: {
|
|
160
|
+
type: Boolean,
|
|
161
|
+
default: false,
|
|
162
|
+
},
|
|
163
|
+
size: {
|
|
164
|
+
type: Number,
|
|
165
|
+
default: 50,
|
|
166
|
+
},
|
|
167
|
+
//附件宽度
|
|
168
|
+
itemWidth: {
|
|
169
|
+
type: String,
|
|
170
|
+
default: '100%',
|
|
171
|
+
},
|
|
172
|
+
})
|
|
173
|
+
const mousemove = (fileName: string) => {
|
|
174
|
+
hoverfileName.value = fileName
|
|
175
|
+
}
|
|
176
|
+
const mouseout = () => {
|
|
177
|
+
hoverfileName.value = ''
|
|
178
|
+
}
|
|
179
|
+
const getAccept = computed(() => {
|
|
180
|
+
if (props.accept === 'images') {
|
|
181
|
+
return '.jpg,.jpeg,.png,.gif,.bmp,.JPG,.JPEG,.PBG,.GIF,.BMP'
|
|
182
|
+
} else if (props.accept === 'document') {
|
|
183
|
+
return '.txt,.pdf,.doc,.docx,.xls,.xlsx,.ppt,.pptx'
|
|
184
|
+
} else if (props.accept === 'txt') {
|
|
185
|
+
return '.txt'
|
|
186
|
+
} else if (props.accept === 'pdf') {
|
|
187
|
+
return '.pdf'
|
|
188
|
+
} else if (props.accept === 'word') {
|
|
189
|
+
return '.doc,.docx'
|
|
190
|
+
} else if (props.accept === 'excel') {
|
|
191
|
+
return '.xls,.xlsx'
|
|
192
|
+
} else if (props.accept === 'ppt') {
|
|
193
|
+
return '.ppt,.pptx'
|
|
194
|
+
} else {
|
|
195
|
+
return ''
|
|
196
|
+
}
|
|
197
|
+
})
|
|
198
|
+
const getIcon = (fileName: string) => {
|
|
199
|
+
const type: string = fileName.split('.').pop() + ''
|
|
200
|
+
if ('.jpg,.jpeg,.png,.gif,.bmp,.JPG,.JPEG,.PBG,.GIF,.BMP'.includes(type)) {
|
|
201
|
+
return 'adtec-image'
|
|
202
|
+
} else if ('txt'.includes(type)) {
|
|
203
|
+
return 'adtec-text'
|
|
204
|
+
} else if ('pdf'.includes(type)) {
|
|
205
|
+
return 'adtec-pdf'
|
|
206
|
+
} else if ('doc,docx'.includes(type)) {
|
|
207
|
+
return 'adtec-word'
|
|
208
|
+
} else if ('xls,xlsx'.includes(type)) {
|
|
209
|
+
return 'adtec-excel'
|
|
210
|
+
} else if ('ppt,pptx'.includes(type)) {
|
|
211
|
+
return 'adtec-ppt'
|
|
212
|
+
} else {
|
|
213
|
+
return 'adtec-text'
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const success = (response: any, uploadFile: UploadFile, uploadFiles: UploadFiles) => {
|
|
217
|
+
if (response.code === '0') {
|
|
218
|
+
props.uploadFilesList.push(response.data as ISysUploadFiles)
|
|
219
|
+
} else {
|
|
220
|
+
ElMessage.error(response.msg)
|
|
221
|
+
ref_upload.value?.handleRemove(uploadFile)
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
const beforeUpload = (file: File) => {
|
|
225
|
+
const f = props.uploadFilesList.find((c) => c.name === file.name)
|
|
226
|
+
if (f) {
|
|
227
|
+
ElMessage.warning(file.name + ',文件已存在')
|
|
228
|
+
return false
|
|
229
|
+
} else if (file.size > props.size * 1024 * 1024) {
|
|
230
|
+
ElMessage.warning('文件大小不能超过' + props.size + 'MB')
|
|
231
|
+
return false
|
|
232
|
+
}
|
|
233
|
+
return true
|
|
234
|
+
}
|
|
235
|
+
const fileClick = (file: UploadFile) => {
|
|
236
|
+
if (file.name === hoverfileName.value) {
|
|
237
|
+
ref_upload.value?.handleRemove(file)
|
|
238
|
+
} else {
|
|
239
|
+
preview(file)
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
const exceed = (files: File[], uploadFiles: UploadUserFile[]) => {
|
|
243
|
+
ElMessage.warning('最多上传' + props.limit + '个文件,上传文件数量已达到限制')
|
|
244
|
+
}
|
|
245
|
+
const error = () => {
|
|
246
|
+
ElMessage.error('上传失败')
|
|
247
|
+
}
|
|
248
|
+
const preview = async (uploadFile: UploadFile) => {
|
|
249
|
+
console.log('preview', uploadFile)
|
|
250
|
+
const file = props.uploadFilesList.find((c) => c.name === uploadFile.name)
|
|
251
|
+
if (file) {
|
|
252
|
+
//if ((uploadFile.response as any).code === '0') {
|
|
253
|
+
// const data = (uploadFile.response as any).data as ISysUploadFiles
|
|
254
|
+
fileView(file.id)
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
const remove = async (file: UploadFile) => {
|
|
258
|
+
// if ((file.response as any).code === '0') {
|
|
259
|
+
// const data = (file.response as any).data as ISysUploadFiles
|
|
260
|
+
const find = props.uploadFilesList.find((c) => c.name === file.name)
|
|
261
|
+
if (find) {
|
|
262
|
+
try {
|
|
263
|
+
await documentApi.delSysUploadFile(find.id)
|
|
264
|
+
props.uploadFilesList.splice(props.uploadFilesList.indexOf(find), 1)
|
|
265
|
+
} catch (error: any) {
|
|
266
|
+
ElMessage.error(error.msg)
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
// }
|
|
270
|
+
}
|
|
271
|
+
onMounted(() => {
|
|
272
|
+
uploadHeaders.value.Authorization = sessionStorage.getItem('Authorization') + ''
|
|
273
|
+
})
|
|
274
|
+
</script>
|
|
275
|
+
<style scoped lang="scss">
|
|
276
|
+
.file-class {
|
|
277
|
+
}
|
|
278
|
+
.file-class :hover {
|
|
279
|
+
color: var(--el-color-primary);
|
|
280
|
+
}
|
|
281
|
+
:deep {
|
|
282
|
+
.el-icon--upload {
|
|
283
|
+
margin-bottom: 0;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
</style>
|