From 5412daaca05811d4c249590217aa549333ee1dff Mon Sep 17 00:00:00 2001
From: hongchao <3228015117@qq.com>
Date: Tue, 21 Oct 2025 17:39:25 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9C=AA=E7=BB=93=E7=AE=97=E4=B8=80=E9=94=AE?=
=?UTF-8?q?=E5=AF=BC=E5=87=BAzip?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/main.js | 3 +-
src/utils/request.js | 39 +++++++++++++++++++
.../material/cost/component/unreportHome.vue | 36 ++++++++++++++++-
3 files changed, 76 insertions(+), 2 deletions(-)
diff --git a/src/main.js b/src/main.js
index c4cb2a68..06e19fd6 100644
--- a/src/main.js
+++ b/src/main.js
@@ -12,7 +12,7 @@ import store from './store'
import router from './router'
import directive from './directive' // directive
import plugins from './plugins' // plugins
-import { download,downloadJson } from '@/utils/request'
+import { download,downloadJson,downloadZip } from '@/utils/request'
import './assets/icons' // icon
import './permission' // permission control
@@ -49,6 +49,7 @@ Vue.prototype.selectDictLabel = selectDictLabel
Vue.prototype.selectDictLabels = selectDictLabels
Vue.prototype.download = download
Vue.prototype.downloadJson = downloadJson
+Vue.prototype.downloadZip = downloadZip
Vue.prototype.handleTree = handleTree
Vue.prototype.indexContinuation = indexContinuation
Vue.prototype.globalUrl = global_
diff --git a/src/utils/request.js b/src/utils/request.js
index b2c48f6f..6ae46169 100644
--- a/src/utils/request.js
+++ b/src/utils/request.js
@@ -225,4 +225,43 @@ export function downloadJson(url, params, filename, config) {
})
}
+
+// 通用下载方法
+export function downloadZip(url, params, filename, config) {
+ downloadLoadingInstance = Loading.service({
+ text: '正在下载数据,请稍候',
+ spinner: 'el-icon-loading',
+ background: 'rgba(0, 0, 0, 0.7)',
+ })
+ return service
+ .post(url, params, {
+ transformRequest: [
+ (params) => {
+ return params
+ },
+ ],
+ headers: { 'Content-Type': 'application/json',encryptResponse: false },
+ responseType: 'blob',
+ ...config,
+ })
+ .then(async (data) => {
+ const isBlob = blobValidate(data)
+ if (isBlob) {
+ const blob = new Blob([data])
+ saveAs(blob, filename)
+ } else {
+ const resText = await data.text()
+ const rspObj = JSON.parse(resText)
+ const errMsg =
+ errorCode[rspObj.code] || rspObj.msg || errorCode['default']
+ Message.error(errMsg)
+ }
+ downloadLoadingInstance.close()
+ })
+ .catch((r) => {
+ console.error(r)
+ Message.error('下载文件出现错误,请联系管理员!')
+ downloadLoadingInstance.close()
+ })
+}
export default service
diff --git a/src/views/material/cost/component/unreportHome.vue b/src/views/material/cost/component/unreportHome.vue
index d4289af2..78074234 100644
--- a/src/views/material/cost/component/unreportHome.vue
+++ b/src/views/material/cost/component/unreportHome.vue
@@ -26,10 +26,15 @@
查询
重置
导出Excel
+ 批量导出ZIP
-
+
+
{{
@@ -424,6 +429,13 @@ export default {
this.getList()
},
methods: {
+ // 多选框选中数据
+ handleSelectionChange(selection) {
+ this.ids = selection.map(item => item)
+ this.single = selection.length != 1
+ this.multiple = !selection.length
+ },
+
/** 转换菜单数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
@@ -558,6 +570,28 @@ export default {
this.aform = { status: '2' };
},
+ //批量导出zip
+ exportZip() {
+ if (!this.ids.length) {
+ this.$message.error('请选择要导出的记录')
+ }
+ let param = []
+ this.ids.map(item => {
+ param.push({ agreementId: item.agreementId,settlementType:item.settlementType })
+ })
+ // exportLeaseAll(this.exportParams).then(res => {
+ // downloadFile({ fileName: `月结明细_${new Date().getTime()}.zip`, fileData: res, fileType: 'application/zip;charset=utf-8' })
+ // })
+ this.downloadZip(
+ 'material/slt_agreement_info/exportUnsettled',
+ JSON.stringify(param),
+ `未结算批量明细导出_${new Date().getTime()}.zip`,
+ )
+
+ this.$refs.tableRef.clearSelection()
+ },
+
+
openPrintDialog(row){
this.openPrint = true
try {