diff --git a/src/api/qc/qc.js b/src/api/qc/qc.js
index 6ca76f9..e5a0c5c 100644
--- a/src/api/qc/qc.js
+++ b/src/api/qc/qc.js
@@ -1,4 +1,4 @@
-import { createAPI } from "@/utils/httpRequest.js";
+import { createAPI, createDownloadAPI } from "@/utils/httpRequest.js";
// ===================================== 检验方法 =====================================
export const qcMethodSearch = data => createAPI(`/pms/qc/qcMethodSearch`,'post',data)
@@ -7,6 +7,7 @@ export const qcMethodUpdate = data => createAPI(`/pms/qc/qcMethodUpdate`,'post',
export const qcMethodDelete = data => createAPI(`/pms/qc/qcMethodDelete`,'post',data)
export const uploadMethodExcel = data => createAPI(`/pms/qc/uploadMethodExcel`,'post',data)
export const downloadQcImportTemplate = (flag, site) => createAPI(`/pms/qc/downloadQcImportTemplate?flag=${flag}&site=${encodeURIComponent(site || '')}`,'post','download')
+export const exportQcExcel = (flag, data) => createDownloadAPI(`/pms/qc/exportQcExcel?flag=${encodeURIComponent(flag || '')}`,'post', data)
// ===================================== 检验项目 =====================================
export const qcItemSearch = data => createAPI(`/pms/qc/qcItemSearch`,'post',data)
diff --git a/src/utils/httpRequest.js b/src/utils/httpRequest.js
index a762667..45d7885 100644
--- a/src/utils/httpRequest.js
+++ b/src/utils/httpRequest.js
@@ -166,3 +166,11 @@ export const createAPI = (url, method, data) => {
...config
})
}
+
+export const createDownloadAPI = (url, method, data) => {
+ return instance2({
+ url,
+ method,
+ data
+ })
+}
diff --git a/src/views/modules/qc/qcItem.vue b/src/views/modules/qc/qcItem.vue
index eef0813..ae176c3 100644
--- a/src/views/modules/qc/qcItem.vue
+++ b/src/views/modules/qc/qcItem.vue
@@ -46,20 +46,7 @@
导入
-
- {{ "导出" }}
-
+ 导出
@@ -449,6 +436,7 @@
addItemObject, // 新增项目设备
deleteItemObject, // 删除项目设备
updateItemObject, // 修改项目设备
+ exportQcExcel
} from "@/api/qc/qc.js"
import { getSiteData } from '@/api/board.js'
import {getTableDefaultListLanguage, getTableUserListLanguage} from "@/api/table.js"
@@ -479,13 +467,7 @@
columnsProp:['createdBy', 'updateBy'],
// 是否收藏
favorite: false,
- // 导出 start
- exportData: [],
- exportName: "检验项目" + this.dayjs().format('YYYYMMDDHHmmss'),
- exportHeader: ["检验项目"],
- exportFooter: [],
- exportList: [],
- // 导出 end
+ exportLoading: false,
searchData: {
site: '',
userName: this.$store.state.user.name,
@@ -1539,32 +1521,28 @@
}
},
- //导出excel
- async createExportData() {
- this.searchData.limit = -1
- this.searchData.page = 1
- await qcItemSearch(this.searchData).then(({data}) => {
- this.exportList= data.page.list;
+ exportExcel () {
+ this.exportLoading = true
+ const query = Object.assign({}, this.searchData, { page: 1, limit: 1000 })
+ exportQcExcel('item', query).then(({data}) => {
+ this.bindExportBlob(data, '检验项目' + this.dayjs().format('YYYYMMDDHHmmss') + '.xlsx')
+ }).catch(() => {
+ this.$message.error('导出失败')
+ }).finally(() => {
+ this.exportLoading = false
})
- return this.exportList;
},
- startDownload() {},
-
- finishDownload() {},
-
- fields () {
- let json = "{"
- this.columnList.forEach((item, index) => {
- if (index == this.columnList.length - 1) {
- json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
- } else {
- json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
- }
- })
- json += "}"
- let s = eval("(" + json + ")")
- return s
+ bindExportBlob (data, fileName) {
+ const blob = new Blob([data], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'})
+ const linkNode = document.createElement('a')
+ linkNode.download = fileName
+ linkNode.style.display = 'none'
+ linkNode.href = URL.createObjectURL(blob)
+ document.body.appendChild(linkNode)
+ linkNode.click()
+ URL.revokeObjectURL(linkNode.href)
+ document.body.removeChild(linkNode)
},
// 导入
@@ -1572,7 +1550,7 @@
let currentData = {
flag: 'item',
createBy: this.$store.state.user.name,
- site: this.$store.state.user.site,
+ site: this.$store.state.user.site
}
//打开组件 去做新增业务
this.$nextTick(() => {
diff --git a/src/views/modules/qc/qcMethod.vue b/src/views/modules/qc/qcMethod.vue
index 1f55f36..6f3b193 100644
--- a/src/views/modules/qc/qcMethod.vue
+++ b/src/views/modules/qc/qcMethod.vue
@@ -44,20 +44,7 @@
查询
新增
导入
-
- {{ "导出" }}
-
+ 导出
@@ -176,7 +163,8 @@
qcMethodUpdate, // 检验方法修改
qcMethodDelete, // 检验方法删除
inspectionTypeSearch, // 搜索所有检验类型
- getSiteAndBuByUserName
+ getSiteAndBuByUserName,
+ exportQcExcel
} from "@/api/qc/qc.js"
import { getSiteData } from '@/api/board.js'
import {getTableDefaultListLanguage, getTableUserListLanguage,updateColumnSize} from "@/api/table.js"
@@ -191,13 +179,7 @@
columnsProp:['createBy', 'updateBy'],
// 是否收藏
favorite: false,
- // 导出 start
- exportData: [],
- exportName: "检验方法" + this.dayjs().format('YYYYMMDDHHmmss'),
- exportHeader: ["检验方法"],
- exportFooter: [],
- exportList: [],
- // 导出 end
+ exportLoading: false,
searchData: {
site: '',
userName: this.$store.state.user.name,
@@ -688,39 +670,35 @@
}
},
- //导出excel
- async createExportData() {
- this.searchData.limit = -1
- this.searchData.page = 1
- await qcMethodSearch(this.searchData).then(({data}) => {
- this.exportList= data.page.list
+ exportExcel () {
+ this.exportLoading = true
+ const query = Object.assign({}, this.searchData, { page: 1, limit: 1000 })
+ exportQcExcel('method', query).then(({data}) => {
+ this.bindExportBlob(data, '检验方法' + this.dayjs().format('YYYYMMDDHHmmss') + '.xlsx')
+ }).catch(() => {
+ this.$message.error('导出失败')
+ }).finally(() => {
+ this.exportLoading = false
})
- return this.exportList
},
- startDownload() {},
-
- finishDownload() {},
-
- fields () {
- let json = "{"
- this.columnList.forEach((item, index) => {
- if (index == this.columnList.length - 1) {
- json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
- } else {
- json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
- }
- })
- json += "}"
- let s = eval("(" + json + ")")
- return s
+ bindExportBlob (data, fileName) {
+ const blob = new Blob([data], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'})
+ const linkNode = document.createElement('a')
+ linkNode.download = fileName
+ linkNode.style.display = 'none'
+ linkNode.href = URL.createObjectURL(blob)
+ document.body.appendChild(linkNode)
+ linkNode.click()
+ URL.revokeObjectURL(linkNode.href)
+ document.body.removeChild(linkNode)
},
qcUpload () {
let currentData = {
flag: 'method',
createBy: this.$store.state.user.name,
- site: this.$store.state.user.site,
+ site: this.$store.state.user.site
}
this.$nextTick(() => {
this.$refs.qcUpload.init(currentData)
diff --git a/src/views/modules/qc/qcPartAttribute.vue b/src/views/modules/qc/qcPartAttribute.vue
index 2e46079..b264f75 100644
--- a/src/views/modules/qc/qcPartAttribute.vue
+++ b/src/views/modules/qc/qcPartAttribute.vue
@@ -71,20 +71,7 @@
物料属性导入
检验模板导入
检验标准导入
-
- {{ "导出" }}
-
+ 导出
@@ -1090,7 +1077,8 @@
updatePatrolConfig as updatePatrolConfigApi,
deletePatrolConfig as deletePatrolConfigApi,
getPatrolOperationDescList as getPatrolOperationDescListApi,
- getPartAttributeFileList
+ getPartAttributeFileList,
+ exportQcExcel
} from "@/api/qc/qc.js"
import { getSiteData } from '@/api/board.js'
import {getTableDefaultListLanguage, getTableUserListLanguage} from "@/api/table.js"
@@ -1114,13 +1102,7 @@
maintainFlagProps: ['iqcFlag', 'ipqcFlag', 'fqcFlag', 'oqcFlag', 'sqcFlag'],
// 是否收藏
favorite: false,
- // 导出 start
- exportData: [],
- exportName: "根据物料设置检验模板" + this.dayjs().format('YYYYMMDDHHmmss'),
- exportHeader: ["根据物料设置检验模板"],
- exportFooter: [],
- exportList: [],
- // 导出 end
+ exportLoading: false,
tagNo: '',
patrolConfigDialogFlag: false,
patrolConfigLoading: false,
@@ -3317,32 +3299,28 @@
}
},
- //导出excel
- async createExportData() {
- this.searchData.limit = -1
- this.searchData.page = 1
- await qcPartAttributeSearch(this.searchData).then(({data}) => {
- this.exportList= data.page.list
+ exportExcel () {
+ this.exportLoading = true
+ const query = Object.assign({}, this.searchData, { page: 1, limit: 1000 })
+ exportQcExcel('partAttr', query).then(({data}) => {
+ this.bindExportBlob(data, '物料属性' + this.dayjs().format('YYYYMMDDHHmmss') + '.xlsx')
+ }).catch(() => {
+ this.$message.error('导出失败')
+ }).finally(() => {
+ this.exportLoading = false
})
- return this.exportList
},
- startDownload() {},
-
- finishDownload() {},
-
- fields () {
- let json = "{"
- this.columnList.forEach((item, index) => {
- if (index == this.columnList.length - 1) {
- json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
- } else {
- json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
- }
- })
- json += "}"
- let s = eval("(" + json + ")")
- return s
+ bindExportBlob (data, fileName) {
+ const blob = new Blob([data], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'})
+ const linkNode = document.createElement('a')
+ linkNode.download = fileName
+ linkNode.style.display = 'none'
+ linkNode.href = URL.createObjectURL(blob)
+ document.body.appendChild(linkNode)
+ linkNode.click()
+ URL.revokeObjectURL(linkNode.href)
+ document.body.removeChild(linkNode)
},
qcPartAttrUpload () {
@@ -3359,7 +3337,7 @@
flag: flag,
title: title,
createBy: this.$store.state.user.name,
- site: this.$store.state.user.site,
+ site: this.$store.state.user.site
}
this.$nextTick(() => {
this.$refs.qcUpload.init(currentData)
@@ -3371,7 +3349,7 @@
let currentData = {
flag: 'partAttribute',
createBy: this.$store.state.user.name,
- site: this.$store.state.user.site,
+ site: this.$store.state.user.site
}
//打开组件 去做新增业务
this.$nextTick(() => {
diff --git a/src/views/modules/qc/qcTemplate.vue b/src/views/modules/qc/qcTemplate.vue
index 7a9dcde..dd22b2e 100644
--- a/src/views/modules/qc/qcTemplate.vue
+++ b/src/views/modules/qc/qcTemplate.vue
@@ -48,20 +48,7 @@
模板导入
检验项目导入
-
- {{ "导出" }}
-
+ 导出
@@ -543,6 +530,7 @@
saveInspectionStandard, // 新增检验标准
goUpItemQC, // 上移项目位置
goDownItemQC,// 下移项目位置
+ exportQcExcel
} from "@/api/qc/qc.js"
import { getSiteData } from '@/api/board.js'
import {getTableDefaultListLanguage, getTableUserListLanguage} from "@/api/table.js"
@@ -559,13 +547,7 @@
columnsProp:['createBy', 'updateBy'],
// 是否收藏
favorite: false,
- // 导出 start
- exportData: [],
- exportName: "根据物料设置检验模板" + this.dayjs().format('YYYYMMDDHHmmss'),
- exportHeader: ["根据物料设置检验模板"],
- exportFooter: [],
- exportList: [],
- // 导出 end
+ exportLoading: false,
tagNo: '',
searchData: {
site: '',
@@ -1758,14 +1740,28 @@
}
},
- //导出excel
- async createExportData () {
- this.searchData.limit = -1
- this.searchData.page = 1
- await templateSearch(this.searchData).then(({data}) => {
- this.exportList= data.page.list
+ exportExcel () {
+ this.exportLoading = true
+ const query = Object.assign({}, this.searchData, { page: 1, limit: 1000 })
+ exportQcExcel('template', query).then(({data}) => {
+ this.bindExportBlob(data, '检验模板' + this.dayjs().format('YYYYMMDDHHmmss') + '.xlsx')
+ }).catch(() => {
+ this.$message.error('导出失败')
+ }).finally(() => {
+ this.exportLoading = false
})
- return this.exportList
+ },
+
+ bindExportBlob (data, fileName) {
+ const blob = new Blob([data], {type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'})
+ const linkNode = document.createElement('a')
+ linkNode.download = fileName
+ linkNode.style.display = 'none'
+ linkNode.href = URL.createObjectURL(blob)
+ document.body.appendChild(linkNode)
+ linkNode.click()
+ URL.revokeObjectURL(linkNode.href)
+ document.body.removeChild(linkNode)
},
goUp() {
goUpItemQC(this.currentRow).then(({data}) => {
@@ -1802,23 +1798,6 @@
})
},
- startDownload() {},
-
- finishDownload() {},
-
- fields () {
- let json = "{"
- this.columnList.forEach((item, index) => {
- if (index == this.columnList.length - 1) {
- json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\""
- } else {
- json += "\"" + item.columnLabel + "\"" + ":" + "\"" + item.columnProp + "\"" + ","
- }
- })
- json += "}"
- let s = eval("(" + json + ")")
- return s
- },
// 模板导入
qcUpload () {
diff --git a/src/views/modules/qc/qc_upload.vue b/src/views/modules/qc/qc_upload.vue
index 6c067f7..fdcddb5 100644
--- a/src/views/modules/qc/qc_upload.vue
+++ b/src/views/modules/qc/qc_upload.vue
@@ -153,10 +153,6 @@ export default {
this.$message.warning("请选择BU!");
return false;
}
- if (this.isMasterImport && !this.importSite) {
- this.$message.warning("未获取到当前用户工厂");
- return false;
- }
if (this.fileList == null || this.fileList.length === 0){
this.$message.error("请先上传文件!");
return false;