-
+
+
+
+ PerPage
+
-
-
+
+
-
-
-
- |
- {{ field.label }}
- |
-
-
-
-
- | {{ row.id }} |
- {{ row.title }} |
- {{ row.is_done }} |
- {{ row.createdAt }} |
-
-
-
-
+
+
+
+ {{ data.index + 1 }}
+
+
+
+ {{ total }}
+
@@ -55,56 +55,86 @@ export default {
components: {},
data() {
return {
- loading: null,
+ perPage: 5, // 페이지당 보여줄 갯수
+ currentPage: 1, // 현재 페이지
total: 0,
- length: 0,
- page: 0, // 현재 페이지
- perPage: 0, // 페이지당 보여줄 갯수
searchString: '',
+ striped: true,
+ hover: true,
+ bordered: true,
+ dark: false,
+ headVariant: 'dark',
fields: [
{
- key: 'id',
+ key: 'index',
label: '번호'
},
{
key: 'title',
- label: '제목'
+ label: '타이틀',
+ sortable: true,
+ sortDirection: 'desc'
},
+ { key: 'content', label: '내용' },
{
key: 'is_done',
- label: '글쓴이'
+ label: '사용여부',
+ formatter: (value) => {
+ return value.toLowerCase() === 'true' ? 'Yes' : 'No'
+ },
+ sortable: true,
+ sortByFormatted: true,
+ filterByFormatted: true
},
- {
- key: 'created_at',
- label: '작성일'
- }
+ // { key: 'updateAt', label: '수정일' },
+ { key: 'createdAt', label: '登録日時' }
],
- rows: []
+ items: []
}
},
setup() {},
created() {
- const url = 'http://localhost:3000/todo'
- this.list(url)
+ this.list()
},
mounted() {},
unmounted() {},
methods: {
- async list(url) {
- this.loading = null
- await axios.get(url).then((response) => {
- if (response.statusText === 'OK') {
- console.log(response)
- this.page = response.data.query.page
- this.per_page = response.data.query.per_page
- this.searchString = response.data.query.searchString
- this.total = response.data.total
- this.rows = response.data.rows
- this.length = response.data.rows.length
- } else {
- throw new Error(`Network response was not ok. \n url => ${url}`)
+ list() {
+ const parameters = {
+ params: {
+ page: parseInt(this.currentPage),
+ per_page: parseInt(this.perPage),
+ searchString: this.searchString
}
- })
+ }
+ console.log(parameters)
+ axios
+ .get('http://localhost:3000/todo', parameters)
+ .then((response) => {
+ // console.log(response)
+ this.currentPage = response.data.page
+ this.perPage = response.data.per_page
+ this.searchString = response.data.searchString
+ this.total = response.data.total
+ this.items = response.data.rows
+ })
+ .catch((err) => {
+ console.log(err)
+ })
+ },
+ pageClick(button, page) {
+ console.log(button)
+ this.currentPage = page
+ this.list()
+ },
+ searchClick() {
+ this.currentPage = 1
+ this.list()
+ }
+ },
+ computed: {
+ getTotal() {
+ return this.total
}
}
}