Flatten nested repos
This commit is contained in:
143
test/vuex/one-sampling-v2/modules/patient.js
Normal file
143
test/vuex/one-sampling-v2/modules/patient.js
Normal file
@@ -0,0 +1,143 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/patient.js"
|
||||
window.api = api
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
nolab:'',
|
||||
search: '',
|
||||
statuses : [{id:'A', text:'Semua'},
|
||||
{id:'N', text:'Belum Sampling'},
|
||||
// {id:'X', text:'Parsial Sampling'},
|
||||
{id:'Y', text:'Selesai Sampling'}],
|
||||
station : [],
|
||||
|
||||
search_status:0,
|
||||
search_error_message:'',
|
||||
search_dialog_is_active: false,
|
||||
patients: [],
|
||||
total_patient: 0,
|
||||
selected_patient: {
|
||||
mr : '-',
|
||||
name : '-',
|
||||
dob : '-',
|
||||
phone : '-',
|
||||
order_id : 0
|
||||
},
|
||||
|
||||
selected_status : {id:'N', text:'Belum Sampling'},
|
||||
selected_station : {},
|
||||
|
||||
// requirements
|
||||
req_status: "X",
|
||||
reqs: []
|
||||
},
|
||||
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_noreg(state,val) {
|
||||
state.noreg=val
|
||||
},
|
||||
update_search(state,val) {
|
||||
state.search=val
|
||||
},
|
||||
update_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
update_patients(state,data) {
|
||||
state.patients= data.records
|
||||
state.total_patient = data.total
|
||||
},
|
||||
update_selected_patient(state,val) {
|
||||
state.selected_patient=val
|
||||
},
|
||||
|
||||
update_selected_status(state, val) {
|
||||
state.selected_status = val
|
||||
},
|
||||
|
||||
update_selected_station(state, val) {
|
||||
state.selected_station = val
|
||||
},
|
||||
|
||||
update_nolab(state, val) {
|
||||
state.nolab = val
|
||||
},
|
||||
|
||||
update_stations(state, val) {
|
||||
state.station = val
|
||||
},
|
||||
|
||||
update_req(state, v) {
|
||||
state.req_status = v.req_status
|
||||
state.reqs = v.reqs
|
||||
},
|
||||
|
||||
update_req_status(state, v) {
|
||||
state.req_status = v
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context) {
|
||||
context.commit("update_search_status", 1)
|
||||
try {
|
||||
let resp= await api.search(context.state.nolab, context.state.search, context.state.selected_station.id, context.state.selected_status.id)
|
||||
|
||||
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,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_patients", data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async get_stations(context) {
|
||||
context.commit("update_search_status", 1)
|
||||
try {
|
||||
let token = one_token()
|
||||
let resp= await api.get_stations(token)
|
||||
|
||||
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","")
|
||||
|
||||
context.commit("update_stations", resp.data.records)
|
||||
|
||||
if (resp.data.records.length > 0) {
|
||||
context.commit("update_selected_station", resp.data.records[0])
|
||||
context.dispatch("search")
|
||||
|
||||
// QUEUE
|
||||
context.commit("queue/update_station_id", resp.data.records[0].id, {root:true})
|
||||
}
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user