Prechádzať zdrojové kódy

:art: 导出文件名字新增时分秒

limengbo 4 rokov pred
rodič
commit
88fceb27ff

+ 1 - 1
src/pages/mobile/Mobile.vue

@@ -278,7 +278,7 @@ export default {
     onExportExcel() {
       const nameList = this.efunChannelList.filter((item) => item.code === this.efunParams.channel)[0]
       const name = (nameList && nameList.name) || ''
-      const date = new Date().toLocaleDateString()
+      const date = formatDate(new Date(), 7)
       downTable('table', [
           {wch: 15}, // "characters"
           {wch: 6},

+ 1 - 1
src/pages/order/Order.vue

@@ -342,7 +342,7 @@ export default {
         const name = (nameList && nameList.title) || ''
         const list = this.productList.filter((item) => item.id === this.orderParams.packageId)[0]
         const productName = list && list.title ? '-' + list.title : ''
-        const date = new Date().toLocaleDateString()
+        const date = formatDate(new Date(), 7)
         downTable('table', [
           {wch: 15}, // "characters"
           {wch: 6},

+ 1 - 1
src/pages/skill/Skill.vue

@@ -600,7 +600,7 @@ export default {
         const name = (nameList && nameList.title) || ''
         const list = this.skillList.filter((item) => item.skillId === this.skillParams.skillId)[0] || ''
         const productName = list && list.skillName ? '-' + list.skillName : ''
-        const date = new Date().toLocaleDateString()
+        const date = formatDate(new Date(), 7)
         downTable('table', [
           {wch: 15}, // "characters"
           {wch: 6},

+ 1 - 1
src/pages/tv/TV.vue

@@ -277,7 +277,7 @@ export default {
     onExportExcel() {
       const nameList = this.efunChannelList.filter((item) => item.code === this.efunParams.channel)[0]
       const name = (nameList && nameList.name) || ''
-      const date = new Date().toLocaleDateString()
+      const date = formatDate(new Date(), 7)
         downTable('table', [
           {wch: 15}, // "characters"
           {wch: 6},

+ 11 - 14
src/utils/formatTime.js

@@ -7,20 +7,17 @@ function formatDate(time, flag) {
 	const day = tf(t.getDate());
 	const hour = tf(t.getHours());
 	const minute = tf(t.getMinutes());
-	//console.log( month + '月' + day + '日' + hour + ':' + minute);
-	if(flag == 1) {
-		return  month + '月' + day + '日' + ' ' + hour + ':' + minute;
-	}else if(flag == 2) {
-		return year + '-' + month + '-' + day
-	}else if(flag == 3){
-		return month + '-' + day + ' ' + hour + ':' + minute;
-	}else if( flag == 4) {
-		return year + '年' + month + '月' + day + '日';
-	}else if( flag == 5){
-		return day.toString().substring(1,2)
-	}else if( flag == 6) {
-		return month + '.' + day ;
-	}
+	const seconds = tf(t.getSeconds());
+	const map = new Map([
+		[1, month + '月' + day + '日' + ' ' + hour + ':' + minute],
+		[2, year + '-' + month + '-' + day],
+		[3, month + '-' + day + ' ' + hour + ':' + minute],
+		[4, year + '年' + month + '月' + day + '日'],
+		[5, day.toString().substring(1,2)],
+		[6, month + '.' + day],
+		[7, year + '年' + month + '月' + day + '日' + hour + '时' + minute + '分' + seconds + '秒']
+	])
+	return map.has(flag) && map.get(flag)
 }
 
 export default formatDate