fix : 修改导出问题

This commit is contained in:
zty 2024-08-07 16:50:08 +08:00
parent 3c1634b797
commit 38ce78b8ee
4 changed files with 27 additions and 25 deletions

View File

@ -289,15 +289,29 @@ export default {
},
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;
getCtAll({page:0}).then((res) =>{
if (res.data){
let tableData = res.data;
const ws = XLSX.utils.json_to_sheet(tableData);
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();
});
},
handleFilter() {
this.listQuery.page = 1;

View File

@ -261,12 +261,11 @@ export default {
// if (!this.exportForm.startDate || !this.exportForm.endDate) {
// this.$message.error('请选择完整的起止日期!');
// return;}
getMyQi().then((response) => {
getMyQi({page:0}).then((response) => {
if (response.data) {
let filename = '资质变更情况统计表.xlsx';
let tableData = response.data;
const ws = XLSX.utils.json_to_sheet(tableData.results);
const ws = XLSX.utils.json_to_sheet(tableData);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
const wbout = XLSX.write(wb, { bookType: 'xlsx', type: 'array' });

View File

@ -257,14 +257,11 @@ export default {
},
handleExport() {
// if (!this.exportForm.startDate || !this.exportForm.endDate) {
// this.$message.error('请选择完整的起止日期!');
// return;}
getAllQi().then((response) => {
getAllQi({page:0}).then((response) => {
if (response.data) {
let filename = '资质情况统计表.xlsx';
let tableData = response.data;
const ws = XLSX.utils.json_to_sheet(tableData.results);
const ws = XLSX.utils.json_to_sheet(tableData);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, 'Sheet1');
const wbout = XLSX.write(wb, { bookType: 'xlsx', type: 'array' });

View File

@ -158,14 +158,6 @@ class CertificateViewSet(CreateUpdateCustomMixin, ModelViewSet):
for thread in threads:
thread.join()
# # Update the objects
# for obj in objects:
# # for field, value in updates.items():
# # setattr(obj, field, value)
# # obj.save()
# serializer = CertificateSerializer(obj, data=updates, partial=True)
# serializer.is_valid(raise_exception=True)
# serializer.save()
return Response()