diff --git a/src/api/qc/qc.js b/src/api/qc/qc.js index f092505..c7c7c79 100644 --- a/src/api/qc/qc.js +++ b/src/api/qc/qc.js @@ -83,6 +83,7 @@ export const qcFamilyAttributeSearch = data => createAPI(`/pms/qc/qcFamilyAttrib export const qcFamilyAttributeSave = data => createAPI(`/pms/qc/qcFamilyAttributeSave`,'post',data) export const qcFamilyAttributeDelete = data => createAPI(`/pms/qc/qcFamilyAttributeDelete`,'post',data) export const uploadFamilyAttributeExcel = data => createAPI(`/pms/qc/uploadFamilyAttributeExcel`,'post',data) +export const queryFileId = data => createAPI(`/pms/qc/queryFileId`,'post',data) // ===================================== FAI检验 ===================================== export const qcFAIInspectionSearch = data => createAPI(`/pms/qc/qcFAIInspectionSearch`,'post',data) diff --git a/src/views/modules/qc/qcItem.vue b/src/views/modules/qc/qcItem.vue index f510d38..a06de97 100644 --- a/src/views/modules/qc/qcItem.vue +++ b/src/views/modules/qc/qcItem.vue @@ -538,13 +538,10 @@ userId: this.$store.state.user.id, languageCode: this.$i18n.locale } - console.log(this.$route.meta.menuId) userFavoriteList(userFavorite).then(({data}) => { for (let i = 0; i < data.list.length; i++) { - // let flag=false; if(this.$route.meta.menuId==data.list[i].menuId){ this.favorite = true - // flag=true; } } @@ -557,17 +554,10 @@ functionId: this.$route.meta.menuId, } if (this.favorite) { - // 取消收藏 - // this.$confirm(`确定取消收藏`, '提示', { - // confirmButtonText: '确定', - // cancelButtonText: '取消', - // type: 'warning' - // }).then(() => { - removeUserFavorite(userFavorite).then(({data}) => { - this.$message.success(data.msg) - this.favorite = false - }) - // }) + removeUserFavorite(userFavorite).then(({data}) => { + this.$message.success(data.msg) + this.favorite = false + }) } else { // 收藏 saveUserFavorite(userFavorite).then(({data}) => { @@ -587,7 +577,7 @@ return this.exportList; }, startDownload() { - // this.exportData = this.dataList + }, finishDownload() { diff --git a/src/views/modules/qc/qc_upload.vue b/src/views/modules/qc/qc_upload.vue index 7fc93f5..9e4a838 100644 --- a/src/views/modules/qc/qc_upload.vue +++ b/src/views/modules/qc/qc_upload.vue @@ -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() { - } }