<template>
|
<div class="apply-info">
|
<div class="dialog-form">
|
<p class="dialog-form-title">
|
{{ addOrEdit === 'add' ? '新增' : '修改' }}
|
</p>
|
<div v-loading="loading">
|
<CommForm
|
ref="editMarkForm"
|
:column="2"
|
:inline="true"
|
:list="formList"
|
:formValues="formValues"
|
:formRules="formRules"
|
@updateValue="updateValue"
|
></CommForm>
|
</div>
|
<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"
|
:disabled="loading"
|
>确定</el-button
|
>
|
</p>
|
</div>
|
</div>
|
</div>
|
</template>
|
<script>
|
// 特殊减免配置
|
import CommForm from '@/components/CommForm'
|
import saveLoanOrgProduct from '@/controller/saveLoanOrgProduct' // 新增、编辑
|
import queryCodeValueList from '@/controller/queryCodeValueList'
|
import qryDimensionList from '@/controller/qryDimensionList'
|
import qryDropDownOptionBatch from '@/controller/qryDropDownOptionBatch'
|
import queryLoanOrgItem from '@/controller/queryLoanOrgItem'
|
import qryOrgProduct from '@/controller/qryOrgProduct'
|
import getDictionaryList from '@/controller/getDictionaryList'
|
|
// 获取产品api
|
import qryProdList from '@/controller/qryProdList'
|
// 获取还款方式api
|
import queryPaymentMethod from '@/controller/queryPaymentMethod'
|
export default {
|
components: {
|
CommForm,
|
},
|
props: {
|
info: {
|
type: Object,
|
default: () => ({}),
|
},
|
isShow: {
|
type: Boolean,
|
default: false,
|
},
|
trxnBr: {
|
type: String,
|
default: '',
|
},
|
buttonProp: {
|
type: String,
|
default: '',
|
},
|
// 初始值
|
initValue: {
|
type: Object,
|
default: () => ({}),
|
},
|
addOrEdit: {
|
type: String,
|
default: '',
|
},
|
detail: {
|
type: Object,
|
default: () => ({}),
|
},
|
},
|
data() {
|
return {
|
model: null,
|
formList: [],
|
loading: false,
|
paymentMethodName: '',
|
orgProductName: '',
|
itemName: {},
|
}
|
},
|
created() {
|
this.init()
|
},
|
methods: {
|
init() {
|
this.$refs['editMarkForm'] && this.$refs['editMarkForm'].resetFields()
|
const { detail, addOrEdit } = this
|
const guaranteeFeeClearingType = !detail.guaranteeFeeClearingType.length ? [] : detail.guaranteeFeeClearingType.split(",")
|
const model = saveLoanOrgProduct()
|
this.model = model
|
this.formList = model.getFormList({
|
...detail,
|
guaranteeFeeClearingType
|
})
|
// .filter(item => {
|
// if(addOrEdit === 'add') {
|
// // 新增-客户名称无须编辑
|
// return item.name !== 'customername'
|
// }
|
// return 1
|
// })
|
this.setSelectOptions()
|
},
|
|
setSelectOptions() {
|
const { formList } = this
|
formList.forEach(({ name }) => {
|
// 项目
|
if (name === 'projectCode') {
|
this.qryDropDownOptionBatch(name, 'projectList')
|
}
|
// 产品
|
if (name === 'productCode') {
|
this.qryProdList(name)
|
}
|
// 资金方
|
if (name === 'orgId') {
|
this.queryLoanOrgItem(name)
|
}
|
// 维度名称
|
if (name === 'productDimensionCode') {
|
this.qryDimensionList()
|
}
|
// 还款方式
|
if (name === 'paymentMethodCode') {
|
this.qryDropDownOptionBatch(name, 'PaymentName')
|
}
|
// 资方还款方式
|
if (name === 'orgPaymentMethodCode') {
|
this.getDictionaryList(name, 'OrgLoanProductRepay')
|
}
|
// 清分
|
if (name === 'useClearing') {
|
this.getDictionaryList(name, 'YesNo')
|
}
|
// 融担清分费用类型
|
if (name === 'guaranteeFeeClearingType') {
|
this.getDictionaryList(name, 'GUARANTEE_FEE_CLEARING_TYPE')
|
}
|
// 资方产品配置期数
|
if (name === 'period') {
|
this.getDictionaryList(name, 'OrgLoanProductTerm')
|
}
|
// 资金产品
|
if (name === 'orgProductCode') {
|
this.qryOrgProduct()
|
}
|
// 状态
|
if (name === 'status') {
|
this.queryCodeValueList(name, { codeNo: 'YesNo' })
|
}
|
})
|
},
|
|
async queryCodeValueList(name, info = {}) {
|
const tempModel = queryCodeValueList()
|
const { list } = await tempModel.request(info)
|
if(name == 'status' && list) {
|
list.map(item => {
|
item.label = item.value == '1' ? '有效' : '无效'
|
})
|
}
|
this.updateValue(name, { options: list })
|
},
|
// 产品名称下拉列表
|
async qryProdList(name) {
|
const tempModel = qryProdList()
|
const { list } = await tempModel.request({ productTypeNo: '' })
|
this.updateValue(name, { options: list })
|
},
|
// 下拉选项枚举
|
async qryDropDownOptionBatch(name, code) {
|
const tempModel = qryDropDownOptionBatch()
|
const res = await tempModel.request([code])
|
let list = res[code]
|
this.updateValue(name, { options: list })
|
},
|
// 下拉选项枚举
|
async getDictionaryList(name, code) {
|
const tempModel = getDictionaryList()
|
const res = await tempModel.request({codeNo: code})
|
let list = res.list
|
this.updateValue(name, { options: list })
|
},
|
// 资金方下拉列表
|
async queryLoanOrgItem(name, info = {}) {
|
const tempModel = queryLoanOrgItem()
|
const { list } = await tempModel.request(info)
|
this.updateValue(name, { options: list })
|
},
|
// 资方产品下拉列表
|
async qryOrgProduct() {
|
let { formValues } = this
|
const res = await qryOrgProduct().request({
|
orgid: formValues.orgId || '',
|
})
|
const { list } = res
|
this.updateValue('orgProductCode', { options: list })
|
},
|
// 产品维度下拉列表
|
async qryDimensionList() {
|
let { formValues } = this
|
const res = await qryDimensionList().request({
|
productid: formValues.productCode || '',
|
})
|
const { list } = res
|
this.updateValue('productDimensionCode', { options: list })
|
},
|
// 还款方式下拉列表
|
async queryMethodList(name) {
|
const tempModel = queryPaymentMethod()
|
const { list } = await tempModel.request({ paymentMethod: '' })
|
this.updateValue(name, { options: list })
|
},
|
|
// 更新表单数据
|
updateValue(index, info) {
|
const { formList, addOrEdit } = 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 })
|
if (preInfo.type == 'select') {
|
const { options } = info
|
const referValue = info.value ? info.value : preInfo.value
|
const checkedOption = options.find(
|
(item) => item.value === referValue
|
)
|
|
// 设置级联下拉选项
|
const linkageOptionsSet = {
|
productCode: 'productDimensionCode', // 产品维度跟产品是级联关系 先选择产品 然后带出维度
|
orgId: 'orgProductCode', // 资方产品跟资金方是级联关系 先选择资金方 然后带出资方产品选项
|
}
|
if (preInfo.name in linkageOptionsSet) {
|
const findIdx = formList.findIndex(
|
({ name }) => name === linkageOptionsSet[preInfo.name]
|
)
|
const value = preInfo.value !== info.value && !info.value ? formList[findIdx].value : preInfo.value === info.value ? formList[findIdx].value : ''
|
this.$set(formList, findIdx, {
|
...formList[findIdx],
|
value: value
|
})
|
preInfo.name === 'productCode' && this.qryDimensionList()
|
preInfo.name === 'orgId' && this.qryOrgProduct()
|
}
|
|
// 关联字段,不可手动编辑
|
const codeToNames = {
|
paymentMethodCode: 'paymentMethodName', // 还款方式名称
|
orgProductCode: 'orgProductName', // 资方产品名称
|
}
|
if (preInfo.name in codeToNames) {
|
const findIdx = formList.findIndex(
|
({ name }) => name === codeToNames[preInfo.name]
|
)
|
this.$set(formList, findIdx, {
|
...formList[findIdx],
|
value: !checkedOption ? '' : checkedOption.value,
|
})
|
}
|
if(preInfo.name === 'useClearing') {
|
const findIdx = formList.findIndex(
|
({ name }) => name === 'guaranteeFeeClearingType'
|
)
|
this.$set(formList[findIdx].rules[0], 'required', formList[index].value === '1')
|
}
|
|
// 后端要求将相关字段中文映射提交
|
const nameSet = {
|
orgId: 'orgName',
|
projectCode: 'projectName',
|
productCode: 'productName',
|
orgProductCode: 'orgProductName',
|
productDimensionCode: 'productDimensionName',
|
paymentMethodCode: 'paymentMethodName',
|
orgPaymentMethodCode: 'orgPaymentMethodName',
|
}
|
if (preInfo.name in nameSet) {
|
this.itemName[nameSet[preInfo.name]] = !checkedOption ? '' : checkedOption.label
|
}
|
}
|
}
|
},
|
// 表单按钮事件处理
|
async submit() {
|
const { model, detail, itemName } = this
|
const { id = '' } = detail
|
const values = this.$refs.editMarkForm.validate()
|
if (values) {
|
this.loading = true
|
try {
|
const guaranteeFeeClearingType = values.guaranteeFeeClearingType.toString()
|
await model.request({
|
...values,
|
...itemName,
|
id,
|
guaranteeFeeClearingType
|
})
|
this.loading = false
|
this.$emit('callback')
|
} catch (error) {
|
this.loading = false
|
}
|
} else {
|
this.$message.warning('当前页面必填数据未填写完毕或填写数据格式错误!')
|
}
|
},
|
resetForm() {
|
const { model } = this
|
this.formList = model.getFormList()
|
},
|
},
|
computed: {
|
// 表单值信息
|
formValues() {
|
const { model, formList } = this
|
if (model) {
|
return model.getFormValues(formList)
|
}
|
return {}
|
},
|
formRules() {
|
const { model, formList } = this
|
if (model) {
|
const rules = model.getFormRules(formList);
|
rules.guaranteeFeeClearingType[0] = {...rules.guaranteeFeeClearingType[0], type:'array',}
|
return rules
|
}
|
return {}
|
},
|
},
|
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;
|
}
|
}
|
& .dialog-upload {
|
display: flex;
|
align-content: center;
|
margin-left: 100px;
|
& .el-button {
|
color: #0081f0;
|
border-color: #0081f0;
|
}
|
& .upload {
|
color: #0081f0;
|
font-size: 12px;
|
margin-left: 20px;
|
cursor: pointer;
|
line-height: 28px;
|
}
|
}
|
}
|
</style>
|