[update] 到账开票可以输入负值;取消完全来款/完全开票不得来款/开票的限制
This commit is contained in:
@@ -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('请输入开票金额')
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user