From bdae23a40c461c2c6b6ee614f661eac731c949c8 Mon Sep 17 00:00:00 2001
From: Mila <Mila@pollex.com.tw>
Date: 星期三, 22 十二月 2021 14:12:05 +0800
Subject: [PATCH] Merge branch 'master' of https://192.168.0.10:8443/r/pcalife/PAM

---
 PAMapp/pages/quickFilter/index.vue |  149 ++++++++++++++++++++++---------------------------
 1 files changed, 68 insertions(+), 81 deletions(-)

diff --git a/PAMapp/pages/quickFilter/index.vue b/PAMapp/pages/quickFilter/index.vue
index 2e35267..6e6444e 100644
--- a/PAMapp/pages/quickFilter/index.vue
+++ b/PAMapp/pages/quickFilter/index.vue
@@ -17,6 +17,10 @@
                     @removeTag="removeTag(item.value)"
                 >
                     <span v-if="item.option === 'gender'">{{item.value === 'male' ? '���' : '憟單��'}}</span>
+                    <span v-else-if="item.option === 'seniority'" class="mdTxt lighter">
+                        {{item.value | formatSeniorityTitle}}
+                        <span class="smTxt">{{item.value | formatSenioritySubTitle}}</span>
+                    </span>
                     <!-- TODO:���遛��漲 -->
                     <!-- <span v-else-if="item.option === 'avgScore'">{{item.value + '��誑銝遛��漲'}}</span> -->
                     <span v-else>{{item.value}}</span>
@@ -66,13 +70,26 @@
 
 <script lang="ts">
 import { Vue, Component, namespace } from 'nuxt-property-decorator';
-import { FastQueryParams } from '~/assets/ts/api/consultant';
-import { Consultant } from '~/assets/ts/models/consultant.model';
-import { Selected } from '~/components/QuickFilter/QuickFilterSelector.vue';
-import { fastQuery } from '~/assets/ts/api/consultant';
+import { Consultant } from '~/shared/models/consultant.model';
+import { FastQueryParams, QuestionOption, Selected } from '~/shared/models/quick-filter.model';
+import queryConsultantService from '~/shared/services/query-consultant.service';
+import { questionList } from '~/shared/const/quickFilter-questionList';
 
 const localStorage = namespace('localStorage');
-@Component
+@Component({
+    filters: {
+        formatSeniorityTitle(value) {
+            if (value === 'SENIOR') return '鞈楛';
+            if (value === 'YOUNG') return '撟渲��';
+            return '銝��';
+        },
+        formatSenioritySubTitle(value) {
+            if (value === 'SENIOR') return '����麾';
+            if (value === 'YOUNG') return '蝯血僑頛犖銝�����';
+            return '撟湧翩銝����';
+        }
+    }
+})
 export default class QuickFilter extends Vue {
     @localStorage.Mutation storageQuickFilter!: (token: string) => void;
     @localStorage.Getter quickFilterSelectedData!: Selected[];
@@ -81,41 +98,9 @@
     consultantList: Consultant[] = [];
     questionOption = {};
     confirmItem: Selected[] = [];
-    questionList: QuestionOption[] = [
-        {
-            name: 'gender',
-            title: '憿批��批',
-            detail: [
-                { name: '���', value: 'male', className: 'btn_man'},
-                { name: '憟單��', value: 'female', className: 'btn_woman'}
-            ],
-            type: 'radio'
-        },
-        // { TODO:���遛��漲
-        //     name: 'avgScore',
-        //     title: '憿批�遛��漲',
-        //     detail: [],
-        //     type: ''
-        // },
-        {
-            name: 'communicationStyles',
-            title: '皞�◢�',
-            detail: [
-                { value: '雓寞��祕', className: 'btn_owl'},
-                { value: '��翰銝餃��', className: 'btn_tiger'},
-                { value: '���', className: 'btn_koala'},
-                { value: '�隢◢頞�', className: 'btn_peacock'}
-            ],
-            type: 'checkbox'
-        },
-        // {
-        //     name: 'status',
-        //     title: '銝�����',
-        //     detail: [],
-        //     type: 'radio'
-        // }
-    ];
+    questionList = questionList;
 
+    //////////////// lifecycle ////////////////
     mounted() {
         if (this.quickFilterSelectedData && this.quickFilterSelectedData.length > 0) {
             this.confirmItem = this.quickFilterSelectedData;
@@ -123,26 +108,8 @@
         }
     }
 
-    gender(): string {
-        const filter = this.confirmItem.filter(item => item.option === 'gender').map(i => i.value);
-        return filter.length === 0 ? '' : filter[0];
-    }
 
-    avgScore(): number {
-        const filter = this.confirmItem.filter(item => item.option === 'avgScore').map(i => i.value);
-        return filter.length === 0 ? '' : filter[0];
-    }
-
-    communicationStyles(): string[] {
-        return this.confirmItem.filter(item => item.option === 'communicationStyles').map(i => i.value);
-    }
-
-    isActive(name: string) {
-        return name === 'gender' && !!this.gender()
-            || name === 'avgScore' && !!this.avgScore()
-            || name === 'communicationStyles' && !!this.communicationStyles().length
-    }
-
+    //////////////////////////////////////////
     openPopUp(question: QuestionOption) {
         this.questionOption = question;
         this.isOpenQuestionPopUp =true;
@@ -159,7 +126,39 @@
         this.isOpenQuestionPopUp = false;
     }
 
-    setConfirmData(event: Selected) {
+    isActive(name: string) {
+        return name === 'gender' && !!this.getGender()
+            || name === 'avgScore' && !!this.getAvgScore()
+            || name === 'communicationStyles' && !!this.getCommunicationStyles().length
+            || name === 'seniority' && !!this.getSeniority()
+    }
+
+
+    //////////////// private ////////////////
+    private getGender(): string {
+        return this.filterSingleSelected('gender');
+    }
+
+    private getAvgScore(): number {
+        return this.filterSingleSelected('avgScore');
+    }
+
+    private getSeniority(): string {
+        return this.filterSingleSelected('seniority');
+    }
+
+    private getCommunicationStyles(): string[] {
+        return this.confirmItem.filter(item => item.option === 'communicationStyles').map(i => i.value);
+    }
+
+    private filterSingleSelected(name: string) {
+        const filter = this.confirmItem.filter(item => item.option === name);
+        return filter.length > 0
+            ? filter[0].value
+            : (name === 'avgScore' ? 0 : '');
+    }
+
+    private setConfirmData(event: Selected) {
         if (event.option === 'communicationStyles') {
             this.filterCommunicationStyles(event);
         } else {
@@ -168,7 +167,7 @@
         }
     }
 
-    filterCommunicationStyles(event: Selected) {
+    private filterCommunicationStyles(event: Selected) {
         const confirmValue = this.confirmItem
             .filter(item => item.option === 'communicationStyles')
             .map(i => i.value);
@@ -188,33 +187,21 @@
         }
     }
 
-    getRecommendList() {
+    private getRecommendList() {
         const data: FastQueryParams = {
-            gender: this.gender(),
-            communicationStyles: this.communicationStyles(),
-            avgScore: this.avgScore(),
-            status: ''
+            gender: this.getGender(),
+            communicationStyles: this.getCommunicationStyles(),
+            avgScore: this.getAvgScore(),
+            status: '',
+            seniority: this.getSeniority()
         }
 
-        fastQuery(data).then((res) => {
-            this.consultantList = res.data;
+        queryConsultantService.fastQuery(data).then((consultantList) => {
+            this.consultantList = consultantList;
             this.storageQuickFilter(JSON.stringify(this.confirmItem))
         })
     }
 
-}
-
-export interface QuestionOption {
-    title: string;
-    detail: Detail[];
-    type: string;
-    name: string;
-}
-
-interface Detail {
-    value: string;
-    name?: string;
-    className: string;
 }
 
 </script>
@@ -273,4 +260,4 @@
         }
     }
 
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.8.0