Browse Source

新增发票管理,基于申请单开票,开票申请

master
panxinyu-YUYwp 1 month ago
parent
commit
e6cf17d15d
  1. 28
      src/api/billing/billing.js
  2. 26
      src/api/invoice/invoice.js
  3. 633
      src/views/modules/billing/billing-request.vue
  4. 527
      src/views/modules/finance/billing-invoice.vue
  5. 914
      src/views/modules/finance/invoice-management.vue

28
src/api/billing/billing.js

@ -0,0 +1,28 @@
import { createAPI } from '@/utils/httpRequest.js'
// 开票申请分页查询(老 /billingApply/billingApplyData)
export const billingApplyData = data => createAPI(`/billingApply/billingApplyData`, 'post', data)
// 开票申请新增/编辑(老 /billingApply/billingApplySave)
export const billingApplySave = data => createAPI(`/billingApply/billingApplySave`, 'post', data)
// 开票申请删除(老 /billingApply/billingApplyDelete)
export const billingApplyDelete = data => createAPI(`/billingApply/billingApplyDelete`, 'post', data)
// 下面三个下拉都是复用发票模块已有的接口,老页面上那两个同名接口后端没搬:
// 老 /billingApply/projectName(type=IT) → /invoice/valueList?type=IT 开票项目
// 老 /invo/invoSend(type=SW) → /invoice/valueList?type=SW 寄送方式
// 老 /billingApply/findCompanyName → /invoice/companyName 客户的开票公司
export const applyValueList = type => createAPI(`/invoice/valueList?type=${type}`, 'post')
export const applyCompanyName = customerId => createAPI(`/invoice/companyName?customerId=${customerId}`, 'post')
export const getCustomerList = () => createAPI(`/projectInfo/getCustomerList`, 'get')
// 联系人子表(老 /cust/personData,新接口 body 是 {id: 客户id})
export const fetchPersonData = customerId => createAPI(`/cust/fetchPersonData`, 'post', { id: customerId })
// 【基于申请单开票】按开票信息id取税号/客户(老 /billingApply/findBillingByBillingId)
// 后端是 @RequestParam,参数必须走 query string,放进 body 会 400
export const findBillingByBillingId = billingInfoId => createAPI(`/billingApply/findBillingByBillingId?billingInfoId=${billingInfoId}`, 'post')
// 【基于申请单开票】存发票 + 把申请单置 Y(老 /billingApply/invoiceSave)
export const applyInvoiceSave = data => createAPI(`/billingApply/invoiceSave`, 'post', data)

26
src/api/invoice/invoice.js

@ -0,0 +1,26 @@
import { createAPI } from "@/utils/httpRequest.js";
// 发票分页查询(老 /invo/invoiceData)
export const invoiceData = data => createAPI(`/invoice/invoiceData`, 'post', data)
// 发票新增/编辑保存(老 /invo/invoiceSave)
export const invoiceSave = data => createAPI(`/invoice/invoiceSave`, 'post', data)
// 发票删除(老 /invo/invoiceDel)
export const invoiceDelete = data => createAPI(`/invoice/invoiceDel`, 'post', data)
// 值表下拉:type=SW 寄送方式 / type=IT 开票项目(老 /invo/invoSend、/invo/projectName)
// 后端是 @RequestParam,参数必须走 query string,放进 body 会 400
export const invoiceValueList = type => createAPI(`/invoice/valueList?type=${type}`, 'post')
// 客户的开票公司列表(老 /invo/companyName),同样是 @RequestParam
export const invoiceCompanyName = customerId => createAPI(`/invoice/companyName?customerId=${customerId}`, 'post')
// 客户下拉(复用 projectInfo 的现成接口,老 /invo/customerName 没搬)
export const getCustomerList = () => createAPI(`/projectInfo/getCustomerList`, 'get')
// 快递公司名称下拉(老 /express/expressName)
export const expressNameList = () => createAPI(`/express/expressName`, 'post')
// 发票页"快递"按钮的保存(老 /express/expresshistSave)
export const expresshistSave = data => createAPI(`/express/expresshistSave`, 'post', data)

633
src/views/modules/billing/billing-request.vue

@ -0,0 +1,633 @@
<template>
<div class="billing-apply">
<el-form inline>
<!-- 老页面这个框标的是"公司名称",但它过滤的是 customer_name(BillingApplyDaoImpl.findAll)。
这里标"客户名称",改成按 customer_id 精确命中,不再模糊匹配 -->
<el-form-item label="客户名称">
<el-select filterable v-model="searchData.customerId" clearable size="small" placeholder="全部"
style="width: 200px;margin-top: 2px">
<el-option :label="item.customerName" :value="item.id"
v-for="(item,index) in customerListOptions" :key="index"></el-option>
</el-select>
</el-form-item>
<el-form-item label="申请日期">
<el-date-picker v-model="searchData.startDate" type="date" format="yyyy-MM-dd"
value-format="yyyy-MM-dd" placeholder="开始日期" size="small"
style="width: 110px;margin-top: 2px"></el-date-picker>
<span style="margin: 0 4px;">~</span>
<el-date-picker v-model="searchData.dateClosed" type="date" format="yyyy-MM-dd"
value-format="yyyy-MM-dd" placeholder="结束日期" size="small"
style="width: 110px;margin-top: 2px"></el-date-picker>
</el-form-item>
<el-form-item label="是否开票">
<el-select v-model="searchData.status" clearable size="small" placeholder="全部"
style="width: 90px;margin-top: 2px">
<el-option label="是" value="Y"></el-option>
<el-option label="否" value="N"></el-option>
</el-select>
</el-form-item>
<el-form-item label="开票项目">
<el-select v-model="searchData.billingProject" clearable size="small" placeholder="全部"
style="width: 140px;margin-top: 2px">
<el-option :label="item.dataValue" :value="item.dataValue"
v-for="(item,index) in billingProjectOptions" :key="index"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button @click="searchApply" style="margin-top: 2px">查询</el-button>
<el-button @click="resetSearch" style="margin-left: 10px;">重置</el-button>
<el-button type="primary" @click="openAddApplyModal" style="margin-left: 10px;">新增</el-button>
</el-form-item>
</el-form>
<el-table :data="applyList" border :height="height" style="width: 100%;" @sort-change="handleSortChange">
<el-table-column prop="customerName" header-align="center" align="left" min-width="200" label="客户名称" show-overflow-tooltip></el-table-column>
<el-table-column prop="billingCompanyName" header-align="center" align="left" min-width="180" label="公司名称" show-overflow-tooltip></el-table-column>
<el-table-column prop="billingProject" header-align="center" align="center" min-width="100" label="开票项目" show-overflow-tooltip></el-table-column>
<el-table-column prop="projectName" header-align="center" align="left" min-width="180" label="项目名称" show-overflow-tooltip></el-table-column>
<el-table-column prop="billingRate" header-align="center" align="center" min-width="70" label="税率">
<template slot-scope="scope">{{ rateText(scope.row.billingRate) }}</template>
</el-table-column>
<el-table-column prop="amount" header-align="center" align="right" min-width="100" sortable="custom" label="开票金额"></el-table-column>
<el-table-column prop="enteredBy" header-align="center" align="center" min-width="90" label="申请人" show-overflow-tooltip></el-table-column>
<el-table-column prop="enteredDate" header-align="center" align="center" min-width="100" sortable="custom" label="申请时间">
<template slot-scope="scope">{{ d10(scope.row.enteredDate) }}</template>
</el-table-column>
<el-table-column prop="status" header-align="center" align="center" min-width="80" label="是否开票">
<template slot-scope="scope">{{ statusText(scope.row.status) }}</template>
</el-table-column>
<el-table-column fixed="right" header-align="center" align="right" class-name="op-col" width="115" label="操作">
<template slot-scope="scope">
<a type="text" size="small" @click="editApply(scope.row)">编辑</a>
<a type="text" size="small" @click="openDetail(scope.row)">详情</a>
<a type="text" size="small" @click="deleteApply(scope.row)">删除</a>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[20, 50, 100, 200, 500]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
<!-- 新增 / 编辑 / 详情:详情复用同一弹窗,全控件 disabled(发票页就是这个套路) -->
<el-dialog :title="applyModalTitle" :visible.sync="showApplyModal" width="770px" top="1vh"
:before-close="beforeCloseApplyModal" :close-on-click-modal="false">
<el-form class="apply-form" :inline="true" label-position="top" :model="applyForm"
style="margin-left:7px; margin-top:-5px; font-size: 0;">
<!-- 第1行:两个下拉各占两档 -->
<el-form-item label="客户名称" required class="two-item">
<el-select filterable v-model="applyForm.customerId" placeholder="请选择" size="small"
style="font-size:12px; height:30px" :disabled="formDisabled || isEditApply"
@change="customerChange" @visible-change="customerDropdownVisible">
<el-option :label="item.customerName" :value="item.id"
v-for="(item,index) in customerListOptions" :key="index"></el-option>
</el-select>
</el-form-item>
<el-form-item label="公司名称" required class="two-item">
<el-select filterable v-model="applyForm.billingInfoId" placeholder="请选择" size="small"
style="font-size:12px; height:30px" :disabled="formDisabled || isEditApply" @change="billingChange">
<el-option :label="item.billingCompanyName" :value="item.id"
v-for="(item,index) in companyNameOptions" :key="index"></el-option>
</el-select>
</el-form-item>
<!-- 第2行:四个一档 -->
<el-form-item label="开票项目" required>
<el-select v-model="applyForm.billingProject" placeholder="请选择" size="small"
style="font-size:12px; height:30px" :disabled="formDisabled">
<el-option :label="item.dataValue" :value="item.dataValue"
v-for="(item,index) in billingProjectOptions" :key="index"></el-option>
</el-select>
</el-form-item>
<el-form-item label="项目名称" >
<el-input v-model="applyForm.projectName" size="small" placeholder="手工录入"
style="font-size:12px; height:30px" :disabled="formDisabled"></el-input>
</el-form-item>
<el-form-item label="税率" required>
<el-select v-model="applyForm.billingRate" size="small" style="font-size:12px; height:30px" :disabled="formDisabled">
<el-option label="6" value="0.06"></el-option>
<el-option label="13" value="0.13"></el-option>
</el-select>
</el-form-item>
<el-form-item label="开票金额" required>
<el-input v-model="applyForm.amount" size="small" :disabled="formDisabled"
style="font-size:12px; height:30px; text-align:right" @change="onAmountChange"></el-input>
</el-form-item>
<!-- 第3行:寄送方式(带...按钮,两档) + 收件人 + 收件人电话 -->
<el-form-item label="寄送方式" class="ship-item">
<el-select v-model="applyForm.shipMethod" placeholder="请选择" size="small"
style="font-size:12px; height:30px" :disabled="formDisabled">
<el-option :label="item.dataValue" :value="item.dataValue"
v-for="(item,index) in sendMethodOptions" :key="index"></el-option>
</el-select>
<!-- 老 #expressButton1:只有寄送方式=快递才可点,用来选联系人 -->
<el-button class="person-btn" size="small" :disabled="formDisabled || applyForm.shipMethod !== '快递'"
@click="openPersonDialog">...</el-button>
</el-form-item>
<el-form-item label="收件人" >
<el-input v-model="applyForm.receiver" size="small"
style="font-size:12px; height:30px" :disabled="formDisabled"></el-input>
</el-form-item>
<el-form-item label="收件人电话" >
<el-input v-model="applyForm.receiverPhone" size="small"
style="font-size:12px; height:30px" :disabled="formDisabled"></el-input>
</el-form-item>
<!-- 收件人地址 / 备注:照抄发票页的裸 div,一档四格 708 -->
<div style="width: 708px; margin-bottom: 1px;">
<div style="font-size: 12px; line-height: 20px; color: #606266; margin-bottom: 2px;">收件人地址</div>
<el-input v-model="applyForm.receiverAddr" size="small" :disabled="formDisabled" style="font-size: 12px;"></el-input>
</div>
<div style="width: 708px; margin-bottom: 10px;">
<div style="font-size: 12px; line-height: 20px; color: #606266; margin-bottom: 2px;">备注</div>
<el-input v-model="applyForm.remark" type="textarea" :rows="1" :disabled="formDisabled" style="font-size: 12px;"></el-input>
</div>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="closeApplyModal">取消</el-button>
<el-button v-if="!detailMode" type="primary" @click="saveApply">保存</el-button>
</div>
</el-dialog>
<!-- 联系人:老 #apply_person_page。12 列一字不少;点"选择"只回填收件人+电话,地址不回填(老 getExpressName 就这样) -->
<el-dialog title="联系人信息" :visible.sync="showPersonModal" width="1100px" top="1vh"
append-to-body :close-on-click-modal="false" @close="closePersonDialog">
<el-table :data="personList" border :height="personHeight" style="font-size:10px; width:100%;">
<el-table-column prop="personName" header-align="center" align="left" label="姓名" min-width="80"></el-table-column>
<el-table-column prop="jobTitle" header-align="center" align="left" label="职位" min-width="90"></el-table-column>
<el-table-column prop="phoneNo1" header-align="center" align="center" label="联系电话1" min-width="110"></el-table-column>
<el-table-column prop="phoneNo2" header-align="center" align="center" label="联系电话2" min-width="110"></el-table-column>
<el-table-column prop="phoneNo3" header-align="center" align="center" label="联系电话3" min-width="110"></el-table-column>
<el-table-column prop="emailAddress" header-align="center" align="left" label="邮箱" min-width="150"></el-table-column>
<el-table-column prop="remark" header-align="center" align="left" label="备注" min-width="120"></el-table-column>
<el-table-column prop="defaultExpress" header-align="center" align="center" label="快递默认" min-width="80">
<template slot-scope="scope">{{ yn(scope.row.defaultExpress) }}</template>
</el-table-column>
<el-table-column prop="active" header-align="center" align="center" label="在用" min-width="60">
<template slot-scope="scope">{{ yn(scope.row.active) }}</template>
</el-table-column>
<el-table-column prop="enteredDate" header-align="center" align="center" label="录入时间" min-width="100">
<template slot-scope="scope">{{ d10dash(scope.row.enteredDate) }}</template>
</el-table-column>
<el-table-column prop="inactiveDate" header-align="center" align="center" label="停用时间" min-width="100">
<template slot-scope="scope">{{ d10dash(scope.row.inactiveDate) }}</template>
</el-table-column>
<el-table-column label="操作" header-align="center" align="center" fixed="right" width="70">
<template slot-scope="scope">
<a type="text" size="mini" @click="choosePerson(scope.row)">选择</a>
</template>
</el-table-column>
</el-table>
<div slot="footer" class="dialog-footer">
<el-button @click="showPersonModal = false">关闭</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
billingApplyData, billingApplySave, billingApplyDelete,
applyValueList, applyCompanyName, getCustomerList, fetchPersonData
} from '@/api/billing/billing.js'
export default {
name: 'billing-request',
data() {
return {
height: 600,
personHeight: 400,
// 四个查询参数名必须和 BillingApplyEntity 的 transient 字段一字不差
searchData: {
customerId: null,
startDate: '',
dateClosed: '',
status: '',
billingProject: '',
page: 1,
limit: 20
},
applyList: [],
pageIndex: 1,
pageSize: 20,
totalPage: 0,
sortField: '',
sortOrder: '',
showApplyModal: false,
isEditApply: false,
detailMode: false,
showPersonModal: false,
personList: [],
customerListOptions: [],
companyNameOptions: [],
sendMethodOptions: [],
billingProjectOptions: [],
applyForm: this.blankApplyForm()
}
},
computed: {
applyModalTitle() {
if (this.detailMode) return '开票申请详情'
return this.isEditApply ? '编辑开票申请' : '新增开票申请'
},
formDisabled() {
return this.detailMode
}
},
mounted() {
this.$nextTick(() => {
this.height = window.innerHeight - 210
})
},
activated() {
this.initData()
},
methods: {
// 老表单 kn_point_form 实际带的 name 就这几个:id/customerId/billingInfoId/billingProject/
// projectName/billingRate/amount/shipMethod/receiver/receiverPhone/receiverAddr/remark。
// status、enteredDate 都不在表单里 → 这里也不带;projectId 恒 0 是老 OutData 那个原始 int 的效果
blankApplyForm() {
return {
id: null,
projectId: 0,
customerId: null,
billingInfoId: null,
billingProject: '',
projectName: '',
billingRate: '0.06',
amount: '0',
shipMethod: '',
receiver: '',
receiverPhone: '',
receiverAddr: '',
remark: ''
}
},
d10(v) {
return v ? String(v).substring(0, 10) : ''
},
d10dash(v) {
return this.d10(v) || '-'
},
yn(v) {
if (v === 'Y') return '是'
if (v === 'N') return '否'
return ''
},
statusText(v) {
if (v === 'Y') return '是'
if (v === 'N') return '否'
return ''
},
// 老列表 formatter:value=='0.06' → '6',否则 '13'
rateText(v) {
if (v == null || v === '') return ''
return Number(v) === 0.06 ? '6' : '13'
},
initData() {
this.fetchApplyList()
this.fetchCustomerOptions()
// IT=开票项目 SW=寄送方式(老 InitprojectName:229 / InitsendWay:308 写死的两个 type)
applyValueList('IT').then(({data}) => {
if (data && data.code === 0) this.billingProjectOptions = data.list
}).catch(err => { console.error(err) })
applyValueList('SW').then(({data}) => {
if (data && data.code === 0) this.sendMethodOptions = data.list
}).catch(err => { console.error(err) })
},
fetchApplyList() {
this.searchData.page = this.pageIndex
this.searchData.limit = this.pageSize
this.searchData.sidx = this.sortField
this.searchData.order = this.sortOrder
billingApplyData(this.searchData).then(({data}) => {
if (data.code === 0) {
this.applyList = data.page.list
this.totalPage = data.page.totalCount
} else {
this.applyList = []
this.totalPage = 0
}
}).catch(err => { console.error(err) })
},
searchApply() {
if (this.searchData.startDate && this.searchData.dateClosed
&& this.searchData.startDate > this.searchData.dateClosed) {
this.$message.warning('开始日期不能晚于结束日期')
return
}
this.pageIndex = 1
this.fetchApplyList()
},
resetSearch() {
this.searchData = { customerId: null, startDate: '', dateClosed: '', status: '', billingProject: '', page: 1, limit: this.pageSize }
this.pageIndex = 1
this.fetchApplyList()
},
sizeChangeHandle(val) {
this.pageSize = val
this.pageIndex = 1
this.fetchApplyList()
},
currentChangeHandle(val) {
this.pageIndex = val
this.fetchApplyList()
},
// 列头排序走后端,形状照抄 contract/info.vue:537
handleSortChange({ prop, order }) {
this.sortField = order ? prop : ''
this.sortOrder = order === 'ascending' ? 'asc' : order === 'descending' ? 'desc' : ''
this.pageIndex = 1
this.fetchApplyList()
},
fetchCustomerOptions() {
getCustomerList().then(({data}) => {
if (data && data.code === 0) this.customerListOptions = data.rows
}).catch(err => { console.error(err) })
},
customerDropdownVisible(visible) {
if (visible && !this.isEditApply) this.fetchCustomerOptions()
},
// 老 #customerName change → /billingApply/findCompanyName 重灌公司下拉
customerChange(customerId) {
this.applyForm.billingInfoId = null
this.companyNameOptions = []
if (customerId) this.fetchCompanyNameOptions(customerId)
},
fetchCompanyNameOptions(customerId) {
applyCompanyName(customerId).then(({data}) => {
if (data && data.code === 0) this.companyNameOptions = data.list
}).catch(err => { console.error(err) })
},
// 老 #billingInfoId change(billingApply.js:650-660)回填收件人/电话/地址。
// 注意电话取的是 phoneNo(经手人电话),不是 receiverPhone —— 老代码就是这么写的
billingChange(billingInfoId) {
let hit = this.companyNameOptions.filter(item => item.id === billingInfoId)[0]
if (!hit) return
this.applyForm.receiver = hit.receiver
this.applyForm.receiverPhone = hit.phoneNo
this.applyForm.receiverAddr = hit.receiverAddr
},
openAddApplyModal() {
this.detailMode = false
this.isEditApply = false
this.companyNameOptions = []
this.applyForm = this.blankApplyForm()
this.showApplyModal = true
},
editApply(row, isDetail) {
// 老 editPayment:452 前端拦已开票;但老"详情"走独立的 details(),没有这道拦截,
// 已开票的行必须能看详情,所以这道守卫只在编辑时生效
if (!isDetail && row.status === 'Y') {
this.$message.error('已开票,无法编辑!')
return
}
this.detailMode = false
this.isEditApply = true
this.applyForm = this.blankApplyForm()
this.applyForm.id = row.id
this.applyForm.customerId = row.customerId
this.applyForm.projectName = row.projectName
this.applyForm.billingInfoId = row.billingInfoId
this.applyForm.shipMethod = row.shipMethod
this.applyForm.billingProject = row.billingProject
if (row.billingRate != null) this.applyForm.billingRate = String(row.billingRate)
this.applyForm.amount = row.amount == null ? '' : String(row.amount)
this.applyForm.receiver = row.receiver
this.applyForm.receiverPhone = row.receiverPhone
this.applyForm.receiverAddr = row.receiverAddr
this.applyForm.remark = row.remark
if (row.customerId) this.fetchCompanyNameOptions(row.customerId)
this.showApplyModal = true
},
openDetail(row) {
this.editApply(row, true)
this.detailMode = true
},
// 老 #amount change:parseInt 为 NaN 就提示并归 0
onAmountChange(val) {
if (isNaN(parseInt(val))) {
this.$message.error('请输入正确的金额!')
this.applyForm.amount = '0'
}
},
// 老 knPointSave:488-503 只有这四条校验,顺序也按它
validateApply() {
let f = this.applyForm
if (!f.customerId) { this.$message.error('请选择客户名称!'); return false }
if (!f.billingInfoId) { this.$message.error('请选择公司名称!'); return false }
if (!f.billingProject) { this.$message.error('请输入开票项目!'); return false }
if (f.amount === '' || f.amount == null || Number(f.amount) === 0) {
this.$message.error('请输入开票金额!'); return false
}
return true
},
saveApply() {
if (!this.validateApply()) return
let inData = Object.assign({}, this.applyForm)
inData.amount = Number(inData.amount)
inData.billingRate = Number(inData.billingRate)
inData.projectName = (inData.projectName || '').trim()
billingApplySave(inData).then(({data}) => {
if (data && data.code === 0) {
this.$message.success(data.msg || '保存成功')
this.showApplyModal = false
this.fetchApplyList()
} else {
this.$message.error((data && data.msg) || '保存失败')
}
}).catch(err => {
console.error(err)
this.$message.error('保存失败')
})
},
beforeCloseApplyModal(done) {
this.closeApplyModal()
done()
},
closeApplyModal() {
this.showApplyModal = false
this.isEditApply = false
this.detailMode = false
this.companyNameOptions = []
this.applyForm = this.blankApplyForm()
this.fetchApplyList()
},
deleteApply(row) {
// 老 delKnPoint:551 同样是前端拦
if (row.status === 'Y') {
this.$message.error('已开票,无法删除!')
return
}
this.$confirm('确定要删除选中的记录吗?', '提示', { type: 'warning' }).then(() => {
billingApplyDelete({ id: row.id }).then(({data}) => {
if (data && data.code === 0) {
// 后端挂着发票时返回的是"无法删除!"这句提示,不是错误码
this.$message.success(data.msg || '删除成功')
this.fetchApplyList()
} else {
this.$message.error((data && data.msg) || '删除失败')
}
}).catch(err => {
console.error(err)
this.$message.error('删除失败')
})
}).catch(() => {})
},
// 老 expressSelect():先清收件人和电话,再开弹窗
openPersonDialog() {
this.applyForm.receiver = ''
this.applyForm.receiverPhone = ''
this.personHeight = Math.min(400, window.innerHeight - 340)
this.fetchPersonList()
this.showPersonModal = true
},
fetchPersonList() {
if (!this.applyForm.customerId) {
this.personList = []
return
}
fetchPersonData(this.applyForm.customerId).then(({data}) => {
if (data && data.code === 0) this.personList = data.list
else this.personList = []
}).catch(err => { console.error(err) })
},
// 老 getExpressName(row):只回填姓名和电话1,地址不动
choosePerson(row) {
this.applyForm.receiver = row.personName
this.applyForm.receiverPhone = row.phoneNo1
this.showPersonModal = false
},
closePersonDialog() {
this.personList = []
}
}
}
</script>
<style>
.billing-apply {
margin-top: 10px;
}
.billing-apply .el-input__prefix {
top: 50%;
transform: translateY(-50%);
font-size: 14px;
height: auto;
line-height: 1;
}
.billing-apply .el-date-editor .el-input__inner {
padding-left: 28px;
}
.billing-apply .el-input__suffix {
top: 50%;
transform: translateY(-50%);
height: auto;
}
.billing-apply > .el-form--inline .el-form-item {
margin-bottom: 10px;
vertical-align: middle;
}
.billing-apply .el-dialog .el-form-item__label {
font-size: 12px;
line-height: 20px;
margin-bottom: 2px;
}
/* ===== 开票信息弹窗:一档 180(控件 170 + 列间距 10),一行四个,和发票页同尺寸 ===== */
.billing-apply .el-dialog .apply-form .el-form-item {
width: 180px;
margin-right: 0;
margin-bottom: 1px;
}
.billing-apply .el-dialog .apply-form .el-form-item .el-input,
.billing-apply .el-dialog .apply-form .el-form-item .el-select {
width: 170px !important;
}
/* 两档:客户名称 / 公司名称(el-select 里层的 .el-input 要一起放开,否则被上面 170 压死) */
.billing-apply .el-dialog .apply-form .el-form-item.two-item {
width: 360px;
}
.billing-apply .el-dialog .apply-form .el-form-item.two-item .el-select,
.billing-apply .el-dialog .apply-form .el-form-item.two-item .el-input {
width: 351px !important;
}
/* 寄送方式 + ... 按钮:两档 360 = 下拉 268 + 缝 6 + 按钮 80 */
.billing-apply .el-dialog .apply-form .el-form-item.ship-item {
width: 360px;
}
.billing-apply .el-dialog .apply-form .el-form-item.ship-item .el-select,
.billing-apply .el-dialog .apply-form .el-form-item.ship-item .el-input {
width: 268px !important;
}
.billing-apply .el-dialog .apply-form .el-form-item.ship-item .person-btn {
width: 77px;
margin-left: 1px;
padding: 4px 0;
font-size: 12px;
}
/* 详情态:把禁用的控件字色压暗,和发票页一致 */
.billing-apply .el-dialog .apply-form .el-input.is-disabled .el-input__inner,
.billing-apply .el-dialog .apply-form .el-textarea.is-disabled .el-textarea__inner {
color: #a8abb2;
}
/* 备注 textarea 必须自带字号:form 上有 font-size:0(抹 inline-block 换行空格用的),
.el-textarea__inner 是 font-size:inherit,不补字就是 0px */
.billing-apply .el-dialog .apply-form .el-textarea__inner {
font-size: 12px;
}
/* 操作列 fixed 克隆层没底色会重影(和 contract / 发票同一主题坑) */
.billing-apply .el-table__fixed-right,
.billing-apply .el-table__fixed-right .el-table__fixed-header-wrapper,
.billing-apply .el-table__fixed-right .el-table__fixed-body-wrapper {
background-color: #fff;
}
/* 操作列三个槽:3×35 + .cell 内边距 10 = 115。font-size:0 抹掉 inline-block 换行空格,
否则实占超 115,最后一个"删除"会被 .cell 的 overflow:hidden 裁掉 */
.billing-apply td.op-col .cell {
font-size: 0;
}
.billing-apply td.op-col .cell > a {
display: inline-block;
width: 35px;
text-align: center;
font-size: 12px;
}
/* 排序箭头:global.scss:77 已把 caret-wrapper 压到 20px,只能在 20px 里排布。
数字照抄 contract/info.vue:1299,表头盒高两页一致所以不用重调 */
.billing-apply .el-table .sort-caret {
border-width: 6px;
left: 6px;
}
.billing-apply .el-table .sort-caret.ascending {
top: -4px;
bottom: auto;
}
.billing-apply .el-table .sort-caret.descending {
top: 8px;
bottom: auto;
}
/* 排序列的表头 .cell 被 global.scss:36 写死成 14px,装不下 :77 那个 20px 的 caret-wrapper,
行盒撑高后下半截被 overflow:hidden 裁掉 → 文字看着下沉。只加高 is-sortable 的表头,箭头规则不动 */
.billing-apply .el-table th.is-sortable > .cell {
height: 20px;
line-height: 20px;
}
</style>

527
src/views/modules/finance/billing-invoice.vue

@ -0,0 +1,527 @@
<template>
<div class="billing-invoice">
<el-form inline>
<!-- 老页面这个框标"公司名称",过滤的却是 customer_name,和开票申请页同一个坑 -->
<el-form-item label="客户名称">
<el-select filterable v-model="searchData.customerId" clearable size="small" placeholder="全部"
style="width: 200px;margin-top: 2px">
<el-option :label="item.customerName" :value="item.id"
v-for="(item,index) in customerListOptions" :key="index"></el-option>
</el-select>
</el-form-item>
<el-form-item label="申请日期">
<el-date-picker v-model="searchData.startDate" type="date" format="yyyy-MM-dd"
value-format="yyyy-MM-dd" placeholder="开始日期" size="small"
style="width: 110px;margin-top: 2px"></el-date-picker>
<span style="margin: 0 4px;">~</span>
<el-date-picker v-model="searchData.dateClosed" type="date" format="yyyy-MM-dd"
value-format="yyyy-MM-dd" placeholder="结束日期" size="small"
style="width: 110px;margin-top: 2px"></el-date-picker>
</el-form-item>
<el-form-item label="是否开票">
<!-- 老 knPointTableInit:17 进页面把 #searchStatus 写死 "N",所以默认只看待开票的 -->
<el-select v-model="searchData.status" clearable size="small" placeholder="全部"
style="width: 90px;margin-top: 2px">
<el-option label="是" value="Y"></el-option>
<el-option label="否" value="N"></el-option>
</el-select>
</el-form-item>
<el-form-item label="开票项目">
<el-select v-model="searchData.billingProject" clearable size="small" placeholder="全部"
style="width: 140px;margin-top: 2px">
<el-option :label="item.dataValue" :value="item.dataValue"
v-for="(item,index) in billingProjectOptions" :key="index"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button @click="searchApply" style="margin-top: 2px">查询</el-button>
<el-button @click="resetSearch" style="margin-left: 10px;">重置</el-button>
</el-form-item>
</el-form>
<el-table :data="applyList" border :height="height" style="width: 100%;" @sort-change="handleSortChange">
<el-table-column prop="customerName" header-align="center" align="left" min-width="200" label="客户名称" show-overflow-tooltip></el-table-column>
<el-table-column prop="billingCompanyName" header-align="center" align="left" min-width="180" label="公司名称" show-overflow-tooltip></el-table-column>
<el-table-column prop="billingProject" header-align="center" align="center" min-width="100" label="开票项目" show-overflow-tooltip></el-table-column>
<el-table-column prop="projectName" header-align="center" align="left" min-width="180" label="项目名称" show-overflow-tooltip></el-table-column>
<el-table-column prop="billingRate" header-align="center" align="center" min-width="70" label="税率">
<template slot-scope="scope">{{ rateText(scope.row.billingRate) }}</template>
</el-table-column>
<el-table-column prop="amount" header-align="center" align="right" min-width="100" sortable="custom" label="开票金额"></el-table-column>
<el-table-column prop="enteredBy" header-align="center" align="center" min-width="90" label="申请人" show-overflow-tooltip></el-table-column>
<el-table-column prop="enteredDate" header-align="center" align="center" min-width="100" sortable="custom" label="申请时间">
<template slot-scope="scope">{{ d10(scope.row.enteredDate) }}</template>
</el-table-column>
<el-table-column prop="status" header-align="center" align="center" min-width="80" label="是否开票">
<template slot-scope="scope">{{ statusText(scope.row.status) }}</template>
</el-table-column>
<!-- 这一列是这页比开票申请页多出来的一列(老 billingApplyInfo.js:109) -->
<el-table-column prop="remark" header-align="center" align="left" min-width="150" label="备注" show-overflow-tooltip></el-table-column>
<el-table-column fixed="right" header-align="center" align="right" class-name="op-col" width="45" label="操作">
<template slot-scope="scope">
<a type="text" size="small" @click="openInvoiceDialog(scope.row)">开票</a>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[20, 50, 100, 200, 500]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
<!-- 发票信息:老 #invo_modal。隐藏域 projectId/customerId/billingApplyId/billingInfoId
在这里不画控件,直接进 invoiceForm 对象,序列化时跟着走 -->
<el-dialog title="发票信息" :visible.sync="showInvoiceModal" width="770px" top="1vh"
:before-close="beforeCloseModal" :close-on-click-modal="false">
<el-form class="invoice-form" :inline="true" label-position="top" :model="invoiceForm"
style="margin-left:7px; margin-top:-5px; font-size: 0;">
<!-- 第1行:三个只读展示 + 项目名称(老页面这三个框就是 readonly 的 input) -->
<el-form-item label="客户名称" required>
<el-input v-model="invoiceForm.customerName" size="small" readonly
style="font-size:12px; height:30px"></el-input>
</el-form-item>
<el-form-item label="公司名称" required>
<el-input v-model="invoiceForm.companyName" size="small" readonly
style="font-size:12px; height:30px"></el-input>
</el-form-item>
<el-form-item label="开票项目" required>
<el-input v-model="invoiceForm.invoiceItem" size="small" readonly
style="font-size:12px; height:30px"></el-input>
</el-form-item>
<el-form-item label="项目名称" >
<el-input v-model="invoiceForm.projectName" size="small"
style="font-size:12px; height:30px"></el-input>
</el-form-item>
<!-- 第2行 -->
<el-form-item label="开票日期" required>
<el-date-picker v-model="invoiceForm.invoiceDate" type="date" format="yyyy-MM-dd"
value-format="yyyy-MM-dd" size="small" :prefix-icon="''"></el-date-picker>
</el-form-item>
<el-form-item label="发票号码" required>
<el-input v-model="invoiceForm.invoiceNo" size="small"
style="font-size:12px; height:30px"></el-input>
</el-form-item>
<el-form-item label="开票金额" required>
<el-input v-model="invoiceForm.invoiceAmount" size="small"
style="font-size:12px; height:30px; text-align:right" @input="onAmountInput"></el-input>
</el-form-item>
<el-form-item label="税率" required>
<el-select v-model="invoiceForm.taxRate" size="small" style="font-size:12px; height:30px" @change="calcUntaxed">
<el-option label="6" value="0.06"></el-option>
<el-option label="13" value="0.13"></el-option>
</el-select>
</el-form-item>
<!-- 第3行 -->
<el-form-item label="未税金额">
<el-input v-model="invoiceForm.untaxedAmount" size="small" readonly
class="untaxed-input"
style="font-size:12px; height:30px; color:#FF0033; text-align:right"></el-input>
</el-form-item>
<el-form-item label="税号" >
<el-input v-model="invoiceForm.taxNo" size="small"
style="font-size:12px; height:30px"></el-input>
</el-form-item>
<el-form-item label="开票人">
<!-- 老 invodeta 没给 #receiver 赋过值,所以这里和老系统一样是空的,要手填 -->
<el-input v-model="invoiceForm.receiver" size="small"
style="font-size:12px; height:30px"></el-input>
</el-form-item>
<el-form-item label="寄送方式">
<el-select v-model="invoiceForm.sendMethod" placeholder="请选择" size="small"
style="font-size:12px; height:30px">
<el-option :label="item.dataValue" :value="item.dataValue"
v-for="(item,index) in sendMethodOptions" :key="index"></el-option>
</el-select>
</el-form-item>
<!-- 第4行 -->
<el-form-item label="寄送日期" >
<el-date-picker v-model="invoiceForm.sendDate" type="date" format="yyyy-MM-dd"
value-format="yyyy-MM-dd" size="small" :prefix-icon="''"></el-date-picker>
</el-form-item>
<el-form-item label="收票人姓名" >
<el-input v-model="invoiceForm.custReceiver" size="small"
style="font-size:12px; height:30px"></el-input>
</el-form-item>
<el-form-item label="收票人电话" >
<el-input v-model="invoiceForm.custReceiverPhone" size="small"
style="font-size:12px; height:30px"></el-input>
</el-form-item>
<el-form-item label="预计收款日期" required>
<el-date-picker v-model="invoiceForm.planPayDate" type="date" format="yyyy-MM-dd"
value-format="yyyy-MM-dd" size="small" :prefix-icon="''"></el-date-picker>
</el-form-item>
<!-- 寄送地址 / 备注:老页面这两个是通栏的,照发票页的裸 div 写法 -->
<div style="width: 708px; margin-bottom: 1px;">
<div style="font-size: 12px; line-height: 20px; color: #606266; margin-bottom: 2px;">寄送地址</div>
<el-input v-model="invoiceForm.sendAddr" size="small" style="font-size: 12px;"></el-input>
</div>
<div style="width: 708px; margin-bottom: 10px;">
<div style="font-size: 12px; line-height: 20px; color: #606266; margin-bottom: 2px;">备注</div>
<el-input v-model="invoiceForm.remark" type="textarea" :rows="1" style="font-size: 12px;"></el-input>
</div>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="closeModal">取消</el-button>
<el-button type="primary" @click="saveInvoice">保存</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
billingApplyData, applyValueList, getCustomerList,
findBillingByBillingId, applyInvoiceSave
} from '@/api/billing/billing.js'
export default {
name: 'billing-invoice',
data() {
return {
height: 600,
searchData: {
customerId: null,
startDate: '',
dateClosed: '',
status: 'N',
billingProject: '',
page: 1,
limit: 20
},
applyList: [],
pageIndex: 1,
pageSize: 20,
totalPage: 0,
sortField: '',
sortOrder: '',
showInvoiceModal: false,
sendMethodOptions: [],
billingProjectOptions: [],
customerListOptions: [],
invoiceForm: this.blankInvoiceForm()
}
},
mounted() {
this.$nextTick(() => {
this.height = window.innerHeight - 210
})
},
created() {
// 老 InitsendWay() 里的 type=SW,复用 /invoice/valueList
applyValueList('SW').then(({data}) => {
if (data && data.code === 0) this.sendMethodOptions = data.list
}).catch(err => { console.error(err) })
// IT=开票项目,和开票申请页同一个字典,查询框和弹窗共用一个数组
applyValueList('IT').then(({data}) => {
if (data && data.code === 0) this.billingProjectOptions = data.list
}).catch(err => { console.error(err) })
// 查询区客户下拉要用,和开票申请页同一个接口
this.fetchCustomerOptions()
},
activated() {
this.fetchApplyList()
},
methods: {
fetchCustomerOptions() {
getCustomerList().then(({data}) => {
if (data && data.code === 0) this.customerListOptions = data.rows
}).catch(err => { console.error(err) })
},
// 字段名一律用 InvoiceEntity 上的名字:customerName / companyName 是它的 transient 字段
// (第 101/104 行),只展示不落库,和老页面那两个 readonly 框对应
blankInvoiceForm() {
return {
id: null,
projectId: 0,
customerId: null,
billingInfoId: null,
billingApplyId: null,
customerName: '',
companyName: '',
invoiceItem: '',
projectName: '',
invoiceDate: '',
invoiceNo: '',
invoiceAmount: '',
taxRate: '0.06',
untaxedAmount: '',
taxNo: '',
receiver: '',
sendMethod: '',
sendDate: '',
custReceiver: '',
custReceiverPhone: '',
sendAddr: '',
planPayDate: '',
remark: ''
}
},
today() {
let d = new Date()
let pad = n => n < 10 ? '0' + n : n
return d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate())
},
d10(v) {
return v ? String(v).substring(0, 10) : ''
},
statusText(v) {
if (v === 'Y') return '是'
if (v === 'N') return '否'
return ''
},
rateText(v) {
if (v == null || v === '') return ''
return Number(v) === 0.06 ? '6' : '13'
},
fetchApplyList() {
this.searchData.page = this.pageIndex
this.searchData.limit = this.pageSize
this.searchData.sidx = this.sortField
this.searchData.order = this.sortOrder
billingApplyData(this.searchData).then(({data}) => {
if (data.code === 0) {
this.applyList = data.page.list
this.totalPage = data.page.totalCount
} else {
this.applyList = []
this.totalPage = 0
}
}).catch(err => { console.error(err) })
},
searchApply() {
if (this.searchData.startDate && this.searchData.dateClosed
&& this.searchData.startDate > this.searchData.dateClosed) {
this.$message.warning('开始日期不能晚于结束日期')
return
}
this.pageIndex = 1
this.fetchApplyList()
},
resetSearch() {
// 重置回本页默认:是否开票仍然是"否",不是"全部"
this.searchData = { customerId: null, startDate: '', dateClosed: '', status: 'N', billingProject: '', page: 1, limit: this.pageSize }
this.pageIndex = 1
this.fetchApplyList()
},
sizeChangeHandle(val) {
this.pageSize = val
this.pageIndex = 1
this.fetchApplyList()
},
currentChangeHandle(val) {
this.pageIndex = val
this.fetchApplyList()
},
// 列头排序走后端,形状照抄 contract/info.vue:537
handleSortChange({ prop, order }) {
this.sortField = order ? prop : ''
this.sortOrder = order === 'ascending' ? 'asc' : order === 'descending' ? 'desc' : ''
this.pageIndex = 1
this.fetchApplyList()
},
// 老 invodeta(row):billingApplyInfo.js:135-171,逐行对应
openInvoiceDialog(row) {
this.invoiceForm = this.blankInvoiceForm()
this.invoiceForm.billingApplyId = row.id
this.invoiceForm.billingInfoId = row.billingInfoId
this.invoiceForm.companyName = row.billingCompanyName
this.invoiceForm.projectName = row.projectName
this.invoiceForm.invoiceAmount = row.amount == null ? '' : String(row.amount)
this.invoiceForm.invoiceItem = row.billingProject
this.invoiceForm.sendMethod = row.shipMethod
this.invoiceForm.customerName = row.customerName
this.invoiceForm.custReceiver = row.receiver
this.invoiceForm.custReceiverPhone = row.receiverPhone
this.invoiceForm.sendAddr = row.receiverAddr
if (row.billingRate != null) this.invoiceForm.taxRate = String(row.billingRate)
// 老代码紧接着 $("#invoiceAmount").change() 把未税金额算出来
this.calcUntaxed()
// 老 InfoDates("invoiceDate"/"sendDate"/"planPayDate"):三个日期都填今天
this.invoiceForm.invoiceDate = this.today()
this.invoiceForm.sendDate = this.today()
this.invoiceForm.planPayDate = this.today()
this.showInvoiceModal = true
this.fetchTaxNo(row.billingInfoId)
},
// 老页面这段 ajax 是 async:false,税号/客户id 是它回填的,表单里根本没有客户选择控件
fetchTaxNo(billingInfoId) {
if (!billingInfoId) return
findBillingByBillingId(billingInfoId).then(({data}) => {
if (data && data.code === 0 && data.list && data.list.length) {
this.invoiceForm.taxNo = data.list[0].taxNo
this.invoiceForm.customerId = data.list[0].customerId
this.invoiceForm.customerName = data.list[0].customerName
}
}).catch(err => { console.error(err) })
},
onAmountInput(val) {
this.invoiceForm.invoiceAmount = this.moneyFilter(val)
this.calcUntaxed()
},
moneyFilter(value) {
let filtered = String(value == null ? '' : value).replace(/[^\d.]/g, '')
if (filtered.startsWith('.')) filtered = '0' + filtered
let dotIndex = filtered.indexOf('.')
if (dotIndex !== -1) {
filtered = filtered.substring(0, dotIndex + 1) + filtered.substring(dotIndex + 1).replace(/\./g, '')
}
return filtered
},
calcUntaxed() {
let amount = Number(this.invoiceForm.invoiceAmount)
if (this.invoiceForm.invoiceAmount === '' || isNaN(amount)) return
this.invoiceForm.untaxedAmount = (amount / (1 + parseFloat(this.invoiceForm.taxRate))).toFixed(2)
},
// 老 invoiceSave():billingApplyInfo.js:236-251 只有这四条
validateInvoice() {
let f = this.invoiceForm
if (!f.invoiceDate) { this.$message.error('请输入开票日期!'); return false }
if (!f.invoiceNo) { this.$message.error('请输入发票号码!'); return false }
if (f.invoiceAmount === '' || f.invoiceAmount == null) { this.$message.error('请输入开票金额!'); return false }
if (!f.planPayDate) { this.$message.error('请输入预计收款日期!'); return false }
return true
},
saveInvoice() {
if (!this.validateInvoice()) return
let inData = Object.assign({}, this.invoiceForm)
inData.invoiceAmount = Number(inData.invoiceAmount)
inData.untaxedAmount = Number(inData.untaxedAmount)
inData.taxRate = Number(inData.taxRate)
inData.projectName = (inData.projectName || '').trim()
inData.invoiceNo = (inData.invoiceNo || '').trim()
// 实体是 @JsonFormat("yyyy-MM-dd HH:mm:ss"),只给日期后端解析不了
if (inData.invoiceDate) inData.invoiceDate = inData.invoiceDate + ' 00:00:00'
if (inData.sendDate) inData.sendDate = inData.sendDate + ' 00:00:00'
if (inData.planPayDate) inData.planPayDate = inData.planPayDate + ' 00:00:00'
applyInvoiceSave(inData).then(({data}) => {
if (data && data.code === 0) {
this.$message.success(data.msg || '保存成功')
this.showInvoiceModal = false
this.fetchApplyList()
} else {
this.$message.error((data && data.msg) || '开票失败')
}
}).catch(err => {
console.error(err)
this.$message.error('开票失败')
})
},
beforeCloseModal(done) {
this.closeModal()
done()
},
closeModal() {
this.showInvoiceModal = false
this.invoiceForm = this.blankInvoiceForm()
this.fetchApplyList()
}
}
}
</script>
<style>
.billing-invoice {
margin-top: 10px;
}
.billing-invoice .el-input__prefix {
top: 50%;
transform: translateY(-50%);
font-size: 14px;
height: auto;
line-height: 1;
}
.billing-invoice .el-date-editor .el-input__inner {
padding-left: 28px;
}
.billing-invoice .el-input__suffix {
top: 50%;
transform: translateY(-50%);
height: auto;
}
.billing-invoice > .el-form--inline .el-form-item {
margin-bottom: 10px;
vertical-align: middle;
}
.billing-invoice .el-dialog .el-form-item__label {
font-size: 12px;
line-height: 20px;
margin-bottom: 2px;
}
/* 弹窗栅格:一档 180(控件 170 + 列间距 10),一行四个,和发票页/开票申请页同尺寸 */
.billing-invoice .el-dialog .invoice-form .el-form-item {
width: 180px;
margin-right: 0;
margin-bottom: 1px;
}
.billing-invoice .el-dialog .invoice-form .el-form-item .el-input,
.billing-invoice .el-dialog .invoice-form .el-form-item .el-select {
width: 170px !important;
}
/* 备注 textarea 必须自带字号:form 上有 font-size:0,.el-textarea__inner 是 font-size:inherit */
.billing-invoice .el-dialog .invoice-form .el-textarea__inner {
font-size: 12px;
}
/* 只读展示框标灰:客户名称/公司名称/开票项目/未税金额。
必须限定 .el-form-item__content 的直接子级 .el-input:
el-select 的内层 input 自带 readonly(2.8.2 select.vue:80),那样会误伤下拉框;
再排掉 .el-date-editor 以防日期框哪天带上 readonly */
.billing-invoice .el-dialog .invoice-form .el-form-item__content > .el-input:not(.el-date-editor) input[readonly] {
background-color: #F5F7FA;
color: #909399;
cursor: default;
}
.billing-invoice .el-dialog .invoice-form .el-form-item__content > .el-input.untaxed-input input[readonly] {
color: #FF0033;
}
/* 操作列 fixed 克隆层没底色会重影 */
.billing-invoice .el-table__fixed-right,
.billing-invoice .el-table__fixed-right .el-table__fixed-header-wrapper,
.billing-invoice .el-table__fixed-right .el-table__fixed-body-wrapper {
background-color: #fff;
}
/* 操作列只有一个"开票":1×35 + .cell 内边距 10 = 45 */
.billing-invoice td.op-col .cell {
font-size: 0;
}
.billing-invoice td.op-col .cell > a {
display: inline-block;
width: 35px;
text-align: center;
font-size: 12px;
}
/* 排序箭头:global.scss:77 已把 caret-wrapper 压到 20px,只能在 20px 里排布。
数字照抄 contract/info.vue:1299,表头盒高两页一致所以不用重调 */
.billing-invoice .el-table .sort-caret {
border-width: 6px;
left: 6px;
}
.billing-invoice .el-table .sort-caret.ascending {
top: -4px;
bottom: auto;
}
.billing-invoice .el-table .sort-caret.descending {
top: 8px;
bottom: auto;
}
/* 排序列的表头 .cell 被 global.scss:36 写死成 14px,装不下 :77 那个 20px 的 caret-wrapper,
行盒撑高后下半截被 overflow:hidden 裁掉 → 文字看着下沉。只加高 is-sortable 的表头,箭头规则不动 */
.billing-invoice .el-table th.is-sortable > .cell {
height: 20px;
line-height: 20px;
}
</style>

914
src/views/modules/finance/invoice-management.vue

@ -0,0 +1,914 @@
<template>
<div class="invoice-maintenance">
<el-form inline>
<el-form-item label="客户名称">
<el-select filterable v-model="searchData.customerId" clearable size="small" placeholder="全部"
style="width: 200px;margin-top: 2px">
<el-option :label="item.customerName" :value="item.id"
v-for="(item,index) in customerListOptions" :key="index"></el-option>
</el-select>
</el-form-item>
<el-form-item label="开票日期">
<el-date-picker v-model="searchData.startDate" type="date" format="yyyy-MM-dd"
value-format="yyyy-MM-dd" placeholder="开始日期" size="small"
style="width: 110px;margin-top: 2px"></el-date-picker>
<span style="margin: 0 4px;">~</span>
<el-date-picker v-model="searchData.dateClosed" type="date" format="yyyy-MM-dd"
value-format="yyyy-MM-dd" placeholder="结束日期" size="small"
style="width: 110px;margin-top: 2px"></el-date-picker>
</el-form-item>
<el-form-item label="计划收款日期">
<el-date-picker v-model="searchData.planPayDateStart" type="date" format="yyyy-MM-dd"
value-format="yyyy-MM-dd" placeholder="开始日期" size="small"
style="width: 110px;margin-top: 2px"></el-date-picker>
<span style="margin: 0 4px;">~</span>
<el-date-picker v-model="searchData.planPayDateEnd" type="date" format="yyyy-MM-dd"
value-format="yyyy-MM-dd" placeholder="结束日期" size="small"
style="width: 110px;margin-top: 2px"></el-date-picker>
</el-form-item>
<el-form-item label="寄票日期">
<el-date-picker v-model="searchData.sendDateStart" type="date" format="yyyy-MM-dd"
value-format="yyyy-MM-dd" placeholder="开始日期" size="small"
style="width: 110px;margin-top: 2px"></el-date-picker>
<span style="margin: 0 4px;">~</span>
<el-date-picker v-model="searchData.sendDateEnd" type="date" format="yyyy-MM-dd"
value-format="yyyy-MM-dd" placeholder="结束日期" size="small"
style="width: 110px;margin-top: 2px"></el-date-picker>
</el-form-item>
<el-form-item label="付款状态">
<el-select v-model="searchData.status" clearable size="small" placeholder="全部"
style="width: 90px;margin-top: 2px">
<el-option label="未付全" value="Y"></el-option>
<el-option label="有付款" value="N"></el-option>
</el-select>
</el-form-item>
<el-form-item label="开票项目">
<el-select v-model="searchData.invoiceItem" clearable size="small" placeholder="全部"
style="width: 140px;margin-top: 2px">
<el-option :label="item.dataValue" :value="item.dataValue"
v-for="(item,index) in invoiceItemOptions" :key="index"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button @click="searchInvoice" style="margin-top: 2px">查询</el-button>
<el-button @click="resetSearch" style="margin-left: 10px;">重置</el-button>
<el-button type="primary" @click="openAddInvoiceModal" style="margin-left: 10px;">新增</el-button>
<el-button @click="exportInvoice" style="margin-left: 10px;">导出</el-button>
</el-form-item>
</el-form>
<el-table :data="invoiceList" border :height="height" style="width: 100%;" @sort-change="handleSortChange">
<el-table-column prop="customerName" header-align="center" align="left" min-width="200" label="客户名称" show-overflow-tooltip></el-table-column>
<el-table-column prop="companyName" header-align="center" align="left" min-width="180" label="公司名称" show-overflow-tooltip></el-table-column>
<el-table-column prop="projectName" header-align="center" align="left" min-width="180" label="项目名称" show-overflow-tooltip></el-table-column>
<el-table-column prop="invoiceItem" header-align="center" align="center" min-width="100" label="开票项目" show-overflow-tooltip></el-table-column>
<el-table-column prop="invoiceDate" header-align="center" align="center" min-width="100" sortable="custom" label="开票日期">
<template slot-scope="scope">{{ d10(scope.row.invoiceDate) }}</template>
</el-table-column>
<el-table-column prop="invoiceNo" header-align="center" align="center" min-width="110" label="发票号码" show-overflow-tooltip></el-table-column>
<el-table-column prop="invoiceAmount" header-align="center" align="right" min-width="100" sortable="custom" label="开票金额"></el-table-column>
<el-table-column prop="taxRate" header-align="center" align="center" min-width="70" label="税率">
<template slot-scope="scope">{{ taxRateText(scope.row.taxRate) }}</template>
</el-table-column>
<el-table-column prop="untaxedAmount" header-align="center" align="right" min-width="100" label="未税金额"></el-table-column>
<el-table-column prop="paidAmount" header-align="center" align="right" min-width="100" label="已付金额"></el-table-column>
<el-table-column header-align="center" align="right" min-width="100" label="未付金额">
<template slot-scope="scope">{{ unpaidAmount(scope.row) }}</template>
</el-table-column>
<el-table-column prop="planPayDate" header-align="center" align="center" min-width="100" label="计划收款日期">
<template slot-scope="scope">{{ d10(scope.row.planPayDate) }}</template>
</el-table-column>
<el-table-column prop="receiver" header-align="center" align="center" min-width="80" label="开票人" show-overflow-tooltip></el-table-column>
<el-table-column prop="sendMethod" header-align="center" align="center" min-width="90" label="寄送方式" show-overflow-tooltip></el-table-column>
<el-table-column prop="sendDate" header-align="center" align="center" min-width="100" label="寄票日期">
<template slot-scope="scope">{{ d10(scope.row.sendDate) }}</template>
</el-table-column>
<el-table-column fixed="right" header-align="center" align="right" class-name="op-col" width="150" label="操作">
<template slot-scope="scope">
<a type="text" size="small" @click="editInvoice(scope.row)">编辑</a>
<a type="text" size="small" @click="openDetail(scope.row)">详情</a>
<a type="text" size="small" @click="deleteInvoice(scope.row)">删除</a>
<a type="text" size="small" @click="openExpressModal(scope.row)">快递</a>
</template>
</el-table-column>
</el-table>
<el-pagination
@size-change="sizeChangeHandle"
@current-change="currentChangeHandle"
:current-page="pageIndex"
:page-sizes="[20, 50, 100, 200, 500]"
:page-size="pageSize"
:total="totalPage"
layout="total, sizes, prev, pager, next, jumper">
</el-pagination>
<!-- 三个合计:老页面也是"当前返回行"累加,分页后就是本页合计,所以这里明确标"本页" -->
<div class="totals-bar">
<span>本页开票金额: <b>{{ pageTotals.invoice }}</b></span>
<span>本页已付金额: <b>{{ pageTotals.paid }}</b></span>
<span>本页未付金额: <b>{{ pageTotals.unpaid }}</b></span>
</div>
<download-excel
ref="exportExcel"
:data="exportList"
:fields="exportFields"
name="发票列表.xls"
style="display:none">
导出
</download-excel>
<!-- 新增 / 编辑 -->
<el-dialog :title="invoiceModalTitle" :visible.sync="showInvoiceModal" width="770px" top="1vh"
:before-close="beforeCloseInvoiceModal" :close-on-click-modal="false">
<el-form class="invoice-form" :inline="true" label-position="top" :model="invoiceForm"
style="margin-left:7px; margin-top:-5px; font-size: 0;">
<!-- 第1行:客户名称 + 公司名称,各占两列;其余字段一律一档,一行四个 -->
<el-form-item label="客户名称" required class="wide-item">
<el-select filterable v-model="invoiceForm.customerId" placeholder="请选择" size="small"
style="font-size:12px; height:30px" :disabled="isEditInvoice || formDisabled"
@change="customerChange" @visible-change="customerDropdownVisible">
<el-option :label="item.customerName" :value="item.id"
v-for="(item,index) in customerListOptions" :key="index"></el-option>
</el-select>
</el-form-item>
<el-form-item label="公司名称" required class="wide-item">
<el-select filterable v-model="invoiceForm.billingInfoId" placeholder="请选择" size="small"
style="font-size:12px; height:30px" :disabled="isEditInvoice || formDisabled" @change="billingChange">
<el-option :label="item.billingCompanyName" :value="item.id"
v-for="(item,index) in companyNameOptions" :key="index"></el-option>
</el-select>
</el-form-item>
<!-- 第2行 -->
<el-form-item label="项目名称" required>
<el-input v-model="invoiceForm.projectName" size="small" placeholder="手工录入"
style="font-size:12px; height:30px" :disabled="formDisabled"></el-input>
</el-form-item>
<el-form-item label="开票项目" required>
<el-select v-model="invoiceForm.invoiceItem" placeholder="请选择" size="small"
style="font-size:12px; height:30px" :disabled="formDisabled">
<el-option :label="item.dataValue" :value="item.dataValue"
v-for="(item,index) in invoiceItemOptions" :key="index"></el-option>
</el-select>
</el-form-item>
<el-form-item label="开票日期" required>
<el-date-picker v-model="invoiceForm.invoiceDate" type="date" format="yyyy-MM-dd"
value-format="yyyy-MM-dd" placeholder="选择日期" size="small" :disabled="formDisabled"
:prefix-icon="''"></el-date-picker>
</el-form-item>
<el-form-item label="发票号码" required>
<el-input v-model="invoiceForm.invoiceNo" size="small"
style="font-size:12px; height:30px" :disabled="formDisabled"></el-input>
</el-form-item>
<!-- 第3行 -->
<el-form-item label="税号">
<el-input v-model="invoiceForm.taxNo" size="small"
style="font-size:12px; height:30px" :disabled="formDisabled"></el-input>
</el-form-item>
<el-form-item label="开票金额" required>
<el-input v-model="invoiceForm.invoiceAmount" size="small" placeholder="请输入金额"
style="font-size:12px; height:30px" :disabled="formDisabled" @input="onAmountInput"></el-input>
</el-form-item>
<el-form-item label="税率" required>
<el-select v-model="invoiceForm.taxRate" size="small" style="font-size:12px; height:30px" :disabled="formDisabled"
@change="calcUntaxed">
<el-option label="6" value="0.06"></el-option>
<el-option label="13" value="0.13"></el-option>
</el-select>
</el-form-item>
<el-form-item label="未税金额">
<el-input v-model="invoiceForm.untaxedAmount" class="untaxed-input" size="small" readonly :disabled="formDisabled"
style="font-size:12px; height:30px; color:#FF0033"></el-input>
</el-form-item>
<!-- 第4行 -->
<el-form-item label="已付金额" v-if="detailMode">
<el-input v-model="invoiceForm.paidAmount" size="small" readonly
style="font-size:12px; height:30px" :disabled="formDisabled"></el-input>
</el-form-item>
<el-form-item label="开票人">
<el-input v-model="invoiceForm.receiver" size="small"
style="font-size:12px; height:30px" :disabled="formDisabled"></el-input>
</el-form-item>
<el-form-item label="寄送方式">
<el-select v-model="invoiceForm.sendMethod" placeholder="请选择" size="small"
style="font-size:12px; height:30px" :disabled="formDisabled">
<el-option :label="item.dataValue" :value="item.dataValue"
v-for="(item,index) in sendMethodOptions" :key="index"></el-option>
</el-select>
</el-form-item>
<el-form-item label="寄送日期">
<el-date-picker v-model="invoiceForm.sendDate" type="date" format="yyyy-MM-dd"
value-format="yyyy-MM-dd" placeholder="选择日期" size="small" :disabled="formDisabled"
:prefix-icon="''"></el-date-picker>
</el-form-item>
<!-- 第5行:只有三个,末尾空一档 -->
<el-form-item label="预计收款日期" required>
<el-date-picker v-model="invoiceForm.planPayDate" type="date" format="yyyy-MM-dd"
value-format="yyyy-MM-dd" placeholder="选择日期" size="small" :disabled="formDisabled"
:prefix-icon="''"></el-date-picker>
</el-form-item>
<el-form-item label="收票人姓名">
<el-input v-model="invoiceForm.custReceiver" size="small"
style="font-size:12px; height:30px" :disabled="formDisabled"></el-input>
</el-form-item>
<el-form-item label="收票人电话">
<el-input v-model="invoiceForm.custReceiverPhone" size="small"
style="font-size:12px; height:30px" :disabled="formDisabled"></el-input>
</el-form-item>
<!-- 寄送地址 / 备注:照抄 contract/info.vue 的裸 div 写法。
label 用 12px/20px + margin 2px、控件 size=small,
和上面 el-form-item 的 label(12/20+2) 与控件(32) 完全同尺寸,行距才一致 -->
<div style="width: 708px; margin-bottom: 1px;">
<div style="font-size: 12px; line-height: 20px; color: #606266; margin-bottom: 2px;">寄送地址</div>
<el-input v-model="invoiceForm.sendAddr" size="small" :disabled="formDisabled" style="font-size: 12px;"></el-input>
</div>
<div style="width: 708px; margin-bottom: 10px;">
<div style="font-size: 12px; line-height: 20px; color: #606266; margin-bottom: 2px;">备注</div>
<el-input v-model="invoiceForm.remark" type="textarea" :rows="1" :disabled="formDisabled" style="font-size: 12px;"></el-input>
</div>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="closeInvoiceModal">取消</el-button>
<el-button v-if="!detailMode" type="primary" @click="saveInvoice">保存</el-button>
</div>
</el-dialog>
<!-- 快递:老页面这个按钮永远新增,不传 id -->
<el-dialog title="快递信息" :visible.sync="showExpressModal" width="640px" top="1vh"
:close-on-click-modal="false">
<!-- 栅格一档 152px:四档 608 正好撑满 640 弹窗(body 左右内边距 10+10、form 左移 7)。
宽度一律走 .express-form 的 CSS 类,这里再写 style="width" 会把同一行的槽顶歪 -->
<el-form class="express-form" :inline="true" label-position="top" :model="expressForm"
style="margin-left:7px; font-size: 0;">
<el-form-item label="客户名称" class="two-item">
<el-input v-model="expressForm.customerName" readonly size="small"></el-input>
</el-form-item>
<el-form-item label="公司名称" class="two-item">
<el-input v-model="expressForm.deliveryCustomerName" size="small"></el-input>
</el-form-item>
<el-form-item label="要求快递日期" required>
<el-date-picker v-model="expressForm.wantedDeliveryDate" type="date" format="yyyy-MM-dd"
value-format="yyyy-MM-dd" size="small" :prefix-icon="''"></el-date-picker>
</el-form-item>
<el-form-item label="快递公司">
<el-select v-model="expressForm.expressName" placeholder="请选择" size="small">
<el-option :label="item.forwarderName" :value="item.forwarderName"
v-for="(item,index) in forwarderOptions" :key="index"></el-option>
</el-select>
</el-form-item>
<el-form-item label="运单号">
<el-input v-model="expressForm.airwayBillNo" size="small"></el-input>
</el-form-item>
<el-form-item label="快递费用">
<el-input v-model="expressForm.expressFee" size="small" @input="onExpressFeeInput"></el-input>
</el-form-item>
<el-form-item label="地址" class="four-item">
<el-input v-model="expressForm.deliveryAddress" size="small"></el-input>
</el-form-item>
<el-form-item label="收件人" class="two-item">
<el-input v-model="expressForm.deliveryContact" size="small"></el-input>
</el-form-item>
<el-form-item label="收件人电话" class="two-item">
<el-input v-model="expressForm.deliveryPhoneNo" size="small"></el-input>
</el-form-item>
<!-- 备注:照抄上面发票弹窗 contract 系的裸 div 写法,不套 el-form-item,
这样它不受 .express-form .el-form-item 那条栅格规则(含 !important 宽度)约束 -->
<div style="width: 598px; margin-bottom: 10px;">
<div style="font-size: 12px; line-height: 20px; color: #606266; margin-bottom: 2px;">备注</div>
<el-input v-model="expressForm.remark" type="textarea" :rows="1" style="font-size: 12px;"></el-input>
</div>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="showExpressModal = false">取消</el-button>
<el-button type="primary" @click="saveExpress">保存</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import {
invoiceData, invoiceSave, invoiceDelete, invoiceValueList, invoiceCompanyName,
getCustomerList, expressNameList, expresshistSave
} from '@/api/invoice/invoice.js'
export default {
name: 'invoice-info',
data() {
return {
height: 600,
// 查询字段名必须和 InvoiceEntity 上的名字一字不差:
// customerId / startDate / dateClosed / planPayDateStart / planPayDateEnd
// / sendDateStart / sendDateEnd / status(dateClosed 不是 endDate)
searchData: {
customerId: null,
startDate: '',
dateClosed: '',
planPayDateStart: '',
planPayDateEnd: '',
sendDateStart: '',
sendDateEnd: '',
status: '',
invoiceItem: '',
page: 1,
limit: 20
},
invoiceList: [],
pageIndex: 1,
pageSize: 20,
totalPage: 0,
sortField: '',
sortOrder: '',
exportList: [],
exportFields: {
'客户名称': 'customerName',
'公司名称': 'companyName',
'项目名称': 'projectName',
'开票项目': 'invoiceItem',
'开票日期': { field: 'invoiceDate', callback: (v) => (v || '').substring(0, 10) },
'发票号码': 'invoiceNo',
'开票金额': 'invoiceAmount',
'税率': { field: 'taxRate', callback: (v) => (v == null || v === '' ? '' : Number((Number(v) * 100).toFixed(2))) },
'未税金额': 'untaxedAmount',
'已付金额': 'paidAmount',
'未付金额': { callback: (row) => this.unpaidAmount(row) },
'计划收款日期': { field: 'planPayDate', callback: (v) => (v || '').substring(0, 10) },
'开票人': 'receiver',
'寄送方式': 'sendMethod',
'寄票日期': { field: 'sendDate', callback: (v) => (v || '').substring(0, 10) }
},
showInvoiceModal: false,
isEditInvoice: false,
// 详情复用新增/编辑弹窗:只填值 + 全控件 disabled,标题和按钮由这两个开关算出来
detailMode: false,
showExpressModal: false,
customerListOptions: [],
companyNameOptions: [],
sendMethodOptions: [],
invoiceItemOptions: [],
forwarderOptions: [],
invoiceForm: this.blankInvoiceForm(),
expressForm: this.blankExpressForm()
}
},
computed: {
pageTotals() {
let invoice = 0, paid = 0
this.invoiceList.forEach(r => {
invoice += Number(r.invoiceAmount) || 0
paid += Number(r.paidAmount) || 0
})
return {
invoice: invoice.toFixed(2),
paid: paid.toFixed(2),
unpaid: (invoice - paid).toFixed(2)
}
},
invoiceModalTitle() {
if (this.detailMode) return '发票信息详情'
return this.isEditInvoice ? '编辑发票' : '新增发票'
},
formDisabled() {
return this.detailMode
}
},
mounted() {
this.$nextTick(() => {
this.height = window.innerHeight - 250
})
},
activated() {
this.initData()
},
methods: {
blankInvoiceForm() {
return {
id: null,
projectId: 0,
projectName: '',
customerId: null,
billingInfoId: null,
invoiceDate: '',
invoiceNo: '',
taxNo: '',
invoiceItem: '',
invoiceAmount: '',
paidAmount: null,
taxRate: '0.06',
untaxedAmount: '',
receiver: '',
sendMethod: '',
sendDate: '',
sendAddr: '',
custReceiver: '',
custReceiverPhone: '',
custReceiverFlag: 'N',
cancelledFlag: 'N',
cancelledDate: null,
cancelledReason: '',
cancelledReceiver: '',
planPayDate: '',
remark: '',
recordVersion: ''
}
},
blankExpressForm() {
return {
customerId: null,
customerName: '',
deliveryCustomerName: '',
deliveryAddress: '',
deliveryContact: '',
deliveryPhoneNo: '',
wantedDeliveryDate: '',
remark: '',
expressName: '',
airwayBillNo: '',
expressFee: ''
}
},
today() {
let d = new Date()
let pad = n => n < 10 ? '0' + n : n
return d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate())
},
d10(v) {
return v ? String(v).substring(0, 10) : ''
},
taxRateText(v) {
if (v == null || v === '') return ''
return Number((Number(v) * 100).toFixed(2))
},
unpaidAmount(row) {
return ((Number(row.invoiceAmount) || 0) - (Number(row.paidAmount) || 0)).toFixed(2)
},
initData() {
this.fetchInvoices()
this.fetchCustomerOptions()
// SW=寄送方式 IT=开票项目(老 invoice.js:290 / :332 写死的两个 type)
invoiceValueList('SW').then(({data}) => {
if (data && data.code === 0) this.sendMethodOptions = data.list
}).catch(err => { console.error(err) })
invoiceValueList('IT').then(({data}) => {
if (data && data.code === 0) this.invoiceItemOptions = data.list
}).catch(err => { console.error(err) })
expressNameList().then(({data}) => {
if (data && data.code === 0) this.forwarderOptions = data.list
}).catch(err => { console.error(err) })
},
fetchInvoices() {
this.searchData.page = this.pageIndex
this.searchData.limit = this.pageSize
this.searchData.sidx = this.sortField
this.searchData.order = this.sortOrder
invoiceData(this.searchData).then(({data}) => {
if (data.code === 0) {
this.invoiceList = data.page.list
this.totalPage = data.page.totalCount
} else {
this.invoiceList = []
this.totalPage = 0
}
}).catch(err => { console.error(err) })
},
searchInvoice() {
if (this.searchData.startDate && this.searchData.dateClosed
&& this.searchData.startDate > this.searchData.dateClosed) {
this.$message.warning('开始日期不能晚于结束日期')
return
}
if (this.searchData.planPayDateStart && this.searchData.planPayDateEnd
&& this.searchData.planPayDateStart > this.searchData.planPayDateEnd) {
this.$message.warning('计划收款日期:开始日期不能晚于结束日期')
return
}
if (this.searchData.sendDateStart && this.searchData.sendDateEnd
&& this.searchData.sendDateStart > this.searchData.sendDateEnd) {
this.$message.warning('寄票日期:开始日期不能晚于结束日期')
return
}
this.pageIndex = 1
this.fetchInvoices()
},
resetSearch() {
this.searchData = { customerId: null, startDate: '', dateClosed: '', planPayDateStart: '', planPayDateEnd: '', sendDateStart: '', sendDateEnd: '', status: '', invoiceItem: '', page: 1, limit: this.pageSize }
this.pageIndex = 1
this.fetchInvoices()
},
sizeChangeHandle(val) {
this.pageSize = val
this.pageIndex = 1
this.fetchInvoices()
},
currentChangeHandle(val) {
this.pageIndex = val
this.fetchInvoices()
},
// 列头排序走后端,形状照抄 contract/info.vue:537
handleSortChange({ prop, order }) {
this.sortField = order ? prop : ''
this.sortOrder = order === 'ascending' ? 'asc' : order === 'descending' ? 'desc' : ''
this.pageIndex = 1
this.fetchInvoices()
},
exportInvoice() {
if (!this.totalPage) {
this.$message.warning('没有可导出的数据')
return
}
const params = Object.assign({}, this.searchData, { page: 1, limit: this.totalPage })
invoiceData(params).then(({data}) => {
if (data.code === 0 && data.page.list.length) {
this.exportList = data.page.list
this.$nextTick(() => { this.$refs.exportExcel.$el.click() })
} else {
this.$message.warning('没有可导出的数据')
}
}).catch(err => {
console.error(err)
this.$message.error('导出失败')
})
},
fetchCustomerOptions() {
getCustomerList().then(({data}) => {
if (data && data.code === 0) this.customerListOptions = data.rows
}).catch(err => { console.error(err) })
},
customerDropdownVisible(visible) {
if (visible && !this.isEditInvoice) this.fetchCustomerOptions()
},
// 客户变化:重新拉该客户的开票公司,并清掉已选(老 #customerId change 就是这个语义)
customerChange(customerId) {
this.invoiceForm.billingInfoId = null
this.companyNameOptions = []
if (customerId) this.fetchCompanyNameOptions(customerId)
},
fetchCompanyNameOptions(customerId) {
invoiceCompanyName(customerId).then(({data}) => {
if (data && data.code === 0) this.companyNameOptions = data.list
}).catch(err => { console.error(err) })
},
// 开票公司变化:回填税号/收票人/电话/寄送地址(老 invoice.js:750 那段,是能用的那段)
billingChange(billingInfoId) {
let hit = this.companyNameOptions.filter(item => item.id === billingInfoId)[0]
if (!hit) return
this.invoiceForm.taxNo = hit.taxNo
this.invoiceForm.custReceiverPhone = hit.phoneNo
this.invoiceForm.custReceiver = hit.receiver
this.invoiceForm.sendAddr = hit.receiverAddr
},
openAddInvoiceModal() {
this.detailMode = false
this.isEditInvoice = false
this.companyNameOptions = []
this.invoiceForm = this.blankInvoiceForm()
this.invoiceForm.sendMethod = '快递'
this.invoiceForm.invoiceDate = this.today()
this.invoiceForm.sendDate = this.today()
this.invoiceForm.planPayDate = this.today()
this.invoiceForm.receiver = this.$store.state.user.userDisplay
this.showInvoiceModal = true
},
editInvoice(row) {
this.detailMode = false
this.isEditInvoice = true
// 整行带上:recordVersion / custReceiverFlag / cancelled_* 都会被 update 原样写回,不能丢
this.invoiceForm = Object.assign(this.blankInvoiceForm(), row)
this.invoiceForm.invoiceDate = this.d10(row.invoiceDate)
this.invoiceForm.sendDate = this.d10(row.sendDate)
this.invoiceForm.planPayDate = this.d10(row.planPayDate)
this.invoiceForm.cancelledDate = row.cancelledDate || null
if (row.taxRate != null) this.invoiceForm.taxRate = String(row.taxRate)
if (row.customerId) this.fetchCompanyNameOptions(row.customerId)
this.showInvoiceModal = true
},
onAmountInput(val) {
this.invoiceForm.invoiceAmount = this.moneyFilter(val)
this.calcUntaxed()
},
onExpressFeeInput(val) {
this.expressForm.expressFee = this.moneyFilter(val)
},
moneyFilter(value) {
let filtered = String(value == null ? '' : value).replace(/[^\d.]/g, '')
if (filtered.startsWith('.')) filtered = '0' + filtered
let dotIndex = filtered.indexOf('.')
if (dotIndex !== -1) {
filtered = filtered.substring(0, dotIndex + 1) + filtered.substring(dotIndex + 1).replace(/\./g, '')
}
return filtered
},
// 未税金额 = 开票金额 / (1 + 税率),取 2 位(老 invoice.js:366-384)
calcUntaxed() {
let amount = Number(this.invoiceForm.invoiceAmount)
if (this.invoiceForm.invoiceAmount === '' || isNaN(amount)) return
let untaxed = amount / (1 + parseFloat(this.invoiceForm.taxRate))
this.invoiceForm.untaxedAmount = untaxed.toFixed(2)
},
validateInvoice() {
let f = this.invoiceForm
let amount = Number(f.invoiceAmount)
let paid = Number(f.paidAmount) || 0
if (f.paidAmount != null && f.paidAmount !== '' && amount && paid > amount) {
this.$message.error('开票金额不能小于已付款金额!')
return false
}
if (!f.customerId) { this.$message.error('请输入客户名称!'); return false }
if (!f.billingInfoId) { this.$message.error('请输入公司名称!'); return false }
if (!f.projectName || !f.projectName.trim()) { this.$message.error('请输入项目名称!'); return false }
if (!f.invoiceItem) { this.$message.error('请输入开票项目!'); return false }
if (!f.invoiceDate) { this.$message.error('请输入开票日期!'); return false }
if (!f.invoiceNo || !f.invoiceNo.trim()) { this.$message.error('请输入发票号码!'); return false }
// 老代码这里是 if (invoiceAmount = 0) 单等号赋值,校验从来没生效;按它的本意实现
if (f.invoiceAmount === '' || f.invoiceAmount == null || isNaN(amount)) {
this.$message.error('请输入开票金额!'); return false
}
if (!f.taxRate) { this.$message.error('请输入税率!'); return false }
this.calcUntaxed()
if (!f.untaxedAmount) { this.$message.error('请输入未税金额!'); return false }
if (!f.planPayDate) { this.$message.error('请输入预计收款时间!'); return false }
return true
},
saveInvoice() {
if (!this.validateInvoice()) return
let inData = Object.assign({}, this.invoiceForm)
inData.invoiceAmount = Number(inData.invoiceAmount)
inData.untaxedAmount = Number(inData.untaxedAmount)
inData.taxRate = Number(inData.taxRate)
inData.projectName = inData.projectName.trim()
inData.invoiceNo = inData.invoiceNo.trim()
// 实体是 @JsonFormat("yyyy-MM-dd HH:mm:ss"),只给日期后端解析不了
if (inData.invoiceDate) inData.invoiceDate = inData.invoiceDate + ' 00:00:00'
if (inData.sendDate) inData.sendDate = inData.sendDate + ' 00:00:00'
if (inData.planPayDate) inData.planPayDate = inData.planPayDate + ' 00:00:00'
if (!inData.cancelledDate) inData.cancelledDate = null
invoiceSave(inData).then(({data}) => {
if (data && data.code === 0) {
this.$message.success(data.msg || '保存成功')
this.showInvoiceModal = false
this.fetchInvoices()
} else {
this.$message.error((data && data.msg) || '保存失败')
}
}).catch(err => {
console.error(err)
this.$message.error('保存失败')
})
},
beforeCloseInvoiceModal(done) {
this.closeInvoiceModal()
done()
},
closeInvoiceModal() {
this.showInvoiceModal = false
this.isEditInvoice = false
this.detailMode = false
this.companyNameOptions = []
this.invoiceForm = this.blankInvoiceForm()
this.fetchInvoices()
},
deleteInvoice(row) {
// 老页面这条是前端拦的,后端只拦"已有核销记录",照抄
if (Number(row.paidAmount) > 0) {
this.$message.error('已付金额大于0,无法删除!')
return
}
this.$confirm('确定要删除选中的发票吗?', '提示', { type: 'warning' }).then(() => {
invoiceDelete({ id: row.id }).then(({data}) => {
if (data && data.code === 0) {
// 后端删除守卫返回的是提示语("已有核销记录,无法删除!"),不是错误码
this.$message.success(data.msg || '删除成功')
this.fetchInvoices()
} else {
this.$message.error((data && data.msg) || '删除失败')
}
}).catch(err => {
console.error(err)
this.$message.error('删除失败')
})
}).catch(() => {})
},
openDetail(row) {
// 复用 editInvoice 的填值:它已经拉好该公司的开票公司列表(否则公司名称下拉只能显示 id)、
// 并把三个日期和 taxRate 归一化,详情要显示的就是这些
this.editInvoice(row)
this.detailMode = true
},
// 老 addExpress(row) 的预填:公司=companyName,地址=sendAddr,收件人=custReceiver,电话=custReceiverPhone
openExpressModal(row) {
this.expressForm = this.blankExpressForm()
this.expressForm.customerId = row.customerId
this.expressForm.customerName = row.customerName
this.expressForm.deliveryCustomerName = row.companyName
this.expressForm.deliveryAddress = row.sendAddr
this.expressForm.deliveryContact = row.custReceiver
this.expressForm.deliveryPhoneNo = row.custReceiverPhone
this.expressForm.wantedDeliveryDate = this.today()
this.showExpressModal = true
},
saveExpress() {
if (!this.expressForm.wantedDeliveryDate) {
this.$message.error('请输入日期!')
return
}
// 字段和老 expresshistSave() 手工拼的那 10 个 key 一致,且不发 id → 必走 insert
let inData = {
customerId: this.expressForm.customerId,
deliveryCustomerName: this.expressForm.deliveryCustomerName,
wantedDeliveryDate: this.expressForm.wantedDeliveryDate + ' 00:00:00',
deliveryAddress: this.expressForm.deliveryAddress,
deliveryContact: this.expressForm.deliveryContact,
deliveryPhoneNo: this.expressForm.deliveryPhoneNo,
remark: this.expressForm.remark,
expressFee: this.expressForm.expressFee === '' ? null : Number(this.expressForm.expressFee),
airwayBillNo: this.expressForm.airwayBillNo,
expressName: this.expressForm.expressName
}
expresshistSave(inData).then(({data}) => {
if (data && data.code === 0) {
this.$message.success(data.msg || '保存成功')
this.showExpressModal = false
} else {
this.$message.error((data && data.msg) || '保存失败')
}
}).catch(err => {
console.error(err)
this.$message.error('保存失败')
})
}
}
}
</script>
<style>
.invoice-maintenance {
margin-top: 10px;
}
.invoice-maintenance .el-input__prefix {
top: 50%;
transform: translateY(-50%);
font-size: 14px;
height: auto;
line-height: 1;
}
.invoice-maintenance .el-date-editor .el-input__inner {
padding-left: 28px;
}
.invoice-maintenance .el-input__suffix {
top: 50%;
transform: translateY(-50%);
height: auto;
}
.invoice-maintenance > .el-form--inline .el-form-item {
margin-bottom: 10px;
vertical-align: middle;
}
.invoice-maintenance .el-dialog .el-form-item__label {
font-size: 12px;
line-height: 20px;
margin-bottom: 2px;
}
/* ===== 新增/编辑弹窗:一档 180px(控件 170 + 列间距 10),一行四个 =====
必须圈在 .invoice-form 上:详情弹窗的 el-form-item 是 v-for 出来的,
不加这个圈,它的 290 / 720 宽字段会被下面的 180px 全部压掉 */
.invoice-maintenance .el-dialog .invoice-form .el-form-item {
width: 180px;
margin-right: 0;
margin-bottom: 1px;
}
.invoice-maintenance .el-dialog .invoice-form .el-form-item .el-input,
.invoice-maintenance .el-dialog .invoice-form .el-form-item .el-select {
width: 170px !important;
}
/* 第1行两个:各占两列 */
.invoice-maintenance .el-dialog .invoice-form .el-form-item.wide-item {
width: 360px;
}
.invoice-maintenance .el-dialog .invoice-form .el-form-item.wide-item .el-select,
.invoice-maintenance .el-dialog .invoice-form .el-form-item.wide-item .el-input {
width: 351px !important;
}
/* 详情态:element 自带的 disabled 已经把控件灰底,这里只把字色再压暗一点 */
.invoice-maintenance .el-dialog .invoice-form .el-input.is-disabled .el-input__inner,
.invoice-maintenance .el-dialog .invoice-form .el-textarea.is-disabled .el-textarea__inner {
color: #a8abb2;
}
/* 快递弹窗栅格:一档 152px,四档 608 正好撑满 640 弹窗(body 左右 10+10、form 左移 7)。
控件比槽窄 10px 留行内缝;margin-right 必须清掉,否则 element 默认的 10px 会把每行第 4 个挤到下一行 */
.invoice-maintenance .el-dialog .express-form .el-form-item {
width: 152px;
margin-right: 0;
margin-bottom: 1px;
}
.invoice-maintenance .el-dialog .express-form .el-form-item .el-input,
.invoice-maintenance .el-dialog .express-form .el-form-item .el-select {
width: 142px !important;
}
/* 两档:客户名称/公司名称、收件人/收件人电话 */
.invoice-maintenance .el-dialog .express-form .el-form-item.two-item {
width: 304px;
}
.invoice-maintenance .el-dialog .express-form .el-form-item.two-item .el-input,
.invoice-maintenance .el-dialog .express-form .el-form-item.two-item .el-select {
width: 294px !important;
}
/* 四档:地址(备注已改成裸 div,不再走栅格) */
.invoice-maintenance .el-dialog .express-form .el-form-item.four-item {
width: 608px;
}
.invoice-maintenance .el-dialog .express-form .el-form-item.four-item .el-input {
width: 598px !important;
}
/* 备注:和新增/编辑发票完全一致——裸 div + 不封顶,靠 resize:vertical 自由往下拖/往回拖,
div 和弹窗 body 一起变长变短(实测拖到 400px 时 body 300→660)。
font-size 必须写死:form 上有 font-size:0(抹 inline-block 换行空格用的),
.el-input__inner 自带字号没事,只有 .el-textarea__inner 是 font-size:inherit ——
不补会把输入的字渲染成 0px。和发票那边一样写在 style 上 */
.invoice-maintenance .el-dialog .express-form .el-textarea__inner {
font-size: 12px;
}
.invoice-maintenance .totals-bar {
margin-top: 8px;
font-size: 12px;
color: #606266;
}
.invoice-maintenance .totals-bar span {
margin-right: 30px;
}
.invoice-maintenance .totals-bar b {
color: #409EFF;
font-weight: 600;
}
/* 操作列 fixed 克隆层没底色会重影(和 contract 同一个主题坑) */
.invoice-maintenance .el-table__fixed-right,
.invoice-maintenance .el-table__fixed-right .el-table__fixed-header-wrapper,
.invoice-maintenance .el-table__fixed-right .el-table__fixed-body-wrapper {
background-color: #fff;
}
/* 操作列:槽位定宽居中。inline-block 之间的换行会渲染成空格(约 3~4px/个),
必须用 font-size:0 抹掉,否则 4×35+9=149 会实占 160,第 4 槽被 .cell 的 overflow:hidden 裁掉 */
.invoice-maintenance td.op-col .cell {
font-size: 0;
}
.invoice-maintenance td.op-col .cell > a {
display: inline-block;
width: 35px;
text-align: center;
font-size: 12px;
}
/* 新增/编辑发票:只读框标灰 —— 未税金额 / 已付金额。
限定 .el-form-item__content 的直接子级 .el-input:el-select 内层 input 自带 readonly(2.8.2),
裸 input[readonly] 会把税率/寄送方式这些下拉框一起染灰;再排掉 .el-date-editor */
.invoice-maintenance .el-dialog .invoice-form .el-form-item__content > .el-input:not(.el-date-editor) input[readonly] {
background-color: #F5F7FA;
color: #909399;
cursor: default;
}
/* 快递信息:只读框标灰 —— 客户名称(公司名称是预填但可改,不归这条管) */
.invoice-maintenance .el-dialog .express-form .el-form-item__content > .el-input:not(.el-date-editor) input[readonly] {
background-color: #F5F7FA;
color: #909399;
cursor: default;
}
.invoice-maintenance .el-dialog .invoice-form .el-form-item__content > .el-input.untaxed-input input[readonly] {
color: #FF0033;
}
/* 排序箭头:global.scss:77 已把 caret-wrapper 压到 20px,只能在 20px 里排布。
数字照抄 contract/info.vue:1299,表头盒高两页一致所以不用重调 */
.invoice-maintenance .el-table .sort-caret {
border-width: 6px;
left: 6px;
}
.invoice-maintenance .el-table .sort-caret.ascending {
top: -4px;
bottom: auto;
}
.invoice-maintenance .el-table .sort-caret.descending {
top: 8px;
bottom: auto;
}
/* 排序列的表头 .cell 被 global.scss:36 写死成 14px,装不下 :77 那个 20px 的 caret-wrapper,
行盒撑高后下半截被 overflow:hidden 裁掉 → 文字看着下沉。只加高 is-sortable 的表头,箭头规则不动 */
.invoice-maintenance .el-table th.is-sortable > .cell {
height: 20px;
line-height: 20px;
}
</style>
Loading…
Cancel
Save