430 lines
16 KiB
JavaScript
430 lines
16 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/antibiotic.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
antibiotics: [],
|
|
save_status: 0,
|
|
save_error_message: '',
|
|
dialog_form_antibiotic: false,
|
|
dialog_status_order: false,
|
|
lookup_antibiotic: 0,
|
|
search_status: 0,
|
|
errors: [],
|
|
startdate: moment(new Date()).format('YYYY-MM-DD'),
|
|
enddate: moment(new Date()).format('YYYY-MM-DD'),
|
|
bases: [],
|
|
base: {},
|
|
omzettypes: [],
|
|
omzettype: {},
|
|
antibiotictypes: [],
|
|
antibiotictype: {},
|
|
agingtypes: [],
|
|
agingtype: {},
|
|
statuss: [],
|
|
autobacterias:[],
|
|
autobacteria:{},
|
|
autocitys:[],
|
|
autocity:{},
|
|
autodistricts:[],
|
|
autodistrict:{},
|
|
autokelurahans:[],
|
|
autokelurahan:{},
|
|
name: '',
|
|
minvalueR: '',
|
|
maxvalueR: '',
|
|
isminvalueinclusiveR: false,
|
|
ismaxvalueinclusiveR: false,
|
|
noteR: '',
|
|
minvalueS: '',
|
|
maxvalueS: '',
|
|
isminvalueinclusiveS: true,
|
|
ismaxvalueinclusiveS: false,
|
|
noteS: '',
|
|
minvalueI: '',
|
|
maxvalueI: '',
|
|
isminvalueinclusiveI: true,
|
|
ismaxvalueinclusiveI: false,
|
|
noteI: '',
|
|
current_page:1,
|
|
x_search: '',
|
|
total_data: 0,
|
|
selected_antibiotic: {
|
|
name: ""
|
|
}
|
|
},
|
|
mutations: {
|
|
update_selected_antibiotic(state, val) {
|
|
state.selected_antibiotic = val
|
|
},
|
|
update_x_search(state, val) {
|
|
state.x_search = val
|
|
},
|
|
update_current_page(state, val) {
|
|
state.current_page = val
|
|
},
|
|
update_total_data(state, val) {
|
|
state.total_data = val
|
|
},
|
|
update_autobacterias(state,data){
|
|
state.autobacterias = data
|
|
},
|
|
update_autobacteria(state,val){
|
|
state.autobacteria = val
|
|
},
|
|
update_autocitys(state,data){
|
|
state.autocitys = data
|
|
},
|
|
update_autocity(state,val){
|
|
state.autocity = val
|
|
},
|
|
update_autodistricts(state,data){
|
|
state.autodistricts = data
|
|
},
|
|
update_autodistrict(state,val){
|
|
state.autodistrict = val
|
|
},
|
|
update_autokelurahans(state,data){
|
|
state.autokelurahans = data
|
|
},
|
|
update_autokelurahan(state,val){
|
|
state.autokelurahan = val
|
|
},
|
|
update_name(state, val) {
|
|
state.name = val
|
|
},
|
|
update_minvalueR(state, val) {
|
|
state.minvalueR = val
|
|
},
|
|
update_maxvalueR(state, val) {
|
|
state.maxvalueR = val
|
|
},
|
|
update_isminvalueinclusiveR(state, val) {
|
|
state.isminvalueinclusiveR = val
|
|
},
|
|
update_ismaxvalueinclusiveR(state, val) {
|
|
state.ismaxvalueinclusiveR = val
|
|
},
|
|
update_noteR(state, val) {
|
|
state.noteR = val
|
|
},
|
|
update_minvalueS(state, val) {
|
|
state.minvalueS = val
|
|
},
|
|
update_maxvalueS(state, val) {
|
|
state.maxvalueS = val
|
|
},
|
|
update_isminvalueinclusiveS(state, val) {
|
|
state.isminvalueinclusiveS = val
|
|
},
|
|
update_ismaxvalueinclusiveS(state, val) {
|
|
state.ismaxvalueinclusiveS = val
|
|
},
|
|
update_noteS(state, val) {
|
|
state.noteS = val
|
|
},
|
|
update_minvalueI(state, val) {
|
|
state.minvalueI = val
|
|
},
|
|
update_maxvalueI(state, val) {
|
|
state.maxvalueI = val
|
|
},
|
|
update_isminvalueinclusiveI(state, val) {
|
|
state.isminvalueinclusiveI = val
|
|
},
|
|
update_ismaxvalueinclusiveI(state, val) {
|
|
state.ismaxvalueinclusiveI = val
|
|
},
|
|
update_noteI(state, val) {
|
|
state.noteI = val
|
|
},
|
|
update_errors(state, val) {
|
|
state.errors = val
|
|
},
|
|
update_antibiotics(state, data) {
|
|
state.antibiotics = data
|
|
},
|
|
update_save_status(state, val) {
|
|
state.save_status = val
|
|
},
|
|
update_save_error_message(state, val) {
|
|
state.save_error_message = val
|
|
},
|
|
update_dialog_form_antibiotic(state, val) {
|
|
state.dialog_form_antibiotic = val
|
|
},
|
|
update_lookup_antibiotic(state, val) {
|
|
state.lookup_antibiotic = val
|
|
},
|
|
update_startdate(state, val) {
|
|
state.startdate = val
|
|
},
|
|
update_enddate(state, val) {
|
|
state.enddate = val
|
|
},
|
|
update_bases(state, data) {
|
|
state.bases = data
|
|
},
|
|
update_base(state, val) {
|
|
state.base = val
|
|
},
|
|
update_omzettypes(state, data) {
|
|
state.omzettypes = data
|
|
},
|
|
update_omzettype(state, val) {
|
|
state.omzettype = val
|
|
},
|
|
update_antibiotictypes(state, data) {
|
|
state.antibiotictypes = data
|
|
},
|
|
update_antibiotictype(state, val) {
|
|
state.antibiotictype = val
|
|
},
|
|
update_agingtypes(state, data) {
|
|
state.agingtypes = data
|
|
},
|
|
update_agingtype(state, val) {
|
|
state.agingtype = val
|
|
},
|
|
update_search_status(state, val) {
|
|
state.search_status = val
|
|
},
|
|
update_statuss(state, data) {
|
|
state.statuss = data
|
|
},
|
|
update_dialog_status_order(state, val) {
|
|
state.dialog_status_order = val
|
|
}
|
|
},
|
|
actions: {
|
|
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)
|
|
context.commit("update_save_error_message", resp.message)
|
|
} else {
|
|
var data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
if (data.total !== -1) {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_save_error_message", resp.message)
|
|
context.commit("bacteria/update_alert_success", true, {
|
|
root: true
|
|
})
|
|
|
|
context.commit("update_dialog_form_antibiotic", false)
|
|
var msg = "Antibiotik " + prm.name + " Bacteria " + prm.bacterianame + " sudah disimpan dong"
|
|
context.commit("bacteria/update_msg_success", msg, {
|
|
root: true
|
|
})
|
|
context.commit("bacteria/update_alert_success", true, {
|
|
root: true
|
|
})
|
|
context.dispatch("lookupbyname", {
|
|
bacteria: prm.sbacteria,
|
|
antibiotic: prm.santibiotic,
|
|
current_page: 1,
|
|
lastid: -1
|
|
})
|
|
} else {
|
|
context.commit("update_errors", resp.data.errors)
|
|
}
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_save_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async lookupx(context, prm) {
|
|
context.commit("update_lookup_antibiotic", 1)
|
|
try {
|
|
let resp = await api.lookupx(one_token(), prm.id)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_lookup_antibiotic", 3)
|
|
} else {
|
|
context.commit("update_lookup_antibiotic", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_antibiotics", data.records)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_lookup_antibiotic", 3)
|
|
}
|
|
},
|
|
async lookup(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.lookup(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_antibiotics", data.records)
|
|
console.log('status')
|
|
console.log(data.records.statuss)
|
|
context.commit("update_statuss", data.records.statuss)
|
|
context.commit("update_total_data", data.total)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async lookupbyname(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.lookupbyname(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_antibiotics", data.records)
|
|
console.log(data.records)
|
|
context.commit("update_total_data", data.total)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async delete(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
let resp = await api.xdelete(one_token(), prm.xid)
|
|
if (resp.status != "OK") {
|
|
context.commit("bacteria/update_save_status", 3, {
|
|
root: true
|
|
})
|
|
context.commit("bacteria/update_save_error_message", resp.message, {
|
|
root: true
|
|
})
|
|
} else {
|
|
context.commit("bacteria/update_save_status", 2, {
|
|
root: true
|
|
})
|
|
context.commit("bacteria/update_save_error_message", resp.message, {
|
|
root: true
|
|
})
|
|
context.commit("bacteria/update_alert_success", true, {
|
|
root: true
|
|
})
|
|
|
|
//context.commit("update_dialog_form_schedule_promise", false)
|
|
var msg = "Antibiotik sudah dihapus dong"
|
|
context.commit("bacteria/update_msg_success", msg, {
|
|
root: true
|
|
})
|
|
context.commit("bacteria/update_alert_success", true, {
|
|
root: true
|
|
})
|
|
context.dispatch("lookupbyname", {
|
|
bacteria: prm.sbacteria,
|
|
antibiotic: prm.santibiotic,
|
|
current_page: 1,
|
|
lastid: -1
|
|
})
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_save_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async searchbacteria(context,prm) {
|
|
context.commit("bacteria/update_autocomplete_status",1,{root: true})
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.searchbacteria(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("bacteria/update_autocomplete_status",3,{root: true})
|
|
} else {
|
|
context.commit("bacteria/update_autocomplete_status",2,{root: true})
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_autobacterias",resp.data.records)
|
|
}
|
|
} catch(e) {
|
|
context.commit("bacteria/update_autocomplete_status",3,{root: true})
|
|
}
|
|
},
|
|
async searchcity(context,prm) {
|
|
context.commit("bacteria/update_autocomplete_status",1,{root: true})
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.searchcity(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("bacteria/update_autocomplete_status",3,{root: true})
|
|
} else {
|
|
context.commit("bacteria/update_autocomplete_status",2,{root: true})
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_autocitys",resp.data.records)
|
|
}
|
|
} catch(e) {
|
|
context.commit("bacteria/update_autocomplete_status",3,{root: true})
|
|
}
|
|
},
|
|
async searchdistrict(context,prm) {
|
|
context.commit("bacteria/update_autocomplete_status",1,{root: true})
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.searchdistrict(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("bacteria/update_autocomplete_status",3,{root: true})
|
|
} else {
|
|
context.commit("bacteria/update_autocomplete_status",2,{root: true})
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_autodistricts",resp.data.records)
|
|
}
|
|
} catch(e) {
|
|
context.commit("bacteria/update_autocomplete_status",3,{root: true})
|
|
}
|
|
},
|
|
async searchkelurahan(context,prm) {
|
|
context.commit("bacteria/update_autocomplete_status",1,{root: true})
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.searchkelurahan(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("bacteria/update_autocomplete_status",3,{root: true})
|
|
} else {
|
|
context.commit("bacteria/update_autocomplete_status",2,{root: true})
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_autokelurahans",resp.data.records)
|
|
}
|
|
} catch(e) {
|
|
context.commit("bacteria/update_autocomplete_status",3,{root: true})
|
|
}
|
|
}
|
|
}
|
|
} |