<template>
|
<div class="apply-info">
|
<CommForm
|
:inline="true"
|
:column="1"
|
:list="formList"
|
@updateValue="updateValue"
|
ref="opiniopForm"
|
:formValues="formValues"
|
:formRules="formRules"
|
title="审批意见"
|
formType="info"
|
></CommForm>
|
<Dialog
|
v-model="isShowDialog"
|
icon="succ"
|
iconText="提交成功"
|
:buttons="[{text: '确定', type: 'primary'}]"
|
@handleClick="commitSuccess"
|
></Dialog>
|
</div>
|
</template>
|
<script>
|
// 审批意见
|
import { mapState } from 'vuex'
|
import CommForm from '@/components/CommForm'
|
import Dialog from '@/components/Dialog'
|
import queryCodeValueList from '@/controller/queryCodeValueList'
|
import queryApproveOpinionInfo from '@/controller/queryApproveOpinionInfo'
|
import approveSubmit from '@/controller/approveSubmit'
|
import submitCommon from '@/controller/submitCommon'
|
import publicSubmit from '@/controller/publicSubmit'
|
import loanCancelClaimSubmit from '@/controller/loanCancelClaimSubmit'
|
import approveSubmitDiscountInvoice from '@/controller/approveSubmitDiscountInvoice'
|
import submitDiscountInvoice from '@/controller/submitDiscountInvoice'
|
|
export default {
|
components: {
|
CommForm,
|
Dialog
|
},
|
props: {
|
conf: {
|
type: Object,
|
default: () => ({})
|
}
|
},
|
data() {
|
return {
|
info: {},
|
query: {},
|
formList: [],
|
invoiceRequiredItems: [],
|
detailModel: null,
|
model: null,
|
selectModel: null,
|
isShowDialog: false
|
}
|
},
|
created() {
|
this.init()
|
},
|
methods: {
|
init() {
|
const { query } = this.$route
|
this.query = query
|
const { pageId, transCode } = this.query
|
this.selectModel = queryCodeValueList()
|
this.detailModel = queryApproveOpinionInfo()
|
// 开票基本信息必填项
|
this.invoiceRequiredItems = submitDiscountInvoice({ pageId, transCode })
|
.getFormList()
|
.filter(({ rules = [] }) =>
|
rules.some(rule =>
|
typeof rule === 'object' ? rule.required : rule === 'required'
|
)
|
)
|
.map(({ name, label }) => ({ name, label }))
|
let model = null
|
if (pageId === '30' || pageId === '35') {
|
model = submitCommon()
|
}
|
|
if (pageId === '36' || pageId === '62') {
|
model = publicSubmit()
|
}
|
|
if (pageId === '60') {
|
model = loanCancelClaimSubmit()
|
}
|
|
if (pageId === '101' || pageId === '102') {
|
model = approveSubmitDiscountInvoice()
|
}
|
|
if (!model) {
|
model = approveSubmit()
|
}
|
|
this.model = model
|
|
this.getDetail()
|
},
|
async getDetail() {
|
const { query, detailModel } = this
|
const { transLogSerialno } = query
|
const info = await detailModel.request({
|
transLogSerialno
|
})
|
this.info = { ...info }
|
this.setForm(info)
|
},
|
|
setForm(initValue) {
|
const { model, conf } = this
|
const formList = model.getFormList(initValue)
|
const { edit } = conf
|
if (edit === 'Y') {
|
this.formList = formList
|
// this.formRules = model.getFormRules()
|
// this.model = model
|
this.setSelectOptions()
|
} else {
|
this.formList = formList.map(item => ({ ...item, type: 'text' }))
|
}
|
},
|
|
// 更新表单数据
|
updateValue(index, info) {
|
const { formList } = this
|
if (isNaN(index)) {
|
// index is name
|
index = formList.findIndex(({ name }) => name === index)
|
}
|
const approveOpinionIndex = formList.findIndex(
|
({ name }) => name === 'approveOpinion'
|
)
|
if (!isNaN(index) && index > -1) {
|
const preInfo = formList[index]
|
this.$set(formList, index, { ...preInfo, ...info })
|
|
if (preInfo.name === 'approveCode' && approveOpinionIndex > -1) {
|
const tempItem = formList[approveOpinionIndex] || {}
|
let { rules = [] } = tempItem
|
|
rules = rules.filter(
|
item =>
|
(typeof item === 'string' && item !== 'required') ||
|
(typeof item === 'object' &&
|
!Object.keys(item).includes('required'))
|
)
|
|
if (info.value === '01') {
|
rules = [...rules]
|
} else {
|
rules = [...rules, 'required']
|
}
|
this.$set(formList, approveOpinionIndex, { ...tempItem, rules })
|
}
|
}
|
},
|
|
// 表单按钮事件处理
|
async submit() {
|
const {
|
model,
|
query,
|
info,
|
conf,
|
trxnbrArray,
|
invoiceInfo,
|
refundApplicationInfo,
|
invoiceRequiredItems
|
} = this
|
const { edit } = conf
|
if (edit !== 'Y') {
|
return false
|
}
|
const {
|
transLogSerialno,
|
transCode,
|
pageId,
|
objectNo,
|
objectType,
|
phaseNo,
|
transCodeOne,
|
stageNum
|
} = query
|
const values = this.$refs.opiniopForm.validate()
|
if (values) {
|
// const loading = this.$loading({
|
// fullscreen: true
|
// })
|
|
let baseInfo = {
|
...values,
|
objectNo,
|
objectType,
|
transCode,
|
phaseNo
|
}
|
|
if (pageId === '60' && trxnbrArray.length === 0) {
|
this.$message.warning('认领流水为空,请选择待认领银行流水!')
|
return false
|
}
|
|
if (pageId === '35') {
|
baseInfo = {
|
...baseInfo,
|
objectType: 'TransactionApply',
|
transCode: transCodeOne
|
}
|
}
|
|
if (pageId === '60') {
|
baseInfo.trxnbrArray = trxnbrArray
|
}
|
if (pageId === '101' || pageId === '102') {
|
const noRequireItem = invoiceRequiredItems.find(
|
({ name }) => !invoiceInfo[name] || invoiceInfo[name] === ''
|
)
|
if (noRequireItem) {
|
this.$message.warning(`请先输入${noRequireItem.label}`)
|
return false
|
}
|
baseInfo = {
|
...baseInfo,
|
...invoiceInfo
|
}
|
}
|
|
if (parseInt(stageNum) === 3) {
|
baseInfo = {
|
...baseInfo,
|
refundtWay: refundApplicationInfo.refundType,
|
name: refundApplicationInfo.name,
|
accountType: refundApplicationInfo.accountingChannel,
|
accountNo: refundApplicationInfo.accountNo
|
}
|
}
|
|
try {
|
await model.request({
|
...info,
|
logSerialno: transLogSerialno,
|
...baseInfo
|
})
|
|
this.isShowDialog = true
|
// this.getDetail()
|
// loading.close()
|
} catch (e) {
|
// loading.close()
|
}
|
} else {
|
// this.$message.warning('当前页面存在必填项未录入或数据录取错误,请检查!')
|
}
|
},
|
|
// 设置表单下拉菜单
|
setSelectOptions() {
|
const { formList, query } = this
|
const { pageId } = query
|
formList.forEach(({ name, attrs = [] }) => {
|
if (
|
attrs.some(
|
item =>
|
(typeof item === 'object' && item.readonly) || item === 'readonly'
|
)
|
) {
|
return false
|
}
|
if (name === 'approveCode') {
|
this.queryCodeValueList(
|
name,
|
pageId === '60'
|
? 'ChannelApplicationResult_dkcx'
|
: 'ChannelApplicationResult'
|
)
|
}
|
})
|
},
|
|
// 贷后交易名称下拉列表
|
async queryCodeValueList(name, codeNo) {
|
const { selectModel } = this
|
const { list } = await selectModel.request({ codeNo })
|
this.updateValue(name, { options: list })
|
},
|
|
// 提交成功后返回原列表页
|
commitSuccess() {
|
this.isShowDialog = false
|
this.$router.go(-1)
|
}
|
},
|
computed: {
|
// 表单值信息
|
formValues() {
|
const { model, formList } = this
|
return model ? model.getFormValues(formList) : {}
|
},
|
formRules() {
|
const { model, formList } = this
|
return model.getFormRules(formList)
|
},
|
...mapState({
|
invoiceInfo: state => state.tabsModule.invoiceInfo,
|
trxnbrArray: state => state.tabsModule.trxnbrArray,
|
refundApplicationInfo: state => state.tabsModule.refundApplicationInfo
|
})
|
},
|
watch: {
|
$route() {
|
const { transLogSerialno, objectNo } = this.$route.query
|
if (transLogSerialno) {
|
this.init()
|
}
|
if (objectNo) {
|
this.init()
|
}
|
}
|
}
|
}
|
</script>
|
<style lang="postcss" scoped>
|
.apply-info {
|
}
|
</style>
|