From 5ca8f6e6e554696cb8add0fc91396b2d905b0d7a Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期二, 30 十一月 2021 13:53:24 +0800
Subject: [PATCH] add: age.filter

---
 PAMapp/components/Consultant/ConsultantCard.vue |    2 +-
 PAMapp/components/Client/ClientCard.vue         |    2 +-
 PAMapp/plugins/filters/age.filter.ts            |   21 +++++++++++++++++++++
 PAMapp/nuxt.config.js                           |    5 +++--
 4 files changed, 26 insertions(+), 4 deletions(-)

diff --git a/PAMapp/components/Client/ClientCard.vue b/PAMapp/components/Client/ClientCard.vue
index 1fffe7c..ef481b3 100644
--- a/PAMapp/components/Client/ClientCard.vue
+++ b/PAMapp/components/Client/ClientCard.vue
@@ -52,7 +52,7 @@
                 <p>�閰梧�{client.phone}}</p>
                 <p>Email嚗{client.email}}</p>
                 <p>�批嚗{gender}}</p>
-                <p>撟湧翩嚗{client.age}}</p>
+                <p>撟湧翩嚗{client.age | toAgeLabel }}</p>
                 <p>�璆哨�{client.job}}</p>
                 <p>��瘙�{client.requirement.split(',').join('��')}}</p>
                 <p v-for="(item, index) in hopeContactTime" :key="index">��蝯⊥�挾{{index + 1 | formatNumber}}嚗{ item | formatHopeContactTime}}</p>
diff --git a/PAMapp/components/Consultant/ConsultantCard.vue b/PAMapp/components/Consultant/ConsultantCard.vue
index 92bb8ef..817d294 100644
--- a/PAMapp/components/Consultant/ConsultantCard.vue
+++ b/PAMapp/components/Consultant/ConsultantCard.vue
@@ -56,7 +56,7 @@
                     <p>�閰梧�{appointmentDetail.phone}}</p>
                     <p>Email嚗{appointmentDetail.email}}</p>
                     <p>�批嚗{gender}}</p>
-                    <p>撟湧翩嚗{appointmentDetail.age}}</p>
+                    <p>撟湧翩嚗{appointmentDetail.age | toAgeLabel }}</p>
                     <p>�璆哨�{appointmentDetail.job}}</p>
                     <p>��瘙�{appointmentDetail.requirement.split(',').join('��')}}</p>
                     <p
diff --git a/PAMapp/nuxt.config.js b/PAMapp/nuxt.config.js
index 33f59f2..73f32ed 100644
--- a/PAMapp/nuxt.config.js
+++ b/PAMapp/nuxt.config.js
@@ -37,12 +37,13 @@
     { src: '~/plugins/vue-awesome-swiper.js', mode: 'client' },
     '~/plugins/service.ts',
     '~/plugins/vue-scroll-picker',
-    '~/plugins/filters/date.filter.ts'
+    '~/plugins/filters/date.filter.ts',
+    '~/plugins/filters/age.filter.ts',
   ],
 
   // Auto import components: https://go.nuxtjs.dev/config-components
   components: true,
-  // loading 
+  // loading
   loading: '~/components/loading.vue',
 
   // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
diff --git a/PAMapp/plugins/filters/age.filter.ts b/PAMapp/plugins/filters/age.filter.ts
new file mode 100644
index 0000000..19e3b49
--- /dev/null
+++ b/PAMapp/plugins/filters/age.filter.ts
@@ -0,0 +1,21 @@
+import Vue from 'vue'
+
+Vue.filter('toAgeLabel', (value: string): string => {
+
+  if (!value ||  typeof value !== 'string') {
+    return '--';
+  };
+
+  const ageLabel = {
+    'under_20': '20甇脖誑銝�',
+    '21-30': '21-30 甇�',
+    '31-40': '31-40 甇�',
+    '41-50': '41-50 甇�',
+    '46-55': '46-55 甇�',
+    '51-60': '51-60 甇�',
+    '61-70': '61-70 甇�',
+    'over_71': '71 甇脖誑銝�'
+  };
+
+  return  ageLabel[value];
+})

--
Gitblit v1.8.0