This commit is contained in:
@@ -41,7 +41,7 @@
|
||||
:headers="headers"
|
||||
:items="Items"
|
||||
item-key="id"
|
||||
:pagination.sync="pagination"
|
||||
:pagination.sync="localFormSettings.pagination"
|
||||
:total-items="totalItems"
|
||||
:loading="loading"
|
||||
:rows-per-page-items="rowsPerPageItems"
|
||||
@@ -71,9 +71,11 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
/* xeslint-disable */
|
||||
/* Xeslint-disable */
|
||||
const FORM_KEY = "inventorywidgetlist";
|
||||
|
||||
export default {
|
||||
created() {
|
||||
beforeCreate() {
|
||||
var that = this;
|
||||
this.$gzlocale
|
||||
.fetch([
|
||||
@@ -94,10 +96,22 @@ export default {
|
||||
header.text = that.$gzlocale.get(header.text);
|
||||
});
|
||||
})
|
||||
.then(() => (this.formState.ready = true))
|
||||
.then(() => {
|
||||
//eslint-disable-next-line
|
||||
debugger;
|
||||
var storedFormSettings = that.$gzform.getFormSettings(FORM_KEY);
|
||||
//set default values for form settings if they are not present yet
|
||||
if (!storedFormSettings) {
|
||||
storedFormSettings = {
|
||||
pagination: {}
|
||||
};
|
||||
}
|
||||
that.localFormSettings = storedFormSettings;
|
||||
that.formState.ready = true;
|
||||
})
|
||||
.catch(err => {
|
||||
this.formState.ready = true; //show the form anyway so we know what's what
|
||||
this.$gzHandleFormError(err);
|
||||
that.formState.ready = true; //show the form anyway so we know what's what
|
||||
that.$gzHandleFormError(err);
|
||||
});
|
||||
},
|
||||
data() {
|
||||
@@ -116,7 +130,9 @@ export default {
|
||||
totalItems: 0,
|
||||
Items: [],
|
||||
loading: true,
|
||||
pagination: {},
|
||||
localFormSettings: {
|
||||
pagination: {}
|
||||
},
|
||||
selected: [],
|
||||
rowsPerPageItems: [5, 10, 25, 99],
|
||||
rowsPerPageText: "blah per blah",
|
||||
@@ -138,7 +154,7 @@ export default {
|
||||
};
|
||||
},
|
||||
watch: {
|
||||
pagination: {
|
||||
"localFormSettings.pagination": {
|
||||
handler() {
|
||||
this.getDataFromApi();
|
||||
},
|
||||
@@ -151,25 +167,43 @@ export default {
|
||||
this.dialogdata.showeditdialog = true;
|
||||
},
|
||||
getDataFromApi() {
|
||||
var that = this;
|
||||
var listOptions = {
|
||||
offset: 0,
|
||||
limit: 5,
|
||||
sort: "name",
|
||||
asc: true
|
||||
};
|
||||
if (this.pagination.rowsPerPage && this.pagination.rowsPerPage > 0) {
|
||||
|
||||
if (
|
||||
this.localFormSettings.pagination.rowsPerPage &&
|
||||
this.localFormSettings.pagination.rowsPerPage > 0
|
||||
) {
|
||||
listOptions.offset =
|
||||
(this.pagination.page - 1) * this.pagination.rowsPerPage;
|
||||
listOptions.limit = this.pagination.rowsPerPage;
|
||||
(this.localFormSettings.pagination.page - 1) *
|
||||
this.localFormSettings.pagination.rowsPerPage;
|
||||
listOptions.limit = this.localFormSettings.pagination.rowsPerPage;
|
||||
}
|
||||
listOptions.sort = this.pagination.sortBy;
|
||||
listOptions.asc = !this.pagination.descending;
|
||||
listOptions.sort = this.localFormSettings.pagination.sortBy;
|
||||
listOptions.asc = !this.localFormSettings.pagination.descending;
|
||||
|
||||
//set the list settings in the store since we were successful at retrieval
|
||||
if (
|
||||
that.localFormSettings &&
|
||||
that.localFormSettings.pagination &&
|
||||
that.localFormSettings.pagination.rowsPerPage
|
||||
) {
|
||||
//eslint-disable-next-line
|
||||
debugger;
|
||||
that.$gzform.setFormSettings(FORM_KEY, that.localFormSettings);
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
var listUrl = "Widget/ListWidgets?" + this.$gzapi.buildQuery(listOptions);
|
||||
this.$gzapi.get(listUrl).then(res => {
|
||||
this.loading = false;
|
||||
this.Items = res.data;
|
||||
this.totalItems = res.paging.count;
|
||||
that.loading = false;
|
||||
that.Items = res.data;
|
||||
that.totalItems = res.paging.count;
|
||||
});
|
||||
},
|
||||
editItem(item) {
|
||||
@@ -181,30 +215,3 @@ export default {
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
//Example api response // { // "data": [ // { // "id": 1, // "concurrencyToken":
|
||||
2262471, // "ownerId": 1, // "name": "Handcrafted Wooden Bacon 23", // "serial":
|
||||
1, // "dollarAmount": 25.42, // "active": true, // "roles": 8212, //
|
||||
"startDate": "2018-11-19T12:20:42.920058", // "endDate":
|
||||
"2018-11-19T15:37:47.053849", // "notes": "Voluptas assumenda laudantium nemo
|
||||
cupiditate. Quia voluptatem reiciendis et. Sit non error est. Tenetur provident
|
||||
nostrum. Voluptatem voluptatem et." // }, // { // "id": 2, //
|
||||
"concurrencyToken": 2262494, // "ownerId": 1, // "name": "Ergonomic Soft Gloves
|
||||
24", // "serial": 2, // "dollarAmount": 530.39, // "active": true, // "roles":
|
||||
8212, // "startDate": "2018-11-19T12:17:32.488013", // "endDate":
|
||||
"2018-11-19T17:01:18.425666", // "notes": "Sed rerum minima blanditiis est.
|
||||
Praesentium consequatur numquam nostrum voluptatem libero dolores voluptatem et.
|
||||
Aut et nobis consectetur voluptatem minus. Ipsa nemo non in iste adipisci
|
||||
voluptatem. Minus consequatur in accusantium." // }, // { // "id": 3, //
|
||||
"concurrencyToken": 2262518, // "ownerId": 1, // "name": "Fantastic Metal
|
||||
Computer 25", // "serial": 3, // "dollarAmount": 494.3, // "active": true, //
|
||||
"roles": 8212, // "startDate": "2018-11-19T13:06:47.437006", // "endDate":
|
||||
"2018-11-19T14:41:44.665721", // "notes": "Facere et ex. Ipsa aspernatur itaque
|
||||
maiores sint nulla esse incidunt. Architecto labore voluptatem dolore iusto ut."
|
||||
// } // ], // "paging": { // "count": 100, // "offset": 0, // "limit": 3, //
|
||||
"first":
|
||||
"http://localhost:7575/api/v8.0/Widget/ListWidgets?pageNo=1&pageSize=3", //
|
||||
"previous": null, // "next":
|
||||
"http://localhost:7575/api/v8.0/Widget/ListWidgets?pageNo=1&pageSize=3", //
|
||||
"last": "http://localhost:7575/api/v8.0/Widget/ListWidgets?pageNo=34&pageSize=3"
|
||||
// } // }
|
||||
|
||||
Reference in New Issue
Block a user