412 lines
14 KiB
JavaScript
412 lines
14 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/dokter.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
last_id: -1,
|
|
act: 'new',
|
|
lookup_dokter: 0,
|
|
lookup_error_message: '',
|
|
dokters: [],
|
|
total_dokters: 0,
|
|
total_filter_dokters: 0,
|
|
selected_dokter: {
|
|
name: ""
|
|
},
|
|
save_status: 0,
|
|
save_error_message: '',
|
|
dialog_form_dokter: false,
|
|
dialog_edit_form_dokter: false,
|
|
alert_success: false,
|
|
alert_error: false,
|
|
msg_success: "",
|
|
msg_error:"",
|
|
show_all: 'N',
|
|
errors: [],
|
|
doktertypes: [],
|
|
doktertype: {},
|
|
doctors: [],
|
|
doctor: {},
|
|
get_data_status: 0,
|
|
get_data_error_message: '',
|
|
cities: [],
|
|
doctor_address: {},
|
|
autocomplete_status: 0,
|
|
search_status: 0,
|
|
districts: [],
|
|
district_address: {},
|
|
kelurahans: [],
|
|
kelurahan_address: {},
|
|
instruments: [],
|
|
instrument: {},
|
|
autotemplates: [],
|
|
autotemplate: {},
|
|
nonlabs: [],
|
|
selected_nonlab: {},
|
|
current_page:1,
|
|
x_search: '',
|
|
|
|
// dropdown dokter
|
|
itemdokters:[],
|
|
itemdokter:{},
|
|
|
|
// dropdown mou
|
|
itemmous:[],
|
|
itemmou:{},
|
|
|
|
open_print_note: false
|
|
},
|
|
mutations: {
|
|
// tambahan dokter
|
|
update_itemdokter(state, val) {
|
|
state.itemdokter = val
|
|
},
|
|
|
|
update_itemdokters(state, val) {
|
|
state.itemdokters = val
|
|
},
|
|
|
|
// tambahan mou
|
|
update_itemmou(state, val) {
|
|
state.itemmou = val
|
|
},
|
|
|
|
update_itemmous(state, val) {
|
|
// console.log("update itemmous",val)
|
|
// console.log()
|
|
state.itemmous = val
|
|
},
|
|
|
|
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_dokter(state, status) {
|
|
state.lookup_dokter = status
|
|
},
|
|
update_dokters(state, data) {
|
|
state.dokters = data.records
|
|
state.total_dokters = data.total
|
|
state.total_filter_dokters = data.total_filter
|
|
},
|
|
update_selected_dokter(state, val) {
|
|
state.selected_dokter = val
|
|
},
|
|
update_save_status(state, val) {
|
|
state.save_status = val
|
|
},
|
|
update_save_error_message(state, val) {
|
|
state.save_error_message = val
|
|
},
|
|
update_dialog_form_dokter(state, val) {
|
|
state.dialog_form_dokter = val
|
|
},
|
|
update_dialog_edit_form_dokter(state, val) {
|
|
state.dialog_edit_form_dokter = val
|
|
},
|
|
update_alert_success(state, val) {
|
|
state.alert_success = val
|
|
},
|
|
update_msg_success(state, val) {
|
|
state.msg_success = val
|
|
},
|
|
|
|
// error
|
|
update_alert_error(state, val) {
|
|
state.alert_error = val
|
|
},
|
|
update_msg_error(state, val) {
|
|
state.msg_error = val
|
|
},
|
|
|
|
update_doktertypes(state, data) {
|
|
state.doktertypes = data
|
|
},
|
|
update_doktertype(state, val) {
|
|
state.doktertype = 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_doctor_address(state, val) {
|
|
state.doctor_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_autotemplates(state, data) {
|
|
state.autotemplates = data
|
|
},
|
|
update_autotemplate(state, val) {
|
|
state.autotemplate = val
|
|
},
|
|
update_nonlabs(state, val) {
|
|
state.nonlabs = val
|
|
},
|
|
update_selected_nonlab(state, val) {
|
|
state.selected_nonlab = val
|
|
},
|
|
|
|
// print
|
|
update_open_print_note(state, val) {
|
|
state.open_print_note = val
|
|
}
|
|
},
|
|
actions: {
|
|
async search(context, prm) {
|
|
context.commit("update_lookup_dokter", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.search(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_lookup_dokter", 3)
|
|
context.commit("update_lookup_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_lookup_dokter", 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_dokters", data)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_lookup_dokter", 3)
|
|
context.commit("update_lookup_error_message", e.message)
|
|
}
|
|
},
|
|
|
|
// dokter autocomplete
|
|
async searchdokterautocomplete(context, prm) {
|
|
// console.log("module");
|
|
context.commit("update_autocomplete_status", 1)
|
|
try {
|
|
let resp = await api.searchdokterautocomplete(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_itemdokters", resp.data.records)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_autocomplete_status", 3)
|
|
}
|
|
},
|
|
|
|
// mou autocomplete
|
|
async searchmouautocomplete(context, prm) {
|
|
// console.log("module", prm);
|
|
context.commit("update_autocomplete_status", 1)
|
|
try {
|
|
let resp = await api.searchmouautocomplete(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_itemmous", resp.data.records)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_autocomplete_status", 3)
|
|
}
|
|
},
|
|
|
|
|
|
async save(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.add(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_alert_error", true)
|
|
console.log(resp.message)
|
|
context.commit("update_msg_error", resp.message)
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_save_error_message", resp.message)
|
|
|
|
// context.commit("update_errors", resp.data.errors)
|
|
context.commit("update_alert_success", true)
|
|
context.commit("update_dialog_form_dokter", false)
|
|
var msg = " " + 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_dokter", false)
|
|
var msg =" dokter " + prm.username + " sudah tersimpan dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
context.dispatch("search", {
|
|
// dokter: prm.sdokter,
|
|
search: "",
|
|
current_page: 1,
|
|
lastid: -1
|
|
})
|
|
|
|
// context.dispatch("search", {
|
|
// search: prm.M_UserUsername,
|
|
// 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)
|
|
|
|
// // context.commit("update_errors", resp.data.errors)
|
|
// context.commit("update_alert_success", true)
|
|
// context.commit("update_dialog_form_dokter", false)
|
|
// var msg = " " + 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_dokter", false)
|
|
var msg = " dokter " + prm.username + " sudah terupdate dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
// console.log("current page : ", prm.curr_pagex)
|
|
context.dispatch("search", {
|
|
search: "",
|
|
// search: this.$store.state.dokter.x_search,
|
|
// current_page: 1,
|
|
current_page: prm.curr_pagex,
|
|
lastid: -1
|
|
})
|
|
}else {
|
|
context.commit("update_msg_success", msg)
|
|
}
|
|
|
|
}
|
|
} 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.id)
|
|
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 = " dokter " + prm.M_UserUsername + " sudah dihapus dong"
|
|
context.commit("update_msg_success", msg)
|
|
context.commit("update_alert_success", true)
|
|
context.commit("update_selected_dokter", {})
|
|
// context.dispatch("search", {
|
|
// search: prm.M_UserUsername,
|
|
// search: this.$store.state.dokter.x_search,
|
|
// current_page: 1,
|
|
// lastid: -1
|
|
// })
|
|
|
|
context.dispatch("search", {
|
|
// search: prm.M_UserUsername,
|
|
search: "",
|
|
current_page: 1,
|
|
lastid: -1
|
|
})
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
console.log(e)
|
|
}
|
|
},
|
|
}
|
|
} |