[update] 到账开票可以输入负值;取消完全来款/完全开票不得来款/开票的限制
This commit is contained in:
@@ -365,9 +365,9 @@ export default {
|
||||
}
|
||||
|
||||
// 是否存在已完成开票的项目
|
||||
if (arr.some(item => item.makeInvoice === 1)) {
|
||||
reject('存在已完成开票的项目!')
|
||||
}
|
||||
// if (arr.some(item => item.makeInvoice === 1)) {
|
||||
// reject('存在已完成开票的项目!')
|
||||
// }
|
||||
|
||||
// 是否选中了标协会员项目,标协会员项目只能到账一次、开票一次,前端进行是否完全到账的限制
|
||||
if (arr.some(item => item.projectType === 5)) {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
v-decorator="['amountReceived',validatorRules.amountReceived]"
|
||||
:maxLength='50'
|
||||
@blur="addZero"
|
||||
@change="e => e.target.value = (e.target.value.replace(/[^0-9.]/g, '')).trim()"></a-input>
|
||||
@change="e => e.target.value = (e.target.value.replace(/[^0-9-.]/g, '')).trim()"></a-input>
|
||||
</a-form-item>
|
||||
<a-form-item label="来款日期" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
||||
<j-date placeholder="请选择来款日期"
|
||||
@@ -60,7 +60,7 @@ export default {
|
||||
type: Number,
|
||||
required: false,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -154,14 +154,9 @@ export default {
|
||||
checkMoney(rules, value, callback) {
|
||||
if (value) {
|
||||
if (money(value)) {
|
||||
if (Number(value) > 0) {
|
||||
callback()
|
||||
} else {
|
||||
callback('到账金额不能小于或等于0')
|
||||
}
|
||||
return
|
||||
callback()
|
||||
}
|
||||
callback('请输入合法的金额数字,最多2位小数,10位正数')
|
||||
callback('请输入合法的金额数字,最多2位小数,10位整数')
|
||||
}
|
||||
callback('请输入到账金额')
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
v-decorator="['invoiceAmount',validatorRules.invoiceAmount]"
|
||||
:maxLength='50'
|
||||
@blur="addZero"
|
||||
@change="e => e.target.value = (e.target.value.replace(/[^0-9.]/g, '')).trim()"></a-input>
|
||||
@change="e => e.target.value = (e.target.value.replace(/[^0-9.-]/g, '')).trim()"></a-input>
|
||||
</a-form-item>
|
||||
<a-form-item label="开票号" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
||||
<a-input placeholder="请输入开票号"
|
||||
@@ -85,7 +85,7 @@ export default {
|
||||
type: String,
|
||||
required: false,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -136,7 +136,7 @@ export default {
|
||||
})
|
||||
},
|
||||
getMailContactPostalCode() {
|
||||
getContactsById({id: this.mailContactsId}).then(res => {
|
||||
getContactsById({ id: this.mailContactsId }).then(res => {
|
||||
this.postalCode = res.result.postalCode
|
||||
this.contactAddress = res.result.contactAddress
|
||||
})
|
||||
@@ -208,9 +208,8 @@ export default {
|
||||
if (value) {
|
||||
if (money(value)) {
|
||||
callback()
|
||||
return
|
||||
}
|
||||
callback('请输入合法的金额数字,最多2位小数,10位正数')
|
||||
callback('请输入合法的金额数字,最多2位小数,10位整数')
|
||||
}
|
||||
callback('请输入到账金额')
|
||||
}
|
||||
|
||||
@@ -368,6 +368,9 @@ export default {
|
||||
* 获取企业信息
|
||||
*/
|
||||
loadCompanyDetail() {
|
||||
if (!this.$route.query.packCompanyId) {
|
||||
return
|
||||
}
|
||||
let param = {
|
||||
id: this.$route.query.packCompanyId
|
||||
}
|
||||
@@ -530,9 +533,9 @@ export default {
|
||||
if (arr.some(item => item.needInvoice === 0 || Number(item.receivableAmount) === 0)) {
|
||||
reject('存在不需要发票的项目!')
|
||||
}
|
||||
if (arr.some(item => item.makeInvoice === 1)) {
|
||||
reject('存在已完成开票的项目!')
|
||||
}
|
||||
// if (arr.some(item => item.makeInvoice === 1)) {
|
||||
// reject('存在已完成开票的项目!')
|
||||
// }
|
||||
// 是否选中了标协会员项目,标协会员项目只能到账一次、开票一次,前端进行是否完全到账的限制
|
||||
if (arr.some(item => item.projectType === 5)) {
|
||||
// 标协会员项目是否完全到账
|
||||
@@ -547,9 +550,9 @@ export default {
|
||||
if (arr.some(item => Number(item.receivableAmount) === 0)) {
|
||||
reject('存在应收金额为0的项目!')
|
||||
}
|
||||
if (arr.some(item => item.inAccount === 1)) {
|
||||
reject('不可选择已付全款的项目!')
|
||||
}
|
||||
// if (arr.some(item => item.inAccount === 1)) {
|
||||
// reject('不可选择已付全款的项目!')
|
||||
// }
|
||||
}
|
||||
resolve(arr)
|
||||
})
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
<a-input placeholder="请输入来款金额"
|
||||
v-decorator="['incomingAmount', validatorRules.incomingAmount]"
|
||||
:maxLength='50'
|
||||
@change="(e) => {e.target.value = (e.target.value.replace(/[^0-9.]/g,'')).trim()}"
|
||||
@change="(e) => {e.target.value = (e.target.value.replace(/[^0-9.-]/g,'')).trim()}"
|
||||
@blur="incomingAmountBlur"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
@@ -168,7 +168,10 @@ export default {
|
||||
remarkList: [], // 备注列表
|
||||
inputIncomingAmount: null, // 输入的来款金额
|
||||
disableMixinCreated: true,
|
||||
sumAmountOwed: 0 // 总欠款金额
|
||||
sumAmountOwed: 0, // 总欠款金额
|
||||
sumIncomingAmount: 0, // 总来款金额
|
||||
// 用于提交的表格数据
|
||||
submitDataSource: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -188,6 +191,7 @@ export default {
|
||||
let amountOwed = Number(item.receivableAmount) - Number(item.paidAmount)
|
||||
item.amountOwed = this.getAddZero(amountOwed)
|
||||
this.sumAmountOwed += Number(item.amountOwed)
|
||||
this.sumIncomingAmount += Number(item.paidAmount)
|
||||
})
|
||||
this.$forceUpdate()
|
||||
},
|
||||
@@ -196,6 +200,10 @@ export default {
|
||||
this.$message.warn('来款金额大于当前欠款金额,输入有误!')
|
||||
return
|
||||
}
|
||||
if (this.inputIncomingAmount < 0 && this.sumIncomingAmount === 0) {
|
||||
this.$message.warn('当前总来款金额为0,不可输入小于0的来款金额')
|
||||
return
|
||||
}
|
||||
if (this.confirmLoading) {
|
||||
return
|
||||
}
|
||||
@@ -203,19 +211,16 @@ export default {
|
||||
this.form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
let formData = []
|
||||
this.dataSource.forEach((item, index) => {
|
||||
if (Number(item.thisIncomingAmount) > 0) {
|
||||
let obj = {
|
||||
amountReceived: item.thisIncomingAmount,
|
||||
paymentDate: values.paymentDate,
|
||||
projectId: item.id,
|
||||
projectType: item.projectType,
|
||||
remark: this.remarkList[index]
|
||||
}
|
||||
formData.push(obj)
|
||||
this.submitDataSource.forEach((item, index) => {
|
||||
let obj = {
|
||||
amountReceived: item.thisIncomingAmount,
|
||||
paymentDate: values.paymentDate,
|
||||
projectId: item.id,
|
||||
projectType: item.projectType,
|
||||
remark: this.remarkList[index]
|
||||
}
|
||||
formData.push(obj)
|
||||
})
|
||||
console.log(formData)
|
||||
addPaymentPhase(formData).then(res => {
|
||||
if (res.success) {
|
||||
this.$message.success(res.message)
|
||||
@@ -256,7 +261,7 @@ export default {
|
||||
*/
|
||||
incomingAmountBlur(e) {
|
||||
this.addZero(e)
|
||||
e.target.value = (e.target.value.replace(/[^0-9.]/g, '')).trim()
|
||||
e.target.value = (e.target.value.replace(/[^0-9.-]/g, '')).trim()
|
||||
this.inputIncomingAmount = Number(e.target.value)
|
||||
this.clearThisTimeAmount()
|
||||
this.calculateThisTimeAmount()
|
||||
@@ -274,31 +279,70 @@ export default {
|
||||
* 计算此次来款信息
|
||||
*/
|
||||
calculateThisTimeAmount() {
|
||||
if (this.inputIncomingAmount <= 0) {
|
||||
this.$message.warn('请输入大于0的来款金额')
|
||||
return
|
||||
}
|
||||
// if (this.inputIncomingAmount === 0) {
|
||||
// this.$message.warn('来款金额不得为0')
|
||||
// return
|
||||
// }
|
||||
if (this.inputIncomingAmount > this.sumAmountOwed) {
|
||||
this.$message.warn('来款金额大于当前欠款金额,输入有误!')
|
||||
return
|
||||
}
|
||||
this.dataSource.forEach((item, index) => {
|
||||
// 当前项目欠款是否 >0
|
||||
if (Number(item.amountOwed) > 0) {
|
||||
// 输入的来款金额是否 >= 当前项目欠款
|
||||
if (this.inputIncomingAmount >= Number(item.amountOwed)) {
|
||||
item.thisIncomingAmount = this.getAddZero(Number(item.amountOwed))
|
||||
this.inputIncomingAmount -= Number(item.amountOwed)
|
||||
} else {
|
||||
// 输入的来款金额小于当前项目欠款且剩余的输入来款金额大于0,则将剩余全部来款算入当前项目的此次来款
|
||||
if (this.inputIncomingAmount > 0) {
|
||||
item.thisIncomingAmount = this.getAddZero(this.inputIncomingAmount)
|
||||
this.inputIncomingAmount = 0
|
||||
}
|
||||
}
|
||||
if (this.inputIncomingAmount < 0 && this.sumIncomingAmount === 0) {
|
||||
this.$message.warn('当前总来款金额为0,不可输入小于0的来款金额')
|
||||
return
|
||||
}
|
||||
// 用于计算的数据
|
||||
let changeInputAmount = this.inputIncomingAmount
|
||||
// 清除要提交的数据
|
||||
this.submitDataSource = []
|
||||
for (let i = 0; i < this.dataSource.length; i++) {
|
||||
let item = this.dataSource[i]
|
||||
//输入来款金额为0,给选中的项目添加来款阶段,来款金额为0
|
||||
if (this.inputIncomingAmount === 0) {
|
||||
item.thisIncomingAmount = this.getAddZero(this.inputIncomingAmount)
|
||||
this.$set(this.dataSource, i, item)
|
||||
this.$set(this.submitDataSource, i, item)
|
||||
continue
|
||||
}
|
||||
this.$set(this.dataSource, index, item)
|
||||
})
|
||||
// 输入的来款金额>0
|
||||
if (this.inputIncomingAmount > 0) {
|
||||
// 分配剩下的>0才能继续走分配
|
||||
if (changeInputAmount > 0) {
|
||||
// 输入的来款金额是否 >= 当前项目欠款
|
||||
if (changeInputAmount >= Number(item.amountOwed)) {
|
||||
item.thisIncomingAmount = this.getAddZero(Number(item.amountOwed))
|
||||
changeInputAmount -= Number(item.amountOwed)
|
||||
} else {
|
||||
// 输入的来款金额小于当前项目欠款且剩余的输入来款金额大于0,则将剩余全部来款算入当前项目的此次来款
|
||||
item.thisIncomingAmount = this.getAddZero(changeInputAmount)
|
||||
changeInputAmount = 0
|
||||
}
|
||||
this.$set(this.submitDataSource, i, item)
|
||||
} else {
|
||||
item.thisIncomingAmount = this.getAddZero(0)
|
||||
}
|
||||
this.$set(this.dataSource, i, item)
|
||||
continue
|
||||
}
|
||||
// 输入的来款金额<0
|
||||
if (this.inputIncomingAmount < 0) {
|
||||
// 分配剩下的<0 && 已收金额 > 0才能继续走分配
|
||||
if (changeInputAmount < 0 && Number(item.paidAmount) > 0) {
|
||||
// 若当前项目的实收 + 分配剩余 > 0,将当前全部分配给这个项目且将剩余清0
|
||||
if (Number(item.paidAmount) + changeInputAmount >= 0) {
|
||||
item.thisIncomingAmount = this.getAddZero(changeInputAmount)
|
||||
changeInputAmount = 0
|
||||
} else {
|
||||
item.thisIncomingAmount = this.getAddZero(-Number(item.paidAmount))
|
||||
changeInputAmount += Number(item.paidAmount)
|
||||
}
|
||||
this.$set(this.submitDataSource, i, item)
|
||||
} else {
|
||||
item.thisIncomingAmount = this.getAddZero(0)
|
||||
}
|
||||
this.$set(this.dataSource, i, item)
|
||||
}
|
||||
}
|
||||
}
|
||||
,
|
||||
/**
|
||||
@@ -309,14 +353,11 @@ export default {
|
||||
*/
|
||||
checkMoney(rules, value, callback) {
|
||||
if (value) {
|
||||
if (Number(value) <= 0) {
|
||||
callback('来款金额不能小于或等于0')
|
||||
}
|
||||
if (money(value)) {
|
||||
callback()
|
||||
return
|
||||
}
|
||||
callback('请输入合法的金额数字,最多2位小数,10位正数')
|
||||
callback('请输入合法的金额数字,最多2位小数,10位整数')
|
||||
}
|
||||
callback('请输入来款金额')
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
v-decorator="['invoiceAmount',validatorRules.invoiceAmount]"
|
||||
:maxLength='50'
|
||||
@blur="invoicingAmountBlur"
|
||||
@change="(e) => {e.target.value = (e.target.value.replace(/[^0-9.]/g,'')).trim()}"></a-input>
|
||||
@change="(e) => {e.target.value = (e.target.value.replace(/[^0-9.-]/g,'')).trim()}"></a-input>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
<a-col :xl="12" :sm="24">
|
||||
@@ -238,7 +238,10 @@ export default {
|
||||
},
|
||||
inputInvoicingAmount: null, // 输入的开票金额
|
||||
sumAmountOwed: 0, // 总未开票金额,
|
||||
sumInvoiceAmount: 0, // 总已开票金额
|
||||
packContact: {}, // 邮寄联系人信息
|
||||
// 用于提交的表格数据
|
||||
submitDataSource: []
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -264,6 +267,7 @@ export default {
|
||||
item.amountOwed = this.getAddZero(amountOwed)
|
||||
item.thisInvoicingAmount = 0
|
||||
this.sumAmountOwed += Number(item.amountOwed)
|
||||
this.sumInvoiceAmount += Number(item.invoiceAmount)
|
||||
})
|
||||
this.$forceUpdate()
|
||||
},
|
||||
@@ -272,7 +276,7 @@ export default {
|
||||
*/
|
||||
invoicingAmountBlur(e) {
|
||||
this.addZero(e)
|
||||
e.target.value = (e.target.value.replace(/[^0-9.]/g, '')).trim()
|
||||
e.target.value = (e.target.value.replace(/[^0-9.-]/g, '')).trim()
|
||||
this.inputInvoicingAmount = Number(e.target.value)
|
||||
this.clearThisTimeAmount()
|
||||
this.calculateThisTimeAmount()
|
||||
@@ -319,37 +323,102 @@ export default {
|
||||
* 计算此次开票信息
|
||||
*/
|
||||
calculateThisTimeAmount() {
|
||||
if (this.inputInvoicingAmount <= 0) {
|
||||
this.$message.warn('请输入大于0的开票金额')
|
||||
return
|
||||
}
|
||||
// if (this.inputInvoicingAmount === null) {
|
||||
// this.$message.warn('开票金额不得为0')
|
||||
// return
|
||||
// }
|
||||
if (this.inputInvoicingAmount > this.sumAmountOwed) {
|
||||
this.$message.warn('开票金额大于当前未开票金额,输入有误!')
|
||||
return
|
||||
}
|
||||
this.dataSource.forEach((item, index) => {
|
||||
// 当前项目欠款是否 >0
|
||||
if (Number(item.amountOwed) > 0) {
|
||||
// 输入的开票金额是否 >= 当前项目欠款
|
||||
if (this.inputInvoicingAmount >= Number(item.amountOwed)) {
|
||||
item.thisInvoicingAmount = this.getAddZero(Number(item.amountOwed))
|
||||
this.inputInvoicingAmount -= Number(item.amountOwed)
|
||||
} else {
|
||||
// 输入的开票金额小于当前项目欠款且剩余的输入开票金额大于0,则将剩余全部开票算入当前项目的此次开票
|
||||
if (this.inputInvoicingAmount > 0) {
|
||||
item.thisInvoicingAmount = this.getAddZero(this.inputInvoicingAmount)
|
||||
this.inputInvoicingAmount = 0
|
||||
}
|
||||
}
|
||||
if (this.inputInvoicingAmount < 0 && this.sumInvoiceAmount === 0) {
|
||||
this.$message.warn('当前总开票金额为0,不可输入小于0的开票金额')
|
||||
return
|
||||
}
|
||||
// 用于计算的数据
|
||||
let changeInputAmount = this.inputInvoicingAmount
|
||||
// 清除要提交的数据
|
||||
this.submitDataSource = []
|
||||
for (let i = 0; i < this.dataSource.length; i++) {
|
||||
let item = this.dataSource[i]
|
||||
//输入来款金额为0,给选中的项目添加来款阶段,来款金额为0
|
||||
if (this.inputInvoicingAmount === 0) {
|
||||
item.thisInvoicingAmount = this.getAddZero(this.inputInvoicingAmount)
|
||||
this.$set(this.dataSource, i, item)
|
||||
this.$set(this.submitDataSource, i, item)
|
||||
continue
|
||||
}
|
||||
this.$set(this.dataSource, index, item)
|
||||
})
|
||||
// 输入的来款金额>0
|
||||
if (this.inputInvoicingAmount > 0) {
|
||||
// 分配剩下的>0才能继续走分配
|
||||
if (changeInputAmount > 0) {
|
||||
// 输入的来款金额是否 >= 当前项目欠款
|
||||
if (changeInputAmount >= Number(item.amountOwed)) {
|
||||
item.thisInvoicingAmount = this.getAddZero(Number(item.amountOwed))
|
||||
changeInputAmount -= Number(item.amountOwed)
|
||||
} else {
|
||||
// 输入的来款金额小于当前项目欠款且剩余的输入来款金额大于0,则将剩余全部来款算入当前项目的此次来款
|
||||
item.thisInvoicingAmount = this.getAddZero(changeInputAmount)
|
||||
changeInputAmount = 0
|
||||
}
|
||||
this.$set(this.submitDataSource, i, item)
|
||||
} else {
|
||||
item.thisInvoicingAmount = this.getAddZero(0)
|
||||
}
|
||||
this.$set(this.dataSource, i, item)
|
||||
continue
|
||||
}
|
||||
// 输入的来款金额<0
|
||||
if (this.inputInvoicingAmount < 0) {
|
||||
// 分配剩下的<0 && 已收金额 > 0才能继续走分配
|
||||
if (changeInputAmount < 0 && Number(item.invoiceAmount) > 0) {
|
||||
// 若当前项目的实收 + 分配剩余 > 0,将当前全部分配给这个项目且将剩余清0
|
||||
if (Number(item.invoiceAmount) + changeInputAmount >= 0) {
|
||||
item.thisInvoicingAmount = this.getAddZero(changeInputAmount)
|
||||
changeInputAmount = 0
|
||||
} else {
|
||||
item.thisInvoicingAmount = this.getAddZero(-Number(item.invoiceAmount))
|
||||
changeInputAmount += Number(item.invoiceAmount)
|
||||
}
|
||||
this.$set(this.submitDataSource, i, item)
|
||||
} else {
|
||||
item.thisInvoicingAmount = this.getAddZero(0)
|
||||
}
|
||||
this.$set(this.dataSource, i, item)
|
||||
}
|
||||
}
|
||||
// this.dataSource.forEach((item, index) => {
|
||||
// // 当前项目欠款是否 >0
|
||||
// if (Number(item.amountOwed) > 0 && Number(item.amountOwed) !== Number(item.invoiceAmount)) {
|
||||
// if (this.inputInvoicingAmount > 0) {
|
||||
// // 输入的开票金额是否 >= 当前项目欠款
|
||||
// if (this.inputInvoicingAmount >= Number(item.amountOwed)) {
|
||||
// item.thisInvoicingAmount = this.getAddZero(Number(item.amountOwed))
|
||||
// this.inputInvoicingAmount -= Number(item.amountOwed)
|
||||
// } else {
|
||||
// // 输入的开票金额小于当前项目欠款且剩余的输入开票金额大于0,则将剩余全部开票算入当前项目的此次开票
|
||||
// if (this.inputInvoicingAmount > 0) {
|
||||
// item.thisInvoicingAmount = this.getAddZero(this.inputInvoicingAmount)
|
||||
// this.inputInvoicingAmount = 0
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// item.thisInvoicingAmount = this.getAddZero(this.inputInvoicingAmount)
|
||||
// this.inputInvoicingAmount = 0
|
||||
// }
|
||||
// }
|
||||
// this.$set(this.dataSource, index, item)
|
||||
// })
|
||||
},
|
||||
handleOk() {
|
||||
if (this.inputInvoicingAmount > this.sumAmountOwed) {
|
||||
this.$message.warn('开票金额大于当前未开票金额,输入有误!')
|
||||
return
|
||||
}
|
||||
if (this.inputInvoicingAmount < 0 && this.sumInvoiceAmount === 0) {
|
||||
this.$message.warn('当前总开票金额为0,不可输入小于0的开票金额')
|
||||
return
|
||||
}
|
||||
if (this.confirmLoading) {
|
||||
return
|
||||
}
|
||||
@@ -357,8 +426,8 @@ export default {
|
||||
this.form.validateFields((err, values) => {
|
||||
if (!err) {
|
||||
let bmpList = []
|
||||
let data = this.dataSource.filter(tt => tt.thisInvoicingAmount !== 0 && tt.thisInvoicingAmount)
|
||||
data.forEach((item, index) => {
|
||||
// let data = this.dataSource.filter(tt => tt.thisInvoicingAmount !== 0 && tt.thisInvoicingAmount)
|
||||
this.submitDataSource.forEach((item, index) => {
|
||||
let obj = {
|
||||
invoiceAmount: item.thisInvoicingAmount,
|
||||
projectId: item.id,
|
||||
@@ -417,9 +486,8 @@ export default {
|
||||
if (value) {
|
||||
if (money(value)) {
|
||||
callback()
|
||||
return
|
||||
}
|
||||
callback('请输入合法的金额数字,最多2位小数,10位正数')
|
||||
callback('请输入合法的金额数字,最多2位小数,10位整数')
|
||||
}
|
||||
callback('请输入开票金额')
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ export default {
|
||||
callback()
|
||||
return
|
||||
}
|
||||
callback('请输入合法的金额数字,最多2位小数,10位正数')
|
||||
callback('请输入合法的金额数字,最多2位小数,10位整数')
|
||||
}
|
||||
callback('请输入打包费用总计')
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user