467 lines
17 KiB
JavaScript
467 lines
17 KiB
JavaScript
import * as api from "../api/payment.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
lookup_status: 0,
|
|
lookup_error_message: '',
|
|
types: [],
|
|
total_payment: 0,
|
|
total_last_payment: 0,
|
|
reload_after_save: false,
|
|
dialog_pay_success: false,
|
|
paynumber: '',
|
|
notes: [],
|
|
dialog_delete: false,
|
|
msg_delete: '',
|
|
note_delete: '',
|
|
nota_delete: {},
|
|
open_print_note: false,
|
|
idx: 0,
|
|
last_payments: [],
|
|
payment_total: 0,
|
|
banks: [],
|
|
disable_btn_pay: 'Y',
|
|
accounts: [],
|
|
save_process: false,
|
|
open_dialog_info: false,
|
|
msg_info: '',
|
|
languages: [],
|
|
selected_language: {},
|
|
data_station_location: [],
|
|
setting_controll: false,
|
|
urlprintnote: false,
|
|
dialog_gagal: false,
|
|
msg_success: "",
|
|
dialog_success: false,
|
|
alert_success: false,
|
|
url_bukti_wa:"",
|
|
msg_gagal:"",
|
|
success_sent_wa: false,
|
|
menu_walk_in: '',
|
|
},
|
|
mutations: {
|
|
update_menu_walk_in(state, val) {
|
|
state.menu_walk_in = val
|
|
},
|
|
update_url_bukti_wa(state, val) {
|
|
state.url_bukti_wa = val;
|
|
},
|
|
update_msg_success(state, val) {
|
|
state.msg_success = val;
|
|
},
|
|
update_dialog_success(state, val) {
|
|
state.dialog_success = val;
|
|
},
|
|
update_msg_gagal(state, val) {
|
|
state.msg_gagal = val;
|
|
},
|
|
update_dialog_gagal(state, val) {
|
|
state.dialog_gagal = val;
|
|
},
|
|
update_alert_success(state, val) {
|
|
state.alert_success = val
|
|
},
|
|
update_msg_success(state, val) {
|
|
state.msg_success = val
|
|
},
|
|
update_urlprintnote(state, value) {
|
|
state.urlprintnote = value
|
|
},
|
|
update_setting_controll(state, value) {
|
|
state.setting_controll = value
|
|
},
|
|
update_data_station_location(state, value) {
|
|
state.data_station_location = value
|
|
},
|
|
update_languages(state, val) {
|
|
state.languages = val
|
|
},
|
|
update_selected_language(state, val) {
|
|
state.selected_language = val
|
|
},
|
|
update_open_dialog_info(state, val) {
|
|
state.open_dialog_info = val
|
|
},
|
|
update_msg_info(state, val) {
|
|
state.msg_info = val
|
|
},
|
|
update_save_process(state, val) {
|
|
state.save_process = val
|
|
},
|
|
update_total_last_payment(state, val) {
|
|
state.total_last_payment
|
|
},
|
|
update_accounts(state, val) {
|
|
state.accounts = val
|
|
},
|
|
update_disable_btn_pay(state, val) {
|
|
state.disable_btn_pay = val
|
|
},
|
|
update_banks(state, val) {
|
|
state.banks = val
|
|
},
|
|
update_lookup_error_message(state, val) {
|
|
state.lookup_error_message = val
|
|
},
|
|
update_lookup_status(state, status) {
|
|
state.lookup_status = status
|
|
},
|
|
update_types(state, data) {
|
|
state.types = data.records
|
|
state.total_type = data.total
|
|
},
|
|
update_selected_status(state, val) {
|
|
state.selected_status = val
|
|
},
|
|
update_total_payment(state, val) {
|
|
state.total_payment = val
|
|
},
|
|
update_reload_after_save(state, val) {
|
|
state.reload_after_save = val
|
|
},
|
|
update_dialog_pay_success(state, val) {
|
|
state.dialog_pay_success = val
|
|
},
|
|
update_paynumber(state, val) {
|
|
state.paynumber = val
|
|
},
|
|
update_notes(state, val) {
|
|
state.notes = val
|
|
},
|
|
update_dialog_delete(state, val) {
|
|
state.dialog_delete = val
|
|
},
|
|
update_note_delete(state, val) {
|
|
state.note_delete = val
|
|
},
|
|
update_msg_delete(state, val) {
|
|
state.msg_delete = val
|
|
},
|
|
update_nota_delete(state, val) {
|
|
state.nota_delete = val
|
|
},
|
|
update_open_print_note(state, val) {
|
|
state.open_print_note = val
|
|
},
|
|
update_idx(state, val) {
|
|
state.idx = val
|
|
},
|
|
update_last_payments(state, val) {
|
|
state.last_payments = val
|
|
},
|
|
},
|
|
actions: {
|
|
async kirimBuktiViaWA(context) {
|
|
try {
|
|
var prm = {
|
|
urlX: context.state.url_bukti_wa,
|
|
T_OrderHeaderID: context.rootState.patient.selected_patient.T_OrderHeaderID,
|
|
M_PatientHp: context.rootState.patient.selected_patient.M_PatientHp,
|
|
M_PatientID: context.rootState.patient.selected_patient.M_PatientID,
|
|
T_OrderHeaderLabNumber: context.rootState.patient.selected_patient.T_OrderHeaderLabNumber,
|
|
token: one_token()
|
|
}
|
|
|
|
let resp = await api.kirimBuktiViaWA(prm)
|
|
console.log("resp update ", resp)
|
|
|
|
if (resp.status != "OK") {
|
|
context.commit("update_msg_gagal", resp.message)
|
|
context.commit("update_dialog_gagal", true);
|
|
} else {
|
|
context.commit("update_dialog_gagal", false);
|
|
context.commit("update_msg_gagal", "")
|
|
|
|
context.commit("update_dialog_success", true);
|
|
var msg = "Sukses Proses Insert Data";
|
|
context.commit("update_msg_success", msg);
|
|
|
|
// TODO: Need better handling, agar tidak ganti selectedPatient
|
|
// Update List Patient dengan Search supaya Button jadi disabled
|
|
const patientState = context.rootState.patient;
|
|
const searchParams = {
|
|
startdate: patientState.start_date,
|
|
enddate: patientState.end_date,
|
|
search: patientState.search,
|
|
status: patientState.selected_status.value,
|
|
current_page: patientState.current_page,
|
|
lastidx: 0
|
|
};
|
|
context.dispatch('patient/search', searchParams, { root: true });
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_msg_gagal", e.message)
|
|
context.commit("update_dialog_gagal", true);
|
|
}
|
|
},
|
|
|
|
async save_control(context, prm) {
|
|
// context.commit("update_search_status",1)
|
|
try {
|
|
|
|
prm.token = one_token()
|
|
let resp = await api.save_control(prm)
|
|
console.log(resp)
|
|
if (resp.status != "OK") {
|
|
// context.commit("update_search_status",3)
|
|
// context.commit("update_search_error_message",resp.message)
|
|
alert(resp.message)
|
|
} else {
|
|
// context.commit("update_search_status",2)
|
|
// context.commit("update_search_error_message","")
|
|
context.commit("update_setting_controll", false)
|
|
//context.dispatch('print_control', {order_id:context.rootState.patient.selected_patient.T_OrderHeaderID,time_start:context.rootState.order.show_time})
|
|
|
|
let idx = context.rootState.patient.selected_patient.T_OrderHeaderID
|
|
let user = one_user()
|
|
var tmx = Number(new Date());
|
|
let urlprintnote = "/birt/run?__report=report/one/lab/rpt_fo_001.rptdesign&__format=pdf&username=" + user.M_StaffName + "&PID=" + idx + "?t=" + tmx
|
|
context.commit("update_urlprintnote", urlprintnote)
|
|
context.commit("update_open_print_note", true)
|
|
|
|
}
|
|
} catch (e) {
|
|
// context.commit("update_search_status",3)
|
|
console.log('gagal')
|
|
alert(e.message)
|
|
}
|
|
},
|
|
|
|
async getLocations(context) {
|
|
// context.commit("update_search_status",1)
|
|
try {
|
|
var prm = {}
|
|
prm.order_id = context.rootState.patient.selected_patient.T_OrderHeaderID
|
|
prm.token = one_token()
|
|
let resp = await api.getLocations(prm)
|
|
console.log(resp)
|
|
if (resp.status != "OK") {
|
|
// context.commit("update_search_status",3)
|
|
// context.commit("update_search_error_message",resp.message)
|
|
alert(resp.message)
|
|
} else {
|
|
// context.commit("update_search_status",2)
|
|
// context.commit("update_search_error_message","")
|
|
|
|
let sl = resp.data.datas
|
|
context.commit("update_data_station_location", sl)
|
|
context.commit("update_setting_controll", true)
|
|
|
|
|
|
}
|
|
} catch (e) {
|
|
// context.commit("update_search_status",3)
|
|
console.log('gagal')
|
|
alert(e.message)
|
|
}
|
|
},
|
|
async getlanguages(context) {
|
|
context.commit("update_lookup_status", 1)
|
|
try {
|
|
let resp = await api.getlanguages(one_token())
|
|
if (resp.status != "OK") {
|
|
context.commit("update_lookup_status", 3)
|
|
context.commit("update_lookup_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_lookup_status", 2)
|
|
context.commit("update_lookup_error_message", "")
|
|
/*let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}*/
|
|
context.commit("update_languages", resp.data)
|
|
context.commit("update_selected_language", {})
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_lookup_status", 3)
|
|
context.commit("update_lookup_error_message", e.message)
|
|
}
|
|
},
|
|
async lookup_type(context, prm) {
|
|
context.commit("update_lookup_status", 1)
|
|
try {
|
|
let resp = await api.lookup_type(one_token())
|
|
if (resp.status != "OK") {
|
|
context.commit("update_lookup_status", 3)
|
|
context.commit("update_lookup_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_lookup_status", 2)
|
|
context.commit("update_lookup_error_message", "")
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_types", data)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_lookup_status", 3)
|
|
context.commit("update_lookup_error_message", e.message)
|
|
}
|
|
},
|
|
async lookup_banks(context) {
|
|
context.commit("update_lookup_status", 1)
|
|
try {
|
|
let resp = await api.lookup_banks(one_token())
|
|
if (resp.status != "OK") {
|
|
context.commit("update_lookup_status", 3)
|
|
context.commit("update_lookup_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_lookup_status", 2)
|
|
context.commit("update_lookup_error_message", "")
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_banks", data.records)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_lookup_status", 3)
|
|
context.commit("update_lookup_error_message", e.message)
|
|
}
|
|
},
|
|
async lookup_accounts(context) {
|
|
context.commit("update_lookup_status", 1)
|
|
try {
|
|
let resp = await api.lookup_accounts(one_token())
|
|
if (resp.status != "OK") {
|
|
context.commit("update_lookup_status", 3)
|
|
context.commit("update_lookup_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_lookup_status", 2)
|
|
context.commit("update_lookup_error_message", "")
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_accounts", data.records)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_lookup_status", 3)
|
|
context.commit("update_lookup_error_message", e.message)
|
|
}
|
|
},
|
|
async searchcard(context, prm) {
|
|
context.commit("update_lookup_status", 1)
|
|
try {
|
|
let resp = await api.searchcard(one_token(), 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_cards", resp.data.records)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_lookup_status", 3)
|
|
}
|
|
},
|
|
async pay(context, prm) {
|
|
context.commit("update_lookup_status", 1)
|
|
|
|
console.log(prm)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.pay(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_lookup_status", 3)
|
|
context.commit("update_lookup_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_lookup_status", 2)
|
|
context.commit("update_lookup_error_message", "")
|
|
let data = {
|
|
records: resp.data.records.types,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_save_process", false)
|
|
var xpayments = resp.data.records.payments
|
|
console.log(xpayments)
|
|
context.commit("update_last_payments", xpayments)
|
|
//console.log(prm.payments)
|
|
let xnumber = resp.data.records.data.numberx
|
|
let id = resp.data.records.data.idx
|
|
var xobj = context.state.types
|
|
//console.log(xobj)
|
|
xobj.forEach(function (obj) {
|
|
obj.chex = false
|
|
obj.leftvalue = 0
|
|
obj.rightvalue = 0
|
|
obj.selected_card = { id: 0, name: '' }
|
|
obj.selected_edc = { id: 0, name: '' }
|
|
obj.selected_account = { id: 0, name: '' }
|
|
})
|
|
var xray = { records: xobj, total: xobj.length }
|
|
context.commit("update_types", xray)
|
|
context.commit("update_disable_btn_pay", 'Y')
|
|
console.log(context.state.types)
|
|
|
|
|
|
context.commit("update_idx", id)
|
|
context.commit("update_total_payment", 0)
|
|
context.commit("update_paynumber", "Pembayaran nomor <span style='color:red'>" + xnumber + "</span> telah berhasil")
|
|
context.commit("update_dialog_pay_success", true)
|
|
|
|
context.commit("update_menu_walk_in", resp.data.menu_walk_in)
|
|
|
|
let resp_check = await api.check_exist_transaction({labnumber: prm.labnumber})
|
|
if(resp_check.status == "success" && resp_check.data != null){
|
|
let resp_repost = await api.re_post_transaction({labnumber: prm.labnumber})
|
|
if(resp_repost.status == "success"){
|
|
context.commit("update_msg_success", resp_repost.message)
|
|
context.commit("update_dialog_success", true)
|
|
context.commit("update_alert_success", true)
|
|
}
|
|
else{
|
|
context.commit("update_msg_gagal", resp_repost.message)
|
|
context.commit("update_dialog_gagal", true)
|
|
context.commit("update_alert_success", false)
|
|
}
|
|
}
|
|
else{
|
|
let resp_post = await api.post_transaction({labnumber: prm.labnumber})
|
|
if(resp_post.status == "success"){
|
|
context.commit("update_msg_success", resp_post.message)
|
|
context.commit("update_dialog_success", true)
|
|
context.commit("update_alert_success", true)
|
|
}
|
|
else{
|
|
context.commit("update_msg_gagal", resp_post.message)
|
|
context.commit("update_dialog_gagal", true)
|
|
context.commit("update_alert_success", false)
|
|
}
|
|
}
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_lookup_status", 3)
|
|
context.commit("update_lookup_error_message", e.message)
|
|
}
|
|
},
|
|
async delete_note(context, prm) {
|
|
context.commit("update_lookup_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.delete_note(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_lookup_status", 3)
|
|
context.commit("update_lookup_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_lookup_status", 2)
|
|
context.commit("update_lookup_error_message", "")
|
|
let xmsg = "Nota nomor <span style='color:red'>" + prm.nota.note_number + "</span> telah dihapus"
|
|
context.commit("update_msg_delete", xmsg)
|
|
context.commit("update_note_delete", '')
|
|
context.commit("update_nota_delete", {})
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_lookup_status", 3)
|
|
context.commit("update_lookup_error_message", e.message)
|
|
}
|
|
}
|
|
}
|
|
} |