Flatten nested repos
This commit is contained in:
190
test/vuex/cpone-receive-sample/modules/receive.js
Normal file
190
test/vuex/cpone-receive-sample/modules/receive.js
Normal file
@@ -0,0 +1,190 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/receive.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
open_dialog_info:false,
|
||||
msg_info:'',
|
||||
search_transaction: 0,
|
||||
search_error_message: '',
|
||||
transactions:[],
|
||||
current_page:1,
|
||||
total_page: 0 ,
|
||||
no_save: 0,
|
||||
selected_transaction: {},
|
||||
search_status: 0,
|
||||
last_id:-1,
|
||||
spk_search:'',
|
||||
dialog_success: false,
|
||||
alert_success: false,
|
||||
open_alert_confirmation:false,
|
||||
dialog_confirmation: false,
|
||||
msg_confirmation: "",
|
||||
act:'new',
|
||||
transaction_date:moment(new Date()).format('YYYY-MM-DD'),
|
||||
msg_success: "",
|
||||
get_data: 0,
|
||||
samples: [],
|
||||
save_data: 0,
|
||||
dialog_error: false,
|
||||
msg_error:""
|
||||
},
|
||||
mutations: {
|
||||
update_open_dialog_info(state, val) {
|
||||
state.open_dialog_info = val
|
||||
},
|
||||
update_msg_info(state, val) {
|
||||
state.msg_info = val
|
||||
},
|
||||
update_search_transaction(state, val) {
|
||||
state.search_transaction = val
|
||||
},
|
||||
update_search_error_message(state, val) {
|
||||
state.search_error_message = val
|
||||
},
|
||||
update_transactions(state, data) {
|
||||
state.transactions = data
|
||||
},
|
||||
update_total_page(state, val) {
|
||||
state.total_page = val
|
||||
},
|
||||
update_current_page(state, val) {
|
||||
state.current_page = val
|
||||
},
|
||||
update_no_save(state, val) {
|
||||
state.no_save = val
|
||||
},
|
||||
update_selected_transaction(state, val) {
|
||||
state.selected_transaction = val
|
||||
},
|
||||
update_search_status(state, val) {
|
||||
state.search_status = val
|
||||
},
|
||||
update_last_id(state, val) {
|
||||
state.last_id = val
|
||||
},
|
||||
update_spk_search(state, val) {
|
||||
state.spk_search = val
|
||||
},
|
||||
update_dialog_success(state, val) {
|
||||
state.dialog_success = val
|
||||
},
|
||||
update_msg_success(state, val) {
|
||||
state.msg_success = val
|
||||
},
|
||||
update_alert_success(state, val) {
|
||||
state.alert_success = val
|
||||
},
|
||||
update_open_alert_confirmation(state, val) {
|
||||
state.open_alert_confirmation = val
|
||||
},
|
||||
update_dialog_confirmation(state, val) {
|
||||
state.dialog_confirmation = val
|
||||
},
|
||||
update_msg_confirmation(state, val) {
|
||||
state.msg_confirmation = val
|
||||
},
|
||||
update_act(state, val) {
|
||||
state.act = val
|
||||
},
|
||||
update_transaction_date(state, val) {
|
||||
state.transaction_date = val
|
||||
},
|
||||
update_get_data(state, val) {
|
||||
state.get_data = val
|
||||
},
|
||||
update_samples(state, val) {
|
||||
state.samples = val
|
||||
},
|
||||
update_save_data(state, val) {
|
||||
state.save_data = val
|
||||
},
|
||||
update_dialog_error(state, val) {
|
||||
state.dialog_error = val
|
||||
},
|
||||
update_update_msg_error(state, val) {
|
||||
state.msg_error = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context, prm) {
|
||||
context.commit("update_search_transaction", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.search(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_transaction", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_transaction", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_transactions", data.records)
|
||||
context.commit("update_total_page", data.total)
|
||||
context.commit("update_no_save", 0)
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_transaction", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
console.log('search',e)
|
||||
}
|
||||
},
|
||||
async getsample(context, prm) {
|
||||
context.commit("update_get_data", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.getsample(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_get_data", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_get_data", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_samples", data.records)
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_get_data", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
console.log('search',e)
|
||||
}
|
||||
},
|
||||
async saveConfirm(context, prm) {
|
||||
context.commit("update_save_data", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.saveConfirm(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_save_data", 3)
|
||||
context.commit("update_msg_error", resp.message)
|
||||
context.commit("update_dialog_error",true)
|
||||
} else {
|
||||
context.commit("update_save_data", 2)
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
var msg = "berhasil disimpan dong.."
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_dialog_success", true)
|
||||
context.commit("update_dialog_confirmation", false)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_data", 3)
|
||||
context.commit("update_msg_error", e.message)
|
||||
console.log('search',e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user