Files
FE_CPONE/test/vuex/one-queue-admin/modules/order.js
2026-04-27 10:13:31 +07:00

113 lines
3.5 KiB
JavaScript

// 1 => LOADING
// 2 => DONE
// 3 => ERROR
import * as api from "../api/order.js"
export default {
namespaced: true,
state: {
catatan_fo:'',
diagnosa:'',
patient_note: '',
finish_dialog_is_active: false,
current_order: {},
received_sample: 'N'
},
mutations: {
update_patient_note(state,val) {
state.patient_note=val
},
update_catatan_fo(state,val) {
state.catatan_fo=val
},
update_diagnosa(state,val) {
state.diagnosa=val
},
update_finish_dialog_is_active(state, val) {
state.finish_dialog_is_active = val
},
update_current_order(state, val) {
state.current_order = val
},
update_received_sample(state, val) {
state.received_sample = val
}
},
actions: {
async save(context) {
var order_id = 0;
var delivery = [];
var detail = [];
var header = {
patient_id: context.rootState.patient.selected_patient.M_PatientID,
age: context.rootState.patient.selected_patient.patient_age,
sender_doctor_id: context.rootState.doctor.selected_doctor.M_DoctorID,
sender_address_id: context.rootState.doctor.selected_address.M_DoctorAddressID,
pj_doctor_id: context.rootState.doctor.selected_doctor_pj.M_DoctorID,
lang_id: context.rootState.language.selected_language.id,
doctor_note: "",
fo_note: "",
company_id: context.rootState.company.selected_company.M_CompanyID,
mou_id: context.rootState.company.selected_mou.M_MouID,
received_sample: context.rootState.order.received_sample
};
let dlv = context.rootState.delivery.deliveries
for (var i in dlv) {
if (dlv[i].selected == true) {
let e = dlv[i].idx.split('-')
delivery.push({
delivery_id:e[0],
delivery_type_id:e[1],
address_id:e[2],
note:dlv[i].note
})
}
}
var px_tmp = [];
var st = context.rootState.px.selected_test;
for (var i in st) {
px_tmp.push({
t_id: st[i]['T_PriceID'],
t_price: st[i]['T_PriceAmount'],
t_disc: st[i]['T_PriceDisc'],
t_discrp: st[i]['T_PriceDiscRp'],
t_cito: st[i]['T_TestIsCito']
})
}
detail = px_tmp;
console.log(header);
console.log(delivery)
// context.commit("update_search_status",1)
try {
let resp= await api.save(0, header, delivery, detail)
if (resp.status != "200") {
// context.commit("update_search_status",3)
// context.commit("update_search_error_message",resp.message)
alert('error')
} else {
context.commit("update_current_order", resp.data.data)
context.commit('update_finish_dialog_is_active', true)
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 )
}
}
}
}