diff --git a/client/src/api/eaduitors.js b/client/src/api/eaduitors.js index e27f3d2..e6f060a 100644 --- a/client/src/api/eaduitors.js +++ b/client/src/api/eaduitors.js @@ -49,3 +49,12 @@ export function getMyEas(query) { method: 'delete' }) } + + + export function exportData(data) { + return request({ + url: `/info/ea/filter_by_date/`, + method: 'post', + data + }) + } \ No newline at end of file diff --git a/client/src/api/qa.js b/client/src/api/qa.js index 1617451..125f08d 100644 --- a/client/src/api/qa.js +++ b/client/src/api/qa.js @@ -55,3 +55,11 @@ export function getRc_activate() { method: 'delete' }) } + + export function exportData(data) { + return request({ + url: `/info/qa/filter_by_date/`, + method: 'post', + data + }) + } diff --git a/client/src/api/qc.js b/client/src/api/qc.js index f123b74..9a9db2f 100644 --- a/client/src/api/qc.js +++ b/client/src/api/qc.js @@ -55,3 +55,12 @@ export function getRc_activate() { method: 'delete' }) } + + + export function exportData(data) { + return request({ + url: `/info/qc/filter_by_date/`, + method: 'post', + data + }) + } diff --git a/client/src/api/review.js b/client/src/api/review.js index 24cb412..c10ac2c 100644 --- a/client/src/api/review.js +++ b/client/src/api/review.js @@ -49,3 +49,12 @@ export function getMyRs(query) { method: 'delete' }) } + + + export function exportData(data) { + return request({ + url: `/info/ar/filter_by_date/`, + method: 'post', + data + }) + } diff --git a/client/src/views/informatiomCollect/externalAuditor.vue b/client/src/views/informatiomCollect/externalAuditor.vue index acffc73..94c1dd9 100644 --- a/client/src/views/informatiomCollect/externalAuditor.vue +++ b/client/src/views/informatiomCollect/externalAuditor.vue @@ -2,9 +2,7 @@
新增 - 导入 - - 导出 + 导出 - @@ -135,9 +120,10 @@ import Pagination from "@/components/Pagination"; // secondary package based on import Treeselect from "@riophae/vue-treeselect"; import "@riophae/vue-treeselect/dist/vue-treeselect.css"; import { getDictList, getDictTypeList } from "@/api/dict"; -import { getMyEas, delEa, createEa, updateEa } from "@/api/eaduitors"; +import { getMyEas, delEa, createEa, updateEa, exportData } from "@/api/eaduitors"; import { upUrl, upHeaders } from "@/api/file"; - +import { saveAs } from 'file-saver'; +import XLSX from 'xlsx'; const defaultContent = { name_company:"", name: "", @@ -169,6 +155,11 @@ export default { typeOptions: [], listLoading: false, dialogVisible: false, + showExportDialog: false, + exportForm: { + startDate: '', // 开始日期 + endDate: '', // 结束日期 + }, listQuery: { page: 1, page_size: 20, @@ -200,22 +191,6 @@ export default { }, methods: { - - //提交表单 - submitForm(formName) { - this.$refs[formName].validate((valid) => { - if (valid) { - if (this.dialogType == "new") { - this.addData(); - } else { - this.editData(); - } - } else { - console.log("error submit!!"); - return false; - } - }); - }, close_dialog(){ this.impDialogVisible = false; }, @@ -275,7 +250,42 @@ export default { this.listLoading = false; }); }, - + handleExport() { + if (!this.exportForm.startDate || !this.exportForm.endDate) { + this.$message.error('请选择完整的起止日期!'); + return;} + console.log(this.exportForm) + exportData(this.exportForm).then((response) => { + if (response.data) { + let filename = '外审员情况表.xlsx'; + let tableData = response.data; + console.log(tableData) + const ws = XLSX.utils.json_to_sheet(tableData.results); + const wb = XLSX.utils.book_new(); + XLSX.utils.book_append_sheet(wb, ws, 'Sheet1'); + const wbout = XLSX.write(wb, { bookType: 'xlsx', type: 'array' }); + try { + saveAs(new Blob([wbout], { type: 'application/octet-stream' }), filename); + } catch (e) { if(typeof console !== 'undefined') console.log(e, wbout); } + return; + }else { + this.$message.error(data.message || '导出失败'); + } + }) + // this.showExportDialog = false; + .catch(error => { + this.$message.error('请求失败,请稍后再试'); + console.error(error); + }) + .finally(() => { + this.handleDialogClose(); + }); + }, + handleDialogClose(){ + this.showExportDialog = false; + this.startDate = ''; + this.endDate = ''; + }, handleFilter() { this.listQuery.page = 1; this.getList(); @@ -352,42 +362,6 @@ export default { } }); }, - submitForm(form) { - this.$refs.dialogForm.validate(async (valid) => { - if (valid) { - this.isSaveing = true; - try { - var res; - if (this.type == "add") { - createOinspect(this.form).then(res=>{ - this.isSaveing = false; - if(res.code>=200){ - this.dialogVisible = false; - this.$emit("success",this.type); - }else{ - this.$message.warning(res.data.msg); - } - }) - } else if (this.type == "edit") { - updateOinspect(this.form.id,this.form).then(res=>{ - this.isSaveing = false; - if(res.code>=200){ - this.dialogVisible = false; - this.$emit("success",this.type); - }else{ - this.$message.warning(res.data.msg); - } - }) - } - return res; - } catch (err) { - //可以处理校验错误 - this.isSaveing = false; - return err; - } - } - }); - }, onCancel() { this.$emit("closed"); }, diff --git a/client/src/views/informatiomCollect/laboratoryContact.vue b/client/src/views/informatiomCollect/laboratoryContact.vue index 6523b71..b3e3b4a 100644 --- a/client/src/views/informatiomCollect/laboratoryContact.vue +++ b/client/src/views/informatiomCollect/laboratoryContact.vue @@ -2,6 +2,7 @@
新增 + 导出 -
取消 @@ -118,6 +109,8 @@ import "@riophae/vue-treeselect/dist/vue-treeselect.css"; import { getDictList, getDictTypeList } from "@/api/dict"; import {createCt, del_contact, updateContact, getCtAll, getCt } from "@/api/contacts"; import { upUrl, upHeaders } from "@/api/file"; +import { saveAs } from 'file-saver'; +import XLSX from 'xlsx'; const defaultContent = { name: "", address: "", @@ -225,7 +218,18 @@ export default { this.listLoading = false; }); }, - + handleExport() { + let filename = '实验室联系方式表.xlsx'; + console.log(this.tableData) + const ws = XLSX.utils.json_to_sheet(this.tableData.results); + const wb = XLSX.utils.book_new(); + XLSX.utils.book_append_sheet(wb, ws, 'Sheet1'); + const wbout = XLSX.write(wb, { bookType: 'xlsx', type: 'array' }); + try { + saveAs(new Blob([wbout], { type: 'application/octet-stream' }), filename); + } catch (e) { if(typeof console !== 'undefined') console.log(e, wbout); } + return; + }, handleFilter() { this.listQuery.page = 1; this.getList(); diff --git a/client/src/views/informatiomCollect/qualityActive.vue b/client/src/views/informatiomCollect/qualityActive.vue index dc1c9b8..20b39de 100644 --- a/client/src/views/informatiomCollect/qualityActive.vue +++ b/client/src/views/informatiomCollect/qualityActive.vue @@ -2,6 +2,7 @@
新增 + 导出 - +