Flatten nested repos
This commit is contained in:
@@ -0,0 +1,786 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/deliveryorder.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
last_id: -1,
|
||||
act: 'new',
|
||||
lookup_deliveryorder: 0,
|
||||
lookup_error_message: '',
|
||||
deliveryorders: [],
|
||||
total_deliveryorders: 0,
|
||||
total_filter_deliveryorders: 0,
|
||||
startdate: moment(new Date()).format('DD-MM-YYYY'),
|
||||
selected_deliveryorder: {},
|
||||
save_status: 0,
|
||||
save_error_message: '',
|
||||
dialog_form_deliveryorder: false,
|
||||
dialog_edit_form_deliveryorder: false,
|
||||
alert_success: false,
|
||||
msg_success: "",
|
||||
show_all: 'N',
|
||||
errors: [],
|
||||
deliveryordertypes: [],
|
||||
deliveryordertype: {},
|
||||
branchs: [],
|
||||
branch: {},
|
||||
destinations: [],
|
||||
destination: {},
|
||||
samples: [],
|
||||
sample: {},
|
||||
couriers: [],
|
||||
courier: {},
|
||||
get_data_status: 0,
|
||||
get_data_error_message: '',
|
||||
cities: [],
|
||||
deliveryorderdetail_address: {},
|
||||
autocomplete_status: 0,
|
||||
search_status: 0,
|
||||
autocitys: [],
|
||||
autocity: {},
|
||||
autodistricts: [],
|
||||
autodistrict: {},
|
||||
autokelurahans: [],
|
||||
autokelurahan: {},
|
||||
nonlabs: [],
|
||||
selected_nonlab: {},
|
||||
current_page: 1,
|
||||
x_search: '',
|
||||
isexternal: 'N',
|
||||
init_date: moment().format("Y-M-D"),
|
||||
xcek: 0
|
||||
},
|
||||
mutations: {
|
||||
update_xcek(state, val) {
|
||||
state.xcek = val
|
||||
},
|
||||
update_init_date(state, val) {
|
||||
state.init_date = val
|
||||
},
|
||||
update_isexternal(state, val) {
|
||||
state.isexternal = val
|
||||
},
|
||||
update_x_search(state, val) {
|
||||
state.x_search = val
|
||||
},
|
||||
update_current_page(state, val) {
|
||||
state.current_page = val
|
||||
},
|
||||
update_last_id(state, val) {
|
||||
state.last_id = 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_startdate(state, val) {
|
||||
state.startdate = val
|
||||
},
|
||||
update_lookup_error_message(state, status) {
|
||||
state.lookup_error_message = status
|
||||
},
|
||||
update_lookup_deliveryorder(state, status) {
|
||||
state.lookup_deliveryorder = status
|
||||
},
|
||||
update_deliveryorders(state, data) {
|
||||
state.deliveryorders = data.records
|
||||
state.total_deliveryorders = data.total
|
||||
state.total_filter_deliveryorders = data.total_filter
|
||||
},
|
||||
update_selected_deliveryorder(state, val) {
|
||||
state.selected_deliveryorder = val
|
||||
},
|
||||
update_save_status(state, val) {
|
||||
state.save_status = val
|
||||
},
|
||||
update_save_error_message(state, val) {
|
||||
state.save_error_message = val
|
||||
},
|
||||
update_dialog_form_deliveryorder(state, val) {
|
||||
state.dialog_form_deliveryorder = val
|
||||
},
|
||||
update_dialog_edit_form_deliveryorder(state, val) {
|
||||
state.dialog_edit_form_deliveryorder = val
|
||||
},
|
||||
update_alert_success(state, val) {
|
||||
state.alert_success = val
|
||||
},
|
||||
update_msg_success(state, val) {
|
||||
state.msg_success = val
|
||||
},
|
||||
update_deliveryordertypes(state, data) {
|
||||
state.deliveryordertypes = data
|
||||
},
|
||||
update_deliveryordertype(state, val) {
|
||||
state.deliveryordertype = val
|
||||
},
|
||||
update_branchs(state, data) {
|
||||
state.branchs = data
|
||||
},
|
||||
update_branch(state, val) {
|
||||
state.branch = val
|
||||
},
|
||||
update_destinations(state, data) {
|
||||
state.destinations = data
|
||||
},
|
||||
update_destination(state, val) {
|
||||
state.destination = val
|
||||
},
|
||||
update_samples(state, data) {
|
||||
state.samples = data
|
||||
},
|
||||
update_sample(state, val) {
|
||||
state.sample = val
|
||||
},
|
||||
update_couriers(state, data) {
|
||||
state.couriers = data
|
||||
},
|
||||
update_courier(state, val) {
|
||||
state.courier = val
|
||||
},
|
||||
update_autocitys(state, data) {
|
||||
state.autocitys = data
|
||||
},
|
||||
update_autocity(state, val) {
|
||||
state.autocity = val
|
||||
},
|
||||
update_autodistricts(state, data) {
|
||||
state.autodistricts = data
|
||||
},
|
||||
update_autodistrict(state, val) {
|
||||
state.autodistrict = val
|
||||
},
|
||||
update_autokelurahans(state, data) {
|
||||
state.autokelurahans = data
|
||||
},
|
||||
update_autokelurahan(state, val) {
|
||||
state.autokelurahan = 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_cities(state, val) {
|
||||
state.cities = val
|
||||
},
|
||||
update_deliveryorderdetail_address(state, val) {
|
||||
state.deliveryorderdetail_address = val
|
||||
},
|
||||
update_autocomplete_status(state, val) {
|
||||
state.autocomplete_status = val
|
||||
},
|
||||
update_districts(state, val) {
|
||||
state.districts = val
|
||||
},
|
||||
update_district_address(state, val) {
|
||||
state.district_address = val
|
||||
},
|
||||
update_kelurahans(state, val) {
|
||||
state.kelurahans = val
|
||||
},
|
||||
update_kelurahan_address(state, val) {
|
||||
state.kelurahan_address = val
|
||||
},
|
||||
update_instruments(state, data) {
|
||||
state.instruments = data
|
||||
},
|
||||
update_instrument(state, val) {
|
||||
state.instrument = val
|
||||
},
|
||||
update_autotemplates(state, data) {
|
||||
state.autotemplates = data
|
||||
},
|
||||
update_autotemplate(state, val) {
|
||||
state.autotemplate = val
|
||||
},
|
||||
update_nonlabs(state, val) {
|
||||
state.nonlabs = val
|
||||
},
|
||||
update_selected_nonlab(state, val) {
|
||||
state.selected_nonlab = val
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
actions: {
|
||||
async lookup(context, prm) {
|
||||
context.commit("update_lookup_deliveryorder", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.lookup(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_deliveryorder", 3)
|
||||
context.commit("update_lookup_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_deliveryorder", 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_deliveryorders", data)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_lookup_deliveryorder", 3)
|
||||
context.commit("update_lookup_error_message", e.message)
|
||||
}
|
||||
},
|
||||
async lookupbydeliveryorderdetail(context, prm) {
|
||||
context.commit("update_lookup_deliveryorder", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.lookupbydeliveryorderdetail(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_deliveryorder", 3)
|
||||
context.commit("update_lookup_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_deliveryorder", 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_deliveryorders", data)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_lookup_deliveryorder", 3)
|
||||
context.commit("update_lookup_error_message", e.message)
|
||||
}
|
||||
},
|
||||
async lookupbydistrict(context, prm) {
|
||||
context.commit("update_lookup_deliveryorder", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.lookupbydistrict(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_deliveryorder", 3)
|
||||
context.commit("update_lookup_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_deliveryorder", 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_deliveryorders", data)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_lookup_deliveryorder", 3)
|
||||
context.commit("update_lookup_error_message", e.message)
|
||||
}
|
||||
},
|
||||
async lookupbykelurahan(context, prm) {
|
||||
context.commit("update_lookup_deliveryorder", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.lookupbykelurahan(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_deliveryorder", 3)
|
||||
context.commit("update_lookup_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_deliveryorder", 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_deliveryorders", data)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_lookup_deliveryorder", 3)
|
||||
context.commit("update_lookup_error_message", e.message)
|
||||
}
|
||||
},
|
||||
async lookupbyname(context, prm) {
|
||||
context.commit("update_lookup_deliveryorder", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.lookupbyname(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_deliveryorder", 3)
|
||||
context.commit("update_lookup_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_deliveryorder", 2)
|
||||
context.commit("update_lookup_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total,
|
||||
total_filter: resp.data.total_filter,
|
||||
branchid: resp.data.branchid,
|
||||
branchname: resp.data.branchname
|
||||
}
|
||||
context.commit("update_deliveryorders", data)
|
||||
console.log(data.branchname)
|
||||
context.commit("update_branchs", [{
|
||||
M_BranchID: data.branchid,
|
||||
M_BranchName: data.branchname
|
||||
}])
|
||||
context.commit("update_branch", {
|
||||
M_BranchID: data.branchid,
|
||||
M_BranchName: data.branchname
|
||||
})
|
||||
//context.dispatch("sample/selected", null,{ root: true })
|
||||
if (prm.lastid === -1) {
|
||||
context.commit("update_selected_deliveryorder", data.records[0])
|
||||
var pat = data.records[0]
|
||||
if(data.total !== 0){
|
||||
context.dispatch("sample/selected", {
|
||||
id: pat.id
|
||||
}, {
|
||||
root: true
|
||||
})
|
||||
context.commit("sample/update_couriers", [{
|
||||
M_CourierID: pat.M_CourierID,
|
||||
M_StaffName: pat.M_StaffName
|
||||
}], {
|
||||
root: true
|
||||
})
|
||||
context.commit("sample/update_courier", {
|
||||
M_CourierID: pat.M_CourierID,
|
||||
M_StaffName: pat.M_StaffName
|
||||
}, {
|
||||
root: true
|
||||
})
|
||||
}else{
|
||||
context.dispatch("sample/selected", {
|
||||
id: 0
|
||||
}, {
|
||||
root: true
|
||||
})
|
||||
context.commit("sample/update_couriers", [], {
|
||||
root: true
|
||||
})
|
||||
context.commit("sample/update_courier", {}, {
|
||||
root: true
|
||||
})
|
||||
}
|
||||
|
||||
} else {
|
||||
context.commit("update_selected_deliveryorder", data.records[prm.lastid])
|
||||
var pat = data.records[prm.lastid]
|
||||
if(data.total !== 0){
|
||||
context.dispatch("sample/selected", {
|
||||
id: pat.id
|
||||
}, {
|
||||
root: true
|
||||
})
|
||||
context.commit("sample/update_couriers", [{
|
||||
M_CourierID: pat.M_CourierID,
|
||||
M_StaffName: pat.M_StaffName
|
||||
}], {
|
||||
root: true
|
||||
})
|
||||
context.commit("sample/update_courier", {
|
||||
M_CourierID: pat.M_CourierID,
|
||||
M_StaffName: pat.M_StaffName
|
||||
}, {
|
||||
root: true
|
||||
})
|
||||
}else{
|
||||
context.dispatch("sample/selected", {
|
||||
id: 0
|
||||
}, {
|
||||
root: true
|
||||
})
|
||||
context.commit("sample/update_couriers", [], {
|
||||
root: true
|
||||
})
|
||||
context.commit("sample/update_courier", {}, {
|
||||
root: true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_lookup_deliveryorder", 3)
|
||||
context.commit("update_lookup_error_message", e.message)
|
||||
}
|
||||
},
|
||||
async lookupbybarcode(context, prm) {
|
||||
context.commit("update_lookup_deliveryorder", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.lookupbybarcode(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_deliveryorder", 3)
|
||||
context.commit("update_lookup_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_deliveryorder", 2)
|
||||
context.commit("update_lookup_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total,
|
||||
total_filter: resp.data.total_filter,
|
||||
branchid: resp.data.branchid,
|
||||
branchname: resp.data.branchname
|
||||
}
|
||||
console.log(data.branchname)
|
||||
context.commit("update_branchs", [{
|
||||
M_BranchID: data.branchid,
|
||||
M_BranchName: data.branchname
|
||||
}])
|
||||
context.commit("update_branch", {
|
||||
M_BranchID: data.branchid,
|
||||
M_BranchName: data.branchname
|
||||
})
|
||||
//context.dispatch("sample/selected", null,{ root: true })
|
||||
if (prm.lastid === -1) {
|
||||
context.commit("update_selected_deliveryorder", data.records[0])
|
||||
var pat = data.records[0]
|
||||
if(data.total !== 0){
|
||||
var cek = context.state.xcek
|
||||
console.log('cek di modules')
|
||||
console.log(cek)
|
||||
if(cek === 0){
|
||||
context.dispatch("sample/selectedbybarcode", {
|
||||
id: pat.id,
|
||||
barcode: prm.search,
|
||||
detail: prm.detail
|
||||
}, {
|
||||
root: true
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
context.commit("sample/update_couriers", [{
|
||||
M_CourierID: pat.M_CourierID,
|
||||
M_StaffName: pat.M_StaffName
|
||||
}], {
|
||||
root: true
|
||||
})
|
||||
context.commit("sample/update_courier", {
|
||||
M_CourierID: pat.M_CourierID,
|
||||
M_StaffName: pat.M_StaffName
|
||||
}, {
|
||||
root: true
|
||||
})
|
||||
}else{
|
||||
context.dispatch("sample/selected", {
|
||||
id: 0
|
||||
}, {
|
||||
root: true
|
||||
})
|
||||
context.commit("sample/update_couriers", [], {
|
||||
root: true
|
||||
})
|
||||
context.commit("sample/update_courier", {}, {
|
||||
root: true
|
||||
})
|
||||
}
|
||||
|
||||
} else {
|
||||
context.commit("update_selected_deliveryorder", data.records[prm.lastid])
|
||||
var pat = data.records[prm.lastid]
|
||||
if(data.total !== 0){
|
||||
context.dispatch("sample/selected", {
|
||||
id: pat.id,
|
||||
barcode: prm.search
|
||||
}, {
|
||||
root: true
|
||||
})
|
||||
context.commit("sample/update_couriers", [{
|
||||
M_CourierID: pat.M_CourierID,
|
||||
M_StaffName: pat.M_StaffName
|
||||
}], {
|
||||
root: true
|
||||
})
|
||||
context.commit("sample/update_courier", {
|
||||
M_CourierID: pat.M_CourierID,
|
||||
M_StaffName: pat.M_StaffName
|
||||
}, {
|
||||
root: true
|
||||
})
|
||||
}else{
|
||||
context.dispatch("sample/selected", {
|
||||
id: 0
|
||||
}, {
|
||||
root: true
|
||||
})
|
||||
context.commit("sample/update_couriers", [], {
|
||||
root: true
|
||||
})
|
||||
context.commit("sample/update_courier", {}, {
|
||||
root: true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_lookup_deliveryorder", 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)
|
||||
var data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("update_alert_success", true)
|
||||
context.commit("update_dialog_form_deliveryorder", false)
|
||||
var msg = " Surat Jalan sudah tersimpan dong ..."
|
||||
context.commit("update_msg_success", msg)
|
||||
context.dispatch("lookupbyname", {
|
||||
deliveryorder: prm.sdeliveryorder,
|
||||
current_page: 1,
|
||||
lastid: -1
|
||||
})
|
||||
// context.dispatch("sample/selected", null, { root: true })
|
||||
|
||||
} 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_deliveryorder", false)
|
||||
var msg = " Surat Jalan sudah terupdate dong ..."
|
||||
context.commit("update_msg_success", msg)
|
||||
// context.dispatch("sample/selected", null, { root: true })
|
||||
context.dispatch("lookupbyname", {
|
||||
deliveryorder: prm.sdeliveryorder,
|
||||
current_page: 1,
|
||||
lastid: -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 delete(context, prm) {
|
||||
context.commit("update_save_status", 1)
|
||||
try {
|
||||
let resp = await api.xdelete(one_token(), prm.deliveryorderid)
|
||||
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 = " Surat Jalan sudah dihapus dong"
|
||||
context.commit("update_msg_success", msg)
|
||||
context.commit("update_alert_success", true)
|
||||
context.commit("update_selected_deliveryorder", {})
|
||||
// context.dispatch("sample/selected", null, { root: true })
|
||||
context.dispatch("lookupbyname", {
|
||||
deliveryorder: prm.sdeliveryorder,
|
||||
current_page: 1,
|
||||
lastid: -1
|
||||
})
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_save_status", 3)
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
async searchdeliveryorderdetail(context, prm) {
|
||||
context.commit("update_autocomplete_status", 1)
|
||||
try {
|
||||
let resp = await api.searchdeliveryorderdetail(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_cities", resp.data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
}
|
||||
},
|
||||
async searchbranch(context, prm) {
|
||||
context.commit("update_autocomplete_status", 1)
|
||||
try {
|
||||
let resp = await api.searchbranch(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_branchs", resp.data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
}
|
||||
},
|
||||
async searchdestination(context, prm) {
|
||||
context.commit("update_autocomplete_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.searchdestination(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_destinations", resp.data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
}
|
||||
},
|
||||
async searchsample(context, prm) {
|
||||
context.commit("update_autocomplete_status", 1)
|
||||
try {
|
||||
let resp = await api.searchsample(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_samples", resp.data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
}
|
||||
},
|
||||
async searchcourier(context, prm) {
|
||||
context.commit("update_autocomplete_status", 1)
|
||||
try {
|
||||
let resp = await api.searchcourier(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_couriers", resp.data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
}
|
||||
},
|
||||
async searchcity(context, prm) {
|
||||
context.commit("update_autocomplete_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.searchcity(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_autocitys", resp.data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
}
|
||||
},
|
||||
async searchdistrict(context, prm) {
|
||||
context.commit("update_autocomplete_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.searchdistrict(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_autodistricts", resp.data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
}
|
||||
},
|
||||
async searchkelurahan(context, prm) {
|
||||
context.commit("update_autocomplete_status", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.searchkelurahan(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_autokelurahans", resp.data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_autocomplete_status", 3)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
295
test/vuex/one-process-ref-delivery-sample-v2/modules/sample.js
Normal file
295
test/vuex/one-process-ref-delivery-sample-v2/modules/sample.js
Normal file
@@ -0,0 +1,295 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/sample.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
samples: [],
|
||||
save_status: 0,
|
||||
save_error_message: '',
|
||||
dialog_form_sample: false,
|
||||
dialog_status_order: false,
|
||||
lookup_sample: 0,
|
||||
search_status: 0,
|
||||
errors: [],
|
||||
startdate: moment(new Date()).format('YYYY-MM-DD'),
|
||||
enddate: moment(new Date()).format('YYYY-MM-DD'),
|
||||
bases: [],
|
||||
base: {},
|
||||
omzettypes: [],
|
||||
omzettype: {},
|
||||
sampletypes: [],
|
||||
sampletype: {},
|
||||
agingtypes: [],
|
||||
agingtype: {},
|
||||
statuss: [],
|
||||
autodeliveryorders:[],
|
||||
autodeliveryorder:{},
|
||||
autocitys:[],
|
||||
autocity:{},
|
||||
autodistricts:[],
|
||||
autodistrict:{},
|
||||
autokelurahans:[],
|
||||
autokelurahan:{},
|
||||
current_page:1,
|
||||
x_search: '',
|
||||
total_data: 0,
|
||||
total_datasemua: 0,
|
||||
total_dataterima: 0,
|
||||
selected_sample: {
|
||||
name: ""
|
||||
},
|
||||
selected: [],
|
||||
lookup_selected_sample: 0,
|
||||
lookup_error_message: '',
|
||||
couriers: [],
|
||||
courier: {},
|
||||
xcek: 0,
|
||||
},
|
||||
mutations: {
|
||||
update_xcek(state, val) {
|
||||
state.xcek = val
|
||||
},
|
||||
update_selected_sample(state, val) {
|
||||
state.selected_sample = val
|
||||
},
|
||||
update_x_search(state, val) {
|
||||
state.x_search = val
|
||||
},
|
||||
update_current_page(state, val) {
|
||||
state.current_page = val
|
||||
},
|
||||
update_total_data(state, val) {
|
||||
state.total_data = val
|
||||
},
|
||||
update_total_datasemua(state, val) {
|
||||
state.total_datasemua = val
|
||||
},
|
||||
update_total_dataterima(state, val) {
|
||||
state.total_dataterima = val
|
||||
},
|
||||
update_autodeliveryorders(state,data){
|
||||
state.autodeliveryorders = data
|
||||
},
|
||||
update_autodeliveryorder(state,val){
|
||||
state.autodeliveryorder = val
|
||||
},
|
||||
update_autocitys(state,data){
|
||||
state.autocitys = data
|
||||
},
|
||||
update_autocity(state,val){
|
||||
state.autocity = val
|
||||
},
|
||||
update_autodistricts(state,data){
|
||||
state.autodistricts = data
|
||||
},
|
||||
update_autodistrict(state,val){
|
||||
state.autodistrict = val
|
||||
},
|
||||
update_autokelurahans(state,data){
|
||||
state.autokelurahans = data
|
||||
},
|
||||
update_autokelurahan(state,val){
|
||||
state.autokelurahan = val
|
||||
},
|
||||
update_errors(state, val) {
|
||||
state.errors = val
|
||||
},
|
||||
update_samples(state, data) {
|
||||
state.samples = data
|
||||
},
|
||||
update_save_status(state, val) {
|
||||
state.save_status = val
|
||||
},
|
||||
update_save_error_message(state, val) {
|
||||
state.save_error_message = val
|
||||
},
|
||||
update_dialog_form_sample(state, val) {
|
||||
state.dialog_form_sample = val
|
||||
},
|
||||
update_lookup_sample(state, val) {
|
||||
state.lookup_sample = val
|
||||
},
|
||||
update_startdate(state, val) {
|
||||
state.startdate = val
|
||||
},
|
||||
update_enddate(state, val) {
|
||||
state.enddate = val
|
||||
},
|
||||
update_bases(state, data) {
|
||||
state.bases = data
|
||||
},
|
||||
update_base(state, val) {
|
||||
state.base = val
|
||||
},
|
||||
update_omzettypes(state, data) {
|
||||
state.omzettypes = data
|
||||
},
|
||||
update_omzettype(state, val) {
|
||||
state.omzettype = val
|
||||
},
|
||||
update_sampletypes(state, data) {
|
||||
state.sampletypes = data
|
||||
},
|
||||
update_sampletype(state, val) {
|
||||
state.sampletype = val
|
||||
},
|
||||
update_agingtypes(state, data) {
|
||||
state.agingtypes = data
|
||||
},
|
||||
update_agingtype(state, val) {
|
||||
state.agingtype = val
|
||||
},
|
||||
update_search_status(state, val) {
|
||||
state.search_status = val
|
||||
},
|
||||
update_statuss(state, data) {
|
||||
state.statuss = data
|
||||
},
|
||||
update_dialog_status_order(state, val) {
|
||||
state.dialog_status_order = val
|
||||
},
|
||||
update_selected(state,data) {
|
||||
state.selected = data
|
||||
},
|
||||
update_lookup_selected_sample(state, val) {
|
||||
state.lookup_selected_sample=val
|
||||
},
|
||||
update_lookup_error_message(state, status) {
|
||||
state.lookup_error_message = status
|
||||
},
|
||||
update_couriers(state, data) {
|
||||
state.couriers = data
|
||||
},
|
||||
update_courier(state, val) {
|
||||
state.courier = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async selected(context,prm) {
|
||||
context.commit("update_lookup_selected_sample", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.selected(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_selected_sample", 3)
|
||||
context.commit("update_lookup_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_selected_sample", 2)
|
||||
context.commit("update_lookup_error_message", "")
|
||||
context.commit("update_selected", resp.data.records)
|
||||
context.commit("update_total_data", resp.data.total)
|
||||
context.commit("update_total_datasemua", resp.data.semua)
|
||||
context.commit("update_total_dataterima", resp.data.terima)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_lookup_selected_sample", 3)
|
||||
context.commit("update_lookup_error_message", e.message)
|
||||
}
|
||||
},
|
||||
async selectedbybarcode(context,prm) {
|
||||
context.commit("update_lookup_selected_sample", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.selectedbybarcode(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_selected_sample", 3)
|
||||
context.commit("update_lookup_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_selected_sample", 2)
|
||||
context.commit("update_lookup_error_message", "")
|
||||
context.commit("update_selected", resp.data.records)
|
||||
context.commit("update_total_data", resp.data.total)
|
||||
context.commit("update_total_datasemua", resp.data.semua)
|
||||
context.commit("update_total_dataterima", resp.data.terima)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_lookup_selected_sample", 3)
|
||||
context.commit("update_lookup_error_message", e.message)
|
||||
}
|
||||
},
|
||||
async lookupbyname(context,prm) {
|
||||
context.commit("update_lookup_selected_sample", 1)
|
||||
try {
|
||||
prm.token = one_token()
|
||||
let resp = await api.lookupbyname(prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_lookup_selected_sample", 3)
|
||||
context.commit("update_lookup_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_lookup_selected_sample", 2)
|
||||
context.commit("update_lookup_error_message", "")
|
||||
context.commit("update_selected", resp.data.records)
|
||||
context.commit("update_total_data", resp.data.total)
|
||||
context.commit("update_total_datasemua", resp.data.semua)
|
||||
context.commit("update_total_dataterima", resp.data.terima)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_lookup_selected_sample", 3)
|
||||
context.commit("update_lookup_error_message", e.message)
|
||||
}
|
||||
},
|
||||
async searchcourier(context, prm) {
|
||||
context.commit("deliveryorder/update_autocomplete_status", 1,{ root: true })
|
||||
try {
|
||||
let resp = await api.searchcourier(one_token(), prm)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("deliveryorder/update_autocomplete_status", 3,{ root: true })
|
||||
} else {
|
||||
context.commit("deliveryorder/update_autocomplete_status", 2,{ root: true })
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_couriers", resp.data.records)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("deliveryorder/update_autocomplete_status", 3,{ root: true })
|
||||
}
|
||||
},
|
||||
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)
|
||||
var data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
|
||||
if (data.total !== -1) {
|
||||
context.commit("deliveryorder/update_alert_success", true,{ root: true })
|
||||
var msg = "Serah terima sampel telah berhasil"
|
||||
context.commit("deliveryorder/update_msg_success", msg,{ root: true })
|
||||
context.commit("deliveryorder/uupdate_selected_deliveryorder", data.records[0],{ root: true })
|
||||
context.commit("update_xcek", 0)
|
||||
context.dispatch("deliveryorder/lookupbyname", {
|
||||
deliveryorder: prm.sdeliveryorder,
|
||||
current_page: 1,
|
||||
lastid: -1
|
||||
},{ root: true })
|
||||
context.dispatch("selected", {
|
||||
id: prm.id
|
||||
})
|
||||
} 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user