<template>
|
<div class="search-form">
|
|
<!-- 筛选条件 -->
|
<CommForm ref="form"
|
formType="search"
|
:column="5"
|
:inline="true"
|
:list="formList"
|
:formValues="formValues"
|
:formRules="formRules"
|
:buttons="formButtons"
|
:isShowAll="isShowAll"
|
labelWidth="60"
|
@updateValue="updateValue"
|
@buttonAction="buttonAction"></CommForm>
|
<div class="middle-button">
|
<!-- :on-change="getList" -->
|
<el-upload :show-file-list="false"
|
:http-request="uploadFile"
|
class="file-uploader"
|
type="primary"
|
action="customize"
|
multiple>
|
<el-button size="mini"
|
class="upload-btn"
|
icon="el-icon-upload2"
|
:loading="uploadLoading">导入流水</el-button>
|
</el-upload>
|
<el-button size="mini"
|
type="primary"
|
@click="batchReceiv">批量入账</el-button>
|
<el-button size="mini"
|
icon="el-icon-download"
|
@click="exportFile">导出</el-button>
|
<!-- <el-button size="mini"
|
@click="publicBatchSubmit">提交审批</el-button> -->
|
</div>
|
|
<!-- 列表 -->
|
<CommTable v-bind="$attrs"
|
:pageInfo="pageInfo"
|
:total="total"
|
:loading="loading"
|
:list="records"
|
:header="tableHeader"
|
:isReserve="true"
|
:isShowMore="false"
|
:isShowCheckbox="true"
|
rowKey="serialno"
|
ref="mainTable"
|
@doAction="doAction"
|
@handleCurrentChange="handleCurrentChange"
|
@handleSizeChange="handleSizeChange"
|
@handleSelectionChange="handleSelectionChange">
|
<template slot-scope="props">
|
<p v-if="props.data.prop=='differenceAmount'">
|
<span :class="['', {'red': props.data.row.differenceAmount>0}]">{{props.data.row.differenceAmount}}</span>
|
</p>
|
</template>
|
</CommTable>
|
|
<el-dialog :visible.sync="dialogBatchVisible"
|
custom-class="comm-dialog"
|
:modal-append-to-body="false"
|
width="450px"
|
title="审批">
|
<el-form ref="dialogForm"
|
:model="form"
|
label-width="80px">
|
<el-form-item label="审批结果"
|
prop="approveCode"
|
:rules="[{ required: true, message: '请选择审批结果'}]">
|
<el-select v-model="form.approveCode"
|
placeholder="请选择审批结果">
|
<el-option label="通过"
|
value="01"></el-option>
|
<el-option label="拒绝"
|
value="02"></el-option>
|
</el-select>
|
</el-form-item>
|
<div class="footer-btn">
|
<el-button @click="resetFormDialog('dialogForm')"
|
size="mini">取消</el-button>
|
<el-button type="primary"
|
size="mini"
|
@click="submitForm('dialogForm')">确定</el-button>
|
</div>
|
</el-form>
|
</el-dialog>
|
</div>
|
</template>
|
<script>
|
// 转账还款认领(批量)
|
import dayjs from 'dayjs'
|
import CommForm from '@/components/CommForm'
|
import CommTable from '@/components/CommTable'
|
import aipOrConfig from '@/controller/repaymentReceive/aipOrConfig'
|
import publicBatchSubmit from '@/controller/publicBatchSubmit'
|
import repaymentReceiveExportReceive from '@/controller/repaymentReceiveExportReceive'
|
|
export default {
|
components: {
|
CommForm,
|
CommTable
|
},
|
props: {
|
model: {
|
type: Object,
|
required: true
|
},
|
// 初始值
|
initValue: {
|
type: Object,
|
default: () => ({})
|
},
|
// 默认请求参数
|
fetchInfo: {
|
type: Object,
|
default: () => ({})
|
},
|
|
codeNo: {
|
type: String,
|
default: ''
|
},
|
|
pageId: {
|
type: String,
|
default: ''
|
}
|
},
|
data() {
|
return {
|
loading: false,
|
uploadLoading: false,
|
dialogBatchVisible: false,
|
isShowAll: true,
|
tempRecord: {},
|
buttonProp: '',
|
tempInfo: {},
|
formList: [],
|
formRules: {},
|
tableHeader: [],
|
formButtons: [
|
{ text: '重置', type: 'default' },
|
{ text: '搜索' }
|
// { text: '展开', type: 'fold' },
|
],
|
pageInfo: {
|
currentPage: 1,
|
pageSize: 10
|
},
|
total: 0,
|
records: [],
|
checkedRecords: [],
|
delRefundModel: null,
|
fileUploadModel: null,
|
fileExportModel: null,
|
accountReceiveModel: null,
|
publicBatchSubmitModel: null,
|
form: {
|
approveCode: null
|
}
|
}
|
},
|
created() {
|
this.init()
|
},
|
mounted() {},
|
methods: {
|
init() {
|
this.$route.meta.keepAlive = true
|
const { model, initValue } = this
|
|
this.formList = model.getFormList(initValue)
|
this.formRules = model.getFormRules()
|
this.tableHeader = model.getTableList()
|
this.fileUploadModel = aipOrConfig('upload')
|
this.deleteReceiveModel = aipOrConfig('del')
|
this.accountReceiveModel = aipOrConfig('account')
|
this.fileExportModel = repaymentReceiveExportReceive()
|
this.publicBatchSubmitModel = publicBatchSubmit()
|
|
this.setSelectOptions()
|
// this.getList()
|
},
|
// 设置表单下拉菜单
|
setSelectOptions(func) {
|
const { formList } = this
|
formList.forEach(({ name }) => {
|
// 当前流程阶段
|
if (name === 'updateDate') {
|
this.updateValue(name, {
|
value: [dayjs().subtract(0, 'day').format('YYYY/MM/DD'), dayjs().format('YYYY/MM/DD')],
|
})
|
}
|
})
|
typeof func === 'function' && func()
|
},
|
|
// 获取列表
|
async getList() {
|
this.loading = true
|
let { pageInfo, formValues, model, fetchInfo } = this
|
const applyno = formValues.applyno.trim()
|
? formValues.applyno
|
.trim()
|
.split('\n')
|
.toString()
|
: ''
|
const bankSerialNumber = formValues.bankSerialNumber.trim()
|
? formValues.bankSerialNumber
|
.trim()
|
.split('\n')
|
.toString()
|
: ''
|
|
const res = await model.request({
|
...fetchInfo,
|
...pageInfo,
|
...formValues,
|
applyno,
|
bankSerialNumber
|
})
|
this.loading = false
|
let { list = [], total } = res
|
list = list.map(item => {
|
return {
|
...item,
|
selectable: item.receiveStatus != '01',
|
action: {
|
buttons: [
|
{ text: '删除', prop: 'delete', disabled: item.receiveStatus == '01' },
|
{
|
text: '入账',
|
prop: 'account',
|
disabled: item.receiveStatus == '01'
|
}
|
]
|
}
|
}
|
})
|
this.records = list
|
this.total = parseInt(total)
|
},
|
|
// 更新表单数据
|
updateValue(index, info) {
|
const { formList } = this
|
if (isNaN(index)) {
|
// index is name
|
index = formList.findIndex(({ name }) => name === index)
|
}
|
if (!isNaN(index) && index > -1) {
|
const preInfo = formList[index]
|
this.$set(formList, index, { ...preInfo, ...info })
|
}
|
},
|
|
// 删除
|
async handleDeleteReceive(data) {
|
const res = await this.deleteReceiveModel.request({
|
serialno: data.serialno
|
})
|
this.$message.success('删除成功')
|
this.getList()
|
|
},
|
// 入账
|
async handleAccountReceive(data, doubleReceive = false) {
|
const res = await this.accountReceiveModel.request({
|
doubleReceive,
|
serialnoArray: [...data]
|
})
|
|
if (res.resultCode == '9999') {
|
this.handleAccountReceive(data, true)
|
return
|
}
|
this.$message.success('操作成功')
|
this.$refs.mainTable.clearTableSelection();
|
this.getList()
|
},
|
|
// async handleDeleteReceive(params) {
|
// this.uploadLoading = true;
|
// try {
|
// let file = params.file;
|
// const res = await this.deleteReceiveModel.request({
|
// file,
|
// });
|
// if (res.code === '00') {
|
// this.$message.success('上传成功');
|
// }
|
// this.uploadLoading = false;
|
// } catch (error) {
|
// this.uploadLoading = false;
|
// }
|
// },
|
// 导入流水
|
async uploadFile(params) {
|
this.uploadLoading = true
|
let url = ''
|
const formData = new FormData()
|
formData.append('file', params.file)
|
if (location.hostname.includes('10.10')) {
|
url =
|
'http://10.10.16.128/rlc-mal/repaymentReceive/uploadBatchReceive'
|
} else {
|
url =
|
process.env.VUE_APP_API_ORIGIN +
|
'/rlc-mal/repaymentReceive/uploadBatchReceive'
|
}
|
fetch(url, {
|
credentials: 'include', // 跨域请求中需要带有cookie
|
method: 'POST',
|
body: formData // 自动修改请求头,formdata的默认请求头的格式是 multipart/form-data
|
}).then(async res => {
|
if (res.headers.get('content-disposition')) {
|
// 切割出文件名
|
const fileNameEncode = res.headers
|
.get('content-disposition')
|
.split('filename=')[1]
|
// 解码
|
const fileName = decodeURIComponent(fileNameEncode)
|
res.blob().then(blob => {
|
var link = document.createElement('a')
|
link.href = window.URL.createObjectURL(blob)
|
link.download = fileName
|
link.click()
|
window.URL.revokeObjectURL(link.href)
|
})
|
this.$message({
|
message: '导入成功,请等待下载结果文件!',
|
type: 'success'
|
})
|
|
this.setSelectOptions(() => {
|
this.getList()
|
})
|
} else {
|
const data = await res.json()
|
this.$message.warning(data.msg)
|
}
|
this.uploadLoading = false
|
})
|
},
|
// 导出
|
async exportFile() {
|
let { formValues, fetchInfo, fileExportModel } = this
|
await fileExportModel.request(formValues)
|
// const params = {
|
// ...fetchInfo,
|
// ...formValues,
|
// };
|
// this.uploadLoading = true;
|
// try {
|
// let file = params.file;
|
// const res = await this.fileExportModel.request({
|
// ...params
|
// });
|
// if (res.code === '00') {
|
// this.$message.success('导出成功');
|
// }
|
// this.uploadLoading = false;
|
// } catch (error) {
|
// this.uploadLoading = false;
|
// }
|
},
|
batchReceiv() {
|
let { checkedRecords } = this
|
if (!checkedRecords.length) {
|
this.$message.warning('请至少选择一条数据')
|
return
|
}
|
let arr = []
|
checkedRecords.map(item => {
|
arr.push(item.serialno)
|
})
|
this.handleAccountReceive([...arr])
|
|
},
|
// 提交审批
|
async publicBatchSubmit() {
|
let { checkedRecords } = this
|
if (!checkedRecords.length) {
|
this.$message.warning('请至少选择一条数据')
|
} else {
|
this.dialogBatchVisible = true
|
}
|
},
|
submitForm(formName) {
|
this.$refs[formName].validate(async valid => {
|
if (valid) {
|
const { checkedRecords, form } = this
|
let arr = []
|
const approveMap = { '01': '通过', '02': '拒绝' }
|
checkedRecords.map(item => {
|
arr.push({
|
logSerialno: item.transSerialno,
|
approveCode: form.approveCode,
|
approveOpinion: approveMap[form.approveCode]
|
})
|
})
|
const res = await this.publicBatchSubmitModel.request(arr)
|
if (res.status == '00') {
|
this.$message.success('审批提交')
|
} else {
|
this.$message.warning(res.message)
|
}
|
} else {
|
return false
|
}
|
})
|
},
|
resetFormDialog(formName) {
|
this.$refs[formName].resetFields()
|
this.dialogBatchVisible = false
|
},
|
// 表格按钮事件处理
|
doAction(item, record) {
|
console.log(item, record)
|
const { prop } = item
|
// 删除
|
if (prop === 'delete') {
|
this.$confirm(
|
`此操作将删除${record.applyno}申请, 是否继续?`,
|
'提示',
|
{
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}
|
)
|
.then(() => {
|
this.handleDeleteReceive(record)
|
})
|
.catch(() => {})
|
}
|
// 入账
|
if (prop === 'account') {
|
this.handleAccountReceive([record.serialno])
|
// if(record.differenceAmount == 0) {
|
// this.handleAccountReceive(record)
|
// return
|
// }
|
// this.$confirm(
|
// `流水金额与结清入账金额差额为${record.differenceAmount},入账需使用虚拟流水补账,请确认是否入账?`,
|
// '提示',
|
// {
|
// confirmButtonText: '确定',
|
// cancelButtonText: '取消',
|
// type: 'warning'
|
// }
|
// )
|
// .then(() => {
|
// this.handleAccountReceive(record)
|
// })
|
// .catch(() => {})
|
}
|
},
|
// 修改翻页条数
|
handleSizeChange(val) {
|
this.pageInfo.pageSize = val
|
this.getList()
|
},
|
|
// 修改翻页数
|
handleCurrentChange(val) {
|
this.pageInfo.currentPage = val
|
this.getList()
|
},
|
|
handleSelectionChange(checkedRecords) {
|
this.checkedRecords = checkedRecords
|
|
// const orderNum = checkedRecords.reduce(
|
// (pre, curr, index) =>
|
// checkedRecords.some(
|
// ({ periodNo }) => periodNo === records[index].periodNo
|
// )
|
// ? pre + 1
|
// : pre,
|
// 0
|
// )
|
// if (orderNum === checkedRecords.length) {
|
// let periodNo = checkedRecords.reduce((pre, curr) => {
|
// return (pre += curr.periodNo + ',')
|
// }, '')
|
// this.periodNo = periodNo.substr(0, periodNo.length - 1)
|
// this.checkedRecords = checkedRecords
|
// } else {
|
// this.$message.warning('只能依次选择。')
|
// this.checkedRecords = []
|
// this.$refs.repaymentApplyTable.$refs.commTable.clearSelection()
|
// }
|
},
|
|
// // 修改翻页条数
|
// planHandleSizeChange(val) {
|
// this.planPageInfo.pageSize = val
|
// this.getPlanList()
|
// },
|
|
// // 修改翻页数
|
// planHandleCurrentChange(val) {
|
// this.planPageInfo.currentPage = val
|
// this.getPlanList()
|
// },
|
|
// 表单按钮事件处理
|
buttonAction(id) {
|
if (id === 0) {
|
this.resetForm()
|
}
|
if (id === 1) {
|
this.resetList()
|
}
|
if (id === 2) {
|
const { isShowAll } = this
|
this.isShowAll = !isShowAll
|
}
|
},
|
|
toShowSucc() {
|
this.getList()
|
},
|
|
resetList() {
|
this.pageInfo.currentPage = 1
|
this.getList()
|
},
|
resetForm() {
|
const { model } = this
|
this.formList = model.getFormList()
|
this.setSelectOptions()
|
// this.resetList();
|
}
|
},
|
computed: {
|
// 表单值信息
|
formValues() {
|
const { model, formList } = this
|
return model.getFormValues(formList)
|
}
|
}
|
}
|
</script>
|
<style lang="postcss" scoped>
|
.upload-btn {
|
height: 32px;
|
margin-right: 10px;
|
padding: 9px 15px;
|
color: #fff;
|
border-color: #0081f0;
|
background-color: #0081f0;
|
}
|
.footer-btn {
|
margin-top: 50px;
|
text-align: center;
|
}
|
>>> .el-select {
|
width: 100%;
|
}
|
.red {
|
color: red;
|
}
|
</style>
|