70 lines
2.1 KiB
JavaScript
70 lines
2.1 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/delivery.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
lookup_delivery:0,
|
|
lookup_error_message:'',
|
|
deliveries: [],
|
|
total_delivery: 0,
|
|
selected_delivery: {},
|
|
address_patient:[],
|
|
address_doctor:[],
|
|
hp_patient:'',
|
|
hp_doctor:''
|
|
},
|
|
mutations: {
|
|
update_lookup_error_message(state,status) {
|
|
state.search_error_message = status
|
|
},
|
|
update_lookup_delivery(state,status) {
|
|
state.lookup_delivery = status
|
|
},
|
|
update_deliveries(state,data) {
|
|
state.deliveries= data.records
|
|
state.total_delivery= data.total
|
|
},
|
|
update_selected_delivery(state,val) {
|
|
state.selected_delivery=val
|
|
},
|
|
update_address_patient(state,val) {
|
|
state.address_patient=val
|
|
},
|
|
update_address_doctor(state,val) {
|
|
state.address_doctor=val
|
|
},
|
|
update_hp_patient(state,val) {
|
|
state.hp_patient = val
|
|
},
|
|
update_hp_doctor(state,val) {
|
|
state.hp_doctor = val
|
|
}
|
|
},
|
|
actions: {
|
|
async lookup(context) {
|
|
context.commit("update_lookup_delivery",1)
|
|
try {
|
|
let resp= await api.lookup(one_token())
|
|
if (resp.status != "OK") {
|
|
context.commit("update_lookup_delivery",3)
|
|
context.commit("update_lookup_error_message",resp.message)
|
|
} else {
|
|
context.commit("update_lookup_delivery",2)
|
|
context.commit("update_lookup_error_message","")
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_deliveries",data)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_lookup_delivery",3)
|
|
context.commit("update_lookup_error_message",e.message )
|
|
}
|
|
}
|
|
}
|
|
}
|