<template>
|
<div class="apply-info">
|
<SectionTitle :title="'基本信息'"></SectionTitle>
|
<CommForm
|
:inline="true"
|
:list="computedFormList"
|
@updateValue="updateValue"
|
:ref="refId"
|
:formValues="formValues"
|
:formRules="formRules"
|
formType="info"
|
></CommForm>
|
|
<FuncDarkTable :conf="conf" :serialNo="serialNo" @sendTableList="sendTableList"></FuncDarkTable>
|
<FuncSonTable
|
:conf="conf"
|
:serialNo="serialNo"
|
:functionName="functionName"
|
@sendTable="sendTable"
|
></FuncSonTable>
|
</div>
|
</template>
|
|
<script>
|
import SectionTitle from '@/components/SectionTitle'
|
import CommForm from '@/components/CommForm'
|
import CommTable from '@/components/CommTable'
|
|
import FuncDarkTable from '@/components/tabsPocket/FuncDarkTable'
|
import FuncSonTable from '@/components/tabsPocket/FuncSonTable'
|
|
import loanOrgFuncConstraintInfo from '@/controller/loanOrgFuncConstraintInfo'
|
import queryCodeValueList from '@/controller/queryCodeValueList'
|
import { mapMutations } from 'vuex'
|
|
export default {
|
components: {
|
SectionTitle,
|
CommForm,
|
CommTable,
|
FuncDarkTable,
|
FuncSonTable
|
},
|
props: {
|
conf: {
|
type: Object,
|
default: () => ({})
|
},
|
typeId: {
|
type: Number,
|
required: true
|
},
|
functionName: {
|
type: String,
|
required: true
|
},
|
serialNo: {
|
type: String,
|
default: ''
|
}
|
},
|
data() {
|
return {
|
info: {},
|
query: {},
|
formList: [],
|
loanOrgFuncDarkTermListSubmitReqs: [], // 功能约束功能黑暗期列表
|
loanOrgSubFlowListSubmitReqs: [], // 功能约束子流程定义列表
|
otherTitle: '',
|
pageInfo: {
|
currentPage: 1,
|
pageSize: 10
|
},
|
total: 0,
|
list: [],
|
selectModel: null,
|
model: null,
|
tableModel: null,
|
isDoingAdd: false,
|
serialNoFunc: ''
|
}
|
},
|
created() {
|
this.init()
|
},
|
methods: {
|
init() {
|
const { $route, typeId, isEdit } = this
|
const { query } = $route
|
this.query = query
|
let tableModel = null
|
this.model = loanOrgFuncConstraintInfo()
|
this.selectModel = queryCodeValueList()
|
this.getDetail()
|
},
|
|
async getDetail() {
|
const { query, model, functionName, serialNo } = this
|
const { operation } = query
|
const info = await model.request({ serialNo })
|
info.serialNo && (this.serialNoFunc = info.serialNo)
|
info.functionType &&
|
this.setSonProcessCode({
|
type: functionName,
|
value: info.functionType
|
})
|
// console.log(info)
|
if (operation === 'add') {
|
this.formList = model.getFormList({ ...info, functionName })
|
} else {
|
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 === 'functionName') {
|
this.queryCodeValueList(name, { codeNo: 'FunctionNameType' })
|
}
|
if (name === 'functionOnOff') {
|
this.queryCodeValueList(name, { codeNo: 'FunctionOff' })
|
}
|
if (name === 'functionType') {
|
this.queryCodeValueList(name, { codeNo: 'FunctType' })
|
}
|
})
|
},
|
async queryCodeValueList(name, info = {}) {
|
const tempModel = queryCodeValueList()
|
const { list } = await tempModel.request(info)
|
this.updateValue(name, { options: list })
|
},
|
|
// 更新表单数据
|
updateValue(index, info) {
|
// console.log(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]
|
this.$set(formList, index, { ...preInfo, ...info })
|
if (info.name === 'functionType') {
|
const { functionName } = this
|
this.setSonProcessCode({
|
type: functionName,
|
value: info.value
|
})
|
}
|
}
|
},
|
|
async submit() {
|
const { refId } = this
|
return await this.$refs[refId].validate()
|
},
|
|
// 表格按钮事件处理
|
doAction(item, record, index) {
|
const { prop } = item
|
this.currentIndex = index
|
this.buttonProp = prop
|
this.tempRecord = record
|
if (prop === 'updateButton') {
|
this.updateRecord()
|
}
|
if (prop === 'deleteButton') {
|
this.isShowDel = true
|
}
|
if (prop === 'cancleButton') {
|
this.changeList()
|
}
|
if (prop === 'addButton') {
|
this.toSubmit(true)
|
}
|
if (prop === 'submitButton') {
|
this.toSubmit()
|
}
|
},
|
|
sendTable(list) {
|
this.loanOrgSubFlowListSubmitReqs = [...list]
|
},
|
|
sendTableList(list) {
|
list = list.map(item => {
|
return {
|
...item,
|
bankName: item.bankName.split(','),
|
bankNo:
|
typeof item.bankNo === 'string'
|
? item.bankNo.split(',')
|
: item.bankNo
|
}
|
})
|
this.loanOrgFuncDarkTermListSubmitReqs = [...list]
|
},
|
...mapMutations(['setSonProcessCode'])
|
},
|
computed: {
|
isEdit() {
|
const { conf } = this
|
return conf.edit === 'Y'
|
},
|
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 {}
|
},
|
computedFormList() {
|
const { formList, formValues, typeId, isEdit, functionOnOffDesc } = this
|
let { functionOnOff } = formValues
|
let tempList = [...formList]
|
if (tempList) {
|
// 功能约束
|
if (typeId === 1) {
|
let filterKeys = ['functionType', 'applyFrequency', 'overTime']
|
!isEdit && (functionOnOff = functionOnOffDesc)
|
if (functionOnOff === '01') {
|
filterKeys = []
|
}
|
return tempList.filter(({ name }) => !filterKeys.includes(name))
|
}
|
}
|
return tempList
|
}
|
},
|
watch: {}
|
}
|
</script>
|
|
<style scoped>
|
</style>
|