Flatten nested repos
This commit is contained in:
214
test/vuex/one-fo-klinik-setting-v3/modules/setting.js
Normal file
214
test/vuex/one-fo-klinik-setting-v3/modules/setting.js
Normal file
@@ -0,0 +1,214 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/setting.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
mous: [],
|
||||
loading: false,
|
||||
error: "",
|
||||
// search_mou: "",
|
||||
selected_mou: {},
|
||||
errors: [],
|
||||
save_status: 2,
|
||||
error_message: "",
|
||||
alert_error: false,
|
||||
dialog_error: false,
|
||||
msg_success: "",
|
||||
alert_success: false,
|
||||
errors: [],
|
||||
companys: [],
|
||||
// search_company: "",
|
||||
selected_company: {},
|
||||
price: '',
|
||||
locationList: [],
|
||||
selectedLocation: {}
|
||||
},
|
||||
mutations: {
|
||||
update_price(state, val) {
|
||||
state.price = val
|
||||
},
|
||||
update_locationList(state, val) {
|
||||
state.locationList = val
|
||||
},
|
||||
update_selectedLocation(state, val) {
|
||||
state.selectedLocation = val
|
||||
},
|
||||
update_mous(state, val) {
|
||||
state.mous = val
|
||||
},
|
||||
update_loading(state, val) {
|
||||
state.loading = val
|
||||
},
|
||||
update_error(state, val) {
|
||||
state.error = val
|
||||
},
|
||||
update_selected_mou(state, val) {
|
||||
if (state.selected_company === undefined) {
|
||||
state.selected_mou = {}
|
||||
} else {
|
||||
state.selected_mou = val
|
||||
}
|
||||
},
|
||||
update_errors(state, val) {
|
||||
state.errors = 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_errors(state, val) {
|
||||
state.errors = val
|
||||
},
|
||||
update_companys(state, val) {
|
||||
state.companys = val
|
||||
},
|
||||
update_selected_company(state, val) {
|
||||
state.selected_company = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async searchmou(context, { companyid, search }) {
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
let resp = await api.searchmou(one_token(), companyid, search)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_error", resp.message)
|
||||
} else {
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_error", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_mous", resp.data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_error", e.message)
|
||||
}
|
||||
},
|
||||
async savesetting(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.savesetting(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_error_message", resp.message)
|
||||
context.commit("update_alert_error", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
} else {
|
||||
var data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
if (data.total !== -1) {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_error_message", "")
|
||||
context.commit("update_dialog_error", false)
|
||||
let data = resp.data
|
||||
var msg = "Berhasil disimpan"
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_alert_success", true)
|
||||
context.commit("update_dialog_error", true)
|
||||
} else {
|
||||
context.commit("update_errors", resp.data.errors)
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_error_message", e.message)
|
||||
context.commit("update_alert_error", true)
|
||||
|
||||
}
|
||||
},
|
||||
async searchcompany(context, { search }) {
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
let resp = await api.searchcompany(one_token(), search)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_error", resp.message)
|
||||
} else {
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_error", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_companys", resp.data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_error", e.message)
|
||||
}
|
||||
},
|
||||
async getLocationList(context) {
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
let resp = await api.getLocationList({ "token": one_token() })
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_error", resp.message)
|
||||
} else {
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_error", "")
|
||||
// let data = {
|
||||
// records: resp.data.records,
|
||||
// total: resp.data.total
|
||||
// }
|
||||
context.commit("update_locationList", resp.data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_error", e.message)
|
||||
}
|
||||
},
|
||||
async get_data(context) {
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
var prm = {}
|
||||
prm.token = one_token()
|
||||
let resp = await api.get_data(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_error", resp.message)
|
||||
} else {
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_error", "")
|
||||
let rst = resp.data.records
|
||||
context.commit("update_selected_mou", { M_MouID: rst.settingM_MouID, M_MouName: rst.M_MouName })
|
||||
context.commit("update_mous", [{ M_MouID: rst.settingM_MouID, M_MouName: rst.M_MouName }])
|
||||
context.commit("update_selected_company", { M_CompanyID: rst.M_CompanyID, M_CompanyName: rst.M_CompanyName })
|
||||
context.commit("update_companys", [{ M_CompanyID: rst.M_CompanyID, M_CompanyName: rst.M_CompanyName }])
|
||||
context.commit("update_price", rst.settingPriceDefault)
|
||||
// { "M_LocationID": "4", "M_LocationT_SampleStationID": "5", "M_LocationName": "R.106 - ECG" }
|
||||
context.commit("update_selectedLocation", { M_LocationID: rst.settingM_LocationID, M_LocationT_SampleStationID: rst.settingT_SampleStationID, M_LocationName: rst.M_LocationName })
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_error", e.message)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user