Initial import
This commit is contained in:
272
one-ui/masterdata/one-fisik-template/modules/fisik.js
Normal file
272
one-ui/masterdata/one-fisik-template/modules/fisik.js
Normal file
@@ -0,0 +1,272 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/fisik.js";
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
last_id: -1,
|
||||
current_page: 1,
|
||||
lookup_fisik: 0,
|
||||
lookup_error_message: "",
|
||||
fisiks: [],
|
||||
total_fisiks: 0,
|
||||
total_filter_fisiks: 0,
|
||||
selected_fisik: {},
|
||||
x_search: "",
|
||||
dialog_fisik: false,
|
||||
act: "new",
|
||||
save_status: 2,
|
||||
loading_save: false,
|
||||
error_message: "",
|
||||
alert_error: false,
|
||||
dialog_error: false,
|
||||
msg_success: "",
|
||||
alert_success: false,
|
||||
nat_tests: [],
|
||||
selected_nat_test: {},
|
||||
snackbar: {
|
||||
value: false,
|
||||
color: "info",
|
||||
mode: "single-line",
|
||||
timeout: 500,
|
||||
text: "",
|
||||
top:false,
|
||||
bottom:true,
|
||||
left:false,
|
||||
right:true,
|
||||
},
|
||||
},
|
||||
mutations: {
|
||||
update_snackbar(state, val) {
|
||||
state.snackbar = val;
|
||||
},
|
||||
update_nat_tests(state, val) {
|
||||
state.nat_tests = val;
|
||||
},
|
||||
update_selected_nat_test(state, val) {
|
||||
state.selected_nat_test = val;
|
||||
},
|
||||
update_lookup_fisik(state, status) {
|
||||
state.lookup_fisik = status;
|
||||
},
|
||||
update_lookup_error_message(state, status) {
|
||||
state.lookup_error_message = status;
|
||||
},
|
||||
update_current_page(state, val) {
|
||||
state.current_page = val;
|
||||
},
|
||||
update_last_id(state, val) {
|
||||
state.last_id = val;
|
||||
},
|
||||
update_fisiks(state, data) {
|
||||
state.fisiks = data.records;
|
||||
state.total_fisiks = data.total;
|
||||
state.total_filter_fisiks = data.total_filter;
|
||||
},
|
||||
update_selected_fisik(state, val) {
|
||||
state.selected_fisik = val;
|
||||
},
|
||||
update_x_search(state, val) {
|
||||
state.x_search = val;
|
||||
},
|
||||
update_dialog_fisik(state, val) {
|
||||
state.dialog_fisik = val;
|
||||
},
|
||||
update_act(state, val) {
|
||||
state.act = 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;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
async fisikTemplateMappingList(context, prm) {
|
||||
context.commit("update_lookup_fisik", 1);
|
||||
try {
|
||||
prm.token = one_token();
|
||||
prm.status = context.rootState.fisikdetail.selected_filter_flag.value;
|
||||
prm.id
|
||||
let resp = await api.fisikTemplateMappingList(prm);
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_fisik", 3);
|
||||
context.commit("update_lookup_error_message", resp.message);
|
||||
} else {
|
||||
context.commit("update_lookup_fisik", 2);
|
||||
context.commit("update_lookup_error_message", "");
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total,
|
||||
total_filter: resp.data.total_filter,
|
||||
};
|
||||
context.commit("update_fisiks", data);
|
||||
if (prm.lastid === -1) {
|
||||
var pat = data.records[0];
|
||||
context.commit("update_selected_fisik", data.records[0]);
|
||||
context.dispatch(
|
||||
"fisikdetail/findFisikTemplate",
|
||||
{
|
||||
id: pat.id,
|
||||
code: "",
|
||||
name: "",
|
||||
current_page: 1,
|
||||
status: context.rootState.fisikdetail.selected_filter_flag.value,
|
||||
lastid: -1,
|
||||
},
|
||||
{
|
||||
root: true,
|
||||
}
|
||||
);
|
||||
} else {
|
||||
var pat = data.records[prm.lastid];
|
||||
context.commit("update_selected_fisik", data.records[prm.lastid]);
|
||||
context.dispatch(
|
||||
"fisikdetail/findFisikTemplate",
|
||||
{
|
||||
id: pat.id,
|
||||
code: "",
|
||||
name: "",
|
||||
current_page: 1,
|
||||
status: context.rootState.fisikdetail.selected_filter_flag.value,
|
||||
lastid: -1,
|
||||
},
|
||||
{
|
||||
root: true,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
context.commit("fisikdetail/update_selected_filter_status", {'value': 'Y', 'text': 'Sudah dipilih'},{root: true});
|
||||
context.dispatch("searchNatTest", {
|
||||
search_nat_test: "",
|
||||
filter_status: context.rootState.fisikdetail.selected_filter_status
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_lookup_fisik", 3);
|
||||
context.commit("update_lookup_error_message", e.message);
|
||||
}
|
||||
},
|
||||
|
||||
async addFisikTemplateMapping(context, prm) {
|
||||
context.commit("update_save_status", 1);
|
||||
try {
|
||||
context.commit("update_loading_save", true);
|
||||
prm.token = one_token();
|
||||
let resp = await api.addFisikTemplateMapping(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 = "Fisik template " + prm.name + " berhasil disimpan";
|
||||
context.commit("update_msg_success", msg);
|
||||
context.commit("update_alert_success", true);
|
||||
context.commit("update_dialog_error", true);
|
||||
context.commit("update_dialog_fisik", false);
|
||||
context.dispatch("fisikTemplateMappingList", {
|
||||
fisikname: "",
|
||||
current_page: 1,
|
||||
lastid: -1,
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_loading_save", false);
|
||||
context.commit("update_error_message", e.message);
|
||||
context.commit("update_alert_error", true);
|
||||
}
|
||||
},
|
||||
async searchNatTest(context, prm) {
|
||||
context.commit("update_save_status", 1);
|
||||
try {
|
||||
context.commit("update_loading_save", true);
|
||||
prm.token = one_token();
|
||||
prm.id = context.rootState.fisik.selected_fisik.id;
|
||||
let resp = await api.searchNatTest(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_nat_tests", resp.data.records);
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_loading_save", false);
|
||||
context.commit("update_error_message", e.message);
|
||||
context.commit("update_alert_error", true);
|
||||
}
|
||||
},
|
||||
async addNatTestMapping(context, prm) {
|
||||
context.commit("update_save_status", 1);
|
||||
try {
|
||||
context.commit("update_loading_save", true);
|
||||
prm.token = one_token();
|
||||
let resp = await api.addNatTestMapping(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.dispatch("searchNatTest", {
|
||||
search_nat_test: "",
|
||||
filter_status: context.rootState.fisikdetail.selected_filter_status
|
||||
});
|
||||
context.commit("update_snackbar", {
|
||||
value: true,
|
||||
color: "success",
|
||||
mode: "single-line",
|
||||
timeout: 3000,
|
||||
text: resp.data.records.status == "Y" ? "Tes " + prm.Nat_TestName + " berhasil dipilih" : "Tes " + prm.Nat_TestName + " berhasil dihapus",
|
||||
top:false,
|
||||
bottom:true,
|
||||
left:false,
|
||||
right:true,
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_loading_save", false);
|
||||
context.commit("update_error_message", e.message);
|
||||
context.commit("update_alert_error", true);
|
||||
}
|
||||
},
|
||||
|
||||
},
|
||||
};
|
||||
136
one-ui/masterdata/one-fisik-template/modules/fisikdetail.js
Normal file
136
one-ui/masterdata/one-fisik-template/modules/fisikdetail.js
Normal file
@@ -0,0 +1,136 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/fisikdetail.js";
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
lookup_status: 2,
|
||||
fisikdetails: [],
|
||||
total_data: 0,
|
||||
current_page: 1,
|
||||
selected_fisikdetail: {},
|
||||
x_search: "",
|
||||
save_status: 2,
|
||||
save_error_message: "",
|
||||
errors: [],
|
||||
fisiknat_tests: [],
|
||||
selected_filter_status: {'value': 'Y', 'text': 'Sudah dipilih'},
|
||||
f_statuss: [{'value': 'Y', 'text': 'Sudah dipilih'}, {'value': 'N', 'text': 'Belum dipilih'}],
|
||||
selected_filter_flag: {'value': 'Y', 'text': 'Sudah dipilih'},
|
||||
},
|
||||
mutations: {
|
||||
update_selected_filter_flag(state, val) {
|
||||
state.selected_filter_flag = val;
|
||||
},
|
||||
update_selected_filter_status(state, val) {
|
||||
state.selected_filter_status = val;
|
||||
},
|
||||
update_f_statuss(state, val) {
|
||||
state.f_statuss = val;
|
||||
},
|
||||
update_lookup_status(state, val) {
|
||||
state.lookup_status = val;
|
||||
},
|
||||
update_fisikdetails(state, val) {
|
||||
state.fisikdetails = val;
|
||||
},
|
||||
update_total_data(state, val) {
|
||||
state.total_data = val;
|
||||
},
|
||||
update_current_page(state, val) {
|
||||
state.current_page = val;
|
||||
},
|
||||
update_selected_fisikdetail(state, val) {
|
||||
state.selected_fisikdetail = val;
|
||||
},
|
||||
update_x_search(state, val) {
|
||||
state.x_search = val;
|
||||
},
|
||||
update_save_status(state, val) {
|
||||
state.save_status = val;
|
||||
},
|
||||
update_save_error_message(state, val) {
|
||||
state.save_error_message = val;
|
||||
},
|
||||
update_errors(state, val) {
|
||||
state.errors = val;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
async findFisikTemplate(context, prm) {
|
||||
context.commit("update_lookup_status", 1);
|
||||
try {
|
||||
prm.token = one_token();
|
||||
let resp = await api.findFisikTemplate(prm);
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_status", 3);
|
||||
} else {
|
||||
context.commit("update_lookup_status", 2);
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total,
|
||||
};
|
||||
context.commit("update_fisikdetails", data.records);
|
||||
context.commit("update_total_data", data.total);
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_lookup_status", 3);
|
||||
}
|
||||
},
|
||||
|
||||
async saveAddFisikTemplateMappingDetail(context, prm) {
|
||||
context.commit("update_save_status", 1);
|
||||
try {
|
||||
prm.token = one_token();
|
||||
let resp = await api.saveAddFisikTemplateMappingDetail(prm);
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3);
|
||||
context.commit("update_save_error_message", resp.message);
|
||||
} else {
|
||||
var data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total,
|
||||
};
|
||||
if (data.total !== -1) {
|
||||
context.commit("update_save_status", 2);
|
||||
context.commit("update_save_error_message", resp.message);
|
||||
context.commit("fisik/update_alert_success", true, {
|
||||
root: true,
|
||||
});
|
||||
|
||||
var msg = "";
|
||||
if (prm.status === "N") {
|
||||
msg = "Fisik Template " + prm.name + " batal dipilih";
|
||||
} else {
|
||||
msg = "Fisik Template " + prm.name + " berhasil dipilih";
|
||||
}
|
||||
context.commit("fisik/update_snackbar", {
|
||||
value: true,
|
||||
color: "success",
|
||||
text: msg,
|
||||
top:false,
|
||||
bottom:true,
|
||||
left:false,
|
||||
right:true,
|
||||
});
|
||||
context.dispatch("findFisikTemplate", {
|
||||
id: prm.templatemappingID,
|
||||
code: prm.code,
|
||||
name: prm.name,
|
||||
status: context.state.selected_filter_flag.value,
|
||||
current_page: prm.current_page,
|
||||
lastid: -1,
|
||||
});
|
||||
} else {
|
||||
context.commit("update_errors", resp.data.errors);
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3);
|
||||
context.commit("update_save_error_message", e.message);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user