From 06f92a4cd5cfd68c88380a2a13998f18ccc71d71 Mon Sep 17 00:00:00 2001 From: wuteng <419274783@qq.com> Date: Sat, 8 Nov 2025 10:56:01 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=B2=E5=BC=80=E7=A5=A8=E2=80=98=E5=AE=9A?= =?UTF-8?q?=E5=88=B6=E5=AF=BC=E5=87=BA=E2=80=99=EF=BC=8C=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/dateUtils.js | 17 ++++++ .../panel/CenterInvoiceHasOpenPanel.vue | 59 +++++++++++-------- 2 files changed, 53 insertions(+), 23 deletions(-) diff --git a/src/utils/dateUtils.js b/src/utils/dateUtils.js index fb209643..37c11ce5 100644 --- a/src/utils/dateUtils.js +++ b/src/utils/dateUtils.js @@ -98,4 +98,21 @@ export function getLastMonthYearMonth() { // 格式化为 YYYY-MM return `${lastYear}-${String(lastMonth + 1).padStart(2, "0")}`; +} +//判断开始和结束时间差是否超过一个月 +/** + * 给日期加一个月(自动处理月份边界和时间精度) + * @param {Date} date 原始日期 + * @returns {Date} 加一个月后的日期 + */ +function addOneMonth(date) { + const newDate = new Date(date); // 复制日期,避免修改原对象 + newDate.setMonth(newDate.getMonth() + 1); + // 自动处理边界(如1月31日→2月最后一天,12月→次年1月) + return newDate; +} +export function isOverOneMonth(startTime, endTime) { + // 较早日期加一个月后,与较晚日期比较 + const earlierPlusOneMonth = addOneMonth(startTime); + return endTime > earlierPlusOneMonth; } \ No newline at end of file diff --git a/src/views/emis/emisSettleInvoiceRecord/panel/CenterInvoiceHasOpenPanel.vue b/src/views/emis/emisSettleInvoiceRecord/panel/CenterInvoiceHasOpenPanel.vue index d1b42385..6a0f55b3 100644 --- a/src/views/emis/emisSettleInvoiceRecord/panel/CenterInvoiceHasOpenPanel.vue +++ b/src/views/emis/emisSettleInvoiceRecord/panel/CenterInvoiceHasOpenPanel.vue @@ -282,8 +282,7 @@ import { auditCenterNoPass,auditCenterPass,listEmisSettleInvoiceRecord, getEmisS import OpenBillForm from '@/views/emis/emisSettleInvoiceRecord/OpenBillForm'; import { listEmisSettleInvoiceChRecord } from "@/api/emis/emisSettleInvoiceChRecord"; import elDateAdvPicker from '@/components/DatePickerAdv/elDateAdvPicker'; -import {timeFormat} from '@/utils/dateUtils' - +import {timeFormat , isOverOneMonth} from '@/utils/dateUtils' export default { name: "CenterInvoiceHasOpenPanel", components: { elDateAdvPicker,OpenBillForm }, @@ -463,31 +462,31 @@ export default { /** 查询开票记录表列表 */ getList() { this.loading = true; - - // 按运单查询时的处理 - if(this.queryOrderType=="1"){ - this.queryParams.params.billCode=this.queryParams.queryCode; - this.queryParams.settleBillNo=null; - this.queryParams.invoiceNo=null; - } - else if(this.queryOrderType=="2"){ - this.queryParams.params.billCode=null; - this.queryParams.settleBillNo=this.queryParams.queryCode; - this.queryParams.invoiceNo=null; - } - else if(this.queryOrderType=="3"){ //发票查询 - this.queryParams.params.billCode=null; - this.queryParams.settleBillNo=null; - this.queryParams.invoiceNo=this.queryParams.queryCode; - } - + this.initQueryParams(); listEmisSettleInvoiceRecord(this.addDateRange(this.queryParams, this.dateTimeRange,'createTime')).then(response => { this.emisSettleInvoiceRecordList = response.rows; this.total = response.total; this.loading = false; }); }, - + initQueryParams() { + // 按运单查询时的处理 + if (this.queryOrderType == "1") { + this.queryParams.params.billCode = this.queryParams.queryCode; + this.queryParams.settleBillNo = null; + this.queryParams.invoiceNo = null; + } + else if (this.queryOrderType == "2") { + this.queryParams.params.billCode = null; + this.queryParams.settleBillNo = this.queryParams.queryCode; + this.queryParams.invoiceNo = null; + } + else if (this.queryOrderType == "3") { //发票查询 + this.queryParams.params.billCode = null; + this.queryParams.settleBillNo = null; + this.queryParams.invoiceNo = this.queryParams.queryCode; + } + }, /** 搜索按钮操作 */ handleQuery() { this.queryParams.pageNum = 1; @@ -647,9 +646,23 @@ export default { }, /** 导出按钮操作 */ handleCustomExport() { - + this.initQueryParams(); + let params = this.addDateRange(this.queryParams, this.dateTimeRange,'createTime'); + //判断时间必选 且开始和结束时间相差不超一个月 + if(!this.dateTimeRange){ + this.$modal.msgError('请选择开票时间'); + return; + } + let startTime=params.params.beginCreateTime; + let endTime=params.params.endCreateTime; + //判断开始时间和结束时间是否在一个月内 + if(isOverOneMonth(new Date(startTime),new Date(endTime))){ + this.$modal.msgError('开票时间不能超过一个月'); + return; + } this.download('emis/emisSettleInvoiceRecord/customExport', { - ...this.queryParams,pageSize:10000 + ...params, + pageSize:10000 }, `已开票列表.xlsx`) }, formatJson(filterVal, jsonData, resData) {