【修改】到账开票批量开票 修改

This commit is contained in:
fengachen
2022-11-09 15:18:34 +08:00
parent b6354f50bf
commit fbff76f178
4 changed files with 102 additions and 50 deletions
@@ -148,7 +148,7 @@ export default {
if(!amount) return if(!amount) return
let obj = this.calcOtherNumber(amount) let obj = this.calcOtherNumber(amount)
this.$nextTick(() => { this.$nextTick(() => {
this.form.setFieldsValue( {tax:obj.noTaxAmount,noTaxAmount: obj.tax}) this.form.setFieldsValue( {tax:obj.tax,noTaxAmount: obj.noTaxAmount})
}) })
}, },
edit(record) { edit(record) {
@@ -137,7 +137,7 @@ export default {
if(!amount) return if(!amount) return
let obj = this.calcOtherNumber(amount) let obj = this.calcOtherNumber(amount)
this.$nextTick(() => { this.$nextTick(() => {
this.form.setFieldsValue( {tax:obj.noTaxAmount,noTaxAmount: obj.tax}) this.form.setFieldsValue( {tax:obj.tax,noTaxAmount: obj.noTaxAmount})
}) })
}, },
add(projectInfo, isFirst) { add(projectInfo, isFirst) {
@@ -166,7 +166,7 @@ export default {
if(!amount) return if(!amount) return
let obj = this.calcOtherNumber(amount) let obj = this.calcOtherNumber(amount)
this.$nextTick(() => { this.$nextTick(() => {
this.form.setFieldsValue( {tax:obj.noTaxAmount,noTaxAmount: obj.tax}) this.form.setFieldsValue( {tax:obj.tax,noTaxAmount: obj.noTaxAmount})
}) })
}, },
add() { add() {
@@ -1,13 +1,13 @@
<template> <template>
<j-modal <j-modal
:title="title" :title="title"
:width="width" :width="width"
:visible="visible" :visible="visible"
:confirmLoading="confirmLoading" :confirmLoading="confirmLoading"
switchFullscreen switchFullscreen
@ok="handleOk" @ok="handleOk"
@cancel="handleCancel" @cancel="handleCancel"
cancelText="关闭"> cancelText="关闭">
<a-spin :spinning="confirmLoading"> <a-spin :spinning="confirmLoading">
<a-form :form="form"> <a-form :form="form">
<a-row> <a-row>
@@ -43,11 +43,11 @@
<a-col :xl="12" :sm="24" v-if="isFinancial"> <a-col :xl="12" :sm="24" v-if="isFinancial">
<a-form-item label="邮寄联系人" :labelCol="labelCol" :wrapperCol="wrapperCol"> <a-form-item label="邮寄联系人" :labelCol="labelCol" :wrapperCol="wrapperCol">
<select-contacts <select-contacts
placeholder="请选择邮寄联系人" placeholder="请选择邮寄联系人"
v-decorator="['contactId',validatorRules.contactId]" v-decorator="['contactId',validatorRules.contactId]"
v-bind="$attrs" v-bind="$attrs"
:maxLength='50' :maxLength='50'
@change="postContactChange"></select-contacts> @change="postContactChange"></select-contacts>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>
@@ -73,13 +73,13 @@
</a-form> </a-form>
<a-table <a-table
ref="table" ref="table"
size="middle" size="middle"
bordered bordered
rowKey="id" rowKey="id"
:columns="columns" :columns="columns"
:dataSource="dataSource" :dataSource="dataSource"
class="j-table-force-nowrap"> class="j-table-force-nowrap">
<template slot="text" slot-scope="text"> <template slot="text" slot-scope="text">
<j-ellipsis :value="text" :length="18"></j-ellipsis> <j-ellipsis :value="text" :length="18"></j-ellipsis>
</template> </template>
@@ -92,6 +92,11 @@
@change="e => {e.target.value = (e.target.value + '').trim()}"></a-input> @change="e => {e.target.value = (e.target.value + '').trim()}"></a-input>
</template> </template>
<!-- 税率-->
<template slot="tax-rate" slot-scope="text,record">
<j-dict-select-tag style="width: 100%" @input="changeRate(record)" placeholder="请选择税率" dict-code="rate" v-model="record.taxRate"></j-dict-select-tag>
</template>
</a-table> </a-table>
</a-spin> </a-spin>
</j-modal> </j-modal>
@@ -99,16 +104,16 @@
<script> <script>
import JDate from '../../../components/tools/JDate' import JDate from '../../../components/tools/JDate'
import { money } from '../../../utils/validate' import {money} from '../../../utils/validate'
import { addZero } from '../../../utils/util' import {addZero} from '../../../utils/util'
import { addPayBill } from '../../../api/incomePaymentsApi' import {addPayBill} from '../../../api/incomePaymentsApi'
import SelectContacts from '../../../components/company/SelectContacts' import SelectContacts from '../../../components/company/SelectContacts'
import { getContactsById } from '../../../api/api' import {getContactsById} from '../../../api/api'
import pick from 'lodash.pick' import pick from 'lodash.pick'
export default { export default {
name: 'BatchInvoicingModule', name: 'BatchInvoicingModule',
components: { JDate, SelectContacts }, components: {JDate, SelectContacts},
props: { props: {
// 选中的项目信息 // 选中的项目信息
selectedData: { selectedData: {
@@ -151,24 +156,24 @@ export default {
data() { data() {
return { return {
title: '批量开票', title: '批量开票',
width: 1000, width: 1200,
confirmLoading: false, confirmLoading: false,
form: this.$form.createForm(this), form: this.$form.createForm(this),
labelCol: { labelCol: {
xs: { span: 24 }, xs: {span: 24},
sm: { span: 6 } sm: {span: 6}
}, },
wrapperCol: { wrapperCol: {
xs: { span: 24 }, xs: {span: 24},
sm: { span: 18 } sm: {span: 18}
}, },
remarksLabelCol: { remarksLabelCol: {
xs: { span: 24 }, xs: {span: 24},
sm: { span: 3 } sm: {span: 3}
}, },
remarksWrapperCol: { remarksWrapperCol: {
xs: { span: 24 }, xs: {span: 24},
sm: { span: 21 } sm: {span: 21}
}, },
columns: [ columns: [
{ {
@@ -184,55 +189,77 @@ export default {
title: '打包项目名称', title: '打包项目名称',
align: 'center', align: 'center',
dataIndex: 'chargeProject', dataIndex: 'chargeProject',
scopedSlots: { customRender: 'text' } scopedSlots: {customRender: 'text'}
}, { }, {
title: '应收金额', title: '应收金额',
align: 'center', align: 'center',
width: 100, width: 100,
dataIndex: 'receivableAmount' dataIndex: 'receivableAmount'
}, { },
{
title: '已开票金额', title: '已开票金额',
align: 'center', align: 'center',
width: 100, width: 100,
dataIndex: 'invoiceAmount' dataIndex: 'invoiceAmount'
}, { },
{
title: '本次开票金额', title: '本次开票金额',
align: 'center', align: 'center',
width: 140, width: 140,
dataIndex: 'thisInvoicingAmount' dataIndex: 'thisInvoicingAmount'
}, { },
{
title: '税率',
align: 'center',
width: 120,
dataIndex: 'taxRate',
scopedSlots: {customRender: 'tax-rate'}
},
{
title: '税额',
align: 'center',
width: 100,
dataIndex: 'tax',
},
{
title: '未税额',
align: 'center',
width: 100,
dataIndex: 'noTaxAmount',
},
{
title: '备注', title: '备注',
align: 'center', align: 'center',
width: 200, width: 200,
dataIndex: 'remark', dataIndex: 'remark',
scopedSlots: { customRender: 'input-text' } scopedSlots: {customRender: 'input-text'}
} }
], ],
dataSource: [], dataSource: [],
remarkList: [], // 备注列表 remarkList: [], // 备注列表
validatorRules: { validatorRules: {
invoiceAmount: { invoiceAmount: {
rules: [{ required: true, validator: this.checkMoney }], rules: [{required: true, validator: this.checkMoney}],
validateTrigger: 'blur' validateTrigger: 'blur'
}, },
billNo: { billNo: {
rules: [{ required: true, message: '请输入开票号' }], rules: [{required: true, message: '请输入开票号'}],
validateTrigger: 'blur' validateTrigger: 'blur'
}, },
billDate: { billDate: {
rules: [{ required: true, message: '请选择开票时间' }], rules: [{required: true, message: '请选择开票时间'}],
validateTrigger: 'change' validateTrigger: 'change'
}, },
contactId: { contactId: {
rules: [{ required: true, message: '请选择邮寄联系人' }], rules: [{required: true, message: '请选择邮寄联系人'}],
validateTrigger: 'change' validateTrigger: 'change'
}, },
postalCode: { postalCode: {
rules: [{ required: true, message: '请输入邮政编码' }], rules: [{required: true, message: '请输入邮政编码'}],
validateTrigger: 'blur' validateTrigger: 'blur'
}, },
contactAddress: { contactAddress: {
rules: [{ required: true, message: '请输入通讯地址' }], rules: [{required: true, message: '请输入通讯地址'}],
validateTrigger: 'blur' validateTrigger: 'blur'
} }
}, },
@@ -246,6 +273,17 @@ export default {
}, },
methods: { methods: {
addZero, addZero,
/**
* 计算本项目开票金额的税额与未税额
* */
changeRate(record){
// 获取本次开票金额 税率
let {thisInvoicingAmount,taxRate} = record
// 计算本次开票金额的 税额与未税额
if(!thisInvoicingAmount) return
record.noTaxAmount = (thisInvoicingAmount / (1 + taxRate * 1)).toFixed(2)
record.tax = (thisInvoicingAmount - record.noTaxAmount).toFixed(2)
},
/** /**
* 获取补0的数据 * 获取补0的数据
* @param value * @param value
@@ -266,8 +304,13 @@ export default {
let amountOwed = Number(item.receivableAmount) - Number(item.invoiceAmount) let amountOwed = Number(item.receivableAmount) - Number(item.invoiceAmount)
item.amountOwed = this.getAddZero(amountOwed) item.amountOwed = this.getAddZero(amountOwed)
item.thisInvoicingAmount = 0 item.thisInvoicingAmount = 0
// 清空上一次的税额 未税额
item.tax = ''
item.noTaxAmount = ''
this.sumAmountOwed += Number(item.amountOwed) this.sumAmountOwed += Number(item.amountOwed)
this.sumInvoiceAmount += Number(item.invoiceAmount) this.sumInvoiceAmount += Number(item.invoiceAmount)
// 设置默认税率 0.06
item.taxRate = '0.06'
}) })
this.$forceUpdate() this.$forceUpdate()
}, },
@@ -289,7 +332,7 @@ export default {
console.log(value) console.log(value)
// value不为undefined // value不为undefined
if (value) { if (value) {
getContactsById({ id: value }).then(res => { getContactsById({id: value}).then(res => {
let obj = { let obj = {
postalCode: res.result.postalCode, postalCode: res.result.postalCode,
contactAddress: res.result.contactAddress contactAddress: res.result.contactAddress
@@ -323,6 +366,7 @@ export default {
* 计算此次开票信息 * 计算此次开票信息
*/ */
calculateThisTimeAmount() { calculateThisTimeAmount() {
console.log(123)
// if (this.inputInvoicingAmount === null) { // if (this.inputInvoicingAmount === null) {
// this.$message.warn('开票金额不得为0') // this.$message.warn('开票金额不得为0')
// return // return
@@ -386,7 +430,12 @@ export default {
} }
this.$set(this.dataSource, i, item) this.$set(this.dataSource, i, item)
} }
} }
// 计算税额 与未税额
this.dataSource.forEach(m => {
this.changeRate(m)
})
// this.dataSource.forEach((item, index) => { // this.dataSource.forEach((item, index) => {
// // 当前项目欠款是否 >0 // // 当前项目欠款是否 >0
// if (Number(item.amountOwed) > 0 && Number(item.amountOwed) !== Number(item.invoiceAmount)) { // if (Number(item.amountOwed) > 0 && Number(item.amountOwed) !== Number(item.invoiceAmount)) {
@@ -432,6 +481,9 @@ export default {
invoiceAmount: item.thisInvoicingAmount, invoiceAmount: item.thisInvoicingAmount,
projectId: item.id, projectId: item.id,
projectType: item.projectType, projectType: item.projectType,
tax:item.tax,
taxRate:item.taxRate,
noTaxAmount:item.noTaxAmount,
remark: this.remarkList[index] remark: this.remarkList[index]
} }
bmpList.push(obj) bmpList.push(obj)
@@ -463,7 +515,7 @@ export default {
this.close() this.close()
}, },
open() { open() {
this.dataSource = this.selectedData this.dataSource = [...this.selectedData]
this.dataSource.forEach(() => { this.dataSource.forEach(() => {
this.remarkList.push('') this.remarkList.push('')
}) })