Initial import
This commit is contained in:
122
apps/modules/system/system.js
Normal file
122
apps/modules/system/system.js
Normal file
@@ -0,0 +1,122 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as menu_api from "../../api/system/menu.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search : '',
|
||||
search_status: 0,
|
||||
search_error_message: "",
|
||||
menu_level_0: [],
|
||||
menu_level_1: [],
|
||||
menu_level_2: [],
|
||||
total_menu: 0,
|
||||
//sipe add breadcrumb dan hak akses
|
||||
bread_crumb : "",
|
||||
is_page_allowed : true,
|
||||
dashboard: "",
|
||||
//tambahan jumlah notification
|
||||
notification_count: 0,
|
||||
change_password_dialog: false,
|
||||
change_password_error: "",
|
||||
branch: {}
|
||||
},
|
||||
|
||||
mutations: {
|
||||
update_branch(state,val) {
|
||||
state.branch = val
|
||||
},
|
||||
update_change_password_dialog(state,val) {
|
||||
state.change_password_dialog = val
|
||||
},
|
||||
update_change_password_error(state,val) {
|
||||
state.change_password_error= val
|
||||
},
|
||||
update_bread_crumb(state,val) {
|
||||
state.bread_crumb = val
|
||||
},
|
||||
update_dashboard(state,val) {
|
||||
state.dashboard= val
|
||||
},
|
||||
update_page_allowed(state,val) {
|
||||
state.is_page_allowed = val
|
||||
},
|
||||
update_search(state,val) {
|
||||
state.search=val
|
||||
},
|
||||
update_search_error_message(state,status) {
|
||||
state.search_error_message = status
|
||||
},
|
||||
update_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
|
||||
update_menu_level_0 (state, data) {
|
||||
state.menu_level_0 = data
|
||||
},
|
||||
|
||||
update_menu_level_1 (state, data) {
|
||||
state.menu_level_1 = data
|
||||
},
|
||||
|
||||
update_menu_level_2 (state, data) {
|
||||
state.menu_level_2 = data
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async get_menu(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await menu_api.get_menu(one_token())
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status",2)
|
||||
context.commit("update_search_error_message","")
|
||||
|
||||
let x = resp.data
|
||||
if (x[0])
|
||||
context.commit("update_menu_level_0", x[0]['p_0'])
|
||||
|
||||
if (x[1])
|
||||
context.commit("update_menu_level_1", x[1])
|
||||
|
||||
if (x[2])
|
||||
context.commit("update_menu_level_2", x[2])
|
||||
}
|
||||
//sipe :
|
||||
// tambahan get bread_crumb
|
||||
resp = await menu_api.get_bread_crumb(one_token())
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status",2)
|
||||
context.commit("update_search_error_message","")
|
||||
context.commit("update_bread_crumb",resp.data.bread_crumb)
|
||||
context.commit("update_branch",resp.data.branch)
|
||||
context.commit("update_page_allowed",resp.data.is_page_allowed)
|
||||
context.commit("update_dashboard",resp.data.dashboard)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message", e.message )
|
||||
}
|
||||
},
|
||||
async change_password(context,prm) {
|
||||
try {
|
||||
let resp = await menu_api.change_password(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_change_password_error",resp.message)
|
||||
} else {
|
||||
context.commit("update_change_password_error","")
|
||||
}
|
||||
} catch(e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user