Initial import
This commit is contained in:
70
mockup/fo/fo02/module_px.js
Normal file
70
mockup/fo/fo02/module_px.js
Normal file
@@ -0,0 +1,70 @@
|
||||
import * as api from "./api.js";
|
||||
|
||||
const module_px = {
|
||||
namespaced : true,
|
||||
|
||||
state: {
|
||||
rows: [],
|
||||
midPages: [],
|
||||
isLoading: false,
|
||||
isError: false,
|
||||
errorMessage: "",
|
||||
query: "",
|
||||
page: 1,
|
||||
totalPage: 2,
|
||||
totalRecord: 11
|
||||
},
|
||||
mutations: {
|
||||
|
||||
updatePx(state, data) {
|
||||
// console.log(data);
|
||||
if (data.status == "ERR") {
|
||||
state.isError = true;
|
||||
if (data.db_error) {
|
||||
state.errorMessage = data.db_error.message;
|
||||
} else {
|
||||
state.errorMessage = data.message;
|
||||
}
|
||||
state.query = data.query;
|
||||
state.page = 0;
|
||||
state.totalPage = 0;
|
||||
state.totalRecord = 0;
|
||||
state.rows = [];
|
||||
state.midPages = [];
|
||||
} else {
|
||||
state.isError = false;
|
||||
state.errorMessage = "";
|
||||
state.query = data.query;
|
||||
state.page = data.page;
|
||||
state.totalPage = data.totalPage;
|
||||
state.totalRecord = data.totalRecord;
|
||||
state.rows = data.rows;
|
||||
state.midPages = data.midPages;
|
||||
}
|
||||
},
|
||||
updateLoadingPx(state, flag) {
|
||||
state.isLoading = flag;
|
||||
},
|
||||
resetErrorPx(state) {
|
||||
state.isError = false;
|
||||
state.errorMessage = "";
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async searchPx(context, data) {
|
||||
context.commit("updateLoadingPx", true);
|
||||
let resp = await api.searchPx(
|
||||
data.query,
|
||||
data.page,
|
||||
data.rowPerPage
|
||||
);
|
||||
context.commit("updateLoadingPx", false);
|
||||
context.commit("updatePx", resp);
|
||||
setTimeout(function() {
|
||||
context.commit("resetErrorPx");
|
||||
}, 5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { module_px }
|
||||
Reference in New Issue
Block a user