230 lines
9.3 KiB
JavaScript
230 lines
9.3 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/deltacheck.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
deltachecks: [],
|
|
deltadifference: '',
|
|
deltadifferencepercent: '',
|
|
ratedifference: '',
|
|
ratedifferencepercent: '',
|
|
validinterval: '',
|
|
upperlimit: '',
|
|
lowerlimit: '',
|
|
dialog_form_delta_check: true,
|
|
selected_autoverificationlist: {},
|
|
selected_test: {},
|
|
search_status: 0,
|
|
tests: [],
|
|
total_test: 0,
|
|
search: '',
|
|
lookup_delta_check: 0,
|
|
times:[],
|
|
time:{},
|
|
difs:[],
|
|
dif:{},
|
|
get_data_status:0,
|
|
get_data_error_message:'',
|
|
isdelta: 'Y'
|
|
},
|
|
mutations: {
|
|
update_delta_check(state, data) {
|
|
state.deltachecks = data
|
|
},
|
|
update_isdelta(state, val) {
|
|
state.isdelta= val
|
|
},
|
|
update_deltadifference(state, val) {
|
|
state.deltadifference = val
|
|
},
|
|
update_deltadifferencepercent(state, val) {
|
|
state.deltadifferencepercent = val
|
|
},
|
|
update_ratedifference(state, val) {
|
|
state.ratedifference = val
|
|
},
|
|
update_ratedifferencepercent(state, val) {
|
|
state.ratedifferencepercent = val
|
|
},
|
|
update_validinterval(state, val) {
|
|
state.validinterval = val
|
|
},
|
|
update_upperlimit(state, val) {
|
|
state.upperlimit = val
|
|
},
|
|
update_lowerlimit(state, val) {
|
|
state.lowerlimit = val
|
|
},
|
|
update_dialog_form_delta_check(state, data) {
|
|
state.dialog_form_delta_check = data
|
|
},
|
|
update_selected_autoverificationlist(state, data) {
|
|
state.selected_autoverificationlist = data
|
|
},
|
|
update_selected_test(state, data) {
|
|
state.selected_test = data
|
|
},
|
|
update_search(state, val) {
|
|
state.search = val
|
|
},
|
|
update_search_status(state, status) {
|
|
state.search_status = status
|
|
},
|
|
update_tests(state, data) {
|
|
state.tests = data.records
|
|
state.total_test = data.total
|
|
},
|
|
update_lookup_delta_check(state, val) {
|
|
state.lookup_delta_check = val
|
|
},
|
|
update_times(state,data){
|
|
state.times = data
|
|
},
|
|
update_time(state,val){
|
|
state.time = val
|
|
},
|
|
update_difs(state,data){
|
|
state.difs = data
|
|
},
|
|
update_dif(state,val){
|
|
state.dif = val
|
|
},
|
|
update_get_data_status(state,val){
|
|
state.get_data_status = val
|
|
},
|
|
update_get_data_error_message(state,val){
|
|
state.get_data_error_message = val
|
|
}
|
|
},
|
|
actions: {
|
|
async save(context, prm) {
|
|
context.commit("autoverificationlist/update_save_status", 1, { root: true })
|
|
try {
|
|
let resp = await api.save(one_token(),prm.Nat_DeltaCheckT_TestID, prm.Nat_DeltaCheckM_DifferenceID, prm.Nat_DeltaCheckValidInterval, prm.Nat_DeltaCheckM_TimeID, prm.Nat_DeltaCheckUpperLimit, prm.Nat_DeltaCheckLowerLimit)
|
|
if (resp.status != "OK") {
|
|
context.commit("autoverificationlist/update_save_status", 3, { root: true })
|
|
context.commit("autoverificationlist/update_save_error_message", resp.message, { root: true })
|
|
} else {
|
|
context.commit("autoverificationlist/update_save_status", 2, { root: true })
|
|
context.commit("autoverificationlist/update_save_error_message", resp.message, { root: true })
|
|
context.commit("autoverificationlist/update_alert_success", true, { root: true })
|
|
|
|
context.commit("update_dialog_form_delta_check", false)
|
|
var msg = "Data sudah tersimpan dong"
|
|
context.commit("autoverificationlist/update_msg_success", msg, { root: true })
|
|
context.commit("autoverificationlist/update_alert_success", true, { root: true })
|
|
context.dispatch("lookup", {
|
|
id: prm.Nat_DeltaCheckT_TestID
|
|
})
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_save_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async search(context, prm) {
|
|
//console.log('dsadas')
|
|
context.commit("update_search_status", 1)
|
|
try {
|
|
let resp = await api.search(one_token(),context.state.search, prm.id)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_search_status", 3)
|
|
} else {
|
|
context.commit("update_search_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_tests", data)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_search_status", 3)
|
|
//context.commit("update_save_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async lookup(context, prm) {
|
|
context.commit("update_lookup_delta_check", 1)
|
|
try {
|
|
let resp = await api.lookup(one_token(),prm.id)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_lookup_delta_check", 3)
|
|
} else {
|
|
context.commit("update_lookup_delta_check", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_delta_check", data.records)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_lookup_delta_check", 3)
|
|
}
|
|
},
|
|
async delete(context, prm) {
|
|
context.commit("autoverificationlist/update_save_status", 1, { root: true })
|
|
try {
|
|
let resp = await api.xdelete(one_token(),prm.xid)
|
|
if (resp.status != "OK") {
|
|
context.commit("autoverificationlist/update_save_status", 3, { root: true })
|
|
context.commit("autoverificationlist/update_save_error_message", resp.message, { root: true })
|
|
} else {
|
|
context.commit("autoverificationlist/update_save_status", 2, { root: true })
|
|
context.commit("autoverificationlist/update_save_error_message", resp.message, { root: true })
|
|
context.commit("autoverificationlist/update_alert_success", true, { root: true })
|
|
|
|
//context.commit("update_dialog_form_schedule_promise", false)
|
|
var msg = "Test " + prm.testname + " dari schedule " + prm.schedulename + " sudah dihapus dong"
|
|
context.commit("autoverificationlist/update_msg_success", msg, { root: true })
|
|
context.commit("autoverificationlist/update_alert_success", true, { root: true })
|
|
context.dispatch("lookup", {
|
|
id: prm.scheduleid
|
|
})
|
|
}
|
|
} catch (e) {
|
|
context.commit("autoverificationlist/update_save_status", 3, { root: true })
|
|
console.log(e)
|
|
}
|
|
},
|
|
async selecttime(context) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
let resp = await api.selecttime(one_token())
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status", 3)
|
|
context.commit("update_get_data_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_get_data_status", 2)
|
|
context.commit("update_get_data_error_message", "")
|
|
context.commit("update_times", resp.data.records.times)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_get_data_status", 3)
|
|
context.commit("update_get_data_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async selectdif(context) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
let resp = await api.selectdif(one_token())
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status", 3)
|
|
context.commit("update_get_data_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_get_data_status", 2)
|
|
context.commit("update_get_data_error_message", "")
|
|
context.commit("update_difs", resp.data.records.difs)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_get_data_status", 3)
|
|
context.commit("update_get_data_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
}
|
|
}
|
|
} |