287 lines
11 KiB
JavaScript
287 lines
11 KiB
JavaScript
// 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:[],
|
|
test:{},
|
|
promises:[],
|
|
promise:{},
|
|
cito:false,
|
|
promise_dialog:false,
|
|
msg_promise_dialog:'',
|
|
selected_detail_verification:{},
|
|
show_promise_left:false,
|
|
showw_promise_right:false,
|
|
promise_left:''
|
|
},
|
|
mutations: {
|
|
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 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
|
|
}
|
|
context.commit("update_test_registration",resp.data.records.testregistration)
|
|
context.commit("update_test_all",resp.data.records.testall)
|
|
context.commit("update_save_message", true)
|
|
setTimeout(() => context.commit("update_save_message", false), 3000)
|
|
}
|
|
} 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 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)
|
|
}
|
|
}
|
|
}
|
|
} |