549 lines
22 KiB
JavaScript
549 lines
22 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/tatgroup.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
last_id: -1,
|
|
act: 'new',
|
|
lookup_tatgroup: 0,
|
|
lookup_error_message: '',
|
|
tatgroups: [],
|
|
total_tatgroups: 0,
|
|
total_filter_tatgroups: 0,
|
|
selected_tatgroup: {
|
|
name: ""
|
|
},
|
|
save_status: 0,
|
|
save_error_message: '',
|
|
dialog_form_tatgroup: false,
|
|
dialog_edit_form_tatgroup: false,
|
|
alert_success: false,
|
|
msg_success: "",
|
|
show_all: 'N',
|
|
errors: [],
|
|
tatgrouptypes: [],
|
|
tatgrouptype: {},
|
|
doctors: [],
|
|
doctor: {},
|
|
get_data_status: 0,
|
|
get_data_error_message: '',
|
|
cities: [],
|
|
tatitem_address: {},
|
|
autocomplete_status: 0,
|
|
search_status: 0,
|
|
districts: [],
|
|
district_address: {},
|
|
kelurahans: [],
|
|
kelurahan_address: {},
|
|
instruments: [],
|
|
instrument: {},
|
|
autogroups: [],
|
|
autogroup: {},
|
|
nonlabs: [],
|
|
selected_nonlab: {},
|
|
current_page:1,
|
|
x_search: ''
|
|
},
|
|
mutations: {
|
|
update_x_search(state, val) {
|
|
state.x_search = val
|
|
},
|
|
update_current_page(state, val) {
|
|
state.current_page = val
|
|
},
|
|
update_last_id(state, val) {
|
|
state.last_id = val
|
|
},
|
|
update_act(state, val) {
|
|
state.act = val
|
|
},
|
|
update_errors(state, val) {
|
|
state.errors = val
|
|
},
|
|
update_show_all(state, val) {
|
|
state.show_all = val
|
|
},
|
|
update_lookup_error_message(state, status) {
|
|
state.lookup_error_message = status
|
|
},
|
|
update_lookup_tatgroup(state, status) {
|
|
state.lookup_tatgroup = status
|
|
},
|
|
update_tatgroups(state, data) {
|
|
state.tatgroups = data.records
|
|
state.total_tatgroups = data.total
|
|
state.total_filter_tatgroups = data.total_filter
|
|
},
|
|
update_selected_tatgroup(state, val) {
|
|
state.selected_tatgroup = val
|
|
},
|
|
update_save_status(state, val) {
|
|
state.save_status = val
|
|
},
|
|
update_save_error_message(state, val) {
|
|
state.save_error_message = val
|
|
},
|
|
update_dialog_form_tatgroup(state, val) {
|
|
state.dialog_form_tatgroup = val
|
|
},
|
|
update_dialog_edit_form_tatgroup(state, val) {
|
|
state.dialog_edit_form_tatgroup = val
|
|
},
|
|
update_alert_success(state, val) {
|
|
state.alert_success = val
|
|
},
|
|
update_msg_success(state, val) {
|
|
state.msg_success = val
|
|
},
|
|
update_tatgrouptypes(state, data) {
|
|
state.tatgrouptypes = data
|
|
},
|
|
update_tatgrouptype(state, val) {
|
|
state.tatgrouptype = val
|
|
},
|
|
update_doctors(state, data) {
|
|
state.doctors = data
|
|
},
|
|
update_doctor(state, val) {
|
|
state.doctor = val
|
|
},
|
|
update_get_data_status(state, val) {
|
|
state.get_data_status = val
|
|
},
|
|
update_get_data_error_message(state, val) {
|
|
state.get_data_error_message = val
|
|
},
|
|
update_cities(state, val) {
|
|
state.cities = val
|
|
},
|
|
update_tatitem_address(state, val) {
|
|
state.tatitem_address = val
|
|
},
|
|
update_autocomplete_status(state, val) {
|
|
state.autocomplete_status = val
|
|
},
|
|
update_districts(state, val) {
|
|
state.districts = val
|
|
},
|
|
update_district_address(state, val) {
|
|
state.district_address = val
|
|
},
|
|
update_kelurahans(state, val) {
|
|
state.kelurahans = val
|
|
},
|
|
update_kelurahan_address(state, val) {
|
|
state.kelurahan_address = val
|
|
},
|
|
update_instruments(state, data) {
|
|
state.instruments = data
|
|
},
|
|
update_instrument(state, val) {
|
|
state.instrument = val
|
|
},
|
|
update_autogroups(state, data) {
|
|
state.autogroups = data
|
|
},
|
|
update_autogroup(state, val) {
|
|
state.autogroup = val
|
|
},
|
|
update_nonlabs(state, val) {
|
|
state.nonlabs = val
|
|
},
|
|
update_selected_nonlab(state, val) {
|
|
state.selected_nonlab = val
|
|
}
|
|
|
|
|
|
},
|
|
actions: {
|
|
async lookup(context, prm) {
|
|
context.commit("update_lookup_tatgroup", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.lookup(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_lookup_tatgroup", 3)
|
|
context.commit("update_lookup_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_lookup_tatgroup", 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_tatgroups", data)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_lookup_tatgroup", 3)
|
|
context.commit("update_lookup_error_message", e.message)
|
|
}
|
|
},
|
|
async lookupbytatitem(context, prm) {
|
|
context.commit("update_lookup_tatgroup", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.lookupbytatitem(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_lookup_tatgroup", 3)
|
|
context.commit("update_lookup_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_lookup_tatgroup", 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_tatgroups", data)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_lookup_tatgroup", 3)
|
|
context.commit("update_lookup_error_message", e.message)
|
|
}
|
|
},
|
|
async lookupbydistrict(context, prm) {
|
|
context.commit("update_lookup_tatgroup", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.lookupbydistrict(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_lookup_tatgroup", 3)
|
|
context.commit("update_lookup_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_lookup_tatgroup", 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_tatgroups", data)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_lookup_tatgroup", 3)
|
|
context.commit("update_lookup_error_message", e.message)
|
|
}
|
|
},
|
|
async lookupbykelurahan(context, prm) {
|
|
context.commit("update_lookup_tatgroup", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.lookupbykelurahan(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_lookup_tatgroup", 3)
|
|
context.commit("update_lookup_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_lookup_tatgroup", 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_tatgroups", data)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_lookup_tatgroup", 3)
|
|
context.commit("update_lookup_error_message", e.message)
|
|
}
|
|
},
|
|
async lookupbyname(context, prm) {
|
|
context.commit("update_lookup_tatgroup", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.lookupbyname(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_lookup_tatgroup", 3)
|
|
context.commit("update_lookup_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_lookup_tatgroup", 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_tatgroups", data)
|
|
var pat = data.records[0]
|
|
if(prm.tatgroup != ""){
|
|
context.commit("tatitem/update_autotatgroups", [{
|
|
NatTatGroupID: pat.NatTatGroupID,
|
|
NatTatGroupName: pat.NatTatGroupName
|
|
}], { root: true })
|
|
context.commit("tatitem/update_autotatgroup", {
|
|
NatTatGroupID: pat.NatTatGroupID,
|
|
NatTatGroupName: pat.NatTatGroupName
|
|
},{ root: true })
|
|
}
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_lookup_tatgroup", 3)
|
|
context.commit("update_lookup_error_message", e.message)
|
|
}
|
|
},
|
|
async save(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.save(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_save_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_save_error_message", resp.message)
|
|
context.commit("update_save_error_message", resp.message)
|
|
var data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
|
|
if (data.total !== -1) {
|
|
context.commit("update_errors", [])
|
|
context.commit("update_alert_success", true)
|
|
context.commit("update_dialog_form_tatgroup", false)
|
|
var msg =" Grup TAT " + prm.name + " sudah tersimpan dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
context.dispatch("lookupbyname", {
|
|
tatgroup: prm.statgroup,
|
|
tatitem: prm.statitem,
|
|
district: prm.sdistrict,
|
|
kelurahan: prm.skelurahan,
|
|
current_page: 1,
|
|
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)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async update(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.update(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_save_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_save_error_message", resp.message)
|
|
context.commit("update_save_error_message", resp.message)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
|
|
if (data.total !== -1) {
|
|
context.commit("update_alert_success", true)
|
|
context.commit("update_dialog_form_tatgroup", false)
|
|
var msg = " Grup TAT " + prm.name + " sudah terupdate dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
context.dispatch("lookupbyname", {
|
|
tatgroup: prm.statgroup,
|
|
tatitem: prm.statitem,
|
|
district: prm.sdistrict,
|
|
kelurahan: prm.skelurahan,
|
|
current_page: 1,
|
|
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)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async delete(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
let resp = await api.xdelete(one_token(), prm.tatgroupid)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_save_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_save_error_message", resp.message)
|
|
context.commit("update_alert_success", true)
|
|
|
|
var msg = " Grup TAT " + prm.name + " sudah dihapus dong"
|
|
context.commit("update_msg_success", msg)
|
|
context.commit("update_alert_success", true)
|
|
context.commit("update_selected_tatgroup", {})
|
|
context.dispatch("lookupbyname", {
|
|
tatgroup: prm.statgroup,
|
|
tatitem: prm.statitem,
|
|
district: prm.sdistrict,
|
|
kelurahan: prm.skelurahan,
|
|
current_page: 1,
|
|
lastid: -1
|
|
})
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async selectnonlab(context) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
let resp = await api.selectnonlab(one_token())
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status", 3)
|
|
context.commit("update_get_data_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_get_data_status", 2)
|
|
context.commit("update_get_data_error_message", "")
|
|
context.commit("update_nonlabs", resp.data.records.nonlabs)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_get_data_status", 3)
|
|
context.commit("update_get_data_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async selectdoctor(context) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
let resp = await api.selectdoctor(one_token())
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status", 3)
|
|
context.commit("update_get_data_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_get_data_status", 2)
|
|
context.commit("update_get_data_error_message", "")
|
|
context.commit("update_doctors", resp.data.records.doctors)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_get_data_status", 3)
|
|
context.commit("update_get_data_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async searchtatitem(context, prm) {
|
|
context.commit("update_autocomplete_status", 1)
|
|
try {
|
|
let resp = await api.searchtatitem(one_token(), prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_autocomplete_status", 3)
|
|
} else {
|
|
context.commit("update_autocomplete_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_cities", resp.data.records)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_autocomplete_status", 3)
|
|
}
|
|
},
|
|
async searchdoctor(context, prm) {
|
|
context.commit("update_autocomplete_status", 1)
|
|
try {
|
|
let resp = await api.searchdoctor(one_token(), prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_autocomplete_status", 3)
|
|
} else {
|
|
context.commit("update_autocomplete_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_doctors", resp.data.records)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_autocomplete_status", 3)
|
|
}
|
|
},
|
|
async searchinstrument(context, prm) {
|
|
context.commit("update_autocomplete_status", 1)
|
|
try {
|
|
let resp = await api.searchinstrument(one_token(), prm.tes)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_autocomplete_status", 3)
|
|
} else {
|
|
context.commit("update_autocomplete_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_instruments", resp.data.records)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_autocomplete_status", 3)
|
|
}
|
|
},
|
|
async searchgroup(context, prm) {
|
|
context.commit("update_autocomplete_status", 1)
|
|
try {
|
|
let resp = await api.searchgroup(one_token(), prm.tes)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_autocomplete_status", 3)
|
|
} else {
|
|
context.commit("update_autocomplete_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_autogroups", resp.data.records)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_autocomplete_status", 3)
|
|
}
|
|
},
|
|
async getdistrict(context, prm) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
let resp = await api.getdistrict(one_token(), prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status", 3)
|
|
} else {
|
|
context.commit("update_get_data_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_districts", resp.data.records)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_get_data_status", 3)
|
|
}
|
|
},
|
|
async getkelurahan(context, prm) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
let resp = await api.getkelurahan(one_token(), prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status", 3)
|
|
} else {
|
|
context.commit("update_get_data_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_kelurahans", resp.data.records)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_get_data_status", 3)
|
|
}
|
|
}
|
|
}
|
|
} |