refine code

This commit is contained in:
Pan
2019-03-19 18:46:30 +08:00
parent fd4b5c4052
commit d927d4172f
9 changed files with 81 additions and 55 deletions

View File

@@ -96,17 +96,16 @@ export default {
this.getList()
},
methods: {
getList() {
async getList() {
this.listLoading = true
fetchList(this.listQuery).then(response => {
this.list = response.data.items
this.total = response.data.total
this.listLoading = false
this.oldList = this.list.map(v => v.id)
this.newList = this.oldList.slice()
this.$nextTick(() => {
this.setSort()
})
const { data } = await fetchList(this.listQuery)
this.list = data.items
this.total = data.total
this.listLoading = false
this.oldList = this.list.map(v => v.id)
this.newList = this.oldList.slice()
this.$nextTick(() => {
this.setSort()
})
},
setSort() {

View File

@@ -88,17 +88,16 @@ export default {
this.getList()
},
methods: {
getList() {
async getList() {
this.listLoading = true
fetchList(this.listQuery).then(response => {
const items = response.data.items
this.list = items.map(v => {
this.$set(v, 'edit', false) // https://vuejs.org/v2/guide/reactivity.html
v.originalTitle = v.title // will be used when user click the cancel botton
return v
})
this.listLoading = false
const { data } = await fetchList(this.listQuery)
const items = data.items
this.list = items.map(v => {
this.$set(v, 'edit', false) // https://vuejs.org/v2/guide/reactivity.html
v.originalTitle = v.title // will be used when user click the cancel botton
return v
})
this.listLoading = false
},
cancelEdit(row) {
row.title = row.originalTitle

View File

@@ -53,12 +53,11 @@ export default {
this.fetchData()
},
methods: {
fetchData() {
async fetchData() {
this.listLoading = true
fetchList().then(response => {
this.list = response.data.items
this.listLoading = false
})
const { data } = await fetchList()
this.list = data.items
this.listLoading = false
},
handleDownload() {
this.downloadLoading = true