696 lines
26 KiB
JavaScript
696 lines
26 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/doctor.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
last_id:-1,
|
|
last_saved_id:-1,
|
|
x_addr_id:0,
|
|
act:'new',
|
|
act_addr:'new',
|
|
get_data_status:0,
|
|
search_doctor: 0,
|
|
search_status: 0,
|
|
search_error_message: '',
|
|
statuses:[{label:'Semua', value:'A'},{label:'Belum disetujui', value:'N'},{label:'Sudah disetujui', value:'Y'}],
|
|
selected_status:{label:'Semua', value:'A'},
|
|
xdate:moment(new Date()).format('YYYY-MM-DD'),
|
|
transaction_date:moment(new Date()).format('YYYY-MM-DD'),
|
|
transaction_time:moment(new Date()).format('hh:mm'),
|
|
preffix:'',
|
|
doctor_name:'',
|
|
suffix:'',
|
|
doctors: [],
|
|
total_doctors:0,
|
|
doctor_address: [],
|
|
sexes:[],
|
|
selected_sex:{},
|
|
religions:[],
|
|
selected_religion:{},
|
|
phone:'',
|
|
hp:'',
|
|
email:'',
|
|
pj:'N',
|
|
dpj:'N',
|
|
clinic:'N',
|
|
is_default:'N',
|
|
marketing_confirm:'N',
|
|
total_doctor: 0,
|
|
selected_doctor: {},
|
|
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:'',
|
|
couriers:[],
|
|
selected_courier:{},
|
|
selected_courier_change:{},
|
|
addresses:[],
|
|
cities:[],
|
|
selected_city:{},
|
|
cities_form:[],
|
|
selected_city_form:{},
|
|
city_address:{},
|
|
districts:[],
|
|
selected_district:{},
|
|
districts_form:[],
|
|
selected_district_form:{},
|
|
district_address:{},
|
|
kelurahans:[],
|
|
selected_kelurahan:{},
|
|
kelurahans_form:[],
|
|
selected_kelurahan_form:{},
|
|
kelurahan_address:{},
|
|
description_address:'',
|
|
errors:[],
|
|
current_page:1,
|
|
task_label:'',
|
|
task_note:'',
|
|
address_note:'',
|
|
dialog_courier:false
|
|
},
|
|
mutations: {
|
|
update_dialog_courier(state, val) {
|
|
state.dialog_courier = val
|
|
},
|
|
update_couriers(state, val) {
|
|
state.couriers = val
|
|
},
|
|
update_selected_courier(state, val) {
|
|
state.selected_courier = val
|
|
},
|
|
update_selected_courier_change(state, val) {
|
|
state.selected_courier_change = val
|
|
},
|
|
update_x_addr_id(state, val) {
|
|
state.x_addr_id = val
|
|
},
|
|
update_xdate(state, val) {
|
|
state.xdate = val
|
|
},
|
|
update_start_date(state, val) {
|
|
state.start_date = 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_doctor(state, doctor) {
|
|
state.search_doctor = doctor
|
|
},
|
|
update_preffix(state, val) {
|
|
state.preffix = val
|
|
},
|
|
update_doctor_name(state, val) {
|
|
state.doctor_name = val
|
|
},
|
|
update_suffix(state, val) {
|
|
state.suffix = val
|
|
},
|
|
update_doctors(state, data) {
|
|
state.doctors = data
|
|
},
|
|
update_selected_status(state, val) {
|
|
state.selected_status = val
|
|
},
|
|
update_selected_doctor(state, val) {
|
|
state.selected_doctor = 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_selected_city(state, val) {
|
|
state.selected_city = val
|
|
},
|
|
update_cities_form(state, val) {
|
|
state.cities_form = val
|
|
},
|
|
update_selected_city_form(state, val) {
|
|
state.selected_city_form = val
|
|
},
|
|
update_city_address(state, val) {
|
|
state.city_address = val
|
|
},
|
|
update_districts(state, val) {
|
|
state.districts = val
|
|
},
|
|
update_selected_district(state, val) {
|
|
state.selected_district = val
|
|
},
|
|
update_districts_form(state, val) {
|
|
state.districts_form = val
|
|
},
|
|
update_selected_district_form(state, val) {
|
|
state.selected_district_form = val
|
|
},
|
|
update_district_address(state, val) {
|
|
state.district_address = val
|
|
},
|
|
update_kelurahans(state, val) {
|
|
state.kelurahans = val
|
|
},
|
|
update_selected_kelurahan_form(state, val) {
|
|
state.selected_kelurahan_form = val
|
|
},
|
|
update_kelurahans_form(state, val) {
|
|
state.kelurahans_form = val
|
|
},
|
|
update_selected_kelurahan(state, val) {
|
|
state.selected_kelurahan = 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_doctor(state, val) {
|
|
state.total_doctor = val
|
|
},
|
|
update_current_page(state, val) {
|
|
state.current_page = val
|
|
},
|
|
update_task_label(state, val) {
|
|
state.task_label = val
|
|
},
|
|
update_task_note(state, val) {
|
|
state.task_note = val
|
|
},
|
|
update_address_note(state, val) {
|
|
state.address_note = val
|
|
},
|
|
update_transaction_date(state, val) {
|
|
state.transaction_date = val
|
|
},
|
|
},
|
|
actions: {
|
|
async search(context, prm) {
|
|
context.commit("update_search_doctor", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.search(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_search_doctor", 3)
|
|
context.commit("update_search_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_search_doctor", 2)
|
|
context.commit("update_search_error_message", "")
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_doctors", data.records)
|
|
console.log(data.total)
|
|
context.commit("update_total_doctor", data.total)
|
|
context.commit("update_no_save", 0)
|
|
if(prm.lastid === -1){
|
|
context.commit("update_selected_doctor", parseInt(data.records[0]))
|
|
var doc = data.records[0]
|
|
|
|
}
|
|
else{
|
|
context.commit("update_selected_doctor", data.records[prm.lastid])
|
|
var doc = data.records[prm.lastid]
|
|
|
|
}
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_search_doctor", 3)
|
|
context.commit("update_search_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async getinitdata(context) {
|
|
context.commit("update_get_data_status",1)
|
|
try {
|
|
let resp= await api.getinitdata(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_cities",data.records.cities)
|
|
context.commit("update_selected_city",data.records.selected_city)
|
|
context.commit("update_districts",data.records.districts)
|
|
context.commit("update_selected_district",data.records.selected_district)
|
|
context.commit("update_kelurahans",data.records.kelurahans)
|
|
context.commit("update_selected_kelurahan",data.records.selected_kelurahan)
|
|
context.commit("update_couriers",data.records.couriers)
|
|
context.commit("update_cities_form",data.records.cities_form)
|
|
context.commit("update_selected_city_form",data.records.selected_city)
|
|
context.commit("update_districts_form",data.records.districts_form)
|
|
var prm = {
|
|
xdate:moment(new Date()).format('YYYY-MM-DD'),
|
|
city:data.records.selected_city,
|
|
district:data.records.selected_district,
|
|
kelurahan:data.records.selected_kelurahan,
|
|
status:'A',
|
|
current_page:1,
|
|
lastid:-1
|
|
}
|
|
context.dispatch("search",prm)
|
|
}
|
|
} 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 savenewtask(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.savenewtask(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status",3)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
context.commit("update_transaction_date",moment(new Date()).format('YYYY-MM-DD'))
|
|
context.commit("update_transaction_time",moment(new Date()).format('hh:mm'))
|
|
context.commit("update_task_label", "")
|
|
context.commit("update_task_note", msg)
|
|
context.commit("update_selected_courier", {})
|
|
context.commit("update_selected_district_form", {})
|
|
context.commit("update_selected_kelurahan_form", {})
|
|
context.commit("update_address_note","")
|
|
context.dispatch("search",{
|
|
xdate:prm.xdate,
|
|
city:prm.filter_city,
|
|
district:prm.filter_district,
|
|
kelurahan:prm.filter_kelurahan,
|
|
status:prm.status,
|
|
current_page:1,
|
|
lastid:-1
|
|
})
|
|
var msg = "Tugas baru telah dibuat"
|
|
context.commit("update_msg_success", msg)
|
|
context.commit("update_dialog_success", true)
|
|
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
},
|
|
async dochangecourier(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.dochangecourier(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status",3)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
context.commit("update_dialog_courier",false)
|
|
context.dispatch("search",{
|
|
xdate:prm.xdate,
|
|
city:prm.city,
|
|
district:prm.district,
|
|
kelurahan:prm.kelurahan,
|
|
status:prm.status,
|
|
current_page:1,
|
|
lastid:-1
|
|
})
|
|
var msg = "Transaksi " + prm.xnumber + " kurirnya sudah diganti dong"
|
|
context.commit("update_msg_success", msg)
|
|
context.commit("update_dialog_success", true)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
},
|
|
async approve(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.approve(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status",3)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
|
|
context.dispatch("search",{
|
|
xdate:prm.xdate,
|
|
city:prm.city,
|
|
district:prm.district,
|
|
kelurahan:prm.kelurahan,
|
|
status:prm.status,
|
|
current_page:1,
|
|
lastid:-1
|
|
})
|
|
var msg = "Transaksi " + prm.xnumber + " sudah disetujui dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
context.commit("update_dialog_success", true)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
},
|
|
async newdoctor(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.newdoctor(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_doctor_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 getcourier(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.getcourier(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_couriers",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 {
|
|
prm.token = one_token()
|
|
let resp= await api.getkelurahan(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 getkelurahanform(context,prm) {
|
|
context.commit("update_get_data_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.getkelurahan(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_form",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)
|
|
}
|
|
}
|
|
}
|
|
} |