From 26dbfaafa064ee79fd4d07aed8e8fa15ec737c46 Mon Sep 17 00:00:00 2001 From: Tomas <tomasysh@gmail.com> Date: 星期四, 09 十二月 2021 14:01:32 +0800 Subject: [PATCH] fixed: my-consultant-list - childRoute error --- /dev/null | 41 ------------- PAMapp/middleware/login.ts | 7 ++ PAMapp/pages/agentInfo/_agentNo.vue | 1 PAMapp/pages/myConsultantList/consultantList/consultant-list.component.ts | 5 - PAMapp/store/index.ts | 3 PAMapp/pages/myConsultantList/contactedList/contacted-list.component.ts | 1 PAMapp/pages/my-consultant-list.component.scss | 0 PAMapp/pages/myConsultantList/contactedList/index.vue | 0 PAMapp/components/Ui/UiPagination.vue | 8 +- PAMapp/pages/myConsultantList.vue | 13 --- PAMapp/pages/my-consultant-list.component.ts | 63 +++++++++++++++++++++ PAMapp/middleware/my-consultant-list.guard.ts | 5 + 12 files changed, 83 insertions(+), 64 deletions(-) diff --git a/PAMapp/components/Ui/UiPagination.vue b/PAMapp/components/Ui/UiPagination.vue index 822d0de..40f2709 100644 --- a/PAMapp/components/Ui/UiPagination.vue +++ b/PAMapp/components/Ui/UiPagination.vue @@ -25,7 +25,7 @@ this.handleCurrentChange(this.currentPage); } - @Emit('changePage') chagnePage(): Consultant[] { + @Emit('changePage') changePage(): Consultant[] { return this.pageList } @@ -37,14 +37,14 @@ if (this.totalList) { this.pageList = this.totalList.slice(this.pageSize * currentPage - this.pageSize, this.pageSize * currentPage) - this.chagnePage(); + this.changePage(); } } - @Watch('totalList') watchtotalList(newValue: Consultant[]) { + @Watch('totalList') watchTotalList(newValue: Consultant[]) { if (newValue) { this.handleCurrentChange(this.currentPage); } } } -</script> \ No newline at end of file +</script> diff --git a/PAMapp/middleware/login.ts b/PAMapp/middleware/login.ts new file mode 100644 index 0000000..0dd75fa --- /dev/null +++ b/PAMapp/middleware/login.ts @@ -0,0 +1,7 @@ +import { isLogin } from '~/assets/ts/auth'; + +export default function({ store, redirect}) { + if (!isLogin()) { + return redirect('/login'); + } +} diff --git a/PAMapp/middleware/my-consultant-list.guard.ts b/PAMapp/middleware/my-consultant-list.guard.ts new file mode 100644 index 0000000..21cd051 --- /dev/null +++ b/PAMapp/middleware/my-consultant-list.guard.ts @@ -0,0 +1,5 @@ +export default function ({ route, redirect }) { + if (route.name === "myConsultantList") { + return redirect('/myConsultantList/consultantList') + } +} diff --git a/PAMapp/pages/agentInfo/_agentNo.vue b/PAMapp/pages/agentInfo/_agentNo.vue index a3b562f..e3e7803 100644 --- a/PAMapp/pages/agentInfo/_agentNo.vue +++ b/PAMapp/pages/agentInfo/_agentNo.vue @@ -144,7 +144,6 @@ </UiField> </el-row> - <AddAndReservedBtns v-if="currentRole!==role.ADMIN" :cusClass="'pam-paragraph'" diff --git a/PAMapp/pages/myConsultantList/my-consultant-list.component.scss b/PAMapp/pages/my-consultant-list.component.scss similarity index 100% rename from PAMapp/pages/myConsultantList/my-consultant-list.component.scss rename to PAMapp/pages/my-consultant-list.component.scss diff --git a/PAMapp/pages/my-consultant-list.component.ts b/PAMapp/pages/my-consultant-list.component.ts new file mode 100644 index 0000000..c5c1f64 --- /dev/null +++ b/PAMapp/pages/my-consultant-list.component.ts @@ -0,0 +1,63 @@ +import { Vue, Component, Watch, State, Action } from 'nuxt-property-decorator'; +import { Consultant } from '~/assets/ts/models/consultant.model'; + +@Component +export default class myConsultantList extends Vue { + activeTabName = 'consultantList'; + contactedList: Consultant[] = []; + consultantList: Consultant[] = []; + + @State('myConsultantList') myConsultantList!: Consultant[]; + @Action storeConsultantList!: any; + + @Watch('myConsultantList') + onMyConsultantListChange() { + this.filterContactedList(); + } + + beforeRouteEnter(to: any, from: any, next: any) { + next((vm: any) => { + if (to.name === 'myConsultantList') { + vm.$router.push('/myConsultantList/consultantList'); + return; + } + }) + } + + mounted() { + this.storeConsultantList(); + + if (this.$route.name) { + this.activeTabName = this.$route.name.split('-')[1] + } + } + + tabClick(path: string) { + this.activeTabName = path; + this.$router.push('/myConsultantList/' + this.activeTabName) + } + + filterContactedList() { + + this.consultantList = (this.myConsultantList || []) + .filter((item) => item.contactStatus !== 'contacted') + .map((item) => { + return { + ...item, + formatDate: new Date(item.updateTime) + } + }) + .sort((previousItem, nextItem) => +nextItem.formatDate - +previousItem.formatDate); + + this.contactedList = (this.myConsultantList || []) + .filter(item => item.contactStatus === 'contacted') + .map((item) => { + return { + ...item, + formatDate: new Date(item.updateTime) + } + }) + .sort((a, b) => +a.formatDate - +b.formatDate); + } + +} diff --git a/PAMapp/pages/myConsultantList/index.vue b/PAMapp/pages/myConsultantList.vue similarity index 73% rename from PAMapp/pages/myConsultantList/index.vue rename to PAMapp/pages/myConsultantList.vue index bb67df2..7fe7eb7 100644 --- a/PAMapp/pages/myConsultantList/index.vue +++ b/PAMapp/pages/myConsultantList.vue @@ -18,18 +18,9 @@ </div> <NuxtChild - :contactedList="contactedList" - :consultantList="consultantList" + :consultantList="consultantList" + :contactedList="contactedList" ></NuxtChild> - - <!-- <ConsultantList - :agents="pageList" - ></ConsultantList> - - <UiPagination - :totalList="consultantList" - @changePage="changePage" - ></UiPagination> --> </div> </template> diff --git a/PAMapp/pages/myConsultantList/consultantList/consultant-list.component.ts b/PAMapp/pages/myConsultantList/consultantList/consultant-list.component.ts index 21a9b04..f041506 100644 --- a/PAMapp/pages/myConsultantList/consultantList/consultant-list.component.ts +++ b/PAMapp/pages/myConsultantList/consultantList/consultant-list.component.ts @@ -1,12 +1,9 @@ - -import { Vue, Component, Prop, Getter } from 'nuxt-property-decorator'; +import { Vue, Component, Prop } from 'nuxt-property-decorator'; import { Consultant } from '~/assets/ts/models/consultant.model'; - @Component export default class ConsultantPage extends Vue { @Prop() consultantList!: Consultant[]; - @Getter isLogin!: boolean; pageList: Consultant[] = []; changePage(pageList: Consultant[]) { diff --git a/PAMapp/pages/myConsultantList/contactedList/contacted-list.component.ts b/PAMapp/pages/myConsultantList/contactedList/contacted-list.component.ts index 53a6a6a..e897f67 100644 --- a/PAMapp/pages/myConsultantList/contactedList/contacted-list.component.ts +++ b/PAMapp/pages/myConsultantList/contactedList/contacted-list.component.ts @@ -1,7 +1,6 @@ import { Vue, Component, Prop } from 'nuxt-property-decorator' ; import { Consultant } from '~/assets/ts/models/consultant.model'; - @Component export default class ContactedList extends Vue { @Prop() contactedList!: Consultant[]; diff --git a/PAMapp/pages/myConsultantList/contactedList/contactedList.vue b/PAMapp/pages/myConsultantList/contactedList/index.vue similarity index 100% rename from PAMapp/pages/myConsultantList/contactedList/contactedList.vue rename to PAMapp/pages/myConsultantList/contactedList/index.vue diff --git a/PAMapp/pages/myConsultantList/my-consultant-list.component.ts b/PAMapp/pages/myConsultantList/my-consultant-list.component.ts deleted file mode 100644 index 2a4c907..0000000 --- a/PAMapp/pages/myConsultantList/my-consultant-list.component.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { Vue, Component, Watch, State, Action } from 'nuxt-property-decorator'; -import { Consultant } from '~/assets/ts/models/consultant.model'; - -@Component -export default class myConsultantList extends Vue { - activeTabName = 'consultantList'; - agents: Consultant[] = []; - contactedList: Consultant[] = []; - consultantList: Consultant[] = []; - - @State('myConsultantList') myConsultantList!: Consultant[]; - @Action storeConsultantList!: any; - - @Watch('myConsultantList') - onMyConsultantListChange() { - this.filterContactedList(); - } - - tabClick(path: string) { - this.activeTabName = path; - this.$router.push('/myConsultantList/' + this.activeTabName) - } - - mounted() { - this.storeConsultantList(); - - if (this.$route.name) { - this.activeTabName = this.$route.name.split('-')[1] - } - } - - filterContactedList() { - this.consultantList = (this.myConsultantList || []) - .filter(item => item.contactStatus !== 'contacted') - .sort((a, b) => a.updateTime > b.updateTime ? -1 : 1); - this.contactedList = (this.myConsultantList || []) - .filter(item => item.contactStatus === 'contacted') - .sort((a, b) => a.updateTime > b.updateTime ? -1 : 1); - } - -} diff --git a/PAMapp/store/index.ts b/PAMapp/store/index.ts index 6e91e76..e7bcff8 100644 --- a/PAMapp/store/index.ts +++ b/PAMapp/store/index.ts @@ -51,7 +51,6 @@ return; }; - if (localData?.length) { const agentNoList = localData.map(i => i.agentNo) await addFavoriteConsultant(agentNoList).then(res => { @@ -141,4 +140,4 @@ }); } -} \ No newline at end of file +} -- Gitblit v1.8.0