From 20b87b7eab9c600e2445548c4306ea1b8b37b275 Mon Sep 17 00:00:00 2001 From: HelenHuang <LinHuang@pollex.com.tw> Date: 星期一, 06 十二月 2021 12:29:50 +0800 Subject: [PATCH] update#131467: [滿意度評分功能]-客戶進行滿意度評分API串接 --- PAMapp/pages/quickFilter/index.vue | 197 +++++++++++++++++++++++++++--------------------- 1 files changed, 111 insertions(+), 86 deletions(-) diff --git a/PAMapp/pages/quickFilter/index.vue b/PAMapp/pages/quickFilter/index.vue index 1c4ab82..8961922 100644 --- a/PAMapp/pages/quickFilter/index.vue +++ b/PAMapp/pages/quickFilter/index.vue @@ -5,37 +5,26 @@ v-for="(question, index) in questionList" :key="index" class="subTitle quickBtn" - :disabled="question.name === 'status'" + :class="{'isActive': isActive(question.name)}" @click="openPopUp(question)" >{{question.title}}</el-button> </div> <h5 class="mdTxt mb-10 mt-30">蝭拚璇辣</h5> <div> - <Ui-Tags - v-if="selectedItem.gender" - @removeTag="removeTag('gender')" - > - {{selectedItem.gender === 'male' ? '���' : '憟單��'}} - </Ui-Tags> - <Ui-Tags - v-if="selectedItem.avgScore" - @removeTag="removeTag('avgScore')" - > - {{selectedItem.avgScore + '��誑銝遛��漲'}} - </Ui-Tags> - <template v-if="selectedItem.communicationStyles"> - <Ui-Tags - v-for="(item, index) in selectedItem.communicationStyles" - :key="index" - @removeTag="removeTag('communicationStyles', index)" + <template v-if="confirmItem.length > 0"> + <UiTags + v-for="(item, index) in confirmItem" :key="index" + @removeTag="removeTag(item.value)" > - {{item}} - </Ui-Tags> + <span v-if="item.option === 'gender'">{{item.value === 'male' ? '���' : '憟單��'}}</span> + <span v-else-if="item.option === 'avgScore'">{{item.value + '��誑銝遛��漲'}}</span> + <span v-else>{{item.value}}</span> + </UiTags> </template> - - <div class="mb-10" v-if="selectedItem.onlineState"></div> - <div class="emptyBox text--mid_grey" - v-if="isEmpty"> + <div + v-else + class="emptyBox text--mid_grey" + > <p class="smTxt">撠蝭拚</p> </div> </div> @@ -59,38 +48,39 @@ </div> <PopUpFrame - :isOpen.sync="questionPopUp" - :drawerSize="questionOption.name === 'communicationStyles' ? '50%' : '30%'" - @update:isOpen="closePopUp" + :isOpen.sync="isOpenQuestionPopUp" + :drawerSize="questionOption.name === 'communicationStyles' ? '55%' : '35%'" + :dialogWidth="'400px'" + class="pam-myDemand-dialog" > <QuickFilterSelector ref="quickFilterRef" - :drawerVisible.sync="questionPopUp" + :isOpenQuestionPopUp="isOpenQuestionPopUp" :questionOption="questionOption" - :selectedItem="selectedItem" + @confirm="confirm" + :confirmItem="confirmItem" ></QuickFilterSelector> </PopUpFrame> - </div> </template> <script lang="ts"> -import { Vue, Component } from 'nuxt-property-decorator'; -import { Consultants, FastQueryParams } from '~/assets/ts/api/consultant'; -import QuickFilterDrawer from '~/components/QuickFilter/QuickFilterSelector.vue'; +import { Vue, Component, namespace } from 'nuxt-property-decorator'; +import { FastQueryParams } from '~/assets/ts/api/consultant'; +import { Consultants } from '~/assets/ts/models/consultant.model'; +import { Selected } from '~/components/QuickFilter/QuickFilterSelector.vue'; import { fastQuery } from '~/assets/ts/api/consultant'; +const localStorage = namespace('localStorage'); @Component export default class QuickFilter extends Vue { - questionPopUp = false; + @localStorage.Mutation storageQuickFilter!: (token: string) => void; + @localStorage.Getter quickFilterSelectedData!: Selected[]; + + isOpenQuestionPopUp = false; consultantList: Consultants[] = []; questionOption = {}; - selectedItem: FastQueryParams = { - gender: '', - avgScore: 0, - communicationStyles: [], - status: '' - }; + confirmItem: Selected[] = []; questionList: QuestionOption[] = [ { name: 'gender', @@ -99,7 +89,7 @@ { name: '���', value: 'male', className: 'btn_man'}, { name: '憟單��', value: 'female', className: 'btn_woman'} ], - type: 'radio', + type: 'radio' }, { name: 'avgScore', @@ -118,57 +108,98 @@ ], type: 'checkbox' }, - { - name: 'status', - title: '銝�����', - detail: [], - type: 'radio' - } + // { + // name: 'status', + // title: '銝�����', + // detail: [], + // type: 'radio' + // } ]; - get isEmpty() { - return !this.selectedItem.gender - && !this.selectedItem.avgScore - && this.selectedItem.communicationStyles.length === 0 - && !this.selectedItem.status + mounted() { + if (this.quickFilterSelectedData && this.quickFilterSelectedData.length > 0) { + this.confirmItem = this.quickFilterSelectedData; + this.getRecommendList(); + } + } + + 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.questionPopUp =true; + this.isOpenQuestionPopUp =true; } - removeTag(type: string, index: number = 0) { - - if (type === 'gender') { - this.selectedItem.gender = '' - } - - if (type === 'avgScore') { - this.selectedItem.avgScore = 0 - } - - if (type === 'communicationStyles') { - this.selectedItem.communicationStyles.splice(index, 1) - } - - this.isEmpty ? this.consultantList = [] : this.getRecommendList(); + removeTag(value: string) { + this.confirmItem = this.confirmItem.filter(item => item.value !== value); + this.confirmItem.length > 0 ? this.getRecommendList() : this.consultantList = []; } - closePopUp() { - this.selectedItem = JSON.parse(JSON.stringify((this.$refs.quickFilterRef as QuickFilterDrawer).pickedItem)); - this.getRecommendList(); + confirm(event: Selected) { + this.setConfirmData(event); + this.confirmItem.length > 0 ? this.getRecommendList() : this.consultantList = []; + this.isOpenQuestionPopUp = false; + } + + setConfirmData(event: Selected) { + if (event.option === 'communicationStyles') { + this.filterCommunicationStyles(event); + } else { + const findIndex = this.confirmItem.findIndex(item => item.option === event.option); + findIndex === -1 ? this.confirmItem.push(event) : this.confirmItem[findIndex] = event; + } + } + + filterCommunicationStyles(event: Selected) { + const confirmValue = this.confirmItem + .filter(item => item.option === 'communicationStyles') + .map(i => i.value); + const pickerValue = event.value; + + this.confirmItem = this.confirmItem + .filter(item => pickerValue.includes(item.value) || item.option !== 'communicationStyles'); + + const addValue = pickerValue.filter(item => !confirmValue.includes(item)).map(i => { + return { + option: 'communicationStyles', + value: i + } + }) + if (addValue.length > 0) { + this.confirmItem.push(...addValue); + } } getRecommendList() { - const data = { - gender: this.selectedItem.gender, - communicationStyles: this.selectedItem.communicationStyles, - avgScore: this.selectedItem.avgScore, - status: this.selectedItem.status + const data: FastQueryParams = { + gender: this.gender(), + communicationStyles: this.communicationStyles(), + avgScore: this.avgScore(), + status: '' } - fastQuery(data).then((res) => this.consultantList = res.data) + fastQuery(data).then((res) => { + this.consultantList = res.data; + this.storageQuickFilter(JSON.stringify(this.confirmItem)) + }) } } @@ -219,17 +250,11 @@ text-align: center; box-shadow: 0 0 6px #22222229; border-radius: 10px; - color: $PRIMARY_WHITE; - background-size: cover; - background-position: center; - background-repeat: no-repeat; - background-image: url('~/assets/images/quickFilter/btn_bg.svg'); + border-color: $CORAL; - &:disabled { + &.isActive { + background-color: $CORAL; color: $PRIMARY_WHITE; - border-color: $LIGHT_GREY; - background-color: $LIGHT_GREY; - background-image: none; } } .quickBtn+.quickBtn { -- Gitblit v1.8.0