Changeset View
Changeset View
Standalone View
Standalone View
src/resources/vue/Widgets/ListTools.vue
Show First 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | export default { | ||||
ListFoot, | ListFoot, | ||||
ListMore, | ListMore, | ||||
ListSearch, | ListSearch, | ||||
ListTable | ListTable | ||||
}, | }, | ||||
data() { | data() { | ||||
return { | return { | ||||
currentSearch: '', | currentSearch: '', | ||||
currentParent: '', | |||||
hasMore: false, | hasMore: false, | ||||
page: 1 | page: 1 | ||||
} | } | ||||
}, | }, | ||||
methods: { | methods: { | ||||
listSearch(name, url, params) { | listSearch(name, url, params) { | ||||
let loader | let loader | ||||
let get = params.get || {} | let get = params.get || {} | ||||
Show All 9 Lines | export default { | ||||
if ('search' in params) { | if ('search' in params) { | ||||
get.search = params.search | get.search = params.search | ||||
this.currentSearch = params.search | this.currentSearch = params.search | ||||
this.hasMore = false | this.hasMore = false | ||||
} else { | } else { | ||||
get.search = this.currentSearch | get.search = this.currentSearch | ||||
} | } | ||||
if ('parent' in params) { | |||||
get.parent = params.parent | |||||
this.currentParent = params.parent | |||||
} else { | |||||
get.parent = this.currentParent | |||||
} | |||||
if (!params.init) { | if (!params.init) { | ||||
loader = $(this.$el).find('.more-loader') | loader = $(this.$el).find('.more-loader') | ||||
if (!loader.length || get.page == 1) { | if (!loader.length || get.page == 1) { | ||||
loader = $(this.$el).find('tfoot td') | loader = $(this.$el).find('tfoot td') | ||||
} | } | ||||
} else { | } else { | ||||
loader = true | loader = true | ||||
} | } | ||||
} else { | } else { | ||||
this.currentSearch = null | this.currentSearch = null | ||||
this.currentParent = null | |||||
} | } | ||||
axios.get(url, { params: get, loader }) | axios.get(url, { params: get, loader }) | ||||
.then(response => { | .then(response => { | ||||
// Note: In Vue we can't just use .concat() | // Note: In Vue we can't just use .concat() | ||||
for (let i in response.data.list) { | for (let i in response.data.list) { | ||||
this.$set(this[name], this[name].length, response.data.list[i]) | this.$set(this[name], this[name].length, response.data.list[i]) | ||||
} | } | ||||
this.hasMore = response.data.hasMore | this.hasMore = response.data.hasMore | ||||
this.page = get.page || 1 | this.page = get.page || 1 | ||||
}) | }) | ||||
} | } | ||||
} | } | ||||
} | } | ||||
</script> | </script> |