663 lines
26 KiB
JavaScript
663 lines
26 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/district.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
districts: [],
|
|
save_status: 0,
|
|
save_error_message: '',
|
|
dialog_form_district: false,
|
|
dialog_status_order: false,
|
|
lookup_district: 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: {},
|
|
districttypes: [],
|
|
districttype: {},
|
|
agingtypes: [],
|
|
agingtype: {},
|
|
statuss: [],
|
|
autocitys:[],
|
|
autocity:{},
|
|
current_page:1,
|
|
x_search: '',
|
|
total_data: 0,
|
|
selected_district: {
|
|
name: ""
|
|
}
|
|
},
|
|
mutations: {
|
|
update_selected_district(state, val) {
|
|
state.selected_district = 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_autocitys(state,data){
|
|
state.autocitys = data
|
|
},
|
|
update_autocity(state,val){
|
|
state.autocity = val
|
|
},
|
|
update_errors(state, val) {
|
|
state.errors = val
|
|
},
|
|
update_districts(state, data) {
|
|
state.districts = data
|
|
},
|
|
update_save_status(state, val) {
|
|
state.save_status = val
|
|
},
|
|
update_save_error_message(state, val) {
|
|
state.save_error_message = val
|
|
},
|
|
update_dialog_form_district(state, val) {
|
|
state.dialog_form_district = val
|
|
},
|
|
update_lookup_district(state, val) {
|
|
state.lookup_district = 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_districttypes(state, data) {
|
|
state.districttypes = data
|
|
},
|
|
update_districttype(state, val) {
|
|
state.districttype = 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
|
|
}
|
|
},
|
|
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("update_save_status", 3)
|
|
context.commit("update_save_error_message", resp.message)
|
|
} else {
|
|
var data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
if (data.total !== -1) {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_save_error_message", resp.message)
|
|
context.commit("city/update_alert_success", true, {
|
|
root: true
|
|
})
|
|
|
|
context.commit("update_dialog_form_district", false)
|
|
var msg = "Kecamatan " + prm.name + " kota " + prm.cityname + " sudah disimpan dong"
|
|
context.commit("city/update_msg_success", msg, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_alert_success", true, {
|
|
root: true
|
|
})
|
|
context.dispatch("lookupbyname", {
|
|
province: prm.sprovince,
|
|
city: prm.scity,
|
|
district: prm.sdistrict,
|
|
kelurahan: prm.skelurahan,
|
|
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 lookupx(context, prm) {
|
|
context.commit("update_lookup_district", 1)
|
|
try {
|
|
let resp = await api.lookupx(one_token(), prm.id)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_lookup_district", 3)
|
|
} else {
|
|
context.commit("update_lookup_district", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_districts", data.records)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_lookup_district", 3)
|
|
}
|
|
},
|
|
async lookup(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.lookup(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_districts", data.records)
|
|
console.log('status')
|
|
console.log(data.records.statuss)
|
|
context.commit("update_statuss", data.records.statuss)
|
|
context.commit("update_total_data", data.total)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async lookupbyprovince(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.lookupbyprovince(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_districts", data.records)
|
|
console.log('status')
|
|
console.log(data.records.statuss)
|
|
context.commit("update_statuss", data.records.statuss)
|
|
context.commit("update_total_data", data.total)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async lookupbycity(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.lookupbycity(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_districts", data.records)
|
|
console.log('status')
|
|
console.log(data.records.statuss)
|
|
context.commit("update_statuss", data.records.statuss)
|
|
context.commit("update_total_data", data.total)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async lookupbykelurahan(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.lookupbykelurahan(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_districts", data.records)
|
|
console.log('status')
|
|
console.log(data.records.statuss)
|
|
context.commit("update_statuss", data.records.statuss)
|
|
context.commit("update_total_data", data.total)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async lookupbyname(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.lookupbyname(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_districts", data.records)
|
|
console.log('status')
|
|
console.log(data.records.statuss)
|
|
context.commit("update_statuss", data.records.statuss)
|
|
context.commit("update_total_data", data.total)
|
|
var pat = data.records[0]
|
|
console.log(pat)
|
|
if(prm.district != ""){
|
|
context.commit("kelurahan/update_autodistricts", [{
|
|
M_DistrictID: pat.M_DistrictID,
|
|
M_DistrictName: pat.M_DistrictName
|
|
}], { root: true })
|
|
context.commit("kelurahan/update_autodistrict", {
|
|
M_DistrictID: pat.M_DistrictID,
|
|
M_DistrictName: pat.M_DistrictName
|
|
},{ root: true })
|
|
}
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 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("city/update_save_status", 3, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_save_error_message", resp.message, {
|
|
root: true
|
|
})
|
|
} else {
|
|
context.commit("city/update_save_status", 2, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_save_error_message", resp.message, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_alert_success", true, {
|
|
root: true
|
|
})
|
|
|
|
//context.commit("update_dialog_form_schedule_promise", false)
|
|
var msg = "Kecamatan " + prm.name + " dari kota " + prm.cityname + " sudah dihapus dong"
|
|
context.commit("city/update_msg_success", msg, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_alert_success", true, {
|
|
root: true
|
|
})
|
|
context.dispatch("lookupbyname", {
|
|
province: prm.sprovince,
|
|
city: prm.scity,
|
|
district: prm.sdistrict,
|
|
kelurahan: prm.skelurahan,
|
|
current_page: 1,
|
|
lastid: -1
|
|
})
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_save_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async searchcity(context,prm) {
|
|
context.commit("province/update_autocomplete_status",1,{root: true})
|
|
try {
|
|
let resp= await api.searchcity(one_token(), prm.tes)
|
|
if (resp.status != "OK") {
|
|
context.commit("province/update_autocomplete_status",3,{root: true})
|
|
} else {
|
|
context.commit("province/update_autocomplete_status",2,{root: true})
|
|
let data = {
|
|
records : resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_autocitys",resp.data.records)
|
|
}
|
|
} catch(e) {
|
|
context.commit("province/update_autocomplete_status",3,{root: true})
|
|
}
|
|
},
|
|
async verify(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
let resp = await api.xverify(one_token(), prm.xid)
|
|
if (resp.status != "OK") {
|
|
context.commit("city/update_save_status", 3, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_save_error_message", resp.message, {
|
|
root: true
|
|
})
|
|
} else {
|
|
context.commit("city/update_save_status", 2, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_save_error_message", resp.message, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_alert_success", true, {
|
|
root: true
|
|
})
|
|
|
|
//context.commit("update_dialog_form_schedule_promise", false)
|
|
var msg = "Agreement " + prm.name + " dari city " + prm.cityname + " sudah diverifikasi"
|
|
context.commit("city/update_msg_success", msg, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_alert_success", true, {
|
|
root: true
|
|
})
|
|
context.dispatch("lookup", {
|
|
id: prm.cityid
|
|
})
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_save_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async unverify(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
let resp = await api.xunverify(one_token(), prm.xid)
|
|
if (resp.status != "OK") {
|
|
context.commit("city/update_save_status", 3, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_save_error_message", resp.message, {
|
|
root: true
|
|
})
|
|
} else {
|
|
context.commit("city/update_save_status", 2, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_save_error_message", resp.message, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_alert_success", true, {
|
|
root: true
|
|
})
|
|
|
|
//context.commit("update_dialog_form_schedule_promise", false)
|
|
var msg = "Verifikasi Agreement " + prm.name + " dari city " + prm.cityname + " sudah dibatalkan"
|
|
context.commit("city/update_msg_success", msg, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_alert_success", true, {
|
|
root: true
|
|
})
|
|
context.dispatch("lookup", {
|
|
id: prm.cityid
|
|
})
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_save_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async release(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
let resp = await api.xrelease(one_token(), prm.xid)
|
|
if (resp.status != "OK") {
|
|
context.commit("city/update_save_status", 3, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_save_error_message", resp.message, {
|
|
root: true
|
|
})
|
|
} else {
|
|
context.commit("city/update_save_status", 2, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_save_error_message", resp.message, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_alert_success", true, {
|
|
root: true
|
|
})
|
|
|
|
//context.commit("update_dialog_form_schedule_promise", false)
|
|
var msg = "Agreement " + prm.name + " dari city " + prm.cityname + " sudah dirilis"
|
|
context.commit("city/update_msg_success", msg, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_alert_success", true, {
|
|
root: true
|
|
})
|
|
context.dispatch("lookup", {
|
|
id: prm.cityid
|
|
})
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_save_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async unrelease(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
let resp = await api.xunrelease(one_token(), prm.xid)
|
|
if (resp.status != "OK") {
|
|
context.commit("city/update_save_status", 3, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_save_error_message", resp.message, {
|
|
root: true
|
|
})
|
|
} else {
|
|
context.commit("city/update_save_status", 2, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_save_error_message", resp.message, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_alert_success", true, {
|
|
root: true
|
|
})
|
|
|
|
//context.commit("update_dialog_form_schedule_promise", false)
|
|
var msg = "Rilis Agreement " + prm.name + " dari city " + prm.cityname + " sudah dibatalkan"
|
|
context.commit("city/update_msg_success", msg, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_alert_success", true, {
|
|
root: true
|
|
})
|
|
context.dispatch("lookup", {
|
|
id: prm.cityid
|
|
})
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_save_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async selectbase(context) {
|
|
context.commit("city/update_get_data_status", 1, {
|
|
root: true
|
|
})
|
|
try {
|
|
let resp = await api.selectbase(one_token())
|
|
if (resp.status != "OK") {
|
|
context.commit("city/update_get_data_status", 3, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_get_data_error_message", resp.message, {
|
|
root: true
|
|
})
|
|
} else {
|
|
context.commit("city/update_get_data_status", 2, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_get_data_error_message", "", {
|
|
root: true
|
|
})
|
|
context.commit("update_bases", resp.data.records.bases)
|
|
}
|
|
} catch (e) {
|
|
context.commit("city/update_get_data_status", 3, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_get_data_error_message", e.message, {
|
|
root: true
|
|
})
|
|
console.log(e)
|
|
}
|
|
},
|
|
async selectomzettype(context) {
|
|
context.commit("city/update_get_data_status", 1, {
|
|
root: true
|
|
})
|
|
try {
|
|
let resp = await api.selectomzettype(one_token())
|
|
if (resp.status != "OK") {
|
|
context.commit("city/update_get_data_status", 3, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_get_data_error_message", resp.message, {
|
|
root: true
|
|
})
|
|
} else {
|
|
context.commit("city/update_get_data_status", 2, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_get_data_error_message", "", {
|
|
root: true
|
|
})
|
|
context.commit("update_omzettypes", resp.data.records.omzettypes)
|
|
}
|
|
} catch (e) {
|
|
context.commit("city/update_get_data_status", 3, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_get_data_error_message", e.message, {
|
|
root: true
|
|
})
|
|
console.log(e)
|
|
}
|
|
},
|
|
async selectdistricttype(context) {
|
|
context.commit("city/update_get_data_status", 1, {
|
|
root: true
|
|
})
|
|
try {
|
|
let resp = await api.selectdistricttype(one_token())
|
|
if (resp.status != "OK") {
|
|
context.commit("city/update_get_data_status", 3, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_get_data_error_message", resp.message, {
|
|
root: true
|
|
})
|
|
} else {
|
|
context.commit("city/update_get_data_status", 2, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_get_data_error_message", "", {
|
|
root: true
|
|
})
|
|
context.commit("update_districttypes", resp.data.records.districttypes)
|
|
}
|
|
} catch (e) {
|
|
context.commit("city/update_get_data_status", 3, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_get_data_error_message", e.message, {
|
|
root: true
|
|
})
|
|
console.log(e)
|
|
}
|
|
},
|
|
async selectagingtype(context) {
|
|
context.commit("city/update_get_data_status", 1, {
|
|
root: true
|
|
})
|
|
try {
|
|
let resp = await api.selectagingtype(one_token())
|
|
if (resp.status != "OK") {
|
|
context.commit("city/update_get_data_status", 3, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_get_data_error_message", resp.message, {
|
|
root: true
|
|
})
|
|
} else {
|
|
context.commit("city/update_get_data_status", 2, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_get_data_error_message", "", {
|
|
root: true
|
|
})
|
|
context.commit("update_agingtypes", resp.data.records.agingtypes)
|
|
}
|
|
} catch (e) {
|
|
context.commit("city/update_get_data_status", 3, {
|
|
root: true
|
|
})
|
|
context.commit("city/update_get_data_error_message", e.message, {
|
|
root: true
|
|
})
|
|
console.log(e)
|
|
}
|
|
}
|
|
}
|
|
} |