195 lines
6.6 KiB
JavaScript
195 lines
6.6 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/queue.js"
|
|
window.api = api
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
load_queue:0,
|
|
load_service:0,
|
|
load_error_message:'',
|
|
queues: [],
|
|
total_queue: 0,
|
|
selected_queue: {},
|
|
info:false,
|
|
msg_info:'',
|
|
services:[],
|
|
selected_service:{"serviceID":0,"serviceName":"All Service"}
|
|
},
|
|
mutations: {
|
|
update_load_queue(state,status) {
|
|
state.load_queue = status
|
|
},
|
|
update_load_error_message(state,val) {
|
|
state.load_error_message = val
|
|
},
|
|
update_queues(state,data){
|
|
state.queues = data.records
|
|
state.total_queue = data.total
|
|
},
|
|
update_info(state,val) {
|
|
state.info = val
|
|
},
|
|
update_msg_info(state,val) {
|
|
state.msg_info = val
|
|
},
|
|
update_load_service(state,status) {
|
|
state.load_service = status
|
|
},
|
|
update_services(state,data) {
|
|
state.services = data.records
|
|
},
|
|
update_selected_service(state,val) {
|
|
state.selected_service = val
|
|
}
|
|
},
|
|
actions: {
|
|
async loadx(context,prm) {
|
|
context.commit("update_load_queue",1)
|
|
try {
|
|
let resp= await api.loadx(prm.serviceid)
|
|
//console.log(resp)
|
|
if (resp.statusText != "OK") {
|
|
context.commit("update_load_queue",3)
|
|
context.commit("update_load_error_message",resp.message)
|
|
} else {
|
|
context.commit("update_load_queue",2)
|
|
context.commit("update_load_error_message","")
|
|
//console.log(resp)
|
|
let data = {
|
|
records : resp.data,
|
|
total: resp.length
|
|
}
|
|
context.commit("update_queues",data)
|
|
context.dispatch("summary/loadx",{}, {root:true})
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_load_queue",3)
|
|
context.commit("update_load_error_message",e.message )
|
|
}
|
|
},
|
|
async loadservice(context) {
|
|
context.commit("update_load_service",1)
|
|
try {
|
|
let resp= await api.loadservice()
|
|
//console.log(resp)
|
|
if (resp.statusText != "OK") {
|
|
context.commit("update_load_service",3)
|
|
context.commit("update_load_error_message",resp.message)
|
|
} else {
|
|
context.commit("update_load_service",2)
|
|
context.commit("update_load_error_message","")
|
|
//console.log(resp)
|
|
let data = {
|
|
records : resp.data,
|
|
total: resp.length
|
|
}
|
|
context.commit("update_services",data)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_load_queue",3)
|
|
context.commit("update_load_error_message",e.message )
|
|
}
|
|
},
|
|
async docall(context,prm) {
|
|
context.commit("update_load_queue",1)
|
|
try {
|
|
let resp= await api.docall(prm.number)
|
|
//console.log(resp)
|
|
if (resp.data.status != "OK") {
|
|
context.commit("update_load_queue",3)
|
|
context.commit("update_info",true)
|
|
context.commit("update_msg_info",resp.data.message)
|
|
context.dispatch("loadx")
|
|
} else {
|
|
context.commit("update_load_queue",2)
|
|
context.commit("update_load_error_message","")
|
|
context.dispatch("loadx")
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_load_queue",3)
|
|
context.commit("update_load_error_message",e.message )
|
|
}
|
|
},
|
|
async dorecall(context,prm) {
|
|
context.commit("update_load_queue",1)
|
|
try {
|
|
let resp= await api.dorecall(prm.number)
|
|
//console.log(resp)
|
|
if (resp.data.status != "OK") {
|
|
context.commit("update_load_queue",3)
|
|
context.commit("update_info",true)
|
|
context.commit("update_msg_info",resp.data.message)
|
|
context.dispatch("loadx")
|
|
} else {
|
|
context.commit("update_load_queue",2)
|
|
context.commit("update_load_error_message","")
|
|
context.dispatch("loadx")
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_load_queue",3)
|
|
context.commit("update_load_error_message",e.message )
|
|
}
|
|
},
|
|
async doserve(context,prm) {
|
|
context.commit("update_load_queue",1)
|
|
try {
|
|
let resp= await api.doserve(prm.number)
|
|
if (resp.data.status != "OK") {
|
|
context.commit("update_load_queue",3)
|
|
context.commit("update_info",true)
|
|
context.commit("update_msg_info",resp.data.message)
|
|
context.dispatch("loadx")
|
|
} else {
|
|
context.commit("update_load_queue",2)
|
|
context.commit("update_load_error_message","")
|
|
context.dispatch("loadx")
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_load_queue",3)
|
|
context.commit("update_load_error_message",e.message )
|
|
}
|
|
},
|
|
async dodone(context,prm) {
|
|
context.commit("update_load_queue",1)
|
|
try {
|
|
let resp= await api.dodone(prm.number)
|
|
if (resp.data.status != "OK") {
|
|
context.commit("update_load_queue",3)
|
|
context.commit("update_info",true)
|
|
context.commit("update_msg_info",resp.data.message)
|
|
context.dispatch("loadx")
|
|
} else {
|
|
context.commit("update_load_queue",2)
|
|
context.commit("update_load_error_message","")
|
|
context.dispatch("loadx")
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_load_queue",3)
|
|
context.commit("update_load_error_message",e.message )
|
|
}
|
|
},
|
|
async doskip(context,prm) {
|
|
context.commit("update_load_queue",1)
|
|
try {
|
|
let resp= await api.doskip(prm.number)
|
|
if (resp.data.status != "OK") {
|
|
context.commit("update_load_queue",3)
|
|
context.commit("update_info",true)
|
|
context.commit("update_msg_info",resp.data.message)
|
|
context.dispatch("loadx")
|
|
} else {
|
|
context.commit("update_load_queue",2)
|
|
context.commit("update_load_error_message","")
|
|
context.dispatch("loadx")
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_load_queue",3)
|
|
context.commit("update_load_error_message",e.message )
|
|
}
|
|
}
|
|
}
|
|
}
|