add modules folder based on s_menu
This commit is contained in:
135
test/vuex/acc-one-transfer-req/modules/np_data.js
Normal file
135
test/vuex/acc-one-transfer-req/modules/np_data.js
Normal file
@@ -0,0 +1,135 @@
|
||||
import * as api from "../api/nonpersediaan_api.js";
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
user: one_user(),
|
||||
user_level: {},
|
||||
filter_sdate: new Date().toISOString().substr(0, 10),
|
||||
filter_edate: new Date().toISOString().substr(0, 10),
|
||||
filter_cabang: {
|
||||
M_BranchID: "0",
|
||||
M_BranchCode: "All",
|
||||
M_BranchName: "Semua"
|
||||
},
|
||||
filter_status: "All",
|
||||
filter_search: "",
|
||||
listing_cabang: [],
|
||||
listing_status: [
|
||||
"All",
|
||||
"Draft",
|
||||
"Verified",
|
||||
"Process",
|
||||
"Completed"
|
||||
],
|
||||
|
||||
listing_tf_req: {
|
||||
total: 0,
|
||||
records: []
|
||||
},
|
||||
listing_tf_page: 1,
|
||||
selected_tf: {}
|
||||
},
|
||||
mutations: {
|
||||
update_filter_sdate(state, data) {
|
||||
state.filter_sdate = data
|
||||
},
|
||||
update_filter_edate(state, data) {
|
||||
state.filter_edate = data
|
||||
},
|
||||
update_filter_cabang(state, data) {
|
||||
state.filter_cabang = data
|
||||
},
|
||||
update_filter_status(state, data) {
|
||||
state.filter_status = data
|
||||
},
|
||||
update_filter_search(state, data) {
|
||||
state.filter_search = data
|
||||
},
|
||||
update_listing_cabang(state, data) {
|
||||
state.listing_cabang = data
|
||||
},
|
||||
update_listing_status(state, data) {
|
||||
state.listing_status = data
|
||||
},
|
||||
update_listing_tf_req(state, data) {
|
||||
state.listing_tf_req = data
|
||||
},
|
||||
update_listing_tf_page(state, data) {
|
||||
state.listing_tf_page = data
|
||||
},
|
||||
update_selected_tf(state, data) {
|
||||
state.selected_tf = data
|
||||
},
|
||||
update_user_level(state, data) {
|
||||
state.user_level = data
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async getBranches(context) {
|
||||
try {
|
||||
let params = {
|
||||
token: one_token(),
|
||||
S_RegionalID: context.state.user.S_RegionalID
|
||||
}
|
||||
|
||||
let resp = await api.getBranches(params);
|
||||
if (resp.status != 'OK') {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
} else {
|
||||
let all = [
|
||||
{
|
||||
M_BranchID: "0",
|
||||
M_BranchCode: "All",
|
||||
M_BranchName: "Semua"
|
||||
}
|
||||
]
|
||||
all.concat(resp.data.records)
|
||||
context.commit("update_listing_cabang", all)
|
||||
}
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
},
|
||||
async cariTF(context) {
|
||||
try {
|
||||
let params = {
|
||||
token: one_token(),
|
||||
startDate: context.state.filter_sdate,
|
||||
endDate: context.state.filter_edate,
|
||||
M_BranchCode: context.state.filter_cabang.M_BranchCode,
|
||||
StatusName: context.state.filter_status,
|
||||
currentPage: context.state.listing_tf_page,
|
||||
search: context.state.filter_search
|
||||
}
|
||||
|
||||
let resp = await api.search(params)
|
||||
if (resp.status != "OK") {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
} else [
|
||||
context.commit("update_listing_tf_req", resp.data)
|
||||
]
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
},
|
||||
async userLevel(context) {
|
||||
try {
|
||||
let resp = await api.getUserLevel({token: one_token()})
|
||||
if (resp.status != 'OK') {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + resp.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
} else {
|
||||
context.commit("update_user_level", resp.data)
|
||||
}
|
||||
} catch (error) {
|
||||
let snac = { isOpen: true, color: "error", msg: "Gagal, " + error.message }
|
||||
context.commit("p_data/update_snackbar", snac, { root: true })
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user