500 lines
20 KiB
JavaScript
500 lines
20 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/packet.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
dialog_success: false,
|
|
msg_success: "",
|
|
open_alert_confirmation: false,
|
|
no_save: 0,
|
|
open_alert_confirmation: false,
|
|
search_tpacket:'',
|
|
tpriceheaderCb:[],
|
|
selected_tpriceheaderCb:{},
|
|
search_packet:0,
|
|
total_packets:0,
|
|
search_status: 0,
|
|
search_error_message:'',
|
|
tpackets:[],
|
|
total_tpacket:0,
|
|
current_page:1,
|
|
selected_packet: {},
|
|
dialog_add:false,
|
|
act: 'edit',
|
|
xid:-1,
|
|
// form
|
|
inp_T_PacketName:'',
|
|
inp_T_PacketNameEdit:'',
|
|
search_kode:'',
|
|
search_nama:'',
|
|
tpriceheaderformCb:[],
|
|
tpriceheaderformeditCb:[],
|
|
selected_tpriceheaderformCb:{},
|
|
selected_tpriceheaderformeditCb:{},
|
|
total_prices:0,
|
|
current_page_tprice:1,
|
|
tprices:[],
|
|
selected_tprice:{},
|
|
selected_tpricedetail:{},
|
|
tpricedetails:[],
|
|
tpackettypeRb:'PN',
|
|
pricepackets:[],
|
|
total_tpacketdetails:0,
|
|
tpacketdetails:[],
|
|
current_page_tpacketdetails:1,
|
|
totalTPriceAwal:0,
|
|
totalTPricePacket:0,
|
|
save_status: 0,
|
|
dialog_error:false,
|
|
msg_error:'',
|
|
dialog_edit:false,
|
|
show_inputan_paket:false,
|
|
natsubgroupCb:[],
|
|
selected_natsubgroupCb:{},
|
|
msg_confirmation_delete:'',
|
|
dialog_confirmation_delete:false,
|
|
start_date:moment(new Date()).format('YYYY-MM-DD'),
|
|
end_date:moment(new Date()).format('YYYY-MM-DD'),
|
|
},
|
|
mutations: {
|
|
update_start_date(state, val) {
|
|
state.start_date = val
|
|
},
|
|
update_end_date(state, val) {
|
|
state.end_date = val
|
|
},
|
|
update_dialog_confirmation_delete(state, val) {
|
|
state.dialog_confirmation_delete = val
|
|
},
|
|
update_msg_confirmation_delete(state, val) {
|
|
state.msg_confirmation_delete = val
|
|
},
|
|
update_natsubgroupCb(state, status){
|
|
state.natsubgroupCb = status
|
|
},
|
|
update_selected_natsubgroupCb(state, status){
|
|
state.selected_natsubgroupCb = status
|
|
},
|
|
update_show_inputan_paket(state, val) {
|
|
state.show_inputan_paket = val
|
|
},
|
|
update_msg_error(state, val) {
|
|
state.msg_error = val
|
|
},
|
|
update_dialog_error(state, val){
|
|
state.dialog_error = val
|
|
},
|
|
update_totalTPricePacket(state, val) {
|
|
state.totalTPricePacket = val
|
|
},
|
|
update_totalTPriceAwal(state, val) {
|
|
state.totalTPriceAwal = val
|
|
},
|
|
update_tpacketdetails(state, val) {
|
|
state.tpacketdetails = val
|
|
},
|
|
update_current_page_tpacketdetails(state, val) {
|
|
state.current_page_tpacketdetails = val
|
|
},
|
|
update_total_tpacketdetails(state, val) {
|
|
state.total_tpacketdetails = val
|
|
},
|
|
update_pricepackets(state,status) {
|
|
state.pricepackets = status
|
|
},
|
|
update_tpackettypeRb(state,status) {
|
|
state.tpackettypeRb = status
|
|
},
|
|
update_tpricedetails(state,status) {
|
|
state.tpricedetails = status
|
|
},
|
|
update_selected_tpricedetail(state, val) {
|
|
state.selected_tpricedetail = val
|
|
},
|
|
update_selected_tprice(state, val) {
|
|
state.selected_tprice = val
|
|
},
|
|
update_tprices(state,status) {
|
|
state.tprices = status
|
|
},
|
|
update_current_page_tprice(state, val) {
|
|
state.current_page_tprice = val
|
|
},
|
|
update_total_prices(state, val) {
|
|
state.total_prices = val
|
|
},
|
|
update_tpriceheaderformCb(state, status){
|
|
state.tpriceheaderformCb = status
|
|
},
|
|
update_tpriceheaderformeditCb(state, status){
|
|
state.tpriceheaderformeditCb = status
|
|
},
|
|
update_selected_tpriceheaderformCb(state, status){
|
|
state.selected_tpriceheaderformCb = status
|
|
},
|
|
update_selected_tpriceheaderformeditCb(state, status){
|
|
state.selected_tpriceheaderformeditCb = status
|
|
},
|
|
update_search_kode(state,status) {
|
|
state.search_kode = status
|
|
},
|
|
update_search_nama(state,status) {
|
|
state.search_nama = status
|
|
},
|
|
update_inp_T_PacketName(state, val){
|
|
state.inp_T_PacketName = val
|
|
},
|
|
update_inp_T_PacketNameEdit(state, val){
|
|
state.inp_T_PacketNameEdit = val
|
|
},
|
|
update_xid(state,val){
|
|
state.xid = val
|
|
},
|
|
update_act(state, val) {
|
|
state.act = val
|
|
},
|
|
update_dialog_add(state, val) {
|
|
state.dialog_add = val
|
|
},
|
|
update_dialog_edit(state, val) {
|
|
state.dialog_edit = val
|
|
},
|
|
update_selected_packet(state, val) {
|
|
state.selected_packet = val
|
|
},
|
|
update_tpackets(state,status) {
|
|
state.tpackets = status
|
|
},
|
|
update_total_tpacket(state, val) {
|
|
state.total_tpacket = val
|
|
},
|
|
update_search_error_message(state, val) {
|
|
state.search_error_message = val
|
|
},
|
|
update_search_status(state, val) {
|
|
state.search_status = val
|
|
},
|
|
update_total_packets(state, val) {
|
|
state.total_packets = val
|
|
},
|
|
update_dialog_success(state, val) {
|
|
state.dialog_success = val
|
|
},
|
|
update_msg_success(state, val) {
|
|
state.msg_success = val
|
|
},
|
|
update_open_alert_confirmation(state, val) {
|
|
state.open_alert_confirmation = val
|
|
},
|
|
update_no_save(state, val) {
|
|
state.no_save = val
|
|
},
|
|
update_open_alert_confirmation(state, val) {
|
|
state.open_alert_confirmation = val
|
|
},
|
|
update_search_tpacket(state,status) {
|
|
state.search_tpacket = status
|
|
},
|
|
update_tpriceheaderCb(state, status){
|
|
state.tpriceheaderCb = status
|
|
},
|
|
update_selected_tpriceheaderCb(state, status){
|
|
state.selected_tpriceheaderCb = status
|
|
},
|
|
update_search_packet(state,status) {
|
|
state.search_packet = status
|
|
},
|
|
update_current_page(state, val) {
|
|
state.current_page = val
|
|
},
|
|
update_save_status(state, val) {
|
|
state.save_status = val
|
|
},
|
|
},
|
|
actions: {
|
|
// delete data
|
|
async deletev0(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.xdeletev0(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_last_id", 0)
|
|
context.commit("update_dialog_confirmation_delete", false)
|
|
context.commit("update_dialog_success", true)
|
|
var msg = "Data paket dengan nama " + prm.name + " sudah dihapus dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
|
|
context.commit("update_inp_T_PacketName", "")
|
|
context.commit("update_selected_tpriceheaderformCb",{})
|
|
context.commit("update_tpackettypeRb",'PN')
|
|
context.commit("update_tpacketdetails", [])
|
|
context.commit("update_totalTPriceAwal", 0)
|
|
context.commit("update_totalTPricePacket", 0)
|
|
context.commit("update_search_nama", "")
|
|
context.commit("update_search_kode", "")
|
|
context.commit("update_tprices", [])
|
|
context.commit("update_total_prices", 0)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
|
|
// dropdown autocomplete get group pemeriksaan
|
|
async getGroupPemeriksaan(context) {
|
|
context.commit("update_search_packet", 1)
|
|
try {
|
|
var prm = {token: one_token()}
|
|
let resp = await api.getGroupPemeriksaan(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_search_packet", 3)
|
|
} else {
|
|
context.commit("update_search_packet", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
}
|
|
context.commit("update_natsubgroupCb", resp.data.records)
|
|
// context.commit("update_selected_tpriceheaderCb",resp.data.records[0])
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_search_packet", 3)
|
|
}
|
|
},
|
|
|
|
// getPacketById
|
|
async getPacketById(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
|
|
let resp = await api.getPacketById(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_msg_error",resp.message)
|
|
context.commit("update_dialog_error",true)
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
|
|
console.log("data paket edit ", data.records)
|
|
// context.commit("update_tpacketdetails", data.records[0].detailpackets)
|
|
|
|
context.commit("update_inp_T_PacketName", data.records[0].T_PacketName)
|
|
context.commit("update_selected_tpriceheaderformCb",{
|
|
T_PriceHeaderID: resp.data.records[0].T_PriceHeaderID,
|
|
T_PriceHeaderName: resp.data.records[0].T_PriceHeaderName
|
|
})
|
|
|
|
context.commit("update_tpackettypeRb",resp.data.records[0].T_PacketType)
|
|
context.commit("update_tpacketdetails", resp.data.records[0].detailpackets)
|
|
|
|
context.commit("update_totalTPricePacket", resp.data.records[0].sumhargapaket)
|
|
context.commit("update_totalTPriceAwal", resp.data.records[0].sumhargaawal)
|
|
context.commit("update_xid", resp.data.records[0].T_PacketID)
|
|
|
|
context.commit("update_dialog_add", true)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
|
|
// save data
|
|
async savesetupv0(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
|
|
let resp = await api.savesetupv0(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_msg_error",resp.message)
|
|
context.commit("update_dialog_error",true)
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
|
|
// namapacket:this.$store.state.packet.inp_T_PacketName,
|
|
// priceheader:this.$store.state.packet.selected_tpriceheaderformCb,
|
|
// jenispacket:this.$store.state.packet.tpackettypeRb,
|
|
// detailpacket:this.$store.state.packet.tpacketdetails,
|
|
// T_PacketOriginalPrice: this.totalTPriceAwal,
|
|
// T_PacketPrice: this.totalTPricePacket,
|
|
|
|
context.commit("update_inp_T_PacketName", "")
|
|
context.commit("update_selected_tpriceheaderformCb",{})
|
|
context.commit("update_tpackettypeRb",'PN')
|
|
context.commit("update_tpacketdetails", [])
|
|
context.commit("update_totalTPriceAwal", 0)
|
|
context.commit("update_totalTPricePacket", 0)
|
|
context.commit("update_search_nama", "")
|
|
context.commit("update_search_kode", "")
|
|
context.commit("update_tprices", [])
|
|
context.commit("update_total_prices", 0)
|
|
context.commit("update_selected_natsubgroupCb", {})
|
|
|
|
if(context.state.act === 'new')
|
|
var msg = "Pembuatan paket dengan nama " + resp.data.records.xnumber + " sudah berhasil dong ..."
|
|
else
|
|
var msg = "Perubahan paket dengan nama " + resp.data.records.xnumber + " sudah berhasil dong ..."
|
|
|
|
context.commit("update_dialog_add", false)
|
|
context.commit("update_msg_error","")
|
|
context.commit("update_dialog_error",false)
|
|
|
|
context.commit("update_dialog_success", true)
|
|
context.commit("update_msg_success", msg)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
|
|
// dropdown tpriceheader listing search
|
|
async getTPriceHeader(context) {
|
|
context.commit("update_search_packet", 1)
|
|
try {
|
|
var prm = {token: one_token()}
|
|
let resp = await api.getTPriceHeader(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_search_packet", 3)
|
|
} else {
|
|
context.commit("update_search_packet", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
}
|
|
context.commit("update_tpriceheaderCb", resp.data.records)
|
|
context.commit("update_selected_tpriceheaderCb",resp.data.records[0])
|
|
|
|
// context.commit("update_selected_tpriceheaderCb",{
|
|
// T_PriceHeaderID: "All",
|
|
// T_PriceHeaderName: "All",
|
|
// T_PriceHeaderStartDate: "",
|
|
// T_PriceHeaderEndDate: "",
|
|
// T_PriceHeaderIsActive: "",
|
|
// T_PriceHeaderUserID: "",
|
|
// T_PriceHeaderCreated: "",
|
|
// T_PriceHeaderCraetdUserID: "",
|
|
// T_PriceHeaderLastUpdated: "",
|
|
// T_PriceHeaderLastUpdatedUserID: "",
|
|
// T_PriceHeaderDeleted: "",
|
|
// T_PriceHeaderDeletedUserID: ""
|
|
// })
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_search_packet", 3)
|
|
}
|
|
},
|
|
|
|
// dropdown tpriceheader form
|
|
async getTPriceHeaderCurrent(context) {
|
|
context.commit("update_search_packet", 1)
|
|
try {
|
|
var prm = {token: one_token()}
|
|
let resp = await api.getTPriceHeaderCurrent(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_search_packet", 3)
|
|
} else {
|
|
context.commit("update_search_packet", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
}
|
|
context.commit("update_tpriceheaderformCb", resp.data.records)
|
|
// context.commit("update_selected_tpriceheaderCb",resp.data.records[0])
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_search_packet", 3)
|
|
}
|
|
},
|
|
|
|
//
|
|
async searchTPricev0(context, prm) {
|
|
context.commit("update_search_packet", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.getTTestByTPriceHeaderCurrent(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_search_packet", 3)
|
|
context.commit("update_search_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_search_packet", 2)
|
|
context.commit("update_search_error_message", "")
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_tprices", data.records)
|
|
context.commit("update_total_prices", data.total)
|
|
context.commit("update_no_save", 0)
|
|
if (prm.lastid === -1) {
|
|
//context.commit("update_selected_patient", data.records[0])
|
|
/*context.dispatch("getaddress", {
|
|
id: pat.M_PatientID
|
|
})*/
|
|
} else {
|
|
//context.commit("update_selected_patient", data.records[prm.lastid])
|
|
/*context.dispatch("getaddress", {
|
|
id: pat.M_PatientID
|
|
})*/
|
|
}
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_search_packet", 3)
|
|
context.commit("update_search_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
|
|
//
|
|
async searchv0(context, prm) {
|
|
context.commit("update_search_packet", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.searchv0(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_search_packet", 3)
|
|
context.commit("update_search_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_search_packet", 2)
|
|
context.commit("update_search_error_message", "")
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_tpackets", data.records)
|
|
context.commit("update_total_packets", data.total)
|
|
context.commit("update_no_save", 0)
|
|
if (prm.lastid === -1) {
|
|
//context.commit("update_selected_patient", data.records[0])
|
|
/*context.dispatch("getaddress", {
|
|
id: pat.M_PatientID
|
|
})*/
|
|
} else {
|
|
//context.commit("update_selected_patient", data.records[prm.lastid])
|
|
/*context.dispatch("getaddress", {
|
|
id: pat.M_PatientID
|
|
})*/
|
|
}
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_search_packet", 3)
|
|
context.commit("update_search_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
},
|
|
} |