213 lines
9.3 KiB
JavaScript
213 lines
9.3 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/order.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
orders: [],
|
|
total_order:0,
|
|
selected_order:{},
|
|
listing_status: 0,
|
|
listing_error_message: '',
|
|
fdate:moment(new Date()).format('YYYY-MM-DD'),
|
|
search_order:0,
|
|
save_status:0,
|
|
search_error_message:'',
|
|
lookup_staff:0,
|
|
lookup_staff_error_message:'',
|
|
staffs:[],
|
|
disabled_button :false
|
|
},
|
|
mutations: {
|
|
update_disabled_button(state, data) {
|
|
state.disabled_button = data
|
|
},
|
|
update_home_service(state, data) {
|
|
state.home_services = data
|
|
},
|
|
update_listing_status(state, val) {
|
|
state.listing_status = val
|
|
},
|
|
update_listing_error_message(state, val) {
|
|
state.listing_error_message = val
|
|
},
|
|
update_fdate(state,val){
|
|
state.fdate = val
|
|
console.log(state.fdate)
|
|
},
|
|
update_search_order(state,val){
|
|
state.search_order = val
|
|
},
|
|
update_search_error_message(state,val){
|
|
state.search_error_message = val
|
|
},
|
|
update_orders(state,data){
|
|
state.orders = data.records
|
|
state.total_order = data.total
|
|
},
|
|
update_save_status(state,val){
|
|
state.save_status = val
|
|
},
|
|
update_orders_commit(state,data){
|
|
state.orders = data
|
|
},
|
|
update_lookup_staff(state,val){
|
|
state.lookup_staff = val
|
|
},
|
|
update_lookup_staff_error_message(state,val){
|
|
state.lookup_staff_error_message = val
|
|
},
|
|
update_staffs(state,data){
|
|
state.staffs = data
|
|
}
|
|
},
|
|
actions: {
|
|
async search(context, prm) {
|
|
context.commit("update_search_order", 1)
|
|
try {
|
|
let resp = await api.search(prm.fdate, prm.fstatus, prm.ftype, one_token())
|
|
if (resp.status != "OK") {
|
|
context.commit("update_search_order", 3)
|
|
context.commit("update_search_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_search_order", 2)
|
|
context.commit("update_search_error_message", "")
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_orders", data)
|
|
//context.commit("update_selected_order", data.records[0])
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_search_order", 3)
|
|
context.commit("update_search_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async lookup_staff(context, prm) {
|
|
context.commit("update_lookup_staff", 1)
|
|
try {
|
|
let resp = await api.lookup_staff(prm.fdate, prm.fstatus,one_token())
|
|
if (resp.status != "OK") {
|
|
context.commit("update_lookup_staff", 3)
|
|
context.commit("update_lookup_staff_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_lookup_staff", 2)
|
|
context.commit("update_lookup_staff_error_message", "")
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_staffs", data.records)
|
|
//context.commit("update_selected_order", data.records[0])
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_lookup_staff", 3)
|
|
context.commit("update_lookup_staff_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async doconfirm(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.doconfirm(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status",3)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
var prm = {fdate:prm.fdate,fstatus:prm.fstatus,ftype:prm.ftype}
|
|
//console.log(prm)
|
|
|
|
//context.commit("px/update_moucompany", data.records[0], { root: true })
|
|
context.commit("form/update_ordertype",{},{ root: true })
|
|
context.commit("form/update_orderdate","",{ root: true })
|
|
context.commit("form/update_orderphone","",{ root: true })
|
|
context.commit("form/update_orderpatient",{},{ root: true })
|
|
context.commit("form/update_orderadress",{},{ root: true })
|
|
context.commit("form/update_orderautotest",{},{ root: true })
|
|
context.commit("form/update_ordertests",[],{ root: true })
|
|
context.commit("form/update_orderstaff",{},{ root: true })
|
|
context.commit("form/update_orderpatients",[],{ root: true })
|
|
context.commit("form/update_orderadresss",[],{ root: true })
|
|
context.commit("form/update_orderdeliverytype",{},{ root: true })
|
|
context.commit("form/update_orderpatientdeliveryaddress",{},{ root: true })
|
|
context.commit("form/update_btn_confirm",'hide',{ root: true })
|
|
context.dispatch("search",prm)
|
|
context.dispatch("lookup_staff",prm)
|
|
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
},
|
|
async doorderlab(context,prm) {
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.doorderlab(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
|
|
}
|
|
|
|
let msg = "Order dengan nomor "+data.records.numberx+" berhasil dibuat"
|
|
// var prm = {fdate:prm.fdate,fstatus:prm.fstatus,ftype:prm.ftype}
|
|
//console.log(prm)
|
|
// context.commit("form/update_dialog_form",false,{ root: true })
|
|
context.commit("form/update_title_ordernumber",'Berhasil !',{ root: true })
|
|
context.commit("form/update_msg_ordernumber",msg,{ root: true })
|
|
context.commit("form/update_dialog_ordernumber",true,{ root: true })
|
|
//context.commit("px/update_moucompany", data.records[0], { root: true })
|
|
/*context.commit("form/update_ordertype",{},{ root: true })
|
|
context.commit("form/update_orderdate","",{ root: true })
|
|
context.commit("form/update_orderphone","",{ root: true })
|
|
context.commit("form/update_orderpatient",{},{ root: true })
|
|
context.commit("form/update_orderadress",{},{ root: true })
|
|
context.commit("form/update_orderautotest",{},{ root: true })
|
|
context.commit("form/update_ordertests",[],{ root: true })
|
|
context.commit("form/update_orderstaff",{},{ root: true })
|
|
context.commit("form/update_orderpatients",[],{ root: true })
|
|
context.commit("form/update_orderadresss",[],{ root: true })
|
|
context.commit("form/update_orderdeliverytype",{},{ root: true })
|
|
context.commit("form/update_orderpatientdeliveryaddress",{},{ root: true })
|
|
context.commit("form/update_btn_confirm",'hide',{ root: true })
|
|
context.commit("form/update_do_btn_order",'hide',{ root: true })*/
|
|
//context.dispatch("search",prm)
|
|
//context.dispatch("lookup_staff",prm)
|
|
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
},
|
|
async docancel(context,prm) {
|
|
|
|
context.commit("update_save_status",1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp= await api.docancel(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status",3)
|
|
} else {
|
|
context.commit("update_save_status",2)
|
|
var prm = {fdate:prm.fdate,fstatus:prm.fstatus,ftype:prm.ftype}
|
|
console.log(prm)
|
|
context.dispatch("search",prm)
|
|
context.dispatch("lookup_staff",prm)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_save_status",3)
|
|
}
|
|
}
|
|
}
|
|
} |