139 lines
4.2 KiB
JavaScript
139 lines
4.2 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/order.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
order_id: 0,
|
|
payment_id: 0,
|
|
queue: '',
|
|
|
|
finish_dialog_is_active: false,
|
|
order: {
|
|
doctor_id: 0,
|
|
complaint: "",
|
|
number: ""
|
|
},
|
|
|
|
print_dialog_is_active: false,
|
|
rpt_url: ''
|
|
},
|
|
mutations: {
|
|
update_finish_dialog_is_active(state, val) {
|
|
state.finish_dialog_is_active = val
|
|
},
|
|
|
|
update_order(state, val) {
|
|
state.order = val
|
|
},
|
|
|
|
update_order_from_save(state, val) {
|
|
let o = state.order
|
|
o.number = val.number
|
|
|
|
state.order_id = val.id
|
|
state.order = o
|
|
},
|
|
|
|
update_complaint(state, v) {
|
|
state.order.complaint = v
|
|
},
|
|
|
|
update_queue(state, v) {
|
|
state.queue = v
|
|
},
|
|
|
|
update_print_dialog_is_active(state, v) {
|
|
state.print_dialog_is_active = v
|
|
},
|
|
|
|
update_rpt_url(state, v) {
|
|
state.rpt_url = v
|
|
},
|
|
|
|
update_payment_id(state, v) {
|
|
state.payment_id = v
|
|
}
|
|
},
|
|
actions: {
|
|
async save (context) {
|
|
var order_id = 0;
|
|
var payment = [];
|
|
var header = {
|
|
patient_id: context.rootState.patient.selected_patient.M_PatientID,
|
|
age: context.rootState.patient.selected_patient.patient_age,
|
|
doctor_id: context.rootState.doctor.selected_doctor.M_DoctorID,
|
|
complaint: context.rootState.order.order.complaint,
|
|
total: context.rootState.payment.order_total,
|
|
queue: context.state.queue
|
|
};
|
|
|
|
payment = context.rootState.payment.payments
|
|
let pym = []
|
|
for (let i in payment) {
|
|
if (payment[i].payment_enable == 'Y')
|
|
pym.push(payment[i])
|
|
}
|
|
payment = pym
|
|
|
|
try {
|
|
let resp= await api.save(0, header, payment, one_token())
|
|
|
|
if (resp.status != "200") {
|
|
// context.commit("update_search_status",3)
|
|
// context.commit("update_search_error_message",resp.message)
|
|
alert('error')
|
|
} else {
|
|
|
|
context.commit("update_order_from_save", resp.data.data)
|
|
context.commit('update_finish_dialog_is_active', true)
|
|
context.dispatch("reset_form")
|
|
|
|
context.commit("update_payment_id", resp.data.data.payment_id)
|
|
// context.commit('payment/update_order_id', resp.data.data.id, {root:true})
|
|
// context.dispatch('payment/get_order', resp.data.data.id, {root:true})
|
|
|
|
}
|
|
} catch(e) {
|
|
// context.commit("update_search_status",3)
|
|
// context.commit("update_search_error_message",e.message )
|
|
}
|
|
},
|
|
|
|
async reset_form (context) {
|
|
context.commit("patient/reset_patient", null, {root:true})
|
|
context.dispatch("payment/search", null, {root:true})
|
|
context.commit("payment/reset_payment", null, {root:true})
|
|
context.commit("doctor/update_selected_doctor", {}, {root:true})
|
|
context.commit("update_complaint", "")
|
|
},
|
|
|
|
async print_receipt (context) {
|
|
context.commit("update_rpt_url", BASE_URL + "/birt/run?__report=report/one/klinik/rpt_c_003.rptdesign&__format=pdf&username=admin%20&PID=" + context.state.payment_id)
|
|
context.commit("update_print_dialog_is_active", true)
|
|
|
|
try {
|
|
let resp= await api.log_nota(one_token(), context.state.order_id, 0)
|
|
|
|
if (resp.status != "200") {
|
|
// context.commit("update_search_status",3)
|
|
// context.commit("update_search_error_message",resp.message)
|
|
alert('error')
|
|
} else {
|
|
|
|
console.log(resp.data)
|
|
// context.commit('payment/update_order_id', resp.data.data.id, {root:true})
|
|
// context.dispatch('payment/get_order', resp.data.data.id, {root:true})
|
|
|
|
}
|
|
} catch(e) {
|
|
// context.commit("update_search_status",3)
|
|
// context.commit("update_search_error_message",e.message )
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|