Flatten nested repos
This commit is contained in:
233
test/vuex/one-md-consumable/modules/consumable.js
Normal file
233
test/vuex/one-md-consumable/modules/consumable.js
Normal file
@@ -0,0 +1,233 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/consumable.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
consumables: [],
|
||||
total_consumable: 0,
|
||||
search_status: 0,
|
||||
selected_consumable: {},
|
||||
current_page: 1,
|
||||
last_id: -1,
|
||||
x_search: "",
|
||||
save_status: 2,
|
||||
loading_save: false,
|
||||
error_message: "",
|
||||
alert_error: false,
|
||||
dialog_error: false,
|
||||
msg_success: "",
|
||||
alert_success: false,
|
||||
dialog_form: false,
|
||||
act: "",
|
||||
satuans: []
|
||||
},
|
||||
mutations: {
|
||||
update_consumables(state, val) {
|
||||
state.consumables = val
|
||||
},
|
||||
update_total_consumable(state, val) {
|
||||
state.total_consumable = val
|
||||
},
|
||||
update_search_status(state, val) {
|
||||
state.search_status = val
|
||||
},
|
||||
update_selected_consumable(state, val) {
|
||||
state.selected_consumable = val
|
||||
},
|
||||
update_current_page(state, val) {
|
||||
state.current_page = val
|
||||
},
|
||||
update_last_id(state, val) {
|
||||
state.last_id = val
|
||||
},
|
||||
update_x_search(state, val) {
|
||||
state.x_search = val
|
||||
},
|
||||
update_save_status(state, val) {
|
||||
state.save_status = val
|
||||
},
|
||||
update_loading_save(state, val) {
|
||||
state.loading_save = val
|
||||
},
|
||||
update_error_message(state, val) {
|
||||
state.error_message = val
|
||||
},
|
||||
update_alert_error(state, val) {
|
||||
state.alert_error = val
|
||||
},
|
||||
update_dialog_error(state, val) {
|
||||
state.dialog_error = val
|
||||
},
|
||||
update_msg_success(state, val) {
|
||||
state.msg_success = val
|
||||
},
|
||||
update_alert_success(state, val) {
|
||||
state.alert_success = val
|
||||
},
|
||||
update_dialog_form(state, val) {
|
||||
state.dialog_form = val
|
||||
},
|
||||
update_act(state, val) {
|
||||
state.act = val
|
||||
},
|
||||
update_satuans(state, val) {
|
||||
state.satuans = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async searchconsumable(context) {
|
||||
context.commit("update_search_status", 1)
|
||||
try {
|
||||
var prm = {
|
||||
token: one_token(),
|
||||
search: context.state.x_search,
|
||||
current_page: context.state.current_page
|
||||
}
|
||||
let resp = await api.searchconsumable(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total,
|
||||
total_filter: resp.data.total_display
|
||||
}
|
||||
context.commit("update_consumables", data.records)
|
||||
context.commit("update_total_consumable", data.total)
|
||||
if (
|
||||
!(
|
||||
Object.keys(context.state.selected_consumable).length === 0 &&
|
||||
context.state.selected_consumable.constructor === Object
|
||||
)
|
||||
){
|
||||
let idx = _.findIndex(resp.data.records, function (o) {
|
||||
return o.M_ConsumableID == context.state.selected_consumable.M_ConsumableID
|
||||
});
|
||||
if (idx >= 0) {
|
||||
context.commit("update_selected_consumable", resp.data.records[idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
}
|
||||
},
|
||||
|
||||
async addconsumable(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
context.commit("update_loading_save", true)
|
||||
prm.token = one_token()
|
||||
let resp = await api.addconsumable(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", resp.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", "")
|
||||
context.commit("update_dialog_error", false)
|
||||
context.commit("update_dialog_form", false)
|
||||
let data = resp.data
|
||||
var msg = "Item " + prm.name + " berhasil di simpan"
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_alert_success", true)
|
||||
context.dispatch("searchconsumable")
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", e.message)
|
||||
context.commit("update_alert_error", true)
|
||||
}
|
||||
},
|
||||
|
||||
async get_satuan(context) {
|
||||
try {
|
||||
var prm = { token: one_token() }
|
||||
let resp = await api.get_satuan(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records
|
||||
}
|
||||
context.commit("update_satuans", data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_error_message", e.message)
|
||||
}
|
||||
},
|
||||
|
||||
async editconsumable(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
context.commit("update_loading_save", true)
|
||||
prm.token = one_token()
|
||||
let resp = await api.editconsumable(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", resp.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", "")
|
||||
context.commit("update_dialog_error", false)
|
||||
context.commit("update_dialog_form", false)
|
||||
let data = resp.data
|
||||
var msg = "Item " + prm.name + " berhasil di edit"
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_alert_success", true)
|
||||
context.dispatch("searchconsumable")
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", e.message)
|
||||
context.commit("update_alert_error", true)
|
||||
}
|
||||
},
|
||||
|
||||
async deleteitem(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
context.commit("update_loading_save", true)
|
||||
prm.token = one_token()
|
||||
let resp = await api.deleteitem(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", resp.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", "")
|
||||
context.commit("update_dialog_error", false)
|
||||
let data = resp.data
|
||||
var msg = "Item " + prm.name + " berhasil di hapus"
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_alert_success", true)
|
||||
context.dispatch("searchconsumable")
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", e.message)
|
||||
context.commit("update_alert_error", true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
211
test/vuex/one-md-consumable/modules/satuan.js
Normal file
211
test/vuex/one-md-consumable/modules/satuan.js
Normal file
@@ -0,0 +1,211 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/satuan.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
satuans: [],
|
||||
total_satuan: 0,
|
||||
selected_satuan: {},
|
||||
search_status: 0,
|
||||
last_id: -1,
|
||||
x_search: "",
|
||||
current_page: 1,
|
||||
save_status: 2,
|
||||
loading_save: false,
|
||||
error_message: "",
|
||||
alert_error: false,
|
||||
dialog_error: false,
|
||||
msg_success: "",
|
||||
alert_success: false,
|
||||
act: "add",
|
||||
dialog_form: false
|
||||
},
|
||||
mutations: {
|
||||
update_satuans(state, val) {
|
||||
state.satuans = val
|
||||
},
|
||||
update_total_satuan(state, val) {
|
||||
state.total_satuan = val
|
||||
},
|
||||
update_selected_satuan(state, val) {
|
||||
state.selected_satuan = val
|
||||
},
|
||||
update_search_status(state, val) {
|
||||
state.search_status = val
|
||||
},
|
||||
update_last_id(state, val) {
|
||||
state.last_id = val
|
||||
},
|
||||
update_x_search(state, val) {
|
||||
state.x_search = val
|
||||
state.current_page = 1
|
||||
},
|
||||
update_current_page(state, val) {
|
||||
state.current_page = val
|
||||
},
|
||||
update_save_status(state, val) {
|
||||
state.save_status = val
|
||||
},
|
||||
update_loading_save(state, val) {
|
||||
state.loading_save = val
|
||||
},
|
||||
update_error_message(state, val) {
|
||||
state.error_message = val
|
||||
},
|
||||
update_alert_error(state, val) {
|
||||
state.alert_error = val
|
||||
},
|
||||
update_dialog_error(state, val) {
|
||||
state.dialog_error = val
|
||||
},
|
||||
update_msg_success(state, val) {
|
||||
state.msg_success = val
|
||||
},
|
||||
update_alert_success(state, val) {
|
||||
state.alert_success = val
|
||||
},
|
||||
update_act(state, val) {
|
||||
state.act = val
|
||||
},
|
||||
update_dialog_form(state, val) {
|
||||
state.dialog_form = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async searchsatuan(context) {
|
||||
context.commit("update_search_status", 1)
|
||||
try {
|
||||
var prm = {
|
||||
token: one_token(),
|
||||
search: context.state.x_search,
|
||||
current_page: context.state.current_page
|
||||
}
|
||||
let resp = await api.searchsatuan(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total_page: resp.data.total_page,
|
||||
total_filter: resp.data.total_filter
|
||||
}
|
||||
context.commit("update_satuans", data.records)
|
||||
context.commit("update_total_satuan", data.total_page)
|
||||
if (
|
||||
!(
|
||||
Object.keys(context.state.selected_satuan).length === 0 &&
|
||||
context.state.selected_satuan.constructor === Object
|
||||
)
|
||||
){
|
||||
let idx = _.findIndex(resp.data.records, function (o) {
|
||||
return o.M_SatuanID == context.state.selected_satuan.M_SatuanID
|
||||
});
|
||||
if (idx >= 0) {
|
||||
context.commit("update_selected_satuan", resp.data.records[idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
}
|
||||
},
|
||||
|
||||
async addsatuan(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
context.commit("update_loading_save", true)
|
||||
prm.token = one_token()
|
||||
let resp = await api.addsatuan(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", resp.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", "")
|
||||
context.commit("update_dialog_error", false)
|
||||
context.commit("update_dialog_form", false)
|
||||
let data = resp.data
|
||||
var msg = "Satuan " + prm.name + " berhasil disimpan"
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_alert_success", true)
|
||||
context.dispatch("searchsatuan")
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", e.message)
|
||||
context.commit("update_alert_error", true)
|
||||
}
|
||||
},
|
||||
|
||||
async edit(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
context.commit("update_loading_save", true)
|
||||
prm.token = one_token()
|
||||
let resp = await api.edit(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", resp.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", "")
|
||||
context.commit("update_dialog_error", false)
|
||||
context.commit("update_dialog_form", false)
|
||||
var msg = "Satuan " + prm.name + " berhasil di edit"
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_alert_success", true)
|
||||
context.dispatch("searchsatuan")
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", e.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
}
|
||||
},
|
||||
|
||||
async deleterow(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
context.commit("update_loading_save", true)
|
||||
prm.token = one_token()
|
||||
let resp = await api.deleterow(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", resp.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", "")
|
||||
context.commit("update_dialog_error", false)
|
||||
context.commit("update_dialog_form", false)
|
||||
var msg = prm.name + " berhasil dihapus"
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_alert_success", true)
|
||||
context.dispatch("searchsatuan")
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", e.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user