From fe4ee6fcbb9fba06a99302958583e7ccab29e614 Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期五, 12 十一月 2021 16:18:45 +0800
Subject: [PATCH] add#129317: Add Date 過濾器

---
 PAMapp/plugins/filters/date.filter.ts |   25 +++++++++++++++++++++++++
 PAMapp/nuxt.config.js                 |    3 ++-
 PAMapp/pages/agentInfo/index.vue      |    4 ++--
 3 files changed, 29 insertions(+), 3 deletions(-)

diff --git a/PAMapp/nuxt.config.js b/PAMapp/nuxt.config.js
index 8fa0416..ee4a9dc 100644
--- a/PAMapp/nuxt.config.js
+++ b/PAMapp/nuxt.config.js
@@ -35,7 +35,8 @@
     '~/plugins/element-ui.js',
     { src: '~/plugins/vue-awesome-swiper.js', mode: 'client' },
     '~/plugins/service.ts',
-    '~/plugins/vue-scroll-picker'
+    '~/plugins/vue-scroll-picker',
+    '~/plugins/filters/date.filter.ts'
   ],
 
   // Auto import components: https://go.nuxtjs.dev/config-components
diff --git a/PAMapp/pages/agentInfo/index.vue b/PAMapp/pages/agentInfo/index.vue
index 91391e9..8804252 100644
--- a/PAMapp/pages/agentInfo/index.vue
+++ b/PAMapp/pages/agentInfo/index.vue
@@ -170,7 +170,7 @@
     phoneNumber: '0912345689',
     serveArea: '������������',
     companyAddress: '����縑蝢拙�敹�頝臭�畾�1���',
-    lastestLoginTime: new Date(),
+    lastestLoginTime: 'Sun Nov 15 1987 00:00:00 GMT+0800 (��������)',
     seniority: '4撟�2���',
     suitability: 53,
     evaluation: 31,
@@ -193,7 +193,7 @@
   phoneNumber: string;
   serveArea: string;
   companyAddress: string;
-  lastestLoginTime: Date;
+  lastestLoginTime: string;
   seniority: string;
   suitability: number;
   evaluation: number;
diff --git a/PAMapp/plugins/filters/date.filter.ts b/PAMapp/plugins/filters/date.filter.ts
new file mode 100644
index 0000000..7c3670c
--- /dev/null
+++ b/PAMapp/plugins/filters/date.filter.ts
@@ -0,0 +1,25 @@
+import Vue from 'vue'
+
+Vue.filter('formatDate', (value: string): string => {
+  const date = new Date(value);
+  const today = new Date();
+
+  const isToday = (compareDate: Date): boolean => {
+    return compareDate.getFullYear() === today.getFullYear()
+          && compareDate.getMonth() === today.getMonth()
+          && compareDate.getDate() === today.getDate();
+  };
+
+  const isThisYear = (compareDate: Date): boolean => {
+    return compareDate.getFullYear() === today.getFullYear();
+  }
+
+  if (isThisYear(date)) {
+    return isToday(date)
+          ? `隞予 ${date.getHours()}:${date.getMinutes()}`
+          : `${date.getMonth() + 1}���${date.getDate()}� ${date.getHours()}:${date.getMinutes()}`;
+  } else {
+    return `${date.getFullYear()}撟�${date.getMonth() + 1}���${date.getDate()}� ${date.getHours()}:${date.getMinutes()}`;
+  }
+
+})

--
Gitblit v1.8.0