<template>
|
<div class="apply-info">
|
<div class="title" v-if="title">
|
<SectionTitle :title="title"></SectionTitle>
|
<div class="middle-button" v-if="isEdit && typeId === 3">
|
<el-button type="primary" @click="toExport" size="small">下载变更后还款计划</el-button>
|
<el-button type="primary" @click="getPlanList" size="small">查询变更后还款计划</el-button>
|
</div>
|
</div>
|
<CommForm
|
:inline="true"
|
:list="formList"
|
@updateValue="updateValue"
|
:formValues="formValues"
|
:formRules="formRules"
|
formType="info"
|
:ref="refId"
|
></CommForm>
|
|
<Dialog
|
v-model="isShowDialog"
|
icon="succ"
|
iconText="提交成功"
|
:buttons="[{text: '确定', type: 'primary'}]"
|
@handleClick="commitSuccess"
|
></Dialog>
|
|
<el-dialog
|
:visible.sync="dialogTableVisible"
|
custom-class="comm-dialog"
|
:modal-append-to-body="false"
|
width="850px"
|
>
|
<RepaymentPlanChanged
|
:tableHeader="planHeader"
|
:pageInfo="planPageInfo"
|
:total="planTotal"
|
:info="{...acctLoanInfo}"
|
:list="planRecords"
|
@handleSizeChange="planHandleSizeChange"
|
@handleCurrentChange="planHandleCurrentChange"
|
:loading="planLoading"
|
:buttons="['下载变更后还款计划']"
|
@action="toExport"
|
></RepaymentPlanChanged>
|
</el-dialog>
|
</div>
|
</template>
|
<script>
|
// 查询还款计划变更后还款计划
|
import { mapState, mapMutations } from 'vuex'
|
import CommForm from '@/components/CommForm'
|
import Dialog from '@/components/Dialog'
|
import SectionTitle from '@/components/SectionTitle'
|
import RepaymentPlanChanged from '@/components/RepaymentPlanChanged'
|
import queryChangePsWaiveInfo from '@/controller/queryChangePsWaiveInfo'
|
import queryCodeValueList from '@/controller/queryCodeValueList'
|
import queryPaymentMethod from '@/controller/queryPaymentMethod'
|
import createPaymentScheduleChange from '@/controller/createPaymentScheduleChange'
|
import queryChangePaymentScheduleList from '@/controller/queryChangePaymentScheduleList'
|
import queryChangePsLoanInfo from '@/controller/queryChangePsLoanInfo'
|
import downloadChangePsListExport from '@/controller/downloadChangePsListExport'
|
|
export default {
|
components: {
|
CommForm,
|
Dialog,
|
SectionTitle,
|
RepaymentPlanChanged
|
},
|
props: {
|
conf: {
|
type: Object,
|
default: () => ({})
|
},
|
typeId: {
|
type: Number,
|
required: true
|
}
|
},
|
data() {
|
return {
|
info: {},
|
query: {},
|
formList: [],
|
waivePayAmtKeys: [],
|
actualPayAmtKeys: [],
|
planModel: null,
|
exportModel: null,
|
planHeader: [],
|
planPageInfo: {
|
currentPage: 1,
|
pageSize: 500000 // 分页可能性能有问题,设定为50基本不会有分页
|
},
|
planTotal: 0,
|
planRecords: [],
|
planLoading: false,
|
selectObj: {},
|
isInit: false,
|
isShowDialog: false,
|
dialogTableVisible: false,
|
// [余额,还款,减免,剩余]
|
changeKeys: [
|
[
|
'umPayInterestAmtA6Sum',
|
'actualPayInterestAmtA6',
|
'waivePayInterestAmtA6',
|
'interestAmtA6Balance'
|
],
|
[
|
'umPayInterestAmtA8Sum',
|
'actualPayInterestAmtA8',
|
'waivePayInterestAmtA8',
|
'interestAmtA8Balance'
|
],
|
[
|
'umPayInterestAmtA3Sum',
|
'actualPayInterestAmtA3',
|
'waivePayInterestAmtA3',
|
'interestAmtA3Balance'
|
],
|
[
|
'umPayInterestAmtA1Sum',
|
'actualPayInterestAmtA1',
|
'waivePayInterestAmtA1',
|
'interestAmtA1Balance'
|
],
|
[
|
'umPayInterestAmtA2Sum',
|
'actualPayInterestAmtA2',
|
'waivePayInterestAmtA2',
|
'interestAmtA2Balance'
|
],
|
[
|
'umPayInterestAmtSum',
|
'actualPayInterestAmt',
|
'waivePayInterestAmt',
|
'interestAmtBalance'
|
],
|
[
|
'umPayPrinciPalAmtSum',
|
'actualPayPrinciPalAmt',
|
'',
|
'princiPalAmtBalance'
|
],
|
[
|
'umPayInterestAmtA5Sum',
|
'actualPayInterestAmtA5',
|
'waivePayInterestAmtA5',
|
'interestAmtA5Balance'
|
],
|
[
|
'umPayInterestAmtA4Sum',
|
'actualPayInterestAmtA4',
|
'waivePayInterestAmtA4',
|
'interestAmtA4Balance'
|
]
|
],
|
model: null,
|
loanInfokeys: {},
|
tempLoanTermUnit: '' // 记录选择的新贷款期限单位
|
}
|
},
|
created() {
|
this.init()
|
},
|
methods: {
|
init() {
|
const { typeId, $route } = this
|
const { query } = $route
|
this.query = query
|
this.model = queryChangePsWaiveInfo(typeId)
|
this.exportModel = downloadChangePsListExport()
|
const planModel = queryChangePaymentScheduleList()
|
const planHeader = planModel.getTableList()
|
this.planModel = planModel
|
this.planHeader = planHeader
|
this.loanInfokeys = queryChangePsLoanInfo()
|
.getFormList()
|
.reduce((pre, curr) => {
|
const { label, name } = curr
|
pre[name] = label
|
return pre
|
}, {})
|
|
this.submitModel = createPaymentScheduleChange()
|
this.waivePayAmtKeys = queryChangePsWaiveInfo(1)
|
.getFormList()
|
.map(({ name }) => name)
|
|
this.actualPayAmtKeys = queryChangePsWaiveInfo(2)
|
.getFormList()
|
.map(({ name }) => name)
|
},
|
getDetail() {
|
const { changePsWaiveInfo, model, isEdit } = this
|
let formList = model.getFormList(changePsWaiveInfo)
|
if (isEdit) {
|
this.formList = formList
|
this.setSelectOptions()
|
} else {
|
this.formList = formList.map(item => {
|
let { descName, value } = item
|
if (descName) {
|
value = changePsWaiveInfo[descName]
|
}
|
return {
|
...item,
|
attrs: ['readonly'],
|
value,
|
rules: []
|
}
|
})
|
}
|
},
|
|
async toExport() {
|
let {
|
planPageInfo,
|
exportModel,
|
query,
|
refId,
|
changePsWaiveInfo,
|
acctLoanInfo
|
} = this
|
const { transLogSerialno, transCode, loanSerialno } = query
|
const values = this.$refs[refId].validate()
|
if (values) {
|
// this.planLoading = true
|
await exportModel.request({
|
logSerialno: transLogSerialno,
|
loanSerialno,
|
transCode,
|
...planPageInfo,
|
...acctLoanInfo,
|
...changePsWaiveInfo,
|
...values // 使用values主要为修正日期格式
|
})
|
// this.planLoading = false
|
// const { list = [], total } = res
|
// this.planRecords = list
|
// this.planTotal = parseInt(total)
|
// this.dialogTableVisible = true
|
}
|
},
|
|
// 设置表单下拉菜单
|
setSelectOptions() {
|
const { formList } = this
|
formList.forEach(({ name, attrs = [] }) => {
|
if (
|
attrs.some(
|
item =>
|
(typeof item === 'object' && item.readonly) || item === 'readonly'
|
)
|
) {
|
return false
|
}
|
if (name === 'residueFeeWay') {
|
this.queryCodeValueList(name, 'ResidueFeeWay')
|
}
|
if (name === 'receivableWay') {
|
this.queryCodeValueList(name, 'ReceivableWay')
|
}
|
if (name === 'interestPeriod') {
|
this.queryCodeValueList(name, 'ChangePsInterestPeriod')
|
}
|
if (name === 'loanTermUnit') {
|
this.queryCodeValueList(name, 'LoanTermUnit')
|
}
|
if (name === 'interestCaliber') {
|
this.queryCodeValueList(name, 'InterestCaliber')
|
}
|
if (name === 'applyType') {
|
this.queryCodeValueList(name, 'ChangePsApplyType')
|
}
|
|
if (name === 'payTermid') {
|
this.queryMethodList(name)
|
}
|
})
|
},
|
|
// 获取select中options数据
|
async queryCodeValueList(name, codeNo) {
|
const { selectObj } = this
|
if (!selectObj[name]) {
|
const tempModel = queryCodeValueList()
|
const { list } = await tempModel.request({ codeNo })
|
this.selectObj[name] = list
|
}
|
this.updateValue(name, { options: this.selectObj[name] }, false)
|
},
|
|
// 获取select中options数据
|
async queryMethodList(name) {
|
const { selectObj } = this
|
if (!selectObj[name]) {
|
const tempModel = queryPaymentMethod()
|
const { list } = await tempModel.request({ paymentMethod: '' })
|
this.selectObj[name] = list
|
}
|
this.updateValue(name, { options: this.selectObj[name] }, false)
|
},
|
|
// 获取列表
|
async getPlanList() {
|
let {
|
planPageInfo,
|
planModel,
|
query,
|
refId,
|
changePsWaiveInfo,
|
acctLoanInfo
|
} = this
|
const { transLogSerialno, transCode, loanSerialno } = query
|
const values = this.$refs[refId].validate()
|
if (values) {
|
this.planLoading = true
|
const res = await planModel.request({
|
logSerialno: transLogSerialno,
|
loanSerialno,
|
transCode,
|
...planPageInfo,
|
...acctLoanInfo,
|
...changePsWaiveInfo,
|
...values // 使用values主要为修正日期格式
|
})
|
this.planLoading = false
|
const { list = [], total } = res
|
this.planRecords = list
|
this.planTotal = parseInt(total)
|
this.dialogTableVisible = true
|
}
|
},
|
|
// 修改翻页条数
|
planHandleSizeChange(val) {
|
this.planPageInfo.pageSize = val
|
this.getPlanList()
|
},
|
|
// 修改翻页数
|
planHandleCurrentChange(val) {
|
this.planPageInfo.currentPage = val
|
this.getPlanList()
|
},
|
|
// 更新表单数据
|
updateValue(index, info, flg = true) {
|
const {
|
formList,
|
typeId,
|
changeKeys,
|
changePsWaiveInfo,
|
acctLoanInfo, // 借据信息数据
|
waivePayAmtKeys,
|
actualPayAmtKeys,
|
loanInfokeys
|
} = this
|
if (isNaN(index)) {
|
// index is name
|
index = formList.findIndex(({ name }) => name === index)
|
}
|
|
if (!isNaN(index) && index > -1) {
|
if (!flg) {
|
const preInfo = formList[index]
|
this.$set(formList, index, { ...preInfo, ...info })
|
} else {
|
this.setChangeFlg(typeId)
|
const { name, value } = info
|
const tempInfo = { ...changePsWaiveInfo, [name]: value }
|
const current = changeKeys.find(item => item.includes(name))
|
const { rateChangeFlag = '' } = tempInfo
|
let updateInfo = { [name]: value }
|
|
if (name !== 'rateChangeFlag' && Number(rateChangeFlag) !== 0) {
|
updateInfo = {
|
...updateInfo,
|
rateChangeFlag: Number(rateChangeFlag).toFixed(10)
|
}
|
}
|
|
if (current) {
|
const total = acctLoanInfo[current[0]] || 0
|
const a1 = tempInfo[current[1]] || 0
|
|
const a2 = tempInfo[current[2]] || 0
|
// 剩余应还提前还款违约金 = 提前还款违约金余额 - 还款提前还款违约金 - 减免提前还款违约金
|
const result = (Number(total) - Number(a1) - Number(a2)).toFixed(2)
|
const updataName = current[3]
|
if (result >= 0) {
|
updateInfo[updataName] = result
|
if (updataName === 'interestAmtA4Balance') {
|
updateInfo['waiveAfterPrinciPalPenaltyAmt'] = result
|
}
|
} else {
|
this.$message(
|
`${this.findLabel(2, current[1])}与${this.findLabel(
|
1,
|
current[2]
|
)}之和${
|
updataName === 'interestAmtA4Balance'
|
? '只能等于'
|
: '不能大于'
|
}${loanInfokeys[current[0]]}`
|
)
|
updateInfo = null
|
}
|
}
|
// 当新贷款期限单位选项为'天'后录入了新首期还款日。再次切换回'月'时应该清空新首期还款日,然后重新录取
|
if (name === 'loanTermUnit') {
|
this.tempLoanTermUnit = value
|
if (value === '01') {
|
this.changePsWaiveInfo.defaultDueDay = ''
|
}
|
}
|
|
// 新首期还款日defaultDueDay不能小于首次计息开始日期firstputoutDate
|
if (name === 'defaultDueDay' || name === 'firstPutOutDate') {
|
const { tempLoanTermUnit } = this
|
// 只有当新贷款期限单位为'月'时才对日期进行限制,为天可以任意选择日期
|
if (tempLoanTermUnit === '01') {
|
const { defaultDueDay, firstPutOutDate } = tempInfo
|
const defDate = new Date(defaultDueDay)
|
const day = defDate.getDate()
|
const firstTime = new Date(firstPutOutDate).getTime()
|
if (
|
day > 25 ||
|
(value !== '' &&
|
firstPutOutDate !== '' &&
|
defDate.getTime() < firstTime)
|
) {
|
this.$message(
|
day > 25
|
? '新首期还款日需小于25日'
|
: '新首期还款日不能小于首次计息开始日期'
|
)
|
updateInfo = null
|
}
|
}
|
}
|
|
/*
|
// 原 新首期还款日defaultDueDay不能小于首次计息开始日期firstputoutDate 逻辑
|
if (name === 'defaultDueDay' || name === 'firstPutOutDate') {
|
const { defaultDueDay, firstPutOutDate } = tempInfo
|
const defDate = new Date(defaultDueDay)
|
const day = defDate.getDate()
|
const firstTime = new Date(firstPutOutDate).getTime()
|
if (
|
day > 25 ||
|
(value !== '' &&
|
firstPutOutDate !== '' &&
|
defDate.getTime() < firstTime)
|
) {
|
this.$message(
|
day > 25
|
? '新首期还款日需小于25日'
|
: '新首期还款日不能小于首次计息开始日期'
|
)
|
updateInfo = null
|
}
|
}
|
*/
|
|
|
if (name === 'waiveprincipalamt' || name === 'actualPayPrinciPalAmt') {
|
let { aheadfee, umPayPrinciPalAmtSum } = acctLoanInfo
|
let { waiveprincipalamt, actualPayPrinciPalAmt } = tempInfo
|
// console.log(Number(waiveprincipalamt), '--', Number(aheadfee),'--',actualPayPrinciPalAmt)
|
if (Number(waiveprincipalamt) > Number(aheadfee)) {
|
this.$message.warning('重组本金损失金额不能大于零期实收息费金额')
|
updateInfo = null
|
} else {
|
const result = (Number(umPayPrinciPalAmtSum)-Number(waiveprincipalamt)-Number(actualPayPrinciPalAmt)).toFixed(2)
|
updateInfo['princiPalAmtBalance'] = result
|
}
|
}
|
|
if (updateInfo) {
|
const waivePayAmt = waivePayAmtKeys
|
.filter(
|
key =>
|
!['waiveAfterPrinciPalPenaltyAmt', 'waivePayAmt'].includes(
|
key
|
)
|
)
|
.reduce((pre, curr, index) => {
|
const temp = Number(tempInfo[curr]) || 0
|
pre = pre + temp
|
return pre
|
}, 0)
|
|
const actualPayAmt = actualPayAmtKeys.reduce((pre, curr, index) => {
|
if (index < actualPayAmtKeys.length - 1) {
|
const temp = Number(tempInfo[curr]) || 0
|
pre = pre + temp
|
}
|
return pre
|
}, 0)
|
|
updateInfo.waivePayAmt = (Number(waivePayAmt) || 0).toFixed(2)
|
updateInfo.actualPayAmt = (Number(actualPayAmt) || 0).toFixed(2)
|
|
this.updateChangePsWaiveInfo(updateInfo)
|
this.getDetail()
|
} else {
|
// this.$message('当前页面存在必填项未录入或数据录入错误,请检查!')
|
}
|
}
|
}
|
},
|
|
findLabel(typeId, key) {
|
const item = queryChangePsWaiveInfo(typeId)
|
.getFormList()
|
.find(({ name }) => name === key)
|
return item ? item.label : ''
|
},
|
|
// 表单按钮事件处理
|
async submit() {
|
const {
|
submitModel,
|
query,
|
refId,
|
changePsWaiveInfo,
|
acctLoanInfo,
|
isEdit
|
} = this
|
const { transLogSerialno, transCode, isFromClaim } = query
|
if (!isEdit || isFromClaim === '1') {
|
return false
|
}
|
|
const values = this.$refs[refId].validate()
|
if (values) {
|
// const loading = this.$loading({
|
// fullscreen: true
|
// })
|
try {
|
await submitModel.request({
|
logSerialno: transLogSerialno,
|
transCode,
|
...acctLoanInfo,
|
...changePsWaiveInfo,
|
...values // 使用values主要为修正日期格式
|
})
|
// loading.close()
|
this.getDetail()
|
this.isShowDialog = true
|
} catch (e) {
|
// loading.close()
|
}
|
} else {
|
this.$message.warning('当前页面存在必填项未录入或数据录入错误,请检查!')
|
}
|
},
|
// 提交成功后返回原列表页
|
commitSuccess() {
|
this.isShowDialog = false
|
this.$router.go(-1)
|
},
|
...mapMutations(['setChangeFlg', 'updateChangePsWaiveInfo'])
|
},
|
computed: {
|
isEdit() {
|
const { conf } = this
|
return conf.edit === 'Y'
|
},
|
title() {
|
const { typeId } = this
|
let result = ''
|
if (typeId === 1) {
|
result = '变更前减免信息'
|
}
|
|
if (typeId === 2) {
|
result = '变更前还款息费'
|
}
|
|
if (typeId === 3) {
|
result = '变更申请信息'
|
}
|
return result
|
},
|
refId() {
|
const { typeId } = this
|
return `repaymentForm${typeId}`
|
},
|
formValues() {
|
const { model, formList } = this
|
return model ? model.getFormValues(formList) : {}
|
},
|
formRules() {
|
const { model, formList } = this
|
if (model) {
|
return model.getFormRules(formList)
|
}
|
return {}
|
},
|
...mapState({
|
changePsWaiveInfo: state => state.tabsModule.changePsWaiveInfo,
|
changeFlg: state => state.tabsModule.changeFlg,
|
acctLoanInfo: state => state.tabsModule.acctLoanInfo
|
})
|
},
|
watch: {
|
changePsWaiveInfo() {
|
const { changeFlg, isInit, typeId } = this
|
if (!isInit) {
|
this.getDetail()
|
this.isInit = true
|
} else if (changeFlg !== typeId) {
|
this.getDetail()
|
}
|
}
|
}
|
}
|
</script>
|
<style lang="postcss" scoped>
|
.apply-info {
|
}
|
.title {
|
display: flex;
|
padding-right: 40px;
|
justify-content: space-between;
|
}
|
</style>
|