优化部分相同代码
This commit is contained in:
parent
8ec1578f50
commit
9d007e64f6
67
resources/assets/js/functions/web.js
vendored
67
resources/assets/js/functions/web.js
vendored
@ -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
|
||||
|
@ -8,7 +8,7 @@
|
||||
@on-visible-change="menuVisibleChange">
|
||||
<div :class="['manage-box-title', visibleMenu ? 'menu-visible' : '']">
|
||||
<div class="manage-box-avatar">
|
||||
<UserAvatar :userid="userId" :size="36" tooltip-disabled/>
|
||||
<UserAvatar :userid="userId" :size="36" tooltipDisabled/>
|
||||
</div>
|
||||
<span>{{userInfo.nickname}}</span>
|
||||
<div class="manage-box-arrow">
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
<!--时间/阅读-->
|
||||
<div v-if="msgData.created_at" class="dialog-foot">
|
||||
<div class="time">{{formatTime(msgData.created_at)}}</div>
|
||||
<div class="time">{{$A.formatTime(msgData.created_at)}}</div>
|
||||
<Poptip
|
||||
v-if="msgData.send > 1 || dialogType == 'group'"
|
||||
class="percent"
|
||||
@ -35,11 +35,11 @@
|
||||
<div slot="content" class="dialog-wrapper-read-poptip-content">
|
||||
<ul class="read">
|
||||
<li class="read-title"><em>{{readList.length}}</em>{{$L('已读')}}</li>
|
||||
<li v-for="item in readList"><UserAvatar :userid="item.userid" :size="26" show-name/></li>
|
||||
<li v-for="item in readList"><UserAvatar :userid="item.userid" :size="26" showName/></li>
|
||||
</ul>
|
||||
<ul class="unread">
|
||||
<li class="read-title"><em>{{unreadList.length}}</em>{{$L('未读')}}</li>
|
||||
<li v-for="item in unreadList"><UserAvatar :userid="item.userid" :size="26" show-name/></li>
|
||||
<li v-for="item in unreadList"><UserAvatar :userid="item.userid" :size="26" showName/></li>
|
||||
</ul>
|
||||
</div>
|
||||
<WCircle :percent="msgData.percentage" :size="14"/>
|
||||
@ -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 ""
|
||||
|
@ -39,7 +39,7 @@
|
||||
:class="{self:item.userid == userId, 'history-tip': topId == item.id}">
|
||||
<em v-if="topId == item.id" class="history-text">{{$L('历史消息')}}</em>
|
||||
<div class="dialog-avatar">
|
||||
<UserAvatar :userid="item.userid" :tooltip-disabled="item.userid == userId" :size="30"/>
|
||||
<UserAvatar :userid="item.userid" :tooltipDisabled="item.userid == userId" :size="30"/>
|
||||
</div>
|
||||
<DialogView :msg-data="item" :dialog-type="dialogData.type"/>
|
||||
</li>
|
||||
@ -49,7 +49,7 @@
|
||||
:key="'tmp_' + item.id"
|
||||
:class="{self:item.userid == userId}">
|
||||
<div class="dialog-avatar">
|
||||
<UserAvatar :userid="item.userid" :tooltip-disabled="item.userid == userId" :size="30"/>
|
||||
<UserAvatar :userid="item.userid" :tooltipDisabled="item.userid == userId" :size="30"/>
|
||||
</div>
|
||||
<DialogView :msg-data="item" :dialog-type="dialogData.type"/>
|
||||
</li>
|
||||
@ -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;
|
||||
|
@ -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)
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -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())];
|
||||
}
|
||||
}]
|
||||
|
@ -84,7 +84,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<template v-if="getOwner.length > 0">
|
||||
<UserAvatar v-for="item in getOwner" :key="item.userid" :userid="item.userid" :size="20" tooltip-disabled/>
|
||||
<UserAvatar v-for="item in getOwner" :key="item.userid" :userid="item.userid" :size="20" tooltipDisabled/>
|
||||
</template>
|
||||
<div v-else>--</div>
|
||||
</Poptip>
|
||||
@ -219,7 +219,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="user-list">
|
||||
<UserAvatar v-for="item in getOwner" :key="item.userid" :userid="item.userid" :size="28" :show-name="getOwner.length === 1" tooltip-disabled/>
|
||||
<UserAvatar v-for="item in getOwner" :key="item.userid" :userid="item.userid" :size="28" :showName="getOwner.length === 1" tooltipDisabled/>
|
||||
</div>
|
||||
</Poptip>
|
||||
</FormItem>
|
||||
@ -250,7 +250,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="getAssist.length > 0" class="user-list">
|
||||
<UserAvatar v-for="item in getAssist" :key="item.userid" :userid="item.userid" :size="28" :show-name="getAssist.length === 1"/>
|
||||
<UserAvatar v-for="item in getAssist" :key="item.userid" :userid="item.userid" :size="28" :showName="getAssist.length === 1" tooltipDisabled/>
|
||||
</div>
|
||||
<div v-else>--</div>
|
||||
</Poptip>
|
||||
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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)
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
@ -242,7 +242,7 @@
|
||||
<EAvatar class="avatar-text" icon="el-icon-s-custom"/>
|
||||
<span class="avatar-name">{{$L('所有人')}}</span>
|
||||
</div>
|
||||
<UserAvatar v-else :size="32" :userid="item.userid" show-name tooltip-disabled/>
|
||||
<UserAvatar v-else :size="32" :userid="item.userid" showName tooltipDisabled/>
|
||||
<Select v-model="item.permission" :placeholder="$L('权限')" @on-change="upShare(item)">
|
||||
<Option :value="1">{{ $L('读/写') }}</Option>
|
||||
<Option :value="0">{{ $L('只读') }}</Option>
|
||||
|
@ -41,7 +41,7 @@
|
||||
<div class="dialog-title">
|
||||
<span>{{dialog.name}}</span>
|
||||
<Icon v-if="dialog.type == 'user' && lastMsgReadDone(dialog.last_msg)" :type="lastMsgReadDone(dialog.last_msg)"/>
|
||||
<em v-if="dialog.last_at">{{formatTime(dialog.last_at)}}</em>
|
||||
<em v-if="dialog.last_at">{{$A.formatTime(dialog.last_at)}}</em>
|
||||
</div>
|
||||
<div class="dialog-text">{{formatLastMsg(dialog.last_msg)}}</div>
|
||||
</div>
|
||||
@ -287,19 +287,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 || '';
|
||||
},
|
||||
|
||||
formatLastMsg(data) {
|
||||
if ($A.isJson(data)) {
|
||||
switch (data.type) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user