//然后重写了添加ebook的方法 应该有更简单的方法 只不过我这个会比较繁琐点
const handleAdd = (info: FileInfo) => {
if (fileList.value.length >1){
message.error("你只能上传一个文件")
}else {
const formData = new FormData();
fileList.value.forEach((file: FileItem) => {
formData.append('file', file as any);
console.log("ebook===="+file)
});
formData.append('name',ebook.value.name)
formData.append('description',ebook.value.description)
formData.append('category1Id',categoryIds.value[0])
formData.append('category2Id',categoryIds.value[1])
if (ebook.value.id != undefined){
formData.append('id',ebook.value.id)
formData.append('docCount',ebook.value.docCount)
formData.append('viewCount',ebook.value.viewCount)
formData.append('voteCount',ebook.value.voteCount)
}
console.log("文件==========="+ebook.value.file)
axios({
method:"post",
url:'/ebook/save',
data: formData
}).then((resp)=>{
const data = resp.data;
modelvisible.value = false;
...
}