<template>
|
<div class="apply-info">
|
<CommForm
|
:inline="true"
|
:list="tempFormList"
|
ref="basicForm"
|
title="基本信息"
|
@updateValue="updateValue"
|
:formValues="formValues"
|
:formRules="formRules"
|
:formType="formType"
|
>
|
<!-- formType="info" -->
|
</CommForm>
|
<!-- <div class="tab-form-buttons" v-if="isShowFooterBtn">
|
<p>
|
<el-button class="comm-button" @click="$router.go(-1)">返回</el-button>
|
</p>
|
<p>
|
<el-button class="comm-button" @click="resetForm">重置</el-button>
|
</p>
|
<p>
|
<el-button class="comm-button" @click="checkData">核对</el-button>
|
</p>
|
<p>
|
<el-button class="comm-button" type="primary" @click="submit" :disabled="isCheck">提交</el-button>
|
</p>
|
</div>-->
|
<Dialog
|
v-model="isShowDialog"
|
icon="succ"
|
iconText="提交成功"
|
:buttons="[{text: '确定', type: 'primary'}]"
|
@handleClick="commitSuccess"
|
></Dialog>
|
</div>
|
</template>
|
<script>
|
import { mapMutations } from 'vuex'
|
import CommForm from '@/components/CommForm'
|
import Dialog from '@/components/Dialog'
|
import voucherDetailCheck from '@/controller/voucherDetailCheck' // 核对
|
import voucherDetailSubmit from '@/controller/voucherDetailSubmit' // 提交
|
import voucherDetailDetails from '@/controller/voucherDetailDetails' // 详情
|
import voucherDetailDelete from '@/controller/voucherDetailDelete' // 删除
|
// 下拉options
|
import queryCodeValueList from '@/controller/queryCodeValueList' // 公共下拉列表接口
|
import queryCodeObject from '@/controller/queryCodeObject' // 公共下拉列表接口
|
|
export default {
|
components: {
|
CommForm,
|
Dialog
|
},
|
props: {
|
conf: {
|
type: Object,
|
default: () => ({})
|
}
|
},
|
data() {
|
return {
|
serialNo: '',
|
info: {},
|
query: {},
|
formList: [],
|
model: null,
|
submitModel: null,
|
detailsModel: null,
|
deleteModel: null,
|
isShowDialog: false,
|
isCheck: true
|
}
|
},
|
created() {
|
this.init()
|
},
|
methods: {
|
init() {
|
let { query } = this.$route
|
this.query = query
|
// console.log(query)
|
query = {
|
...query,
|
serialNo: ''
|
}
|
// console.log(query)
|
let model = voucherDetailCheck(query)
|
this.model = model
|
// this.model = queryCustomerInfoChange()
|
this.checkModel = voucherDetailCheck()
|
this.submitModel = voucherDetailSubmit()
|
this.detailsModel = voucherDetailDetails()
|
this.deleteModel = voucherDetailDelete()
|
this.getDetail()
|
this.setSelectOptions()
|
},
|
async getDetail() {
|
const { query, model, detailsModel } = this
|
const { command, serialNo } = query
|
if (serialNo) {
|
const info = await detailsModel.request({
|
serialNo
|
})
|
info.beginAndEndDate = `${info.beginDate}-${info.endDate}`
|
this.formList = model.getFormList(info)
|
} else {
|
this.formList = model.getFormList(command)
|
}
|
},
|
async setSelectOptions() {
|
const { formList } = this
|
// formList.forEach(({ name }) => {
|
formList.forEach(item => {
|
if (item.name === 'checkType') {
|
this.queryCodeValueList(item.name, { codeNo: 'VoucherType' })
|
}
|
if (item.name === 'accountingChannel') {
|
this.queryCodeValueList(item.name, { codeNo: 'PutOutAccountType' })
|
}
|
// 支付通道回款表单信息-支付公司名称
|
if (item.label === '支付公司名称') {
|
this.queryCodeObject(item.name, { codeno: 'incomeAccountType' })
|
}
|
if (item.label === '放款账户户名') {
|
this.queryCodeObjectIdent(item.name, {
|
codeno: 'PutOutAccountType'
|
})
|
}
|
if (item.label === '收款账户账号') {
|
this.queryCodeObjectIdentNum(item.name, {
|
codeno: 'ContraryAccountType'
|
})
|
}
|
})
|
},
|
|
// 获取select中options数据
|
async queryCodeValueList(name, info = {}) {
|
const tempModel = queryCodeValueList()
|
const { list } = await tempModel.request(info)
|
this.updateValue(name, { options: list })
|
},
|
|
// 获取select中options数据
|
async queryCodeObject(name, info = {}) {
|
const tempModel = queryCodeObject()
|
const { list } = await tempModel.request(info)
|
let listArray = []
|
list.forEach(item => {
|
let obj = {}
|
obj.label = item.itemname
|
obj.value = item.itemname
|
obj.tempValue = item.attribute4
|
listArray.push(obj)
|
})
|
this.updateValue(name, { options: listArray })
|
},
|
|
async queryCodeObjectIdent(name, info = {}) {
|
const tempModel = queryCodeObject()
|
const { list } = await tempModel.request(info)
|
let listArray = []
|
list.forEach(item => {
|
let obj = {}
|
obj.label = item.itemname
|
obj.value = item.itemname
|
obj.tempValue = item.attribute1
|
listArray.push(obj)
|
})
|
this.updateValue(name, { options: listArray })
|
},
|
|
async queryCodeObjectIdentNum(name, info = {}) {
|
const tempModel = queryCodeObject()
|
const { list } = await tempModel.request(info)
|
let listArray = []
|
list.forEach(item => {
|
let obj = {}
|
obj.label = item.attribute1
|
obj.value = item.attribute1
|
obj.tempValue = item.attribute3
|
listArray.push(obj)
|
})
|
this.updateValue(name, { options: listArray })
|
},
|
|
// 重置表单 => 控制核对后的小类消失,基本信息可编辑
|
async resetForm() {
|
const { deleteModel, serialNo } = this
|
if (serialNo) {
|
await deleteModel.request({
|
serialNo
|
})
|
}
|
this.isCheck = true
|
this.$emit('showCheck', true) // 按钮控制
|
const { model } = this
|
this.serialNo = ''
|
this.setSerialNo(this.serialNo)
|
this.setBasicInfo({})
|
this.formList = model.getFormList()
|
this.setSelectOptions()
|
},
|
|
// 核对 => 表单不可编辑,显示后面的小类信息
|
// 测试用
|
// async checkData() {
|
// this.isCheck = false
|
// this.serialNo = '201911051637502300597Y3M250000eb'
|
// this.$emit('showCheck', false)
|
// this.setSerialNo(this.serialNo)
|
// },
|
|
// 核对 => 表单不可编辑,显示后面的小类信息
|
async checkData() {
|
const { checkModel } = this
|
// console.log(this.formList)
|
const values = this.$refs.basicForm.validate()
|
if (values) {
|
try {
|
const checkRes = await checkModel.request({
|
...values
|
})
|
const { serialNo } = checkRes
|
this.serialNo = serialNo
|
this.$emit('showCheck', false)
|
this.setSerialNo(serialNo)
|
this.setBasicInfo(checkRes)
|
this.isCheck = false
|
} catch (error) {
|
this.$emit('showCheck', true)
|
console.log(error)
|
}
|
} else {
|
this.$message.warning('当前页面有数据未输入!')
|
}
|
},
|
// 提交 => 初始不可点击/核对成功后科点击提交
|
async submit() {
|
const { submitModel, serialNo } = this
|
await submitModel.request({
|
serialNo
|
})
|
this.setSerialNo('')
|
this.$emit('showCheck', true) // 按钮控制
|
this.isShowDialog = true
|
},
|
|
// 提交成功后返回原列表页
|
commitSuccess() {
|
this.isShowDialog = false
|
this.$router.go(-1)
|
},
|
|
// 更新表单数据
|
updateValue(index, info) {
|
const { formList, $route, tempFormList } = this
|
const { command } = $route.query
|
// console.log(index, info)
|
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 })
|
}
|
// console.log(formList[index].value)
|
if (command && formList[index].name === 'checkType') {
|
formList[index].value = command
|
formList[index].attrs = ['disabled']
|
}
|
// 联动处理
|
if (index === 2 && info.label === '放款账户户名') {
|
const { options, value } = info
|
const identifierIndex = formList.findIndex(
|
item => item.name === 'identifier'
|
)
|
const targetIndex = options.findIndex(({ label }) => label === value)
|
if (identifierIndex > -1) {
|
if (value) {
|
const { tempValue } = options[targetIndex]
|
this.formList[identifierIndex].value = tempValue
|
} else {
|
this.formList[identifierIndex].value = ''
|
}
|
}
|
}
|
|
if (index === 2 && info.label === '收款账户账号') {
|
const { options, value } = info
|
const identifierIndex = formList.findIndex(
|
item => item.name === 'institution'
|
)
|
const targetIndex = options.findIndex(({ label }) => label === value)
|
if (identifierIndex > -1) {
|
if (value) {
|
const { tempValue } = options[targetIndex]
|
this.formList[identifierIndex].value = tempValue
|
} else {
|
this.formList[identifierIndex].value = ''
|
}
|
}
|
}
|
if (info.label === '支付公司名称') {
|
const { value, options } = info
|
const identifierIndex = formList.findIndex(
|
item => item.name === 'identifier'
|
)
|
const targetIndex = options.findIndex(({ label }) => label === value)
|
if (identifierIndex > -1) {
|
if (value) {
|
const { tempValue } = options[targetIndex]
|
this.formList[identifierIndex].value = tempValue
|
} else {
|
this.formList[identifierIndex].value = ''
|
}
|
}
|
}
|
},
|
...mapMutations(['setSerialNo', 'setBasicInfo'])
|
},
|
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 {}
|
},
|
tempFormList() {
|
const { isCheck, formList } = this
|
if (isCheck) {
|
return formList
|
} else {
|
formList.map(item => {
|
if (item.type === 'select' || item.type === 'daterange') {
|
item.attrs = [...item.attrs, 'disabled']
|
} else {
|
if (item.attrs) {
|
item.attrs =
|
item.attrs.indexOf('readonly') > -1
|
? item.attrs
|
: [...item.attrs, 'readonly']
|
} else {
|
item.attrs = ['readonly']
|
}
|
}
|
item.rules = []
|
})
|
return formList
|
}
|
},
|
formType() {
|
const { query } = this.$route
|
const { isApplyPhase } = query
|
if (isApplyPhase === '2') {
|
return 'text'
|
} else {
|
return ''
|
}
|
},
|
isShowFooterBtn() {
|
const { isApplyPhase } = this.$route.query
|
if (isApplyPhase === '2') {
|
return false
|
} else {
|
return true
|
}
|
}
|
},
|
watch: {
|
$route() {
|
const { transLogSerialno } = this.$route.query
|
if (transLogSerialno) {
|
this.init()
|
}
|
}
|
// isCheck(val) {
|
// const { formList } = this
|
// if (!val) {
|
// formList.map(item => {
|
// if (item.attrs) {
|
// item.attrs =
|
// item.attrs.indexOf('readonly') > -1
|
// ? item.attrs
|
// : [...item.attrs, 'readonly']
|
// } else {
|
// item.attrs = ['readonly']
|
// }
|
// })
|
// }
|
// }
|
}
|
}
|
</script>
|
<style lang="postcss" scoped>
|
.apply-info {
|
}
|
.tab-form-buttons {
|
display: flex;
|
justify-content: center;
|
padding: 20px 0 30px 0;
|
& p {
|
margin: 0 40px 0 0;
|
}
|
& p:last-child {
|
margin-right: 0;
|
}
|
}
|
</style>
|