|
|
@@ -1,26 +1,54 @@
|
|
|
+import {Notification} from 'element-ui'
|
|
|
+
|
|
|
export const timeChange = (dateString, formdate) => {
|
|
|
- if (dateString == null || dateString == '') {
|
|
|
- return '';
|
|
|
- }
|
|
|
- // new Date('');传入毫秒数,也可以得到普通的时间,再对date处理
|
|
|
- var date = new Date(parseInt(dateString));
|
|
|
- //获取年份,月份,天数,小时数,分钟数,小于10的显示01-09
|
|
|
- var year = date.getFullYear();
|
|
|
- var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
|
|
|
- var currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
|
|
|
- var hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
|
|
|
- var minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
|
|
|
- if (formdate == null || formdate == "yyyy-mm-dd HH:mm") {
|
|
|
- return year + "-" + month + "-" + currentDate + " " + hours + ":" + minutes;
|
|
|
- } else if (formdate == "yyyy-mm-dd") {
|
|
|
- return year + "-" + month + "-" + currentDate;
|
|
|
- } else if (formdate == "yyyy-mm") {
|
|
|
- return year + month;
|
|
|
- } else if (formdate == "mm-dd") {
|
|
|
- return month + "-" + currentDate;
|
|
|
- } else if (formdate == "HH:mm") {
|
|
|
- return hours + ":" + minutes;
|
|
|
- } else {
|
|
|
- return "";
|
|
|
- }
|
|
|
+ if (dateString == null || dateString == '') {
|
|
|
+ return ''
|
|
|
+ }
|
|
|
+ // new Date('');传入毫秒数,也可以得到普通的时间,再对date处理
|
|
|
+ var date = new Date(parseInt(dateString))
|
|
|
+ //获取年份,月份,天数,小时数,分钟数,小于10的显示01-09
|
|
|
+ var year = date.getFullYear()
|
|
|
+ var month = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1
|
|
|
+ var currentDate = date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
|
|
|
+ var hours = date.getHours() < 10 ? '0' + date.getHours() : date.getHours()
|
|
|
+ var minutes = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes()
|
|
|
+ if (formdate == null || formdate == 'yyyy-mm-dd HH:mm') {
|
|
|
+ return year + '-' + month + '-' + currentDate + ' ' + hours + ':' + minutes
|
|
|
+ } else if (formdate == 'yyyy-mm-dd') {
|
|
|
+ return year + '-' + month + '-' + currentDate
|
|
|
+ } else if (formdate == 'yyyy-mm') {
|
|
|
+ return year + month
|
|
|
+ } else if (formdate == 'mm-dd') {
|
|
|
+ return month + '-' + currentDate
|
|
|
+ } else if (formdate == 'HH:mm') {
|
|
|
+ return hours + ':' + minutes
|
|
|
+ } else {
|
|
|
+ return ''
|
|
|
+ }
|
|
|
+}
|
|
|
+export const notify = (type, msg, title) => {
|
|
|
+ var title = '消息'
|
|
|
+ switch (type) {
|
|
|
+ case 'success':
|
|
|
+ title = '成功'
|
|
|
+ break
|
|
|
+ case 'warning':
|
|
|
+ title = '提醒'
|
|
|
+ break
|
|
|
+ case 'info':
|
|
|
+ title = '消息'
|
|
|
+ break
|
|
|
+ case 'error':
|
|
|
+ title = '错误'
|
|
|
+ break
|
|
|
+ default:
|
|
|
+ title = '消息'
|
|
|
+ break
|
|
|
+ }
|
|
|
+ return Notification({
|
|
|
+ title: title,
|
|
|
+ message: msg,
|
|
|
+ type: type,
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
}
|