691 lines
26 KiB
JavaScript
691 lines
26 KiB
JavaScript
// 1 => LOADING
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/testcalculation.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
last_id: -1,
|
|
last_saved_id: -1,
|
|
x_pat_id: 0,
|
|
act: 'edit',
|
|
act_comp: 'new',
|
|
act_pat: 'new',
|
|
act_send: 'N',
|
|
get_data_status: 0,
|
|
search_testcalculation: 0,
|
|
search_status: 0,
|
|
search_error_message: '',
|
|
dialog_form_order: false,
|
|
dialog_edit_form_order:false,
|
|
dialog_status_order: false,
|
|
norm: '',
|
|
testcalculation_name: '',
|
|
testcalculations: [],
|
|
total_testcalculations: 0,
|
|
testcalculation_detail: [],
|
|
date: '',
|
|
note: '',
|
|
companyid: 0,
|
|
companyname: '',
|
|
mouid: 0,
|
|
mouname: '',
|
|
sdate:moment(new Date()).format('YYYY-MM-DD'),
|
|
companies: [],
|
|
company: {},
|
|
mous: [],
|
|
mou: {},
|
|
total_testcalculation: 0,
|
|
selected_testcalculation: {},
|
|
codenumber:{},
|
|
codenumberx:'',
|
|
save_status: 0,
|
|
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: "",
|
|
dialog_confirmation_send: false,
|
|
msg_confirmation_send: "",
|
|
dialog_confirmation_delete_pat: false,
|
|
msg_confirmation_delete_pat: "",
|
|
autocomplete_status: 0,
|
|
dialog_form_detail: false,
|
|
errors: [],
|
|
details: [],
|
|
namacalculation: '',
|
|
rumus: '',
|
|
dob: '',
|
|
sexes: [],
|
|
selected_sex: {},
|
|
titles: [],
|
|
selected_title: {},
|
|
orderautotests:[],
|
|
orderautotest:{},
|
|
autotests:[],
|
|
autotest:{},
|
|
ordertests:[],
|
|
deleted_ordertests:[],
|
|
ordertestfavorits:[],
|
|
statuss:[],
|
|
isage: 'N',
|
|
issex: 'N',
|
|
xisage: 'N',
|
|
xissex: 'N',
|
|
rumusx: ''
|
|
},
|
|
mutations: {
|
|
update_x_pat_id(state, val) {
|
|
state.x_pat_id = val
|
|
},
|
|
update_last_id(state, val) {
|
|
state.last_id = val
|
|
},
|
|
update_last_saved_id(state, val) {
|
|
state.last_saved_id = val
|
|
},
|
|
update_act(state, val) {
|
|
state.act = val
|
|
},
|
|
update_act_comp(state, val) {
|
|
state.act_comp = val
|
|
},
|
|
update_act_pat(state, val) {
|
|
state.act_pat = val
|
|
},
|
|
update_act_send(state, val) {
|
|
state.act_send = val
|
|
},
|
|
update_get_data_status(state, val) {
|
|
state.get_data_status = val
|
|
},
|
|
update_search_error_message(state, testcalculation) {
|
|
state.search_error_message = testcalculation
|
|
},
|
|
update_search_testcalculation(state, testcalculation) {
|
|
state.search_testcalculation = testcalculation
|
|
},
|
|
update_dialog_form_order(state, val) {
|
|
state.dialog_form_order = val
|
|
},
|
|
update_dialog_edit_form_order(state, val) {
|
|
state.dialog_edit_form_order = val
|
|
},
|
|
update_dialog_status_order(state, val) {
|
|
state.dialog_status_order = val
|
|
},
|
|
update_testcalculation_name(state, val) {
|
|
state.testcalculation_name = val
|
|
},
|
|
update_date(state, val) {
|
|
state.date = val
|
|
},
|
|
update_sdate(state,val){
|
|
state.sdate = val
|
|
},
|
|
update_note(state, val) {
|
|
state.note = val
|
|
},
|
|
update_companyid(state, val) {
|
|
state.companyid = val
|
|
},
|
|
update_companyname(state, val) {
|
|
state.companyname = val
|
|
},
|
|
update_mouid(state, val) {
|
|
state.mouid = val
|
|
},
|
|
update_mouname(state, val) {
|
|
state.mouname = val
|
|
},
|
|
update_testcalculations(state, data) {
|
|
state.testcalculations = data
|
|
},
|
|
update_selected_testcalculation(state, val) {
|
|
state.selected_testcalculation = val
|
|
},
|
|
update_codenumber(state, val) {
|
|
state.codenumber = val
|
|
},
|
|
update_codenumberx(state, val) {
|
|
state.codenumberx = 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_dialog_confirmation_send(state, val) {
|
|
state.dialog_confirmation_send = val
|
|
},
|
|
update_msg_confirmation_send(state, val) {
|
|
state.msg_confirmation_send = val
|
|
},
|
|
update_dialog_confirmation_delete_pat(state, val) {
|
|
state.dialog_confirmation_delete_pat = val
|
|
},
|
|
update_msg_confirmation_delete_pat(state, val) {
|
|
state.msg_confirmation_delete_pat = val
|
|
},
|
|
update_details(state, val) {
|
|
state.details = val
|
|
},
|
|
update_autocomplete_status(state, val) {
|
|
state.autocomplete_status = val
|
|
},
|
|
update_dialog_form_detail(state, val) {
|
|
state.dialog_form_detail = val
|
|
},
|
|
update_label_detail(state, val) {
|
|
state.label_detail = val
|
|
},
|
|
update_companies(state, val) {
|
|
state.companies = val
|
|
},
|
|
update_company(state, val) {
|
|
state.company = val
|
|
},
|
|
update_mous(state, val) {
|
|
state.mous = val
|
|
},
|
|
update_mou(state, val) {
|
|
state.mou = val
|
|
},
|
|
update_search_status(state, val) {
|
|
state.search_status = val
|
|
},
|
|
update_errors(state, val) {
|
|
state.errors = val
|
|
},
|
|
update_total_testcalculations(state, val) {
|
|
state.total_testcalculations = val
|
|
},
|
|
update_dob(state, val) {
|
|
state.dob = val
|
|
},
|
|
update_namacalculation(state, val) {
|
|
state.namacalculation = val
|
|
},
|
|
update_rumus(state, val) {
|
|
state.rumus = val
|
|
},
|
|
update_sexes(state, val) {
|
|
state.sexes = val
|
|
},
|
|
update_selected_sex(state, val) {
|
|
state.selected_sex = val
|
|
},
|
|
update_titles(state, val) {
|
|
state.titles = val
|
|
},
|
|
update_selected_title(state, val) {
|
|
state.selected_title = val
|
|
},
|
|
update_orderautotests(state,data){
|
|
state.orderautotests = data
|
|
},
|
|
update_orderautotest(state,val){
|
|
state.orderautotest = val
|
|
},
|
|
update_autotests(state,data){
|
|
state.autotests = data
|
|
},
|
|
update_autotest(state,val){
|
|
state.autotest = val
|
|
},
|
|
update_ordertests(state,data){
|
|
state.ordertests = data
|
|
},
|
|
update_deleted_ordertests(state,data){
|
|
state.deleted_ordertests = data
|
|
},
|
|
update_ordertestfavorits(state,data){
|
|
state.ordertestfavorits = data
|
|
},
|
|
update_statuss(state,data){
|
|
state.statuss = data
|
|
},
|
|
update_isage(state, val) {
|
|
state.isage = val
|
|
},
|
|
update_issex(state, val) {
|
|
state.issex = val
|
|
},
|
|
update_xisage(state, val) {
|
|
state.xisage = val
|
|
},
|
|
update_xissex(state, val) {
|
|
state.xissex = val
|
|
},
|
|
update_rumusx(state, val) {
|
|
state.rumusx = val
|
|
}
|
|
},
|
|
actions: {
|
|
async search(context, prm) {
|
|
context.commit("update_search_testcalculation", 1)
|
|
try {
|
|
let resp = await api.search(one_token(), prm.name)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_search_testcalculation", 3)
|
|
context.commit("update_search_error_message", resp.message)
|
|
} else {
|
|
context.commit("update_search_testcalculation", 2)
|
|
context.commit("update_search_error_message", "")
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_testcalculations", data.records)
|
|
context.commit("update_total_testcalculations", data.total)
|
|
context.commit("update_no_save", 0)
|
|
if (prm.lastid === -1) {
|
|
context.commit("update_selected_testcalculation", data.records[0])
|
|
var pat = data.records[0]
|
|
context.commit("update_rumusx", pat.T_TestCalculationFormula)
|
|
|
|
context.commit("update_x_pat_id", pat.T_TestCalculationID)
|
|
context.commit("update_namacalculation", pat.T_TestCalculationName)
|
|
context.commit("update_rumus", pat.T_TestCalculationFormula)
|
|
context.commit("update_autotests", [{
|
|
Nat_TestID: pat.T_TestCalculationNat_TestID,
|
|
Nat_TestName: pat.Nat_TestName
|
|
}])
|
|
context.commit("update_autotest", {
|
|
Nat_TestID: pat.T_TestCalculationNat_TestID,
|
|
Nat_TestName: pat.Nat_TestName
|
|
})
|
|
context.commit("update_selected_sex", {
|
|
Nat_SexID: pat.T_TestCalculationNat_SexID,
|
|
Nat_SexName: pat.Nat_SexName
|
|
})
|
|
context.dispatch("getdetail", {
|
|
id: pat.T_TestCalculationID
|
|
})
|
|
} else {
|
|
context.commit("update_selected_testcalculation", data.records[prm.lastid])
|
|
var pat = data.records[prm.lastid]
|
|
context.commit("update_isage", pat.T_TestCalculationIsAge)
|
|
context.commit("update_issex", pat.T_TestCalculationIsSex)
|
|
context.commit("update_rumusx", pat.T_TestCalculationFormula)
|
|
|
|
context.commit("update_x_pat_id", pat.T_TestCalculationID)
|
|
context.commit("update_namacalculation", pat.T_TestCalculationName)
|
|
context.commit("update_rumus", pat.T_TestCalculationFormula)
|
|
context.commit("update_autotests", [{
|
|
Nat_TestID: pat.T_TestCalculationNat_TestID,
|
|
Nat_TestName: pat.Nat_TestName
|
|
}])
|
|
context.commit("update_autotest", {
|
|
Nat_TestID: pat.T_TestCalculationNat_TestID,
|
|
Nat_TestName: pat.Nat_TestName
|
|
})
|
|
context.commit("update_selected_sex", {
|
|
Nat_SexID: pat.T_TestCalculationNat_SexID,
|
|
Nat_SexName: pat.Nat_SexName
|
|
})
|
|
context.dispatch("getdetail", {
|
|
id: pat.T_TestCalculationID
|
|
})
|
|
}
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_search_testcalculation", 3)
|
|
context.commit("update_search_error_message", e.message)
|
|
console.log(e)
|
|
}
|
|
},
|
|
async getsexreg(context,prm) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
prm.sexid = prm.sexid
|
|
let resp = await api.getsexreg(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_titles", data.records.titles)
|
|
context.commit("update_sexes", data.records.sexes)
|
|
}
|
|
} 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_last_id", prm.id)
|
|
context.commit("update_dialog_success", true)
|
|
var msg = "Data nomor " + prm.nomor + " sudah terupdate dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
context.commit("update_dialog_form_order", false)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async newtestcalculation(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.newtestcalculation(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
console.log(resp.data.id)
|
|
context.commit("update_last_id", resp.data.id)
|
|
context.commit("update_dialog_success", true)
|
|
var msg = "Data berhasil disimpan"
|
|
context.commit("update_msg_success", msg)
|
|
context.commit("update_dialog_form_order", false)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async delete(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.xdelete(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_last_id", 0)
|
|
context.commit("update_dialog_confirmation_delete", false)
|
|
context.commit("update_dialog_success", true)
|
|
var msg = "Data nomor" + prm.T_ReceiveReferenceHeaderNumber + " sudah dihapus dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async sendorder(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.sendorder(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_dialog_confirmation_send", false)
|
|
context.commit("update_last_id", prm.T_TestCalculationID)
|
|
context.commit("update_dialog_success", true)
|
|
var msg = "Permintaan nomor " + prm.T_ReceiveReferenceHeaderNumber + " sudah berhasil dikirim ..."
|
|
context.commit("update_msg_success", msg)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async getdetail(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.getdetail(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
let data = {
|
|
records: resp.data.records,
|
|
total: resp.data.total
|
|
}
|
|
context.commit("update_details", data.records)
|
|
var pat = data.records[0]
|
|
context.commit("update_ordertests", pat.tests)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
|
|
async searchcompany(context, prm) {
|
|
context.commit("update_autocomplete_status", 1)
|
|
try {
|
|
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 getmou(context, prm) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
let resp = await api.getmou(one_token(), 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_mous", resp.data.records)
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_get_data_status", 3)
|
|
}
|
|
},
|
|
async searchtest(context,prm) {
|
|
context.commit("update_autocomplete_status",1)
|
|
try {
|
|
let resp= await api.searchtest(one_token(), prm.tes)
|
|
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_orderautotests",resp.data.records)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_autocomplete_status",3)
|
|
}
|
|
},
|
|
async getnumberx(context,prm) {
|
|
context.commit("update_get_data_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.getnumberx(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,
|
|
number: resp.data.number
|
|
}
|
|
context.commit("update_codenumber", data.records[0])
|
|
context.commit("update_codenumberx", data.number)
|
|
var oldArr = context.state.ordertests
|
|
console.log(oldArr)
|
|
var arrTest = data.records[0]
|
|
oldArr.push(arrTest)
|
|
|
|
context.commit("update_orderautotests", [])
|
|
context.commit("update_orderautotest", {})
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_get_data_status", 3)
|
|
}
|
|
},
|
|
async deletenumberx(context,prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.deletenumberx(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async searchtestheader(context,prm) {
|
|
context.commit("update_autocomplete_status",1)
|
|
try {
|
|
let resp= await api.searchtestheader(one_token(), prm.tes)
|
|
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_autotests",resp.data.records)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_autocomplete_status",3)
|
|
}
|
|
},
|
|
async searchtestfavorit(context,prm) {
|
|
context.commit("update_autocomplete_status",1)
|
|
try {
|
|
let resp= await api.searchtestfavorit(one_token(), prm.mouid)
|
|
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_ordertestfavorits",resp.data.records)
|
|
}
|
|
} catch(e) {
|
|
context.commit("update_autocomplete_status",3)
|
|
}
|
|
},
|
|
async savenewdetail(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.savenewdetail(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_dialog_form_detail", false)
|
|
context.commit("update_last_id", resp.data.id)
|
|
context.commit("update_dialog_success", true)
|
|
var msg = "Penambahan data rumus " + prm.T_TestCalculationName + " sudah berhasil dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async saveeditdetail(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.saveeditdetail(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_dialog_form_detail", false)
|
|
context.commit("update_last_id", prm.T_TestCalculationID)
|
|
context.commit("update_dialog_success", true)
|
|
var msg = "Perubahan data rumus " + prm.T_TestCalculationName + " sudah berhasil dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
},
|
|
async deletedetail(context, prm) {
|
|
context.commit("update_save_status", 1)
|
|
try {
|
|
prm.token = one_token()
|
|
let resp = await api.deletedetail(prm)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_save_status", 3)
|
|
} else {
|
|
context.commit("update_save_status", 2)
|
|
context.commit("update_dialog_confirmation_delete_pat", false)
|
|
context.commit("update_last_id", prm.T_TestCalculationID)
|
|
context.commit("update_dialog_success", true)
|
|
var msg = "Penghapusan data rumus " + prm.T_TestCalculationName + " sudah berhasil dong ..."
|
|
context.commit("update_msg_success", msg)
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_save_status", 3)
|
|
}
|
|
}
|
|
}
|
|
} |