991 lines
38 KiB
JavaScript
991 lines
38 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/sample.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
last_id: -1,
|
|
last_saved_id: -1,
|
|
x_addr_id: 0,
|
|
act: 'new',
|
|
last_trx: {},
|
|
act_addr: 'new',
|
|
get_data_status: 0,
|
|
search_trx: 0,
|
|
search_status: 0,
|
|
search_error_message: '',
|
|
start_date: moment(new Date()).format('YYYY-MM-DD'),
|
|
end_date: moment(new Date()).format('YYYY-MM-DD'),
|
|
total_transaction: 0,
|
|
transactions: [],
|
|
details: [],
|
|
selected_detai: {},
|
|
stations: [{ id: "NEW", name: "BARU" }, { id: "VAL1", name: "VERIFIKASI" }, { id: "VAL2", name: "VALIDASI" }],
|
|
selected_station: { id: "NEW", name: "BARU" },
|
|
selected_transaction: {},
|
|
save_status: 0,
|
|
name_lab: '',
|
|
btn_save_seen: true,
|
|
pgrs_save: false,
|
|
save_error_message: '',
|
|
no_save: 0,
|
|
open_alert_confirmation: false,
|
|
alert_success: false,
|
|
msg_success: "",
|
|
dialog_success: false,
|
|
dialog_confirmation_delete: false,
|
|
msg_confirmation_delete: "",
|
|
autocomplete_status: 0,
|
|
dialog_form_address: false,
|
|
errors: [],
|
|
open_dialog_info: false,
|
|
msg_info: '',
|
|
dialog_action: false,
|
|
msg_action: '',
|
|
current_status: null,
|
|
uploaded_files: [],
|
|
uploaded_error: null,
|
|
photos: [],
|
|
selected_photo: {},
|
|
dialog_image: false,
|
|
image: '',
|
|
doctors: [],
|
|
selected_doctor: {},
|
|
doctor_address: [],
|
|
selected_doctor_address: {},
|
|
trx_date: moment(new Date()).format('YYYY-MM-DD'),
|
|
couriers: [],
|
|
selected_courier: {},
|
|
trx_note: '',
|
|
item_groups: [{ id: 2, fulltitle: '' }],
|
|
select_item_group: { id: 2, fulltitle: '' },
|
|
item_subgroups: [{ id: 0, fulltitle: '' }],
|
|
select_item_subgroup: { id: 0, fulltitle: '' },
|
|
selected_itemgroupname: '',
|
|
selected_itemsubgroupname: '',
|
|
langs: [],
|
|
selected_lang: {},
|
|
current_page: 1,
|
|
total_page: 1,
|
|
dialog_print_lang: false,
|
|
selected_test: {},
|
|
templates: [],
|
|
selected_template: {},
|
|
dialog_template: false,
|
|
dialog_note: false,
|
|
current_page_histories: 0,
|
|
total_page_histories: 0,
|
|
histories: [],
|
|
selected_history: {},
|
|
details_histories: [],
|
|
dialog_histories: false,
|
|
typeresult: { id: 'Rontgen', name: 'Radiodiagnostik' },
|
|
companies: [],
|
|
selected_company: { id: 0, name: 'Semua' },
|
|
autocomplete_status: 0,
|
|
switch_exclude: false,
|
|
status_results: [{ id: 'X', name: 'Belum ditentukan' }, { id: 'Y', name: 'Normal' }, { id: 'N', name: 'Tidak Normal' }],
|
|
selected_status_result: { id: 'X', name: 'Belum ditentukan' },
|
|
print_format: 'format-1',
|
|
doctorList: [],
|
|
selectedDoctor: {},
|
|
searchDoctor: '',
|
|
dialogDoctor: false,
|
|
selectedDoctrorTest: {},
|
|
search_lab_no: '',
|
|
search_type: '',
|
|
station_id: null,
|
|
location_id: null,
|
|
next_url: null,
|
|
attachments: []
|
|
},
|
|
mutations: {
|
|
update_attachments(state, val) {
|
|
state.attachments = val
|
|
},
|
|
update_search_lab_no(state, val) {
|
|
state.search_lab_no = val
|
|
},
|
|
update_next_url(state, val) {
|
|
state.next_url = val
|
|
},
|
|
update_search_type(state, val) {
|
|
state.search_type = val
|
|
},
|
|
update_location_id(state, val) {
|
|
state.location_id = val
|
|
},
|
|
update_station_id(state, val) {
|
|
state.station_id = val
|
|
},
|
|
update_print_format(state, val) {
|
|
state.print_format = val
|
|
},
|
|
update_status_results(state, val) {
|
|
state.status_results = val
|
|
},
|
|
update_selected_status_result(state, val) {
|
|
state.selected_status_result = val
|
|
},
|
|
update_switch_exclude(state, val) {
|
|
state.switch_exclude = val
|
|
},
|
|
update_autocomplete_status(state, val) {
|
|
state.autocomplete_status = val
|
|
},
|
|
update_companies(state, val) {
|
|
state.companies = val
|
|
},
|
|
update_selected_company(state, val) {
|
|
state.selected_company = val
|
|
},
|
|
update_typeresult(state, val) {
|
|
state.typeresult = val
|
|
},
|
|
update_dialog_histories(state, val) {
|
|
state.dialog_histories = val
|
|
},
|
|
update_histories(state, val) {
|
|
state.histories = val
|
|
},
|
|
update_selected_history(state, val) {
|
|
state.selected_history = val
|
|
},
|
|
update_details_histories(state, val) {
|
|
state.details_histories = val
|
|
},
|
|
update_current_page_histories(state, val) {
|
|
state.current_page_histories = val
|
|
},
|
|
update_total_page_histories(state, val) {
|
|
state.total_page_histories = val
|
|
},
|
|
update_dialog_note(state, val) {
|
|
state.dialog_note = val
|
|
},
|
|
update_dialog_template(state, val) {
|
|
state.dialog_template = val
|
|
},
|
|
update_templates(state, val) {
|
|
state.templates = val
|
|
},
|
|
update_selected_template(state, val) {
|
|
state.selected_template = val
|
|
},
|
|
update_selected_test(state, val) {
|
|
state.selected_test = val
|
|
},
|
|
update_dialog_print_lang(state, val) {
|
|
state.dialog_print_lang = val
|
|
},
|
|
update_selected_lang(state, val) {
|
|
state.selected_lang = val
|
|
},
|
|
update_current_page(state, val) {
|
|
state.current_page = val
|
|
},
|
|
update_total_page(state, val) {
|
|
state.total_page = val
|
|
},
|
|
update_x_addr_id(state, val) {
|
|
state.x_addr_id = val
|
|
},
|
|
update_last_id(state, val) {
|
|
state.last_id = val
|
|
},
|
|
update_last_trx(state, val) {
|
|
state.last_trx = val
|
|
},
|
|
update_last_saved_id(state, val) {
|
|
state.last_saved_id = val
|
|
},
|
|
update_act(state, val) {
|
|
state.act = val
|
|
},
|
|
update_start_date(state, val) {
|
|
state.start_date = val
|
|
},
|
|
update_end_date(state, val) {
|
|
state.end_date = val
|
|
},
|
|
update_name_lab(state, val) {
|
|
state.name_lab = val
|
|
},
|
|
update_stations(state, val) {
|
|
state.stations = val
|
|
},
|
|
update_selected_station(state, val) {
|
|
state.selected_station = val
|
|
},
|
|
update_act_addr(state, val) {
|
|
state.act_addr = val
|
|
},
|
|
update_get_data_status(state, val) {
|
|
state.get_data_status = val
|
|
},
|
|
update_search_error_message(state, patient) {
|
|
state.search_error_message = patient
|
|
},
|
|
update_search_transaction(state, val) {
|
|
state.search_transaction = val
|
|
},
|
|
update_transactions(state, data) {
|
|
state.transactions = data
|
|
},
|
|
update_selected_transaction(state, val) {
|
|
state.selected_transaction = val
|
|
},
|
|
update_details(state, data) {
|
|
state.details = data
|
|
},
|
|
update_selected_detail(state, val) {
|
|
state.selected_detail = val
|
|
},
|
|
update_save_status(state, val) {
|
|
state.save_status = val
|
|
},
|
|
update_btn_save_seen(state, val) {
|
|
state.btn_save_seen = val
|
|
},
|
|
update_pgrs_save(state, val) {
|
|
state.pgrs_save = val
|
|
},
|
|
update_save_error_message(state, msg) {
|
|
state.save_error_message = ''
|
|
},
|
|
update_no_save(state, val) {
|
|
state.no_save = val
|
|
},
|
|
update_open_alert_confirmation(state, val) {
|
|
state.open_alert_confirmation = val
|
|
},
|
|
update_alert_success(state, val) {
|
|
state.alert_success = val
|
|
},
|
|
update_msg_success(state, val) {
|
|
state.msg_success = val
|
|
},
|
|
update_dialog_success(state, val) {
|
|
state.dialog_success = val
|
|
},
|
|
update_dialog_confirmation_delete(state, val) {
|
|
state.dialog_confirmation_delete = val
|
|
},
|
|
update_msg_confirmation_delete(state, val) {
|
|
state.msg_confirmation_delete = val
|
|
},
|
|
update_search_status(state, val) {
|
|
state.search_status = val
|
|
},
|
|
update_errors(state, val) {
|
|
state.errors = val
|
|
},
|
|
update_total_transactions(state, val) {
|
|
state.total_transactions = val
|
|
},
|
|
update_open_dialog_info(state, val) {
|
|
state.open_dialog_info = val
|
|
},
|
|
update_msg_info(state, val) {
|
|
state.msg_info = val
|
|
},
|
|
update_dialog_action(state, val) {
|
|
state.dialog_action = val
|
|
},
|
|
update_msg_action(state, val) {
|
|
state.msg_action = val
|
|
},
|
|
update_current_status(state, val) {
|
|
state.current_status = val
|
|
},
|
|
update_uploaded_files(state, val) {
|
|
state.uploaded_files = val
|
|
},
|
|
update_uploaded_error(state, val) {
|
|
state.uploaded_error = val
|
|
},
|
|
update_photos(state, val) {
|
|
state.photos = val
|
|
},
|
|
update_selected_photo(state, val) {
|
|
state.selected_photo = val
|
|
},
|
|
update_dialog_image(state, val) {
|
|
state.dialog_image = val
|
|
},
|
|
update_image(state, val) {
|
|
state.image = val
|
|
},
|
|
update_doctors(state, val) {
|
|
state.doctors = val
|
|
},
|
|
update_selected_doctor(state, val) {
|
|
state.selected_doctor = val
|
|
},
|
|
update_doctor_address(state, val) {
|
|
state.doctor_address = val
|
|
},
|
|
update_selected_doctor_address(state, val) {
|
|
state.selected_doctor_address = val
|
|
},
|
|
update_trx_date(state, val) {
|
|
state.trx_date = val
|
|
},
|
|
update_couriers(state, val) {
|
|
state.couriers = val
|
|
},
|
|
update_selected_courier(state, val) {
|
|
state.selected_courier = val
|
|
},
|
|
update_trx_note(state, val) {
|
|
state.trx_note = val
|
|
},
|
|
update_item_groups(state, val) {
|
|
state.item_groups = val
|
|
},
|
|
update_select_item_group(state, val) {
|
|
state.select_item_group = val
|
|
},
|
|
update_item_subgroups(state, val) {
|
|
state.item_subgroups = val
|
|
},
|
|
update_select_item_subgroup(state, val) {
|
|
state.select_item_subgroup = val
|
|
},
|
|
update_selected_itemgroupname(state, val) {
|
|
state.selected_itemgroupname = val
|
|
},
|
|
update_selected_itemsubgroupname(state, val) {
|
|
state.selected_itemsubgroupname = val
|
|
},
|
|
update_item_langs(state, val) {
|
|
state.langs = val
|
|
},
|
|
update_doctorList(state, val) {
|
|
state.doctorList = val
|
|
},
|
|
update_selectedDoctor(state, val) {
|
|
state.selectedDoctor = val
|
|
},
|
|
update_searchDoctor(state, val) {
|
|
state.searchDoctor = val
|
|
},
|
|
update_dialogDoctor(state, val) {
|
|
state.dialogDoctor = val
|
|
},
|
|
update_selectedDoctrorTest(state, val) {
|
|
state.selectedDoctrorTest = val
|
|
},
|
|
},
|
|
actions: {
|
|
async search(context, prm) {
|
|
context.commit("update_search_transaction", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
prm.current_page = context.state.current_page
|
|
prm.lastid = context.state.last_id
|
|
console.log(prm)
|
|
let resp = await api.search(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_search_transaction", 3)
|
|
context.commit("update_search_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_search_transaction", 2)
|
|
context.commit("update_search_error_message", "")
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
|
|
var trx = []
|
|
if (data.records.length > 0) {
|
|
context.commit("update_transactions", resp.data.records)
|
|
if (prm.lastid === -1) {
|
|
trx = resp.data.records[0]
|
|
context.commit("update_last_id", trx.trx_id)
|
|
}
|
|
else {
|
|
let arrtrx = context.state.transactions
|
|
var idx = _.findIndex(arrtrx, item => item.trx_id === context.state.last_id)
|
|
trx = resp.data.records[idx]
|
|
}
|
|
context.commit("update_selected_transaction", trx)
|
|
context.commit("update_attachments", [])
|
|
context.dispatch("getattachments", trx)
|
|
|
|
if (!_.isEmpty(trx.details)) {
|
|
context.commit("update_details", trx.details)
|
|
}
|
|
else {
|
|
context.commit("update_details", [])
|
|
}
|
|
if (trx.doctorID !== null && trx.doctorID !== "") {
|
|
let selectedDoctor = {
|
|
doctorID: trx.doctorID,
|
|
doctorName: trx.doctorName
|
|
}
|
|
context.commit("update_selectedDoctor", selectedDoctor)
|
|
context.commit("update_searchDoctor", trx.doctorName)
|
|
|
|
}
|
|
}
|
|
else {
|
|
context.commit("update_transactions", [])
|
|
context.commit("update_selected_transaction", {})
|
|
}
|
|
|
|
context.commit("update_total_transactions", data.total)
|
|
context.commit("update_total_page", data.total)
|
|
context.commit("update_no_save", 0)
|
|
context.commit("update_act", 'edit')
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_search_transaction", 3)
|
|
context.commit("update_search_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async searchbyid(context) {
|
|
context.commit("update_search_transaction", 1)
|
|
try {
|
|
let prmx = {}
|
|
prmx.token = one_token()
|
|
prmx.nolab = context.state.search_lab_no
|
|
prmx.type = context.state.search_type
|
|
console.log(prmx)
|
|
let resp = await api.searchbyid(prmx)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_search_transaction", 3)
|
|
context.commit("update_search_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_search_transaction", 2)
|
|
context.commit("update_search_error_message", "")
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
|
|
var trx = []
|
|
if (data.records.length > 0) {
|
|
context.commit("update_transactions", resp.data.records)
|
|
context.commit("update_next_url", resp.data.nexturl)
|
|
|
|
|
|
trx = resp.data.records[0]
|
|
|
|
context.commit("update_selected_transaction", trx)
|
|
|
|
if (!_.isEmpty(trx.details)) {
|
|
context.commit("update_details", trx.details)
|
|
}
|
|
else {
|
|
context.commit("update_details", [])
|
|
}
|
|
if (trx.doctorID !== null && trx.doctorID !== "") {
|
|
let selectedDoctor = {
|
|
doctorID: trx.doctorID,
|
|
doctorName: trx.doctorName
|
|
}
|
|
context.commit("update_selectedDoctor", selectedDoctor)
|
|
context.commit("update_searchDoctor", trx.doctorName)
|
|
|
|
}
|
|
}
|
|
else {
|
|
context.commit("update_transactions", [])
|
|
context.commit("update_selected_transaction", {})
|
|
}
|
|
|
|
context.commit("update_total_transactions", data.total)
|
|
context.commit("update_total_page", data.total)
|
|
context.commit("update_no_save", 0)
|
|
context.commit("update_act", 'edit')
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_search_transaction", 3)
|
|
context.commit("update_search_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async search_histories(context, prm) {
|
|
context.commit("update_search_transaction", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.search_histories(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_search_transaction", 3)
|
|
context.commit("update_search_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_search_transaction", 2)
|
|
context.commit("update_search_error_message", "")
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
|
|
var trx = []
|
|
if (data.records.length > 0) {
|
|
context.commit("update_histories", resp.data.records)
|
|
if (prm.lastid === -1 || prm.lastid > data.records.length - 1) {
|
|
trx = resp.data.records[0]
|
|
}
|
|
else {
|
|
trx = resp.data.records[prm.lastid]
|
|
}
|
|
context.commit("update_selected_history", trx)
|
|
}
|
|
else {
|
|
context.commit("update_histories", [])
|
|
context.commit("update_selected_history", {})
|
|
}
|
|
|
|
context.commit("update_total_page_histories", data.total)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_search_transaction", 3)
|
|
context.commit("update_search_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async getdoctorcouriers(context, prm) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.getdoctorcouriers(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status", 3)
|
|
} else {
|
|
context.commit("update_get_data_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_doctors", data.records['doctors'])
|
|
context.commit("update_couriers", data.records['couriers'])
|
|
context.dispatch("search", prm)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_get_data_status", 3)
|
|
}
|
|
},
|
|
async save_flagprint(context, prm) {
|
|
context.commit("update_get_data_status", 1)
|
|
console.log('backen oeyy')
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.save_flagprint(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status", 3)
|
|
} else {
|
|
context.commit("update_get_data_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_get_data_status", 3)
|
|
}
|
|
},
|
|
async getgroups(context, prm) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.getgroups(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status", 3)
|
|
} else {
|
|
context.commit("update_get_data_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
var groups = data.records['groups']
|
|
var langs = data.records['langs']
|
|
context.commit("update_item_langs", langs)
|
|
context.commit("update_item_groups", groups)
|
|
context.commit("update_select_item_group", groups[0])
|
|
context.commit("update_selected_itemgroupname", groups[0].fulltitle)
|
|
context.commit("update_item_subgroups", groups[0].childrens)
|
|
context.commit("update_select_item_subgroup", groups[0].childrens[0])
|
|
context.commit("update_selected_itemsubgroupname", groups[0].childrens[0].fulltitle)
|
|
prm.groupid = groups[0].id
|
|
prm.subgroupid = groups[0].childrens[0].id
|
|
context.dispatch("search", prm)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_get_data_status", 3)
|
|
}
|
|
},
|
|
async upload(context, prm) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
|
|
let resp = await api.upload(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status", 3)
|
|
} else {
|
|
context.commit("update_get_data_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total,
|
|
error: resp.data.errors.error
|
|
}
|
|
context.commit("update_uploaded_files", data.records)
|
|
|
|
var msg = "Photo telah berhasil diupload"
|
|
if (data.error) {
|
|
msg = data.error
|
|
context.commit("update_current_status", 'STATUS_FAILED')
|
|
}
|
|
else {
|
|
context.commit("update_current_status", 'STATUS_SUCCESS')
|
|
}
|
|
|
|
context.commit("update_msg_info", msg)
|
|
context.commit("update_open_dialog_info", true)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_get_data_status", 3)
|
|
}
|
|
},
|
|
async doaction(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.doaction(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_dialog_action", false)
|
|
context.dispatch("search", prm)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async printcount(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.printcount(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_dialog_action", false)
|
|
var xprm = prm
|
|
console.log(xprm)
|
|
if (context.state.search_lab_no === '') {
|
|
context.dispatch("search", xprm)
|
|
}
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async deletephoto(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.deletephoto(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_act", '-')
|
|
context.commit("update_dialog_confirmation_delete", false)
|
|
context.commit("update_selected_photo", {})
|
|
context.dispatch("search", prm)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async searchcompany(context, prm) {
|
|
context.commit("update_autocomplete_status", 1)
|
|
try {
|
|
//console.log(prm)
|
|
let resp = await api.searchcompany(one_token(), prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_autocomplete_status", 3)
|
|
} else {
|
|
context.commit("update_autocomplete_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_companies", resp.data.records)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_autocomplete_status", 3)
|
|
}
|
|
},
|
|
async getdoctoraddress(context, prm) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.getdoctoraddress(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status", 3)
|
|
} else {
|
|
context.commit("update_get_data_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_doctor_address", data.records)
|
|
context.commit("update_selected_doctor_address", {})
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async getordersamples(context, prm) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.getordersamples(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status", 3)
|
|
} else {
|
|
context.commit("update_get_data_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_details", data.records)
|
|
context.commit("update_selected_detail", {})
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_get_data_status", 3)
|
|
}
|
|
},
|
|
async getrstbylang(context, prm) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.getrstbylang(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status", 3)
|
|
} else {
|
|
context.commit("update_get_data_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
var seltrx = prm.selected_trx
|
|
seltrx.details[prm.idx].details = data.records
|
|
seltrx.details[prm.idx].language_id = prm.lang.id
|
|
seltrx.details[prm.idx].language_name = prm.lang.name
|
|
context.commit("update_selected_transaction", seltrx)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_get_data_status", 3)
|
|
}
|
|
},
|
|
async save(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.save(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_selected_transaction", {})
|
|
context.commit("update_details", [])
|
|
context.commit("update_selected_detail", {})
|
|
context.commit("update_selected_doctor", {})
|
|
context.commit("update_selected_doctor_address", {})
|
|
context.commit("update_selected_courier", {})
|
|
context.commit("update_trx_date", moment(new Date()).format('YYYY-MM-DD'))
|
|
context.commit("update_trx_note", '')
|
|
context.commit("update_act", 'new')
|
|
context.commit("update_dialog_success", true)
|
|
context.commit("update_last_id", resp.data.id)
|
|
var msg = "Transaksi penyimpanan " + resp.data.numbering + " berhasil dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async deletetrx(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.deletetrx(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_selected_transaction", {})
|
|
context.commit("update_details", [])
|
|
context.commit("update_selected_detail", {})
|
|
context.commit("update_selected_doctor", {})
|
|
context.commit("update_selected_doctor_address", {})
|
|
context.commit("update_selected_courier", {})
|
|
context.commit("update_trx_date", moment(new Date()).format('YYYY-MM-DD'))
|
|
context.commit("update_trx_note", '')
|
|
context.commit("update_act", 'new')
|
|
context.commit("update_dialog_confirmation_delete", false)
|
|
context.commit("update_dialog_success", true)
|
|
var msg = "Transaksi hapus " + prm.trx_numbering + " berhasil dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async saveresult(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.saveresult(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
context.commit("update_dialog_action", false);
|
|
context.commit("update_msg_info", resp.message)
|
|
context.commit("update_open_dialog_info", true)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
//context.commit("update_last_id",prm.lastid)
|
|
context.commit("update_dialog_action", false)
|
|
var msg = "Order " + prm.trx_numbering + " pemeriksaan <span class='red--text'>" + prm.trx.test_name + "</span> berhasil diupdate dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
context.commit("update_dialog_success", true)
|
|
if (context.state.search_lab_no !== '' && prm.act !== "unval1") {
|
|
console.log(context.state.next_url)
|
|
console.log(context.state.search_bynolab)
|
|
console.log(context.state.location_id)
|
|
window.location = "/one-ui/" + context.state.next_url + "?labnumber=" + context.state.search_lab_no + "&stat=" + context.state.station_id + "&loc=" + context.state.location_id
|
|
} else if (context.state.search_lab_no !== '' && prm.act === "unval1") {
|
|
location.reload()
|
|
}
|
|
}
|
|
} catch (e) {
|
|
console.log(e);
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async gettemplate(context, prm) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.gettemplate(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status", 3)
|
|
} else {
|
|
context.commit("update_get_data_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
if (data.records) {
|
|
var temp_val = data.records
|
|
context.commit("update_templates", temp_val)
|
|
context.commit("update_selected_template", temp_val[0])
|
|
context.commit("update_dialog_template", true)
|
|
/*var seltrx = context.state.selected_transaction
|
|
|
|
seltrx.details[prm.idx].details.forEach(function(temp,index) {
|
|
var template_detail_id = seltrx.details[prm.idx].details[index].template_detail_id
|
|
var value_now = seltrx.details[prm.idx].details[index].result_value
|
|
var filter_temp = _.filter(temp_val, function(o) { return o.So_TemplateDetailID === template_detail_id })
|
|
if(!value_now || value_now === ''){
|
|
seltrx.details[prm.idx].details[index].result_value = filter_temp[0].So_TemplateValueText
|
|
}
|
|
|
|
})*/
|
|
|
|
//context.commit("update_selected_transaction",seltrx)
|
|
}
|
|
else {
|
|
var msg = "Belum dibuat dong template nya"
|
|
context.commit("update_msg_info", msg)
|
|
context.commit("update_open_dialog_info", true)
|
|
}
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_get_data_status", 3)
|
|
}
|
|
},
|
|
async getdoctorlist(context, prm) {
|
|
context.commit("update_autocomplete_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
|
|
let resp = await api.getdoctor(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_autocomplete_status", 3)
|
|
} else {
|
|
context.commit("update_autocomplete_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_doctorList", data.records)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_autocomplete_status", 3)
|
|
}
|
|
},
|
|
async savedoctor(context, prm) {
|
|
context.commit("update_autocomplete_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.savedoctor(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_autocomplete_status", 3)
|
|
} else {
|
|
context.commit("update_autocomplete_status", 2)
|
|
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
if (context.state.search_lab_no === '') {
|
|
context.commit("update_doctorList", data.records)
|
|
context.commit("update_dialogDoctor", false)
|
|
context.commit("update_selectedDoctor", {})
|
|
context.commit("update_selectedDoctor", {})
|
|
context.commit("update_searchDoctor", '')
|
|
context.dispatch("search", prm)
|
|
} else {
|
|
location.reload()
|
|
}
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_autocomplete_status", 3)
|
|
}
|
|
},
|
|
async getattachments(context, prm) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.getattachments(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_get_data_status", 3)
|
|
} else {
|
|
context.commit("update_get_data_status", 2)
|
|
context.commit("update_attachments", resp.data.records)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_get_data_status", 3)
|
|
}
|
|
}
|
|
}
|
|
} |