未结算一键导出zip
This commit is contained in:
		
							parent
							
								
									1f73f483e0
								
							
						
					
					
						commit
						5412daaca0
					
				| 
						 | 
					@ -12,7 +12,7 @@ import store from './store'
 | 
				
			||||||
import router from './router'
 | 
					import router from './router'
 | 
				
			||||||
import directive from './directive' // directive
 | 
					import directive from './directive' // directive
 | 
				
			||||||
import plugins from './plugins' // plugins
 | 
					import plugins from './plugins' // plugins
 | 
				
			||||||
import { download,downloadJson } from '@/utils/request'
 | 
					import { download,downloadJson,downloadZip } from '@/utils/request'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
import './assets/icons' // icon
 | 
					import './assets/icons' // icon
 | 
				
			||||||
import './permission' // permission control
 | 
					import './permission' // permission control
 | 
				
			||||||
| 
						 | 
					@ -49,6 +49,7 @@ Vue.prototype.selectDictLabel = selectDictLabel
 | 
				
			||||||
Vue.prototype.selectDictLabels = selectDictLabels
 | 
					Vue.prototype.selectDictLabels = selectDictLabels
 | 
				
			||||||
Vue.prototype.download = download
 | 
					Vue.prototype.download = download
 | 
				
			||||||
Vue.prototype.downloadJson = downloadJson
 | 
					Vue.prototype.downloadJson = downloadJson
 | 
				
			||||||
 | 
					Vue.prototype.downloadZip = downloadZip
 | 
				
			||||||
Vue.prototype.handleTree = handleTree
 | 
					Vue.prototype.handleTree = handleTree
 | 
				
			||||||
Vue.prototype.indexContinuation = indexContinuation
 | 
					Vue.prototype.indexContinuation = indexContinuation
 | 
				
			||||||
Vue.prototype.globalUrl = global_
 | 
					Vue.prototype.globalUrl = global_
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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
 | 
					export default service
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -26,10 +26,15 @@
 | 
				
			||||||
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery" >查询</el-button>
 | 
					                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery" >查询</el-button>
 | 
				
			||||||
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery" >重置</el-button>
 | 
					                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery" >重置</el-button>
 | 
				
			||||||
                <el-button type="success" icon="el-icon-download" size="mini" @click="exportExcel" :disabled="tableList.length === 0">导出Excel</el-button>
 | 
					                <el-button type="success" icon="el-icon-download" size="mini" @click="exportExcel" :disabled="tableList.length === 0">导出Excel</el-button>
 | 
				
			||||||
 | 
					                <el-button type="success" icon="el-icon-download" size="mini" @click="exportZip" :disabled="tableList.length === 0">批量导出ZIP</el-button>
 | 
				
			||||||
            </el-form-item>
 | 
					            </el-form-item>
 | 
				
			||||||
        </el-form>
 | 
					        </el-form>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        <el-table v-loading="loading" :data="tableList" :max-height="650">
 | 
					        <el-table v-loading="loading"  ref="tableRef" :data="tableList" @selection-change="handleSelectionChange" :max-height="650">
 | 
				
			||||||
 | 
					            <el-table-column
 | 
				
			||||||
 | 
					                type="selection"
 | 
				
			||||||
 | 
					                align="center"
 | 
				
			||||||
 | 
					            />
 | 
				
			||||||
            <el-table-column label="序号" align="center" type="index" width="60">
 | 
					            <el-table-column label="序号" align="center" type="index" width="60">
 | 
				
			||||||
                <template slot-scope="scope">
 | 
					                <template slot-scope="scope">
 | 
				
			||||||
                    <span>{{
 | 
					                    <span>{{
 | 
				
			||||||
| 
						 | 
					@ -424,6 +429,13 @@ export default {
 | 
				
			||||||
        this.getList()
 | 
					        this.getList()
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    methods: {
 | 
					    methods: {
 | 
				
			||||||
 | 
					        // 多选框选中数据
 | 
				
			||||||
 | 
					        handleSelectionChange(selection) {
 | 
				
			||||||
 | 
					            this.ids = selection.map(item => item)
 | 
				
			||||||
 | 
					            this.single = selection.length != 1
 | 
				
			||||||
 | 
					            this.multiple = !selection.length
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        /** 转换菜单数据结构 */
 | 
					        /** 转换菜单数据结构 */
 | 
				
			||||||
        normalizer(node) {
 | 
					        normalizer(node) {
 | 
				
			||||||
            if (node.children && !node.children.length) {
 | 
					            if (node.children && !node.children.length) {
 | 
				
			||||||
| 
						 | 
					@ -558,6 +570,28 @@ export default {
 | 
				
			||||||
            this.aform = { status: '2' };
 | 
					            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){
 | 
					        openPrintDialog(row){
 | 
				
			||||||
            this.openPrint = true
 | 
					            this.openPrint = true
 | 
				
			||||||
            try {
 | 
					            try {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue