From 94ef5e3121146d139681fb6b9240a2731e055e09 Mon Sep 17 00:00:00 2001 From: zty Date: Mon, 8 Apr 2024 16:06:39 +0800 Subject: [PATCH] =?UTF-8?q?feature=20feat:=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=AF=84=E5=AE=A1=20=E8=B4=A8=E9=87=8F=E8=A1=A8=E5=BD=B0=20?= =?UTF-8?q?=E8=B4=A8=E9=87=8F=E6=B4=BB=E5=8A=A8=20=E5=AE=9E=E9=AA=8C?= =?UTF-8?q?=E5=AE=A4=20=E5=A4=96=E5=AE=A1=E5=91=98=E7=9A=84=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/api/eaduitors.js | 9 + client/src/api/qa.js | 8 + client/src/api/qc.js | 9 + client/src/api/review.js | 9 + .../informatiomCollect/externalAuditor.vue | 168 ++++++++---------- .../informatiomCollect/laboratoryContact.vue | 26 +-- .../informatiomCollect/qualityActive.vue | 79 +++++++- .../informatiomCollect/qualityCommend.vue | 89 ++++++++-- .../views/informatiomCollect/reviewStatus.vue | 99 ++++++++--- .../migrations/0018_auto_20240407_1622.py | 75 ++++++++ server/apps/information/models.py | 46 +++++ server/apps/information/serializers.py | 1 + server/apps/information/views.py | 138 ++++++++++++-- 13 files changed, 595 insertions(+), 161 deletions(-) create mode 100644 server/apps/information/migrations/0018_auto_20240407_1622.py 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 @@
新增 + 导出 - +