313 lines
12 KiB
JavaScript
313 lines
12 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/samplestorage.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
last_id:-1,
|
|
last_saved_id:-1,
|
|
x_addr_id:0,
|
|
act:'new',
|
|
act_addr:'new',
|
|
get_data_status:0,
|
|
search_trx: 0,
|
|
search_status: 0,
|
|
search_error_message: '',
|
|
start_date:moment(new Date()).format('YYYY-MM-DD'),
|
|
end_date:moment(new Date()).format('YYYY-MM-DD'),
|
|
total_transaction: 0,
|
|
transactions:[],
|
|
selected_transaction: {},
|
|
save_status: 0,
|
|
btn_save_seen: true,
|
|
pgrs_save: false,
|
|
save_error_message: '',
|
|
no_save: 0,
|
|
open_alert_confirmation:false,
|
|
alert_success: false,
|
|
msg_success: "",
|
|
dialog_success: false,
|
|
dialog_confirmation_delete: false,
|
|
msg_confirmation_delete: "",
|
|
autocomplete_status:0,
|
|
dialog_form_address: false,
|
|
errors:[],
|
|
open_dialog_info:false,
|
|
msg_info:'',
|
|
current_page:1,
|
|
total_page:1,
|
|
placed_almaries:[],
|
|
selected_placed_almari:{},
|
|
placed_rack:[],
|
|
selected_placed_rack:{},
|
|
is_autoplaced:false,
|
|
xbarcode:'',
|
|
dialog_alert:false,
|
|
|
|
},
|
|
mutations: {
|
|
update_dialog_alert(state, val) {
|
|
state.dialog_alert = val
|
|
},
|
|
update_xbarcode(state, val) {
|
|
state.xbarcode = val
|
|
},
|
|
update_is_autoplaced(state, val) {
|
|
state.is_autoplaced = val
|
|
},
|
|
update_selected_placed_rack(state, val) {
|
|
state.selected_placed_rack = val
|
|
},
|
|
update_placed_rack(state, val) {
|
|
state.placed_rack = val
|
|
},
|
|
update_selected_placed_almari(state, val) {
|
|
state.selected_placed_almari = val
|
|
},
|
|
update_placed_almaries(state, val) {
|
|
state.placed_almaries = val
|
|
},
|
|
update_total_page(state, val) {
|
|
state.total_page = val
|
|
},
|
|
update_current_page(state, val) {
|
|
state.current_page = val
|
|
},
|
|
update_x_addr_id(state, val) {
|
|
state.x_addr_id = val
|
|
},
|
|
update_last_id(state, val) {
|
|
state.last_id = val
|
|
},
|
|
update_last_saved_id(state, val) {
|
|
state.last_saved_id = val
|
|
},
|
|
update_act(state, val) {
|
|
state.act = val
|
|
},
|
|
update_start_date(state, val) {
|
|
state.start_date = val
|
|
},
|
|
update_end_date(state, val) {
|
|
state.end_date = val
|
|
},
|
|
update_act_addr(state, val) {
|
|
state.act_addr = val
|
|
},
|
|
update_get_data_status(state, val) {
|
|
state.get_data_status = val
|
|
},
|
|
update_search_error_message(state, patient) {
|
|
state.search_error_message = patient
|
|
},
|
|
update_search_transaction(state, val) {
|
|
state.search_transaction = val
|
|
},
|
|
update_transactions(state, data) {
|
|
state.transactions = data
|
|
},
|
|
update_selected_transaction(state, val) {
|
|
state.selected_transaction = val
|
|
},
|
|
update_save_status(state, val) {
|
|
state.save_status = val
|
|
},
|
|
update_btn_save_seen(state, val) {
|
|
state.btn_save_seen = val
|
|
},
|
|
update_pgrs_save(state, val) {
|
|
state.pgrs_save = val
|
|
},
|
|
update_save_error_message(state, msg) {
|
|
state.save_error_message = ''
|
|
},
|
|
update_no_save(state, val) {
|
|
state.no_save = val
|
|
},
|
|
update_open_alert_confirmation(state, val) {
|
|
state.open_alert_confirmation = val
|
|
},
|
|
update_alert_success(state, val) {
|
|
state.alert_success = val
|
|
},
|
|
update_msg_success(state, val) {
|
|
state.msg_success = val
|
|
},
|
|
update_dialog_success(state, val) {
|
|
state.dialog_success = val
|
|
},
|
|
update_dialog_confirmation_delete(state, val) {
|
|
state.dialog_confirmation_delete = val
|
|
},
|
|
update_msg_confirmation_delete(state, val) {
|
|
state.msg_confirmation_delete = val
|
|
},
|
|
update_search_status(state, val) {
|
|
state.search_status = val
|
|
},
|
|
update_errors(state, val) {
|
|
state.errors = val
|
|
},
|
|
update_total_transactions(state, val) {
|
|
state.total_transactions = val
|
|
},
|
|
update_open_dialog_info(state, val) {
|
|
state.open_dialog_info = val
|
|
},
|
|
update_msg_info(state, val) {
|
|
state.msg_info = val
|
|
},
|
|
},
|
|
actions: {
|
|
async placed_sample(context,prm) {
|
|
console.log(prm)
|
|
var is_autoplaced = context.state.is_autoplaced
|
|
if(is_autoplaced){
|
|
prm.selected_placed_almari = context.state.selected_placed_almari
|
|
prm.selected_placed_rack = context.state.selected_placed_rack
|
|
prm.details = context.rootState.form.details
|
|
context.commit("update_get_data_status",1)
|
|
if(!_.isEmpty(context.state.selected_placed_almari) && !_.isEmpty(context.state.selected_placed_rack)){
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.placedSample(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status",3)
|
|
} else {
|
|
context.commit("update_get_data_status",2)
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
console.log("dasds")
|
|
//context.commit("update_placed_rack",data.records)
|
|
if(data.records.row && data.records.col){
|
|
var arr = context.rootState.form.details
|
|
var existindex = _.findIndex(arr, { barcode:prm.search })
|
|
if(existindex === -1){
|
|
var detail = {
|
|
xid:0,
|
|
barcode:prm.search,
|
|
almari:prm.selected_placed_almari,
|
|
rack:prm.selected_placed_rack,
|
|
rackid: prm.selected_placed_rack.id,
|
|
row:data.records.row,
|
|
col:data.records.col,
|
|
ordersampleid:data.records.T_OrderSampleID,
|
|
patientname:data.records.patientname
|
|
}
|
|
|
|
arr.push(detail)
|
|
|
|
context.commit("form/update_details",arr,{root:true})
|
|
context.commit("form/update_selected_detail",detail,{root:true})
|
|
|
|
if(!_.isEmpty(context.rootState.form.selected_rack) && parseInt(context.rootState.form.selected_rack.id) == parseInt(prm.selected_placed_rack.id)){
|
|
var rackcontents = context.rootState.form.rack_contents
|
|
//console.log('masuk looping')
|
|
//console.log(rackcontents)
|
|
for (var i = 0; i < rackcontents.length; i++) {
|
|
var childs = rackcontents[i]
|
|
for (var x = 0; x < childs.length; x++) {
|
|
var arrinlist = context.rootState.form.details
|
|
if(childs[x].row !== 0 & childs[x].col !== 0){
|
|
let idx = _.findIndex(arrinlist, { rackid: context.rootState.form.selected_rack.id, row:childs[x].row, col: childs[x].col})
|
|
if(idx !== -1){
|
|
childs[x].selected = 'T'
|
|
}
|
|
else{
|
|
childs[x].selected = 'N'
|
|
}
|
|
}
|
|
}
|
|
}
|
|
context.commit("form/update_rack_contents",rackcontents,{root:true})
|
|
}
|
|
}
|
|
}
|
|
else{
|
|
context.commit("update_dialog_alert",true)
|
|
}
|
|
|
|
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_get_data_status",3)
|
|
}
|
|
}
|
|
else{
|
|
context.commit("update_dialog_alert",true)
|
|
}
|
|
}
|
|
else{
|
|
var barcode = prm.search
|
|
context.dispatch("form/checkbarcode",{
|
|
barcode : barcode,
|
|
details : context.rootState.form.details
|
|
},{root:true})
|
|
}
|
|
|
|
},
|
|
async getrackbyalmari(context,prm) {
|
|
context.commit("update_get_data_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.getrackbyalmari(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status",3)
|
|
} else {
|
|
context.commit("update_get_data_status",2)
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
console.log("dasds")
|
|
context.commit("update_placed_rack",data.records)
|
|
context.commit("update_selected_placed_rack",{})
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_get_data_status",3)
|
|
}
|
|
},
|
|
async search(context, prm) {
|
|
context.commit("update_search_transaction", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.search(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_search_transaction", 3)
|
|
context.commit("update_search_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_search_transaction", 2)
|
|
context.commit("update_search_error_message", "")
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_transactions", data.records)
|
|
context.commit("update_total_transactions", data.total)
|
|
context.commit("update_total_page", data.total)
|
|
context.commit("update_no_save", 0)
|
|
/*if(prm.lastid === -1){
|
|
context.commit("update_selected_transaction", data.records[0])
|
|
var doc = data.records[0]
|
|
|
|
}
|
|
else{
|
|
context.commit("update_selected_transaction", data.records[prm.lastid])
|
|
var doc = data.records[prm.lastid]
|
|
|
|
}*/
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_search_transaction", 3)
|
|
context.commit("update_search_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
|
|
}
|
|
} |