Flatten nested repos
This commit is contained in:
266
test/vuex/one-md-nat-unit---/modules/unit.js
Normal file
266
test/vuex/one-md-nat-unit---/modules/unit.js
Normal file
@@ -0,0 +1,266 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/unit.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
act: 'new',
|
||||
lookup_unit: 0,
|
||||
lookup_error_message: '',
|
||||
units: [],
|
||||
unitlangs: [],
|
||||
showunits: [],
|
||||
total_units: 0,
|
||||
total_filter_units: 0,
|
||||
selected_unit: {
|
||||
name: "[ Belum memilih Satuan ]"
|
||||
},
|
||||
save_status: 0,
|
||||
save_error_message: '',
|
||||
dialog_form_unit: false,
|
||||
dialog_edit_form_unit: false,
|
||||
alert_success: false,
|
||||
msg_success: "",
|
||||
show_all: 'N',
|
||||
errors: [],
|
||||
get_data_status: 0,
|
||||
get_data_error_message: '',
|
||||
autocomplete_status: 0,
|
||||
search_status: 0,
|
||||
current_page:1,
|
||||
x_search: ''
|
||||
},
|
||||
mutations: {
|
||||
update_x_search(state, val) {
|
||||
state.x_search = val
|
||||
},
|
||||
update_act(state, val) {
|
||||
state.act = val
|
||||
},
|
||||
update_errors(state, val) {
|
||||
state.errors = val
|
||||
},
|
||||
update_show_all(state, val) {
|
||||
state.show_all = val
|
||||
},
|
||||
update_lookup_error_message(state, status) {
|
||||
state.lookup_error_message = status
|
||||
},
|
||||
update_lookup_unit(state, status) {
|
||||
state.lookup_unit = status
|
||||
},
|
||||
update_units(state, data) {
|
||||
state.units = data.records
|
||||
state.total_units = data.total
|
||||
state.total_filter_units = data.total_filter
|
||||
},
|
||||
update_unitlangs(state, data) {
|
||||
state.unitlangs = data.records
|
||||
},
|
||||
update_showunits(state, data) {
|
||||
state.units = data.records
|
||||
},
|
||||
update_selected_unit(state, val) {
|
||||
state.selected_unit = val
|
||||
},
|
||||
update_save_status(state, val) {
|
||||
state.save_status = val
|
||||
},
|
||||
update_save_error_message(state, val) {
|
||||
state.save_error_message = val
|
||||
},
|
||||
update_dialog_form_unit(state, val) {
|
||||
state.dialog_form_unit = val
|
||||
},
|
||||
update_dialog_edit_form_unit(state, val) {
|
||||
state.dialog_edit_form_unit = val
|
||||
},
|
||||
update_alert_success(state, val) {
|
||||
state.alert_success = val
|
||||
},
|
||||
update_msg_success(state, val) {
|
||||
state.msg_success = 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
|
||||
},
|
||||
update_autocomplete_status(state, val) {
|
||||
state.autocomplete_status = val
|
||||
},
|
||||
update_current_page(state, val) {
|
||||
state.current_page = val
|
||||
}
|
||||
|
||||
},
|
||||
actions: {
|
||||
async lookup(context, prm) {
|
||||
context.commit("update_lookup_unit", 1)
|
||||
try {
|
||||
let resp = await api.lookup(one_token(), prm.search, prm.current_page)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_unit", 3)
|
||||
context.commit("update_lookup_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_unit", 2)
|
||||
context.commit("update_lookup_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total,
|
||||
total_filter: resp.data.total_filter
|
||||
}
|
||||
context.commit("update_units", data)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_lookup_unit", 3)
|
||||
context.commit("update_lookup_error_message", e.message)
|
||||
}
|
||||
},
|
||||
async save(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.save(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
var data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("update_errors", [])
|
||||
context.commit("update_alert_success", true)
|
||||
context.commit("update_dialog_form_unit", false)
|
||||
var msg = "Satuan " + prm.name + " sudah tersimpan dong ..."
|
||||
context.commit("update_msg_success", msg)
|
||||
context.dispatch("lookup", {
|
||||
search: prm.search,
|
||||
current_page: 1
|
||||
})
|
||||
} else {
|
||||
context.commit("update_errors", resp.data.errors)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_save_error_message", e.message)
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
async update(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.update(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("update_alert_success", true)
|
||||
context.commit("update_dialog_form_unit", false)
|
||||
var msg = "Satuan " + prm.name + " sudah terupdate dong ..."
|
||||
context.commit("update_msg_success", msg)
|
||||
context.dispatch("lookup", {
|
||||
search: prm.search,
|
||||
current_page: 1
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_save_error_message", e.message)
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
async delete(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
let resp = await api.xdelete(one_token(), prm.unitid)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
context.commit("update_alert_success", true)
|
||||
|
||||
var msg = "Schedule " + prm.unitname + " sudah dihapus dong"
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_alert_success", true)
|
||||
context.commit("update_selected_unit", {})
|
||||
context.dispatch("lookup", {
|
||||
search: prm.search,
|
||||
current_page: 1
|
||||
})
|
||||
context.commit("sampletype/update_unit_sampletype", [], {
|
||||
root: true
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3)
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
async saveunitlang(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.saveunitlang(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_save_status", 2)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
context.commit("update_save_error_message", resp.message)
|
||||
var data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("update_errors", [])
|
||||
context.commit("update_alert_success", true)
|
||||
context.commit("update_dialog_form_unit", false)
|
||||
var msg = "Satuan " + prm.unitname + " sudah tersimpan dong ..."
|
||||
context.commit("update_msg_success", msg)
|
||||
context.dispatch("lookup", {
|
||||
search: prm.search,
|
||||
current_page: 1
|
||||
})
|
||||
} else {
|
||||
context.commit("update_errors", resp.data.errors)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_save_error_message", e.message)
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
169
test/vuex/one-md-nat-unit---/modules/unitlang.js
Normal file
169
test/vuex/one-md-nat-unit---/modules/unitlang.js
Normal file
@@ -0,0 +1,169 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/unitlang.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
unitlangs: [],
|
||||
save_status: 0,
|
||||
save_error_message: '',
|
||||
dialog_form_unitlang: false,
|
||||
lookup_unitlang: 0,
|
||||
lookupunitlang: 0,
|
||||
errors:[],
|
||||
startdate:moment(new Date()).format('YYYY-MM-DD'),
|
||||
enddate:moment(new Date()).format('YYYY-MM-DD')
|
||||
},
|
||||
mutations: {
|
||||
update_errors(state, val) {
|
||||
state.errors = val
|
||||
},
|
||||
update_unitlangs(state, data) {
|
||||
state.unitlangs = data
|
||||
},
|
||||
update_save_status(state, val) {
|
||||
state.save_status = val
|
||||
},
|
||||
update_save_error_message(state, val) {
|
||||
state.save_error_message = val
|
||||
},
|
||||
update_dialog_form_unitlang(state, val) {
|
||||
state.dialog_form_unitlang = val
|
||||
},
|
||||
update_lookup_unitlang(state, val) {
|
||||
state.lookup_unitlang = val
|
||||
},
|
||||
update_lookupunitlang(state, val) {
|
||||
state.lookupunitlang = val
|
||||
},
|
||||
update_startdate(state,val){
|
||||
state.startdate = val
|
||||
},
|
||||
update_enddate(state,val){
|
||||
state.enddate = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async save(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.save(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("unit/update_save_status", 3, { root: true })
|
||||
context.commit("unit/update_save_error_message", resp.message, { root: true })
|
||||
} else {
|
||||
var data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
if(data.total !== -1){
|
||||
context.commit("unit/update_save_status", 2, { root: true })
|
||||
context.commit("unit/update_save_error_message", resp.message, { root: true })
|
||||
context.commit("unit/update_alert_success", true, { root: true })
|
||||
|
||||
context.commit("update_dialog_form_unitlang", false)
|
||||
var msg = "Bahan " + prm.unitname + " sudah update dong"
|
||||
context.commit("unit/update_msg_success", msg, { root: true })
|
||||
context.commit("unit/update_alert_success", true, { root: true })
|
||||
context.dispatch("lookup", {
|
||||
id: prm.unitid
|
||||
})
|
||||
}else{
|
||||
context.commit("update_errors", resp.data.errors)
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_save_error_message", e.message)
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
async lookup(context, prm) {
|
||||
context.commit("update_lookup_unitlang", 1)
|
||||
try {
|
||||
let resp = await api.lookup(one_token(),prm.id)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_unitlang", 3)
|
||||
} else {
|
||||
context.commit("update_lookup_unitlang", 2)
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_unitlangs", data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_lookup_unitlang", 3)
|
||||
}
|
||||
},
|
||||
async lookupunitlang(context, prm) {
|
||||
context.commit("update_lookupunitlang", 1)
|
||||
try {
|
||||
let resp = await api.lookupunitlang(one_token(),prm.id,prm.search, prm.current_page)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookupunitlang", 3)
|
||||
} else {
|
||||
context.commit("update_lookupunitlang", 2)
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total,
|
||||
total_filter: resp.data.total_filter
|
||||
}
|
||||
context.commit("unit/update_units", data, { root: true })
|
||||
// context.commit("unit/update_showunits", data, { root: true })
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_lookupunitlang", 3)
|
||||
}
|
||||
},
|
||||
async lookupunitlanghide(context, prm) {
|
||||
context.commit("update_lookupunitlang", 1)
|
||||
try {
|
||||
let resp = await api.lookupunitlanghide(one_token(),prm.id,prm.search, prm.current_page)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookupunitlang", 3)
|
||||
} else {
|
||||
context.commit("update_lookupunitlang", 2)
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total,
|
||||
total_filter: resp.data.total_filter
|
||||
}
|
||||
context.commit("unit/update_units", data, { root: true })
|
||||
// context.commit("unit/update_showunits", data, { root: true })
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_lookupunitlang", 3)
|
||||
}
|
||||
},
|
||||
async delete(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
let resp = await api.xdelete(one_token(),prm.xid)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("unit/update_save_status", 3, { root: true })
|
||||
context.commit("unit/update_save_error_message", resp.message, { root: true })
|
||||
} else {
|
||||
context.commit("unit/update_save_status", 2, { root: true })
|
||||
context.commit("unit/update_save_error_message", resp.message, { root: true })
|
||||
context.commit("unit/update_alert_success", true, { root: true })
|
||||
|
||||
//context.commit("update_dialog_form_schedule_promise", false)
|
||||
var msg = "Mou "+prm.name+" dari unit " + prm.unitname + " sudah dihapus dong"
|
||||
context.commit("unit/update_msg_success", msg, { root: true })
|
||||
context.commit("unit/update_alert_success", true, { root: true })
|
||||
context.dispatch("lookup", {
|
||||
id: prm.unitid
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_save_error_message", e.message)
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user