218 lines
6.4 KiB
JavaScript
218 lines
6.4 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/re_px.js"
|
|
window.api = api
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
order_id: 0,
|
|
contain_val: false,
|
|
|
|
search_status:0,
|
|
search_error_message:'',
|
|
search_dialog_is_active: false,
|
|
|
|
// PX
|
|
total_px: 0,
|
|
pxs: [],
|
|
selected_px: {},
|
|
selected_px_idx: 0,
|
|
|
|
groups: [{id:'1', name:'DUMMY - KIMIA'}, {id:'2', name:'DUMMY - HEMATOLOGI'}],
|
|
selected_group: {},
|
|
|
|
reruns: [{date:'2019-07-10 08:00', instrument:'COBAS', result:'56'}, {date:'2019-07-10 08:20', instrument:'COBAS', result:'68'}],
|
|
selected_rerun: {},
|
|
dialog_rerun: false,
|
|
snackbar: false,
|
|
snackbar_err: false,
|
|
|
|
dialog_trend: false,
|
|
info_trend: {}
|
|
},
|
|
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_status(state,status) {
|
|
state.search_status = status
|
|
},
|
|
|
|
update_id(state, id) {
|
|
state.order_id = id
|
|
},
|
|
|
|
update_pxs(state, pxs) {
|
|
state.pxs = pxs.records
|
|
},
|
|
|
|
update_selected_px(state, px) {
|
|
state.selected_px = px
|
|
},
|
|
|
|
update_selected_px_idx(state, idx) {
|
|
state.selected_px_idx = idx
|
|
},
|
|
|
|
update_selected_group(state, group) {
|
|
state.selected_group = group
|
|
},
|
|
|
|
update_dialog_rerun(state, v) {
|
|
state.dialog_rerun = v
|
|
},
|
|
|
|
update_reruns(state, reruns) {
|
|
state.reruns = reruns.records
|
|
},
|
|
|
|
update_selected_rerun(state, rerun) {
|
|
state.selected_rerun = rerun
|
|
},
|
|
|
|
update_snackbar(state, v) {
|
|
state.snackbar = v
|
|
},
|
|
|
|
update_snackbar_err(state, v) {
|
|
state.snackbar_err = v
|
|
},
|
|
|
|
update_dialog_trend(state, v) {
|
|
state.dialog_trend = v
|
|
},
|
|
|
|
update_info_trend(state, v) {
|
|
state.info_trend = v
|
|
},
|
|
|
|
update_contain_val(state, v) {
|
|
state.contain_val = v
|
|
}
|
|
},
|
|
actions: {
|
|
async search(context) {
|
|
context.commit("update_search_status", 1)
|
|
context.commit('update_contain_val', false)
|
|
try {
|
|
let resp= await api.search(one_token(), context.state.order_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
|
|
}
|
|
|
|
for (let i in data.records) {
|
|
let x = data.records[i]
|
|
if (x.validation == "X" && x.sample_handling_perfect == "Y") {
|
|
if (x.mr_state == "Y")
|
|
x.validation = "Y"
|
|
else
|
|
x.validation = "N"
|
|
|
|
data.records[i] = x
|
|
}
|
|
|
|
if (x.validation_old == "Y")
|
|
context.commit('update_contain_val', true)
|
|
}
|
|
|
|
context.commit("update_pxs", data)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_search_status",3)
|
|
context.commit("update_search_error_message",e.message )
|
|
}
|
|
},
|
|
|
|
async confirm(context) {
|
|
let data = []
|
|
let x = context.state.pxs
|
|
for (let i in x) {
|
|
let y = x[i]
|
|
if (y.validation != "X" && y.validation_old != y.validation)
|
|
data.push({id:y.id, mr_state:y.mr_state, validation:y.validation, test_id:y.t_testid, test_name:y.t_testname})
|
|
}
|
|
|
|
if (data.length < 1) {
|
|
context.commit('update_snackbar_err', true)
|
|
return
|
|
}
|
|
|
|
try {
|
|
let resp= await api.confirm(one_token(), JSON.stringify(data))
|
|
|
|
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.dispatch("search")
|
|
context.commit("update_snackbar", true)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_search_status",3)
|
|
context.commit("update_search_error_message",e.message )
|
|
}
|
|
},
|
|
|
|
async mr_state(context) {
|
|
context.commit("update_search_status", 1)
|
|
try {
|
|
let resp= await api.mr_state(one_token(), context.state.selected_px.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","")
|
|
|
|
context.commit('update_info_trend', resp.data)
|
|
context.commit('update_dialog_trend', true)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_search_status",3)
|
|
context.commit("update_search_error_message",e.message )
|
|
}
|
|
},
|
|
|
|
async print_count(context) {
|
|
let order_id = context.state.order_id
|
|
try {
|
|
let resp= await api.print_count(one_token(), order_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","")
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_search_status",3)
|
|
context.commit("update_search_error_message",e.message )
|
|
}
|
|
}
|
|
}
|
|
}
|