Flatten nested repos
This commit is contained in:
501
test/vuex/one-sample-lab-verification/modules/samplesend.js
Normal file
501
test/vuex/one-sample-lab-verification/modules/samplesend.js
Normal file
@@ -0,0 +1,501 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/samplesend.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
last_id:-1,
|
||||
last_saved_id:-1,
|
||||
x_addr_id:0,
|
||||
btn_hide:false,
|
||||
act:'edit',
|
||||
act_addr:'new',
|
||||
act_search:false,
|
||||
get_data_status:0,
|
||||
search_patient: 0,
|
||||
search_status: 0,
|
||||
search_error_message: '',
|
||||
preffix:'',
|
||||
patient_name:'',
|
||||
suffix:'',
|
||||
patients: [],
|
||||
selected_patient: [],
|
||||
sampletypes:[],
|
||||
selected_sampletype:{},
|
||||
total_patients:0,
|
||||
patient_address: [],
|
||||
stations:[],
|
||||
selected_station:{},
|
||||
statuses:[],
|
||||
selected_status:{},
|
||||
transaction_date:moment(new Date()).format('DD-MM-YYYY'),
|
||||
transaction_time:moment(new Date()).format("hh:mm"),
|
||||
phone:'',
|
||||
hp:'',
|
||||
email:'',
|
||||
pj:'N',
|
||||
dpj:'N',
|
||||
clinic:'N',
|
||||
is_default:'N',
|
||||
marketing_confirm:'N',
|
||||
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: "",
|
||||
dialog_confirmation_delete_addr: false,
|
||||
msg_confirmation_delete_addr: "",
|
||||
autocomplete_status:0,
|
||||
dialog_form_address: false,
|
||||
label_address:'',
|
||||
addresses:[],
|
||||
cities:[],
|
||||
city_address:{},
|
||||
districts:[],
|
||||
district_address:{},
|
||||
kelurahans:[],
|
||||
kelurahan_address:{},
|
||||
description_address:'',
|
||||
errors:[],
|
||||
dialog_action:false,
|
||||
msg_action:'',
|
||||
current_page:1,
|
||||
total_page:1,
|
||||
dialog_requirement:false,
|
||||
requirements:[],
|
||||
selected_sample:{},
|
||||
open_dialog_info:false,
|
||||
msg_info:'',
|
||||
name:'',
|
||||
nolab:'',
|
||||
information_bahan:[],
|
||||
staff:{id:0,code:'',name:'BELUM ADA STAF',code:'',userid:''},
|
||||
indeterminatex:false,
|
||||
bar_chx_all:false,
|
||||
filter_sampletype:[],
|
||||
selected_filter_sampletype:{}
|
||||
},
|
||||
mutations: {
|
||||
update_filter_sampletype(state, val) {
|
||||
state.filter_sampletype = val
|
||||
},
|
||||
update_selected_filter_sampletype(state, val) {
|
||||
state.selected_filter_sampletype = val
|
||||
},
|
||||
update_act_search(state, val) {
|
||||
state.act_search = val
|
||||
},
|
||||
update_bar_chx_all(state, val) {
|
||||
state.bar_chx_all = val
|
||||
},
|
||||
update_indeterminatex(state, val) {
|
||||
state.indeterminatex = val
|
||||
},
|
||||
update_btn_hide(state, val) {
|
||||
state.btn_hide = val
|
||||
},
|
||||
update_staff(state, val) {
|
||||
state.staff = val
|
||||
},
|
||||
update_information_bahan(state, val) {
|
||||
state.information_bahan = val
|
||||
},
|
||||
update_name(state, val) {
|
||||
state.name = val
|
||||
},
|
||||
update_nolab(state, val) {
|
||||
state.nolab = val
|
||||
},
|
||||
update_open_dialog_info(state, val) {
|
||||
state.open_dialog_info = val
|
||||
},
|
||||
update_msg_info(state, val) {
|
||||
state.msg_info = val
|
||||
},
|
||||
update_selected_sample(state, val) {
|
||||
state.selected_sample = val
|
||||
},
|
||||
update_requirements(state, val) {
|
||||
state.requirements = val
|
||||
},
|
||||
update_dialog_requirement(state, val) {
|
||||
state.dialog_requirement = 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_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_patient(state, patient) {
|
||||
state.search_patient = patient
|
||||
},
|
||||
update_preffix(state, val) {
|
||||
state.preffix = val
|
||||
},
|
||||
update_patient_name(state, val) {
|
||||
state.patient_name = val
|
||||
},
|
||||
update_suffix(state, val) {
|
||||
state.suffix = val
|
||||
},
|
||||
update_patients(state, data) {
|
||||
state.patients = data
|
||||
},
|
||||
update_selected_patient(state, val) {
|
||||
state.selected_patient = val
|
||||
},
|
||||
update_sampletypes(state, data) {
|
||||
state.sampletypes = data
|
||||
},
|
||||
update_selected_sampletype(state, val) {
|
||||
state.selected_sampletype = val
|
||||
},
|
||||
update_stations(state, val) {
|
||||
state.stations = val
|
||||
},
|
||||
update_selected_station(state, val) {
|
||||
state.selected_station = val
|
||||
},
|
||||
update_statuses(state, val) {
|
||||
state.statuses = val
|
||||
},
|
||||
update_selected_status(state, val) {
|
||||
state.selected_status = val
|
||||
},
|
||||
update_phone(state, val) {
|
||||
state.phone = val
|
||||
},
|
||||
update_email(state, val) {
|
||||
state.email = val
|
||||
},
|
||||
update_hp(state, val) {
|
||||
state.hp = val
|
||||
},
|
||||
update_pj(state, val) {
|
||||
state.pj = val
|
||||
},
|
||||
update_dpj(state, val) {
|
||||
state.dpj = val
|
||||
},
|
||||
update_clinic(state, val) {
|
||||
state.clinic = val
|
||||
},
|
||||
update_marketing_confirm(state, val) {
|
||||
state.marketing_confirm = val
|
||||
},
|
||||
update_is_default(state, val) {
|
||||
state.is_default = 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_dialog_confirmation_delete_addr(state, val) {
|
||||
state.dialog_confirmation_delete_addr = val
|
||||
},
|
||||
update_msg_confirmation_delete_addr(state, val) {
|
||||
state.msg_confirmation_delete_addr = val
|
||||
},
|
||||
update_addresses(state, val) {
|
||||
state.addresses = val
|
||||
},
|
||||
update_autocomplete_status(state,val){
|
||||
state.autocomplete_status = val
|
||||
},
|
||||
update_dialog_form_address(state, val) {
|
||||
state.dialog_form_address = val
|
||||
},
|
||||
update_label_address(state, val) {
|
||||
state.label_address = val
|
||||
},
|
||||
update_cities(state, val) {
|
||||
state.cities = val
|
||||
},
|
||||
update_city_address(state, val) {
|
||||
state.city_address = val
|
||||
},
|
||||
update_districts(state, val) {
|
||||
state.districts = val
|
||||
},
|
||||
update_district_address(state, val) {
|
||||
state.district_address = val
|
||||
},
|
||||
update_kelurahans(state, val) {
|
||||
state.kelurahans = val
|
||||
},
|
||||
update_kelurahan_address(state, val) {
|
||||
state.kelurahan_address = val
|
||||
},
|
||||
update_description_address(state, val) {
|
||||
state.description_address = val
|
||||
},
|
||||
update_search_status(state, val) {
|
||||
state.search_status = val
|
||||
},
|
||||
update_errors(state, val) {
|
||||
state.errors = val
|
||||
},
|
||||
update_total_patients(state, val) {
|
||||
state.total_patients = val
|
||||
},
|
||||
update_dialog_action(state, val) {
|
||||
state.dialog_action = val
|
||||
},
|
||||
update_msg_action(state, val) {
|
||||
state.msg_action = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context, prm) {
|
||||
context.commit("update_search_patient", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.search(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_patient", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_patient", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_bar_chx_all",false)
|
||||
context.commit("update_indeterminatex",false)
|
||||
context.commit("update_patients", data.records)
|
||||
context.commit("update_total_patients", data.total)
|
||||
if(data.records.length > 0 && context.state.act_search){
|
||||
context.commit("update_bar_chx_all",true)
|
||||
context.commit("update_indeterminatex",false)
|
||||
var patients = data.records
|
||||
patients.forEach((el)=>{el.chex = true})
|
||||
context.commit("update_patients", patients)
|
||||
context.commit("update_act_search",false)
|
||||
}
|
||||
|
||||
context.commit("update_no_save", 0)
|
||||
context.commit("update_selected_patient", [])
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_patient", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
async getstationstatus(context,prm) {
|
||||
context.commit("update_get_data_status",1)
|
||||
try {
|
||||
let resp= await api.getstationstatus(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_stations",data.records.stations)
|
||||
context.commit("update_selected_station",data.records.stations[0])
|
||||
context.commit("update_statuses",data.records.statuses)
|
||||
context.commit("update_selected_status",data.records.statuses[0])
|
||||
|
||||
context.commit("update_filter_sampletype",data.records.sampletypes)
|
||||
context.commit("update_selected_filter_sampletype",data.records.sampletypes[0])
|
||||
|
||||
prm.nolab = ''
|
||||
//prm.sampletypeid = -1
|
||||
if(data.records.sampletypes.length > 0){
|
||||
var idx_sampletypeid = _.findIndex(data.records.sampletypes, function(o) { return o.id === prm.sampletypeid })
|
||||
if(idx_sampletypeid === -1){
|
||||
prm.sampletypeid = data.records.sampletypes[0].id
|
||||
context.commit("update_selected_filter_sampletype",data.records.sampletypes[0])
|
||||
}
|
||||
else
|
||||
context.commit("update_selected_filter_sampletype",data.records.sampletypes[idx_sampletypeid])
|
||||
}
|
||||
|
||||
context.dispatch("search",prm)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_get_data_status",3)
|
||||
}
|
||||
},
|
||||
async receivesample(context,prm) {
|
||||
context.commit("update_save_status",1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp= await api.doaction(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status",3)
|
||||
} else {
|
||||
context.commit("update_save_status",2)
|
||||
prm.search.lastid = -1
|
||||
context.dispatch("search",prm.search)
|
||||
}
|
||||
} 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)
|
||||
}
|
||||
},
|
||||
/*async search_patient(context,prm) {
|
||||
context.commit("update_get_data_status",1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
prm.stationid = context.state.selected_station.id
|
||||
let resp= await api.search_patient(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.rootState.px.req_status
|
||||
var rst = data.records
|
||||
if(rst){
|
||||
console.log(rst)
|
||||
context.commit("update_nolab",prm.search)
|
||||
context.commit("update_patients",rst)
|
||||
context.commit("update_bar_chx_all",true)
|
||||
context.commit("update_indeterminatex",false)
|
||||
context.commit("update_selected_patient",rst)
|
||||
}
|
||||
else{
|
||||
var msg = "Makan sambal pakai nasi, <span class='mono' style='color:red;font-weight:bold'>"+prm.search+"</span> mungkin sample-nya belum diverifikasi"
|
||||
context.commit("update_msg_info",msg)
|
||||
context.commit("update_open_dialog_info",true)
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_get_data_status",3)
|
||||
}
|
||||
},*/
|
||||
search_patient(context,prm) {
|
||||
context.commit("update_get_data_status",1)
|
||||
context.commit("update_act_search",true)
|
||||
//context.commit("update_get_data_status",1)
|
||||
prm.token = one_token()
|
||||
context.commit("update_nolab",prm.search)
|
||||
var serach = prm.search
|
||||
prm.stationid = context.state.selected_station.id
|
||||
//prm.statusid = context.state.selected_status.id
|
||||
prm.nolab = serach
|
||||
prm.searchx = serach
|
||||
prm.lastid = -1
|
||||
window.key_enter = ''
|
||||
|
||||
console.log(prm)
|
||||
context.dispatch("search",prm)
|
||||
},
|
||||
async doaction(context,prm) {
|
||||
context.commit("update_save_status",1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp= await api.doaction(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_act",'-')
|
||||
context.commit("update_btn_hide",false)
|
||||
if(data.records['status'] === 'OK'){
|
||||
context.dispatch("getstationstatus",{
|
||||
nolab:context.state.nolab,
|
||||
sampletypeid: context.state.selected_filter_sampletype.id,
|
||||
lastid: -1
|
||||
})
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_save_status",3)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user