521 lines
19 KiB
JavaScript
521 lines
19 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/staff.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
last_id:-1,
|
|
last_saved_id:-1,
|
|
x_addr_id:0,
|
|
act:'edit',
|
|
act_addr:'new',
|
|
get_data_status:0,
|
|
search_staff: 0,
|
|
search_status: 0,
|
|
search_error_message: '',
|
|
statuses:[{label:'Belum dikonfirmasi marketing', value:'N'},{label:'Sudah dikonfirmasi marketing', value:'Y'}],
|
|
selected_status:{label:'Belum dikonfirmasi marketing', value:'N'},
|
|
preffix:'',
|
|
staff_name:'',
|
|
suffix:'',
|
|
staffs: [],
|
|
total_staffs:0,
|
|
homeservice_staffs: [],
|
|
total_homeservice_staffs:0,
|
|
staff_address: [],
|
|
sexes:[],
|
|
selected_sex:{},
|
|
religions:[],
|
|
selected_religion:{},
|
|
phone:'',
|
|
hp:'',
|
|
email:'',
|
|
pj:'N',
|
|
dpj:'N',
|
|
clinic:'N',
|
|
is_default:'N',
|
|
marketing_confirm:'N',
|
|
total_staff: 0,
|
|
selected_staff: {},
|
|
selected_homeservice_staff: {},
|
|
save_status: 0,
|
|
btn_save_seen: true,
|
|
pgrs_save: false,
|
|
save_error_message: '',
|
|
no_save: 0,
|
|
open_alert_confirmation:false,
|
|
alert_success: false,
|
|
msg_success: "",
|
|
dialog_success: false,
|
|
dialog_confirmation_delete: false,
|
|
msg_confirmation_delete: "",
|
|
dialog_confirmation_delete_addr: false,
|
|
msg_confirmation_delete_addr: "",
|
|
autocomplete_status:0,
|
|
dialog_form_address: false,
|
|
label_address:'',
|
|
addresses:[],
|
|
cities:[],
|
|
city_address:{},
|
|
districts:[],
|
|
district_address:{},
|
|
kelurahans:[],
|
|
kelurahan_address:{},
|
|
description_address:'',
|
|
errors:[]
|
|
},
|
|
mutations: {
|
|
update_x_addr_id(state, val) {
|
|
state.x_addr_id = val
|
|
},
|
|
update_last_id(state, val) {
|
|
state.last_id = val
|
|
},
|
|
update_last_saved_id(state, val) {
|
|
state.last_saved_id = val
|
|
},
|
|
update_act(state, val) {
|
|
state.act = val
|
|
},
|
|
update_act_addr(state, val) {
|
|
state.act_addr = val
|
|
},
|
|
update_get_data_status(state, val) {
|
|
state.get_data_status = val
|
|
},
|
|
update_search_error_message(state, patient) {
|
|
state.search_error_message = patient
|
|
},
|
|
update_search_staff(state, staff) {
|
|
state.search_staff = staff
|
|
},
|
|
update_preffix(state, val) {
|
|
state.preffix = val
|
|
},
|
|
update_staff_name(state, val) {
|
|
state.staff_name = val
|
|
},
|
|
update_suffix(state, val) {
|
|
state.suffix = val
|
|
},
|
|
update_staffs(state, data) {
|
|
state.staffs = data
|
|
},
|
|
update_homeservice_staffs(state, data) {
|
|
state.homeservice_staffs = data
|
|
},
|
|
update_selected_status(state, val) {
|
|
state.selected_status = val
|
|
},
|
|
update_selected_staff(state, val) {
|
|
state.selected_staff = val
|
|
},
|
|
update_selected_homeservice_staff(state, val) {
|
|
state.selected_homeservice_staff = val
|
|
},
|
|
update_sexes(state, val) {
|
|
state.sexes = val
|
|
},
|
|
update_selected_sex(state, val) {
|
|
state.selected_sex = val
|
|
},
|
|
update_religions(state, val) {
|
|
state.religions = val
|
|
},
|
|
update_selected_religion(state, val) {
|
|
state.selected_religion = val
|
|
},
|
|
update_phone(state, val) {
|
|
state.phone = val
|
|
},
|
|
update_email(state, val) {
|
|
state.email = val
|
|
},
|
|
update_hp(state, val) {
|
|
state.hp = val
|
|
},
|
|
update_pj(state, val) {
|
|
state.pj = val
|
|
},
|
|
update_dpj(state, val) {
|
|
state.dpj = val
|
|
},
|
|
update_clinic(state, val) {
|
|
state.clinic = val
|
|
},
|
|
update_marketing_confirm(state, val) {
|
|
state.marketing_confirm = val
|
|
},
|
|
update_is_default(state, val) {
|
|
state.is_default = val
|
|
},
|
|
update_save_status(state, val) {
|
|
state.save_status = val
|
|
},
|
|
update_btn_save_seen(state, val) {
|
|
state.btn_save_seen = val
|
|
},
|
|
update_pgrs_save(state, val) {
|
|
state.pgrs_save = val
|
|
},
|
|
update_save_error_message(state, msg) {
|
|
state.save_error_message = ''
|
|
},
|
|
update_no_save(state, val) {
|
|
state.no_save = val
|
|
},
|
|
update_open_alert_confirmation(state, val) {
|
|
state.open_alert_confirmation = val
|
|
},
|
|
update_alert_success(state, val) {
|
|
state.alert_success = val
|
|
},
|
|
update_msg_success(state, val) {
|
|
state.msg_success = val
|
|
},
|
|
update_dialog_success(state, val) {
|
|
state.dialog_success = val
|
|
},
|
|
update_dialog_confirmation_delete(state, val) {
|
|
state.dialog_confirmation_delete = val
|
|
},
|
|
update_msg_confirmation_delete(state, val) {
|
|
state.msg_confirmation_delete = val
|
|
},
|
|
update_dialog_confirmation_delete_addr(state, val) {
|
|
state.dialog_confirmation_delete_addr = val
|
|
},
|
|
update_msg_confirmation_delete_addr(state, val) {
|
|
state.msg_confirmation_delete_addr = val
|
|
},
|
|
update_addresses(state, val) {
|
|
state.addresses = val
|
|
},
|
|
update_autocomplete_status(state,val){
|
|
state.autocomplete_status = val
|
|
},
|
|
update_dialog_form_address(state, val) {
|
|
state.dialog_form_address = val
|
|
},
|
|
update_label_address(state, val) {
|
|
state.label_address = val
|
|
},
|
|
update_cities(state, val) {
|
|
state.cities = val
|
|
},
|
|
update_city_address(state, val) {
|
|
state.city_address = 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_description_address(state, val) {
|
|
state.description_address = val
|
|
},
|
|
update_search_status(state, val) {
|
|
state.search_status = val
|
|
},
|
|
update_errors(state, val) {
|
|
state.errors = val
|
|
},
|
|
update_total_staffs(state, val) {
|
|
state.total_staffs = val
|
|
},
|
|
update_total_homeservice_staffs(state, val) {
|
|
state.total_homeservice_staffs = val
|
|
}
|
|
},
|
|
actions: {
|
|
async search(context, prm) {
|
|
context.commit("update_search_staff", 1)
|
|
try {
|
|
let resp = await api.search(one_token(), prm.name, prm.status)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_search_staff", 3)
|
|
context.commit("update_search_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_search_staff", 2)
|
|
context.commit("update_search_error_message", "")
|
|
let data = {
|
|
records: resp.data.records,
|
|
total_all: resp.data.total_all,
|
|
total_homeservice: resp.data.total_homeservice
|
|
}
|
|
context.commit("update_staffs", data.records['all'])
|
|
context.commit("update_homeservice_staffs", data.records['homeservice'])
|
|
context.commit("update_total_staffs", data.total_all)
|
|
context.commit("update_total_homeservice_staffs", data.total_homeservice)
|
|
context.commit("update_no_save", 0)
|
|
if(prm.lastid === -1){
|
|
context.commit("update_selected_staff", data.records['all'][0])
|
|
}
|
|
else{
|
|
context.commit("update_selected_staff", data.records['all'][prm.lastid])
|
|
}
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_search_staff", 3)
|
|
context.commit("update_search_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async getsexreg(context) {
|
|
context.commit("update_get_data_status",1)
|
|
try {
|
|
let resp= await api.getsexreg(one_token())
|
|
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_sexes",data.records.sexes)
|
|
context.commit("update_religions",data.records.religions)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_get_data_status",3)
|
|
}
|
|
},
|
|
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)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
context.commit("update_last_id", prm.M_DoctorID)
|
|
context.commit("update_dialog_success", true)
|
|
var msg = "Data dokter " + prm.M_DoctorName + " sudah terupdate dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
},
|
|
async newstaff(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.newstaff(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status",3)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
console.log(resp.data.id)
|
|
context.commit("update_last_id", resp.data.id)
|
|
context.commit("update_dialog_success", true)
|
|
var msg = "Data dokter " + prm.M_DoctorName + " sudah tersimpan dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
},
|
|
async delete(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.xdelete(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status",3)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
context.commit("update_last_id", 0)
|
|
context.commit("update_dialog_confirmation_delete",false)
|
|
context.commit("update_dialog_success", true)
|
|
var msg = "Data dokter " + prm.M_DoctorName + " sudah dihapus dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
context.commit("update_preffix",'')
|
|
context.commit("update_staff_name",'')
|
|
context.commit("update_suffix",'')
|
|
context.commit("update_selected_sex",{})
|
|
context.commit("update_selected_religion",{})
|
|
context.commit("update_phone",'')
|
|
context.commit("update_email",'')
|
|
context.commit("update_hp",'')
|
|
context.commit("update_pj",'N')
|
|
context.commit("update_dpj",'N')
|
|
context.commit("update_clinic",'N')
|
|
context.commit("update_marketing_confirm",'N')
|
|
context.commit("update_is_default",'N')
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
},
|
|
async getaddress(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.getaddress(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status",3)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_addresses",data.records)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
},
|
|
async searchcity(context,prm) {
|
|
context.commit("update_autocomplete_status",1)
|
|
try {
|
|
let resp= await api.searchcity(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 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)
|
|
}
|
|
},
|
|
async savenewaddress(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.savenewaddress(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status",3)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
context.commit("update_dialog_form_address",false)
|
|
context.commit("update_last_id", prm.M_DoctorAddressM_DoctorID)
|
|
context.commit("update_dialog_success", true)
|
|
var msg = "Penambahan data alamat dokter " + prm.M_DoctorName + " sudah berhasil dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
},
|
|
async saveeditaddress(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.saveeditaddress(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status",3)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
context.commit("update_dialog_form_address",false)
|
|
context.commit("update_last_id", prm.M_DoctorAddressM_DoctorID)
|
|
context.commit("update_dialog_success", true)
|
|
var msg = "Perubahan data alamat dokter " + prm.M_DoctorName + " sudah berhasil dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
},
|
|
async deleteaddress(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.deleteaddress(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status",3)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
context.commit("update_dialog_confirmation_delete_addr",false)
|
|
context.commit("update_last_id", prm.M_DoctorAddressM_DoctorID)
|
|
context.commit("update_dialog_success", true)
|
|
var msg = "Penghapusan data alamat "+prm.M_DoctorAddressNote+" dari dokter " + prm.M_DoctorName + " sudah berhasil dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
},
|
|
async settohomeservice(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.settohomeservice(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status",3)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
context.dispatch("search",{
|
|
name:prm.searchname,
|
|
lastid:prm.M_StaffID
|
|
})
|
|
|
|
/*var msg = "Data dokter " + prm.M_DoctorName + " sudah terupdate dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
context.commit("update_dialog_success", true)*/
|
|
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
},
|
|
}
|
|
} |