diff --git a/resources/assets/js/functions/web.js b/resources/assets/js/functions/web.js index 658da041..11552679 100755 --- a/resources/assets/js/functions/web.js +++ b/resources/assets/js/functions/web.js @@ -76,6 +76,73 @@ } }, + /** + * 格式化时间 + * @param date + * @returns {*|string} + */ + formatTime(date) { + let time = Math.round($A.Date(date).getTime() / 1000), + string = ''; + if ($A.formatDate('Ymd') === $A.formatDate('Ymd', time)) { + string = $A.formatDate('H:i', time) + } else if ($A.formatDate('Y') === $A.formatDate('Y', time)) { + string = $A.formatDate('m-d', time) + } else { + string = $A.formatDate('Y-m-d', time) + } + return string || ''; + }, + + /** + * 小于9补0 + * @param val + * @returns {number|string} + */ + formatBit(val) { + val = +val + return val > 9 ? val : '0' + val + }, + + /** + * 秒转时间 + * @param second + * @returns {string} + */ + formatSeconds(second) { + let duration + let days = Math.floor(second / 86400); + let hours = Math.floor((second % 86400) / 3600); + let minutes = Math.floor(((second % 86400) % 3600) / 60); + let seconds = Math.floor(((second % 86400) % 3600) % 60); + if (days > 0) { + if (hours > 0) duration = days + "d," + this.formatBit(hours) + "h"; + else if (minutes > 0) duration = days + "d," + this.formatBit(minutes) + "min"; + else if (seconds > 0) duration = days + "d," + this.formatBit(seconds) + "s"; + else duration = days + "d"; + } + else if (hours > 0) duration = this.formatBit(hours) + ":" + this.formatBit(minutes) + ":" + this.formatBit(seconds); + else if (minutes > 0) duration = this.formatBit(minutes) + ":" + this.formatBit(seconds); + else if (seconds > 0) duration = this.formatBit(seconds) + "s"; + return duration; + }, + + /** + * 倒计时格式 + * @param date + * @param nowTime + * @returns {string|*} + */ + countDownFormat(date, nowTime) { + let time = Math.round(this.Date(date).getTime() / 1000) - nowTime; + if (time < 86400 * 7 && time > 0 ) { + return this.formatSeconds(time); + } else if (time <= 0) { + return '-' + this.formatSeconds(time * -1); + } + return this.formatTime(date) + }, + /** * 获取一些指定时间 * @param str diff --git a/resources/assets/js/pages/manage.vue b/resources/assets/js/pages/manage.vue index 39dd2137..f018c572 100644 --- a/resources/assets/js/pages/manage.vue +++ b/resources/assets/js/pages/manage.vue @@ -8,7 +8,7 @@ @on-visible-change="menuVisibleChange">
- +
{{userInfo.nickname}}
diff --git a/resources/assets/js/pages/manage/components/DialogView.vue b/resources/assets/js/pages/manage/components/DialogView.vue index 6bfb7d64..dd248e39 100644 --- a/resources/assets/js/pages/manage/components/DialogView.vue +++ b/resources/assets/js/pages/manage/components/DialogView.vue @@ -23,7 +23,7 @@
-
{{formatTime(msgData.created_at)}}
+
{{$A.formatTime(msgData.created_at)}}
  • {{readList.length}}{{$L('已读')}}
  • -
  • +
  • {{unreadList.length}}{{$L('未读')}}
  • -
  • +
@@ -129,19 +129,6 @@ export default { }); }, - formatTime(date) { - let time = Math.round($A.Date(date).getTime() / 1000), - string = ''; - if ($A.formatDate('Ymd') === $A.formatDate('Ymd', time)) { - string = $A.formatDate('H:i', time) - } else if ($A.formatDate('Y') === $A.formatDate('Y', time)) { - string = $A.formatDate('m-d', time) - } else { - string = $A.formatDate('Y-m-d', time) - } - return string || ''; - }, - textMsg(text) { if (!text) { return "" diff --git a/resources/assets/js/pages/manage/components/DialogWrapper.vue b/resources/assets/js/pages/manage/components/DialogWrapper.vue index bed2e394..ecaeaa41 100644 --- a/resources/assets/js/pages/manage/components/DialogWrapper.vue +++ b/resources/assets/js/pages/manage/components/DialogWrapper.vue @@ -39,7 +39,7 @@ :class="{self:item.userid == userId, 'history-tip': topId == item.id}"> {{$L('历史消息')}}
- +
@@ -49,7 +49,7 @@ :key="'tmp_' + item.id" :class="{self:item.userid == userId}">
- +
@@ -358,19 +358,6 @@ export default { this.$emit("on-active"); }, - formatTime(date) { - let time = Math.round($A.Date(date).getTime() / 1000), - string = ''; - if ($A.formatDate('Ymd') === $A.formatDate('Ymd', time)) { - string = $A.formatDate('H:i', time) - } else if ($A.formatDate('Y') === $A.formatDate('Y', time)) { - string = $A.formatDate('m-d', time) - } else { - string = $A.formatDate('Y-m-d', time) - } - return string || ''; - }, - openProject() { if (!this.dialogData.group_info) { return; diff --git a/resources/assets/js/pages/manage/components/ProjectList.vue b/resources/assets/js/pages/manage/components/ProjectList.vue index 98bb1027..a2cf6fb4 100644 --- a/resources/assets/js/pages/manage/components/ProjectList.vue +++ b/resources/assets/js/pages/manage/components/ProjectList.vue @@ -1298,51 +1298,9 @@ export default { this.tempShowTasks = []; }, - formatTime(date) { - let time = Math.round($A.Date(date).getTime() / 1000), - string = ''; - if ($A.formatDate('Ymd') === $A.formatDate('Ymd', time)) { - string = $A.formatDate('H:i', time) - } else if ($A.formatDate('Y') === $A.formatDate('Y', time)) { - string = $A.formatDate('m-d', time) - } else { - string = $A.formatDate('Y-m-d', time) - } - return string || ''; - }, - - formatBit(val) { - val = +val - return val > 9 ? val : '0' + val - }, - - formatSeconds(second) { - let duration - let days = Math.floor(second / 86400); - let hours = Math.floor((second % 86400) / 3600); - let minutes = Math.floor(((second % 86400) % 3600) / 60); - let seconds = Math.floor(((second % 86400) % 3600) % 60); - if (days > 0) { - if (hours > 0) duration = days + "d," + this.formatBit(hours) + "h"; - else if (minutes > 0) duration = days + "d," + this.formatBit(minutes) + "min"; - else if (seconds > 0) duration = days + "d," + this.formatBit(seconds) + "s"; - else duration = days + "d"; - } - else if (hours > 0) duration = this.formatBit(hours) + ":" + this.formatBit(minutes) + ":" + this.formatBit(seconds); - else if (minutes > 0) duration = this.formatBit(minutes) + ":" + this.formatBit(seconds); - else if (seconds > 0) duration = this.formatBit(seconds) + "s"; - return duration; - }, - expiresFormat(date) { - let time = Math.round($A.Date(date).getTime() / 1000) - this.nowTime; - if (time < 86400 * 7 && time > 0 ) { - return this.formatSeconds(time); - } else if (time <= 0) { - return '-' + this.formatSeconds(time * -1); - } - return this.formatTime(date) - } + return $A.countDownFormat(date, this.nowTime) + }, } } diff --git a/resources/assets/js/pages/manage/components/TaskAdd.vue b/resources/assets/js/pages/manage/components/TaskAdd.vue index 156b60d3..5a48d7c8 100644 --- a/resources/assets/js/pages/manage/components/TaskAdd.vue +++ b/resources/assets/js/pages/manage/components/TaskAdd.vue @@ -302,21 +302,21 @@ export default { text: this.$L('3天'), value() { let e = new Date(); - e.setDate(e.getDate() + 3); + e.setDate(e.getDate() + 2); return [new Date(), lastSecond(e.getTime())]; } }, { text: this.$L('5天'), value() { let e = new Date(); - e.setDate(e.getDate() + 5); + e.setDate(e.getDate() + 4); return [new Date(), lastSecond(e.getTime())]; } }, { text: this.$L('7天'), value() { let e = new Date(); - e.setDate(e.getDate() + 7); + e.setDate(e.getDate() + 6); return [new Date(), lastSecond(e.getTime())]; } }] diff --git a/resources/assets/js/pages/manage/components/TaskDetail.vue b/resources/assets/js/pages/manage/components/TaskDetail.vue index 99a9eb6a..3eb70990 100644 --- a/resources/assets/js/pages/manage/components/TaskDetail.vue +++ b/resources/assets/js/pages/manage/components/TaskDetail.vue @@ -84,7 +84,7 @@
--
@@ -219,7 +219,7 @@
- +
@@ -250,7 +250,7 @@
- +
--
@@ -727,21 +727,21 @@ export default { text: this.$L('3天'), value() { let e = new Date(); - e.setDate(e.getDate() + 3); + e.setDate(e.getDate() + 2); return [new Date(), lastSecond(e.getTime())]; } }, { text: this.$L('5天'), value() { let e = new Date(); - e.setDate(e.getDate() + 5); + e.setDate(e.getDate() + 4); return [new Date(), lastSecond(e.getTime())]; } }, { text: this.$L('7天'), value() { let e = new Date(); - e.setDate(e.getDate() + 7); + e.setDate(e.getDate() + 6); return [new Date(), lastSecond(e.getTime())]; } }] @@ -752,50 +752,8 @@ export default { this.innerHeight = Math.min(1100, window.innerHeight); }, - formatTime(date) { - let time = Math.round($A.Date(date).getTime() / 1000), - string = ''; - if ($A.formatDate('Ymd') === $A.formatDate('Ymd', time)) { - string = $A.formatDate('H:i', time) - } else if ($A.formatDate('Y') === $A.formatDate('Y', time)) { - string = $A.formatDate('m-d', time) - } else { - string = $A.formatDate('Y-m-d', time) - } - return string || ''; - }, - - formatBit(val) { - val = +val - return val > 9 ? val : '0' + val - }, - - formatSeconds(second) { - let duration - let days = Math.floor(second / 86400); - let hours = Math.floor((second % 86400) / 3600); - let minutes = Math.floor(((second % 86400) % 3600) / 60); - let seconds = Math.floor(((second % 86400) % 3600) % 60); - if (days > 0) { - if (hours > 0) duration = days + "d," + this.formatBit(hours) + "h"; - else if (minutes > 0) duration = days + "d," + this.formatBit(minutes) + "min"; - else if (seconds > 0) duration = days + "d," + this.formatBit(seconds) + "s"; - else duration = days + "d"; - } - else if (hours > 0) duration = this.formatBit(hours) + ":" + this.formatBit(minutes) + ":" + this.formatBit(seconds); - else if (minutes > 0) duration = this.formatBit(minutes) + ":" + this.formatBit(seconds); - else if (seconds > 0) duration = this.formatBit(seconds) + "s"; - return duration; - }, - expiresFormat(date) { - let time = Math.round($A.Date(date).getTime() / 1000) - this.nowTime; - if (time < 86400 * 7 && time > 0 ) { - return this.formatSeconds(time); - } else if (time <= 0) { - return '-' + this.formatSeconds(time * -1); - } - return this.formatTime(date) + return $A.countDownFormat(date, this.nowTime) }, onNameKeydown(e) { diff --git a/resources/assets/js/pages/manage/components/TaskRow.vue b/resources/assets/js/pages/manage/components/TaskRow.vue index c41013af..3e3ed726 100644 --- a/resources/assets/js/pages/manage/components/TaskRow.vue +++ b/resources/assets/js/pages/manage/components/TaskRow.vue @@ -262,50 +262,8 @@ export default { }); }, - formatTime(date) { - let time = Math.round($A.Date(date).getTime() / 1000), - string = ''; - if ($A.formatDate('Ymd') === $A.formatDate('Ymd', time)) { - string = $A.formatDate('H:i', time) - } else if ($A.formatDate('Y') === $A.formatDate('Y', time)) { - string = $A.formatDate('m-d', time) - } else { - string = $A.formatDate('Y-m-d', time) - } - return string || ''; - }, - - formatBit(val) { - val = +val - return val > 9 ? val : '0' + val - }, - - formatSeconds(second) { - let duration - let days = Math.floor(second / 86400); - let hours = Math.floor((second % 86400) / 3600); - let minutes = Math.floor(((second % 86400) % 3600) / 60); - let seconds = Math.floor(((second % 86400) % 3600) % 60); - if (days > 0) { - if (hours > 0) duration = days + "d," + this.formatBit(hours) + "h"; - else if (minutes > 0) duration = days + "d," + this.formatBit(minutes) + "min"; - else if (seconds > 0) duration = days + "d," + this.formatBit(seconds) + "s"; - else duration = days + "d"; - } - else if (hours > 0) duration = this.formatBit(hours) + ":" + this.formatBit(minutes) + ":" + this.formatBit(seconds); - else if (minutes > 0) duration = this.formatBit(minutes) + ":" + this.formatBit(seconds); - else if (seconds > 0) duration = this.formatBit(seconds) + "s"; - return duration; - }, - expiresFormat(date) { - let time = Math.round($A.Date(date).getTime() / 1000) - this.nowTime; - if (time < 86400 * 7 && time > 0 ) { - return this.formatSeconds(time); - } else if (time <= 0) { - return '-' + this.formatSeconds(time * -1); - } - return this.formatTime(date) + return $A.countDownFormat(date, this.nowTime) }, completeAtFormat(date) { diff --git a/resources/assets/js/pages/manage/dashboard.vue b/resources/assets/js/pages/manage/dashboard.vue index 3f325c91..bafb00e9 100644 --- a/resources/assets/js/pages/manage/dashboard.vue +++ b/resources/assets/js/pages/manage/dashboard.vue @@ -272,51 +272,9 @@ export default { }); }, - formatTime(date) { - let time = Math.round($A.Date(date).getTime() / 1000), - string = ''; - if ($A.formatDate('Ymd') === $A.formatDate('Ymd', time)) { - string = $A.formatDate('H:i', time) - } else if ($A.formatDate('Y') === $A.formatDate('Y', time)) { - string = $A.formatDate('m-d', time) - } else { - string = $A.formatDate('Y-m-d', time) - } - return string || ''; - }, - - formatBit(val) { - val = +val - return val > 9 ? val : '0' + val - }, - - formatSeconds(second) { - let duration - let days = Math.floor(second / 86400); - let hours = Math.floor((second % 86400) / 3600); - let minutes = Math.floor(((second % 86400) % 3600) / 60); - let seconds = Math.floor(((second % 86400) % 3600) % 60); - if (days > 0) { - if (hours > 0) duration = days + "d," + this.formatBit(hours) + "h"; - else if (minutes > 0) duration = days + "d," + this.formatBit(minutes) + "min"; - else if (seconds > 0) duration = days + "d," + this.formatBit(seconds) + "s"; - else duration = days + "d"; - } - else if (hours > 0) duration = this.formatBit(hours) + ":" + this.formatBit(minutes) + ":" + this.formatBit(seconds); - else if (minutes > 0) duration = this.formatBit(minutes) + ":" + this.formatBit(seconds); - else if (seconds > 0) duration = this.formatBit(seconds) + "s"; - return duration; - }, - expiresFormat(date) { - let time = Math.round($A.Date(date).getTime() / 1000) - this.nowTime; - if (time < 86400 * 7 && time > 0 ) { - return this.formatSeconds(time); - } else if (time <= 0) { - return '-' + this.formatSeconds(time * -1); - } - return this.formatTime(date) - } + return $A.countDownFormat(date, this.nowTime) + }, } } diff --git a/resources/assets/js/pages/manage/file.vue b/resources/assets/js/pages/manage/file.vue index e2394466..572d8cb5 100644 --- a/resources/assets/js/pages/manage/file.vue +++ b/resources/assets/js/pages/manage/file.vue @@ -242,7 +242,7 @@ {{$L('所有人')}} - +