Files
luos/resources/assets/js/components/dataViews/vueCardView/VueCardViewMixins.js

55 lines
1.2 KiB
JavaScript
Raw Normal View History

2021-07-08 20:20:05 +00:00
export default {
data() {
let that = this;
return {
2021-07-13 15:10:59 +00:00
height: 0,
2021-07-08 20:20:05 +00:00
config: {
page: 1
},
data: []
}
},
mounted: function () {
this.getData();
2021-07-13 15:10:59 +00:00
this.getBodyHeight();
2021-07-08 20:20:05 +00:00
},
methods: {
/**
* Get data similar to vue Table
*/
getData() {
let options = _.extend({}, this.config, this.options),
that = this;
this.options.requestFunction(options)
.then((data) => {
that.data = data.data;
})
.catch(() => {
});
},
/**
* Get data when press the button more view
*/
viewMore() {
2021-07-13 15:10:59 +00:00
let options = _.extend({}, this.config, this.options, { page: this.config.page + 1 }),
that = this;
this.options.requestFunctionViewMore(options)
.then((data) => {
if (data.data && data.data.length != 0) {
that.data = that.data.concat(data.data);
that.config.page += 1;
}
})
.catch(() => {
2021-07-08 20:20:05 +00:00
2021-07-13 15:10:59 +00:00
});
},
2021-07-13 15:17:06 +00:00
/**
* Return the height for Vue Card View body
*/
2021-07-13 15:10:59 +00:00
getBodyHeight() {
this.height = window.innerHeight - this.$root.$el.clientHeight;
2021-07-08 20:20:05 +00:00
}
}
2021-07-13 15:17:06 +00:00
}