516 lines
21 KiB
JavaScript
516 lines
21 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/samplestorage.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
trx_id:0,
|
|
save_status: 0,
|
|
transaction_number:'',
|
|
transaction_date:moment(new Date()).format('DD-MM-YYYY'),
|
|
transaction_date_mcu:moment(new Date()).format('DD-MM-YYYY'),
|
|
transaction_time:moment(new Date()).format("HH:mm"),
|
|
xfilterdate:moment(new Date()).format('YYYY-MM-DD'),
|
|
end_date:moment(new Date()).format('YYYY-MM-DD'),
|
|
transaction_note:'',
|
|
details:[],
|
|
total_details:0,
|
|
samples:[],
|
|
selected_detail:{},
|
|
almaries:[],
|
|
mgmmcus:[],
|
|
selected_mgmmcu:{},
|
|
staffs:[],
|
|
selected_staff:{},
|
|
officer_types:[
|
|
{'id':'D', 'name':'Driver'},
|
|
{'id':'PU', 'name':'Petugas Umum'},
|
|
{'id':'CS', 'name':'Atur Pasien'},
|
|
{'id':'IT', 'name':'IT Support'},
|
|
{'id':'R','name':'Registrasi LIS'},
|
|
{'id':'RR','name':'Registrasi Rontgen'},
|
|
{'id':'PA','name':'Pendaftaran Akhir'}
|
|
],
|
|
selected_officer_type:{},
|
|
racks:[],
|
|
selected_almari:{},
|
|
selected_rack:{},
|
|
get_data_status:0,
|
|
open_almari:false,
|
|
open_rack:false,
|
|
rack_contents:[],
|
|
dialog_search_sample:false,
|
|
lookup_sample_status:0,
|
|
kecamatans:[],
|
|
selected_kecamatan:{'id':'0','name':'Semua'},
|
|
companies:[{'M_CompanyID':'0','M_CompanyName':'Semua'}],
|
|
selected_company:{'M_CompanyID':'0','M_CompanyName':'Semua'},
|
|
types:[],
|
|
selected_type:{'id':'0','name':'Semua'},
|
|
errors:[],
|
|
current_page_search:1,
|
|
total_page_search:1,
|
|
bar_chx_all:false,
|
|
bar_chx_allx:false,
|
|
selected_transaction:{},
|
|
deleted_details:[],
|
|
show_delete:false,
|
|
filter_search:'',
|
|
officerHeaderDetails:[],
|
|
selected_officerHeaderDetail:{},
|
|
search_staff: ""
|
|
},
|
|
mutations: {
|
|
update_filter_search(state, val) {
|
|
state.filter_search = val
|
|
},
|
|
update_show_delete(state, val) {
|
|
state.show_delete = val
|
|
},
|
|
update_deleted_details(state, val) {
|
|
state.deleted_details = val
|
|
},
|
|
update_bar_chx_allx(state, val) {
|
|
state.bar_chx_allx = val
|
|
},
|
|
update_selected_transaction(state, val) {
|
|
state.selected_transaction = val
|
|
},
|
|
update_bar_chx_all(state, val) {
|
|
state.bar_chx_all = val
|
|
},
|
|
update_current_page_search(state, val) {
|
|
state.current_page_search = val
|
|
},
|
|
update_total_page_search(state, val) {
|
|
state.total_page_search = val
|
|
},
|
|
update_errors(state, val) {
|
|
state.errors = val
|
|
},
|
|
update_trx_id(state, val) {
|
|
state.trx_id = val
|
|
},
|
|
update_xfilterdate(state, val) {
|
|
state.xfilterdate = val
|
|
},
|
|
update_companies(state, val) {
|
|
state.companies = val
|
|
},
|
|
update_selected_company(state, val) {
|
|
state.selected_company = val
|
|
},
|
|
update_kecamatans(state, val) {
|
|
state.kecamatans = val
|
|
},
|
|
update_selected_kecamatan(state, val) {
|
|
state.selected_kecamatan = val
|
|
},
|
|
update_types(state, val) {
|
|
state.types = val
|
|
},
|
|
update_selected_type(state, val) {
|
|
state.selected_type = val
|
|
},
|
|
update_mgmmcus(state, val) {
|
|
state.mgmmcus = val
|
|
},
|
|
update_selected_mgmmcu(state, val) {
|
|
state.selected_mgmmcu = val
|
|
},
|
|
update_staffs(state, val) {
|
|
state.staffs = val
|
|
},
|
|
update_selected_staff(state, val) {
|
|
state.selected_staff = val
|
|
},
|
|
update_officer_types(state, val) {
|
|
state.officer_types = val
|
|
},
|
|
update_selected_officer_type(state, val) {
|
|
state.selected_officer_type = val
|
|
},
|
|
update_save_status(state, val) {
|
|
state.save_status = val
|
|
},
|
|
update_transaction_number(state, val) {
|
|
state.transaction_number = val
|
|
},
|
|
update_transaction_date(state, val) {
|
|
state.transaction_date = val
|
|
},
|
|
update_transaction_date_mcu(state, val) {
|
|
state.transaction_date_mcu = val
|
|
},
|
|
update_transaction_time(state, val) {
|
|
state.transaction_time = val
|
|
},
|
|
update_transaction_note(state, val) {
|
|
state.transaction_note = val
|
|
},
|
|
update_end_date(state, val) {
|
|
state.end_date = val
|
|
},
|
|
update_details(state, val) {
|
|
state.details = val
|
|
},
|
|
update_total_details(state, val) {
|
|
state.total_details = val
|
|
},
|
|
update_samples(state, val) {
|
|
state.samples = val
|
|
},
|
|
update_selected_detail(state, val) {
|
|
state.selected_detail = val
|
|
console.log(val)
|
|
},
|
|
update_almaries(state, val) {
|
|
state.almaries = val
|
|
},
|
|
update_racks(state, val) {
|
|
state.racks = val
|
|
},
|
|
update_selected_almari(state, val) {
|
|
state.selected_almari = val
|
|
},
|
|
update_selected_rack(state, val) {
|
|
state.selected_rack = val
|
|
},
|
|
update_get_data_status(state, val) {
|
|
state.get_data_status = val
|
|
},
|
|
update_open_almari(state, val) {
|
|
state.open_almari = val
|
|
},
|
|
update_open_rack(state, val) {
|
|
state.open_rack = val
|
|
},
|
|
update_rack_contents(state, val) {
|
|
state.rack_contents = val
|
|
},
|
|
update_dialog_search_sample(state, val) {
|
|
state.dialog_search_sample = val
|
|
},
|
|
update_lookup_sample_status(state, val) {
|
|
state.lookup_sample_status = val
|
|
},
|
|
update_officerHeaderDetails(state, val) {
|
|
state.officerHeaderDetails = val
|
|
},
|
|
update_selected_officerHeaderDetail(state, val) {
|
|
state.officerHeaderDetail = val
|
|
},
|
|
update_deleted_officerHeaderDetails(state, val) {
|
|
state.officerHeaderDetails.splice(val, 1)
|
|
},
|
|
update_search_staff(state, val) {
|
|
state.search_staff = val
|
|
}
|
|
},
|
|
actions: {
|
|
async removeOfficer(context, idx) {
|
|
context.commit('update_deleted_officerHeaderDetails', idx);
|
|
},
|
|
async getmgmmcu(context) {
|
|
context.commit("update_get_data_status",1)
|
|
try {
|
|
let resp= await api.getmgmmcu(one_token())
|
|
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_mgmmcus",data.records)
|
|
var xdate = moment(data.records.xdate).format('YYYY-MM-DD')
|
|
console.log(xdate)
|
|
context.commit("update_transaction_date",xdate)
|
|
var xdatemcu = moment(data.records.xdatemcu).format('YYYY-MM-DD')
|
|
console.log(xdatemcu)
|
|
context.commit("update_transaction_date_mcu",xdatemcu)
|
|
var xtime = moment(data.records.xdate).format("HH:mm")
|
|
context.commit("update_transaction_time",xtime)
|
|
console.log(xtime)
|
|
|
|
context.commit("samplestorage/update_selected_transaction",{},{root:true})
|
|
context.commit("samplestorage/update_act",'new',{root:true})
|
|
context.commit("update_transaction_number","")
|
|
context.commit("update_trx_id",0)
|
|
context.commit("update_transaction_note",'')
|
|
context.commit("update_selected_mgmmcu",{})
|
|
context.commit("update_selected_staff",{})
|
|
context.commit("update_selected_officer_type",{})
|
|
context.commit("update_officerHeaderDetails",[])
|
|
context.commit("update_details",[])
|
|
context.commit("update_deleted_details",[])
|
|
context.commit("update_trx_id",0)
|
|
context.commit("update_show_delete",false)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_get_data_status",3)
|
|
}
|
|
},
|
|
async getstaff(context,prm) {
|
|
context.commit("update_get_data_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.getstaff(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_staffs",data.records)
|
|
|
|
// context.commit("samplestorage/update_selected_transaction",{},{root:true})
|
|
// context.commit("samplestorage/update_act",'new',{root:true})
|
|
// context.commit("update_transaction_number","")
|
|
// context.commit("update_trx_id",0)
|
|
// context.commit("update_transaction_note",'')
|
|
// context.commit("update_selected_mgmmcu",{})
|
|
// context.commit("update_selected_staff",{})
|
|
// context.commit("update_selected_officer_type",{})
|
|
// context.commit("update_officerHeaderDetails",[])
|
|
// context.commit("update_details",[])
|
|
// context.commit("update_deleted_details",[])
|
|
// context.commit("update_trx_id",0)
|
|
// context.commit("update_show_delete",false)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_get_data_status",3)
|
|
}
|
|
},
|
|
async deleteAll(context,prm) {
|
|
context.commit("update_get_data_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.deleteall(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status",3)
|
|
} else {
|
|
context.commit("update_get_data_status",2)
|
|
context.commit("samplestorage/update_current_page",1,{root:true})
|
|
var xprm = {
|
|
startdate:context.rootState.samplestorage.start_date,
|
|
enddate: context.rootState.samplestorage.end_date,
|
|
// status:context.rootState.samplestorage.selected_status.id,
|
|
current_page:context.rootState.samplestorage.current_page,
|
|
lastid:-1
|
|
}
|
|
context.commit("update_officerHeaderDetails",[])
|
|
context.dispatch("samplestorage/search",xprm,{root:true})
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_get_data_status",3)
|
|
}
|
|
},
|
|
async getkecamatan(context,prm){
|
|
context.commit("update_get_data_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.getkecamatan(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_kecamatans",data.records['kecamatan'])
|
|
context.commit("update_selected_kecamatan",{id:0,name:'Semua Kecamatan'})
|
|
|
|
context.commit("update_types",data.records['type'])
|
|
context.commit("update_selected_type",{id:0,name:'Semua Pengantaran'})
|
|
|
|
var xprm = prm
|
|
xprm.kecamatan = context.state.selected_kecamatan
|
|
xprm.type = context.state.selected_type
|
|
context.dispatch("searchall",xprm)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_get_data_status",3)
|
|
}
|
|
},
|
|
async getdetails(context,prm) {
|
|
context.commit("update_get_data_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.getdetails(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_officerHeaderDetails",data.records)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_get_data_status",3)
|
|
}
|
|
},
|
|
async save(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.save(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status",3)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
context.commit("update_transaction_date",moment(new Date()).format('DD-MM-YYYY'))
|
|
context.commit("update_transaction_date_mcu",moment(new Date()).format('DD-MM-YYYY'))
|
|
context.commit("update_transaction_time",moment(new Date()).format("hh:mm"))
|
|
context.commit("update_transaction_note","")
|
|
context.commit("update_transaction_number","")
|
|
context.commit("update_selected_mgmmcu",{})
|
|
context.commit("update_selected_staff",{})
|
|
context.commit("update_selected_officer_type",{})
|
|
|
|
context.commit("update_officerHeaderDetails",[])
|
|
|
|
context.commit("samplestorage/update_last_id", resp.data.id,{root:true})
|
|
var msg = "Transaksi " + resp.data.number + " berhasil dong ..."
|
|
context.commit("samplestorage/update_msg_success", msg,{root:true})
|
|
context.commit("samplestorage/update_dialog_success", true,{root:true})
|
|
// context.commit("update_details",[])
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
},
|
|
async checkbarcode(context,prm) {
|
|
context.commit("update_get_data_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.checkbarcode(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){
|
|
var arr = prm.details
|
|
let idx = _.findIndex(arr, { barcode : prm.barcode})
|
|
|
|
if(idx === -1 ){
|
|
var detail = {
|
|
xid:0,
|
|
barcode:prm.barcode,
|
|
almari:{},
|
|
rack:{},
|
|
rackid:0,
|
|
row:0,
|
|
col:0,
|
|
ordersampleid:data.records.T_OrderSampleID,
|
|
patientname:data.records.patientname
|
|
}
|
|
arr.push(detail)
|
|
|
|
context.commit("update_details",arr)
|
|
let idx = _.findIndex(arr, function(o) { return o.barcode == detail.barcode })
|
|
context.commit("update_selected_detail",arr[idx])
|
|
}else{
|
|
var msg = "Sudah ada di list dong"
|
|
context.commit("samplestorage/update_msg_info",msg,{root:true})
|
|
context.commit("samplestorage/update_open_dialog_info",true,{root:true})
|
|
}
|
|
|
|
}
|
|
else{
|
|
var msg = "Barcode <span style='font-weight:900'>"+prm.barcode+"</span> tidak valid dong"
|
|
context.commit("samplestorage/update_msg_info",msg,{root:true})
|
|
context.commit("samplestorage/update_open_dialog_info",true,{root:true})
|
|
}
|
|
|
|
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_get_data_status",3)
|
|
}
|
|
},
|
|
async lookupsamples(context, prm) {
|
|
context.commit("update_lookup_sample_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.lookupsamples(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_lookup_sample_status", 3)
|
|
} else {
|
|
context.commit("update_lookup_sample_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_samples", data.records)
|
|
context.commit("update_dialog_search_sample",true)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_lookup_sample_status", 3)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async searchall(context, prm) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.searchall(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_samples", data.records)
|
|
context.commit("update_dialog_search_sample",true)
|
|
context.commit("update_total_page_search", data.total)
|
|
context.commit("update_companies", resp.data.companies)
|
|
var idx_company = _.findIndex(resp.data.companies, prm.company)
|
|
if(idx_company != -1){
|
|
context.commit("update_selected_company", prm.company)
|
|
}
|
|
else{
|
|
context.commit("update_selected_company", {'M_CompanyID':'0','M_CompanyName':'Semua'})
|
|
}
|
|
|
|
context.commit("update_kecamatans", resp.data.districts)
|
|
var idx_kecamatan = _.findIndex(resp.data.districts, prm.kecamatan)
|
|
if(idx_kecamatan != -1){
|
|
context.commit("update_selected_kecamatan", prm.kecamatan)
|
|
}
|
|
else{
|
|
context.commit("update_selected_kecamatan", {'id':'0','name':'Semua'})
|
|
}
|
|
|
|
context.commit("update_types", resp.data.deliveries)
|
|
var idx_type = _.findIndex(resp.data.deliveries, prm.type)
|
|
if(idx_type != -1){
|
|
context.commit("update_selected_type", prm.type)
|
|
}
|
|
else{
|
|
context.commit("update_selected_type", {'id':'0','name':'Semua'})
|
|
}
|
|
//context.commit("update_total_details", data.total)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_get_data_status", 3)
|
|
console.log(e)
|
|
}
|
|
}
|
|
}
|
|
} |