Flatten nested repos
This commit is contained in:
194
test/vuex/one-fo-registration-dev/modules/area.js
Normal file
194
test/vuex/one-fo-registration-dev/modules/area.js
Normal file
@@ -0,0 +1,194 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/area.js"
|
||||
window.api = api
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search: '',
|
||||
search_status:0,
|
||||
search_error_message:'',
|
||||
search_dialog_is_active: false,
|
||||
|
||||
provinces: [],
|
||||
cities: [],
|
||||
districts: [],
|
||||
villages: [],
|
||||
|
||||
total_provinces: 0,
|
||||
total_cities: 0,
|
||||
total_districts: 0,
|
||||
total_villages: 0,
|
||||
|
||||
total_display: 0,
|
||||
|
||||
selected_province: {},
|
||||
selected_city: {},
|
||||
selected_district: {},
|
||||
selected_village: {}
|
||||
},
|
||||
mutations: {
|
||||
update_search_dialog_is_active(state,status) {
|
||||
state.search_dialog_is_active = status
|
||||
},
|
||||
update_search_error_message(state,status) {
|
||||
state.search_error_message = status
|
||||
},
|
||||
|
||||
update_search(state,val) {
|
||||
state.search=val
|
||||
},
|
||||
|
||||
update_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
|
||||
update_area(state, data) {
|
||||
state[data.type] = data.records
|
||||
state['total_'+data.type] = data.total
|
||||
state.total_display = data.total_display
|
||||
|
||||
if (["provinces", "districts", "villages"].indexOf(data.type) > -1)
|
||||
state['selected_'+ data.type.substring(0, data.type.length-1) ] = null
|
||||
else if (data.type == "cities")
|
||||
state['selected_city'] = null
|
||||
|
||||
for (let i in data.records) {
|
||||
if (data.records[i].is_default == "Y") {
|
||||
|
||||
if (["provinces", "districts", "villages"].indexOf(data.type) > -1)
|
||||
state['selected_'+ data.type.substring(0, data.type.length-1) ] = data.records[i]
|
||||
|
||||
else if (data.type == "cities")
|
||||
state['selected_city'] = data.records[i]
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
update_selected_area(state, val) {
|
||||
state['selected_'+val.type] = val.val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search_province(context) {
|
||||
context.commit("update_search_status", 1)
|
||||
context.commit("update_area", {records:[], total:0, total_display:0, type:'city'})
|
||||
context.commit("update_area", {records:[], total:0, total_display:0, type:'district'})
|
||||
context.commit("update_area", {records:[], total:0, total_display:0, type:'village'})
|
||||
context.commit("update_selected_area", {type:'city',val:null})
|
||||
context.commit("update_selected_area", {type:'district',val:null})
|
||||
context.commit("update_selected_area", {type:'village',val:null})
|
||||
try {
|
||||
let resp = await api.search_province(context.state.search)
|
||||
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,
|
||||
total_display: resp.data.total_display,
|
||||
type: 'provinces'
|
||||
}
|
||||
context.commit("update_area", data)
|
||||
context.dispatch("search_city")
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async search_city(context) {
|
||||
// City
|
||||
context.commit("update_search_status", 1)
|
||||
context.commit("update_area", {records:[], total:0, total_display:0, type:'district'})
|
||||
context.commit("update_area", {records:[], total:0, total_display:0, type:'village'})
|
||||
context.commit("update_selected_area", {type:'district',val:null})
|
||||
context.commit("update_selected_area", {type:'village',val:null})
|
||||
try {
|
||||
let resp = await api.search_city(context.state.selected_province.M_ProvinceID, context.state.search)
|
||||
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,
|
||||
total_display: resp.data.total_display,
|
||||
type: 'cities'
|
||||
}
|
||||
context.commit("update_area", data)
|
||||
context.commit("update_search_status", 1)
|
||||
context.dispatch("search_district")
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message", e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async search_district(context) {
|
||||
// City
|
||||
context.commit("update_search_status", 1)
|
||||
context.commit("update_area", {records:[], total:0, total_display:0, type:'village'})
|
||||
context.commit("update_selected_area", {type:'village',val:null})
|
||||
try {
|
||||
let resp = await api.search_district(context.state.selected_city.M_CityID, context.state.search)
|
||||
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,
|
||||
total_display: resp.data.total_display,
|
||||
type: 'districts'
|
||||
}
|
||||
context.commit("update_area", data)
|
||||
context.commit("update_search_status", 1)
|
||||
context.dispatch("search_kelurahan")
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message", e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async search_kelurahan(context) {
|
||||
// City
|
||||
context.commit("update_search_status", 1)
|
||||
try {
|
||||
let resp = await api.search_kelurahan(context.state.selected_district.M_DistrictID, context.state.search)
|
||||
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,
|
||||
total_display: resp.data.total_display,
|
||||
type: 'villages'
|
||||
}
|
||||
|
||||
context.commit("update_area", data)
|
||||
context.commit("update_search_status", 1)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message", e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
128
test/vuex/one-fo-registration-dev/modules/company.js
Normal file
128
test/vuex/one-fo-registration-dev/modules/company.js
Normal file
@@ -0,0 +1,128 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/company.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search: '',
|
||||
search_status:0,
|
||||
search_error_message:'',
|
||||
companies: [],
|
||||
total_company: 0,
|
||||
selected_company: {},
|
||||
selected_mou: {},
|
||||
|
||||
selected_px_tab: 'px'
|
||||
},
|
||||
mutations: {
|
||||
update_selected_px_tab(state,tab) {
|
||||
state.selected_px_tab = tab
|
||||
},
|
||||
|
||||
|
||||
update_search_error_message(state,status) {
|
||||
state.search_error_message = status
|
||||
},
|
||||
update_selected_mou(state,val) {
|
||||
state.selected_mou = val
|
||||
},
|
||||
update_search(state,val) {
|
||||
state.search=val
|
||||
},
|
||||
update_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
update_companies(state,data) {
|
||||
state.companies= data.records
|
||||
state.total_company= data.total
|
||||
},
|
||||
update_selected_company(state,val) {
|
||||
state.selected_company=val
|
||||
},
|
||||
|
||||
reset_company(state) {
|
||||
state.companies = []
|
||||
state.total_company = 0
|
||||
state.search = ""
|
||||
state.selected_company = {}
|
||||
state.selected_mou = {}
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context, prm) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search(context.state.search)
|
||||
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_default(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search_default()
|
||||
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)
|
||||
context.commit("update_selected_company", data.records[0])
|
||||
|
||||
for(let i in data.records[0].mou) {
|
||||
let cmou = data.records[0].mou[i]
|
||||
if (cmou.M_MouIsDefault == "Y") {
|
||||
context.commit("update_selected_mou", cmou)
|
||||
|
||||
if (cmou.M_MouEmail != "" && cmou.M_MouEmailIsDefault == "Y") {
|
||||
let dlv = context.rootState.delivery.checked_id
|
||||
// if (dlv == undefined) dlv = []
|
||||
|
||||
if (dlv.indexOf(cmou.delivery_email_code) < 0) {
|
||||
|
||||
// console.log(cid)
|
||||
dlv.push(cmou.delivery_email_code)
|
||||
console.log(dlv)
|
||||
context.commit('delivery/update_checked_id', dlv, {root:true})
|
||||
}
|
||||
}
|
||||
|
||||
context.commit("delivery/update_params", {m_id:cmou.M_MouID}, {root:true})
|
||||
context.dispatch("delivery/search", null, {root:true})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// search px
|
||||
context.dispatch('px/search', null, {root:true})
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
87
test/vuex/one-fo-registration-dev/modules/delivery.js
Normal file
87
test/vuex/one-fo-registration-dev/modules/delivery.js
Normal file
@@ -0,0 +1,87 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/delivery.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search_status:0,
|
||||
search_error_message:'',
|
||||
deliveries: [],
|
||||
patient_id: 0,
|
||||
doctor_id: 0,
|
||||
order_id: 0,
|
||||
mou_id: 0,
|
||||
|
||||
checked_id: []
|
||||
},
|
||||
mutations: {
|
||||
update_search_error_message(state,status) {
|
||||
state.search_error_message = status
|
||||
},
|
||||
update_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
update_deliveries(state,data) {
|
||||
for (var i in data) {
|
||||
if (state.checked_id.indexOf(data[i].idx) > -1)
|
||||
data[i].selected = true
|
||||
else
|
||||
data[i].selected = false
|
||||
}
|
||||
|
||||
state.deliveries = data
|
||||
},
|
||||
update_deliveries_2(state) {
|
||||
for (var i in state.deliveries) {
|
||||
if (state.checked_id.indexOf(state.deliveries[i].idx) > -1)
|
||||
state.deliveries[i].selected = true
|
||||
else
|
||||
state.deliveries[i].selected = false
|
||||
}
|
||||
// state.deliveries= data
|
||||
},
|
||||
update_selected_delivery(state,val) {
|
||||
state.selected_delivery=val
|
||||
},
|
||||
update_params(state, val) {
|
||||
if (typeof val.p_id !== 'undefined')
|
||||
state.patient_id = val.p_id;
|
||||
if (typeof val.o_id !== 'undefined')
|
||||
state.order_id = val.o_id;
|
||||
if (typeof val.d_id !== 'undefined')
|
||||
state.doctor_id = val.d_id;
|
||||
if (typeof val.m_id !== 'undefined')
|
||||
state.mou_id = val.m_id;
|
||||
},
|
||||
update_checked_id(state, val) {
|
||||
state.checked_id = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search(context.state.order_id,
|
||||
context.state.patient_id,
|
||||
context.state.doctor_id,
|
||||
context.state.mou_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","")
|
||||
let data = {
|
||||
records : resp.data.records
|
||||
}
|
||||
context.commit("update_deliveries",data.records)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
121
test/vuex/one-fo-registration-dev/modules/doctor.js
Normal file
121
test/vuex/one-fo-registration-dev/modules/doctor.js
Normal file
@@ -0,0 +1,121 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/doctor.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search : '',
|
||||
search_status: 0,
|
||||
search_error_message: "",
|
||||
doctors: [],
|
||||
total_doctor: 0,
|
||||
selected_doctor: {},
|
||||
selected_address: {},
|
||||
|
||||
doctors_pj: [],
|
||||
selected_doctor_pj : {},
|
||||
search_pj_status: 0,
|
||||
search_pj_error_message: "",
|
||||
|
||||
mounted: 0
|
||||
},
|
||||
mutations: {
|
||||
update_search(state,val) {
|
||||
state.search=val
|
||||
},
|
||||
update_search_error_message(state,status) {
|
||||
state.search_error_message = status
|
||||
},
|
||||
update_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
update_doctors(state,data) {
|
||||
state.doctors = data.records
|
||||
state.total_doctor= data.total
|
||||
},
|
||||
update_selected_doctor(state, doc) {
|
||||
state.selected_doctor= doc
|
||||
|
||||
if (!doc) return
|
||||
state.selected_address = null
|
||||
|
||||
if (doc.address)
|
||||
if (doc.address.length> 0) {
|
||||
state.selected_address = doc.address[0]
|
||||
}
|
||||
},
|
||||
update_selected_address(state,addr) {
|
||||
state.selected_address = addr
|
||||
},
|
||||
update_search_pj_error_message(state,status) {
|
||||
state.search_pj_error_message = status
|
||||
},
|
||||
update_search_pj_status(state,status) {
|
||||
state.search_pj_status = status
|
||||
},
|
||||
update_doctors_pj(state,data) {
|
||||
state.doctors_pj = data.records
|
||||
let flag_found = false
|
||||
data.records.forEach(function(d) {
|
||||
if (d.M_DoctorIsDefaultPJ == 'Y' ) {
|
||||
state.selected_doctor_pj = d
|
||||
flag_found = true
|
||||
}
|
||||
})
|
||||
if (! flag_found & data.records.length > 0 ) state.selected_doctor_pj = data.records[0]
|
||||
},
|
||||
update_selected_doctor_pj(state,doc) {
|
||||
state.selected_doctor_pj = doc
|
||||
},
|
||||
|
||||
increment_mounted(state, n) {
|
||||
state.mounted = state.mounted + n;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search_pj(context) {
|
||||
context.commit("update_search_pj_status",1)
|
||||
try {
|
||||
let resp= await api.searchPj()
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_pj_status",3)
|
||||
context.commit("update_search_pj_error_message",resp.message)
|
||||
} else {
|
||||
context.commit("update_search_pj_status",2)
|
||||
context.commit("update_search_pj_error_message","")
|
||||
let data = {
|
||||
total : resp.data.total,
|
||||
records : resp.data.records
|
||||
}
|
||||
context.commit("update_doctors_pj",data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_pj_status",3)
|
||||
context.commit("update_search_pj_error_message",e.message )
|
||||
}
|
||||
},
|
||||
async search(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search(context.state.search)
|
||||
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 = {
|
||||
total : resp.data.total,
|
||||
records : resp.data.records
|
||||
}
|
||||
context.commit("update_doctors", data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
283
test/vuex/one-fo-registration-dev/modules/doctor_new.js
Normal file
283
test/vuex/one-fo-registration-dev/modules/doctor_new.js
Normal file
@@ -0,0 +1,283 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/doctor.js"
|
||||
import * as area from "../api/area.js"
|
||||
import * as other from "../api/other.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search : '',
|
||||
search_status: 0,
|
||||
search_error_message: "",
|
||||
|
||||
sexs: [],
|
||||
selected_sex: null,
|
||||
param_name: '',
|
||||
param_prefix1: '',
|
||||
param_prefix2: '',
|
||||
param_sufix1: '',
|
||||
param_sufix2: '',
|
||||
param_sufix3: '',
|
||||
param_hp: '',
|
||||
param_address: '',
|
||||
|
||||
provinces: [],
|
||||
selected_province: null,
|
||||
cities: [],
|
||||
selected_city: null,
|
||||
districts: [],
|
||||
selected_district: null,
|
||||
villages: [],
|
||||
selected_village: null,
|
||||
dialog_new: false,
|
||||
|
||||
adhoc: false
|
||||
},
|
||||
|
||||
mutations: {
|
||||
update_search(state,val) {
|
||||
state.search=val
|
||||
},
|
||||
|
||||
update_search_error_message(state,status) {
|
||||
state.search_error_message = status
|
||||
},
|
||||
|
||||
update_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
|
||||
update_dialog_new(state, d) {
|
||||
state.dialog_new = d
|
||||
},
|
||||
|
||||
update_sexs(state, d) {
|
||||
state.sexs = d.records
|
||||
},
|
||||
|
||||
update_selected_sex(state, d) {
|
||||
state.selected_sex = d
|
||||
},
|
||||
|
||||
update_provinces(state, d) {
|
||||
state.provinces = d.records
|
||||
state.cities = []
|
||||
state.districts = []
|
||||
state.villages = []
|
||||
state.selected_city = null
|
||||
state.selected_district = null
|
||||
state.selected_village = null
|
||||
|
||||
for (let i in d.records)
|
||||
if (d.records[i].is_default == "Y")
|
||||
state.selected_province = d.records[i]
|
||||
},
|
||||
|
||||
update_selected_province(state, d) {
|
||||
state.selected_province = d
|
||||
},
|
||||
|
||||
update_districts(state, d) {
|
||||
state.districts = d.records
|
||||
state.villages = []
|
||||
state.selected_village = null
|
||||
|
||||
for (let i in d.records)
|
||||
if (d.records[i].is_default == "Y")
|
||||
state.selected_district = d.records[i]
|
||||
},
|
||||
|
||||
update_selected_district(state, d) {
|
||||
state.selected_district = d
|
||||
},
|
||||
|
||||
update_cities(state, d) {
|
||||
state.cities = d.records
|
||||
state.districts = []
|
||||
state.villages = []
|
||||
state.selected_district = null
|
||||
state.selected_village = null
|
||||
|
||||
for (let i in d.records)
|
||||
if (d.records[i].is_default == "Y")
|
||||
state.selected_city = d.records[i]
|
||||
},
|
||||
|
||||
update_selected_city(state, d) {
|
||||
state.selected_city = d
|
||||
},
|
||||
|
||||
update_villages(state, d) {
|
||||
state.villages = d.records
|
||||
|
||||
for (let i in d.records)
|
||||
if (d.records[i].is_default == "Y")
|
||||
state.selected_village = d.records[i]
|
||||
},
|
||||
|
||||
update_selected_village(state, d) {
|
||||
state.selected_village = d
|
||||
},
|
||||
|
||||
update_param(state, d) {
|
||||
state['param_'+d.param] = d.val
|
||||
},
|
||||
|
||||
update_adhoc(state, d) {
|
||||
state.adhoc = d
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async save(context) {
|
||||
context.commit('update_search_status', 1)
|
||||
try {
|
||||
let d = {
|
||||
name: context.state.param_name,
|
||||
prefix1: context.state.param_prefix1,
|
||||
prefix2: context.state.param_prefix2,
|
||||
sufix1: context.state.param_sufix1,
|
||||
sufix2: context.state.param_sufix2,
|
||||
sufix3: context.state.param_sufix3,
|
||||
sex: context.state.selected_sex.M_SexID,
|
||||
hp: context.state.param_hp,
|
||||
address: context.state.param_address,
|
||||
village: context.state.selected_village.M_KelurahanID
|
||||
}
|
||||
|
||||
let resp = await api.save(one_token(), d)
|
||||
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_adhoc', true)
|
||||
context.commit('doctor/update_doctors', data, {root:true})
|
||||
context.commit('doctor/update_search', data.records[0].M_DoctorRealName, {root:true})
|
||||
context.commit('doctor/update_selected_doctor', data.records[0], {root:true})
|
||||
context.commit('delivery/update_params', {d_id:data.records[0].M_DoctorID}, {root:true})
|
||||
context.dispatch('delivery/search', null, {root:true})
|
||||
|
||||
context.commit('update_dialog_new', false)
|
||||
context.commit('update_dialog_loading', false, {root:true})
|
||||
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
|
||||
async search_sex(context) {
|
||||
context.commit('update_search_status', 1)
|
||||
try {
|
||||
let resp = await other.search_sex()
|
||||
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
|
||||
}
|
||||
|
||||
context.commit('update_sexs', data)
|
||||
}
|
||||
} catch(e) {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
async search_province(context) {
|
||||
context.commit('update_search_status', 1)
|
||||
try {
|
||||
let resp = await area.search_province()
|
||||
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
|
||||
}
|
||||
|
||||
context.commit('update_provinces', data)
|
||||
}
|
||||
} catch(e) {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
async search_city(context) {
|
||||
context.commit('update_search_status', 1)
|
||||
try {
|
||||
let resp = await area.search_city(context.state.selected_province.M_ProvinceID)
|
||||
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
|
||||
}
|
||||
|
||||
context.commit('update_cities', data)
|
||||
}
|
||||
} catch(e) {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
async search_district(context) {
|
||||
context.commit('update_search_status', 1)
|
||||
try {
|
||||
let resp = await area.search_district(context.state.selected_city.M_CityID)
|
||||
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
|
||||
}
|
||||
|
||||
context.commit('update_districts', data)
|
||||
}
|
||||
} catch(e) {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
async search_village(context) {
|
||||
context.commit('update_search_status', 1)
|
||||
try {
|
||||
let resp = await area.search_kelurahan(context.state.selected_district.M_DistrictID)
|
||||
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
|
||||
}
|
||||
|
||||
context.commit('update_villages', data)
|
||||
}
|
||||
} catch(e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
69
test/vuex/one-fo-registration-dev/modules/history.js
Normal file
69
test/vuex/one-fo-registration-dev/modules/history.js
Normal file
@@ -0,0 +1,69 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/history.js"
|
||||
window.api = api
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
noreg:'',
|
||||
search: '',
|
||||
search_status:0,
|
||||
search_error_message:'',
|
||||
search_dialog_is_active: false,
|
||||
histories: [],
|
||||
|
||||
history_dialog: false
|
||||
},
|
||||
mutations: {
|
||||
update_search_dialog_is_active(state,status) {
|
||||
state.search_dialog_is_active = status
|
||||
},
|
||||
|
||||
update_search_error_message(state,status) {
|
||||
state.search_error_message = status
|
||||
},
|
||||
|
||||
update_search(state,val) {
|
||||
state.search=val
|
||||
},
|
||||
|
||||
update_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
|
||||
update_histories(state, data) {
|
||||
state.histories = data.records
|
||||
},
|
||||
|
||||
update_history_dialog(state, v) {
|
||||
state.history_dialog = v
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp = await api.search(context.rootState.patient.selected_patient.M_PatientID)
|
||||
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
|
||||
}
|
||||
context.commit("update_histories", data)
|
||||
|
||||
// commit("patientaddress/test", "X", { root: true })
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
59
test/vuex/one-fo-registration-dev/modules/language.js
Normal file
59
test/vuex/one-fo-registration-dev/modules/language.js
Normal file
@@ -0,0 +1,59 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/language.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search_status:0,
|
||||
search_error_message:'',
|
||||
languages: [],
|
||||
selected_language: {},
|
||||
selected_language_2: null
|
||||
},
|
||||
mutations: {
|
||||
update_search_error_message(state,status) {
|
||||
state.search_error_message = status
|
||||
},
|
||||
|
||||
update_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
|
||||
update_languages(state,data) {
|
||||
state.languages= data.records
|
||||
if (data.records.length > 0) state.selected_language = data.records[0]
|
||||
},
|
||||
|
||||
update_selected_language(state, val) {
|
||||
state.selected_language = val
|
||||
},
|
||||
|
||||
update_selected_language_2(state, val) {
|
||||
state.selected_language_2 = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search()
|
||||
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
|
||||
}
|
||||
context.commit("update_languages",data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
331
test/vuex/one-fo-registration-dev/modules/order.js
Normal file
331
test/vuex/one-fo-registration-dev/modules/order.js
Normal file
@@ -0,0 +1,331 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/order.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
order_id: 0,
|
||||
queue: "",
|
||||
is_from_clinic: false,
|
||||
|
||||
catatan_fo:'',
|
||||
diagnosa:'',
|
||||
patient_note: '',
|
||||
|
||||
finish_dialog_is_active: false,
|
||||
current_order: {},
|
||||
|
||||
received_sample: 'N',
|
||||
|
||||
tabs : [
|
||||
{"label":"DEMOGRAFI", "icon":"opacity", "code":"01", "enabled":true},
|
||||
{"label":"PEMERIKSAAN", "icon":"verified_user", "code":"02", "enabled":true},
|
||||
{"label":"PEMBAYARAN", "icon":"motorcycle", "code":"03", "enabled":true}
|
||||
],
|
||||
|
||||
print_dialog_is_active: false,
|
||||
rpt_url: window.BASE_URL + '/one-ui/test/vuex/common/under-cons.pdf'
|
||||
},
|
||||
mutations: {
|
||||
update_patient_note(state,val) {
|
||||
state.patient_note=val
|
||||
},
|
||||
update_catatan_fo(state,val) {
|
||||
state.catatan_fo=val
|
||||
},
|
||||
update_diagnosa(state,val) {
|
||||
state.diagnosa=val
|
||||
},
|
||||
update_finish_dialog_is_active(state, val) {
|
||||
state.finish_dialog_is_active = val
|
||||
},
|
||||
update_current_order(state, val) {
|
||||
state.current_order = val
|
||||
},
|
||||
|
||||
update_received_sample(state, val) {
|
||||
state.received_sample = val
|
||||
},
|
||||
|
||||
update_tab_enable(state, v) {
|
||||
state.tabs[v[0]].enabled = v[1]
|
||||
},
|
||||
|
||||
update_from_clinic(state, v) {
|
||||
state.is_from_clinic = v
|
||||
},
|
||||
|
||||
update_queue(state, v) {
|
||||
state.queue = v
|
||||
},
|
||||
|
||||
update_order_id(state, v) {
|
||||
state.order_id = v
|
||||
},
|
||||
|
||||
reset_form(state) {
|
||||
state.order_id = 0
|
||||
state.queue = ""
|
||||
state.is_from_clinic = false
|
||||
state.catatan_fo = ""
|
||||
state.diagnosa = ""
|
||||
state.patient_note = ""
|
||||
},
|
||||
|
||||
update_print_dialog_is_active(state, val) {
|
||||
state.print_dialog_is_active = val
|
||||
},
|
||||
|
||||
update_rpt_url(state, v) {
|
||||
state.rpt_url = v
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async save(context) {
|
||||
var order_id = context.state.order_id;
|
||||
var delivery = [];
|
||||
var detail = [];
|
||||
var req = [];
|
||||
console.log('lang_2')
|
||||
console.log(context.rootState.language.selected_language_2)
|
||||
var header = {
|
||||
patient_id: context.rootState.patient.selected_patient.M_PatientID,
|
||||
age: context.rootState.patient.selected_patient.patient_age,
|
||||
sender_doctor_id: context.rootState.doctor.selected_doctor.M_DoctorID,
|
||||
sender_address_id: context.rootState.doctor.selected_address.M_DoctorAddressID,
|
||||
pj_doctor_id: context.rootState.doctor.selected_doctor_pj.M_DoctorID,
|
||||
lang_id: context.rootState.language.selected_language.id,
|
||||
lang_si: context.rootState.language.selected_language.is_si,
|
||||
lang_id_2: context.rootState.language.selected_language_2 ? context.rootState.language.selected_language_2.id : 0,
|
||||
lang_si_2: context.rootState.language.selected_language_2 ? context.rootState.language.selected_language_2.is_si : "N",
|
||||
doctor_note: "",
|
||||
fo_note: context.state.catatan_fo,
|
||||
patient_note: context.state.patient_note,
|
||||
company_id: context.rootState.company.selected_company.M_CompanyID,
|
||||
mou_id: context.rootState.company.selected_mou.M_MouID,
|
||||
received_sample: context.rootState.order.received_sample,
|
||||
queue: context.state.queue,
|
||||
diagnose: context.state.diagnosa,
|
||||
is_cito: context.rootState.px.is_cito,
|
||||
cito_id: context.rootState.px.selected_cito ? context.rootState.px.selected_cito.Nat_CitoID : 0
|
||||
};
|
||||
|
||||
let dlv = context.rootState.delivery.deliveries
|
||||
for (var i in dlv) {
|
||||
if (dlv[i].selected == true) {
|
||||
let e = dlv[i].idx.split('-')
|
||||
delivery.push({
|
||||
delivery_id:e[0],
|
||||
delivery_type_id:e[1],
|
||||
address_id:e[2],
|
||||
note:dlv[i].note
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
var px_tmp = [];
|
||||
var st = context.rootState.px.selected_test;
|
||||
for (let i in st) {
|
||||
let x = {
|
||||
t_id: st[i]['T_TestID'],
|
||||
t_price: st[i]['T_PriceAmount'],
|
||||
t_disc: st[i]['T_PriceDisc'],
|
||||
t_discrp: st[i]['T_PriceDiscRp'],
|
||||
t_cito: st[i]['T_TestIsCito'],
|
||||
t_req: 'N',
|
||||
t_reqnote: '',
|
||||
t_ispacket: st[i]['is_packet'],
|
||||
t_packetid: st[i]['packet_id'],
|
||||
t_packettype: st[i]['px_type']
|
||||
}
|
||||
|
||||
let rq = context.rootState.px.requirement
|
||||
for (let j in rq) {
|
||||
if (rq[j].label == st[i].T_TestRequirement) {
|
||||
x.t_req = (rq[j].checked ? 'Y' : 'N')
|
||||
x.t_reqnote = rq[j].note
|
||||
}
|
||||
}
|
||||
|
||||
px_tmp.push(x)
|
||||
}
|
||||
|
||||
detail = px_tmp;
|
||||
|
||||
// let _req = context.rootState.px.requirement
|
||||
// for (let _i in _req) {
|
||||
// req.push({req_id:_req[_i].req_id, req_label:_req[_i].label, checked:(_req[_i].checked?"Y":"N"), note:_req[_i].note, px_id:_req[_i].px_id})
|
||||
// }
|
||||
let req_status = context.rootState.px.req_status
|
||||
req = {
|
||||
status : req_status,
|
||||
reqs : req_status == 'Y' ? [] : context.rootState.px.reqs
|
||||
}
|
||||
|
||||
// context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.save(one_token(), order_id, header, delivery, detail, req)
|
||||
|
||||
if (resp.status != "200") {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",resp.message)
|
||||
alert('error')
|
||||
} else {
|
||||
// Dialog loading
|
||||
context.commit('update_dialog_loading', false, {root:true})
|
||||
|
||||
context.commit("update_current_order", resp.data.data)
|
||||
context.commit('update_finish_dialog_is_active', true)
|
||||
|
||||
context.commit('payment/update_order_id', resp.data.data.id, {root:true})
|
||||
context.dispatch('payment/get_order', resp.data.data.id, {root:true})
|
||||
|
||||
// store.commit('change_tab', '03');
|
||||
}
|
||||
} catch(e) {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async load_from_clinic(context) {
|
||||
let queue = context.state.queue;
|
||||
|
||||
try {
|
||||
let resp= await api.load_from_clinic(queue)
|
||||
|
||||
if (resp.status != "200") {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",resp.message)
|
||||
alert('error')
|
||||
} else {
|
||||
|
||||
if (resp.data.status != "OK") {
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
let data = resp.data.data
|
||||
context.commit('update_from_clinic', true)
|
||||
|
||||
context.commit('patient/update_selected_patient', data.patient, {root:true})
|
||||
context.commit('doctor/update_doctors', {records:[data.doctor], total:1}, {root:true})
|
||||
context.commit('doctor/update_selected_doctor', data.doctor, {root:true})
|
||||
context.commit('doctor/update_search', data.doctor.search, {root:true})
|
||||
|
||||
// Delivery
|
||||
context.commit('delivery/update_params', {p_id:data.patient.M_PatientID}, {root:true})
|
||||
context.commit('delivery/update_params', {d_id:data.doctor.M_DoctorID}, {root:true})
|
||||
|
||||
|
||||
// Company
|
||||
let search = data.company.search
|
||||
delete(data.company.search)
|
||||
|
||||
setTimeout(function() { context.commit('company/update_companies', {records:[data.company], total:1}, {root:true}) }, 0)
|
||||
setTimeout(function() { context.commit('company/update_search', search, {root:true}) }, 0)
|
||||
setTimeout(function() { context.commit('company/update_selected_company', data.company, {root:true}) }, 0)
|
||||
|
||||
setTimeout(function() { context.commit('company/update_selected_mou', data.company.mou[0], {root:true}) }, 0)
|
||||
// setTimeout(function() { context.commit('company/selected_xx', data.company.mou[0], {root:true}) }, 0)
|
||||
|
||||
// PX
|
||||
context.commit("px/update_selected_test", data.test, {root:true})
|
||||
context.commit("px/update_requirement", data.req, {root:true})
|
||||
|
||||
// Delivery
|
||||
context.dispatch('delivery/search', null, {root:true})
|
||||
}
|
||||
} catch(e) {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async load(context) {
|
||||
let id = context.state.order_id;
|
||||
|
||||
try {
|
||||
let resp = await api.load(id)
|
||||
|
||||
if (resp.status != "200") {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",resp.message)
|
||||
alert('error')
|
||||
} else {
|
||||
|
||||
if (resp.data.status != "OK") {
|
||||
return;
|
||||
}
|
||||
|
||||
let data = resp.data.data
|
||||
|
||||
|
||||
|
||||
context.commit('patient/update_selected_patient', data.patient, {root:true})
|
||||
context.commit('doctor/update_doctors', {records:[data.doctor], total:1}, {root:true})
|
||||
context.commit('doctor/update_selected_doctor', data.doctor, {root:true})
|
||||
context.commit('doctor/update_search', data.doctor.search, {root:true})
|
||||
|
||||
// Delivery
|
||||
context.commit('delivery/update_params', {p_id:data.patient.M_PatientID}, {root:true})
|
||||
context.commit('delivery/update_params', {d_id:data.doctor.M_DoctorID}, {root:true})
|
||||
|
||||
|
||||
// Company
|
||||
let search = data.company.search
|
||||
delete(data.company.search)
|
||||
|
||||
setTimeout(function() { context.commit('company/update_companies', {records:[data.company], total:1}, {root:true}) }, 0)
|
||||
setTimeout(function() { context.commit('company/update_search', search, {root:true}) }, 0)
|
||||
setTimeout(function() { context.commit('company/update_selected_company', data.company, {root:true}) }, 0)
|
||||
|
||||
setTimeout(function() { context.commit('company/update_selected_mou', data.company.mou[0], {root:true}) }, 0)
|
||||
// setTimeout(function() { context.commit('company/selected_xx', data.company.mou[0], {root:true}) }, 0)
|
||||
|
||||
context.commit('update_received_sample', data.order.rec_sample);
|
||||
|
||||
// PX
|
||||
context.commit("px/update_selected_test", data.test, {root:true})
|
||||
context.commit("px/update_requirement", data.req, {root:true})
|
||||
|
||||
// Delivery
|
||||
context.dispatch('delivery/search', null, {root:true})
|
||||
|
||||
// Enable tab
|
||||
context.commit('update_tab_enable', [2, true])
|
||||
|
||||
setTimeout(function() {
|
||||
context.commit('update_from_clinic', false)
|
||||
}, 15000)
|
||||
|
||||
}
|
||||
} catch(e) {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async reset_form(context) {
|
||||
context.commit("reset_form")
|
||||
context.commit("patient/update_selected_patient", {}, {root:true})
|
||||
context.commit("doctor/update_doctors", {records:[], total:0}, {root:true})
|
||||
context.commit("doctor/update_selected_doctor", {}, {root:true})
|
||||
context.commit("doctor/update_selected_doctor_pj", {}, {root:true})
|
||||
|
||||
// context.commit("delivery/update_deliveries", [], {root:true})
|
||||
// context.commit("delivery/update_selected_delivery", {}, {root:true})
|
||||
context.commit("delivery/update_params", {p_id:0, d_id:0, o_id:0}, {root:true})
|
||||
context.dispatch("delivery/search", null, {root:true})
|
||||
|
||||
context.commit("px/update_selected_test", [], {root:true})
|
||||
context.commit("px/update_requirement", [], {root:true})
|
||||
|
||||
// Company
|
||||
context.commit("company/reset_company")
|
||||
}
|
||||
}
|
||||
}
|
||||
100
test/vuex/one-fo-registration-dev/modules/other.js
Normal file
100
test/vuex/one-fo-registration-dev/modules/other.js
Normal file
@@ -0,0 +1,100 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/other.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search : '',
|
||||
search_status: 0,
|
||||
search_error_message: "",
|
||||
|
||||
sex: [],
|
||||
total_sex: 0,
|
||||
selected_sex: {},
|
||||
|
||||
title: [],
|
||||
total_title: 0,
|
||||
selected_title: {},
|
||||
|
||||
banks: [],
|
||||
|
||||
mounted: 0
|
||||
},
|
||||
mutations: {
|
||||
update_search(state, val) {
|
||||
state.search=val
|
||||
},
|
||||
update_search_error_message(state,status) {
|
||||
state.search_error_message = status
|
||||
},
|
||||
update_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
update_sex(state, data) {
|
||||
state.sex = data.records
|
||||
state.total_sex = data.total
|
||||
},
|
||||
update_selected_sex(state, doc) {
|
||||
state.selected_sex = doc
|
||||
if (doc.title) {
|
||||
state.title = doc.title
|
||||
} else {
|
||||
state.title = []
|
||||
}
|
||||
},
|
||||
update_selected_title(state, doc) {
|
||||
state.selected_title = doc
|
||||
},
|
||||
|
||||
update_banks(state, d) {
|
||||
state.banks = d.records
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
|
||||
async search_sex(context) {
|
||||
context.commit("update_search_status", 1)
|
||||
try {
|
||||
let resp= await api.search_sex(context.state.search)
|
||||
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 = {
|
||||
total : resp.data.total,
|
||||
records : resp.data.records
|
||||
}
|
||||
context.commit("update_sex", data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async search_bank(context) {
|
||||
context.commit("update_search_status", 1)
|
||||
try {
|
||||
let resp= await api.search_bank(context.state.search)
|
||||
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
|
||||
}
|
||||
context.commit("update_banks", data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
168
test/vuex/one-fo-registration-dev/modules/patient.js
Normal file
168
test/vuex/one-fo-registration-dev/modules/patient.js
Normal file
@@ -0,0 +1,168 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/patient.js"
|
||||
window.api = api
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
noreg:'',
|
||||
search: '',
|
||||
search_status:0,
|
||||
search_error_message:'',
|
||||
search_dialog_is_active: false,
|
||||
patients: [],
|
||||
total_patient: 0,
|
||||
total_display: 0,
|
||||
selected_patient: {},
|
||||
|
||||
patient_new: {},
|
||||
patient_new_dialog_is_active: false,
|
||||
|
||||
idtypes: [],
|
||||
selected_idtype: {}
|
||||
},
|
||||
mutations: {
|
||||
update_search_dialog_is_active(state,status) {
|
||||
state.search_dialog_is_active = status
|
||||
},
|
||||
update_search_error_message(state,status) {
|
||||
state.search_error_message = status
|
||||
},
|
||||
update_noreg(state,val) {
|
||||
state.noreg=val
|
||||
},
|
||||
update_search(state,val) {
|
||||
state.search=val
|
||||
},
|
||||
update_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
update_patients(state,data) {
|
||||
state.patients= data.records
|
||||
state.total_patient = data.total
|
||||
state.total_display = data.total_display
|
||||
},
|
||||
update_selected_patient(state,val) {
|
||||
var now = moment(new Date())
|
||||
var dob = moment(new Date(val.M_PatientDOB))
|
||||
var year = now.diff(dob,'years')
|
||||
dob.add(year,'years')
|
||||
var month = now.diff(dob,'months')
|
||||
dob.add(month,'months')
|
||||
var day = now.diff(dob,'days')
|
||||
if (isNaN(year)) val.patient_age = ''
|
||||
else val.patient_age = `${year} tahun ${month} bulan ${day} hari`
|
||||
|
||||
state.selected_patient=val
|
||||
// store.state.patientaddress.patient_id = val.M_PatientID
|
||||
|
||||
// photo
|
||||
|
||||
},
|
||||
|
||||
update_patient_new(state, v) {
|
||||
state.patient_new = v
|
||||
},
|
||||
|
||||
update_patient_new_dialog_is_active(state, v) {
|
||||
state.patient_new_dialog_is_active = v
|
||||
},
|
||||
|
||||
update_idtypes(state, v) {
|
||||
state.idtypes = v.records
|
||||
},
|
||||
|
||||
update_selected_idtype(state, v) {
|
||||
state.selected_idtype = v
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context, prm) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search(context.state.noreg,context.state.search)
|
||||
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,
|
||||
total_display: resp.data.total_display
|
||||
}
|
||||
context.commit("update_patients",data)
|
||||
|
||||
if (prm)
|
||||
if (prm.use) {
|
||||
let pat = context.state.patients[prm.use_idx]
|
||||
context.commit('update_selected_patient', pat)
|
||||
context.commit('order/update_patient_note', pat.M_PatientNote, {root:true})
|
||||
context.commit('delivery/update_params', {p_id:pat.M_PatientID}, { root: true })
|
||||
context.dispatch('delivery/search', null, { root: true })
|
||||
|
||||
context.commit('photo/update_patient_id', pat.M_PatientID, {root: true})
|
||||
}
|
||||
|
||||
// commit("patientaddress/test", "X", { root: true })
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async add_new(context, prm) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
|
||||
let resp= await api.add_new(prm)
|
||||
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","")
|
||||
|
||||
if (prm.use) {
|
||||
context.commit('update_noreg', resp.data.noreg)
|
||||
context.commit('update_search', '')
|
||||
|
||||
context.dispatch('search', {use:true, use_idx:0})
|
||||
}
|
||||
|
||||
// commit("patientaddress/test", "X", { root: true })
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async search_idtype(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search_idtype()
|
||||
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
|
||||
}
|
||||
|
||||
context.commit("update_idtypes", data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
86
test/vuex/one-fo-registration-dev/modules/patientaddress.js
Normal file
86
test/vuex/one-fo-registration-dev/modules/patientaddress.js
Normal file
@@ -0,0 +1,86 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/patientaddress.js"
|
||||
window.api = api
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
noreg:'',
|
||||
search: '',
|
||||
search_status:0,
|
||||
search_error_message:'',
|
||||
search_dialog_is_active: false,
|
||||
patients: [],
|
||||
total_patient: 0,
|
||||
total_display: 0,
|
||||
selected_patient: {},
|
||||
|
||||
address: [],
|
||||
patient_id: 0
|
||||
},
|
||||
mutations: {
|
||||
update_search_dialog_is_active(state,status) {
|
||||
state.search_dialog_is_active = status
|
||||
},
|
||||
update_search_error_message(state,status) {
|
||||
state.search_error_message = status
|
||||
},
|
||||
update_noreg(state,val) {
|
||||
state.noreg=val
|
||||
},
|
||||
update_search(state,val) {
|
||||
state.search=val
|
||||
},
|
||||
update_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
update_patients(state,data) {
|
||||
state.patients= data.records
|
||||
state.total_patient = data.total
|
||||
state.total_display = data.total_display
|
||||
},
|
||||
update_selected_patient(state,val) {
|
||||
state.selected_patient=val
|
||||
},
|
||||
|
||||
update_address(state, val) {
|
||||
state.address = val;
|
||||
},
|
||||
|
||||
testx(state, val) {
|
||||
state.patient_id = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context,prm) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.getAll(context.state.patient_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","")
|
||||
let data = resp.data;
|
||||
context.commit("update_address",data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async loadAddress(context, prm) {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
tests (a) {
|
||||
alert(a)
|
||||
}
|
||||
}
|
||||
}
|
||||
250
test/vuex/one-fo-registration-dev/modules/payment.js
Normal file
250
test/vuex/one-fo-registration-dev/modules/payment.js
Normal file
@@ -0,0 +1,250 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/payment.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
order_id: 0,
|
||||
|
||||
selected_patient: {
|
||||
order_no: '-',
|
||||
order_date: '-',
|
||||
order_mou: '-',
|
||||
order_company: '-',
|
||||
patient_name: '-',
|
||||
patient_mr: '-',
|
||||
doctor_sender: '-',
|
||||
doctor_sender_address: '-',
|
||||
doctor_pj: '-'
|
||||
},
|
||||
|
||||
order_detail: [
|
||||
// { n:1, d_id:1, t_id:1, t_name:'SGOT', t_price:80000, t_disctotal:7000, t_total:73000 },
|
||||
// { n:2, d_id:2, t_id:2, t_name:'SGPT', t_price:75000, t_disctotal:8000, t_total:67000 }
|
||||
],
|
||||
order_delivery: [],
|
||||
|
||||
order_subtotal: 0,
|
||||
order_rounding: 0,
|
||||
order_total: 0,
|
||||
order_company: {
|
||||
is_bill: "N",
|
||||
min_dp: 0,
|
||||
min_dp_rp: 0,
|
||||
on_hold: "N",
|
||||
on_hold_text: ""
|
||||
},
|
||||
|
||||
payment_cash_amount: 0,
|
||||
payment_debit_amount: 0,
|
||||
payment_credit_amount: 0,
|
||||
|
||||
payments: [],
|
||||
payment_total: 0,
|
||||
|
||||
payment_id: 0,
|
||||
payment_number: '',
|
||||
finish_dialog_is_active: false,
|
||||
|
||||
paid: false
|
||||
},
|
||||
mutations: {
|
||||
update_order (state, data) {
|
||||
state.selected_patient = data.order_header
|
||||
state.order_detail = data.order_detail
|
||||
state.order_delivery = data.order_delivery
|
||||
|
||||
state.order_subtotal = data.order_header.order_subtotal
|
||||
state.order_rounding = data.order_header.order_rounding
|
||||
state.order_total = data.order_header.order_total
|
||||
|
||||
state.order_company = {
|
||||
is_bill: data.order_header.M_CompanyIsBill,
|
||||
min_dp: data.order_header.M_CompanyMinDP,
|
||||
min_dp_rp: Math.round(data.order_header.M_CompanyMinDP * data.order_header.order_total / 100),
|
||||
on_hold: data.order_header.M_CompanyIsAgingOnHold,
|
||||
on_hold_text: data.order_header.M_CompanyIsAgingOnHoldNote
|
||||
}
|
||||
},
|
||||
|
||||
update_order_id (state, id) {
|
||||
state.order_id = id
|
||||
},
|
||||
|
||||
update_payment(state, o) {
|
||||
if (o.type == 'cash')
|
||||
state.payment_cash_amount = o.amount
|
||||
if (o.type == 'debit')
|
||||
state.payment_debit_amount = o.amount
|
||||
if (o.type == 'credit')
|
||||
state.payment_credit_amount = o.amount
|
||||
},
|
||||
|
||||
update_payments(state, o) {
|
||||
state.payments = o
|
||||
|
||||
// Total payments
|
||||
let total = 0
|
||||
for (let i in o) {
|
||||
o[i].payment_actual = Math.round(o[i].payment_actual)
|
||||
total += o[i].payment_actual
|
||||
}
|
||||
|
||||
state.payment_total = total
|
||||
|
||||
// Calculate change
|
||||
for (let i in o) {
|
||||
o[i].payment_amount = o[i].payment_actual
|
||||
|
||||
if (o[i].payment_type_code == 'CASH') {
|
||||
o[i].payment_change = 0
|
||||
let chg = total - state.order_total;
|
||||
|
||||
if (chg > o[i].payment_actual)
|
||||
chg = o[i].payment_actual
|
||||
if (chg < 0)
|
||||
chg = 0
|
||||
|
||||
o[i].payment_change = chg
|
||||
|
||||
// re-calculate payment amount
|
||||
o[i].payment_amount = o[i].payment_actual - o[i].payment_change
|
||||
state.payment_total -= chg
|
||||
}
|
||||
}
|
||||
|
||||
state.payments = o
|
||||
},
|
||||
|
||||
reset_payment(state) {
|
||||
state.payment_total = 0
|
||||
},
|
||||
|
||||
update_finish_dialog_is_active(state, val) {
|
||||
state.finish_dialog_is_active = val
|
||||
},
|
||||
|
||||
update_payment_number(state, val) {
|
||||
state.payment_number = val
|
||||
},
|
||||
|
||||
update_payment_id(state, val) {
|
||||
state.payment_id = val
|
||||
},
|
||||
|
||||
update_paid(state, val) {
|
||||
state.paid = val
|
||||
},
|
||||
|
||||
update_order_company(state, val) {
|
||||
state.order_company = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async get_order(context, prm) {
|
||||
// context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.get_order(prm)
|
||||
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 = resp.data.data
|
||||
context.commit("update_order", data)
|
||||
|
||||
// commit("patientaddress/test", "X", { root: true })
|
||||
}
|
||||
} catch(e) {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async search(context, prm) {
|
||||
// context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search(prm)
|
||||
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 = resp.data
|
||||
context.commit("update_payments", data)
|
||||
|
||||
// commit("patientaddress/test", "X", { root: true })
|
||||
}
|
||||
} catch(e) {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async save(context) {
|
||||
var order_id = context.state.order_id;
|
||||
let payments = []
|
||||
let p = context.state.payments
|
||||
for (let i in context.state.payments) {
|
||||
if (Math.round(p[i].payment_amount) == 0)
|
||||
continue;
|
||||
|
||||
payments.push({
|
||||
type: p[i].payment_type_id,
|
||||
amount: p[i].payment_amount,
|
||||
actual: p[i].payment_actual,
|
||||
changes: p[i].payment_change,
|
||||
note: p[i].payment_note,
|
||||
card: p[i].payment_card_id,
|
||||
edc: p[i].payment_edc_id
|
||||
})
|
||||
}
|
||||
|
||||
// context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.save(one_token(), order_id, payments)
|
||||
|
||||
if (resp.status != "200") {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",resp.message)
|
||||
alert('error')
|
||||
} else {
|
||||
context.commit('update_payment_number', resp.data.data.payment_number)
|
||||
context.commit('update_payment_id', resp.data.data.payment_id)
|
||||
context.commit('update_finish_dialog_is_active', true)
|
||||
context.commit('update_paid', true)
|
||||
}
|
||||
} catch(e) {
|
||||
// context.commit("update_search_status",3)
|
||||
// context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async print_nota (context, a) {
|
||||
let usr = one_user()
|
||||
let ts = Date.now() / 1000 | 0
|
||||
let x = context.rootState.company.selected_mou
|
||||
let rpt_url = '/birt/run?__report=report/one/fo/rpt_t_003.rptdesign&PID='+a+'&username='+usr.M_UserUsername+'&__format=pdf&ts='+ts
|
||||
if (x.M_MouIsBill == 'Y')
|
||||
rpt_url = '/birt/run?__report=report/one/fo/rpt_t_006.rptdesign&__format=pdf&username='+usr.M_UserUsername+'&PID='+a+'&ts='+ts
|
||||
|
||||
context.commit('order/update_rpt_url', window.BASE_URL + rpt_url, {root:true})
|
||||
context.commit('order/update_print_dialog_is_active', true, {root:true})
|
||||
},
|
||||
|
||||
async print_invoice (context, a) {
|
||||
context.commit('order/update_rpt_url', window.BASE_URL + '/birt/run?__report=report/one/fo/rpt_t_001.rptdesign&PID='+a+'&username=admin&__format=pdf', {root:true})
|
||||
context.commit('order/update_print_dialog_is_active', true, {root:true})
|
||||
},
|
||||
|
||||
async print_control (context, a) {
|
||||
context.commit('order/update_rpt_url', window.BASE_URL + '/birt/run?__report=report/one/lab/rpt_fo_001.rptdesign&PID='+a+'&username=admin&__format=pdf', {root:true})
|
||||
context.commit('order/update_print_dialog_is_active', true, {root:true})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
50
test/vuex/one-fo-registration-dev/modules/photo.js
Normal file
50
test/vuex/one-fo-registration-dev/modules/photo.js
Normal file
@@ -0,0 +1,50 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/photo.js"
|
||||
window.api = api
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
dialog_photo: false,
|
||||
photo_64: '',
|
||||
photo_url: 'https://www.sgm-inc.com/wp-content/uploads/2014/06/no-profile-male-img.gif',
|
||||
default_photo_url: 'https://www.sgm-inc.com/wp-content/uploads/2014/06/no-profile-male-img.gif',
|
||||
patient_id: 0
|
||||
},
|
||||
mutations: {
|
||||
update_dialog_photo (state, v) {
|
||||
state.dialog_photo = v
|
||||
},
|
||||
|
||||
update_photo_64 (state, data) {
|
||||
state.photo_64 = data
|
||||
},
|
||||
|
||||
update_photo_url (state, data) {
|
||||
state.photo_url = data
|
||||
},
|
||||
|
||||
update_patient_id (state, id) {
|
||||
state.patient_id = id
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async upload(context) {
|
||||
|
||||
try {
|
||||
let resp = await api.upload(one_token(), context.state.patient_id, context.state.photo_64)
|
||||
|
||||
if (resp.status != "OK") {
|
||||
|
||||
} else {
|
||||
context.commit('update_photo_url', resp.data.photo_url);
|
||||
context.commit('update_dialog_photo', false)
|
||||
}
|
||||
} catch(e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
480
test/vuex/one-fo-registration-dev/modules/px.js
Normal file
480
test/vuex/one-fo-registration-dev/modules/px.js
Normal file
@@ -0,0 +1,480 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/px.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search: '',
|
||||
search_status:0,
|
||||
search_error_message:'',
|
||||
tests: [],
|
||||
total_test: 0,
|
||||
selected_test: [],
|
||||
|
||||
search_panel: '',
|
||||
search_panel_status:0,
|
||||
panels: [],
|
||||
total_panel: 0,
|
||||
selected_panel: [],
|
||||
requirement: [],
|
||||
appx_schedule: '',
|
||||
|
||||
search_profile: '',
|
||||
profiles: [],
|
||||
total_profile: 0,
|
||||
|
||||
cito: {test:[], panel:[]},
|
||||
nat_test: [],
|
||||
|
||||
req_status: "X",
|
||||
reqs: [],
|
||||
|
||||
citos: [],
|
||||
selected_cito: null,
|
||||
is_cito: "N"
|
||||
},
|
||||
mutations: {
|
||||
update_requirement(state,val) {
|
||||
state.requirement = val
|
||||
},
|
||||
update_search_error_message(state,status) {
|
||||
state.search_error_message = status
|
||||
},
|
||||
update_selected_test(state,val) {
|
||||
// if (state.cito.length > 0) {
|
||||
for (var i in val) {
|
||||
val[i]['T_TestIsCito'] = 'N'
|
||||
if (state.cito.test.indexOf(val[i]['T_TestID']) > -1)
|
||||
val[i]['T_TestIsCito'] = 'Y'
|
||||
}
|
||||
// }
|
||||
|
||||
state.selected_test = val
|
||||
},
|
||||
update_mouCompanyID(state,val) {
|
||||
state.mouCompanyID=val
|
||||
},
|
||||
update_search(state,val) {
|
||||
state.search=val
|
||||
},
|
||||
update_search_status(state,status) {
|
||||
state.search_status = status
|
||||
},
|
||||
update_tests(state,data) {
|
||||
state.tests= data.records
|
||||
state.total_test= data.total
|
||||
},
|
||||
update_search_panel(state,val) {
|
||||
state.search_panel=val
|
||||
},
|
||||
update_search_panel_status(state,status) {
|
||||
state.search_panel_status = status
|
||||
},
|
||||
update_panels(state,data) {
|
||||
state.panels = data.records
|
||||
state.total_panel = data.total
|
||||
},
|
||||
update_selected_panel(state,val) {
|
||||
state.selected_panel= val
|
||||
},
|
||||
|
||||
update_cito(state, val) {
|
||||
let test = state.selected_test
|
||||
let cito = state.cito
|
||||
// if (val.length > 0) {
|
||||
|
||||
for (var i in test) {
|
||||
test[i]['T_TestIsCito'] = 'N'
|
||||
if (val.v.indexOf(test[i]['T_TestID']) > -1)
|
||||
test[i]['T_TestIsCito'] = 'Y'
|
||||
}
|
||||
|
||||
// }
|
||||
|
||||
cito[val.t] = val.v
|
||||
console.log(cito)
|
||||
state.cito = cito
|
||||
state.selected_test = test
|
||||
},
|
||||
|
||||
update_appx_schedule(state, v) {
|
||||
state.appx_schedule = v
|
||||
},
|
||||
|
||||
update_search_profile(state, v) {
|
||||
state.search_profile = v
|
||||
},
|
||||
|
||||
update_profiles(state, data) {
|
||||
state.profiles = data.records
|
||||
state.total_profile = data.total
|
||||
},
|
||||
|
||||
update_nat_test(state) {
|
||||
let px = state.selected_test
|
||||
let nt = []
|
||||
for (let i in px) {
|
||||
for (let j in px[i].nat_test) {
|
||||
nt.push(px[i].nat_test[j])
|
||||
}
|
||||
}
|
||||
|
||||
state.nat_test = nt
|
||||
},
|
||||
|
||||
update_req_status(state, val) {
|
||||
state.req_status = val
|
||||
},
|
||||
|
||||
update_reqs(state, val) {
|
||||
state.reqs = val
|
||||
},
|
||||
|
||||
update_citos(state, val) {
|
||||
state.citos = val.records
|
||||
},
|
||||
|
||||
update_selected_cito(state, val) {
|
||||
state.selected_cito = val
|
||||
},
|
||||
|
||||
update_is_cito(state, val) {
|
||||
state.is_cito = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
delete_px (context, test) {
|
||||
let sel = context.state.selected_test
|
||||
sel.forEach(function(t, idx) {
|
||||
if(t.T_TestID == test.T_TestID && t.px_type == test.px_type) {
|
||||
sel.splice(idx,1)
|
||||
}
|
||||
});
|
||||
|
||||
let cito = context.state.cito.test
|
||||
let cito_idx = cito.indexOf(test.T_TestID)
|
||||
if (cito_idx > -1)
|
||||
cito.splice(cito_idx, 1)
|
||||
|
||||
context.commit("update_selected_test", sel)
|
||||
let tests = context.state.tests
|
||||
if (tests == undefined ) tests = []
|
||||
tests.push(test)
|
||||
|
||||
let dt = {
|
||||
records : tests,
|
||||
total: tests.length
|
||||
}
|
||||
|
||||
context.commit("update_tests", dt)
|
||||
context.dispatch("delete_req", test)
|
||||
// context.dispatch("update_req", null)
|
||||
context.dispatch("appx_schedule")
|
||||
context.commit('update_nat_test')
|
||||
},
|
||||
|
||||
delete_req(context, px) {
|
||||
let req = context.state.requirement
|
||||
for (let i in req) {
|
||||
let x = _.indexOf(req[i].px_id, px.T_TestID)
|
||||
if (x > -1)
|
||||
req[i].px_id.splice(x, 1)
|
||||
|
||||
if (req[i].px_id.length < 1)
|
||||
req.splice(i, 1)
|
||||
}
|
||||
|
||||
context.commit('update_requirement', req)
|
||||
},
|
||||
|
||||
async search(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let mouCompanyID = 0
|
||||
if (context.rootState.company.selected_mou.M_MouID) {
|
||||
mouCompanyID = context.rootState.company.selected_mou.M_MouID
|
||||
}
|
||||
let resp= await api.search(mouCompanyID,context.state.search)
|
||||
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 )
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
|
||||
async panel(context,prm) {
|
||||
context.commit("update_search_panel_status",1)
|
||||
try {
|
||||
let mouCompanyID = 0
|
||||
if (context.rootState.company.selected_mou.M_MouCompanyID) {
|
||||
mouCompanyID = context.rootState.company.selected_mou.M_MouCompanyID
|
||||
}
|
||||
let resp= await api.panel(mouCompanyID,context.state.search)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_panel_status",3)
|
||||
context.commit("update_search_error_message",resp.message)
|
||||
} else {
|
||||
context.commit("update_search_panel_status",2)
|
||||
context.commit("update_search_error_message","")
|
||||
let data = {
|
||||
records : resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_panels",data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_panel_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async profile(context) {
|
||||
context.commit("update_search_panel_status", 1)
|
||||
try {
|
||||
let mou_id = 0
|
||||
if (context.rootState.company.selected_mou.M_MouID) {
|
||||
mou_id = context.rootState.company.selected_mou.M_MouID
|
||||
}
|
||||
|
||||
let resp = await api.profile(mou_id, context.state.search_profile)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_panel_status",3)
|
||||
context.commit("update_search_error_message",resp.message)
|
||||
} else {
|
||||
context.commit("update_search_panel_status",2)
|
||||
context.commit("update_search_error_message","")
|
||||
let data = {
|
||||
records : resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
context.commit("update_profiles", data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_panel_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async get_price(context, prm) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
|
||||
let mou_id = context.rootState.company.selected_mou.M_MouID
|
||||
let resp = await api.get_price(prm.test_id, mou_id, prm.cito)
|
||||
|
||||
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 x = context.state.selected_test
|
||||
for (let i in x) {
|
||||
if (x[i].T_TestID == prm.test_id) {
|
||||
if ((Math.round(resp.data.test_price) == 0 && x[i].T_TestForceSell != "Y") ||
|
||||
Math.round(resp.data.test_price) < 0 ) {
|
||||
alert('Pemeriksaan ini belum ada harga CITO-nya !')
|
||||
x[i].T_TestIsCito = "N"
|
||||
let n = context.state.cito.test.indexOf(x[i].T_TestID)
|
||||
if (n > -1)
|
||||
context.state.cito.test.splice(n, 1)
|
||||
|
||||
// let tests = context.state.tests
|
||||
// if (tests == undefined ) tests = []
|
||||
// tests.push(x[i])
|
||||
// let dt = {
|
||||
// records : tests,
|
||||
// total: tests.length
|
||||
// }
|
||||
// context.commit("update_tests", dt)
|
||||
// x.splice(i, 1);
|
||||
}
|
||||
|
||||
else {
|
||||
x[i].T_PriceAmount = resp.data.test_price
|
||||
x[i].T_PriceDisc = resp.data.test_disc
|
||||
x[i].T_PriceDiscRp = resp.data.test_discrp
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
context.commit("update_selected_test", x)
|
||||
context.commit("update_nat_test")
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
async appx_schedule(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
|
||||
let ids = []
|
||||
let pn_ids = []
|
||||
context.commit("update_appx_schedule", '-')
|
||||
|
||||
let pxs = context.state.selected_test
|
||||
for (let i in pxs) {
|
||||
if (pxs[i].px_type == 'PN')
|
||||
pn_ids.push(pxs[i].T_TestID)
|
||||
else
|
||||
ids.push(pxs[i].T_TestID)
|
||||
}
|
||||
|
||||
let resp = await api.appx_schedule(ids.join(','), pn_ids.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","")
|
||||
|
||||
context.commit("update_appx_schedule", resp.data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message", e.message )
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
async search_cito(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search_cito(one_token())
|
||||
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
|
||||
}
|
||||
context.commit("update_citos", data)
|
||||
|
||||
for (let i in data.records)
|
||||
if (data.records[i].Nat_CitoIsDefault == "Y")
|
||||
context.commit('update_selected_cito', data.records[i])
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message", e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async search_pxs(context, id) {
|
||||
context.commit("update_search_status",1)
|
||||
// LOADING
|
||||
context.commit('update_dialog_loading', true, {root:true})
|
||||
|
||||
try {
|
||||
let mouCompanyID = 0
|
||||
if (context.rootState.company.selected_mou.M_MouID) {
|
||||
mouCompanyID = context.rootState.company.selected_mou.M_MouID
|
||||
}
|
||||
let resp= await api.search_pxs(mouCompanyID, id)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",resp.message)
|
||||
|
||||
// LOADING
|
||||
context.commit('update_dialog_loading', false, {root:true})
|
||||
} else {
|
||||
context.commit("update_search_status",2)
|
||||
context.commit("update_search_error_message","")
|
||||
|
||||
let x = resp.data.records
|
||||
|
||||
for (let k in x) {
|
||||
// SEARCH NAT TEST
|
||||
let px = x[k]
|
||||
let nt = context.state.nat_test
|
||||
let found_nt = false
|
||||
for (let i in px.nat_test) {
|
||||
if (nt.indexOf(px.nat_test[i]) > -1)
|
||||
found_nt = true
|
||||
}
|
||||
|
||||
if (found_nt)
|
||||
continue
|
||||
|
||||
let selected_test = context.state.selected_test
|
||||
let flag_found = false
|
||||
selected_test.forEach( function(t, idx) {
|
||||
if (t.T_TestID == px.T_TestID) {
|
||||
selected_test[idx] = px
|
||||
flag_found = true
|
||||
}
|
||||
})
|
||||
|
||||
if (!flag_found) {
|
||||
selected_test.push(px)
|
||||
}
|
||||
context.commit('update_selected_test', selected_test)
|
||||
|
||||
let req = px.requirement
|
||||
let reqs = context.state.requirement
|
||||
if (req.length > 0) {
|
||||
for(let i in req) {
|
||||
let found = false
|
||||
for(let j in reqs) {
|
||||
if (reqs[j]['req_id'] == req[i]['req_id'])
|
||||
found = j
|
||||
}
|
||||
|
||||
if (!found)
|
||||
reqs.push({
|
||||
px_id: [px.T_TestID],
|
||||
label: req[i]['req_name'],
|
||||
error_message: 'Hasil harus di isi',
|
||||
is_error: true,
|
||||
checked : false,
|
||||
note: '',
|
||||
req_id: req[i]['req_id']
|
||||
})
|
||||
else
|
||||
reqs[found].px_id.push(px.T_TestID)
|
||||
}
|
||||
|
||||
context.commit('update_requirement', reqs)
|
||||
}
|
||||
|
||||
|
||||
context.commit('update_nat_test')
|
||||
// END LOADING
|
||||
|
||||
}
|
||||
|
||||
context.dispatch('appx_schedule')
|
||||
context.commit('update_dialog_loading', false, {root:true})
|
||||
context.commit('history/update_history_dialog', false, {root:true})
|
||||
context.commit('change_tab', '02', {root:true})
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user