物资厂家文件上传
This commit is contained in:
parent
7a080291fc
commit
de858331a0
|
|
@ -15,13 +15,23 @@ export const downloadFile = ({ fileData, fileType, fileName }) => {
|
||||||
|
|
||||||
// 通用a链接下载
|
// 通用a链接下载
|
||||||
export const downloadFileByUrl = (url) => {
|
export const downloadFileByUrl = (url) => {
|
||||||
const link = document.createElement('a')
|
const link = document.createElement('a');
|
||||||
link.href = url
|
link.href = url; // 设置文件 URL
|
||||||
link.setAttribute('download', '')
|
link.download = ''; // 提供下载提示
|
||||||
link.style.display = 'none'
|
document.body.appendChild(link); // 将链接添加到 DOM
|
||||||
document.body.appendChild(link)
|
link.click(); // 模拟点击下载
|
||||||
link.click()
|
document.body.removeChild(link); // 下载后移除链接
|
||||||
URL.revokeObjectURL(link.href)
|
|
||||||
document.body.removeChild(link)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pdf、doc、docx等文件下载
|
||||||
|
export const downloadFileData = ({ fileName, fileUrl }) => {
|
||||||
|
const link = document.createElement('a')
|
||||||
|
link.setAttribute('download', '')
|
||||||
|
link.style.display = 'none'
|
||||||
|
link.href = fileUrl
|
||||||
|
link.download = fileName
|
||||||
|
document.body.appendChild(link)
|
||||||
|
link.click();
|
||||||
|
// URL.revokeObjectURL(link.href)
|
||||||
|
document.body.removeChild(link)
|
||||||
|
}
|
||||||
|
|
@ -232,7 +232,7 @@
|
||||||
<script>
|
<script>
|
||||||
import { getListFacturer,getFacturerDetail,editFacturer,addFacturer,delFacturer } from "@/api/ma/supplier";
|
import { getListFacturer,getFacturerDetail,editFacturer,addFacturer,delFacturer } from "@/api/ma/supplier";
|
||||||
import { imgUpLoadThree, fileUpLoad } from '@/api/system/upload'
|
import { imgUpLoadThree, fileUpLoad } from '@/api/system/upload'
|
||||||
import { downloadFile,downloadFileByUrl } from '@/utils/download'
|
import { downloadFile,downloadFileData } from '@/utils/download'
|
||||||
import { getToken } from '@/utils/auth'
|
import { getToken } from '@/utils/auth'
|
||||||
export default {
|
export default {
|
||||||
name: "supplier",
|
name: "supplier",
|
||||||
|
|
@ -423,7 +423,7 @@
|
||||||
downloadFile({ fileName: file.name, fileData: file.raw, fileType: 'application/vnd.ms-excel;charset=utf-8' })
|
downloadFile({ fileName: file.name, fileData: file.raw, fileType: 'application/vnd.ms-excel;charset=utf-8' })
|
||||||
}else if(file.status === 'success'){
|
}else if(file.status === 'success'){
|
||||||
|
|
||||||
downloadFileByUrl( file.url )
|
downloadFileData( { fileName: file.name, fileUrl: file.url } )
|
||||||
// downloadFileData({ fileName: file.name,fileUrl:file.url })
|
// downloadFileData({ fileName: file.name,fileUrl:file.url })
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -529,14 +529,13 @@
|
||||||
if (valid) {
|
if (valid) {
|
||||||
if (this.form.supplierId != undefined) {
|
if (this.form.supplierId != undefined) {
|
||||||
const reqData = new FormData();
|
const reqData = new FormData();
|
||||||
|
if(this.businessLicenseListTemp.length!=0){
|
||||||
|
await this.getImaUpload(),
|
||||||
|
await this.editFacturerTemp(this.form);
|
||||||
|
}else{
|
||||||
|
await this.editFacturerTemp(this.form);
|
||||||
|
}
|
||||||
|
|
||||||
editFacturer(this.form).then(response => {
|
|
||||||
this.$modal.msgSuccess("修改成功");
|
|
||||||
this.showHouse = false;
|
|
||||||
this.getList();
|
|
||||||
this.businessLicenseListTemp=[];
|
|
||||||
this.delBusinessFileIdList=[];
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
if(this.businessLicenseListTemp.length!=0){
|
if(this.businessLicenseListTemp.length!=0){
|
||||||
await this.getImaUpload(),
|
await this.getImaUpload(),
|
||||||
|
|
@ -573,7 +572,18 @@
|
||||||
this.getList();
|
this.getList();
|
||||||
this.businessLicenseListTemp=[];
|
this.businessLicenseListTemp=[];
|
||||||
this.businessLicenseFileList=[];
|
this.businessLicenseFileList=[];
|
||||||
this.delBusinessFileIdList=[];
|
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
async editFacturerTemp(form){
|
||||||
|
this.form.bmFileInfos=this.businessLicenseFileList
|
||||||
|
editFacturer(form).then(response => {
|
||||||
|
this.$modal.msgSuccess("修改成功");
|
||||||
|
this.showHouse = false;
|
||||||
|
this.getList();
|
||||||
|
this.businessLicenseListTemp=[];
|
||||||
|
this.businessLicenseFileList=[];
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue