From 119c22f0185250640edf47ae7e099c008585f515 Mon Sep 17 00:00:00 2001 From: fudax Date: Sat, 15 Feb 2020 09:18:33 +0800 Subject: [PATCH] release v2.0 --- src/components/Home.vue | 27 +- .../center/message/MessageCenter.vue | 2 +- .../center/warning/WarningCenter.vue | 487 ++++++++++++++++ src/components/mgr/jobs/JobManage.vue | 2 +- src/components/query/RefusedDefect.vue | 2 +- .../sep/analysis/DefectDirection.vue | 468 ++++++++-------- src/components/sep/analysis/DefectFixCost.vue | 170 +++--- .../sep/analysis/DefectFixTimes.vue | 170 +++--- src/components/sep/analysis/DefectFounder.vue | 280 +++++----- .../sep/analysis/DefectInfluence.vue | 176 +++--- src/components/sep/analysis/DefectModule.vue | 280 +++++----- .../sep/analysis/DefectReqirements.vue | 280 +++++----- .../sep/analysis/DefectResponser.vue | 280 +++++----- .../sep/analysis/DefectVerifyCost.vue | 184 +++--- src/components/sep/opr/BuildList.vue | 2 +- src/components/sep/opr/Device.vue | 2 +- src/components/sep/opr/Instance.vue | 10 +- src/components/sep/opr/Problem.vue | 2 +- src/components/sep/opr/Sonar.vue | 24 +- src/components/sqa/bug/DefectDirection.vue | 522 +++++++++--------- src/components/sqa/bug/DefectFixCost.vue | 180 +++--- src/components/sqa/bug/DefectFixTimes.vue | 180 +++--- src/components/sqa/bug/DefectFoundPeriod.vue | 186 +++---- src/components/sqa/bug/DefectFounder.vue | 230 ++++---- src/components/sqa/bug/DefectInfluence.vue | 186 +++---- src/components/sqa/bug/DefectModule.vue | 230 ++++---- src/components/sqa/bug/DefectPriority.vue | 186 +++---- .../sqa/bug/DefectProducePeriod.vue | 186 +++---- src/components/sqa/bug/DefectReqirements.vue | 230 ++++---- src/components/sqa/bug/DefectResponser.vue | 230 ++++---- src/components/sqa/bug/DefectType.vue | 186 +++---- src/components/sqa/bug/DefectVerifyCost.vue | 180 +++--- src/components/sqa/cms/CmsManpower.vue | 182 +++--- src/components/sqa/cms/CmsModule.vue | 194 +++---- src/components/sqa/cms/CmsOffset.vue | 182 +++--- src/components/sqa/cms/CmsResponser.vue | 192 +++---- src/components/sqa/cms/CmsSpliter.vue | 192 +++---- src/components/sqa/cms/CmsStatus.vue | 202 +++---- src/components/sqa/pro/ProblemCloseCost.vue | 180 +++--- src/components/sqa/pro/ProblemImproveOne.vue | 260 ++++----- src/components/sqa/pro/ProblemImproveTwo.vue | 280 +++++----- src/components/sqa/pro/ProblemInfluence.vue | 186 +++---- src/components/sqa/pro/ProblemModule.vue | 230 ++++---- src/components/sqa/pro/ProblemPriority.vue | 186 +++---- src/components/sqa/pro/ProblemResolveCost.vue | 180 +++--- src/components/sqa/pro/ProblemResponser.vue | 230 ++++---- src/components/sqa/pro/ProblemStatus.vue | 238 ++++---- src/components/sqa/pro/ProblemSubmitter.vue | 230 ++++---- src/components/sqa/pro/ProblemTypeOne.vue | 258 ++++----- src/components/sqa/pro/ProblemTypeTwo.vue | 266 ++++----- src/components/sqa/req/ReqChange.vue | 182 +++--- src/components/sqa/req/ReqOffset.vue | 182 +++--- src/components/sqa/req/ReqPriority.vue | 202 +++---- src/components/sqa/req/ReqStatus.vue | 202 +++---- src/components/sqa/req/ReqSubmitter.vue | 242 ++++---- src/components/sqa/req/ReqType.vue | 202 +++---- src/components/sqa/tms/TmsManpower.vue | 182 +++--- src/components/sqa/tms/TmsOffset.vue | 182 +++--- src/components/sqa/tms/TmsResponser.vue | 192 +++---- src/components/sqa/tms/TmsSpliter.vue | 192 +++---- src/components/sqa/tms/TmsStatus.vue | 202 +++---- src/components/sqa/tms/TmsType.vue | 202 +++---- src/components/work/MissionPannel.vue | 10 +- src/components/work/Workbench.vue | 94 +++- src/router/index.js | 9 + src/util/cookie.js | 42 +- src/util/date.js | 356 ++++++------ 67 files changed, 6542 insertions(+), 5961 deletions(-) create mode 100644 src/components/center/warning/WarningCenter.vue diff --git a/src/components/Home.vue b/src/components/Home.vue index c4db4ac..0d472d7 100644 --- a/src/components/Home.vue +++ b/src/components/Home.vue @@ -1,13 +1,7 @@ + + + diff --git a/src/components/sqa/bug/DefectFixCost.vue b/src/components/sqa/bug/DefectFixCost.vue index bfdc54b..1d45c00 100644 --- a/src/components/sqa/bug/DefectFixCost.vue +++ b/src/components/sqa/bug/DefectFixCost.vue @@ -1,90 +1,90 @@ - - - + + + diff --git a/src/components/sqa/bug/DefectFixTimes.vue b/src/components/sqa/bug/DefectFixTimes.vue index 95f11ee..17367e6 100644 --- a/src/components/sqa/bug/DefectFixTimes.vue +++ b/src/components/sqa/bug/DefectFixTimes.vue @@ -1,90 +1,90 @@ - - - + + + diff --git a/src/components/sqa/bug/DefectFoundPeriod.vue b/src/components/sqa/bug/DefectFoundPeriod.vue index f1b225c..a3d6b53 100644 --- a/src/components/sqa/bug/DefectFoundPeriod.vue +++ b/src/components/sqa/bug/DefectFoundPeriod.vue @@ -1,93 +1,93 @@ - - - + + + diff --git a/src/components/sqa/bug/DefectFounder.vue b/src/components/sqa/bug/DefectFounder.vue index 99f9ba3..5d8735b 100644 --- a/src/components/sqa/bug/DefectFounder.vue +++ b/src/components/sqa/bug/DefectFounder.vue @@ -1,115 +1,115 @@ - - - + + + diff --git a/src/components/sqa/bug/DefectInfluence.vue b/src/components/sqa/bug/DefectInfluence.vue index b323f8d..6d71950 100644 --- a/src/components/sqa/bug/DefectInfluence.vue +++ b/src/components/sqa/bug/DefectInfluence.vue @@ -1,93 +1,93 @@ - - - + + + diff --git a/src/components/sqa/bug/DefectModule.vue b/src/components/sqa/bug/DefectModule.vue index f7a7d85..35425af 100644 --- a/src/components/sqa/bug/DefectModule.vue +++ b/src/components/sqa/bug/DefectModule.vue @@ -1,115 +1,115 @@ - - - + + + diff --git a/src/components/sqa/bug/DefectPriority.vue b/src/components/sqa/bug/DefectPriority.vue index 27f79fa..585a145 100644 --- a/src/components/sqa/bug/DefectPriority.vue +++ b/src/components/sqa/bug/DefectPriority.vue @@ -1,93 +1,93 @@ - - - + + + diff --git a/src/components/sqa/bug/DefectProducePeriod.vue b/src/components/sqa/bug/DefectProducePeriod.vue index 8246478..6e1a927 100644 --- a/src/components/sqa/bug/DefectProducePeriod.vue +++ b/src/components/sqa/bug/DefectProducePeriod.vue @@ -1,93 +1,93 @@ - - - + + + diff --git a/src/components/sqa/bug/DefectReqirements.vue b/src/components/sqa/bug/DefectReqirements.vue index 15f37c6..9d9a08c 100644 --- a/src/components/sqa/bug/DefectReqirements.vue +++ b/src/components/sqa/bug/DefectReqirements.vue @@ -1,115 +1,115 @@ - - - + + + diff --git a/src/components/sqa/bug/DefectResponser.vue b/src/components/sqa/bug/DefectResponser.vue index 9161556..bcc5c7c 100644 --- a/src/components/sqa/bug/DefectResponser.vue +++ b/src/components/sqa/bug/DefectResponser.vue @@ -1,115 +1,115 @@ - - - + + + diff --git a/src/components/sqa/bug/DefectType.vue b/src/components/sqa/bug/DefectType.vue index bdf5166..d9f25d6 100644 --- a/src/components/sqa/bug/DefectType.vue +++ b/src/components/sqa/bug/DefectType.vue @@ -1,93 +1,93 @@ - - - + + + diff --git a/src/components/sqa/bug/DefectVerifyCost.vue b/src/components/sqa/bug/DefectVerifyCost.vue index 645718a..4f78424 100644 --- a/src/components/sqa/bug/DefectVerifyCost.vue +++ b/src/components/sqa/bug/DefectVerifyCost.vue @@ -1,90 +1,90 @@ - - - + + + diff --git a/src/components/sqa/cms/CmsManpower.vue b/src/components/sqa/cms/CmsManpower.vue index 2d249e1..2b7a274 100644 --- a/src/components/sqa/cms/CmsManpower.vue +++ b/src/components/sqa/cms/CmsManpower.vue @@ -1,91 +1,91 @@ - - - + + + diff --git a/src/components/sqa/cms/CmsModule.vue b/src/components/sqa/cms/CmsModule.vue index 51c945d..662c7a1 100644 --- a/src/components/sqa/cms/CmsModule.vue +++ b/src/components/sqa/cms/CmsModule.vue @@ -1,97 +1,97 @@ - - - + + + diff --git a/src/components/sqa/cms/CmsOffset.vue b/src/components/sqa/cms/CmsOffset.vue index 2742856..319b937 100644 --- a/src/components/sqa/cms/CmsOffset.vue +++ b/src/components/sqa/cms/CmsOffset.vue @@ -1,91 +1,91 @@ - - - + + + diff --git a/src/components/sqa/cms/CmsResponser.vue b/src/components/sqa/cms/CmsResponser.vue index 1b4c74a..12bf636 100644 --- a/src/components/sqa/cms/CmsResponser.vue +++ b/src/components/sqa/cms/CmsResponser.vue @@ -1,96 +1,96 @@ - - - + + + diff --git a/src/components/sqa/cms/CmsSpliter.vue b/src/components/sqa/cms/CmsSpliter.vue index 41e03a6..725c53e 100644 --- a/src/components/sqa/cms/CmsSpliter.vue +++ b/src/components/sqa/cms/CmsSpliter.vue @@ -1,96 +1,96 @@ - - - + + + diff --git a/src/components/sqa/cms/CmsStatus.vue b/src/components/sqa/cms/CmsStatus.vue index 81c658a..50fcb95 100644 --- a/src/components/sqa/cms/CmsStatus.vue +++ b/src/components/sqa/cms/CmsStatus.vue @@ -1,101 +1,101 @@ - - - + + + diff --git a/src/components/sqa/pro/ProblemCloseCost.vue b/src/components/sqa/pro/ProblemCloseCost.vue index c6507c9..95c0fd1 100644 --- a/src/components/sqa/pro/ProblemCloseCost.vue +++ b/src/components/sqa/pro/ProblemCloseCost.vue @@ -1,90 +1,90 @@ - - - + + + diff --git a/src/components/sqa/pro/ProblemImproveOne.vue b/src/components/sqa/pro/ProblemImproveOne.vue index 492b849..16e69ad 100644 --- a/src/components/sqa/pro/ProblemImproveOne.vue +++ b/src/components/sqa/pro/ProblemImproveOne.vue @@ -1,130 +1,130 @@ - - - + + + diff --git a/src/components/sqa/pro/ProblemImproveTwo.vue b/src/components/sqa/pro/ProblemImproveTwo.vue index b800ac3..1f43989 100644 --- a/src/components/sqa/pro/ProblemImproveTwo.vue +++ b/src/components/sqa/pro/ProblemImproveTwo.vue @@ -1,140 +1,140 @@ - - - + + + diff --git a/src/components/sqa/pro/ProblemInfluence.vue b/src/components/sqa/pro/ProblemInfluence.vue index d6bbe7c..7e8185e 100644 --- a/src/components/sqa/pro/ProblemInfluence.vue +++ b/src/components/sqa/pro/ProblemInfluence.vue @@ -1,93 +1,93 @@ - - - + + + diff --git a/src/components/sqa/pro/ProblemModule.vue b/src/components/sqa/pro/ProblemModule.vue index b986e58..ff7508b 100644 --- a/src/components/sqa/pro/ProblemModule.vue +++ b/src/components/sqa/pro/ProblemModule.vue @@ -1,115 +1,115 @@ - - - + + + diff --git a/src/components/sqa/pro/ProblemPriority.vue b/src/components/sqa/pro/ProblemPriority.vue index b460423..88b0506 100644 --- a/src/components/sqa/pro/ProblemPriority.vue +++ b/src/components/sqa/pro/ProblemPriority.vue @@ -1,93 +1,93 @@ - - - + + + diff --git a/src/components/sqa/pro/ProblemResolveCost.vue b/src/components/sqa/pro/ProblemResolveCost.vue index aa46bcd..82b253d 100644 --- a/src/components/sqa/pro/ProblemResolveCost.vue +++ b/src/components/sqa/pro/ProblemResolveCost.vue @@ -1,90 +1,90 @@ - - - + + + diff --git a/src/components/sqa/pro/ProblemResponser.vue b/src/components/sqa/pro/ProblemResponser.vue index abd9ac5..b61ec86 100644 --- a/src/components/sqa/pro/ProblemResponser.vue +++ b/src/components/sqa/pro/ProblemResponser.vue @@ -1,115 +1,115 @@ - - - + + + diff --git a/src/components/sqa/pro/ProblemStatus.vue b/src/components/sqa/pro/ProblemStatus.vue index 10fce21..55b7c5e 100644 --- a/src/components/sqa/pro/ProblemStatus.vue +++ b/src/components/sqa/pro/ProblemStatus.vue @@ -1,119 +1,119 @@ - - - + + + diff --git a/src/components/sqa/pro/ProblemSubmitter.vue b/src/components/sqa/pro/ProblemSubmitter.vue index ebbea4a..c25d263 100644 --- a/src/components/sqa/pro/ProblemSubmitter.vue +++ b/src/components/sqa/pro/ProblemSubmitter.vue @@ -1,115 +1,115 @@ - - - + + + diff --git a/src/components/sqa/pro/ProblemTypeOne.vue b/src/components/sqa/pro/ProblemTypeOne.vue index 346129e..532dfef 100644 --- a/src/components/sqa/pro/ProblemTypeOne.vue +++ b/src/components/sqa/pro/ProblemTypeOne.vue @@ -1,129 +1,129 @@ - - - + + + diff --git a/src/components/sqa/pro/ProblemTypeTwo.vue b/src/components/sqa/pro/ProblemTypeTwo.vue index 0a9bcc5..cd15fd5 100644 --- a/src/components/sqa/pro/ProblemTypeTwo.vue +++ b/src/components/sqa/pro/ProblemTypeTwo.vue @@ -1,133 +1,133 @@ - - - + + + diff --git a/src/components/sqa/req/ReqChange.vue b/src/components/sqa/req/ReqChange.vue index 0035fe7..d39d4fb 100644 --- a/src/components/sqa/req/ReqChange.vue +++ b/src/components/sqa/req/ReqChange.vue @@ -1,91 +1,91 @@ - - - + + + diff --git a/src/components/sqa/req/ReqOffset.vue b/src/components/sqa/req/ReqOffset.vue index 4342348..d2edd19 100644 --- a/src/components/sqa/req/ReqOffset.vue +++ b/src/components/sqa/req/ReqOffset.vue @@ -1,91 +1,91 @@ - - - + + + diff --git a/src/components/sqa/req/ReqPriority.vue b/src/components/sqa/req/ReqPriority.vue index 384356a..f57358a 100644 --- a/src/components/sqa/req/ReqPriority.vue +++ b/src/components/sqa/req/ReqPriority.vue @@ -1,101 +1,101 @@ - - - + + + diff --git a/src/components/sqa/req/ReqStatus.vue b/src/components/sqa/req/ReqStatus.vue index e96f57d..e1e4e8a 100644 --- a/src/components/sqa/req/ReqStatus.vue +++ b/src/components/sqa/req/ReqStatus.vue @@ -1,101 +1,101 @@ - - - + + + diff --git a/src/components/sqa/req/ReqSubmitter.vue b/src/components/sqa/req/ReqSubmitter.vue index e540620..413714c 100644 --- a/src/components/sqa/req/ReqSubmitter.vue +++ b/src/components/sqa/req/ReqSubmitter.vue @@ -1,121 +1,121 @@ - - - + + + diff --git a/src/components/sqa/req/ReqType.vue b/src/components/sqa/req/ReqType.vue index 7f2d1c3..60cf8e7 100644 --- a/src/components/sqa/req/ReqType.vue +++ b/src/components/sqa/req/ReqType.vue @@ -1,101 +1,101 @@ - - - + + + diff --git a/src/components/sqa/tms/TmsManpower.vue b/src/components/sqa/tms/TmsManpower.vue index 5eb6bee..de77ae2 100644 --- a/src/components/sqa/tms/TmsManpower.vue +++ b/src/components/sqa/tms/TmsManpower.vue @@ -1,91 +1,91 @@ - - - + + + diff --git a/src/components/sqa/tms/TmsOffset.vue b/src/components/sqa/tms/TmsOffset.vue index 812c6e1..d9b8580 100644 --- a/src/components/sqa/tms/TmsOffset.vue +++ b/src/components/sqa/tms/TmsOffset.vue @@ -1,91 +1,91 @@ - - - + + + diff --git a/src/components/sqa/tms/TmsResponser.vue b/src/components/sqa/tms/TmsResponser.vue index ec8ad9d..847756f 100644 --- a/src/components/sqa/tms/TmsResponser.vue +++ b/src/components/sqa/tms/TmsResponser.vue @@ -1,96 +1,96 @@ - - - + + + diff --git a/src/components/sqa/tms/TmsSpliter.vue b/src/components/sqa/tms/TmsSpliter.vue index ef3c4be..b8b8f60 100644 --- a/src/components/sqa/tms/TmsSpliter.vue +++ b/src/components/sqa/tms/TmsSpliter.vue @@ -1,96 +1,96 @@ - - - + + + diff --git a/src/components/sqa/tms/TmsStatus.vue b/src/components/sqa/tms/TmsStatus.vue index ccfc1e1..2cecfd9 100644 --- a/src/components/sqa/tms/TmsStatus.vue +++ b/src/components/sqa/tms/TmsStatus.vue @@ -1,101 +1,101 @@ - - - + + + diff --git a/src/components/sqa/tms/TmsType.vue b/src/components/sqa/tms/TmsType.vue index feda16a..c272288 100644 --- a/src/components/sqa/tms/TmsType.vue +++ b/src/components/sqa/tms/TmsType.vue @@ -1,101 +1,101 @@ - - - + + + diff --git a/src/components/work/MissionPannel.vue b/src/components/work/MissionPannel.vue index ce564f3..5352d60 100644 --- a/src/components/work/MissionPannel.vue +++ b/src/components/work/MissionPannel.vue @@ -82,7 +82,7 @@
- {{ele.label}} + {{ele.label}}
计划人力:{{ele.manpower}} 人日 @@ -106,7 +106,7 @@ {{ele.label}} - {{ele.label}} + {{ele.label}}
计划人力:{{ele.manpower}} 人日 @@ -129,7 +129,7 @@
- {{ele.label}} + {{ele.label}}
计划人力:{{ele.manpower}} 人日 @@ -153,7 +153,7 @@ {{ele.label}} - {{ele.label}} + {{ele.label}}
计划人力:{{ele.manpower}} 人日 @@ -176,7 +176,7 @@
- {{ele.label}} + {{ele.label}}
计划人力:{{ele.manpower}} 人日 diff --git a/src/components/work/Workbench.vue b/src/components/work/Workbench.vue index d9e1f01..60f5f6f 100644 --- a/src/components/work/Workbench.vue +++ b/src/components/work/Workbench.vue @@ -71,6 +71,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -177,14 +251,14 @@
当前合计
- {{warning.count}} + {{warning.count}}
与我相关
- {{warning.mine}} + {{warning.mine}} {{warning.count == 0 ? '0.0%' : (warning.mine * 100 / warning.count).toFixed(1) + '%'}}
@@ -518,6 +592,8 @@ export default { showMyRequest: false, showAllCms: false, showMyCms: false, + showAllWarning: false, + showMyWarning: false, userProducts: [], release: { count: 0, @@ -888,12 +964,14 @@ export default { productWarningQuery() { let _self = this; - // _self.$axios.post("/dashboard/warning") - // .then(function(res) { - // let result = res.data; - // _self.warning.count = result.count; - // _self.warning.mine = result.mine; - // }) + _self.$axios.post("/dashboard/warning") + .then(function(res) { + let result = res.data; + _self.warning.count = result.count; + _self.warning.mine = result.mine; + _self.warning.allData = result.allData; + _self.warning.mineData = result.mineData; + }) }, productCodeHealthyQuery() { diff --git a/src/router/index.js b/src/router/index.js index 618c430..2d8d231 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -33,6 +33,15 @@ export default new Router({ }, component: resolve => require(['@/components/center/message/MessageCenter.vue'], resolve) }, + { + path: '/warning', + name: 'warning', + meta: { + requireAuth: true, + keepAlive: false + }, + component: resolve => require(['@/components/center/warning/WarningCenter.vue'], resolve) + }, { path: '/release', name: 'release', diff --git a/src/util/cookie.js b/src/util/cookie.js index b44dc91..b9b14c5 100644 --- a/src/util/cookie.js +++ b/src/util/cookie.js @@ -1,21 +1,21 @@ -export function getCookie(name) { - var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"); - if (arr = document.cookie.match(reg)) - return (arr[2]); - else - return null; -} - -export function setCookie(c_name, value, expireSeconds) { - var exdate = new Date(); - exdate.setSeconds(exdate.getSeconds() + expireSeconds); - document.cookie = c_name + "=" + escape(value) + ((expireSeconds == null) ? "" : ";expires=" + exdate.toGMTString()); -}; - -export function delCookie(name) { - var exp = new Date(); - exp.setTime(exp.getTime() - 1); - var cval = getCookie(name); - if (cval != null) - document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString(); -}; +export function getCookie(name) { + var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)"); + if (arr = document.cookie.match(reg)) + return (arr[2]); + else + return null; +} + +export function setCookie(c_name, value, expireSeconds) { + var exdate = new Date(); + exdate.setSeconds(exdate.getSeconds() + expireSeconds); + document.cookie = c_name + "=" + escape(value) + ((expireSeconds == null) ? "" : ";expires=" + exdate.toGMTString()); +}; + +export function delCookie(name) { + var exp = new Date(); + exp.setTime(exp.getTime() - 1); + var cval = getCookie(name); + if (cval != null) + document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString(); +}; diff --git a/src/util/date.js b/src/util/date.js index 1ed0cc0..8aeae12 100644 --- a/src/util/date.js +++ b/src/util/date.js @@ -1,178 +1,178 @@ -function dateFormat(date, fmt) { - if (/(y+)/.test(fmt)) { - fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length)); - } - let o = { - 'M+': date.getMonth() + 1, - 'd+': date.getDate(), - 'h+': date.getHours(), - 'H+': date.getHours(), - 'm+': date.getMinutes(), - 's+': date.getSeconds() - } - for (let k in o) { - let str = o[k] + ''; - if (new RegExp(`(${k})`).test(fmt)) { - fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : padLeftZero(str)); - } - } - return fmt; -}; - -function padLeftZero(str) { - return ('00' + str).substr(str.length); -} - -function strToDate(date_str) { - var str = date_str.split('-'); - return new Date(str[0], str[1] - 1, str[2]); -} - -function dateDiff(date_s, date_e) { - var dTotal = ""; - var y1 = date_s.getFullYear(); //返回表示月份的数字 (0,1,2,3...11) - var y2 = date_e.getFullYear(); - var m1 = date_s.getMonth(); //返回表示月份的数字 (0,1,2,3...11) - var m2 = date_e.getMonth() + (y2 - y1) * 12; - var w1 = date_s.getDay(); - var w2 = date_e.getDay(); //返回表示星期的某一天的數字 - var d1 = date_s.getDate(); //還回月份的某一天 (1...31) - var d2 = date_e.getDate(); - var st = date_s.getHours(); //時間的小時的字段 {0.....23} - var et = date_e.getHours(); - var min1 = date_s.getMinutes(); - var min2 = date_e.getMinutes(); - var dCount = 0; - var dMin = 0; - var dHour = 0; - var dWeek = 0; - var dt = 0; - try { - if (m2 - m1 > 0) { - for (var i = m1; i < m2; i++) { - //判断头尾月份总共多少天 - dt += Check_days(i); - } - dCount = dt + d2 - d1; - } else { - dCount = d2 - d1; //天數差 - } - - if (w2 - w1 <= 0 && dCount > 0) { - // 星期天 並且天數差大於0 - dWeek = 1; - } else if (dCount > 7) { //天數差 7天以上 - dWeek = parseInt(dCount / 7); - } - - dHour = et - st; //小時差 - dMin = min2 - min1; - if (min1 == '20') { - if (min2 == '20') { - dMin = (dMin) / 60; - } else { - dMin = (dMin + 20) / 60; - } - } else { - dMin = dMin / 60; - } - dTotal = (dCount - dWeek) * 8 + dHour + dMin; - //午休时间判断 - return (st < 12 && et > 12) ? dTotal - 1 : dTotal; - } catch (e) { - return e.message; - } -} - -function Check_days(v) { - var days = 0; - switch (v) { - case 0: - case 2: - case 4: - case 6: - case 7: - case 9: - case 11: - days = 31; - break; - case 1: - days = 28; - break; - case 3: - case 5: - case 8: - case 10: - days = 30; - break; - } - return days; -} - -function dateAdd (date, interval, number) { - var d = date; - var k = { - 'y': 'FullYear', - 'q': 'Month', - 'm': 'Month', - 'w': 'Date', - 'd': 'Date', - 'h': 'Hours', - 'n': 'Minutes', - 's': 'Seconds', - 'ms': 'MilliSeconds' - }; - var n = { - 'q': 3, - 'w': 7 - }; - eval('d.set' + k[interval] + '(d.get' + k[interval] + '()+' + ((n[interval] || 1) * number) + ')'); - return d; -} - -var pickOptions = { - shortcuts: [{ - text: "最近一周", - onClick(picker) { - const end = new Date(); - const start = new Date(); - start.setTime(start.getTime() - 3600 * 1000 * 24 * 7); - picker.$emit("pick", [start, end]); - } - }, - { - text: "今天", - onClick(picker) { - const end = new Date(); - const start = new Date(); - picker.$emit("pick", [start, end]); - } - }, - { - text: "最近一个月", - onClick(picker) { - const end = new Date(); - const start = new Date(); - start.setTime(start.getTime() - 3600 * 1000 * 24 * 30); - picker.$emit("pick", [start, end]); - } - }, - { - text: "最近三个月", - onClick(picker) { - const end = new Date(); - const start = new Date(); - start.setTime(start.getTime() - 3600 * 1000 * 24 * 90); - picker.$emit("pick", [start, end]); - } - } - ] -} - -export { - dateFormat, - dateDiff, - dateAdd, - strToDate, - pickOptions -} +function dateFormat(date, fmt) { + if (/(y+)/.test(fmt)) { + fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length)); + } + let o = { + 'M+': date.getMonth() + 1, + 'd+': date.getDate(), + 'h+': date.getHours(), + 'H+': date.getHours(), + 'm+': date.getMinutes(), + 's+': date.getSeconds() + } + for (let k in o) { + let str = o[k] + ''; + if (new RegExp(`(${k})`).test(fmt)) { + fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? str : padLeftZero(str)); + } + } + return fmt; +}; + +function padLeftZero(str) { + return ('00' + str).substr(str.length); +} + +function strToDate(date_str) { + var str = date_str.split('-'); + return new Date(str[0], str[1] - 1, str[2]); +} + +function dateDiff(date_s, date_e) { + var dTotal = ""; + var y1 = date_s.getFullYear(); //返回表示月份的数字 (0,1,2,3...11) + var y2 = date_e.getFullYear(); + var m1 = date_s.getMonth(); //返回表示月份的数字 (0,1,2,3...11) + var m2 = date_e.getMonth() + (y2 - y1) * 12; + var w1 = date_s.getDay(); + var w2 = date_e.getDay(); //返回表示星期的某一天的數字 + var d1 = date_s.getDate(); //還回月份的某一天 (1...31) + var d2 = date_e.getDate(); + var st = date_s.getHours(); //時間的小時的字段 {0.....23} + var et = date_e.getHours(); + var min1 = date_s.getMinutes(); + var min2 = date_e.getMinutes(); + var dCount = 0; + var dMin = 0; + var dHour = 0; + var dWeek = 0; + var dt = 0; + try { + if (m2 - m1 > 0) { + for (var i = m1; i < m2; i++) { + //判断头尾月份总共多少天 + dt += Check_days(i); + } + dCount = dt + d2 - d1; + } else { + dCount = d2 - d1; //天數差 + } + + if (w2 - w1 <= 0 && dCount > 0) { + // 星期天 並且天數差大於0 + dWeek = 1; + } else if (dCount > 7) { //天數差 7天以上 + dWeek = parseInt(dCount / 7); + } + + dHour = et - st; //小時差 + dMin = min2 - min1; + if (min1 == '20') { + if (min2 == '20') { + dMin = (dMin) / 60; + } else { + dMin = (dMin + 20) / 60; + } + } else { + dMin = dMin / 60; + } + dTotal = (dCount - dWeek) * 8 + dHour + dMin; + //午休时间判断 + return (st < 12 && et > 12) ? dTotal - 1 : dTotal; + } catch (e) { + return e.message; + } +} + +function Check_days(v) { + var days = 0; + switch (v) { + case 0: + case 2: + case 4: + case 6: + case 7: + case 9: + case 11: + days = 31; + break; + case 1: + days = 28; + break; + case 3: + case 5: + case 8: + case 10: + days = 30; + break; + } + return days; +} + +function dateAdd (date, interval, number) { + var d = date; + var k = { + 'y': 'FullYear', + 'q': 'Month', + 'm': 'Month', + 'w': 'Date', + 'd': 'Date', + 'h': 'Hours', + 'n': 'Minutes', + 's': 'Seconds', + 'ms': 'MilliSeconds' + }; + var n = { + 'q': 3, + 'w': 7 + }; + eval('d.set' + k[interval] + '(d.get' + k[interval] + '()+' + ((n[interval] || 1) * number) + ')'); + return d; +} + +var pickOptions = { + shortcuts: [{ + text: "最近一周", + onClick(picker) { + const end = new Date(); + const start = new Date(); + start.setTime(start.getTime() - 3600 * 1000 * 24 * 7); + picker.$emit("pick", [start, end]); + } + }, + { + text: "今天", + onClick(picker) { + const end = new Date(); + const start = new Date(); + picker.$emit("pick", [start, end]); + } + }, + { + text: "最近一个月", + onClick(picker) { + const end = new Date(); + const start = new Date(); + start.setTime(start.getTime() - 3600 * 1000 * 24 * 30); + picker.$emit("pick", [start, end]); + } + }, + { + text: "最近三个月", + onClick(picker) { + const end = new Date(); + const start = new Date(); + start.setTime(start.getTime() - 3600 * 1000 * 24 * 90); + picker.$emit("pick", [start, end]); + } + } + ] +} + +export { + dateFormat, + dateDiff, + dateAdd, + strToDate, + pickOptions +}