批量导出月结明细表
This commit is contained in:
parent
a732a51b9a
commit
ab0c96fdc8
|
|
@ -107,11 +107,6 @@ export const getUnitListByProjetctIds = (params) => {
|
|||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 费用维修审核-提交
|
||||
export function auditSltApi(data) {
|
||||
return request({
|
||||
|
|
@ -121,11 +116,19 @@ export function auditSltApi(data) {
|
|||
})
|
||||
}
|
||||
|
||||
// 导出
|
||||
export function exportLeaseAll(data) {
|
||||
return request({
|
||||
url: 'material/sltAgreementInfo/exportLeaseAll',
|
||||
method: 'post',
|
||||
responseType: 'blob',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ import router from './router'
|
|||
import directive from './directive' // directive
|
||||
import VueDOMPurifyHTML from 'vue-dompurify-html'
|
||||
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
|
||||
|
|
@ -63,6 +63,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.globalUrl = global_
|
||||
Vue.prototype.indexContinuation = indexContinuation
|
||||
|
|
|
|||
|
|
@ -270,4 +270,43 @@ export function downloadJson(url, params, filename, config) {
|
|||
downloadLoadingInstance.close()
|
||||
})
|
||||
}
|
||||
|
||||
// 通用下载方法
|
||||
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
|
||||
|
|
|
|||
|
|
@ -146,8 +146,8 @@
|
|||
|
||||
<script>
|
||||
import { getUnitList, getProjectList } from '@/api/claimAndRefund/receive'
|
||||
import { getSltAgreementInfo,getProjectListByUnitIds,getUnitListByProjetctIds } from '@/api/cost/cost'
|
||||
|
||||
import { getSltAgreementInfo,getProjectListByUnitIds,getUnitListByProjetctIds,exportLeaseAll } from '@/api/cost/cost'
|
||||
import { downloadFile } from '@/utils/download'
|
||||
import ExportDialog from './component/exportDialog.vue'
|
||||
import MonthRecord from './component/monthRecord.vue'
|
||||
import FinishAndDetails from './component/finishAndDetails.vue'
|
||||
|
|
@ -383,7 +383,10 @@ export default {
|
|||
this.ids.forEach((e) => {
|
||||
this.exportParams.push({
|
||||
agreementId: e.agreementId,
|
||||
agreementCode: e.agreementCode,
|
||||
costBearingParty: '',
|
||||
projectName: e.projectName,
|
||||
unitName: e.unitName,
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -395,16 +398,19 @@ export default {
|
|||
},
|
||||
/** 确定按钮 */
|
||||
handleSubmit(form) {
|
||||
console.log("ppppppppppppppppp",form)
|
||||
if (form.length === 1) {
|
||||
this.exportParams.forEach((e) => {
|
||||
e.costBearingParty = form[0]
|
||||
})
|
||||
}
|
||||
|
||||
this.downloadJson(
|
||||
'material/sltAgreementInfo/exportSltInfoMonth',
|
||||
// exportLeaseAll(this.exportParams).then(res => {
|
||||
// downloadFile({ fileName: `月结明细_${new Date().getTime()}.zip`, fileData: res, fileType: 'application/zip;charset=utf-8' })
|
||||
// })
|
||||
this.downloadZip(
|
||||
'material/sltAgreementInfo/exportLeaseAll',
|
||||
JSON.stringify(this.exportParams),
|
||||
`月结明细${new Date().getTime()}.xlsx`,
|
||||
`月结明细${new Date().getTime()}.zip`,
|
||||
)
|
||||
|
||||
this.exportDialogVisible = false
|
||||
|
|
|
|||
Loading…
Reference in New Issue