Flatten nested repos
This commit is contained in:
446
test/vuex/modules/test.js
Normal file
446
test/vuex/modules/test.js
Normal file
@@ -0,0 +1,446 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/test.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
act:'',
|
||||
lookup_test:0,
|
||||
lookup_error_message:'',
|
||||
get_data_status:0,
|
||||
test_dialog:false,
|
||||
test_message:'',
|
||||
status_done:'N',
|
||||
save_status:0,
|
||||
save_message:false,
|
||||
save_status_verification:0,
|
||||
save_error_message:'',
|
||||
autocomplete_status:0,
|
||||
test_registration:[],
|
||||
test_verification:[],
|
||||
test_all:[],
|
||||
tests:[],
|
||||
selected_test:{},
|
||||
test:{},
|
||||
promises:[],
|
||||
promise:{},
|
||||
cito:false,
|
||||
promise_dialog:false,
|
||||
msg_promise_dialog:'',
|
||||
selected_detail_verification:{},
|
||||
show_promise_left:false,
|
||||
showw_promise_right:false,
|
||||
promise_left:'',
|
||||
show_cito_dropdown:'N',
|
||||
selected_cito:{},
|
||||
citos:[],
|
||||
orderid:0,
|
||||
mouid:0,
|
||||
},
|
||||
mutations: {
|
||||
update_orderid(state, val) {
|
||||
state.orderid = val
|
||||
},
|
||||
update_mouid(state, val) {
|
||||
state.mouid = val
|
||||
},
|
||||
update_citos(state, val) {
|
||||
state.citos = val
|
||||
},
|
||||
update_selected_cito(state, val) {
|
||||
state.selected_cito = val
|
||||
},
|
||||
update_show_cito_dropdown(state, val) {
|
||||
state.show_cito_dropdown = val
|
||||
},
|
||||
update_selected_test(state, val) {
|
||||
state.selected_test = val
|
||||
},
|
||||
update_act(state, val) {
|
||||
state.act = val
|
||||
},
|
||||
update_lookup_test(state, val) {
|
||||
state.lookup_test = val
|
||||
},
|
||||
update_get_data_status(state, val) {
|
||||
state.get_data_status = val
|
||||
},
|
||||
update_lookup_error_message(state, val) {
|
||||
state.lookup_error_message = val
|
||||
},
|
||||
update_test_dialog(state, val) {
|
||||
state.test_dialog = val
|
||||
},
|
||||
update_test_message(state, val) {
|
||||
state.test_message = val
|
||||
},
|
||||
update_status_done(state, val) {
|
||||
state.status_done = val
|
||||
},
|
||||
update_save_status(state, val) {
|
||||
state.save_status = val
|
||||
},
|
||||
update_save_status_verification(state, val) {
|
||||
state.save_status_verification = val
|
||||
},
|
||||
update_save_error_message(state, val) {
|
||||
state.save_error_message = val
|
||||
},
|
||||
update_save_message(state, val) {
|
||||
state.save_message = val
|
||||
},
|
||||
update_autocomplete_status(state,val){
|
||||
state.autocomplete_status = val
|
||||
},
|
||||
update_test_registration(state,val){
|
||||
state.test_registration = val
|
||||
},
|
||||
update_test_verification(state,val){
|
||||
state.test_verification = val
|
||||
},
|
||||
update_test_all(state,val){
|
||||
state.test_all = val
|
||||
},
|
||||
update_tests(state,val){
|
||||
state.tests = val
|
||||
},
|
||||
update_test(state,val){
|
||||
state.test = val
|
||||
},
|
||||
update_promises(state,val){
|
||||
state.promises = val
|
||||
},
|
||||
update_promise(state,val){
|
||||
state.promise = val
|
||||
},
|
||||
update_cito(state,val){
|
||||
state.cito = val
|
||||
},
|
||||
update_promise_dialog(state,val){
|
||||
state.promise_dialog = val
|
||||
},
|
||||
update_msg_promise_dialog(state,val){
|
||||
state.msg_promise_dialog = val
|
||||
},
|
||||
update_selected_detail_verification(state,val){
|
||||
state.selected_detail_verification = val
|
||||
},
|
||||
update_show_promise_left(state,val){
|
||||
state.show_promise_left = val
|
||||
},
|
||||
update_show_promise_right(state,val){
|
||||
state.show_promise_right = val
|
||||
},
|
||||
update_promise_left(state,val){
|
||||
state.promise_left = val
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
async lookup(context,prm) {
|
||||
context.commit("update_lookup_test",1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp= await api.lookup(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_test",3)
|
||||
context.commit("update_lookup_error_message",resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_test",2)
|
||||
context.commit("update_lookup_error_message","")
|
||||
let data = {
|
||||
records : resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
let rtn = data.records
|
||||
|
||||
context.commit("update_test_registration",rtn.testregistration)
|
||||
context.commit("update_test_verification",rtn.testverification)
|
||||
if(rtn.testverification.length > 0){
|
||||
context.commit("update_promise_left",resp.data.promise)
|
||||
context.commit("update_show_promise_left",true)
|
||||
}
|
||||
context.commit("update_test_all",rtn.testall)
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_lookup_test",3)
|
||||
context.commit("update_lookup_error_message",e.message )
|
||||
}
|
||||
},
|
||||
async lookup_promises(context,prm) {
|
||||
context.commit("update_lookup_test",1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp= await api.lookup_promises(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_test",3)
|
||||
context.commit("update_lookup_error_message",resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_test",2)
|
||||
context.commit("update_lookup_error_message","")
|
||||
let data = {
|
||||
records : resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
let rtn = data.records
|
||||
|
||||
context.commit("update_promises",rtn)
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_lookup_test",3)
|
||||
context.commit("update_lookup_error_message",e.message )
|
||||
}
|
||||
},
|
||||
async savetestadditionalverification(context,prm) {
|
||||
context.commit("update_save_status_verification",1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.savetestadditionalverification(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status_verification", 3)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_save_status_verification", 2)
|
||||
context.commit("update_save_error_message", "")
|
||||
|
||||
context.commit("update_test_registration",resp.data.records)
|
||||
context.commit("update_test_verification",[])
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status_verification", 3)
|
||||
context.commit("update_save_error_message", e.message)
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
async searchtest(context,prm) {
|
||||
context.commit("update_autocomplete_status",1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp= await api.searchtest(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_tests",resp.data.records)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_autocomplete_status",3)
|
||||
}
|
||||
},
|
||||
async checkstatus(context,prm) {
|
||||
context.commit("update_autocomplete_status",1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp= await api.checkstatus(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_autocomplete_status",3)
|
||||
} else {
|
||||
context.commit("update_autocomplete_status",2)
|
||||
let data = {
|
||||
status : resp.data.status,
|
||||
total: resp.data.total
|
||||
}
|
||||
var oldArr = context.state.test_all
|
||||
delete prm.token
|
||||
var idx = _.findIndex(oldArr, prm)
|
||||
if(data.status == 'OK'){
|
||||
|
||||
oldArr[idx].active = 'Y'
|
||||
oldArr[idx].status = false
|
||||
context.commit("update_test_all",oldArr)
|
||||
}
|
||||
else{
|
||||
oldArr[idx].status = true
|
||||
//oldArr[idx]["status === 'Y'"] = true
|
||||
context.commit("update_test_all",oldArr)
|
||||
console.log(oldArr)
|
||||
var msg = "Bang ... beli satenya 10 tusuk, pake lontong ya, kalo statusnya sdh divalidasi tidak bisa dihapus ya"
|
||||
context.commit('patient/update_errormsg',msg,{root:true})
|
||||
context.commit('patient/update_dialogerrormsg',msg,{root:true})
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_autocomplete_status",3)
|
||||
}
|
||||
},
|
||||
async savetestadditional(context,prm) {
|
||||
context.commit("update_save_status",1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp= await api.savetestadditional(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
|
||||
}
|
||||
console.log("dasdsa")
|
||||
context.commit("update_promise_dialog",false)
|
||||
context.commit("update_test_dialog",false)
|
||||
context.commit("update_test_all",resp.data.records.testall)
|
||||
context.commit("update_save_message", true)
|
||||
context.commit("update_show_cito_dropdown","N")
|
||||
context.commit("update_selected_cito",{})
|
||||
//setTimeout(() => context.commit("update_save_message", false), 3000)
|
||||
var snackbar = {value:true,text:"Data berhasil disimpan",timeout:4000}
|
||||
context.commit("patient/update_snackbar", snackbar,{root:true})
|
||||
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_save_status",3)
|
||||
}
|
||||
},
|
||||
async getnewprice(context,prm) {
|
||||
context.commit("update_save_status",1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp= await api.getnewprice(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
|
||||
}
|
||||
console.log(data.records.length)
|
||||
if(data.records.length === 0){
|
||||
var oldArr = context.state.test_all
|
||||
var idx = _.findIndex(oldArr, {pxid:prm.pxid})
|
||||
oldArr[idx].status = true
|
||||
oldArr[idx].active = 'Y'
|
||||
oldArr[idx].cito = false
|
||||
console.log(oldArr)
|
||||
context.commit("update_test_all",oldArr)
|
||||
|
||||
var msg = "Kala hujan di waktu pagi, cobalah sejenak untuk menepi, Jika harga belum diisi, tak ada yang bisa ditampilkan di sini"
|
||||
context.commit('patient/update_errormsg',msg,{root:true})
|
||||
context.commit('patient/update_dialogerrormsg',msg,{root:true})
|
||||
}else{
|
||||
var newprice = data.records[0]
|
||||
var oldArr = context.state.test_all
|
||||
var idx = _.findIndex(oldArr, {pxid:prm.pxid})
|
||||
delete prm.token
|
||||
delete prm.orderid
|
||||
|
||||
//var distot = ((parseFloat(newprice.T_PriceDisc)/100) * parseInt(newprice.T_PriceAmount)) + parseInt(newprice.T_PriceDiscRp)
|
||||
//var total = parseInt(newprice.T_PriceAmount) - distot
|
||||
//console.log(distot)
|
||||
prm.discountpersen = newprice.discountpersen
|
||||
prm.discountrp = newprice.discountrp
|
||||
prm.bruto = newprice.bruto
|
||||
prm.discount = newprice.discount
|
||||
prm.total = newprice.total
|
||||
prm.cito = newprice.cito
|
||||
prm.status = newprice.cito_before
|
||||
prm.active = 'Y'
|
||||
//console.log(prm)
|
||||
oldArr[idx] = prm
|
||||
|
||||
context.commit("update_test_all",oldArr)
|
||||
}
|
||||
//console.log(prm)
|
||||
context.commit("update_show_cito_dropdown","N")
|
||||
var rows = context.state.citos
|
||||
var row = _.filter(rows, function(o) { return o.xdefault === 'Y' })
|
||||
context.commit("update_selected_cito",row[0])
|
||||
console.log(prm.cito_before)
|
||||
console.log(prm.cito)
|
||||
if(prm.cito & prm.cito_before === 'N'){
|
||||
context.commit("update_show_cito_dropdown","Y")
|
||||
}
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_save_status",3)
|
||||
}
|
||||
},
|
||||
async getchildrenprofil(context,prm) {
|
||||
context.commit("update_get_data_status",1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp= await api.getchildrenprofil(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
|
||||
}
|
||||
var rows = data.records
|
||||
var xtestall = prm.all
|
||||
rows.forEach(function(entry) {
|
||||
xtestall.push(entry)
|
||||
})
|
||||
|
||||
context.commit("update_test_all",xtestall)
|
||||
context.commit("update_test",{})
|
||||
context.commit("update_tests",[])
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_get_data_status",3)
|
||||
}
|
||||
},
|
||||
async getcitos(context,prm) {
|
||||
context.commit("update_get_data_status",1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp= await api.getcitos(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
|
||||
}
|
||||
|
||||
var rows = data.records
|
||||
context.commit("update_citos",rows)
|
||||
var row = _.filter(rows, function(o) { return o.xdefault === 'Y' })
|
||||
context.commit("update_selected_cito",row)
|
||||
|
||||
context.commit("update_selected_cito","N")
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_get_data_status",3)
|
||||
}
|
||||
},
|
||||
async checkpromisetests(context,prm) {
|
||||
context.commit("update_get_data_status",1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp= await api.checkpromisetests(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
|
||||
}
|
||||
var msg = "<p>Janji hasil sebelum tambahan adalah <div class='pa-2 white--text info'>"+data.records.before+"</div></p>"+
|
||||
"<p>Janji hasil setelah tambahan adalah <div class='pa-2 white--text red'>"+data.records.after+"</div></p>"+
|
||||
"<h4 class='pt-2 text-uppercase font-weight-black'>YAKIN AKAN UPDATE ?</h4>"
|
||||
context.commit("update_msg_promise_dialog",msg)
|
||||
context.commit("update_promise_dialog", true)
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_get_data_status",3)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user