From df0b661216028e6b44c55e94e0f8d601be9a8802 Mon Sep 17 00:00:00 2001 From: Mila <Mila@pollex.com.tw> Date: 星期四, 25 十一月 2021 12:28:40 +0800 Subject: [PATCH] 1. 設定 uat router base 2. fix: run generate warn (router.scrollBehavior property is deprecated in favor of using ~/app/router.scrollBehavior.js file) --- PAMapp/components/AddAndReservedBtns.vue | 48 ++++++++++++++++-------------------------------- 1 files changed, 16 insertions(+), 32 deletions(-) diff --git a/PAMapp/components/AddAndReservedBtns.vue b/PAMapp/components/AddAndReservedBtns.vue index bdc1244..74be21f 100644 --- a/PAMapp/components/AddAndReservedBtns.vue +++ b/PAMapp/components/AddAndReservedBtns.vue @@ -1,7 +1,7 @@ <template> <el-row type="flex" justify="center" :class="cusClass"> - <el-button @click="addConsultant(agentInfo)"> - <span> + 憿批��</span> + <el-button @click="addConsultant(agentInfo)" :disabled="isAdded"> + <span> {{isAdded ? '撌脣�憿批��' : '+ 憿批��'}}</span> </el-button> <el-button @click="reserveCommunication" @@ -11,51 +11,35 @@ </template> <script lang="ts"> -import { Vue, Component, Prop, Emit } from 'nuxt-property-decorator'; -import { addFavoriteConsultant, Consultants } from '~/assets/ts/api/consultant'; +import { Vue, Component, Prop, Emit, Action, State } from 'nuxt-property-decorator'; +import { Consultants } from '~/assets/ts/api/consultant'; import { isLogin } from '~/assets/ts/auth'; -import { getFavoriteFromStorage, setFavoriteToStorage } from '~/assets/ts/storageConsultant'; @Component export default class AddAndReservedBtns extends Vue { + @Action addToMyConsultantList!: (consultantToAdd: Consultants) => Promise<boolean> + @State('myConsultantList') myConsultantList!: Consultants[]; + @Prop() agentInfo!: Consultants; @Prop() cusClass!: string; isVisiblePopUp = false; addConsultant(item: Consultants) { - console.log('click') - if (isLogin()) { - addFavoriteConsultant([item.agentNo]).then(res => this.openPopUp()) - } else { - this.addConsultantToStorage(item); - } - } - - addConsultantToStorage(item: Consultants) { - let agentList = [item]; - const consultantList = getFavoriteFromStorage(); - - if (consultantList) { - const isRepeat = consultantList.findIndex(i => i.agentNo === item.agentNo) === -1; - isRepeat - ? this.storageFavoriteAndPopUp(consultantList.concat(agentList)) - : this.openPopUp('撌脩��憿批��'); - - } else { - this.storageFavoriteAndPopUp(agentList); - } - } - - storageFavoriteAndPopUp(item: Consultants[]) { - setFavoriteToStorage(item); - this.openPopUp(); + this.addToMyConsultantList(item).then(addOk => { + addOk && this.openPopUp(); + }); } reserveCommunication() { - isLogin() ? this.$router.push('/questionnaire') : this.$router.push('/login'); + isLogin() ? this.$router.push(`/questionnaire/${this.agentInfo.agentNo}`) : this.$router.push('/login'); } @Emit('openPopUp') openPopUp(popUpTxt: string = '����憿批��') { return popUpTxt } + + get isAdded() { + return this.myConsultantList.find(item => item.agentNo === this.agentInfo.agentNo) + ? true : false + } } </script> \ No newline at end of file -- Gitblit v1.8.0