|
|
|
@ -2,6 +2,7 @@ |
|
|
|
<div class="customer-css"> |
|
|
|
<el-dialog :title="titleCon" :close-on-click-modal="false" :visible.sync="visible" width="390px" style="height: 520px;" class="customer-dialog"> |
|
|
|
<el-form :inline="true" label-position="top" label-width="80px"> |
|
|
|
<el-button type="primary" @click="downloadFile()">下载文件模板</el-button> |
|
|
|
<el-row> |
|
|
|
<el-col :span="24"> |
|
|
|
<el-upload class="customer-upload" drag action="javascript:void(0);" ref="uploadFile" :limit="1" accept=".xlsx,.xls" |
|
|
|
@ -27,6 +28,8 @@ import { |
|
|
|
uploadPartAttributeExcel, // 导入物料属性文件 |
|
|
|
uploadFamilyAttributeExcel, // 导入类别属性文件 |
|
|
|
} from "@/api/qc/qc.js" |
|
|
|
import axios from 'axios' |
|
|
|
import Vue from 'vue' |
|
|
|
export default { |
|
|
|
data() { |
|
|
|
return { |
|
|
|
@ -35,6 +38,8 @@ export default { |
|
|
|
fileList: [], |
|
|
|
pageData: { |
|
|
|
flag: '', |
|
|
|
createBy: '', |
|
|
|
site: '' |
|
|
|
}, |
|
|
|
} |
|
|
|
}, |
|
|
|
@ -74,6 +79,8 @@ export default { |
|
|
|
} |
|
|
|
const formData = new FormData(); |
|
|
|
formData.append("file", this.fileList[0].raw); |
|
|
|
formData.append("createBy", this.pageData.createBy); |
|
|
|
formData.append("site", this.pageData.site); |
|
|
|
if (this.pageData.flag == 'item'){ |
|
|
|
uploadExcel(formData).then(({data}) => { |
|
|
|
if (data.code === 0) { |
|
|
|
@ -123,8 +130,133 @@ export default { |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
downloadFile(){ |
|
|
|
if(this.pageData.flag == 'item'){ |
|
|
|
let file = { |
|
|
|
id: 61, |
|
|
|
fileName: '检验项目格式.xlsx', |
|
|
|
} |
|
|
|
axios.get('/proxyApi/pms/eamObject/downLoadObjectFile/' + file.id, { |
|
|
|
responseType: 'blob', |
|
|
|
headers: { |
|
|
|
'Content-Type': 'application/json', |
|
|
|
'token': Vue.cookie.get('token') |
|
|
|
} |
|
|
|
}).then(({data}) => { |
|
|
|
// 不限制文件下载类型 |
|
|
|
const blob = new Blob([data], {type: "application/octet-stream"}) |
|
|
|
// 下载文件名称 |
|
|
|
const fileName = file.fileName |
|
|
|
// a标签下载 |
|
|
|
const linkNode = document.createElement('a') |
|
|
|
// a标签的download属性规定下载文件的名称 |
|
|
|
linkNode.download = fileName |
|
|
|
linkNode.style.display = 'none' |
|
|
|
// 生成一个Blob URL |
|
|
|
linkNode.href = URL.createObjectURL(blob) |
|
|
|
document.body.appendChild(linkNode) |
|
|
|
// 模拟在按钮上的一次鼠标单击 |
|
|
|
linkNode.click() |
|
|
|
// 释放URL 对象 |
|
|
|
URL.revokeObjectURL(linkNode.href) |
|
|
|
document.body.removeChild(linkNode) |
|
|
|
}) |
|
|
|
}else if (this.pageData.flag == 'template'){ |
|
|
|
let file = { |
|
|
|
id: 62, |
|
|
|
fileName: '检验模板格式.xlsx', |
|
|
|
} |
|
|
|
axios.get('/proxyApi/pms/eamObject/downLoadObjectFile/' + file.id, { |
|
|
|
responseType: 'blob', |
|
|
|
headers: { |
|
|
|
'Content-Type': 'application/json', |
|
|
|
'token': Vue.cookie.get('token') |
|
|
|
} |
|
|
|
}).then(({data}) => { |
|
|
|
// 不限制文件下载类型 |
|
|
|
const blob = new Blob([data], {type: "application/octet-stream"}) |
|
|
|
// 下载文件名称 |
|
|
|
const fileName = file.fileName |
|
|
|
// a标签下载 |
|
|
|
const linkNode = document.createElement('a') |
|
|
|
// a标签的download属性规定下载文件的名称 |
|
|
|
linkNode.download = fileName |
|
|
|
linkNode.style.display = 'none' |
|
|
|
// 生成一个Blob URL |
|
|
|
linkNode.href = URL.createObjectURL(blob) |
|
|
|
document.body.appendChild(linkNode) |
|
|
|
// 模拟在按钮上的一次鼠标单击 |
|
|
|
linkNode.click() |
|
|
|
// 释放URL 对象 |
|
|
|
URL.revokeObjectURL(linkNode.href) |
|
|
|
document.body.removeChild(linkNode) |
|
|
|
}) |
|
|
|
}else if (this.pageData.flag == 'partAttribute'){ |
|
|
|
let file = { |
|
|
|
id: 63, |
|
|
|
fileName: '物料属性设置.xlsx', |
|
|
|
} |
|
|
|
axios.get('/proxyApi/pms/eamObject/downLoadObjectFile/' + file.id, { |
|
|
|
responseType: 'blob', |
|
|
|
headers: { |
|
|
|
'Content-Type': 'application/json', |
|
|
|
'token': Vue.cookie.get('token') |
|
|
|
} |
|
|
|
}).then(({data}) => { |
|
|
|
// 不限制文件下载类型 |
|
|
|
const blob = new Blob([data], {type: "application/octet-stream"}) |
|
|
|
// 下载文件名称 |
|
|
|
const fileName = file.fileName |
|
|
|
// a标签下载 |
|
|
|
const linkNode = document.createElement('a') |
|
|
|
// a标签的download属性规定下载文件的名称 |
|
|
|
linkNode.download = fileName |
|
|
|
linkNode.style.display = 'none' |
|
|
|
// 生成一个Blob URL |
|
|
|
linkNode.href = URL.createObjectURL(blob) |
|
|
|
document.body.appendChild(linkNode) |
|
|
|
// 模拟在按钮上的一次鼠标单击 |
|
|
|
linkNode.click() |
|
|
|
// 释放URL 对象 |
|
|
|
URL.revokeObjectURL(linkNode.href) |
|
|
|
document.body.removeChild(linkNode) |
|
|
|
}) |
|
|
|
}else if (this.pageData.flag == 'familyAttribute'){ |
|
|
|
let file = { |
|
|
|
id: 64, |
|
|
|
fileName: '分类属性设置.xlsx', |
|
|
|
} |
|
|
|
axios.get('/proxyApi/pms/eamObject/downLoadObjectFile/' + file.id, { |
|
|
|
responseType: 'blob', |
|
|
|
headers: { |
|
|
|
'Content-Type': 'application/json', |
|
|
|
'token': Vue.cookie.get('token') |
|
|
|
} |
|
|
|
}).then(({data}) => { |
|
|
|
// 不限制文件下载类型 |
|
|
|
const blob = new Blob([data], {type: "application/octet-stream"}) |
|
|
|
// 下载文件名称 |
|
|
|
const fileName = file.fileName |
|
|
|
// a标签下载 |
|
|
|
const linkNode = document.createElement('a') |
|
|
|
// a标签的download属性规定下载文件的名称 |
|
|
|
linkNode.download = fileName |
|
|
|
linkNode.style.display = 'none' |
|
|
|
// 生成一个Blob URL |
|
|
|
linkNode.href = URL.createObjectURL(blob) |
|
|
|
document.body.appendChild(linkNode) |
|
|
|
// 模拟在按钮上的一次鼠标单击 |
|
|
|
linkNode.click() |
|
|
|
// 释放URL 对象 |
|
|
|
URL.revokeObjectURL(linkNode.href) |
|
|
|
document.body.removeChild(linkNode) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
created() { |
|
|
|
|
|
|
|
|