|
@@ -18,6 +18,7 @@
|
|
|
<!-- 使用file插槽自定义文件列表 -->
|
|
|
<draggable
|
|
|
v-model="fileListData"
|
|
|
+ v-loading="pdfLoading"
|
|
|
item-key="uid"
|
|
|
handle=".drag-handle"
|
|
|
class="file-list-container"
|
|
@@ -179,6 +180,9 @@ const beforeUpload = async (file) => {
|
|
|
return true
|
|
|
} else {
|
|
|
window?.$message?.warning('文件大小, 不能过60M!')
|
|
|
+
|
|
|
+ console.log(fileListData.value, 'fileListData.value')
|
|
|
+
|
|
|
return false
|
|
|
}
|
|
|
}
|
|
@@ -192,16 +196,25 @@ const q = 1 // 假设q是固定偏移量,可以根据需要调整
|
|
|
// 新增的处理方法
|
|
|
// 文件变化处理
|
|
|
const handleFileChange = async (file, fileList) => {
|
|
|
-console.log(file, 'file')
|
|
|
-let url = await getPdfUrl([file])
|
|
|
-file.url = url
|
|
|
+ if (!isFileSize(file?.size, 60)) {
|
|
|
+ window?.$message?.warning('文件大小, 不能过60M!')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ fileListData.value = fileList.map((item, index) => ({
|
|
|
+ ...item,
|
|
|
+ sort: index + q, // 为每个文件添加sort字段
|
|
|
+ url:'',
|
|
|
+ }))
|
|
|
|
|
|
|
|
|
- fileListData.value = fileList.map((item, index) => ({
|
|
|
- ...item,
|
|
|
- sort: index + q, // 为每个文件添加sort字段
|
|
|
- }))
|
|
|
-
|
|
|
+ fileListData.value = fileList.filter(file => isFileSize(file?.size, 60))
|
|
|
+ const pdfUrLArray = await getPdfUrl(fileListData.value)
|
|
|
+ fileListData.value.forEach((item, index) => {
|
|
|
+ if (item.raw && pdfUrLArray[index]) {
|
|
|
+ const pdfUrl = pdfUrLArray[index]['url']
|
|
|
+ fileListData.value[index].url = pdfUrl // 更新文件列表中的 url 字段
|
|
|
+ }
|
|
|
+ })
|
|
|
|
|
|
}
|
|
|
//上传文件前预览pdf
|
|
@@ -221,7 +234,7 @@ const getPdfUrl = async (arr) => {
|
|
|
pdfLoading.value = false
|
|
|
if (!error && code === 200) {
|
|
|
console.log(data, 'data')
|
|
|
- return data[0].url
|
|
|
+ return data
|
|
|
|
|
|
|
|
|
} else {
|
|
@@ -325,7 +338,7 @@ const delUploadData = async (file) => {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
- emit('change', { type: 'success' })
|
|
|
+
|
|
|
}
|
|
|
|
|
|
const uploadRemove = () => {
|