diff --git a/jshERP-web/src/utils/util.js b/jshERP-web/src/utils/util.js index 85501b3a..391440ae 100644 --- a/jshERP-web/src/utils/util.js +++ b/jshERP-web/src/utils/util.js @@ -548,6 +548,24 @@ export function getBeforeFormatDate(day) { return thirtyDaysAgo.getFullYear() + seperator1 + month + seperator1 + strDate } +/** + * js获取N月前的日期, 格式“yyyy-MM-dd” + */ +export function getPrevMonthFormatDate(monthNum) { + let prevMonth = new Date(); // 当前日期 + prevMonth.setMonth(prevMonth.getMonth() - monthNum); // 设置为前一个月 + let seperator1 = "-"; + let month = prevMonth.getMonth() + 1; + let strDate = prevMonth.getDate(); + if (month >= 1 && month <= 9) { + month = "0" + month; + } + if (strDate >= 0 && strDate <= 9) { + strDate = "0" + strDate; + } + return prevMonth.getFullYear() + seperator1 + month + seperator1 + strDate +} + /** * JS中根据指定值删除数组中的元素 * @param arrylist diff --git a/jshERP-web/src/views/bill/mixins/BillListMixin.js b/jshERP-web/src/views/bill/mixins/BillListMixin.js index 3d376458..0f747bef 100644 --- a/jshERP-web/src/views/bill/mixins/BillListMixin.js +++ b/jshERP-web/src/views/bill/mixins/BillListMixin.js @@ -3,7 +3,8 @@ import {getAction } from '@/api/manage' import { FormTypes } from '@/utils/JEditableTableUtil' import {findBillDetailByNumber, findBySelectSup, findBySelectCus, findBySelectRetail, getUserList, getAccount, waitBillCount, getCurrentSystemConfig, getPlatformConfigByKey} from '@/api/api' -import { getCheckFlag } from "@/utils/util" +import { getCheckFlag, getFormatDate, getPrevMonthFormatDate } from '@/utils/util' +import moment from 'moment' export const BillListMixin = { data () { @@ -13,6 +14,7 @@ export const BillListMixin = { /* 单据Excel是否开启 */ isShowExcel: false, waitTotal: 0, + dateFormat: 'YYYY-MM-DD', billExcelUrl: '', supList: [], cusList: [], @@ -23,6 +25,11 @@ export const BillListMixin = { settingDataIndex:[], // 实际列 columns:[], + queryParam: { + beginTime: getPrevMonthFormatDate(3), + endTime: getFormatDate(), + createTimeRange: [moment(getPrevMonthFormatDate(3)), moment(getFormatDate())] + } } }, computed: { @@ -105,13 +112,17 @@ export const BillListMixin = { searchReset() { this.queryParam = { type: this.queryParam.type, - subType: this.queryParam.subType + subType: this.queryParam.subType, + beginTime: getPrevMonthFormatDate(3), + endTime: getFormatDate(), + createTimeRange: [moment(getPrevMonthFormatDate(3)), moment(getFormatDate())] } this.loadData(1); }, onDateChange: function (value, dateString) { this.queryParam.beginTime=dateString[0]; this.queryParam.endTime=dateString[1]; + this.queryParam.createTimeRange = [moment(dateString[0]), moment(dateString[1])] }, onDateOk(value) { console.log(value); diff --git a/jshERP-web/src/views/financial/mixins/FinancialListMixin.js b/jshERP-web/src/views/financial/mixins/FinancialListMixin.js index b3bbc992..ac21577a 100644 --- a/jshERP-web/src/views/financial/mixins/FinancialListMixin.js +++ b/jshERP-web/src/views/financial/mixins/FinancialListMixin.js @@ -1,7 +1,8 @@ import {findFinancialDetailByNumber, findBySelectSup, findBySelectCus, findBySelectOrgan, findBySelectRetail, getUserList, getPersonByType, getAccount, getCurrentSystemConfig, getPlatformConfigByKey} from '@/api/api' -import { getCheckFlag } from "@/utils/util" +import { getCheckFlag, getFormatDate, getPrevMonthFormatDate } from '@/utils/util' import Vue from 'vue' +import moment from 'moment' export const FinancialListMixin = { data () { @@ -18,7 +19,12 @@ export const FinancialListMixin = { retailList: [], userList: [], personList: [], - accountList: [] + accountList: [], + queryParam: { + beginTime: getPrevMonthFormatDate(3), + endTime: getFormatDate(), + createTimeRange: [moment(getPrevMonthFormatDate(3)), moment(getFormatDate())] + } } }, computed: { @@ -83,7 +89,10 @@ export const FinancialListMixin = { }, searchReset() { this.queryParam = { - type: this.queryParam.type + type: this.queryParam.type, + beginTime: getPrevMonthFormatDate(3), + endTime: getFormatDate(), + createTimeRange: [moment(getPrevMonthFormatDate(3)), moment(getFormatDate())] } this.loadData(1); }, @@ -161,6 +170,7 @@ export const FinancialListMixin = { onDateChange: function (value, dateString) { this.queryParam.beginTime=dateString[0]; this.queryParam.endTime=dateString[1]; + this.queryParam.createTimeRange = [moment(dateString[0]), moment(dateString[1])] }, onDateOk(value) { console.log(value);