Initial import
This commit is contained in:
272
one-ui/agreement/one-md-packet-v8/modules/packet.js
Normal file
272
one-ui/agreement/one-md-packet-v8/modules/packet.js
Normal file
@@ -0,0 +1,272 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/packet.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
|
||||
search_status: 0,
|
||||
search_error_message: '',
|
||||
|
||||
query_company: '',
|
||||
companies: [],
|
||||
selected_company: {},
|
||||
total_company: 0,
|
||||
default_company: {},
|
||||
|
||||
query_mou: '',
|
||||
mous: [],
|
||||
selected_mou: null,
|
||||
total_mou: 0,
|
||||
default_mou: {},
|
||||
|
||||
query_packet: '',
|
||||
packets: [],
|
||||
selected_packet: null,
|
||||
total_packet: 0,
|
||||
new_packet: {amount:0, disc:0, discrp:0, sub_total:0, other:0, total:0, cito:'N'},
|
||||
edit_packet: false,
|
||||
|
||||
query_addon: '',
|
||||
addons: [],
|
||||
selected_addon: {},
|
||||
total_addon: 0,
|
||||
new_addon_name: '',
|
||||
|
||||
// others: [{id:1, name:'Jasa Dokter', packet:10000}, {id:2, name:'Lain - lain', packet:5000}],
|
||||
others: [],
|
||||
selected_other: {},
|
||||
total_other: 0,
|
||||
|
||||
dialog_px_new: false,
|
||||
dialog_addon_new: false,
|
||||
dialog_packet: false,
|
||||
|
||||
auto_selected_packet_id: 0,
|
||||
isverif: 'N'
|
||||
},
|
||||
mutations: {
|
||||
update_isverif(state, d) {
|
||||
state.isverif = d
|
||||
},
|
||||
|
||||
update_search_error_message(state, patient) {
|
||||
state.search_error_message = patient
|
||||
},
|
||||
|
||||
// MOU
|
||||
update_query_mou(state, q) {
|
||||
state.query_mou = q
|
||||
},
|
||||
|
||||
update_mous(state, d) {
|
||||
state.mous = d.records
|
||||
state.total_mou = d.total
|
||||
},
|
||||
|
||||
update_selected_mou(state, d) {
|
||||
state.selected_mou = d
|
||||
},
|
||||
|
||||
// COMPANY
|
||||
update_query_company(state, q) {
|
||||
state.query_company = q
|
||||
},
|
||||
|
||||
update_companies(state, d) {
|
||||
state.companies = d.records
|
||||
state.total_company = d.total
|
||||
},
|
||||
|
||||
update_selected_company(state, d) {
|
||||
state.selected_company = d
|
||||
|
||||
// update mous
|
||||
if (d) {
|
||||
state.mous = d.mou
|
||||
state.selected_mou = {}
|
||||
state.total_mou = d.mou.length
|
||||
} else {
|
||||
state.mous = []
|
||||
state.selected_mou = {}
|
||||
state.total_mou = 0
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
// PRICE
|
||||
update_query_packet(state, q) {
|
||||
state.query_packet = q
|
||||
},
|
||||
|
||||
update_packets(state, d) {
|
||||
state.packets = d.records
|
||||
state.total_packet = d.total
|
||||
},
|
||||
|
||||
update_selected_packet(state, d) {
|
||||
state.selected_packet = d
|
||||
},
|
||||
|
||||
update_new_packet(state, d) {
|
||||
state.new_packet = d
|
||||
},
|
||||
|
||||
update_edit_packet(state, d) {
|
||||
state.edit_packet = d
|
||||
},
|
||||
|
||||
update_search_status(state, val) {
|
||||
state.search_status = val
|
||||
},
|
||||
|
||||
update_errors(state, val) {
|
||||
state.errors = val
|
||||
},
|
||||
|
||||
update_dialog_packet(state, val) {
|
||||
state.dialog_packet = val
|
||||
},
|
||||
|
||||
update_default_mou(state, val) {
|
||||
state.default_mou = val
|
||||
},
|
||||
|
||||
update_default_company(state, val) {
|
||||
state.default_company = val
|
||||
},
|
||||
|
||||
update_auto_selected_packet_id(state, val) {
|
||||
state.auto_selected_packet_id = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search_company(context) {
|
||||
|
||||
try {
|
||||
let resp = await api.search_company(one_token(), context.state.query_company)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
|
||||
context.commit("update_companies", data)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
},
|
||||
|
||||
async search_mou(context) {
|
||||
|
||||
try {
|
||||
let resp = await api.search_mou(one_token(), context.state.selected_company.M_CompanyID, context.state.query_mou)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
|
||||
context.commit("update_mous", data)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
},
|
||||
|
||||
async search_default_mou(context) {
|
||||
|
||||
try {
|
||||
let resp = await api.search_default_mou()
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
|
||||
context.commit('update_default_mou', resp.data.mou)
|
||||
context.commit('update_default_company', resp.data.company)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
},
|
||||
|
||||
async search_packet(context) {
|
||||
|
||||
try {
|
||||
let resp = await api.search_packet(one_token(), context.state.selected_mou.M_MouID, context.state.selected_type, context.state.query_packet)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total,
|
||||
isverif: resp.data.isverif
|
||||
}
|
||||
|
||||
context.commit("update_packets", data)
|
||||
context.commit("update_isverif", data.isverif)
|
||||
|
||||
// Auto selected after save
|
||||
|
||||
console.log(context.state.auto_selected_packet_id)
|
||||
if (context.state.auto_selected_packet_id != 0) {
|
||||
for(let i in data.records)
|
||||
if (data.records[i].T_PacketID == context.state.auto_selected_packet_id) {
|
||||
context.commit('update_selected_packet', data.records[i])
|
||||
context.dispatch('px/search_px', null, {root:true})
|
||||
}
|
||||
|
||||
}else {
|
||||
context.commit('update_selected_packet', 0)
|
||||
context.commit('px/update_pxs',[] , {root:true})
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
},
|
||||
|
||||
async del_packet(context, id) {
|
||||
|
||||
try {
|
||||
let resp = await api.del_packet(one_token(), id)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
|
||||
context.dispatch('search_packet')
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
212
one-ui/agreement/one-md-packet-v8/modules/packet_copy.js
Normal file
212
one-ui/agreement/one-md-packet-v8/modules/packet_copy.js
Normal file
@@ -0,0 +1,212 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/packet.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
|
||||
search_status: 0,
|
||||
search_error_message: '',
|
||||
|
||||
query_company: '',
|
||||
companies: [],
|
||||
selected_company: {},
|
||||
total_company: 0,
|
||||
default_company: {},
|
||||
|
||||
query_mou: '',
|
||||
mous: [],
|
||||
selected_mou: null,
|
||||
total_mou: 0,
|
||||
default_mou: {},
|
||||
|
||||
query_packet: '',
|
||||
packets: [],
|
||||
selected_packet: null,
|
||||
total_packet: 0,
|
||||
|
||||
dialog_copy: false
|
||||
},
|
||||
mutations: {
|
||||
|
||||
update_search_error_message(state, patient) {
|
||||
state.search_error_message = patient
|
||||
},
|
||||
|
||||
// MOU
|
||||
update_query_mou(state, q) {
|
||||
state.query_mou = q
|
||||
},
|
||||
|
||||
update_mous(state, d) {
|
||||
state.mous = d.records
|
||||
state.total_mou = d.total
|
||||
},
|
||||
|
||||
update_selected_mou(state, d) {
|
||||
state.selected_mou = d
|
||||
},
|
||||
|
||||
// COMPANY
|
||||
update_query_company(state, q) {
|
||||
state.query_company = q
|
||||
},
|
||||
|
||||
update_companies(state, d) {
|
||||
state.companies = d.records
|
||||
state.total_company = d.total
|
||||
},
|
||||
|
||||
update_selected_company(state, d) {
|
||||
state.selected_company = d
|
||||
|
||||
// update mous
|
||||
if (d) {
|
||||
state.mous = d.mou
|
||||
state.selected_mou = {}
|
||||
state.total_mou = d.mou.length
|
||||
} else {
|
||||
state.mous = []
|
||||
state.selected_mou = {}
|
||||
state.total_mou = 0
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
// PRICE
|
||||
update_query_packet(state, q) {
|
||||
state.query_packet = q
|
||||
},
|
||||
|
||||
update_packets(state, d) {
|
||||
state.packets = d.records
|
||||
state.total_packet = d.total
|
||||
},
|
||||
|
||||
update_selected_packet(state, d) {
|
||||
state.selected_packet = d
|
||||
},
|
||||
|
||||
update_search_status(state, val) {
|
||||
state.search_status = val
|
||||
},
|
||||
|
||||
update_errors(state, val) {
|
||||
state.errors = val
|
||||
},
|
||||
|
||||
update_dialog_copy(state, val) {
|
||||
state.dialog_copy = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search_company(context) {
|
||||
|
||||
try {
|
||||
let resp = await api.search_company(one_token(), context.state.query_company)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
|
||||
context.commit("update_companies", data)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
},
|
||||
|
||||
async search_mou(context) {
|
||||
|
||||
try {
|
||||
let resp = await api.search_mou(one_token(), context.state.selected_company.M_CompanyID, context.state.query_mou)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
|
||||
context.commit("update_mous", data)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
},
|
||||
|
||||
async search_packet(context) {
|
||||
|
||||
try {
|
||||
let resp = await api.search_packet(one_token(), context.state.selected_mou.M_MouID, context.rootState.packet.selected_packet.T_PacketType, context.state.query_packet, true)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
|
||||
context.commit("update_packets", data)
|
||||
|
||||
// Auto selected after save
|
||||
if (context.state.auto_selected_packet_id) {
|
||||
for(let i in data.records)
|
||||
if (data.records[i].T_PacketID == context.state.auto_selected_packet_id)
|
||||
context.commit('update_selected_packet', data.records[i])
|
||||
}
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
},
|
||||
|
||||
async save_copy(context) {
|
||||
|
||||
try {
|
||||
let source_id = context.state.selected_packet.T_PacketID
|
||||
let target_id = context.rootState.packet.selected_packet.T_PacketID
|
||||
|
||||
let resp = await api.save_copy(one_token(), source_id, target_id)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
|
||||
context.commit('update_dialog_copy', false)
|
||||
context.dispatch('px/search_px', null, {root:true})
|
||||
|
||||
let x = context.rootState.packet.selected_packet
|
||||
x.T_PacketPrice = resp.data.packet_price
|
||||
x.T_PacketOriginalPrice = resp.data.total_price
|
||||
|
||||
context.commit('packet/update_selected_packet', x, {root:true})
|
||||
context.commit('test/update_state_add', false, {root:true})
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
168
one-ui/agreement/one-md-packet-v8/modules/packet_new.js
Normal file
168
one-ui/agreement/one-md-packet-v8/modules/packet_new.js
Normal file
@@ -0,0 +1,168 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/packet.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
|
||||
search_status: 0,
|
||||
search_error_message: '',
|
||||
|
||||
query_company: '',
|
||||
companies: [],
|
||||
selected_company: {},
|
||||
total_company: 0,
|
||||
|
||||
query_mou: '',
|
||||
mous: [],
|
||||
selected_mou: {},
|
||||
total_mou: 0,
|
||||
|
||||
total_packet: 0,
|
||||
new_packet: { amount:0, disc:0, discrp:0, sub_total:0, other:0, total:0, cito:'N'},
|
||||
edit_packet: false,
|
||||
dialog_packet: false,
|
||||
|
||||
state_edit: false,
|
||||
in_saving: false
|
||||
},
|
||||
mutations: {
|
||||
update_in_saving(state, val) {
|
||||
state.in_saving = val
|
||||
},
|
||||
update_search_error_message(state, patient) {
|
||||
state.search_error_message = patient
|
||||
},
|
||||
|
||||
// MOU
|
||||
update_query_mou(state, q) {
|
||||
state.query_mou = q
|
||||
},
|
||||
|
||||
update_mous(state, d) {
|
||||
state.mous = d.records
|
||||
state.total_mou = d.total
|
||||
},
|
||||
|
||||
update_selected_mou(state, d) {
|
||||
state.selected_mou = d
|
||||
},
|
||||
|
||||
// COMPANY
|
||||
update_query_company(state, q) {
|
||||
state.query_company = q
|
||||
},
|
||||
|
||||
update_companies(state, d) {
|
||||
state.companies = d.records
|
||||
state.total_company = d.total
|
||||
},
|
||||
|
||||
update_selected_company(state, d) {
|
||||
state.selected_company = d
|
||||
|
||||
// update mous
|
||||
state.mous = d.mou
|
||||
state.selected_mou = {}
|
||||
state.total_mou = (d.mou ? d.mou.length : 0)
|
||||
},
|
||||
|
||||
update_search_status(state, val) {
|
||||
state.search_status = val
|
||||
},
|
||||
|
||||
update_errors(state, val) {
|
||||
state.errors = val
|
||||
},
|
||||
|
||||
update_dialog_packet(state, val) {
|
||||
state.dialog_packet = val
|
||||
},
|
||||
|
||||
update_state_edit(state, val) {
|
||||
state.state_edit = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search_company(context) {
|
||||
|
||||
try {
|
||||
let resp = await api.search_company(one_token(), context.state.query_company)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
|
||||
context.commit("update_companies", data)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
},
|
||||
|
||||
async search_mou(context) {
|
||||
|
||||
try {
|
||||
let resp = await api.search_mou(one_token(), context.state.selected_company.M_CompanyID, context.state.query_mou)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
|
||||
context.commit("update_mous", data)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
},
|
||||
|
||||
async save(context, data) {
|
||||
|
||||
try {
|
||||
let resp
|
||||
if (data.edit)
|
||||
resp = await api.save(one_token(), JSON.stringify(data), true)
|
||||
else
|
||||
resp = await api.save(one_token(), JSON.stringify(data))
|
||||
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
|
||||
context.dispatch("packet/search_packet", null, {root:true})
|
||||
context.commit('update_dialog_packet', false)
|
||||
|
||||
context.commit('packet/update_auto_selected_packet_id', resp.data, {root:true})
|
||||
context.commit("packet/update_query_company", context.state.selected_company.M_CompanyName, {root:true})
|
||||
context.commit('packet/update_companies', {records:[context.state.selected_company], total:1}, {root:true})
|
||||
context.commit('packet/update_selected_company', context.state.selected_company, {root:true})
|
||||
context.commit('packet/update_selected_mou', context.state.selected_mou, {root:true})
|
||||
context.dispatch('packet/search_packet', null, {root:true})
|
||||
context.commit("update_in_saving", false)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
166
one-ui/agreement/one-md-packet-v8/modules/px.js
Normal file
166
one-ui/agreement/one-md-packet-v8/modules/px.js
Normal file
@@ -0,0 +1,166 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/px.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
|
||||
search_status: 0,
|
||||
search_error_message: '',
|
||||
|
||||
query_px: '',
|
||||
pxs: [],
|
||||
selected_px: {},
|
||||
total_px: 0,
|
||||
|
||||
packet_price: 0,
|
||||
estimate_total_price: 0,
|
||||
|
||||
nat_tests: []
|
||||
},
|
||||
mutations: {
|
||||
|
||||
update_search_error_message(state, patient) {
|
||||
state.search_error_message = patient
|
||||
},
|
||||
|
||||
|
||||
// PX
|
||||
update_query_px(state, q) {
|
||||
state.query_px = q
|
||||
},
|
||||
|
||||
update_pxs(state, d) {
|
||||
state.pxs = d.records
|
||||
state.total_px = d.total
|
||||
},
|
||||
|
||||
update_selected_px(state, d) {
|
||||
state.selected_px = d
|
||||
},
|
||||
|
||||
update_search_status(state, val) {
|
||||
state.search_status = val
|
||||
},
|
||||
|
||||
update_errors(state, val) {
|
||||
state.errors = val
|
||||
},
|
||||
|
||||
update_estimate_total_price(state, v) {
|
||||
state.estimate_total_price = v
|
||||
},
|
||||
|
||||
update_packet_price(state, v) {
|
||||
state.packet_price = v
|
||||
},
|
||||
|
||||
update_nat_tests(state, v) {
|
||||
state.nat_tests = v
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search_px(context) {
|
||||
try {
|
||||
// Set loading state
|
||||
context.commit("update_search_status", 1)
|
||||
|
||||
let packet = context.rootState.packet.selected_packet
|
||||
console.log(packet)
|
||||
let resp = await api.search(one_token(), packet.T_PacketID, context.state.query_px)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
|
||||
context.commit("update_pxs", data)
|
||||
|
||||
// Calculate and set estimate_total_price (BRUTO) from loaded data
|
||||
// Use T_PacketOriginalBruto from packet if available, otherwise calculate from details
|
||||
let totalBruto = 0;
|
||||
if (packet.T_PacketOriginalBruto && parseFloat(packet.T_PacketOriginalBruto) > 0) {
|
||||
totalBruto = parseFloat(packet.T_PacketOriginalBruto);
|
||||
} else {
|
||||
// Calculate from detail records
|
||||
for (let i in resp.data.records) {
|
||||
totalBruto += parseFloat(resp.data.records[i].T_PacketDetailPriceAmount)
|
||||
|| parseFloat(resp.data.records[i].T_PriceAmount)
|
||||
|| 0;
|
||||
}
|
||||
}
|
||||
context.commit("update_estimate_total_price", totalBruto)
|
||||
|
||||
// Set packet price (NETTO) from T_PacketPrice
|
||||
let packetPrice = parseFloat(packet.T_PacketPrice) || 0;
|
||||
context.commit("update_packet_price", packetPrice)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
},
|
||||
|
||||
async save_px(context) {
|
||||
try {
|
||||
// Set loading state
|
||||
context.commit("update_search_status", 1)
|
||||
|
||||
let packet = context.rootState.packet.selected_packet
|
||||
let packet_id = packet.T_PacketID
|
||||
let packet_price = packet.T_PacketPrice
|
||||
let packet_original_price = packet.T_PacketOriginalPrice
|
||||
|
||||
let pxs = context.state.pxs
|
||||
console.log('=== SAVING PXS DATA ===', pxs)
|
||||
let json_px = []
|
||||
for (let i in pxs) {
|
||||
// Use the correct field names that match the UI component
|
||||
// T_PacketDetail* fields are what we use in the UI
|
||||
// Use explicit checks with hasOwnProperty or !== undefined to handle 0 values correctly
|
||||
let testDisc = (pxs[i].T_PacketDetailPriceDisc !== undefined && pxs[i].T_PacketDetailPriceDisc !== null)
|
||||
? parseFloat(pxs[i].T_PacketDetailPriceDisc)
|
||||
: (pxs[i].T_PriceDisc !== undefined ? parseFloat(pxs[i].T_PriceDisc) : 0);
|
||||
|
||||
let testDiscRp = (pxs[i].T_PacketDetailPriceDiscRp !== undefined && pxs[i].T_PacketDetailPriceDiscRp !== null)
|
||||
? parseFloat(pxs[i].T_PacketDetailPriceDiscRp)
|
||||
: (pxs[i].T_PriceDiscRp !== undefined ? parseFloat(pxs[i].T_PriceDiscRp) : 0);
|
||||
|
||||
json_px.push({
|
||||
test_id: pxs[i].T_TestID,
|
||||
test_price: pxs[i].T_PacketDetailPrice || pxs[i].T_PriceTotal, // Final price after discounts
|
||||
test_disc: testDisc, // Percentage discount (handles 0 correctly)
|
||||
test_discrp: testDiscRp, // Rupiah discount (handles 0 correctly)
|
||||
test_subtotal: pxs[i].T_PacketDetailPriceSubTotal || pxs[i].T_PriceSubTotal, // Subtotal = price
|
||||
test_bruto: pxs[i].T_PacketDetailPriceAmount || pxs[i].T_PriceAmount // Original bruto price
|
||||
})
|
||||
}
|
||||
console.log('=== JSON PX TO SAVE ===', json_px)
|
||||
json_px = JSON.stringify(json_px)
|
||||
|
||||
let resp = await api.save(one_token(), packet_id, packet_price, packet_original_price, json_px)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
|
||||
// DON'T auto-exit add mode
|
||||
// Let user click "Kembali" button to exit
|
||||
// context.commit("test/update_state_add", false, {root:true})
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
107
one-ui/agreement/one-md-packet-v8/modules/test.js
Normal file
107
one-ui/agreement/one-md-packet-v8/modules/test.js
Normal file
@@ -0,0 +1,107 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/packet.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
|
||||
search_status: 0,
|
||||
search_error_message: '',
|
||||
|
||||
query_test: '',
|
||||
tests: [],
|
||||
selected_test: {},
|
||||
total_test: 0,
|
||||
|
||||
company_id: 0,
|
||||
mou_id: 0,
|
||||
|
||||
state_add: false,
|
||||
exclude: [],
|
||||
include: []
|
||||
},
|
||||
mutations: {
|
||||
update_search_error_message(state, patient) {
|
||||
state.search_error_message = patient
|
||||
},
|
||||
|
||||
// PRICE
|
||||
update_query_test(state, q) {
|
||||
state.query_test = q
|
||||
},
|
||||
|
||||
update_tests(state, d) {
|
||||
state.tests = d.records
|
||||
state.total_test = d.total
|
||||
},
|
||||
|
||||
update_selected_test(state, d) {
|
||||
state.selected_test = d
|
||||
},
|
||||
|
||||
update_search_status(state, val) {
|
||||
state.search_status = val
|
||||
},
|
||||
|
||||
update_errors(state, val) {
|
||||
state.errors = val
|
||||
},
|
||||
|
||||
update_company_id(state, val) {
|
||||
state.company_id = val
|
||||
},
|
||||
|
||||
update_mou_id(state, val) {
|
||||
state.mou_id = val
|
||||
},
|
||||
|
||||
update_state_add(state, val) {
|
||||
state.state_add = val
|
||||
if (val) {
|
||||
state.exclude = []
|
||||
state.include = []
|
||||
}
|
||||
},
|
||||
|
||||
update_exclude(state, val) {
|
||||
state.exclude = val
|
||||
},
|
||||
|
||||
update_include(state, val) {
|
||||
state.include = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search_test(context) {
|
||||
try {
|
||||
// Set loading state
|
||||
context.commit("update_search_status", 1)
|
||||
|
||||
let mou = context.rootState.packet.selected_mou.M_MouID
|
||||
let x = context.rootState.packet.selected_packet.T_PacketType
|
||||
// if (x == "PN")
|
||||
// mou = context.rootState.packet.default_mou.M_MouID
|
||||
|
||||
let resp = await api.search_test(mou, context.rootState.packet.selected_packet.T_PacketID, context.state.query_test, context.state.exclude.join(','), context.state.include.join(','))
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status", 2)
|
||||
context.commit("update_search_error_message", "")
|
||||
let data = {
|
||||
records: resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
|
||||
context.commit("update_tests", data)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user