46 lines
1.3 KiB
JavaScript
46 lines
1.3 KiB
JavaScript
import * as api from "../api/company.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
loading: false,
|
|
error: '',
|
|
companies: [],
|
|
company: {M_CompanyID : 0 , M_CompanyName : 'Semua Kel Pelanggan'}
|
|
},
|
|
mutations: {
|
|
update_loading(state, val) {
|
|
state.loading= val
|
|
},
|
|
update_companies(state, val) {
|
|
state.companies= val
|
|
},
|
|
update_error(state, val) {
|
|
state.error= val
|
|
},
|
|
update_company(state, val) {
|
|
state.company= val
|
|
},
|
|
},
|
|
actions: {
|
|
async search(context, prm) {
|
|
context.commit("update_loading", 1)
|
|
try {
|
|
let resp = await api.search(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_loading", 3)
|
|
context.commit("update_error", resp.message)
|
|
} else {
|
|
context.commit("update_loading", 2)
|
|
context.commit("update_error", "")
|
|
context.commit("update_companies", resp.data.data)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_loading", 3)
|
|
context.commit("update_error", e.message)
|
|
}
|
|
}
|
|
}
|
|
}
|