This repository has been archived by the owner on Jan 4, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from beohoang98/feature/partner_management
Feature/partner management
- Loading branch information
Showing
14 changed files
with
932 additions
and
793 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
packages/client/src/components/PaginateTable/PaginateTable.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<template> | ||
<div class="app-paginate-table" v-loading="loading"> | ||
<el-table border fit height="500" show-header stripe :data="localData"> | ||
<el-table-column | ||
v-for="field in fieldList" | ||
:prop="field" | ||
:key="field" | ||
:label="fields[field]" | ||
:formatter="formatter[field]" | ||
/> | ||
</el-table> | ||
<el-pagination | ||
background | ||
:current-page="page" | ||
:page-size="limit" | ||
:page-count="totalPage" | ||
@current-change="handlePageChange.bind(this)" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Component, Prop, Vue, Watch } from "vue-property-decorator"; | ||
import { axiosInstance } from "@/utils/axios"; | ||
@Component({ | ||
name: "app-paginate-table", | ||
}) | ||
export default class PaginateTable extends Vue { | ||
@Prop({ required: true, type: String }) api_url!: string; | ||
@Prop({ required: false, type: Object, default: () => ({}) }) | ||
queries!: Record<string, string | number>; | ||
@Prop({ required: false, type: Object, default: () => [] }) fields!: any; | ||
@Prop({ required: false, type: Object, default: () => ({}) }) | ||
formatter!: Record<string, (value: any) => any>; | ||
localData: any[] = []; | ||
page = 1; | ||
limit = 20; | ||
totalPage = 1; | ||
loading = true; | ||
get fieldList(): string[] { | ||
return Object.keys(this.fields); | ||
} | ||
handlePageChange(page: number) { | ||
this.fetchData(page, this.limit); | ||
} | ||
@Watch("queries") | ||
onQueryChange() { | ||
this.fetchData(this.page, this.limit); | ||
} | ||
fetchData(page = 1, limit = 20) { | ||
this.loading = true; | ||
axiosInstance | ||
.get<Paginate>(this.api_url, { | ||
params: { | ||
...this.queries, | ||
page, | ||
limit, | ||
}, | ||
}) | ||
.then(({ data }) => { | ||
this.localData = data.items; | ||
this.totalPage = data.meta.totalPages; | ||
this.page = data.meta.currentPage; | ||
}) | ||
.finally(() => { | ||
this.loading = false; | ||
}); | ||
} | ||
mounted() { | ||
this.fetchData(this.page, this.limit); | ||
} | ||
} | ||
</script> | ||
|
||
<style lang="scss"></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,8 @@ | ||
import { VueConstructor } from "vue"; | ||
import Vue from "vue"; | ||
import dayjs from "dayjs"; | ||
|
||
export default { | ||
install: (Vue: VueConstructor) => { | ||
Vue.filter("date", (value: string | number) => { | ||
return dayjs(value).format("DD MMM yyyy"); | ||
}); | ||
Vue.filter("datetime", (value: string | number) => { | ||
return dayjs(value).format("DD/MM/yy HH:mm:ss"); | ||
}); | ||
}, | ||
}; | ||
Vue.filter("date", (value: string | number) => { | ||
return dayjs(value).format("DD MMM YYYY"); | ||
}); | ||
Vue.filter("datetime", (value: string | number) => { | ||
return dayjs(value).format("DD/MM/YY HH:mm:ss"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./number"; | ||
export * from "./date"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
565c89f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: