|
@@ -6,7 +6,6 @@ import { getFullUrl, getPartUrl } from '~/utils/helper';
|
|
|
import user from '~/store/user';
|
|
|
const token = user.token
|
|
|
const action = window.GLOBAL_CONFIG.api + '/upload/main/file'
|
|
|
-console.log('file upload progress');
|
|
|
|
|
|
const data = { token, client: 'web', api: 'json', issubmit: '1', site: 'tyyx' }
|
|
|
const emit = defineEmits(['update:part', 'update:full', 'update:size', 'update:time', 'compile', 'update:list'])
|
|
@@ -152,6 +151,29 @@ watch(() => List_part.value, () => {
|
|
|
emit('compile', FILE_LIST.value)
|
|
|
console.log('compile');
|
|
|
})
|
|
|
+
|
|
|
+function handleRequest(args) {
|
|
|
+ // console.log('handleRequest', args)
|
|
|
+ REQUEST.upload({
|
|
|
+ url: args.action,
|
|
|
+ data: {
|
|
|
+ ...args.data,
|
|
|
+ [args.filename]: args.file,
|
|
|
+ },
|
|
|
+ // onUploadProgress: () => {
|
|
|
+ // // console.log('progressEvent : ', progressEvent)
|
|
|
+ // // const percentage = (progressEvent.loaded / progressEvent.total) * 100
|
|
|
+ // // args.onProgress({ percentage }, args.file, args.fileList)
|
|
|
+ // },
|
|
|
+ }).then((res) => {
|
|
|
+ console.log('res', res)
|
|
|
+ if (res.code === '1')
|
|
|
+ args?.onSuccess(res, args.file, args.fileList)
|
|
|
+
|
|
|
+ else
|
|
|
+ args?.onError(res, args.file, args.fileList)
|
|
|
+ })
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
|
|
@@ -159,7 +181,7 @@ watch(() => List_part.value, () => {
|
|
|
<!-- :on-preview="handlePictureCardPreview" -->
|
|
|
<el-upload :action="action" :data="data" name="filedata" :on-success="handleSuccess" :on-remove="onRemove"
|
|
|
:on-exceed="onExceed" :before-upload="beforeUpload" v-model:file-list="FILE_LIST"
|
|
|
- :on-preview="handlePictureCardPreview" v-bind="attrs" class="w-full">
|
|
|
+ :on-preview="handlePictureCardPreview" v-bind="attrs" class="w-full" :http-request="handleRequest" >
|
|
|
<template #default>
|
|
|
<slot>
|
|
|
<el-button type="primary">点击上传</el-button>
|