<template>
|
<div class="apply-info">
|
<div class="dialog-form">
|
<p class="dialog-form-title">{{buttonProp === 'virtualClaimUndoButton' ? '贴息项目确认' : '贴息项目确认'}}</p>
|
<CommForm
|
:inline="true"
|
:list="titleFormList"
|
@updateValue="updateValueTitle"
|
ref="titleForm"
|
:formValues="titleFormValues"
|
:formRules="titleFormRules"
|
:column="2"
|
></CommForm>
|
<CommForm
|
:inline="true"
|
:list="formList"
|
@updateValue="updateValue"
|
ref="editClaimForm"
|
:formValues="formValues"
|
:formRules="formRules"
|
:column="2"
|
></CommForm>
|
<div class="dialog-form-buttons">
|
<p>
|
<el-button class="comm-button" @click="$emit('close')">取消</el-button>
|
</p>
|
<p>
|
<el-button class="comm-button" type="primary" @click="submit">确认</el-button>
|
</p>
|
</div>
|
</div>
|
</div>
|
</template>
|
<script>
|
// 项目确认
|
import CommForm from '@/components/CommForm'
|
// import virtualClaimConfirm from '@/controller/virtualClaimConfirm'
|
// import virtualClaimCancel from '@/controller/virtualClaimCancel'
|
|
// 流水上传
|
import updateDisCountUpload from '@/controller/updateDisCountUpload'
|
// 项目名称列表
|
import queryProjectList from '@/controller/queryProjectList'
|
import qryFlowPhaseList from '@/controller/qryFlowPhaseList'
|
// 贴息结算上传获取收款账户信息
|
import queryDisUploadAccount from '@/controller/queryDisUploadAccount'
|
|
export default {
|
components: {
|
CommForm
|
},
|
props: {
|
info: {
|
type: Object,
|
default: () => ({})
|
},
|
isShow: {
|
type: Boolean,
|
default: false
|
},
|
detail: {
|
type: Object,
|
default: () => ({})
|
},
|
trxnBr: {
|
type: String,
|
default: ''
|
},
|
buttonProp: {
|
type: String,
|
default: ''
|
},
|
uploadFlowParams: {
|
type: Object,
|
default: () => ({})
|
}
|
},
|
data() {
|
return {
|
formList: [],
|
titleFormList: [],
|
titleFormRules: {},
|
model: null,
|
isCancle: false,
|
uploadFlowModel: null,
|
acctNo: '',
|
acctName: ''
|
}
|
},
|
created() {
|
this.init()
|
},
|
methods: {
|
init() {
|
const { buttonProp, detail } = this
|
// const isCancle = buttonProp === 'virtualClaimUndoButton'
|
const model = updateDisCountUpload()
|
// const cancleModel = virtualClaimCancel()
|
// this.isCancle = isCancle
|
this.model = model
|
this.formList = model.getFormList(detail)
|
const titleModel = queryDisUploadAccount()
|
this.titleFormList = titleModel.getFormList()
|
this.titleFormRules = titleModel.getFormRules()
|
this.titleModel = titleModel
|
this.mode = updateDisCountUpload()
|
this.setSelectOptions()
|
},
|
|
// 设置下拉值
|
setSelectOptions() {
|
const { formList, titleFormList } = this
|
formList.forEach(({ name }) => {
|
if (name === 'projectName') {
|
this.queryProjectList(name)
|
}
|
})
|
|
titleFormList.forEach(({ name }) => {
|
if (name === 'accountName') {
|
this.queryDisUploadAccountName(name)
|
}
|
if (name === 'accountNo') {
|
this.queryDisUploadAccount(name)
|
}
|
})
|
},
|
|
async queryDisUploadAccountName(name) {
|
const tempModel = queryDisUploadAccount()
|
const { list } = await tempModel.request({
|
codeNo: 'ContraryAccountType'
|
})
|
// this.newTitleListName = [];
|
// for (let i = 0; i < list.length; i++) {
|
// let obj = {};
|
// for (let key in list[i]) {
|
// obj.label = list[i].accountName;
|
// obj.value = list[i].accountNo;
|
// }
|
// this.newTitleListName.push(obj);
|
// }
|
// 账户名
|
// const newList = list.filter(item => item.)
|
// console.log(this.newTitleListName)
|
let result = list.reduce((pre, curr) => {
|
let { label } = curr
|
pre[label] = pre[label] ? [...pre[label], curr] : [curr]
|
return pre
|
}, {})
|
// console.log(result)
|
let arr = []
|
for (let key in result) {
|
let obj = {}
|
obj.label = key
|
obj.value = key
|
// console.log(key)
|
arr.push(obj)
|
}
|
// console.log(arr)
|
this.updateValueTitle(name, {
|
// options: this.newTitleListName
|
options: arr
|
})
|
},
|
|
async queryDisUploadAccount(name) {
|
const tempModel = queryDisUploadAccount()
|
const { list } = await tempModel.request({
|
codeNo: 'ContraryAccountType'
|
})
|
this.newTitleList = []
|
for (let i = 0; i < list.length; i++) {
|
let obj = {}
|
obj.label = list[i].value
|
obj.value = list[i].value
|
obj.tipLabel = list[i].label // 存储名称
|
this.newTitleList.push(obj)
|
}
|
// 账户账号
|
// console.log(this.newTitleList)
|
this.updateValueTitle(name, {
|
options: this.newTitleList
|
// options: list
|
})
|
},
|
|
async queryProjectList(name) {
|
// const { transCode } = this
|
const tempModel = queryProjectList()
|
const { list } = await tempModel.request({ isAll: '01' })
|
this.newList = []
|
for (let i = 0; i < list.length; i++) {
|
let obj = {}
|
obj.label = list[i].label
|
obj.value = list[i].value
|
this.newList.push(obj)
|
}
|
this.updateValue(name, {
|
options: list
|
})
|
},
|
|
async qryFlowPhaseList(name) {
|
const { transCode } = this
|
const tempModel = qryFlowPhaseList()
|
const { list } = await tempModel.request({ transCode })
|
this.updateValue(name, {
|
options: list
|
})
|
},
|
|
// 更新表单数据
|
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 })
|
}
|
this.formList[1].value = this.formList[0].value
|
},
|
|
// 更新头部表单数据
|
updateValueTitle(index, info) {
|
const { titleFormList } = this
|
if (isNaN(index)) {
|
// index is name
|
index = titleFormList.findIndex(({ name }) => name === index)
|
}
|
if (!isNaN(index) && index > -1) {
|
const preInfo = titleFormList[index]
|
this.$set(titleFormList, index, { ...preInfo, ...info })
|
}
|
// 联动处理
|
if (index === 0) {
|
// this.titleFormList[1].value = this.titleFormList[0].value
|
const { value } = this.titleFormList[0]
|
if (value) {
|
this.titleFormList[1].value = ''
|
// console.log(this.titleFormList[0])
|
const options = this.newTitleList.filter(
|
item => item.tipLabel === value
|
)
|
// console.log(options)
|
this.titleFormList[1].options = options
|
this.acctName = value
|
}
|
}
|
if (index === 1) {
|
const { value } = this.titleFormList[1]
|
if (value) {
|
this.acctNo = value
|
// console.log(value)
|
}
|
}
|
},
|
|
resetTitleForm() {
|
const { titleModel } = this
|
this.titleFormList = titleModel.getFormList()
|
this.setSelectOptions()
|
this.uploadFlowArray = []
|
},
|
|
// 表单按钮事件处理
|
async submit() {
|
const { uploadFlowModel, trxnBr, mode, uploadFlowParams } = this;
|
const {
|
uploadFlowArray,
|
} = uploadFlowParams;
|
let trxnbrArray = []
|
uploadFlowArray.map(item => {
|
trxnbrArray.push(item.trxnbr)
|
})
|
const values = this.$refs.editClaimForm.validate()
|
// console.log(values)
|
const titlwValues = this.$refs.titleForm.validate()
|
|
// console.log(titlwValues)
|
if (values && titlwValues) {
|
const { projectId } = values
|
const { acctNo, acctName } = this
|
const { label } = this.newList.find(item => item.value === projectId)
|
// console.log(acctNo, acctName,projectId,label)
|
await mode.request({
|
projectId,
|
projectName: label,
|
acctNo,
|
acctName,
|
trxnbrArray,
|
});
|
this.$message.success('上传成功')
|
this.$emit("callback");
|
}
|
}
|
},
|
computed: {
|
// 表单值信息
|
formValues() {
|
const { model, formList } = this
|
if (model) {
|
return model.getFormValues(formList)
|
}
|
return {}
|
},
|
formRules() {
|
const { model, formList } = this
|
if (model) {
|
return model.getFormRules(formList)
|
}
|
return {}
|
},
|
// 表单信息
|
titleFormValues() {
|
const { titleModel, titleFormList } = this
|
return titleModel.getFormValues(titleFormList)
|
}
|
},
|
watch: {
|
isShow() {
|
const { isShow } = this
|
if (isShow) {
|
this.init()
|
}
|
}
|
}
|
}
|
</script>
|
<style lang="postcss" scoped>
|
.dialog-form {
|
& .dialog-form-buttons {
|
display: flex;
|
justify-content: center;
|
padding: 50px 0 10px 0;
|
& p {
|
margin: 0 40px 0 0;
|
}
|
& p:last-child {
|
margin-right: 0;
|
}
|
}
|
}
|
</style>
|