|
|
|
@ -27,6 +27,7 @@ import { |
|
|
|
uploadTemplateExcel, // 导入模板文件 |
|
|
|
uploadPartAttributeExcel, // 导入物料属性文件 |
|
|
|
uploadFamilyAttributeExcel, // 导入类别属性文件 |
|
|
|
queryFileId, // 查询文件ID |
|
|
|
} from "@/api/qc/qc.js" |
|
|
|
import { downLoadObjectFile } from '@/api/eam/eam_object_list.js' |
|
|
|
import axios from 'axios' |
|
|
|
@ -82,7 +83,7 @@ export default { |
|
|
|
formData.append("file", this.fileList[0].raw); |
|
|
|
formData.append("createBy", this.pageData.createBy); |
|
|
|
formData.append("site", this.pageData.site); |
|
|
|
if (this.pageData.flag == 'item'){ |
|
|
|
if (this.pageData.flag === 'item'){ |
|
|
|
uploadExcel(formData).then(({data}) => { |
|
|
|
if (data.code === 0) { |
|
|
|
this.$message.success(data.msg); |
|
|
|
@ -94,7 +95,7 @@ export default { |
|
|
|
this.$message.warning(data.msg); |
|
|
|
} |
|
|
|
}) |
|
|
|
} else if (this.pageData.flag == 'template'){ |
|
|
|
} else if (this.pageData.flag === 'template'){ |
|
|
|
uploadTemplateExcel(formData).then(({data}) => { |
|
|
|
if (data.code === 0) { |
|
|
|
this.$message.success(data.msg); |
|
|
|
@ -106,7 +107,7 @@ export default { |
|
|
|
this.$message.warning(data.msg); |
|
|
|
} |
|
|
|
}) |
|
|
|
}else if (this.pageData.flag == 'partAttribute'){ |
|
|
|
}else if (this.pageData.flag === 'partAttribute'){ |
|
|
|
uploadPartAttributeExcel(formData).then(({data}) => { |
|
|
|
if (data.code === 0) { |
|
|
|
this.$message.success(data.msg); |
|
|
|
@ -118,7 +119,7 @@ export default { |
|
|
|
this.$message.warning(data.msg); |
|
|
|
} |
|
|
|
}) |
|
|
|
}else if (this.pageData.flag == 'familyAttribute'){ |
|
|
|
}else if (this.pageData.flag === 'familyAttribute'){ |
|
|
|
uploadFamilyAttributeExcel(formData).then(({data}) => { |
|
|
|
if (data.code === 0) { |
|
|
|
this.$message.success(data.msg); |
|
|
|
@ -133,117 +134,70 @@ 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') |
|
|
|
// } |
|
|
|
// }) |
|
|
|
downLoadObjectFile(file) |
|
|
|
.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) |
|
|
|
async downloadFile(){ |
|
|
|
let file = { |
|
|
|
id: 0, |
|
|
|
fileName: '' |
|
|
|
} |
|
|
|
let tempData = { |
|
|
|
orderRef1: '', |
|
|
|
orderRef2: '' |
|
|
|
} |
|
|
|
if(this.pageData.flag === 'item'){ // 检验项目 |
|
|
|
tempData.orderRef1 = 'qc'; |
|
|
|
tempData.orderRef2 = 'itemFormat'; |
|
|
|
await queryFileId(tempData).then(({data}) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
file.id = data.data.id |
|
|
|
file.fileName = data.data.fileName |
|
|
|
} else { |
|
|
|
this.$alert(data.msg, '错误', { |
|
|
|
confirmButtonText: '确定' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}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') |
|
|
|
// } |
|
|
|
// }) |
|
|
|
downLoadObjectFile(file) |
|
|
|
.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'){ // 检验模板 |
|
|
|
tempData.orderRef1 = 'qc'; |
|
|
|
tempData.orderRef2 = 'templateFormat'; |
|
|
|
await queryFileId(tempData).then(({data}) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
file.id = data.data.id |
|
|
|
file.fileName = data.data.fileName |
|
|
|
} else { |
|
|
|
this.$alert(data.msg, '错误', { |
|
|
|
confirmButtonText: '确定' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}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') |
|
|
|
// } |
|
|
|
// }) |
|
|
|
downLoadObjectFile(file) |
|
|
|
.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'){ // 物料属性设置 |
|
|
|
tempData.orderRef1 = 'qc'; |
|
|
|
tempData.orderRef2 = 'partAttributeFormat'; |
|
|
|
await queryFileId(tempData).then(({data}) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
file.id = data.data.id |
|
|
|
file.fileName = data.data.fileName |
|
|
|
} else { |
|
|
|
this.$alert(data.msg, '错误', { |
|
|
|
confirmButtonText: '确定' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
}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') |
|
|
|
// } |
|
|
|
// }) |
|
|
|
downLoadObjectFile(file) |
|
|
|
.then(({data}) => { |
|
|
|
}else if (this.pageData.flag === 'familyAttribute'){ // 类别属性设置 |
|
|
|
tempData.orderRef1 = 'qc'; |
|
|
|
tempData.orderRef2 = 'familyAttributeFormat'; |
|
|
|
await queryFileId(tempData).then(({data}) => { |
|
|
|
if (data && data.code === 0) { |
|
|
|
file.id = data.data.id |
|
|
|
file.fileName = data.data.fileName |
|
|
|
} else { |
|
|
|
this.$alert(data.msg, '错误', { |
|
|
|
confirmButtonText: '确定' |
|
|
|
}) |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
await downLoadObjectFile(file) |
|
|
|
.then(({data}) => { |
|
|
|
// 不限制文件下载类型 |
|
|
|
const blob = new Blob([data], {type: "application/octet-stream"}) |
|
|
|
// 下载文件名称 |
|
|
|
@ -262,13 +216,8 @@ export default { |
|
|
|
URL.revokeObjectURL(linkNode.href) |
|
|
|
document.body.removeChild(linkNode) |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}, |
|
|
|
created() { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
</script> |
|
|
|
|