保誠-保戶業務員媒合平台
Tomas
2021-11-12 fe4ee6fcbb9fba06a99302958583e7ccab29e614
add#129317: Add Date 過濾器
修改2個檔案
新增1個檔案
32 ■■■■■ 已變更過的檔案
PAMapp/nuxt.config.js 3 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/pages/agentInfo/index.vue 4 ●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
PAMapp/plugins/filters/date.filter.ts 25 ●●●●● 修補檔 | 檢視 | 原始 | 究查 | 歷程
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
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;
PAMapp/plugins/filters/date.filter.ts
¤ñ¹ï·sÀÉ®×
@@ -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()}`;
  }
})