Files
2026-04-27 10:13:31 +07:00

108 lines
3.2 KiB
JavaScript

// 1 => LOADING
// 2 => DONE
// 3 => ERROR
import * as api from "../api/payment.js"
export default {
namespaced: true,
state: {
order_id: 0,
selected_patient: {
order_no: '-',
order_date: '-',
order_mou: '-',
order_company: '-',
patient_name: '-',
patient_mr: '-',
doctor_sender: '-',
doctor_pj: '-'
},
order_detail: [
// { n:1, d_id:1, t_id:1, t_name:'SGOT', t_price:80000, t_disctotal:7000, t_total:73000 },
// { n:2, d_id:2, t_id:2, t_name:'SGPT', t_price:75000, t_disctotal:8000, t_total:67000 }
],
order_subtotal: 0,
order_rounding: 0,
order_total: 0,
payment_cash_amount: 0,
payment_debit_amount: 0,
payment_credit_amount: 0,
payments: []
},
mutations: {
update_order (state, data) {
state.selected_patient = data.order_header
state.order_detail = data.order_detail
state.order_subtotal = data.order_header.order_subtotal
state.order_rounding = data.order_header.order_rounding
state.order_total = data.order_header.order_total
},
update_order_id (state, id) {
state.order_id = id
},
update_payment(state, o) {
if (o.type == 'cash')
state.payment_cash_amount = o.amount
if (o.type == 'debit')
state.payment_debit_amount = o.amount
if (o.type == 'credit')
state.payment_credit_amount = o.amount
},
update_payments(state, o) {
state.payments = o
}
},
actions: {
async get_order(context, prm) {
// context.commit("update_search_status",1)
try {
let resp= await api.get_order(prm)
if (resp.status != "OK") {
// context.commit("update_search_status",3)
// context.commit("update_search_error_message",resp.message)
} else {
// context.commit("update_search_status",2)
// context.commit("update_search_error_message","")
let data = resp.data.data
context.commit("update_order", data)
// commit("patientaddress/test", "X", { root: true })
}
} catch(e) {
// context.commit("update_search_status",3)
// context.commit("update_search_error_message",e.message )
}
},
async search(context, prm) {
// context.commit("update_search_status",1)
try {
let resp= await api.search(prm)
if (resp.status != "OK") {
// context.commit("update_search_status",3)
// context.commit("update_search_error_message",resp.message)
} else {
// context.commit("update_search_status",2)
// context.commit("update_search_error_message","")
let data = resp.data
context.commit("update_payments", data)
// commit("patientaddress/test", "X", { root: true })
}
} catch(e) {
// context.commit("update_search_status",3)
// context.commit("update_search_error_message",e.message )
}
}
}
}