Browse Source

完善出纳付款--打印pdf

master
yunuo970428 3 years ago
parent
commit
be2ea03e61
  1. 8
      anrui-buscenter/anrui-finmanage-ui/src/api/anruifinmanagement/chunafukuan/cashier.js
  2. 80
      anrui-buscenter/anrui-finmanage-ui/src/views/anruifinmanagement/chunafukuan/chunafukuanguanli/cashier.vue

8
anrui-buscenter/anrui-finmanage-ui/src/api/anruifinmanagement/chunafukuan/cashier.js

@ -27,5 +27,13 @@ export default {
data: params, data: params,
headers: { 'Content-Type': 'application/json' } headers: { 'Content-Type': 'application/json' }
}) })
},
// 通过sid作废一条或多条记录
createPdf: function(data) {
return request({
url: '/fin/v1/finpaymentrecord/createPdf',
method: 'post',
params: data
})
} }
} }

80
anrui-buscenter/anrui-finmanage-ui/src/views/anruifinmanagement/chunafukuan/chunafukuanguanli/cashier.vue

@ -43,7 +43,7 @@
<el-table :key="tableKey" v-loading="listLoading" :data="list" border style="width: 100%;" @selection-change="handleSelectionChange"> <el-table :key="tableKey" v-loading="listLoading" :data="list" border style="width: 100%;" @selection-change="handleSelectionChange">
<el-table-column width="50px" fixed type="selection" align="center"/> <el-table-column width="50px" fixed type="selection" align="center"/>
<el-table-column width="80px" fixed label="序号" type="index" :index="indexMethod" align="center"/> <el-table-column width="80px" fixed label="序号" type="index" :index="indexMethod" align="center"/>
<el-table-column label="操作" fixed width="100px" align="center"> <el-table-column label="操作" fixed width="180px" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="primary" size="mini" @click="handlePrint(scope.row)">打印</el-button> <el-button type="primary" size="mini" @click="handlePrint(scope.row)">打印</el-button>
<el-button type="primary" :disabled="scope.row.state === '未支付' ? false : true" size="mini" @click="handleEdit(scope.row)">办理</el-button> <el-button type="primary" :disabled="scope.row.state === '未支付' ? false : true" size="mini" @click="handleEdit(scope.row)">办理</el-button>
@ -462,34 +462,58 @@ export default {
this.dialogUrl = row.payFile this.dialogUrl = row.payFile
}, },
handlePrint(row) { handlePrint(row) {
axios({ req.createPdf({ sid: row.sid }).then((resp) => {
method: 'get', if (resp.success) {
url: process.env.VUE_APP_URL + '/api/fin/v1/finpaymentrecord/createPdf', var xhr = new XMLHttpRequest()
params: { xhr.open('GET', process.env.VUE_APP_BASE_API + '/base/file/download?filePath=' + resp.data + '&outFileName=' + '出纳', true)
sid: row.sid xhr.setRequestHeader('token', getStorage())
}, xhr.responseType = 'blob'
responseType: 'blob', xhr.onload = function(e) {
headers: { token: getStorage() } //
}).then((response) => { var blob = this.response
console.log(response) var filename = '预付款申请.pdf'
if (response.data == undefined) { var a = document.createElement('a')
const blob = new Blob([response], { type: 'application/pdf' }) // blob.type="application/octet-stream";
const link = document.createElement('a') // url
link.href = window.URL.createObjectURL(blob) var url = URL.createObjectURL(blob)
link.download = '出纳付款.pdf' a.href = url
link.click() a.download = filename
window.URL.revokeObjectURL(link.href) a.click()
} else { // URL
const blob = new Blob([response.data], { type: 'application/pdf' }) window.URL.revokeObjectURL(url)
const link = document.createElement('a') }
link.href = window.URL.createObjectURL(blob) //
link.download = '出纳付款.pdf' xhr.send()
link.click() }
window.URL.revokeObjectURL(link.href)
}
}).catch(error => {
this.$message.error(error)
}) })
// axios({
// method: 'post',
// url: '/api' + '/fin/v1/finpaymentrecord/createPdf',
// params: {
// sid: row.sid
// },
// responseType: 'blob',
// headers: { token: getStorage() }
// }).then((response) => {
// console.log(response)
// if (response.data == undefined) {
// const blob = new Blob([response], { type: 'application/pdf' })
// const link = document.createElement('a')
// link.href = window.URL.createObjectURL(blob)
// link.download = '.pdf'
// link.click()
// window.URL.revokeObjectURL(link.href)
// } else {
// const blob = new Blob([response.data], { type: 'application/pdf' })
// const link = document.createElement('a')
// link.href = window.URL.createObjectURL(blob)
// link.download = '.pdf'
// link.click()
// window.URL.revokeObjectURL(link.href)
// }
// }).catch(error => {
// this.$message.error(error)
// })
}, },
handleEdit(row) { handleEdit(row) {
this.dialogVisible = true this.dialogVisible = true

Loading…
Cancel
Save