|
|
@@ -1,51 +1,12 @@
|
|
|
-import { getList, add, update, remove, getDetail, updateStatus } from '@/api/order/invoice'
|
|
|
-import { mapGetters } from 'vuex'
|
|
|
-import {
|
|
|
- INVOICE_TYPES,
|
|
|
- INVOICE_STATUS,
|
|
|
- INVOICE_TYPE_OPTIONS,
|
|
|
- INVOICE_STATUS_OPTIONS,
|
|
|
- getInvoiceTypeLabel,
|
|
|
- getInvoiceTypeTagType,
|
|
|
- getInvoiceStatusLabel,
|
|
|
- getInvoiceStatusTagType
|
|
|
-} from '@/constants'
|
|
|
+// @ts-check
|
|
|
+import { getARBillHeadStatusInquiry } from '@/api/comprehensive'
|
|
|
|
|
|
/**
|
|
|
- * 发票查询参数类型定义
|
|
|
- * @typedef {Object} InvoiceQueryParams
|
|
|
- * @property {string} [orderId] - 订单ID
|
|
|
- * @property {string} [invoiceId] - 发票ID
|
|
|
- * @property {string} [invoiceNo] - 发票号码
|
|
|
- * @property {string} [customerName] - 客户名称
|
|
|
- * @property {number} [invoiceStatus] - 开票状态
|
|
|
- * @property {string} [startDate] - 开始日期
|
|
|
- * @property {string} [endDate] - 结束日期
|
|
|
+ * @typedef {import('@/api/types/comprehensive').ARBillHeadStatusInquiryParams} ARBillHeadStatusInquiryParams
|
|
|
+ * @typedef {import('@/api/types/comprehensive').ARBillHeadStatusInquiryRecord} ARBillHeadStatusInquiryRecord
|
|
|
*/
|
|
|
|
|
|
/**
|
|
|
- * 发票表单数据类型定义
|
|
|
- * @typedef {Object} InvoiceForm
|
|
|
- * @property {string} [id] - 发票ID
|
|
|
- * @property {string} invoiceNo - 发票号码
|
|
|
- * @property {string} invoiceCode - 发票代码
|
|
|
- * @property {number} orderId - 订单ID
|
|
|
- * @property {string} orderCode - 订单编码
|
|
|
- * @property {number} customerId - 客户ID
|
|
|
- * @property {string} customerCode - 客户编码
|
|
|
- * @property {string} customerName - 客户名称
|
|
|
- * @property {string} taxNo - 税号
|
|
|
- * @property {string} invoiceTitle - 发票抬头
|
|
|
- * @property {string} amount - 金额
|
|
|
- * @property {string} taxAmount - 税额
|
|
|
- * @property {string} totalAmount - 总金额
|
|
|
- * @property {string} invoiceType - 发票类型
|
|
|
- * @property {number} invoiceStatus - 开票状态
|
|
|
- * @property {string} invoiceDate - 开票日期
|
|
|
- */
|
|
|
-
|
|
|
-/**
|
|
|
- * 分页信息类型定义
|
|
|
* @typedef {Object} PageInfo
|
|
|
* @property {number} pageSize - 每页大小
|
|
|
* @property {number} currentPage - 当前页码
|
|
|
@@ -53,16 +14,18 @@ import {
|
|
|
*/
|
|
|
|
|
|
/**
|
|
|
- * 发票管理混入
|
|
|
- * @mixin InvoiceMixin
|
|
|
+ * 发票及开票信息查询混入(应收单)
|
|
|
+ * @description 使用 U9Cloud 综合查询接口查询应收单开票状态
|
|
|
*/
|
|
|
export default {
|
|
|
+ name: 'InvoiceStatusQuery',
|
|
|
+
|
|
|
data() {
|
|
|
return {
|
|
|
- /** @type {InvoiceForm} 表单数据 */
|
|
|
+ /** @type {Record<string, any>} 表单数据 */
|
|
|
form: {},
|
|
|
|
|
|
- /** @type {InvoiceQueryParams} 查询参数 */
|
|
|
+ /** @type {Partial<ARBillHeadStatusInquiryParams> & { businessDate?: string | [string, string], fuzzyValue?: string }} 查询参数 */
|
|
|
query: {},
|
|
|
|
|
|
/** @type {boolean} 加载状态 */
|
|
|
@@ -75,612 +38,292 @@ export default {
|
|
|
total: 0
|
|
|
},
|
|
|
|
|
|
- /** @type {Array<InvoiceItem>} 选中的数据列表 */
|
|
|
- selectionList: [],
|
|
|
-
|
|
|
- /** @type {Array<InvoiceItem>} 表格数据 */
|
|
|
+ /** @type {ARBillHeadStatusInquiryRecord[]} 表格数据 */
|
|
|
data: [],
|
|
|
|
|
|
+ /** @type {ARBillHeadStatusInquiryRecord[]} 查询原始数据(用于前端分页) */
|
|
|
+ rawData: [],
|
|
|
+
|
|
|
+ /** @type {boolean} 是否后端分页 */
|
|
|
+ serverPaging: false,
|
|
|
+
|
|
|
/** @type {Object} 表格配置选项 */
|
|
|
option: {
|
|
|
height: 'auto',
|
|
|
calcHeight: 30,
|
|
|
- dialogWidth: 1000,
|
|
|
- labelWidth: 120,
|
|
|
tip: false,
|
|
|
searchShow: true,
|
|
|
searchMenuSpan: 6,
|
|
|
border: true,
|
|
|
index: true,
|
|
|
- selection: true,
|
|
|
- viewBtn: true,
|
|
|
- editBtn: true,
|
|
|
- addBtn: true,
|
|
|
- delBtn: true,
|
|
|
- dialogClickModal: false,
|
|
|
+ menu: false,
|
|
|
+ viewBtn: false,
|
|
|
+ editBtn: false,
|
|
|
+ delBtn: false,
|
|
|
+ addBtn: false,
|
|
|
column: [
|
|
|
{
|
|
|
- label: '发票号码',
|
|
|
- prop: 'invoiceNo',
|
|
|
+ label: '单据编号',
|
|
|
+ prop: 'docNo',
|
|
|
search: true,
|
|
|
- rules: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请输入发票号码',
|
|
|
- trigger: 'blur'
|
|
|
- }
|
|
|
- ]
|
|
|
+ width: 150
|
|
|
},
|
|
|
{
|
|
|
- label: '发票代码',
|
|
|
- prop: 'invoiceCode',
|
|
|
+ label: '销售订单编号',
|
|
|
+ prop: 'soDocNo',
|
|
|
search: true,
|
|
|
- rules: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请输入发票代码',
|
|
|
- trigger: 'blur'
|
|
|
- }
|
|
|
- ]
|
|
|
+ width: 150
|
|
|
},
|
|
|
{
|
|
|
- label: '订单ID',
|
|
|
- prop: 'orderId',
|
|
|
+ label: '销售订单行号',
|
|
|
+ prop: 'soDocLineNo',
|
|
|
search: true,
|
|
|
- type: 'number',
|
|
|
- rules: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请输入订单ID',
|
|
|
- trigger: 'blur'
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'number',
|
|
|
- message: '请输入数字',
|
|
|
- trigger: 'blur'
|
|
|
- },
|
|
|
- {
|
|
|
- min: 0,
|
|
|
- message: '请输入大于等于0的数字',
|
|
|
- trigger: 'blur'
|
|
|
- }
|
|
|
- ]
|
|
|
+ width: 120
|
|
|
},
|
|
|
{
|
|
|
- label: '订单编码',
|
|
|
- prop: 'orderCode',
|
|
|
+ label: '业务日期',
|
|
|
+ prop: 'businessDate',
|
|
|
+ type: 'datetime',
|
|
|
+ format: 'YYYY-MM-DD HH:mm:ss',
|
|
|
+ valueFormat: 'YYYY-MM-DD HH:mm:ss',
|
|
|
search: true,
|
|
|
- addDisplay: false,
|
|
|
- editDisplay: false
|
|
|
+ searchRange: true,
|
|
|
+ width: 170
|
|
|
},
|
|
|
{
|
|
|
- label: '客户名称',
|
|
|
- prop: 'customerName',
|
|
|
+ label: '组织名称',
|
|
|
+ prop: 'orgName',
|
|
|
search: true,
|
|
|
- rules: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请输入客户名称',
|
|
|
- trigger: 'blur'
|
|
|
- },
|
|
|
- {
|
|
|
- min: 2,
|
|
|
- max: 50,
|
|
|
- message: '客户名称长度必须在2到50个字符之间',
|
|
|
- trigger: 'blur'
|
|
|
- }
|
|
|
- ]
|
|
|
+ width: 120
|
|
|
},
|
|
|
{
|
|
|
label: '客户编码',
|
|
|
prop: 'customerCode',
|
|
|
search: true,
|
|
|
- rules: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请输入客户编码',
|
|
|
- trigger: 'blur'
|
|
|
- },
|
|
|
- {
|
|
|
- min: 2,
|
|
|
- max: 50,
|
|
|
- message: '客户编码长度必须在2到50个字符之间',
|
|
|
- trigger: 'blur'
|
|
|
- },
|
|
|
- {
|
|
|
- pattern: /^[a-zA-Z0-9_-]+$/,
|
|
|
- message: '客户编码只能包含字母、数字、下划线和中横线',
|
|
|
- trigger: 'blur'
|
|
|
- }
|
|
|
- ]
|
|
|
+ width: 140
|
|
|
},
|
|
|
{
|
|
|
- label: '税号',
|
|
|
- prop: 'taxNo',
|
|
|
- rules: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请输入税号',
|
|
|
- trigger: 'blur'
|
|
|
- }
|
|
|
- ]
|
|
|
+ label: '客户名称',
|
|
|
+ prop: 'customerName',
|
|
|
+ search: true,
|
|
|
+ width: 160
|
|
|
},
|
|
|
{
|
|
|
- label: '发票抬头',
|
|
|
- prop: 'invoiceTitle',
|
|
|
- rules: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请输入发票抬头',
|
|
|
- trigger: 'blur'
|
|
|
- }
|
|
|
- ]
|
|
|
+ label: '客户站点名称',
|
|
|
+ prop: 'custSiteName',
|
|
|
+ search: true,
|
|
|
+ width: 160
|
|
|
},
|
|
|
{
|
|
|
- label: '金额',
|
|
|
- prop: 'amount',
|
|
|
- slot: true,
|
|
|
- type: 'number',
|
|
|
- precision: 2,
|
|
|
- rules: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请输入金额',
|
|
|
- trigger: 'blur'
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'number',
|
|
|
- message: '请输入数字',
|
|
|
- trigger: 'blur'
|
|
|
- },
|
|
|
- {
|
|
|
- min: 0,
|
|
|
- message: '请输入大于等于0的数字',
|
|
|
- trigger: 'blur'
|
|
|
- }
|
|
|
- ]
|
|
|
+ label: '物料编码',
|
|
|
+ prop: 'itemCode',
|
|
|
+ search: true,
|
|
|
+ width: 140
|
|
|
},
|
|
|
{
|
|
|
- label: '税额',
|
|
|
- prop: 'taxAmount',
|
|
|
- slot: true,
|
|
|
- type: 'number',
|
|
|
- precision: 2,
|
|
|
- rules: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请输入税额',
|
|
|
- trigger: 'blur'
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'number',
|
|
|
- message: '请输入数字',
|
|
|
- trigger: 'blur'
|
|
|
- },
|
|
|
- {
|
|
|
- min: 0,
|
|
|
- message: '请输入大于等于0的数字',
|
|
|
- trigger: 'blur'
|
|
|
- }
|
|
|
- ]
|
|
|
+ label: '物料名称',
|
|
|
+ prop: 'itemName',
|
|
|
+ search: true,
|
|
|
+ width: 160
|
|
|
},
|
|
|
{
|
|
|
- label: '总金额',
|
|
|
- prop: 'totalAmount',
|
|
|
- slot: true,
|
|
|
- type: 'number',
|
|
|
- precision: 2,
|
|
|
- rules: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请输入总金额',
|
|
|
- trigger: 'blur'
|
|
|
- },
|
|
|
- {
|
|
|
- type: 'number',
|
|
|
- message: '请输入数字',
|
|
|
- trigger: 'blur'
|
|
|
- },
|
|
|
- {
|
|
|
- min: 0,
|
|
|
- message: '请输入大于等于0的数字',
|
|
|
- trigger: 'blur'
|
|
|
- }
|
|
|
- ]
|
|
|
+ label: '规格',
|
|
|
+ prop: 'specs',
|
|
|
+ width: 160
|
|
|
},
|
|
|
{
|
|
|
- label: '发票类型',
|
|
|
- prop: 'invoiceType',
|
|
|
- slot: true,
|
|
|
- type: 'select',
|
|
|
- search: true,
|
|
|
- width: 120,
|
|
|
- dicData: INVOICE_TYPE_OPTIONS,
|
|
|
- rules: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请选择发票类型',
|
|
|
- trigger: 'change'
|
|
|
- }
|
|
|
- ]
|
|
|
+ label: '数量',
|
|
|
+ prop: 'qty',
|
|
|
+ width: 100
|
|
|
},
|
|
|
{
|
|
|
- label: '开票状态',
|
|
|
- prop: 'invoiceStatus',
|
|
|
- slot: true,
|
|
|
- search: true,
|
|
|
- type: 'select',
|
|
|
- dicData: INVOICE_STATUS_OPTIONS,
|
|
|
- rules: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请选择开票状态',
|
|
|
- trigger: 'change'
|
|
|
- }
|
|
|
- ]
|
|
|
+ label: '含税单价',
|
|
|
+ prop: 'taxPrice',
|
|
|
+ width: 110
|
|
|
},
|
|
|
{
|
|
|
- label: '开票日期',
|
|
|
- prop: 'invoiceDate',
|
|
|
- type: 'date',
|
|
|
- format: 'yyyy-MM-dd',
|
|
|
- valueFormat: 'yyyy-MM-dd',
|
|
|
- rules: [
|
|
|
- {
|
|
|
- required: true,
|
|
|
- message: '请选择开票日期',
|
|
|
- trigger: 'change'
|
|
|
- }
|
|
|
- ]
|
|
|
+ label: '含税金额',
|
|
|
+ prop: 'puAmount',
|
|
|
+ width: 110
|
|
|
},
|
|
|
{
|
|
|
- label: '创建时间',
|
|
|
- prop: 'createTime',
|
|
|
- type: 'datetime',
|
|
|
- format: 'yyyy-MM-dd HH:mm:ss',
|
|
|
- valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
|
|
- addDisplay: false,
|
|
|
- editDisplay: false,
|
|
|
- width: 160
|
|
|
+ label: '应收不含税金额',
|
|
|
+ prop: 'arocMoneyNonTax',
|
|
|
+ width: 130
|
|
|
},
|
|
|
{
|
|
|
- label: '更新时间',
|
|
|
- prop: 'updateTime',
|
|
|
- type: 'datetime',
|
|
|
- format: 'yyyy-MM-dd HH:mm:ss',
|
|
|
- valueFormat: 'yyyy-MM-dd HH:mm:ss',
|
|
|
- addDisplay: false,
|
|
|
- editDisplay: false,
|
|
|
- width: 160
|
|
|
+ label: '应收税额',
|
|
|
+ prop: 'arocMoneyGoodsTax',
|
|
|
+ width: 110
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '应收含税金额',
|
|
|
+ prop: 'arocMoneyTotalMoney',
|
|
|
+ width: 130
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '开票不含税金额',
|
|
|
+ prop: 'arfcMoneyNonTax',
|
|
|
+ width: 130
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '开票税额',
|
|
|
+ prop: 'arfcMoneyGoodsTax',
|
|
|
+ width: 110
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '开票含税金额',
|
|
|
+ prop: 'arfcMoneyTotalMoney',
|
|
|
+ width: 130
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '单据状态',
|
|
|
+ prop: 'docStatus',
|
|
|
+ search: true,
|
|
|
+ width: 110
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: '模糊关键字',
|
|
|
+ prop: 'fuzzyValue',
|
|
|
+ search: true,
|
|
|
+ hide: true
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- computed: {
|
|
|
- ...mapGetters(['permission']),
|
|
|
-
|
|
|
- /**
|
|
|
- * 权限列表
|
|
|
- * @returns {Object} 权限配置对象
|
|
|
- */
|
|
|
- permissionList() {
|
|
|
- return {
|
|
|
- addBtn: this.vaildData(this.permission.order_invoice_add, false),
|
|
|
- viewBtn: this.vaildData(this.permission.order_invoice_view, false),
|
|
|
- editBtn: this.vaildData(this.permission.order_invoice_edit, false),
|
|
|
- delBtn: this.vaildData(this.permission.order_invoice_delete, false)
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 是否有选中的数据
|
|
|
- * @returns {boolean} 是否有选中数据
|
|
|
- */
|
|
|
- hasSelection() {
|
|
|
- return this.selectionList.length > 0
|
|
|
- }
|
|
|
+ created() {
|
|
|
+ this.onLoad()
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
/**
|
|
|
- * 获取发票类型标签文本
|
|
|
- * @param {string} type - 发票类型
|
|
|
- * @returns {string} 标签文本
|
|
|
+ * 前端分页应用
|
|
|
*/
|
|
|
- getInvoiceTypeLabel,
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取发票类型标签样式
|
|
|
- * @param {string} type - 发票类型
|
|
|
- * @returns {string} 标签样式类型
|
|
|
- */
|
|
|
- getInvoiceTypeTagType,
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取发票状态标签文本
|
|
|
- * @param {number} status - 发票状态
|
|
|
- * @returns {string} 标签文本
|
|
|
- */
|
|
|
- getInvoiceStatusLabel,
|
|
|
-
|
|
|
- /**
|
|
|
- * 获取发票状态标签样式
|
|
|
- * @param {number} status - 发票状态
|
|
|
- * @returns {string} 标签样式类型
|
|
|
- */
|
|
|
- getInvoiceStatusTagType,
|
|
|
-
|
|
|
- /**
|
|
|
- * 格式化金额显示
|
|
|
- * @param {string|number} amount - 金额
|
|
|
- * @returns {string} 格式化后的金额
|
|
|
- */
|
|
|
- formatAmount(amount) {
|
|
|
- if (!amount) return '0.00'
|
|
|
- return parseFloat(amount).toLocaleString('zh-CN', {
|
|
|
- minimumFractionDigits: 2,
|
|
|
- maximumFractionDigits: 2
|
|
|
- })
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 批量删除处理
|
|
|
- * @returns {Promise<void>}
|
|
|
- */
|
|
|
- async handleDelete() {
|
|
|
- if (!this.hasSelection) {
|
|
|
- this.$message.warning('请选择要删除的数据')
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- await this.$confirm('确定删除选中的发票信息吗?', '提示', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
- })
|
|
|
-
|
|
|
- const ids = this.selectionList.map(item => item.id).join(',')
|
|
|
- const res = await remove(ids)
|
|
|
-
|
|
|
- if (res.data.success) {
|
|
|
- this.$message.success('删除成功')
|
|
|
- await this.onLoad(this.page)
|
|
|
- } else {
|
|
|
- this.$message.error(res.data.msg || '删除失败')
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- if (error !== 'cancel') {
|
|
|
- console.error('删除发票失败:', error)
|
|
|
- this.$message.error('删除失败,请重试')
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 批量更新发票状态
|
|
|
- * @param {number} status - 新状态
|
|
|
- * @returns {Promise<void>}
|
|
|
- */
|
|
|
- async handleBatchUpdateStatus(status) {
|
|
|
- if (!this.hasSelection) {
|
|
|
- this.$message.warning('请选择要更新状态的数据')
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
- const statusText = getInvoiceStatusLabel(status)
|
|
|
-
|
|
|
- try {
|
|
|
- await this.$confirm(`确定将选中的发票状态更新为"${statusText}"吗?`, '提示', {
|
|
|
- confirmButtonText: '确定',
|
|
|
- cancelButtonText: '取消',
|
|
|
- type: 'warning'
|
|
|
- })
|
|
|
-
|
|
|
- const ids = this.selectionList.map(item => item.id)
|
|
|
- const res = await updateStatus(ids, status)
|
|
|
-
|
|
|
- if (res.data.success) {
|
|
|
- this.$message.success('状态更新成功')
|
|
|
- await this.onLoad(this.page)
|
|
|
- } else {
|
|
|
- this.$message.error(res.data.msg || '状态更新失败')
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- if (error !== 'cancel') {
|
|
|
- console.error('更新发票状态失败:', error)
|
|
|
- this.$message.error('状态更新失败,请重试')
|
|
|
- }
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 行删除处理
|
|
|
- * @param {InvoiceItem} row - 要删除的行数据
|
|
|
- * @param {number} index - 行索引
|
|
|
- * @returns {Promise<void>}
|
|
|
- */
|
|
|
- async rowDel(row, index) {
|
|
|
- try {
|
|
|
- const res = await remove(row.id)
|
|
|
- if (res.data.success) {
|
|
|
- this.$message.success('删除成功')
|
|
|
- this.onLoad(this.page)
|
|
|
- } else {
|
|
|
- this.$message.error(res.data.msg || '删除失败')
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.error('删除发票失败:', error)
|
|
|
- this.$message.error('删除失败,请重试')
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 行更新处理
|
|
|
- * @param {InvoiceForm} row - 更新的行数据
|
|
|
- * @param {number} index - 行索引
|
|
|
- * @param {Function} done - 完成回调
|
|
|
- * @param {Function} loading - 加载状态回调
|
|
|
- * @returns {Promise<void>}
|
|
|
- */
|
|
|
- async rowUpdate(row, index, done, loading) {
|
|
|
- try {
|
|
|
- loading()
|
|
|
- const res = await update(row)
|
|
|
-
|
|
|
- if (res.data.success) {
|
|
|
- this.$message.success('修改成功')
|
|
|
- done()
|
|
|
- this.onLoad(this.page)
|
|
|
- } else {
|
|
|
- this.$message.error(res.data.msg || '修改失败')
|
|
|
- loading()
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.error('修改发票失败:', error)
|
|
|
- this.$message.error('修改失败,请重试')
|
|
|
- loading()
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 行保存处理
|
|
|
- * @param {InvoiceForm} row - 保存的行数据
|
|
|
- * @param {Function} done - 完成回调
|
|
|
- * @param {Function} loading - 加载状态回调
|
|
|
- * @returns {Promise<void>}
|
|
|
- */
|
|
|
- async rowSave(row, done, loading) {
|
|
|
- try {
|
|
|
- loading()
|
|
|
- const res = await add(row)
|
|
|
-
|
|
|
- if (res.data.success) {
|
|
|
- this.$message.success('添加成功')
|
|
|
- done()
|
|
|
- this.onLoad(this.page)
|
|
|
- } else {
|
|
|
- this.$message.error(res.data.msg || '添加失败')
|
|
|
- loading()
|
|
|
- }
|
|
|
- } catch (error) {
|
|
|
- console.error('添加发票失败:', error)
|
|
|
- this.$message.error('添加失败,请重试')
|
|
|
- loading()
|
|
|
- }
|
|
|
+ applyPagination() {
|
|
|
+ const start = (this.page.currentPage - 1) * this.page.pageSize
|
|
|
+ const end = start + this.page.pageSize
|
|
|
+ this.page.total = this.rawData.length
|
|
|
+ this.data = this.rawData.slice(start, end)
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 搜索变化处理
|
|
|
- * @param {InvoiceQueryParams} params - 搜索参数
|
|
|
+ * @param {any} params - 搜索参数
|
|
|
* @param {Function} done - 完成回调
|
|
|
- * @returns {void}
|
|
|
*/
|
|
|
searchChange(params, done) {
|
|
|
this.query = params
|
|
|
- this.onLoad(this.page, params)
|
|
|
+ this.page.currentPage = 1
|
|
|
+ this.onLoad()
|
|
|
done()
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 搜索重置处理
|
|
|
- * @returns {void}
|
|
|
*/
|
|
|
searchReset() {
|
|
|
this.query = {}
|
|
|
- this.onLoad(this.page)
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 选择变化处理
|
|
|
- * @param {Array<InvoiceItem>} list - 选中的数据列表
|
|
|
- * @returns {void}
|
|
|
- */
|
|
|
- selectionChange(list) {
|
|
|
- this.selectionList = list
|
|
|
+ this.page.currentPage = 1
|
|
|
+ this.onLoad()
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 当前页变化处理
|
|
|
* @param {number} currentPage - 当前页码
|
|
|
- * @returns {void}
|
|
|
*/
|
|
|
currentChange(currentPage) {
|
|
|
this.page.currentPage = currentPage
|
|
|
+ if (this.serverPaging) {
|
|
|
+ this.onLoad()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.applyPagination()
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页大小变化处理
|
|
|
* @param {number} pageSize - 页大小
|
|
|
- * @returns {void}
|
|
|
*/
|
|
|
sizeChange(pageSize) {
|
|
|
this.page.pageSize = pageSize
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 刷新变化处理
|
|
|
- * @returns {void}
|
|
|
- */
|
|
|
- refreshChange() {
|
|
|
- this.onLoad(this.page, this.query)
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 打开前处理
|
|
|
- * @param {Function} done - 完成回调
|
|
|
- * @param {string} type - 操作类型
|
|
|
- * @returns {void}
|
|
|
- */
|
|
|
- beforeOpen(done, type) {
|
|
|
- done()
|
|
|
+ this.page.currentPage = 1
|
|
|
+ if (this.serverPaging) {
|
|
|
+ this.onLoad()
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.applyPagination()
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 加载数据
|
|
|
- * @param {PageInfo} page - 分页信息
|
|
|
- * @param {InvoiceQueryParams} params - 查询参数
|
|
|
* @returns {Promise<void>}
|
|
|
*/
|
|
|
- async onLoad(page, params = {}) {
|
|
|
+ async onLoad() {
|
|
|
this.loading = true
|
|
|
|
|
|
try {
|
|
|
- const res = await getList(page.currentPage || 1, page.pageSize || 10, {
|
|
|
- ...this.query,
|
|
|
- ...params
|
|
|
- })
|
|
|
+ const { businessDate, fuzzyValue, ...rest } = this.query || {}
|
|
|
+ /** @type {ARBillHeadStatusInquiryParams} */
|
|
|
+ const params = { ...rest }
|
|
|
|
|
|
- if (res.data.success) {
|
|
|
- const { records, total } = res.data.data
|
|
|
- this.data = records || []
|
|
|
- this.page.total = total || 0
|
|
|
- } else {
|
|
|
- this.$message.error(res.data.msg || '获取数据失败')
|
|
|
- this.data = []
|
|
|
- this.page.total = 0
|
|
|
+ params.pageNum = this.page.currentPage
|
|
|
+ params.pageSize = this.page.pageSize
|
|
|
+
|
|
|
+ if (params.docStatus !== undefined && params.docStatus !== null && params.docStatus !== '') {
|
|
|
+ params.docStatusList = String(params.docStatus)
|
|
|
+ delete params.docStatus
|
|
|
}
|
|
|
+
|
|
|
+ if (Array.isArray(businessDate) && businessDate.length === 2) {
|
|
|
+ params.businessDateStart = businessDate[0]
|
|
|
+ params.businessDateEnd = businessDate[1]
|
|
|
+ }
|
|
|
+
|
|
|
+ if (fuzzyValue) {
|
|
|
+ params.fuzzyValue = fuzzyValue
|
|
|
+ params.fuzzyFields = params.fuzzyFields || 'Customer_Name,Item_Name'
|
|
|
+ }
|
|
|
+
|
|
|
+ const res = await getARBillHeadStatusInquiry(params)
|
|
|
+ const respData = res && res.data ? res.data.data : null
|
|
|
+
|
|
|
+ const isPaged =
|
|
|
+ respData &&
|
|
|
+ typeof respData === 'object' &&
|
|
|
+ Array.isArray(respData.records) &&
|
|
|
+ typeof respData.total === 'number'
|
|
|
+
|
|
|
+ this.serverPaging = Boolean(isPaged)
|
|
|
+
|
|
|
+ if (isPaged) {
|
|
|
+ const records = respData.records
|
|
|
+ this.data = records.slice().sort((a, b) => {
|
|
|
+ const at = a && a.businessDate ? new Date(a.businessDate).getTime() : 0
|
|
|
+ const bt = b && b.businessDate ? new Date(b.businessDate).getTime() : 0
|
|
|
+ return bt - at
|
|
|
+ })
|
|
|
+ this.page.total = respData.total
|
|
|
+ this.rawData = []
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ const list = Array.isArray(respData) ? respData : []
|
|
|
+ this.rawData = list.slice().sort((a, b) => {
|
|
|
+ const at = a && a.businessDate ? new Date(a.businessDate).getTime() : 0
|
|
|
+ const bt = b && b.businessDate ? new Date(b.businessDate).getTime() : 0
|
|
|
+ return bt - at
|
|
|
+ })
|
|
|
+ this.applyPagination()
|
|
|
} catch (error) {
|
|
|
- console.error('获取发票列表失败:', error)
|
|
|
- this.$message.error('获取数据失败,请重试')
|
|
|
- this.data = []
|
|
|
- this.page.total = 0
|
|
|
+ console.error('加载发票及开票信息失败:', error)
|
|
|
+ this.serverPaging = false
|
|
|
+ this.rawData = []
|
|
|
+ this.applyPagination()
|
|
|
} finally {
|
|
|
this.loading = false
|
|
|
}
|
|
|
}
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 组件挂载后初始化
|
|
|
- * @returns {void}
|
|
|
- */
|
|
|
- mounted() {
|
|
|
- // 默认不加载数据,需要通过搜索条件触发
|
|
|
- this.loading = false
|
|
|
- this.data = []
|
|
|
- this.page.total = 0
|
|
|
}
|
|
|
}
|