| | |
| | | @removeTag="removeTag(item.value)" |
| | | > |
| | | <span v-if="item.option === 'gender'">{{item.value === 'male' ? '男性' : '女性'}}</span> |
| | | <span v-else-if="item.option === 'avgScore'">{{item.value + '星以上滿意度'}}</span> |
| | | <!-- TODO:隱藏滿意度 --> |
| | | <!-- <span v-else-if="item.option === 'avgScore'">{{item.value + '星以上滿意度'}}</span> --> |
| | | <span v-else>{{item.value}}</span> |
| | | </UiTags> |
| | | </template> |
| | |
| | | |
| | | <PopUpFrame |
| | | :isOpen.sync="isOpenQuestionPopUp" |
| | | :drawerSize="questionOption.name === 'communicationStyles' ? '55%' : '35%'" |
| | | :dialogWidth="'400px'" |
| | | class="pam-myDemand-dialog" |
| | | > |
| | |
| | | </template> |
| | | |
| | | <script lang="ts"> |
| | | import { Vue, Component } from 'nuxt-property-decorator'; |
| | | import { Consultants, FastQueryParams } from '~/assets/ts/api/consultant'; |
| | | import { Selected } from '~/components/QuickFilter/QuickFilterSelector.vue'; |
| | | import { fastQuery } from '~/assets/ts/api/consultant'; |
| | | import { Vue, Component, namespace } from 'nuxt-property-decorator'; |
| | | |
| | | import queryConsultantService from '~/shared/services/query-consultant.service'; |
| | | import { Consultant } from '~/shared/models/consultant.model'; |
| | | import { questionList } from '~/shared/const/quickFilter-questionList'; |
| | | import { FastQueryParams, QuestionOption, Selected } from '~/shared/models/quick-filter.model'; |
| | | |
| | | const localStorage = namespace('localStorage'); |
| | | @Component |
| | | export default class QuickFilter extends Vue { |
| | | @localStorage.Mutation storageQuickFilter!: (token: string) => void; |
| | | @localStorage.Getter quickFilterSelectedData!: Selected[]; |
| | | |
| | | isOpenQuestionPopUp = false; |
| | | consultantList: Consultants[] = []; |
| | | 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' |
| | | }, |
| | | { |
| | | 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; |
| | | |
| | | gender(): string { |
| | | const filter = this.confirmItem.filter(item => item.option === 'gender').map(i => i.value); |
| | | return filter.length === 0 ? '' : filter[0]; |
| | | //////////////// lifecycle //////////////// |
| | | mounted() { |
| | | if (this.quickFilterSelectedData && this.quickFilterSelectedData.length > 0) { |
| | | this.confirmItem = this.quickFilterSelectedData; |
| | | this.getRecommendList(); |
| | | } |
| | | } |
| | | |
| | | 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; |
| | |
| | | this.isOpenQuestionPopUp = false; |
| | | } |
| | | |
| | | setConfirmData(event: Selected) { |
| | | isActive(name: string) { |
| | | return name === 'gender' && !!this.gender() |
| | | || name === 'avgScore' && !!this.avgScore() |
| | | || name === 'communicationStyles' && !!this.communicationStyles().length |
| | | } |
| | | |
| | | |
| | | //////////////// private //////////////// |
| | | private gender(): string { |
| | | const filter = this.confirmItem.filter(item => item.option === 'gender').map(i => i.value); |
| | | return filter.length === 0 ? '' : filter[0]; |
| | | } |
| | | |
| | | private avgScore(): number { |
| | | const filter = this.confirmItem.filter(item => item.option === 'avgScore').map(i => i.value); |
| | | return filter.length === 0 ? '' : filter[0]; |
| | | } |
| | | |
| | | private communicationStyles(): string[] { |
| | | return this.confirmItem.filter(item => item.option === 'communicationStyles').map(i => i.value); |
| | | } |
| | | |
| | | private setConfirmData(event: Selected) { |
| | | if (event.option === 'communicationStyles') { |
| | | this.filterCommunicationStyles(event); |
| | | } else { |
| | |
| | | } |
| | | } |
| | | |
| | | filterCommunicationStyles(event: Selected) { |
| | | private filterCommunicationStyles(event: Selected) { |
| | | const confirmValue = this.confirmItem |
| | | .filter(item => item.option === 'communicationStyles') |
| | | .map(i => i.value); |
| | |
| | | } |
| | | } |
| | | |
| | | getRecommendList() { |
| | | private getRecommendList() { |
| | | const data: FastQueryParams = { |
| | | gender: this.gender(), |
| | | communicationStyles: this.communicationStyles(), |
| | |
| | | status: '' |
| | | } |
| | | |
| | | 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> |
| | |
| | | .quickBtnBlock { |
| | | display: flex; |
| | | width: 100%; |
| | | height: 132px; |
| | | // height: 132px; |
| | | flex-wrap: wrap; |
| | | justify-content: space-between; |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | </style> |
| | | </style> |