<template>
|
<div class="apply-info" v-show="isHasBusiness === '1'">
|
<SectionTitle :title="'业务通道信息'"></SectionTitle>
|
<CommForm
|
:inline="true"
|
:list="formList"
|
@updateValue="updateValue"
|
:ref="'editMarkForm'"
|
:formValues="formValues"
|
:formRules="formRules"
|
formType="info"
|
></CommForm>
|
</div>
|
</template>
|
|
<script>
|
import { mapMutations, mapState } from 'vuex'
|
import SectionTitle from '@/components/SectionTitle'
|
import CommForm from '@/components/CommForm'
|
import CommTable from '@/components/CommTable'
|
|
import queryFundUnitLoanChannel from '@/controller/queryFundUnitLoanChannel'
|
import queryCodeValueList from '@/controller/queryCodeValueList'
|
import queryLoanChannelList from '@/controller/queryLoanChannelList'
|
|
export default {
|
components: {
|
SectionTitle,
|
CommForm,
|
CommTable,
|
},
|
props: {
|
conf: {
|
type: Object,
|
default: () => ({}),
|
},
|
},
|
data() {
|
return {
|
info: {},
|
query: {},
|
formList: [],
|
pageInfo: {
|
currentPage: 1,
|
pageSize: 10,
|
},
|
total: 0,
|
list: [],
|
model: null,
|
tableModel: null,
|
isDoingAdd: false,
|
serialNo: '',
|
}
|
},
|
created() {
|
const { isHasBusiness } = this
|
isHasBusiness !== '0' && this.init()
|
},
|
methods: {
|
init() {
|
const { $route, isEdit } = this
|
const { query } = $route
|
this.query = query
|
let tableModel = null
|
this.model = queryFundUnitLoanChannel()
|
this.getDetail()
|
},
|
|
async getDetail() {
|
const { query, model } = this
|
const { serialNo = '' } = query
|
const info = await model.request({ serialNo })
|
if (info.serialNo) {
|
// this.setCreditSerialNo(info.serialNo)
|
this.serialNo = info.serialNo
|
}
|
this.formList = model.getFormList(info)
|
this.setForm({ ...info })
|
},
|
|
setForm(info = {}) {
|
const { isEdit, formList } = this
|
if (isEdit) {
|
this.setSelectOptions()
|
} else {
|
this.formList = formList.map((item) => {
|
let { name, descName, value, type, attrs = [] } = item
|
if (type === 'select' && descName) {
|
if (attrs.includes('multiple')) {
|
// 多选处理
|
value = info[descName].join()
|
} else {
|
this[descName] = info[name] // 缓存对应的name的值到对应的descName上 便于联动时进行值替换
|
value = info[descName]
|
}
|
}
|
return {
|
...item,
|
type: 'input',
|
value,
|
attrs: [...attrs, 'readonly'],
|
rules: [],
|
}
|
})
|
}
|
},
|
setSelectOptions() {
|
const { formList } = this
|
formList.forEach(({ name }) => {
|
if (name === 'channelCode') {
|
this.queryLoanChannelList(name, { codeNo: 'BankMonthLimit' })
|
}
|
if (name === 'channelType') {
|
this.queryCodeValueList(name, { codeNo: 'LoanChannelType' })
|
}
|
if (name === 'channelRateType') {
|
this.queryCodeValueList(name, { codeNo: 'ChannelRateType' })
|
}
|
})
|
},
|
|
async queryLoanChannelList(name, info = {}) {
|
const tempModel = queryLoanChannelList()
|
const { list } = await tempModel.request(info)
|
this.updateValue(name, { options: list })
|
},
|
|
async queryCodeValueList(name, info = {}) {
|
const tempModel = queryCodeValueList()
|
const { list } = await tempModel.request(info)
|
this.updateValue(name, { options: list })
|
},
|
|
// 更新表单数据
|
updateValue(index, info) {
|
const { formList } = this
|
// 由于展示字段与formList个数不一致,index判断会有问题,所以已name为准
|
if (info.name) {
|
index = info.name
|
}
|
if (isNaN(index)) {
|
// index is name
|
index = formList.findIndex(({ name }) => name === index)
|
}
|
if (!isNaN(index) && index > -1) {
|
const preInfo = formList[index]
|
if (info.name === 'channelCode' && info.value) {
|
this.$set(formList, index, { ...preInfo, ...info })
|
const { options } = info
|
const { channelName, channelType } = options.find(
|
(item) => item.value === info.value
|
)
|
const channelNameIndex = formList.findIndex(
|
({ name }) => name === 'channelName'
|
)
|
channelNameIndex > -1 &&
|
this.$set(formList, channelNameIndex, {
|
...formList[channelNameIndex],
|
value: channelName,
|
})
|
const channelTypeIndex = formList.findIndex(
|
({ name }) => name === 'channelType'
|
)
|
channelTypeIndex > -1 &&
|
this.$set(formList, channelTypeIndex, {
|
...formList[channelTypeIndex],
|
value: channelType,
|
})
|
}
|
this.$set(formList, index, { ...preInfo, ...info })
|
}
|
if (info.name && info.name === 'channelRate') {
|
const { value, label } = info
|
if (Number(value) > 99) {
|
this.$message.warning(`${label}输入值范围[0,99]`)
|
this.$set(formList, index, { ...formList[index], value: '' })
|
}
|
}
|
},
|
|
submit() {
|
const { serialNo = '' } = this
|
const values = this.$refs['editMarkForm'].validate()
|
if (values) {
|
this.setFundUnitLoanChannelSubmitReq({
|
...values,
|
serialNo,
|
})
|
}
|
},
|
|
...mapMutations(['setFundUnitLoanChannelSubmitReq']),
|
},
|
computed: {
|
isEdit() {
|
const { conf } = this
|
return conf.edit === 'Y'
|
},
|
// 表单值信息
|
formValues() {
|
const { model, formList } = this
|
return model ? model.getFormValues(formList) : {}
|
},
|
formRules() {
|
const { model, formList } = this
|
if (model) {
|
return model.getFormRules(formList)
|
}
|
return {}
|
},
|
...mapState({
|
isHasBusiness: (state) => state.captialUnit.isHasBusiness,
|
}),
|
},
|
watch: {
|
isHasBusiness(val) {
|
val === '1' && this.init()
|
},
|
},
|
}
|
</script>
|
|
<style scoped>
|
</style>
|