Initial import
This commit is contained in:
@@ -0,0 +1,157 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/trendanalys.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
trendanalyss: [],
|
||||
minimumtest: '',
|
||||
islow: '',
|
||||
ishigh: '',
|
||||
istrend: 'N',
|
||||
dialog_form_trend_analys: true,
|
||||
selected_autoverificationlist: {},
|
||||
selected_test: {},
|
||||
search_status: 0,
|
||||
tests: [],
|
||||
total_test: 0,
|
||||
search: '',
|
||||
lookup_trend_analys: 0
|
||||
},
|
||||
mutations: {
|
||||
update_trend_analys(state, data) {
|
||||
state.trendanalyss = data
|
||||
},
|
||||
update_minimumtest(state, val) {
|
||||
state.minimumtest = val
|
||||
},
|
||||
update_islow(state, val) {
|
||||
state.islow = val
|
||||
},
|
||||
update_ishigh(state, val) {
|
||||
state.ishigh = val
|
||||
},
|
||||
update_istrend(state, val) {
|
||||
state.istrend = val
|
||||
},
|
||||
update_dialog_form_trend_analys(state, data) {
|
||||
state.dialog_form_trend_analys = 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_trend_analys(state, val) {
|
||||
state.lookup_trend_analys = 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_TrendAnalysisNat_TestID, prm.Nat_TrendAnalysisMinCount,prm.Nat_TrendAnalysisLow,prm.Nat_TrendAnalysisHigh)
|
||||
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_trend_analys", 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_TrendAnalysisNat_TestID
|
||||
})
|
||||
context.dispatch("autoverificationlist/lookup", {
|
||||
search: prm.search
|
||||
}, { root: true })
|
||||
}
|
||||
} 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_trend_analys", 1)
|
||||
try {
|
||||
let resp = await api.lookup(one_token(),prm.id)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_trend_analys", 3)
|
||||
} else {
|
||||
context.commit("update_lookup_trend_analys", 2)
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_trend_analys", data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_lookup_trend_analys", 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user