70 lines
1.9 KiB
JavaScript
70 lines
1.9 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/history.js"
|
|
window.api = api
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
noreg:'',
|
|
search: '',
|
|
search_status:0,
|
|
search_error_message:'',
|
|
search_dialog_is_active: false,
|
|
histories: [],
|
|
|
|
history_dialog: false
|
|
},
|
|
mutations: {
|
|
update_search_dialog_is_active(state,status) {
|
|
state.search_dialog_is_active = status
|
|
},
|
|
|
|
update_search_error_message(state,status) {
|
|
state.search_error_message = status
|
|
},
|
|
|
|
update_search(state,val) {
|
|
state.search=val
|
|
},
|
|
|
|
update_search_status(state,status) {
|
|
state.search_status = status
|
|
},
|
|
|
|
update_histories(state, data) {
|
|
state.histories = data.records
|
|
},
|
|
|
|
update_history_dialog(state, v) {
|
|
state.history_dialog = v
|
|
}
|
|
},
|
|
actions: {
|
|
async search(context) {
|
|
context.commit("update_search_status",1)
|
|
try {
|
|
let resp = await api.search(context.rootState.patient.selected_patient.M_PatientID)
|
|
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 = {
|
|
records : resp.data.records
|
|
}
|
|
context.commit("update_histories", data)
|
|
|
|
// commit("patientaddress/test", "X", { root: true })
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_search_status",3)
|
|
context.commit("update_search_error_message",e.message )
|
|
}
|
|
}
|
|
}
|
|
}
|