From 7357a3709ebeb22f28c17a21f103d0c715213b34 Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期二, 31 十二月 2024 17:50:16 +0800 Subject: [PATCH] 编号、单位等 --- src/utils/istation/common.js | 37 +++++++++++++++++++++++++++++++------ 1 files changed, 31 insertions(+), 6 deletions(-) diff --git a/src/utils/istation/common.js b/src/utils/istation/common.js index b689e93..5d291f9 100644 --- a/src/utils/istation/common.js +++ b/src/utils/istation/common.js @@ -1,3 +1,5 @@ + +import moment from 'moment'; /** * 鑾峰彇璺濈date鐨刣ayCount澶╂暟( 骞存湀鏃�) * @param {*} dayCount 璺濈date鐨勫ぉ鏁� @@ -89,16 +91,16 @@ if (l) { a1 < 2 ? (b = - n / Math.pow(10, a1) - parseInt(n / Math.pow(10, a1)) > 0.5 - ? Math.round(n / Math.pow(10, a1)) * Math.pow(10, a1) - : (parseInt(n / Math.pow(10, a1)) + 0.5) * Math.pow(10, a1)) + n / Math.pow(10, a1) - parseInt(n / Math.pow(10, a1)) > 0.5 + ? Math.round(n / Math.pow(10, a1)) * Math.pow(10, a1) + : (parseInt(n / Math.pow(10, a1)) + 0.5) * Math.pow(10, a1)) : (b = Math.ceil(n / Math.pow(10, 1)) * Math.pow(10, 1)); } else { a1 < 2 ? (b = - n / Math.pow(10, a1) - parseInt(n / Math.pow(10, a1)) > 0.5 - ? (parseInt(n / Math.pow(10, a1)) + 0.5) * Math.pow(10, a1) - : Math.floor(n / Math.pow(10, a1)) * Math.pow(10, a1)) + n / Math.pow(10, a1) - parseInt(n / Math.pow(10, a1)) > 0.5 + ? (parseInt(n / Math.pow(10, a1)) + 0.5) * Math.pow(10, a1) + : Math.floor(n / Math.pow(10, a1)) * Math.pow(10, a1)) : (b = Math.floor(n / Math.pow(10, 1)) * Math.pow(10, 1)); } return l ? (-20 <= a1 ? +b.toFixed(a1 < 0 ? -a1 + 1 : 0) : b) : b; @@ -584,3 +586,26 @@ export const $ = (name) => document.querySelector(name); export const getContainerSize = (dom) => ({ width: dom.getBoundingClientRect().width, height: dom.getBoundingClientRect().height }); +export const getDefaultPeriod = (selectedPeriod) => { + // 鏍规嵁閫夋嫨鐨勫懆鏈熻繑鍥炵浉搴旂殑鏃ユ湡鑼冨洿 + let startDate, endDate; + switch (selectedPeriod) { + case '7Days': + startDate = moment().subtract(7, 'days'); + endDate = moment(); + break; + case 'ThisMonth': + startDate = moment().startOf('month'); + endDate = moment(); + break; + case 'ThisYear': + startDate = moment().startOf('year'); + endDate = moment(); + break; + default: + // 澶勭悊鏈尮閰嶅埌鐨勬儏鍐� + startDate = moment().subtract(7, 'days'); + endDate = moment(); + } + return { startDate, endDate }; +}; \ No newline at end of file -- Gitblit v1.9.3