<template>
|
<div>
|
<EditForm
|
:inline="true"
|
:list="showList"
|
title="申请信息"
|
@updateValue="updateValue"
|
ref="malApply"
|
:formValues="formValues"
|
:formRules="formRules"
|
formType="info"
|
></EditForm>
|
<Dialog
|
v-model="isShowSucc"
|
icon="succ"
|
iconText="提交成功"
|
:close="false"
|
:buttons="[{text: '确定', type: 'primary'}]"
|
@handleClick="sureSucc"
|
></Dialog>
|
</div>
|
</template>
|
<script>
|
// 申请信息
|
import { mapState } from 'vuex'
|
import Dialog from '../Dialog'
|
import EditForm from '../EditForm'
|
import customerContractMailCommit from '@comprehensive/model/customerContractMailCommit'
|
import {
|
getDictionaryList,
|
customerContractMailInfo,
|
getProvinceCodeList,
|
getCityCodeList,
|
getAreaCodeList
|
} from '@comprehensive/serve/public'
|
|
export default {
|
components: {
|
EditForm,
|
Dialog
|
},
|
props: {
|
info: {
|
type: Object,
|
default: () => ({})
|
}
|
},
|
data() {
|
return {
|
loading: false,
|
isShowSucc: false,
|
model: null,
|
query: {},
|
detailInfo: {},
|
formRules: {},
|
formList: []
|
}
|
},
|
created() {
|
this.init()
|
},
|
methods: {
|
init() {
|
const { query } = this.$route
|
this.query = query
|
const model = customerContractMailCommit()
|
this.model = model
|
this.getDetail()
|
},
|
|
async getDetail() {
|
const { model, info, loanInfo } = this
|
const { edit } = info
|
if (Object.keys(loanInfo).length === 0) {
|
return false
|
}
|
let { result } = await customerContractMailInfo()
|
if (!result.recipient && loanInfo.customerName) {
|
result = { ...result, recipient: loanInfo.customerName }
|
}
|
if (!result.phone && loanInfo.phone) {
|
result = { ...result, phone: loanInfo.phone }
|
}
|
// 文字回车换行处理
|
result.econtent = result.econtent.replace(/\\n/g, '\r\n')
|
this.detailInfo = result
|
const formList = model.getFormList(result)
|
this.formList = formList
|
if (edit === 'Y') {
|
this.formRules = model.getFormRules(formList)
|
this.getOptions()
|
}
|
},
|
|
getOptions() {
|
const conf = {
|
contractSendType: 'ContractSendType',
|
status: 'MStatus'
|
}
|
Object.keys(conf).forEach(key => this.getStatus(key, conf[key]))
|
this.getArea('province')
|
},
|
|
// 邮寄状态
|
async getStatus(name, codeNo) {
|
const { result } = await getDictionaryList({ codeNo })
|
this.updateOptions(name, result, 'itemname', 'itemno')
|
},
|
|
updateOptions(name, list, labelKey, valueKey, info = {}) {
|
this.updateValue(name, {
|
options: list.map(item => ({
|
label: item[labelKey],
|
value: item[valueKey]
|
})),
|
...info
|
})
|
},
|
|
async getArea(name, itmeNo) {
|
if (name === 'province') {
|
const { result } = await getProvinceCodeList()
|
this.updateOptions(name, result, 'itemname', 'itemno', { value: '' })
|
}
|
|
if (name === 'city') {
|
const { result } = await getCityCodeList({ codeNo: 'AreaCode', itmeNo })
|
this.updateOptions(name, result, 'itemname', 'itemno', { value: '' })
|
}
|
|
if (name === 'regions') {
|
const { result } = await getAreaCodeList({ codeNo: 'AreaCode', itmeNo })
|
this.updateOptions(name, result, 'itemname', 'itemno', { value: '' })
|
}
|
},
|
|
// 更新表单数据
|
updateValue(index, info) {
|
const { formList } = this
|
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 })
|
|
// const cityIndex = formList.findIndex(({ name }) => name === 'city')
|
const regionsIndex = formList.findIndex(
|
({ name }) => name === 'regions'
|
)
|
|
if (info.name === 'province') {
|
this.getArea('city', info.value)
|
this.$set(formList, regionsIndex, {
|
...formList[regionsIndex],
|
options: [],
|
value: ''
|
})
|
}
|
|
if (info.name === 'city') {
|
this.getArea('regions', info.value)
|
}
|
}
|
},
|
|
sureSucc() {
|
this.isShowSucc = false
|
this.$router.go(-1)
|
},
|
|
async PARENT_SUBMIT() {
|
const { model, query, detailInfo, contractNoArray } = this
|
const { applySerialNo } = query
|
const { mailingNo } = detailInfo
|
let info = this.$refs.malApply.validate()
|
if (info) {
|
// this.loading = true
|
|
if (info.contractSendType === '02' && contractNoArray.length < 1) {
|
this.$message.warning('请先选择电子合同!')
|
return false
|
}
|
await model.request({
|
applySerialNo,
|
mailingNo,
|
contractNoArray,
|
...info
|
})
|
this.isShowSucc = true
|
// this.loading = false
|
} else {
|
this.$message.warning('当前页面存在必填项未录入或数据录取错误,请检查!')
|
}
|
}
|
},
|
computed: {
|
showList() {
|
const { formList, formValues } = this
|
const { contractSendType } = formValues
|
// 1 电子邮件, 2 邮寄
|
const emailKeys = ['toAdress', 'etitle', 'econtent']
|
const normalKeys = [
|
'province',
|
'city',
|
'regions',
|
'address',
|
'zipCode',
|
'courierCompany',
|
'logisticsNumber',
|
'mailingDate',
|
'status'
|
]
|
let filterKeys = [...emailKeys, ...normalKeys]
|
if (contractSendType === '01') {
|
filterKeys = [...emailKeys]
|
}
|
if (contractSendType === '02') {
|
filterKeys = [...normalKeys]
|
}
|
return formList.filter(({ name }) => !filterKeys.includes(name))
|
},
|
// 表单值信息
|
formValues() {
|
const { model, formList } = this
|
return model.getFormValues(formList)
|
},
|
...mapState({
|
loanInfo: state => state.comprehensiveTransaction.loanInfo,
|
contractNoArray: state => state.comprehensiveTransaction.contractNoArray
|
})
|
},
|
watch: {
|
loanInfo() {
|
this.getDetail()
|
}
|
}
|
}
|
</script>
|
|
<style lang="postcss" scoped>
|
</style>
|