452 lines
18 KiB
JavaScript
452 lines
18 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: '',
|
|
filter_work:[{value:'manual',name:'Manual'},{value:'auto',name:'Otomatis'},{value:'all',name:'Semua'}],
|
|
selected_filter_work:{value:'manual',name:'Manual'},
|
|
filter_status:[{value:'ready',name:'Belum Selesai'},{value:'done',name:'Sudah Selesai'},{value:'readyhandover',name:'Siap Diserahkan'},{value:'receivedpatient',name:'Diterima Pasien'}],
|
|
selected_filter_status:{value:'ready',name:'Belum Dikirim'},
|
|
start_date:moment(new Date()).format('YYYY-MM-DD'),
|
|
end_date:moment(new Date()).format('YYYY-MM-DD'),
|
|
total_transaction: 0,
|
|
staffs:[],
|
|
selected_staff:{},
|
|
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:'',
|
|
open_print_out:false,
|
|
current_page:1,
|
|
total_page:1,
|
|
dialog_authorize:false,
|
|
mous:[],
|
|
selected_mou:{},
|
|
barcode:'',
|
|
snackbar:{value:false,timeout:4000,text:''},
|
|
info : {rest:0,total:0},
|
|
staff:{},
|
|
search:''
|
|
},
|
|
mutations: {
|
|
update_search(state, patient) {
|
|
state.search = patient
|
|
},
|
|
update_info(state, patient) {
|
|
state.info = patient
|
|
},
|
|
update_snackbar(state, patient) {
|
|
state.snackbar = patient
|
|
},
|
|
update_barcode(state, val) {
|
|
state.barcode = val
|
|
},
|
|
update_mous(state, val) {
|
|
state.mous = val
|
|
},
|
|
update_selected_mou(state, val) {
|
|
state.selected_mou = val
|
|
},
|
|
update_current_page(state, val) {
|
|
state.current_page = val
|
|
},
|
|
update_total_page(state, val) {
|
|
state.total_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_staffs(state, data) {
|
|
state.staffs = data
|
|
},
|
|
update_selected_staff(state, val) {
|
|
state.selected_staff = val
|
|
},
|
|
update_transactions(state, data) {
|
|
state.transactions = data
|
|
},
|
|
update_selected_filter_work(state, val) {
|
|
state.selected_filter_work = val
|
|
},
|
|
update_selected_filter_status(state, val) {
|
|
state.selected_filter_status = val
|
|
},
|
|
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_authorize(state,val){
|
|
state.dialog_authorize = 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
|
|
},
|
|
update_open_print_out(state, val) {
|
|
state.open_print_out = val
|
|
},
|
|
|
|
},
|
|
actions: {
|
|
async getinitialdatas(context,prm) {
|
|
context.commit("update_get_data_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.getinitialdatas(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
|
|
}
|
|
context.commit("update_mous",data.records['mous'])
|
|
context.commit("update_selected_mou",data.records['mous'][0])
|
|
context.dispatch("search",{
|
|
search:prm.search,
|
|
current_page:prm.current_page,
|
|
mouid:data.records['mous'][0]['id'],
|
|
lastid:-1
|
|
})
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_get_data_status",3)
|
|
}
|
|
},
|
|
async screening(context,prm) {
|
|
context.commit("update_get_data_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.screening(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
|
|
}
|
|
|
|
context.commit("update_msg_success","Sample "+prm.barcode+" disiapkan untuk upload")
|
|
context.commit("update_dialog_success",true)
|
|
setTimeout(function(){ context.commit("update_dialog_success",false) }, 1000)
|
|
context.dispatch("search",prm)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_get_data_status",3)
|
|
}
|
|
},
|
|
async dosampled(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.dosampled(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status",3)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
|
|
let msg = data.records
|
|
var snackbar = {value:true,timeout:4000,text:msg}
|
|
context.commit("update_snackbar",snackbar)
|
|
context.dispatch("search",{
|
|
search:prm.search,
|
|
mouid:prm.mouid,
|
|
current_page:prm.current_page,
|
|
lastid:-1
|
|
})
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
},
|
|
async scanbarcode(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.scanbarcode(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status",3)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
|
|
let msg = data.records
|
|
context.commit("update_barcode","")
|
|
var snackbar = {value:true,timeout:4000,text:msg}
|
|
context.commit("update_snackbar",snackbar)
|
|
console.log(snackbar)
|
|
context.dispatch("search",{
|
|
search:prm.search,
|
|
mouid:prm.mouid,
|
|
current_page:prm.current_page,
|
|
lastid:-1
|
|
})
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
},
|
|
async search_barcode(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
window.key_enter = ''
|
|
prm.token = one_token()
|
|
let resp= await api.search_barcode(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status",3)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
|
|
let msg = data.records
|
|
context.commit("update_barcode","")
|
|
var snackbar = {value:true,timeout:4000,text:msg}
|
|
context.commit("update_snackbar",snackbar)
|
|
console.log({
|
|
search:context.state.search,
|
|
mouid:context.state.selected_mou.id,
|
|
current_page:context.state.current_page,
|
|
lastid:-1
|
|
})
|
|
context.dispatch("search",{
|
|
search:context.state.search,
|
|
mouid:context.state.selected_mou.id,
|
|
current_page:context.state.current_page,
|
|
lastid:-1
|
|
})
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_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_info", {rest:data.records[0].xrest,total:data.records[0].xtotal})
|
|
context.commit("update_total_page", parseInt(data.total))
|
|
context.commit("update_no_save", 0)
|
|
|
|
|
|
/*if(prm.lastid === -1){
|
|
if(data.records.length > 0){
|
|
var trx = data.records[0]
|
|
console.log(trx)
|
|
context.commit("update_selected_transaction",trx)
|
|
context.commit("update_act",'edit')
|
|
context.commit("form/update_transaction_number",trx.trx_number,{root:true})
|
|
context.commit("form/update_transaction_date",trx.xdate,{root:true})
|
|
context.commit("form/update_transaction_time",trx.xtime,{root:true})
|
|
context.commit("form/update_staffs",[{M_StaffID:trx.trx_staffid,M_StaffName:trx.trx_staffname}],{root:true})
|
|
context.commit("form/update_selected_staff",{M_StaffID:trx.trx_staffid,M_StaffName:trx.trx_staffname},{root:true})
|
|
context.commit("form/update_porter",trx.trx_transporter,{root:true})
|
|
context.commit("form/update_transaction_note",trx.trx_note,{root:true})
|
|
context.commit("form/update_detailnonsamples",trx.detailnonsamples,{root:true})
|
|
context.commit("form/update_details",trx.details,{root:true})
|
|
}
|
|
else{
|
|
var trx = {}
|
|
console.log(trx)
|
|
context.commit("update_selected_transaction",trx)
|
|
context.commit("update_act",'new')
|
|
context.commit("form/update_transaction_number",'',{root:true})
|
|
context.commit("form/update_transaction_date",moment(new Date()).format('YYYY-MM-DD'),{root:true})
|
|
context.commit("form/update_transaction_time",moment(new Date()).format("hh:mm"),{root:true})
|
|
context.commit("form/update_staffs",[],{root:true})
|
|
context.commit("form/update_selected_staff",{},{root:true})
|
|
context.commit("form/update_porter",'',{root:true})
|
|
context.commit("form/update_transaction_note",'',{root:true})
|
|
context.commit("form/update_detailnonsamples",[],{root:true})
|
|
context.commit("form/update_details",[],{root:true})
|
|
}
|
|
|
|
}
|
|
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)
|
|
}
|
|
},
|
|
async deletetrx(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.deletetrx(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status",3)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
context.commit("update_selected_transaction",{})
|
|
context.commit("form/update_transaction_number",'',{root:true})
|
|
context.commit("form/update_transaction_date",moment(new Date()).format('YYYY-MM-DD'),{root:true})
|
|
context.commit("form/update_transaction_time",moment(new Date()).format("hh:mm"),{root:true})
|
|
context.commit("form/update_staffs",[])
|
|
context.commit("form/update_selected_staff",{},{root:true})
|
|
context.commit("form/update_porter",'',{root:true})
|
|
context.commit("form/update_transaction_note",'',{root:true})
|
|
context.commit("form/update_detailnonsamples",[],{root:true})
|
|
context.commit("form/update_details",[],{root:true})
|
|
context.commit("update_act",'new')
|
|
context.commit("update_dialog_confirmation_delete",false)
|
|
context.commit("update_dialog_success", true)
|
|
var msg = "Transaksi pembatalan " + prm.trx_number + " berhasil dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
},
|
|
async search_staff(context,prm) {
|
|
context.commit("update_get_data_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.search_staff(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
|
|
}
|
|
if(data.records)
|
|
context.commit("update_staff",resp.data.records)
|
|
else{
|
|
context.commit("update_staff",{id:0,code:'',name:'STAF TIDAK DITEMUKAN',code:'',userid:''})
|
|
}
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_get_data_status",3)
|
|
}
|
|
},
|
|
}
|
|
} |