【update】报名页面增加发票信息的核对、增加备注字段
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
// 发票信息模态框等相关操作的集合
|
||||
// 需要发票的类型
|
||||
export const InvoiceTypeEnums = {
|
||||
noNeed: { name: '不需要', index: 0 },
|
||||
plain: { name: '增值税普通发票', index: 1 },
|
||||
special: { name: '增值税专用发票', index: 2 }
|
||||
}
|
||||
const commonArr = [
|
||||
{name: '企业名称', key: 'companyName'},
|
||||
{name: '信用代码', key: 'dutyCode'}
|
||||
]
|
||||
const specialArr = [
|
||||
{name: '公司地址', key: 'companyAddress'},
|
||||
{name: '公司电话', key: 'companyPhone'},
|
||||
{name: '开户行', key: 'openingBank'},
|
||||
{name: '银行账号', key: 'bankAccount'},
|
||||
{name: '联行号', key: 'linkBankNumber'}
|
||||
]
|
||||
import signUpApi from '../assets/js/http/signUp'
|
||||
|
||||
module.exports = Behavior({
|
||||
data: {
|
||||
// page-container 相关的配置
|
||||
statusBarHeight: wx.getSystemInfoSync()['statusBarHeight'],
|
||||
invoiceConfirmModalVisible: false,
|
||||
duration: 300,
|
||||
position: 'bottom',
|
||||
round: false,
|
||||
overlay: true,
|
||||
customStyle: 'height: 60%;',
|
||||
overlayStyle: '',
|
||||
// 验证的相关信息
|
||||
confirmArr: [],
|
||||
confirmObj: {}
|
||||
|
||||
},
|
||||
methods: {
|
||||
showConfirmModal(obj, callback) {
|
||||
console.log("----showConfirmModal-----")
|
||||
this.data.confirmObj = {...obj}
|
||||
let needInvoice = Number(obj.needInvoice)
|
||||
let confirmArr = [...commonArr]
|
||||
if (needInvoice === InvoiceTypeEnums.special.index) {
|
||||
confirmArr = confirmArr.concat(specialArr)
|
||||
}
|
||||
// 将回调函数存储
|
||||
this.confirmModalCallback = callback
|
||||
this.setData({
|
||||
invoiceConfirmModalVisible: true,
|
||||
confirmObj: this.data.confirmObj,
|
||||
confirmArr
|
||||
})
|
||||
},
|
||||
/**
|
||||
* 判断发票信息是否发生改变
|
||||
* @param confirmObj ---form表单中的数据
|
||||
* @param selectedCompany ---单位的初始化信息
|
||||
* @returns {boolean} --返回是否发生改变
|
||||
*/
|
||||
judgeInvoiceChange(confirmObj, selectedCompany) {
|
||||
// 如果需要发票,判断当前的发票信息是否进行了修改,用于最后提交的时候判断是否请求接口,减少冗余的请求
|
||||
let needInvoice = Number(confirmObj.needInvoice)
|
||||
if(!needInvoice) {
|
||||
return false
|
||||
}
|
||||
if (needInvoice) {
|
||||
let changeInvoiceFlag = this.data.confirmArr.some(tt => {
|
||||
if(selectedCompany[tt.key] !== confirmObj[tt.key]) {
|
||||
return true
|
||||
}
|
||||
})
|
||||
return changeInvoiceFlag
|
||||
}
|
||||
},
|
||||
confirmModalCancel() {
|
||||
this.setData({
|
||||
invoiceConfirmModalVisible: false
|
||||
})
|
||||
},
|
||||
confirmModalSureFunc() {
|
||||
const formData = this.data.confirmObj
|
||||
// 首先先判断发票信息有没有变化
|
||||
let changeInvoiceFlag = this.judgeInvoiceChange(formData, this.data.selectedCompany)
|
||||
if(!changeInvoiceFlag) {
|
||||
this.setData({
|
||||
invoiceConfirmModalVisible: false
|
||||
})
|
||||
this.confirmModalCallback && this.confirmModalCallback()
|
||||
return
|
||||
}
|
||||
|
||||
// 变化的时候请求接口
|
||||
// 请求接口同步数据
|
||||
const params = {
|
||||
id: formData.companyId, // 企业id
|
||||
needInvoice: formData.needInvoice,
|
||||
companyName: formData.companyName,
|
||||
dutyCode: formData.dutyCode
|
||||
}
|
||||
if (Number(formData.needInvoice) === InvoiceTypeEnums.special.index) {
|
||||
params.companyAddress = formData.companyAddress
|
||||
params.companyPhone = formData.companyPhone
|
||||
params.openingBank = formData.openingBank
|
||||
params.bankAccount = formData.bankAccount
|
||||
params.linkBankNumber = formData.linkBankNumber
|
||||
}
|
||||
signUpApi.updateInvoiceBySignUp(params).then(res => {
|
||||
if (res.success) {
|
||||
this.setData({
|
||||
invoiceConfirmModalVisible: false
|
||||
})
|
||||
this.confirmModalCallback && this.confirmModalCallback()
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: res.message,
|
||||
icon: "none",
|
||||
duration: 800,
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user