Flatten nested repos
This commit is contained in:
210
test/vuex/one-md-report/modules/reportgroup.js
Normal file
210
test/vuex/one-md-report/modules/reportgroup.js
Normal file
@@ -0,0 +1,210 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/reportgroup.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
reportgroups: [],
|
||||
total_reportgroup: 0,
|
||||
selected_reportgroup: {},
|
||||
current_page: 1,
|
||||
last_id: -1,
|
||||
x_search: "",
|
||||
search_status: false,
|
||||
dialog_form: false,
|
||||
act: "add",
|
||||
loading_save: false,
|
||||
save_status: 2,
|
||||
alert_success: false,
|
||||
msg_success: "",
|
||||
alert_error: false,
|
||||
error_message: "",
|
||||
dialog_error: false
|
||||
},
|
||||
mutations: {
|
||||
update_reportgroups(state, val) {
|
||||
state.reportgroups = val
|
||||
},
|
||||
update_total_reportgroup(state, val) {
|
||||
state.total_reportgroup = val
|
||||
},
|
||||
update_selected_reportgroup(state, val) {
|
||||
state.selected_reportgroup = val
|
||||
},
|
||||
update_current_page(state, val) {
|
||||
state.current_page = val
|
||||
},
|
||||
update_last_id(state, val) {
|
||||
state.last_id = val
|
||||
},
|
||||
update_x_search(state, val) {
|
||||
state.x_search = val
|
||||
state.current_page = 1
|
||||
},
|
||||
update_search_status(state, val) {
|
||||
state.search_status = val
|
||||
},
|
||||
update_dialog_form(state, val) {
|
||||
state.dialog_form = val
|
||||
},
|
||||
update_act(state, val) {
|
||||
state.act = val
|
||||
},
|
||||
update_loading_save(state, val) {
|
||||
state.loading_save = val
|
||||
},
|
||||
update_save_status(state, val) {
|
||||
state.save_status = val
|
||||
},
|
||||
update_alert_success(state, val) {
|
||||
state.alert_success = val;
|
||||
},
|
||||
update_msg_success(state, val) {
|
||||
state.msg_success = val
|
||||
},
|
||||
update_alert_error(state, val) {
|
||||
state.alert_error = val;
|
||||
},
|
||||
update_error_message(state, val) {
|
||||
state.error_message = val
|
||||
},
|
||||
update_dialog_error(state, val) {
|
||||
state.dialog_error = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async searchgroup(context) {
|
||||
context.commit("update_search_status", true)
|
||||
try {
|
||||
var prm = {
|
||||
token: one_token(),
|
||||
search: context.state.x_search,
|
||||
current_page: context.state.current_page
|
||||
}
|
||||
let resp = await api.searchgroup(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", false)
|
||||
console.log(resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", false)
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total_page: resp.data.total_page,
|
||||
total_filter: resp.data.total_filter
|
||||
}
|
||||
context.commit("update_reportgroups", data.records)
|
||||
context.commit("update_total_reportgroup", data.total_page)
|
||||
if (context.state.last_id == -1) {
|
||||
if (resp.data && resp.data.records.length > 0) {
|
||||
context.commit("update_selected_reportgroup", resp.data.records[0])
|
||||
}
|
||||
} else {
|
||||
let idx = _.findIndex(resp.data.records, function (o) {
|
||||
return o.R_ReportGroupID == context.state.update_selected_reportgroup.R_ReportGroupID
|
||||
});
|
||||
if (idx >= 0) {
|
||||
context.commit("update_selected_reportgroup", resp.data.records[idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", false)
|
||||
}
|
||||
},
|
||||
|
||||
async addgroup(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
context.commit("update_loading_save", true)
|
||||
prm.token = one_token()
|
||||
let resp = await api.addgroup(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", resp.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", "")
|
||||
context.commit("update_dialog_error", false)
|
||||
let data = resp.data
|
||||
var msg = "Report group " + prm.name + " berhasil disimpan"
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_alert_success", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
context.dispatch("searchgroup")
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", e.message)
|
||||
context.commit("update_alert_error", true)
|
||||
}
|
||||
},
|
||||
|
||||
async editgroup(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
context.commit("update_loading_save", true)
|
||||
prm.token = one_token()
|
||||
let resp = await api.editgroup(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", resp.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", "")
|
||||
context.commit("update_dialog_error", false)
|
||||
context.commit("update_dialog_form", false)
|
||||
var msg = "Report group " + prm.name + " berhasil terupdate"
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_alert_success", true)
|
||||
context.dispatch("searchgroup")
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", e.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
}
|
||||
},
|
||||
|
||||
async deletegroup(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
context.commit("update_loading_save", true)
|
||||
prm.token = one_token()
|
||||
let resp = await api.deletegroup(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", resp.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", "")
|
||||
context.commit("update_dialog_error", false)
|
||||
context.commit("update_dialog_form", false)
|
||||
var msg = "Report group " + prm.name + " berhasil dihapus"
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_alert_success", true)
|
||||
context.dispatch("searchgroup")
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", e.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
285
test/vuex/one-md-report/modules/reportparameter.js
Normal file
285
test/vuex/one-md-report/modules/reportparameter.js
Normal file
@@ -0,0 +1,285 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/reportparameter.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
reportparams: [],
|
||||
total_reportparam: 0,
|
||||
selected_reportparam: {},
|
||||
search_status: false,
|
||||
x_search: "",
|
||||
current_page: 1,
|
||||
last_id: -1,
|
||||
dialog_form: false,
|
||||
act: "add",
|
||||
loading_save: false,
|
||||
autocomplete_status: 0,
|
||||
|
||||
// dropdown reports
|
||||
reports: [],
|
||||
report: {},
|
||||
|
||||
type_status: 0,
|
||||
types: [],
|
||||
save_status: 2,
|
||||
loading_save: false,
|
||||
error_message: "",
|
||||
alert_error: false,
|
||||
dialog_error: false,
|
||||
msg_success: "",
|
||||
alert_success: false,
|
||||
selected_reports_id: 0
|
||||
},
|
||||
mutations: {
|
||||
update_reportparams(state, val) {
|
||||
state.reportparams = val
|
||||
},
|
||||
update_total_reportparam(state, val) {
|
||||
state.total_reportparam = val
|
||||
},
|
||||
update_selected_reportparam(state, val) {
|
||||
state.selected_reportparam = val
|
||||
},
|
||||
update_search_status(state, val) {
|
||||
state.search_status = val
|
||||
},
|
||||
update_x_search(state, val) {
|
||||
state.x_search = val
|
||||
state.current_page = 1
|
||||
},
|
||||
update_current_page(state, val) {
|
||||
state.current_page = val
|
||||
},
|
||||
update_last_id(state, val) {
|
||||
state.last_id = val
|
||||
},
|
||||
update_dialog_form(state, val) {
|
||||
state.dialog_form = val
|
||||
},
|
||||
update_act(state, val) {
|
||||
state.act = val
|
||||
},
|
||||
update_loading_save(state, val) {
|
||||
state.loading_save = val
|
||||
},
|
||||
update_autocomplete_status(state, val) {
|
||||
state.autocomplete_status = val
|
||||
},
|
||||
update_reports(state, val) {
|
||||
state.reports = val
|
||||
},
|
||||
update_report(state, val) {
|
||||
state.report = val
|
||||
},
|
||||
update_type_status(state, val) {
|
||||
state.type_status = val
|
||||
},
|
||||
update_types(state, val) {
|
||||
state.types = val
|
||||
},
|
||||
update_save_status(state, val) {
|
||||
state.save_status = val
|
||||
},
|
||||
update_loading_save(state, val) {
|
||||
state.loading_save = val
|
||||
},
|
||||
update_error_message(state, val) {
|
||||
state.error_message = val
|
||||
},
|
||||
update_alert_error(state, val) {
|
||||
state.alert_error = val;
|
||||
},
|
||||
update_dialog_error(state, val) {
|
||||
state.dialog_error = val
|
||||
},
|
||||
update_msg_success(state, val) {
|
||||
state.msg_success = val
|
||||
},
|
||||
update_alert_success(state, val) {
|
||||
state.alert_success = val
|
||||
},
|
||||
update_selected_reports_id(state, val) {
|
||||
state.selected_reports_id = val
|
||||
state.current_page = 1
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async searchparam(context) {
|
||||
context.commit("update_search_status", true)
|
||||
try {
|
||||
var prm = {
|
||||
token: one_token(),
|
||||
report_id: context.state.selected_reports_id,
|
||||
search: context.state.x_search,
|
||||
current_page: context.state.current_page
|
||||
}
|
||||
let resp = await api.searchparam(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", false)
|
||||
console.log(resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", false)
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total_page: resp.data.total_page,
|
||||
total_filter: resp.data.total_filter
|
||||
}
|
||||
context.commit("update_reportparams", data.records)
|
||||
context.commit("update_total_reportparam", data.total_page)
|
||||
if (context.state.last_id == -1) {
|
||||
if (resp.data && resp.data.records.length > 0) {
|
||||
context.commit("update_selected_reportparam", resp.data.records[0])
|
||||
}
|
||||
} else {
|
||||
let idx = _.findIndex(resp.data.records, function (o) {
|
||||
return o.R_ReportDetailID == context.state.update_selected_reportparam.R_ReportDetailID
|
||||
});
|
||||
if (idx >= 0) {
|
||||
context.commit("update_selected_reportparam", resp.data.records[idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", false)
|
||||
}
|
||||
},
|
||||
|
||||
// dropdown reports
|
||||
async get_reports(context, prm) {
|
||||
context.commit("update_autocomplete_status", 1)
|
||||
try {
|
||||
var prm = {
|
||||
token: one_token(),
|
||||
reportid: context.state.selected_reports_id
|
||||
}
|
||||
let resp = await api.get_reports(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
} else {
|
||||
context.commit("update_autocomplete_status", 2)
|
||||
let data = {
|
||||
records: resp.data.records
|
||||
}
|
||||
context.commit("update_reports", resp.data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
}
|
||||
},
|
||||
|
||||
async get_type(context) {
|
||||
context.commit("update_type_status", 1)
|
||||
try {
|
||||
var prm = { token: one_token() }
|
||||
let resp = await api.get_type(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_type_status", 3)
|
||||
} else {
|
||||
context.commit("update_type_status", 2)
|
||||
let data = {
|
||||
records: resp.data.records
|
||||
}
|
||||
context.commit("update_types", data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_type_status", 3)
|
||||
}
|
||||
},
|
||||
|
||||
async addparam(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
context.commit("update_loading_save", true)
|
||||
prm.token = one_token()
|
||||
let resp = await api.addparam(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", resp.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", "")
|
||||
context.commit("update_dialog_error", false)
|
||||
let data = resp.data
|
||||
var msg = prm.name + " berhasil disimpan"
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_alert_success", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
context.dispatch("searchparam")
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", e.message)
|
||||
context.commit("update_alert_error", true)
|
||||
}
|
||||
},
|
||||
|
||||
async editparam(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
context.commit("update_loading_save", true)
|
||||
prm.token = one_token()
|
||||
let resp = await api.editparam(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", resp.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", "")
|
||||
context.commit("update_dialog_error", false)
|
||||
context.commit("update_dialog_form", false)
|
||||
var msg = prm.name + " berhasil terupdate"
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_alert_success", true)
|
||||
context.dispatch("searchparam")
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", e.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
}
|
||||
},
|
||||
|
||||
async deleteparam(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
context.commit("update_loading_save", true)
|
||||
prm.token = one_token()
|
||||
let resp = await api.deleteparam(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", resp.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", "")
|
||||
context.commit("update_dialog_error", false)
|
||||
context.commit("update_dialog_form", false)
|
||||
var msg = prm.name + " berhasil dihapus"
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_alert_success", true)
|
||||
context.dispatch("searchparam")
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", e.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
241
test/vuex/one-md-report/modules/reports.js
Normal file
241
test/vuex/one-md-report/modules/reports.js
Normal file
@@ -0,0 +1,241 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/reports.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
reportss: [],
|
||||
total_reports: 0,
|
||||
search_status: false,
|
||||
current_page: 1,
|
||||
x_search: "",
|
||||
selected_reports: {},
|
||||
last_id: -1,
|
||||
dialog_form: false,
|
||||
act: "add",
|
||||
loading_save: false,
|
||||
getreportgroup: [],
|
||||
save_status: 2,
|
||||
error_message: "",
|
||||
alert_error: false,
|
||||
dialog_error: false,
|
||||
msg_success: "",
|
||||
alert_success: false,
|
||||
selected_reportgroup_id: 0
|
||||
},
|
||||
mutations: {
|
||||
update_reportss(state, val) {
|
||||
state.reportss = val
|
||||
},
|
||||
update_total_reports(state, val) {
|
||||
state.total_reports = val
|
||||
},
|
||||
update_search_status(state, val) {
|
||||
state.search_status = val
|
||||
},
|
||||
update_current_page(state, val) {
|
||||
state.current_page = val
|
||||
},
|
||||
update_x_search(state, val) {
|
||||
state.x_search = val
|
||||
state.current_page = 1
|
||||
},
|
||||
update_selected_reports(state, val) {
|
||||
state.selected_reports = val
|
||||
},
|
||||
update_last_id(state, val) {
|
||||
state.last_id = val
|
||||
},
|
||||
update_dialog_form(state, val) {
|
||||
state.dialog_form = val
|
||||
},
|
||||
update_act(state, val) {
|
||||
state.act = val
|
||||
},
|
||||
update_loading_save(state, val) {
|
||||
state.loading_save = val
|
||||
},
|
||||
update_getreportgroup(state, val) {
|
||||
state.getreportgroup = val
|
||||
},
|
||||
update_save_status(state, val) {
|
||||
state.save_status = val
|
||||
},
|
||||
update_error_message(state, val) {
|
||||
state.error_message = val
|
||||
},
|
||||
update_alert_error(state, val) {
|
||||
state.alert_error = val;
|
||||
},
|
||||
update_dialog_error(state, val) {
|
||||
state.dialog_error = val
|
||||
},
|
||||
update_msg_success(state, val) {
|
||||
state.msg_success = val
|
||||
},
|
||||
update_alert_success(state, val) {
|
||||
state.alert_success = val
|
||||
},
|
||||
update_selected_reportgroup_id(state, val) {
|
||||
state.selected_reportgroup_id = val
|
||||
state.current_page = 1
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async searchreports(context) {
|
||||
context.commit("update_search_status", true)
|
||||
try {
|
||||
var prm = {
|
||||
token: one_token(),
|
||||
reportgroup_id: context.state.selected_reportgroup_id,
|
||||
search: context.state.x_search,
|
||||
current_page: context.state.current_page
|
||||
}
|
||||
let resp = await api.searchreports(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", false)
|
||||
console.log(resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", false)
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total_page: resp.data.total_page,
|
||||
total_filter: resp.data.total_filter
|
||||
}
|
||||
context.commit("update_reportss", data.records)
|
||||
context.commit("update_total_reports", data.total_page)
|
||||
if (context.state.last_id == -1) {
|
||||
if (resp.data && resp.data.records.length > 0) {
|
||||
context.commit("update_selected_reports", resp.data.records[0])
|
||||
}
|
||||
} else {
|
||||
let idx = _.findIndex(resp.data.records, function (o) {
|
||||
return o.R_ReportID == context.state.update_selected_reports.R_ReportID
|
||||
});
|
||||
console.log("idx reports", idx)
|
||||
if (idx >= 0) {
|
||||
console.log("cek idx reports", idx)
|
||||
context.commit("update_selected_reports", resp.data.records[idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", false)
|
||||
}
|
||||
},
|
||||
|
||||
async get_reportgroup(context) {
|
||||
try {
|
||||
var prm = { token: one_token() }
|
||||
let resp = await api.get_reportgroup(prm)
|
||||
if (resp.status != "OK") {
|
||||
console.log(resp.message)
|
||||
} else {
|
||||
let data = {
|
||||
records: resp.data.records
|
||||
}
|
||||
context.commit("update_getreportgroup", data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
|
||||
async addreport(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
context.commit("update_loading_save", true)
|
||||
prm.token = one_token()
|
||||
let resp = await api.addreport(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", resp.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", "")
|
||||
context.commit("update_dialog_error", false)
|
||||
let data = resp.data
|
||||
var msg = "Report " + prm.name + " berhasil disimpan"
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_alert_success", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
context.dispatch("searchreports")
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", e.message)
|
||||
context.commit("update_alert_error", true)
|
||||
}
|
||||
},
|
||||
|
||||
async editreport(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
context.commit("update_loading_save", true)
|
||||
prm.token = one_token()
|
||||
let resp = await api.editreport(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", resp.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", "")
|
||||
context.commit("update_dialog_error", false)
|
||||
context.commit("update_dialog_form", false)
|
||||
var msg = "Reports " + prm.name + " berhasil terupdate"
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_alert_success", true)
|
||||
context.dispatch("searchreports")
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", e.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
}
|
||||
},
|
||||
|
||||
async deletereport(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
context.commit("update_loading_save", true)
|
||||
prm.token = one_token()
|
||||
let resp = await api.deletereport(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", resp.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", "")
|
||||
context.commit("update_dialog_error", false)
|
||||
context.commit("update_dialog_form", false)
|
||||
var msg = "Reports " + prm.name + " berhasil dihapus"
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_alert_success", true)
|
||||
context.dispatch("searchreports")
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
context.commit("update_loading_save", false)
|
||||
context.commit("update_error_message", e.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user