文件上传
This commit is contained in:
parent
a1eb8e0f0d
commit
ecedc86725
|
|
@ -57,9 +57,10 @@ export function addFacturer(data) {
|
||||||
//删除服务器中的文件
|
//删除服务器中的文件
|
||||||
export function deleteFile(objectKey) {
|
export function deleteFile(objectKey) {
|
||||||
return request({
|
return request({
|
||||||
url: '/file/deleteFile',
|
url: '/file/deleteFile/',
|
||||||
method: 'delete',
|
method: 'delete',
|
||||||
params:{objectKey}
|
params:{"objectKey":objectKey},
|
||||||
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -231,7 +231,7 @@
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { getListFacturer,getFacturerDetail,editFacturer,addFacturer,delFacturer } from "@/api/ma/supplier";
|
import { getListFacturer,getFacturerDetail,editFacturer,addFacturer,delFacturer,deleteFile } from "@/api/ma/supplier";
|
||||||
import { imgUpLoadThree, fileUpLoad } from '@/api/system/upload'
|
import { imgUpLoadThree, fileUpLoad } from '@/api/system/upload'
|
||||||
import { downloadFile,downloadFileData } from '@/utils/download'
|
import { downloadFile,downloadFileData } from '@/utils/download'
|
||||||
import { getToken } from '@/utils/auth'
|
import { getToken } from '@/utils/auth'
|
||||||
|
|
@ -298,6 +298,7 @@
|
||||||
businessLicenseListTemp:[],
|
businessLicenseListTemp:[],
|
||||||
delBusinessFileIdList:[],
|
delBusinessFileIdList:[],
|
||||||
modelIdTemp:undefined,
|
modelIdTemp:undefined,
|
||||||
|
base64Data:undefined,
|
||||||
//图片查看弹窗
|
//图片查看弹窗
|
||||||
dialogImageUrl: '',
|
dialogImageUrl: '',
|
||||||
dialogVisible: false,
|
dialogVisible: false,
|
||||||
|
|
@ -388,6 +389,10 @@
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
this.businessLicenseListTemp.splice(sum, 1)
|
this.businessLicenseListTemp.splice(sum, 1)
|
||||||
|
if(file.status=='success'){
|
||||||
|
this.delBusinessFileIdList.push(file.url);
|
||||||
|
}
|
||||||
|
console.log('delBusinessFileIdList',this.delBusinessFileIdList)
|
||||||
},
|
},
|
||||||
|
|
||||||
isImage(file){
|
isImage(file){
|
||||||
|
|
@ -484,6 +489,7 @@
|
||||||
handleAdd() {
|
handleAdd() {
|
||||||
this.reset()
|
this.reset()
|
||||||
this.uploadKey = Date.now();
|
this.uploadKey = Date.now();
|
||||||
|
this.delBusinessFileIdList=[];
|
||||||
this.businessLicenseListTemp=[];
|
this.businessLicenseListTemp=[];
|
||||||
this.businessLicenseFileList=[];
|
this.businessLicenseFileList=[];
|
||||||
this.showHouse = true
|
this.showHouse = true
|
||||||
|
|
@ -493,6 +499,7 @@
|
||||||
handleUpdate(row){
|
handleUpdate(row){
|
||||||
this.reset()
|
this.reset()
|
||||||
this.uploadKey = Date.now();
|
this.uploadKey = Date.now();
|
||||||
|
this.delBusinessFileIdList=[];
|
||||||
this.businessLicenseListTemp=[];
|
this.businessLicenseListTemp=[];
|
||||||
this.businessLicenseFileList=[];
|
this.businessLicenseFileList=[];
|
||||||
const supplierId = row.supplierId;
|
const supplierId = row.supplierId;
|
||||||
|
|
@ -539,8 +546,10 @@
|
||||||
if(this.businessLicenseListTemp.length!=0){
|
if(this.businessLicenseListTemp.length!=0){
|
||||||
await this.getImaUploadEdit(),
|
await this.getImaUploadEdit(),
|
||||||
await this.editFacturerTemp(this.form);
|
await this.editFacturerTemp(this.form);
|
||||||
|
await this.deleteFile();
|
||||||
}else{
|
}else{
|
||||||
await this.editFacturerTemp(this.form);
|
await this.editFacturerTemp(this.form);
|
||||||
|
await this.deleteFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -602,6 +611,7 @@
|
||||||
this.$modal.msgSuccess("新增成功");
|
this.$modal.msgSuccess("新增成功");
|
||||||
this.showHouse = false;
|
this.showHouse = false;
|
||||||
this.getList();
|
this.getList();
|
||||||
|
this.delBusinessFileIdList=[];
|
||||||
this.businessLicenseListTemp=[];
|
this.businessLicenseListTemp=[];
|
||||||
this.businessLicenseFileList=[];
|
this.businessLicenseFileList=[];
|
||||||
|
|
||||||
|
|
@ -614,14 +624,49 @@
|
||||||
this.$modal.msgSuccess("修改成功");
|
this.$modal.msgSuccess("修改成功");
|
||||||
this.showHouse = false;
|
this.showHouse = false;
|
||||||
this.getList();
|
this.getList();
|
||||||
|
this.delBusinessFileIdList=[];
|
||||||
this.businessLicenseListTemp=[];
|
this.businessLicenseListTemp=[];
|
||||||
this.businessLicenseFileList=[];
|
this.businessLicenseFileList=[];
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async deleteFile(){
|
||||||
|
if(this.delBusinessFileIdList.length>0){
|
||||||
|
this.delBusinessFileIdList.forEach(async item=>{
|
||||||
|
|
||||||
|
const urlCode = encodeURIComponent(item)
|
||||||
|
|
||||||
|
await deleteFile(btoa(urlCode));
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
async convertToBase64(data) {
|
||||||
|
const url = data;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch(url);
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('网络响应不正常');
|
||||||
|
}
|
||||||
|
const blob = await response.blob();
|
||||||
|
const reader = new FileReader();
|
||||||
|
|
||||||
|
reader.onloadend = () => {
|
||||||
|
this.base64Data = reader.result; // 获取 Base64 数据并存储
|
||||||
|
};
|
||||||
|
|
||||||
|
reader.readAsDataURL(blob); // 将 Blob 读取为 Data URL
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取文件失败:', error);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
// 取消按钮
|
// 取消按钮
|
||||||
cancel() {
|
cancel() {
|
||||||
this.showHouse = false;
|
this.showHouse = false;
|
||||||
|
this.delBusinessFileIdList=[];
|
||||||
this.businessLicenseListTemp=[]
|
this.businessLicenseListTemp=[]
|
||||||
this.businessLicenseFileList=[];
|
this.businessLicenseFileList=[];
|
||||||
this.uploadKey = Date.now();
|
this.uploadKey = Date.now();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue