From 9dd11bd6a971e13aa74ad7a8994f9710edb42590 Mon Sep 17 00:00:00 2001 From: spring <2396852758@qq.com> Date: 星期二, 25 二月 2025 15:05:51 +0800 Subject: [PATCH] 修改导出 --- src/views/CNAS/resourceDemand/standardMaterialAccept/index.vue | 89 ++++++++++++++++---------------------------- 1 files changed, 32 insertions(+), 57 deletions(-) diff --git a/src/views/CNAS/resourceDemand/standardMaterialAccept/index.vue b/src/views/CNAS/resourceDemand/standardMaterialAccept/index.vue index b6bb91f..1a67d66 100644 --- a/src/views/CNAS/resourceDemand/standardMaterialAccept/index.vue +++ b/src/views/CNAS/resourceDemand/standardMaterialAccept/index.vue @@ -19,34 +19,34 @@ </div> <div class="table"> <lims-table :tableData="tableData" :column="columns" :height="'calc(100vh - 250px)'" @pagination="pagination" - :page="page" :tableLoading="tableLoading"></lims-table> + :page="page" :tableLoading="tableLoading"></lims-table> </div> <AddRecord ref="addRecordRef" @submit="submit"></AddRecord> </div> -<!-- <div class="tables">--> -<!-- <ZTTable--> -<!-- :column="columns"--> -<!-- :table-data="tableData"--> -<!-- >--> -<!-- <template slot="action" slot-scope="{ row }">--> -<!-- <el-button type="text" @click="edit(row)">缂栬緫</el-button>--> -<!-- </template>--> -<!-- </ZTTable>--> -<!-- <div class="pagination">--> -<!-- <div></div>--> -<!-- <el-pagination--> -<!-- :page-size="pagination.pageSize"--> -<!-- :page-sizes="[10, 20, 30, 40]"--> -<!-- :total="pagination.total"--> -<!-- layout="total, sizes, prev, pager, next, jumper"--> -<!-- @current-change="handleCurrent"--> -<!-- @size-change="handleSize"--> -<!-- >--> -<!-- </el-pagination>--> -<!-- </div>--> -<!-- </div>--> -<!-- <AddRecord ref="addRecordRef" @submit="submit"></AddRecord>--> + <!-- <div class="tables">--> + <!-- <ZTTable--> + <!-- :column="columns"--> + <!-- :table-data="tableData"--> + <!-- >--> + <!-- <template slot="action" slot-scope="{ row }">--> + <!-- <el-button type="text" @click="edit(row)">缂栬緫</el-button>--> + <!-- </template>--> + <!-- </ZTTable>--> + <!-- <div class="pagination">--> + <!-- <div></div>--> + <!-- <el-pagination--> + <!-- :page-size="pagination.pageSize"--> + <!-- :page-sizes="[10, 20, 30, 40]"--> + <!-- :total="pagination.total"--> + <!-- layout="total, sizes, prev, pager, next, jumper"--> + <!-- @current-change="handleCurrent"--> + <!-- @size-change="handleSize"--> + <!-- >--> + <!-- </el-pagination>--> + <!-- </div>--> + <!-- </div>--> + <!-- <AddRecord ref="addRecordRef" @submit="submit"></AddRecord>--> </template> <script> @@ -138,8 +138,8 @@ }, methods: { async getTableData() { - const res = await getPageAcceptance(this.form); - if(res.code === 200){ + const res = await getPageAcceptance(this.form); + if (res.code === 200) { this.tableData = res.data.records; this.page.total = res.data.total; } @@ -150,9 +150,9 @@ }, async submit(form) { - const {code} = await form.acceptance.id ? updateAcceptanc(this.form):addAcceptance((this.form)); - if(code == 200) { - this.$message.success(`${form.acceptance.id ? '缂栬緫':'娣诲姞'}鎴愬姛`) + const { code } = await form.acceptance.id ? updateAcceptanc(this.form) : addAcceptance((this.form)); + if (code == 200) { + this.$message.success(`${form.acceptance.id ? '缂栬緫' : '娣诲姞'}鎴愬姛`) this.getTableData() } }, @@ -169,7 +169,7 @@ url: getAcceptanceDetails, params: { id } }) - if(code == 200) { + if (code == 200) { return data; } }, @@ -183,33 +183,8 @@ url: `${exportAcceptance}`, responseType: "blob" }) - const blob = new Blob([res], {type: 'application/octet-stream'}); - //灏咮lob 瀵硅薄杞崲鎴愬瓧绗︿覆 - let reader = new FileReader(); - reader.readAsText(blob, 'utf-8'); - reader.onload = () => { - try { - let result = JSON.parse(reader.result); - if (result.message) { - this.$message.error(result.message); - } else { - const url = URL.createObjectURL(blob); - const link = document.createElement('a'); - link.href = url; - link.download = '鏍囧噯鐗╄川楠屾敹.xlsx'; - link.click(); - this.$message.success('瀵煎嚭鎴愬姛') - } - } catch (err) { - console.log(err); - const url = URL.createObjectURL(blob); - const link = document.createElement('a'); - link.href = url; - link.download = '鏍囧噯鐗╄川楠屾敹.xlsx'; - link.click(); - this.$message.success('瀵煎嚭鎴愬姛') - } - } + const blob = new Blob([res], { type: 'application/octet-stream' }); + this.$download.saveAs(blob, '鏍囧噯鐗╄川楠屾敹.xlsx'); }, // 鍒嗛〉鍒囨崲 -- Gitblit v1.9.3