Flatten nested repos
This commit is contained in:
391
test/vuex/one-sample-storage-empty/modules/form.js
Normal file
391
test/vuex/one-sample-storage-empty/modules/form.js
Normal file
@@ -0,0 +1,391 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/samplestorage.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
save_status: 0,
|
||||
transaction_number:'',
|
||||
transaction_date:moment(new Date()).format('DD-MM-YYYY'),
|
||||
transaction_time:moment(new Date()).format("hh:mm"),
|
||||
transaction_note:'',
|
||||
picname:'',
|
||||
details:[],
|
||||
detailnonsamples:[],
|
||||
samples:[],
|
||||
nonsamples:[],
|
||||
selected_detail:{},
|
||||
selected_detail_nonsample:{},
|
||||
almaries:[],
|
||||
racks:[],
|
||||
staffs:[],
|
||||
selected_almari:{},
|
||||
selected_rack:{},
|
||||
selected_staff:{},
|
||||
get_data_status:0,
|
||||
open_almari:false,
|
||||
open_rack:false,
|
||||
rack_contents:[],
|
||||
dialog_search_sample:false,
|
||||
dialog_search_nonsample:false,
|
||||
lookup_sample_status:0,
|
||||
errors:[],
|
||||
dialog_add_vendor:false,
|
||||
success_add_vendor:false,
|
||||
autocomplete_status:0,
|
||||
porter:'',
|
||||
success_add_item:false,
|
||||
sample_weight:0,
|
||||
nonsample_weight:0,
|
||||
reffnumber:''
|
||||
},
|
||||
mutations: {
|
||||
update_autocomplete_status(state, val) {
|
||||
state.autocomplete_status = 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_time(state, val) {
|
||||
state.transaction_time = val
|
||||
},
|
||||
update_transaction_note(state, val) {
|
||||
state.transaction_note = val
|
||||
},
|
||||
update_picname(state, val) {
|
||||
state.picname = val
|
||||
},
|
||||
update_details(state, val) {
|
||||
state.details = val
|
||||
},
|
||||
update_detailnonsamples(state, val) {
|
||||
state.detailnonsamples = val
|
||||
},
|
||||
update_samples(state, val) {
|
||||
state.samples = val
|
||||
},
|
||||
update_nonsamples(state, val) {
|
||||
state.nonsamples = val
|
||||
},
|
||||
update_selected_detail(state, val) {
|
||||
state.selected_detail = val
|
||||
console.log(val)
|
||||
},
|
||||
update_selected_detail_nonsample(state, val) {
|
||||
state.selected_detail_nonsample = val
|
||||
console.log(val)
|
||||
},
|
||||
update_almaries(state, val) {
|
||||
state.almaries = val
|
||||
},
|
||||
update_racks(state, val) {
|
||||
state.racks = val
|
||||
},
|
||||
update_staffs(state, val) {
|
||||
state.staffs = val
|
||||
},
|
||||
update_selected_staff(state, val) {
|
||||
state.selected_staff = 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_dialog_search_nonsample(state, val) {
|
||||
state.dialog_search_nonsample = val
|
||||
},
|
||||
update_lookup_sample_status(state, val) {
|
||||
state.lookup_sample_status = val
|
||||
},
|
||||
update_errors(state, val) {
|
||||
state.errors = val
|
||||
},
|
||||
update_dialog_add_vendor(state, val) {
|
||||
state.dialog_add_vendor = val
|
||||
},
|
||||
update_success_add_vendor(state, val) {
|
||||
state.success_add_vendor = val
|
||||
},
|
||||
update_success_add_item(state, val) {
|
||||
state.success_add_item = val
|
||||
},
|
||||
update_porter(state, val) {
|
||||
state.porter= val
|
||||
},
|
||||
update_sample_weight(state, val) {
|
||||
state.sample_weight = val
|
||||
},
|
||||
update_nonsample_weight(state, val) {
|
||||
state.nonsample_weight = val
|
||||
},
|
||||
update_reffnumber(state, val) {
|
||||
state.reffnumber = val
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
async getitems(context) {
|
||||
context.commit("update_get_data_status",1)
|
||||
try {
|
||||
let resp= await api.getitems(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_details",data.records['details'])
|
||||
var dx = data.records['details']
|
||||
var sampleweigth = 0
|
||||
var nonsampleweight = 0
|
||||
for (var x = 0; x < dx.length; x++) {
|
||||
sampleweigth = sampleweigth + parseFloat(dx[x].sampleweight)
|
||||
nonsampleweight = nonsampleweight + parseFloat(dx[x].nonsampleweight)
|
||||
}
|
||||
context.commit("update_sample_weight",sampleweigth)
|
||||
context.commit("update_nonsample_weight",nonsampleweight)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_get_data_status",3)
|
||||
}
|
||||
},
|
||||
async getrackcontent(context,prm) {
|
||||
context.commit("update_get_data_status",1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp= await api.getrackcontent(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_rack_contents",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_time",moment(new Date()).format("hh:mm"))
|
||||
context.commit("update_selected_vendor",{})
|
||||
context.commit("update_picname","")
|
||||
context.commit("update_transaction_note","")
|
||||
context.commit("update_selected_almari",{})
|
||||
context.commit("update_racks",[])
|
||||
context.commit("update_selected_rack",{})
|
||||
context.commit("update_open_almari",false)
|
||||
context.commit("update_open_rack",false)
|
||||
context.commit("update_rack_contents",[])
|
||||
context.commit("update_details",[])
|
||||
context.commit("update_sample_weight",0)
|
||||
context.commit("update_detailnonsamples",[])
|
||||
context.commit("samplestorage/update_dialog_success", true,{root:true})
|
||||
context.commit("samplestorage/update_last_id", resp.data.id,{root:true})
|
||||
var msg = "Transaksi penyimpanan " + resp.data.numbering + " berhasil dong ..."
|
||||
context.commit("samplestorage/update_msg_success", msg,{root:true})
|
||||
|
||||
}
|
||||
} 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 lookupnonsamples(context, prm) {
|
||||
context.commit("update_lookup_sample_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.lookupnonsamples(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_nonsamples", data.records)
|
||||
context.commit("update_dialog_search_nonsample",true)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_lookup_sample_status", 3)
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
async savenewvendor(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.savenewvendor(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
|
||||
}
|
||||
|
||||
context.commit("update_success_add_vendor", true)
|
||||
context.commit("update_dialog_add_vendor", false)
|
||||
|
||||
setTimeout(function(){ context.commit("update_success_add_vendor", false) }, 3000);
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3)
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
async savenewitem(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.savenewitem(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
|
||||
}
|
||||
context.commit("update_nonsamples", data.records)
|
||||
|
||||
context.commit("update_success_add_item", true)
|
||||
setTimeout(function(){ context.commit("update_success_add_item", false) }, 3000);
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3)
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
async searchstaff(context,prm) {
|
||||
context.commit("update_autocomplete_status",1)
|
||||
try {
|
||||
let resp= await api.searchstaff(one_token(),prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_autocomplete_status",3)
|
||||
} else {
|
||||
context.commit("update_autocomplete_status",2)
|
||||
let data = {
|
||||
records : resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_staffs",resp.data.records)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_autocomplete_status",3)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
240
test/vuex/one-sample-storage-empty/modules/samplestorage.js
Normal file
240
test/vuex/one-sample-storage-empty/modules/samplestorage.js
Normal file
@@ -0,0 +1,240 @@
|
||||
// 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:'',
|
||||
open_print_out:false,
|
||||
current_page:1,
|
||||
total_page:1
|
||||
},
|
||||
mutations: {
|
||||
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
|
||||
},
|
||||
update_open_print_out(state, val) {
|
||||
state.open_print_out = val
|
||||
},
|
||||
|
||||
},
|
||||
actions: {
|
||||
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("form/update_details",[],{root:true})
|
||||
context.commit("form/update_nonsample_weight",0,{root:true})
|
||||
context.commit("form/update_sample_weight",0,{root:true})
|
||||
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)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user