add modules folder based on s_menu
This commit is contained in:
348
test/vuex/acc-one-mutasi-request-approved/modules/mutasi.js
Normal file
348
test/vuex/acc-one-mutasi-request-approved/modules/mutasi.js
Normal file
@@ -0,0 +1,348 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
|
||||
import * as api from "../api/api.js";
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
alert_error: false,
|
||||
err_message: "",
|
||||
menu_start_date: false,
|
||||
menu_end_date: false,
|
||||
d_start_date: new Date().toISOString().substring(0, 10),
|
||||
d_end_date: new Date().toISOString().substring(0, 10),
|
||||
f_start_date: moment(new Date()).format("YYYY-MM-DD"),
|
||||
f_end_date: moment(new Date()).format("YYYY-MM-DD"),
|
||||
f_status: '',
|
||||
status_options: [
|
||||
{ text: 'All', value: '' },
|
||||
{ text: 'Draft', value: 'Draft' },
|
||||
{ text: 'Verified', value: 'Verified' },
|
||||
{ text: 'Approved', value: 'Approved' },
|
||||
{ text: 'Rejected', value: 'Rejected' },
|
||||
{ text: 'sent', value: 'sent' },
|
||||
{ text: 'Received', value: 'Received' },
|
||||
{ text: 'Done', value: 'Done' },
|
||||
],
|
||||
f_search : '',
|
||||
list_data: [],
|
||||
selected_list_data: {},
|
||||
isLoading: 0,
|
||||
current_page: 1,
|
||||
total_pages: 0,
|
||||
snackbar: {
|
||||
color: 'success',
|
||||
msg: '',
|
||||
isOpen: false
|
||||
},
|
||||
dialog_delete: false,
|
||||
approve_level: 0,
|
||||
dialog_reject: false,
|
||||
note_reject: '',
|
||||
dialog_form_mutasi_view: false
|
||||
},
|
||||
mutations: {
|
||||
update_alert_error(state, val) {
|
||||
state.alert_error = val;
|
||||
},
|
||||
update_err_message(state, val) {
|
||||
state.err_message = val;
|
||||
},
|
||||
update_menu_start_date(state, val) {
|
||||
state.menu_start_date = val;
|
||||
},
|
||||
update_menu_end_date(state, val) {
|
||||
state.menu_end_date = val;
|
||||
},
|
||||
update_d_start_date(state, val) {
|
||||
state.d_start_date = val;
|
||||
},
|
||||
update_d_end_date(state, val) {
|
||||
state.d_end_date = val;
|
||||
},
|
||||
update_f_start_date(state, val) {
|
||||
state.f_start_date = val;
|
||||
},
|
||||
update_f_end_date(state, val) {
|
||||
state.f_end_date = val;
|
||||
},
|
||||
update_f_status(state, val) {
|
||||
state.f_status = val;
|
||||
},
|
||||
update_status_options(state, val) {
|
||||
state.status_options = val;
|
||||
},
|
||||
update_f_search(state, val) {
|
||||
state.f_search = val;
|
||||
state.current_page = 1
|
||||
},
|
||||
update_list_data(state, val) {
|
||||
state.list_data = val;
|
||||
},
|
||||
update_selected_list_data(state, val) {
|
||||
state.selected_list_data = val;
|
||||
},
|
||||
update_isLoading(state, val) {
|
||||
state.isLoading = val;
|
||||
},
|
||||
update_current_page(state, val) {
|
||||
state.current_page = val;
|
||||
},
|
||||
update_total_pages(state, val) {
|
||||
state.total_pages = val;
|
||||
},
|
||||
update_snackbar(state, data) {
|
||||
state.snackbar = data
|
||||
},
|
||||
update_dialog_delete(state, val) {
|
||||
state.dialog_delete = val
|
||||
},
|
||||
update_approve_level(state, data) {
|
||||
state.approve_level = data
|
||||
},
|
||||
update_dialog_reject(state, val) {
|
||||
state.dialog_reject = val
|
||||
},
|
||||
update_note_reject(state, val) {
|
||||
state.note_reject = val
|
||||
},
|
||||
update_dialog_form_mutasi_view(state, val) {
|
||||
state.dialog_form_mutasi_view = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context) {
|
||||
context.commit("update_isLoading", 1)
|
||||
try {
|
||||
let param = {
|
||||
token: one_token(),
|
||||
search: context.state.f_search,
|
||||
start_date: context.state.f_start_date,
|
||||
end_date: context.state.f_end_date,
|
||||
current_page: context.state.current_page,
|
||||
status: context.state.f_status
|
||||
}
|
||||
const resp = await api.search(param);
|
||||
if (resp.status != 'OK') {
|
||||
context.commit("update_isLoading", 3)
|
||||
context.commit("update_snackbar", {
|
||||
color: 'error',
|
||||
msg: resp.message,
|
||||
isOpen: true
|
||||
}, { root: true });
|
||||
} else {
|
||||
context.commit("update_isLoading", 2)
|
||||
context.commit("update_list_data", resp.data.records);
|
||||
context.commit("update_total_pages", resp.data.total_page);
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_isLoading", 3)
|
||||
context.commit("update_snackbar", {
|
||||
color: 'error',
|
||||
msg: error.message,
|
||||
isOpen: true
|
||||
}, { root: true });
|
||||
}
|
||||
},
|
||||
|
||||
async getItemMutasiUpdate(context) {
|
||||
try {
|
||||
let param = {
|
||||
token: one_token(),
|
||||
mutasiRequestID: context.state.selected_list_data.MutasiRequestID
|
||||
}
|
||||
const resp = await api.getItemMutasiUpdate(param);
|
||||
if (resp.status != 'OK') {
|
||||
context.commit("update_snackbar", {
|
||||
color: 'error',
|
||||
msg: resp.message,
|
||||
isOpen: true
|
||||
});
|
||||
} else {
|
||||
context.commit("form/update_mutasi_date", context.state.selected_list_data.MutasiRequestDate, { root: true });
|
||||
|
||||
let category = {
|
||||
itemCategoryID: context.state.selected_list_data.itemCategoryID,
|
||||
itemCategoryName: context.state.selected_list_data.itemCategoryName
|
||||
}
|
||||
context.commit("form/update_selected_category", category, { root: true });
|
||||
|
||||
let branch_asal = {
|
||||
M_BranchID: context.state.selected_list_data.branch_asal_id,
|
||||
M_BranchName: context.state.selected_list_data.branch_asal_name,
|
||||
M_BranchCode: context.state.selected_list_data.branch_asal_code,
|
||||
}
|
||||
context.commit("form/update_selected_branch_asal", branch_asal, { root: true });
|
||||
|
||||
let branch_tujuan = {
|
||||
M_BranchID: context.state.selected_list_data.branch_tujuan_id,
|
||||
M_BranchName: context.state.selected_list_data.branch_tujuan_name,
|
||||
M_BranchCode: context.state.selected_list_data.branch_tujuan_code,
|
||||
}
|
||||
context.commit("form/update_selected_branch_tujuan", branch_tujuan, { root: true });
|
||||
|
||||
context.commit("form/update_note", context.state.selected_list_data.MutasiRequestNote, { root: true });
|
||||
context.commit("form/update_list_mutasi_item", resp.data.records, { root: true });
|
||||
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_snackbar", {
|
||||
color: 'error',
|
||||
msg: error.message,
|
||||
isOpen: true
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
async deleteMutasi(context) {
|
||||
try {
|
||||
let param = {
|
||||
token: one_token(),
|
||||
mutasiRequestID: context.state.selected_list_data.MutasiRequestID
|
||||
}
|
||||
const resp = await api.deleteMutasi(param);
|
||||
if (resp.status != 'OK') {
|
||||
context.commit("update_snackbar", {
|
||||
color: 'error',
|
||||
msg: resp.message,
|
||||
isOpen: true
|
||||
});
|
||||
} else {
|
||||
context.dispatch("search");
|
||||
context.commit('update_dialog_delete', false)
|
||||
|
||||
context.commit("update_snackbar", {
|
||||
color: 'success',
|
||||
msg: resp.data,
|
||||
isOpen: true
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_snackbar", {
|
||||
color: 'error',
|
||||
msg: error.message,
|
||||
isOpen: true
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
async getApproveLevel(context) {
|
||||
try {
|
||||
let param = {
|
||||
token: one_token()
|
||||
}
|
||||
const resp = await api.getApproveLevel(param);
|
||||
if (resp.status != 'OK') {
|
||||
context.commit("update_snackbar", {
|
||||
color: 'error',
|
||||
msg: resp.message,
|
||||
isOpen: true
|
||||
});
|
||||
} else {
|
||||
let data = resp.data.M_UserM_ApproveLevelID
|
||||
|
||||
context.commit("update_approve_level", data)
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_snackbar", {
|
||||
color: 'error',
|
||||
msg: error.message,
|
||||
isOpen: true
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
async verifMutasiRequest(context, param) {
|
||||
try {
|
||||
param.token = one_token()
|
||||
param.approvelevel = context.state.approve_level
|
||||
const resp = await api.approveMutasiRequest(param);
|
||||
if (resp.status != 'OK') {
|
||||
context.commit("update_snackbar", {
|
||||
color: 'error',
|
||||
msg: resp.message,
|
||||
isOpen: true
|
||||
});
|
||||
} else {
|
||||
context.dispatch("search");
|
||||
context.commit("form/update_dialog_form_mutasi_verif", false, { root: true });
|
||||
|
||||
context.commit("update_snackbar", {
|
||||
color: 'success',
|
||||
msg: resp.data,
|
||||
isOpen: true
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_snackbar", {
|
||||
color: 'error',
|
||||
msg: error.message,
|
||||
isOpen: true
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
async approveMutasiRequest(context, param) {
|
||||
try {
|
||||
param.token = one_token()
|
||||
param.approvelevel = context.state.approve_level
|
||||
const resp = await api.approveMutasiRequest(param);
|
||||
if (resp.status != 'OK') {
|
||||
context.commit("update_snackbar", {
|
||||
color: 'error',
|
||||
msg: resp.message,
|
||||
isOpen: true
|
||||
});
|
||||
} else {
|
||||
context.dispatch("search");
|
||||
context.commit("form/update_dialog_form_mutasi_approve", false, { root: true });
|
||||
|
||||
context.commit("update_snackbar", {
|
||||
color: 'success',
|
||||
msg: resp.data,
|
||||
isOpen: true
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_snackbar", {
|
||||
color: 'error',
|
||||
msg: error.message,
|
||||
isOpen: true
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
async rejectMutasiRequest(context, param) {
|
||||
try {
|
||||
param.token = one_token()
|
||||
const resp = await api.rejectMutasiRequest(param);
|
||||
if (resp.status != 'OK') {
|
||||
context.commit("update_snackbar", {
|
||||
color: 'error',
|
||||
msg: resp.message,
|
||||
isOpen: true
|
||||
});
|
||||
} else {
|
||||
context.dispatch("search");
|
||||
context.commit("update_dialog_reject", false);
|
||||
context.commit("update_note_reject", '');
|
||||
|
||||
context.commit("update_snackbar", {
|
||||
color: 'success',
|
||||
msg: resp.data,
|
||||
isOpen: true
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
context.commit("update_snackbar", {
|
||||
color: 'error',
|
||||
msg: error.message,
|
||||
isOpen: true
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user