Flatten nested repos
This commit is contained in:
568
test/vuex/cpone-sample-to-branch/modules/patient.js
Normal file
568
test/vuex/cpone-sample-to-branch/modules/patient.js
Normal file
@@ -0,0 +1,568 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/price.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
lastidx: 0,
|
||||
lookup_status: 0,
|
||||
lookup_error_message: '',
|
||||
search_patient: 0,
|
||||
search_error_message: '',
|
||||
start_date: moment(new Date()).format('YYYY-MM-DD'),
|
||||
end_date: moment(new Date()).format('YYYY-MM-DD'),
|
||||
search: '',
|
||||
total_patiens: 0,
|
||||
total_filter_patiens: 0,
|
||||
total_patients_all: 0,
|
||||
patients: [],
|
||||
total_patient: 0,
|
||||
selected_patient: { totalbill: 0 },
|
||||
save_error_message: '',
|
||||
statuses: [{ name: 'Belum Lunas', value: 'N' }, { name: 'Lunas', value: 'Y' }, { name: 'Semua', value: 'A' }],
|
||||
selected_status: { name: 'Belum Lunas', value: 'N' },
|
||||
open_alert_no_pay: false,
|
||||
msg_alert_no_pay: "Loh ... Gak jadi bayar dong ?",
|
||||
current_page: 1,
|
||||
total_page: 0,
|
||||
filters: [{ id: 'day', name: 'Hari ini' }, { id: 'notsampled', name: 'Belum sampling' }, { id: 'all', name: 'Tampilkan semua' }],
|
||||
selected_filter: { id: 'day', name: 'Hari ini' },
|
||||
promise_dialog: false,
|
||||
promises: [],
|
||||
errors: [],
|
||||
save_status: 0,
|
||||
save_error_message: '',
|
||||
barcodes: [],
|
||||
dialog_barcode: false,
|
||||
autocomplete_status: 0,
|
||||
companies: [],
|
||||
selected_company: { id: 0, name: 'Semua' },
|
||||
doctors: [],
|
||||
selected_doctor: { id: 0, name: 'Semua' },
|
||||
dialog_timeline_delivery: false,
|
||||
timeline_delivery: [],
|
||||
dialog_update_dob: false,
|
||||
show_form_dob: 'N',
|
||||
data_patient: {},
|
||||
alert_success: false,
|
||||
msg_success: "",
|
||||
filter_tests: [],
|
||||
selected_filter_test: {},
|
||||
dialogQrCode: false,
|
||||
urlQrCode: '',
|
||||
selected_branch:{},
|
||||
branchs:[],
|
||||
sample_staffs:[],
|
||||
selected_staff_sample:{},
|
||||
courier_staffs:[],
|
||||
selected_staff_courier:{},
|
||||
errors:[],
|
||||
pgrs_save:false,
|
||||
selected_setup:{},
|
||||
setups:[]
|
||||
|
||||
},
|
||||
mutations: {
|
||||
update_selected_setup(state, val) {
|
||||
state.selected_setup = val
|
||||
},
|
||||
update_setups(state, val) {
|
||||
state.setups = val
|
||||
},
|
||||
update_pgrs_save(state, val) {
|
||||
state.update_pgrs_save = val
|
||||
},
|
||||
update_errors(state, val) {
|
||||
state.errors = val
|
||||
},
|
||||
update_selected_staff_courier(state, val) {
|
||||
state.selected_staff_courier = val
|
||||
},
|
||||
update_courier_staffs(state, val) {
|
||||
state.courier_staffs = val
|
||||
},
|
||||
update_selected_staff_sample(state, val) {
|
||||
state.selected_staff_sample = val
|
||||
},
|
||||
update_sample_staffs(state, val) {
|
||||
state.sample_staffs = val
|
||||
},
|
||||
update_branchs(state, val) {
|
||||
state.branchs = val
|
||||
},
|
||||
update_selected_branch(state, val) {
|
||||
state.selected_branch = val
|
||||
},
|
||||
update_filter_tests(state, val) {
|
||||
state.filter_tests = val
|
||||
},
|
||||
update_selected_filter_test(state, val) {
|
||||
state.selected_filter_test = val
|
||||
},
|
||||
update_alert_success(state, val) {
|
||||
state.alert_success = val
|
||||
},
|
||||
update_msg_success(state, val) {
|
||||
state.msg_success = val
|
||||
},
|
||||
update_data_patient(state, val) {
|
||||
state.data_patient = val
|
||||
},
|
||||
update_show_form_dob(state, val) {
|
||||
state.show_form_dob = val
|
||||
},
|
||||
update_dialog_update_dob(state, val) {
|
||||
state.dialog_update_dob = val
|
||||
},
|
||||
update_timeline_delivery(state, val) {
|
||||
state.timeline_delivery = val
|
||||
},
|
||||
update_dialog_timeline_delivery(state, val) {
|
||||
state.dialog_timeline_delivery = val
|
||||
},
|
||||
update_companies(state, val) {
|
||||
state.companies = val
|
||||
},
|
||||
update_selected_company(state, val) {
|
||||
state.selected_company = val
|
||||
},
|
||||
update_doctors(state, val) {
|
||||
state.doctors = val
|
||||
},
|
||||
update_selected_doctor(state, val) {
|
||||
state.selected_doctor = val
|
||||
},
|
||||
update_dialog_barcode(state, val) {
|
||||
state.dialog_barcode = val
|
||||
},
|
||||
update_barcodes(state, val) {
|
||||
state.barcodes = val
|
||||
},
|
||||
update_total_patients_all(state, val) {
|
||||
state.total_patients_all = val
|
||||
},
|
||||
update_save_status(state, val) {
|
||||
state.save_status = val
|
||||
},
|
||||
update_save_error_message(state, val) {
|
||||
state.save_error_message = val
|
||||
},
|
||||
update_lookup_error_message(state, val) {
|
||||
state.lookup_error_message = val
|
||||
},
|
||||
update_lookup_status(state, status) {
|
||||
state.lookup_status = status
|
||||
},
|
||||
update_promise_dialog(state, val) {
|
||||
state.promise_dialog = val
|
||||
},
|
||||
update_promises(state, val) {
|
||||
state.promises = val
|
||||
},
|
||||
update_errors(state, val) {
|
||||
state.errors = val
|
||||
},
|
||||
update_lastidx(state, val) {
|
||||
state.lastidx = val
|
||||
},
|
||||
update_selected_filter(state, val) {
|
||||
state.selected_filter = val
|
||||
},
|
||||
update_filters(state, val) {
|
||||
state.filters = val
|
||||
},
|
||||
update_total_page(state, val) {
|
||||
state.total_page = val
|
||||
},
|
||||
update_total_patient(state, val) {
|
||||
state.total_patient = val
|
||||
},
|
||||
update_current_page(state, val) {
|
||||
state.current_page = val
|
||||
},
|
||||
update_search_error_message(state, patient) {
|
||||
state.search_error_message = patient
|
||||
},
|
||||
update_search_patient(state, patient) {
|
||||
state.search_patient = patient
|
||||
},
|
||||
update_patients(state, data) {
|
||||
state.patients = data.records
|
||||
state.total_patient = data.total
|
||||
state.total_page = data.total
|
||||
state.total_patients = data.total
|
||||
state.total_filter_patients = data.total_filter
|
||||
},
|
||||
update_selected_patient(state, val) {
|
||||
state.selected_patient = val
|
||||
},
|
||||
update_start_date(state, val) {
|
||||
state.start_date = val
|
||||
},
|
||||
update_autocomplete_status(state, val) {
|
||||
state.autocomplete_status = val
|
||||
},
|
||||
update_end_date(state, val) {
|
||||
state.end_date = val
|
||||
},
|
||||
update_search(state, val) {
|
||||
state.search = val
|
||||
},
|
||||
update_selected_status(state, val) {
|
||||
state.selected_status = val
|
||||
},
|
||||
update_open_alert_no_pay(state, val) {
|
||||
state.open_alert_no_pay = val
|
||||
},
|
||||
update_msg_alert_no_pay(state, val) {
|
||||
state.msg_alert_no_pay = val
|
||||
},
|
||||
update_dialogQrCode(state, val) {
|
||||
state.dialogQrCode = val
|
||||
},
|
||||
update_urlQrCode(state, val) {
|
||||
state.urlQrCode = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context, prm) {
|
||||
context.commit("update_search_patient", 1)
|
||||
try {
|
||||
console.log(prm)
|
||||
prm.token = one_token()
|
||||
let data = {
|
||||
records: [],
|
||||
total: 0,
|
||||
total_filter: 0
|
||||
}
|
||||
context.commit("update_patients", data)
|
||||
let resp = await api.search(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_patient", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_patient", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total,
|
||||
total_filter: resp.data.total_filter
|
||||
}
|
||||
console.log("")
|
||||
console.log(data.records)
|
||||
context.commit("update_patients", data)
|
||||
context.commit("update_total_page", data.total)
|
||||
context.commit("update_total_patients_all", resp.data.total_all)
|
||||
|
||||
if (prm.lastidx === -1) {
|
||||
context.commit("update_selected_patient", data.records[0])
|
||||
if (!_.isEmpty(data.records[0]))
|
||||
context.commit("payment/update_notes", data.records[0].notes, { root: true })
|
||||
else
|
||||
context.commit("payment/update_notes", [], { root: true })
|
||||
}
|
||||
else {
|
||||
context.commit("update_selected_patient", data.records[prm.lastidx])
|
||||
context.commit("payment/update_notes", data.records[prm.lastidx].notes, { root: true })
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_patient", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
async lookup_promises(context, prm) {
|
||||
context.commit("update_lookup_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.lookup_promises(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_status", 3)
|
||||
context.commit("update_lookup_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_status", 2)
|
||||
context.commit("update_lookup_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_promises", data.records)
|
||||
context.commit("update_promise_dialog", true)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_lookup_status", 3)
|
||||
context.commit("update_lookup_error_message", e.message)
|
||||
}
|
||||
},
|
||||
async getdatabarcodes(context, prm) {
|
||||
context.commit("update_lookup_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.getdatabarcodes(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_status", 3)
|
||||
context.commit("update_lookup_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_status", 2)
|
||||
context.commit("update_lookup_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_barcodes", data.records)
|
||||
context.commit("update_dialog_barcode", true)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_lookup_status", 3)
|
||||
context.commit("update_lookup_error_message", e.message)
|
||||
}
|
||||
},
|
||||
async getdatadob(context, prm) {
|
||||
context.commit("update_lookup_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.getdatadob(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_status", 3)
|
||||
context.commit("update_lookup_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_status", 2)
|
||||
context.commit("update_lookup_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_data_patient", data.records)
|
||||
context.commit("update_show_form_dob", resp.data.status)
|
||||
context.commit("update_dialog_update_dob", true)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_lookup_status", 3)
|
||||
context.commit("update_lookup_error_message", e.message)
|
||||
}
|
||||
},
|
||||
async gettimelinedelivery(context, prm) {
|
||||
context.commit("update_lookup_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.gettimelinedelivery(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_status", 3)
|
||||
context.commit("update_lookup_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_status", 2)
|
||||
context.commit("update_lookup_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
|
||||
context.commit("update_timeline_delivery", data.records)
|
||||
context.commit("update_dialog_timeline_delivery", true)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_lookup_status", 3)
|
||||
context.commit("update_lookup_error_message", e.message)
|
||||
}
|
||||
},
|
||||
async savepromises(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.save_promises(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", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_promises", data.records)
|
||||
context.commit("update_promise_dialog", false)
|
||||
var xsearch = prm.search
|
||||
|
||||
context.dispatch("search", xsearch)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3)
|
||||
context.commit("update_save_error_message", e.message)
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
async searchcompany(context, prm) {
|
||||
context.commit("update_autocomplete_status", 1)
|
||||
try {
|
||||
let resp = await api.searchcompany(one_token(), prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
} else {
|
||||
context.commit("update_autocomplete_status", 2)
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_companies", resp.data.records)
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
}
|
||||
},
|
||||
async searchdoctor(context, prm) {
|
||||
context.commit("update_autocomplete_status", 1)
|
||||
try {
|
||||
let resp = await api.searchdoctor(one_token(), prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
} else {
|
||||
context.commit("update_autocomplete_status", 2)
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_doctors", resp.data.records)
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
}
|
||||
},
|
||||
async searchtest(context, prm) {
|
||||
context.commit("update_autocomplete_status", 1)
|
||||
try {
|
||||
let resp = await api.searchtest(one_token(), prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
} else {
|
||||
context.commit("update_autocomplete_status", 2)
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_filter_tests", resp.data.records)
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
}
|
||||
},
|
||||
async searchstaffsample(context, prm) {
|
||||
context.commit("update_autocomplete_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.searchstaffs(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
} else {
|
||||
context.commit("update_autocomplete_status", 2)
|
||||
context.commit("update_sample_staffs", resp.data.records)
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
}
|
||||
},
|
||||
|
||||
async searchstaffcourier(context, prm) {
|
||||
context.commit("update_autocomplete_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
prm.staff_sample = context.state.selected_staff_sample
|
||||
let resp = await api.searchstaffs(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
} else {
|
||||
context.commit("update_autocomplete_status", 2)
|
||||
context.commit("update_courier_staffs", resp.data.records)
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
}
|
||||
},
|
||||
async getsetups(context,prm) {
|
||||
context.commit("update_autocomplete_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.getsetups(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
} else {
|
||||
context.commit("update_autocomplete_status", 2)
|
||||
context.commit("update_setups", resp.data.records)
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
}
|
||||
},
|
||||
async getbranchs(context) {
|
||||
context.commit("update_autocomplete_status", 1)
|
||||
try {
|
||||
let prm = {}
|
||||
prm.token = one_token()
|
||||
let resp = await api.getbranchs(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
} else {
|
||||
context.commit("update_autocomplete_status", 2)
|
||||
context.commit("update_branchs", resp.data.records)
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
}
|
||||
},
|
||||
async updatedob(context, prm) {
|
||||
context.commit("update_autocomplete_status", 1)
|
||||
try {
|
||||
prm.orderid = context.state.selected_patient.T_OrderHeaderID
|
||||
prm.token = one_token()
|
||||
let resp = await api.updatedob(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
} else {
|
||||
context.commit("update_autocomplete_status", 2)
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_dialog_update_dob", false)
|
||||
var msg = "Terima kasih telah meng-update tanggal lahir, jadi gak bingung dong kalo mau ultah"
|
||||
if (prm.status === 'Y') {
|
||||
msg = "Terima kasih, Mimin akan melanjutkan request ini ke bagian proses"
|
||||
}
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_alert_success", true)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
}
|
||||
},
|
||||
|
||||
async saveheader(context, prm) {
|
||||
//context.commit("update_autocomplete_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.saveheader(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_pgrs_save", false)
|
||||
} else {
|
||||
context.commit("update_pgrs_save", false)
|
||||
//context.commit("update_sample_staffs", resp.data.records)
|
||||
context.commit("price/update_dialogPriceHeader", false,{root:true})
|
||||
context.dispatch("price/searchHeader",{},{root:true})
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_pgrs_save", false)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
149
test/vuex/cpone-sample-to-branch/modules/payment.js
Normal file
149
test/vuex/cpone-sample-to-branch/modules/payment.js
Normal file
@@ -0,0 +1,149 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/payment.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
lookup_status:0,
|
||||
lookup_error_message:'',
|
||||
types: [],
|
||||
total_payment:0,
|
||||
reload_after_save: false,
|
||||
dialog_pay_success:false,
|
||||
paynumber :'',
|
||||
notes :[],
|
||||
dialog_delete:false,
|
||||
msg_delete:'',
|
||||
note_delete:'',
|
||||
nota_delete:{},
|
||||
open_print_note:false,
|
||||
idx:0,
|
||||
last_payments:{}
|
||||
},
|
||||
mutations: {
|
||||
update_lookup_error_message(state,val) {
|
||||
state.lookup_error_message = val
|
||||
},
|
||||
update_lookup_status(state,status) {
|
||||
state.lookup_status = status
|
||||
},
|
||||
update_types(state,data) {
|
||||
state.types = data.records
|
||||
state.total_type = data.total
|
||||
},
|
||||
update_selected_status(state,val) {
|
||||
state.selected_status=val
|
||||
},
|
||||
update_total_payment(state,val) {
|
||||
state.total_payment=val
|
||||
},
|
||||
update_reload_after_save(state,val) {
|
||||
state.reload_after_save=val
|
||||
},
|
||||
update_dialog_pay_success(state,val) {
|
||||
state.dialog_pay_success=val
|
||||
},
|
||||
update_paynumber(state,val) {
|
||||
state.paynumber=val
|
||||
},
|
||||
update_notes(state,val) {
|
||||
state.notes=val
|
||||
},
|
||||
update_dialog_delete(state,val) {
|
||||
state.dialog_delete=val
|
||||
},
|
||||
update_note_delete(state,val) {
|
||||
state.note_delete=val
|
||||
},
|
||||
update_msg_delete(state,val) {
|
||||
state.msg_delete=val
|
||||
},
|
||||
update_nota_delete(state,val) {
|
||||
state.nota_delete=val
|
||||
},
|
||||
update_open_print_note(state,val) {
|
||||
state.open_print_note=val
|
||||
},
|
||||
update_idx(state,val) {
|
||||
state.idx=val
|
||||
},
|
||||
update_last_payments(state,val) {
|
||||
state.last_payments=val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async lookup_type(context) {
|
||||
context.commit("update_lookup_status",1)
|
||||
try {
|
||||
let resp= await api.lookup_type(one_token())
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_status",3)
|
||||
context.commit("update_lookup_error_message",resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_status",2)
|
||||
context.commit("update_lookup_error_message","")
|
||||
let data = {
|
||||
records : resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_types",data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_lookup_status",3)
|
||||
context.commit("update_lookup_error_message",e.message )
|
||||
}
|
||||
},
|
||||
async pay(context,prm) {
|
||||
context.commit("update_lookup_status",1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp= await api.pay(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_status",3)
|
||||
context.commit("update_lookup_error_message",resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_status",2)
|
||||
context.commit("update_lookup_error_message","")
|
||||
let data = {
|
||||
records : resp.data.records.types,
|
||||
total: resp.data.total
|
||||
}
|
||||
let xnumber = resp.data.records.data.numberx
|
||||
let id = resp.data.records.data.idx
|
||||
context.commit("update_types",data)
|
||||
context.commit("update_last_payments",prm.payments)
|
||||
context.commit("update_idx",id)
|
||||
context.commit("update_total_payment",0)
|
||||
context.commit("update_paynumber","Pembayaran nomor <span style='color:red'>"+xnumber+"</span> telah berhasil")
|
||||
context.commit("update_dialog_pay_success",true)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_lookup_status",3)
|
||||
context.commit("update_lookup_error_message",e.message )
|
||||
}
|
||||
},
|
||||
async delete_note(context,prm) {
|
||||
context.commit("update_lookup_status",1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp= await api.delete_note(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_status",3)
|
||||
context.commit("update_lookup_error_message",resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_status",2)
|
||||
context.commit("update_lookup_error_message","")
|
||||
let xmsg = "Nota nomor <span style='color:red'>"+prm.nota.note_number+"</span> telah dihapus"
|
||||
context.commit("update_msg_delete",xmsg)
|
||||
context.commit("update_note_delete",'')
|
||||
context.commit("update_nota_delete",{})
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_lookup_status",3)
|
||||
context.commit("update_lookup_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
357
test/vuex/cpone-sample-to-branch/modules/price.js
Normal file
357
test/vuex/cpone-sample-to-branch/modules/price.js
Normal file
@@ -0,0 +1,357 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/price.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
lookup_status: 0,
|
||||
searchPrice: "",
|
||||
priceHeaderList: [],
|
||||
loading: false,
|
||||
page: 1,
|
||||
totalPageHeader: 0,
|
||||
errorMsg: '',
|
||||
snackbarSuccess: false,
|
||||
snackbarError: false,
|
||||
successMsg: '',
|
||||
selectedPriceHeader: {
|
||||
"headerID": "0",
|
||||
"headerName": "",
|
||||
"headerStartDate": "",
|
||||
"headerEndDate": "",
|
||||
"headerCode": "CODE"
|
||||
},
|
||||
dialogPriceHeader: false,
|
||||
dialogDeleteHeader: false,
|
||||
startDateHeader: moment(new Date()).format('YYYY-MM-DD'),
|
||||
endDateHeader: moment(new Date()).format('YYYY-MM-DD'),
|
||||
nameHeader: "",
|
||||
filterName: "",
|
||||
filterSubGroup: [],
|
||||
filterStatus: [],
|
||||
selectedFilterSubGroup: {
|
||||
"id": "0",
|
||||
'name': 'Semua'
|
||||
},
|
||||
selectedFilterStatus: {
|
||||
"id": "A",
|
||||
'name': 'Semua'
|
||||
},
|
||||
priceTestList: [],
|
||||
priceTestPageTotal: 0,
|
||||
priceTestPage: 1,
|
||||
isLoading:false
|
||||
},
|
||||
mutations: {
|
||||
update_isLoading(state, val) {
|
||||
state.isLoading = val
|
||||
},
|
||||
update_lookup_status(state, val) {
|
||||
state.lookup_status = val
|
||||
},
|
||||
update_searchPrice(state, val) {
|
||||
state.searchPrice = val
|
||||
},
|
||||
update_priceHeaderList(state, val) {
|
||||
state.priceHeaderList = val
|
||||
},
|
||||
update_loading(state, val) {
|
||||
state.loading = val
|
||||
},
|
||||
update_page(state, val) {
|
||||
state.page = val
|
||||
},
|
||||
update_totalPageHeader(state, val) {
|
||||
state.totalPageHeader = val
|
||||
},
|
||||
update_errorMsg(state, val) {
|
||||
state.errorMsg = val
|
||||
},
|
||||
update_snackbarSuccess(state, val) {
|
||||
state.snackbarSuccess = val
|
||||
},
|
||||
update_snackbarError(state, val) {
|
||||
state.snackbarError = val
|
||||
},
|
||||
update_successMsg(state, val) {
|
||||
state.successMsg = val
|
||||
},
|
||||
update_selectedPriceHeader(state, val) {
|
||||
state.selectedPriceHeader = val
|
||||
},
|
||||
update_dialogPriceHeader(state, val) {
|
||||
state.dialogPriceHeader = val
|
||||
},
|
||||
update_startDateHeader(state, val) {
|
||||
state.startDateHeader = val
|
||||
},
|
||||
update_endDateHeader(state, val) {
|
||||
state.endDateHeader = val
|
||||
},
|
||||
update_nameHeader(state, val) {
|
||||
state.nameHeader = val
|
||||
},
|
||||
update_dialogDeleteHeader(state, val) {
|
||||
state.dialogDeleteHeader = val
|
||||
},
|
||||
update_filterName(state, val) {
|
||||
state.filterName = val
|
||||
},
|
||||
update_filterStatus(state, val) {
|
||||
state.filterStatus = val
|
||||
},
|
||||
update_filterSubGroup(state, val) {
|
||||
state.filterSubGroup = val
|
||||
},
|
||||
update_selectedFilterStatus(state, val) {
|
||||
state.selectedFilterStatus = val
|
||||
},
|
||||
update_selectedFilterSubGroup(state, val) {
|
||||
state.selectedFilterSubGroup = val
|
||||
},
|
||||
update_priceTestList(state, val) {
|
||||
state.priceTestList = val
|
||||
},
|
||||
update_priceTestPageTotal(state, val) {
|
||||
state.priceTestPageTotal = val
|
||||
},
|
||||
update_priceTestPage(state, val) {
|
||||
state.priceTestPage = val
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
async searchHeader(context,xprm) {
|
||||
context.commit("update_lookup_status", 1)
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
let prm = {
|
||||
token: one_token(),
|
||||
page: context.state.page,
|
||||
date: context.state.endDateHeader
|
||||
}
|
||||
let resp = await api.search(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_status", 3)
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_errorMsg", resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_status", 2)
|
||||
context.commit("update_errorMsg", '')
|
||||
context.commit("update_loading", false)
|
||||
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_priceHeaderList", resp.data.records)
|
||||
context.commit("update_priceTestList", []);
|
||||
if(context.state.page === 1){
|
||||
context.commit("update_selectedPriceHeader", resp.data.records[0])
|
||||
context.dispatch("searchpricetest")
|
||||
|
||||
}
|
||||
|
||||
context.commit("update_totalPageHeader", resp.data.total)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
context.commit("update_lookup_status", 3)
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_errorMsg", e)
|
||||
}
|
||||
},
|
||||
async insertPriceHeader(context) {
|
||||
context.commit("update_lookup_status", 1)
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
let prm = {
|
||||
token: one_token(),
|
||||
name: context.state.nameHeader,
|
||||
sd: context.state.startDateHeader,
|
||||
ed: context.state.endDateHeader
|
||||
}
|
||||
let resp = await api.insertheader(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_status", 3)
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_snackbarError", true)
|
||||
context.commit("update_errorMsg", resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_status", 2)
|
||||
context.commit("update_errorMsg", '')
|
||||
context.commit("update_successMsg", 'Berhasil Membuat Harga ' + context.state.nameHeader)
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_snackbarSuccess", true)
|
||||
context.commit("update_dialogPriceHeader", false)
|
||||
context.commit("update_nameHeader", '')
|
||||
context.dispatch("searchPriceHeader")
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
context.commit("update_lookup_status", 3)
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_snackbarError", true)
|
||||
context.commit("update_errorMsg", e)
|
||||
}
|
||||
},
|
||||
async editPriceHeader(context) {
|
||||
context.commit("update_lookup_status", 1)
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
let prm = {
|
||||
id: context.state.selectedPriceHeader.headerID,
|
||||
token: one_token(),
|
||||
name: context.state.nameHeader,
|
||||
sd: context.state.startDateHeader,
|
||||
ed: context.state.endDateHeader
|
||||
}
|
||||
let resp = await api.editheader(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_status", 3)
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_snackbarError", true)
|
||||
context.commit("update_errorMsg", resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_status", 2)
|
||||
context.commit("update_errorMsg", '')
|
||||
context.commit("update_successMsg", 'Berhasil Edit Harga ' + context.state.nameHeader)
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_snackbarSuccess", true)
|
||||
context.commit("update_dialogPriceHeader", false)
|
||||
context.commit("update_nameHeader", '')
|
||||
context.dispatch("searchPriceHeader")
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
context.commit("update_lookup_status", 3)
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_snackbarError", true)
|
||||
context.commit("update_errorMsg", e)
|
||||
}
|
||||
},
|
||||
async deletePriceHeader(context) {
|
||||
context.commit("update_lookup_status", 1)
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
let prm = {
|
||||
id: context.state.selectedPriceHeader.headerID,
|
||||
token: one_token(),
|
||||
}
|
||||
let resp = await api.deleteheader(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_status", 3)
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_snackbarError", true)
|
||||
context.commit("update_errorMsg", resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_status", 2)
|
||||
context.commit("update_errorMsg", '')
|
||||
context.commit("update_successMsg", 'Berhasil Hapus Harga ' + context.state.nameHeader)
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_snackbarSuccess", true)
|
||||
context.commit("update_dialogDeleteHeader", false)
|
||||
context.commit("update_nameHeader", '')
|
||||
context.commit("update_priceTestList", [])
|
||||
context.dispatch("searchHeader")
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
context.commit("update_lookup_status", 3)
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_snackbarError", true)
|
||||
context.commit("update_errorMsg", e)
|
||||
}
|
||||
},
|
||||
async getpricefilter(context) {
|
||||
context.commit("update_lookup_status", 1)
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
let prm = {
|
||||
token: one_token(),
|
||||
}
|
||||
let resp = await api.getfilterprice(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_status", 3)
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_errorMsg", resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_status", 2)
|
||||
context.commit("update_errorMsg", '')
|
||||
context.commit("update_loading", false)
|
||||
|
||||
|
||||
context.commit("update_filterStatus", resp.data.status)
|
||||
context.commit("update_filterSubGroup", resp.data.subgroup)
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
context.commit("update_lookup_status", 3)
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_errorMsg", e)
|
||||
}
|
||||
},
|
||||
async searchpricetest(context) {
|
||||
context.commit("update_lookup_status", 1)
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
let prm = {
|
||||
token: one_token(),
|
||||
search: context.state.filterName,
|
||||
mgm_mcuid:context.state.selectedPriceHeader?context.state.selectedPriceHeader.mgm_mcuid:0,
|
||||
//subgroup: context.state.selectedFilterSubGroup.id,
|
||||
//status: context.state.selectedFilterStatus.id,
|
||||
headerid: context.state.selectedPriceHeader?context.state.selectedPriceHeader.headerID:0,
|
||||
page: context.state.priceTestPage,
|
||||
}
|
||||
let resp = await api.searchpricetest(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_status", 3)
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_errorMsg", resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_status", 2)
|
||||
context.commit("update_errorMsg", '')
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_priceTestList", resp.data.records)
|
||||
context.commit("update_priceTestPageTotal", resp.data.total)
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
context.commit("update_lookup_status", 3)
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_errorMsg", e)
|
||||
}
|
||||
},
|
||||
async checksample(context,prm) {
|
||||
context.commit("update_lookup_status", 1)
|
||||
context.commit("update_loading", true)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
prm.headerid = context.state.selectedPriceHeader.headerID
|
||||
let resp = await api.checksample(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_status", 3)
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_snackbarError", true)
|
||||
context.commit("update_errorMsg", resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_status", 2)
|
||||
context.commit("update_errorMsg", '')
|
||||
context.commit("update_successMsg", 'Barcode '+resp.data.records.barcode+' dimasukkan keranjang')
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_snackbarSuccess", true)
|
||||
context.dispatch("searchpricetest")
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
context.commit("update_lookup_status", 3)
|
||||
context.commit("update_loading", false)
|
||||
context.commit("update_snackbarError", true)
|
||||
context.commit("update_errorMsg", e)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user