Flatten nested repos
This commit is contained in:
266
test/vuex/one-process-reference-out/modules/ro_master.js
Normal file
266
test/vuex/one-process-reference-out/modules/ro_master.js
Normal file
@@ -0,0 +1,266 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/ro_master.js"
|
||||
window.api = api
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search: '',
|
||||
search_company_id: 0,
|
||||
|
||||
search_status:0,
|
||||
search_error_message:'',
|
||||
search_dialog_is_active: false,
|
||||
|
||||
pxs: [],
|
||||
total_px: 0,
|
||||
total_px_page: 0,
|
||||
curr_px_page: 1,
|
||||
selected_px: { },
|
||||
|
||||
companies: [],
|
||||
total_company: 0,
|
||||
selected_company: {},
|
||||
search_company: "",
|
||||
|
||||
tests: [],
|
||||
total_test: 0,
|
||||
selected_test: {},
|
||||
search_test: "",
|
||||
|
||||
regionals: [],
|
||||
total_regional: 0,
|
||||
selected_regional: {},
|
||||
|
||||
branches: [],
|
||||
total_branch: 0,
|
||||
selected_branch: {},
|
||||
|
||||
dialog_main: false,
|
||||
|
||||
add_is_internal: "N"
|
||||
},
|
||||
mutations: {
|
||||
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_pxs(state, data) {
|
||||
state.pxs= data.records
|
||||
state.total_px = data.total
|
||||
state.total_px_page = data.total_page
|
||||
},
|
||||
|
||||
update_curr_px_page(state, data) {
|
||||
state.curr_px_page = data
|
||||
},
|
||||
|
||||
update_selected_px(state,val) {
|
||||
state.selected_px=val
|
||||
},
|
||||
|
||||
update_search_company_id(state, id) {
|
||||
state.search_company_id = id
|
||||
},
|
||||
|
||||
update_dialog_main(state, v) {
|
||||
state.dialog_main = v
|
||||
},
|
||||
|
||||
update_companies(state, data) {
|
||||
state.companies = data.records
|
||||
state.total_company = data.total
|
||||
},
|
||||
|
||||
update_selected_company(state, val) {
|
||||
state.selected_company = val
|
||||
},
|
||||
|
||||
update_search_company(state, val) {
|
||||
state.search_company = val
|
||||
},
|
||||
|
||||
update_tests(state, data) {
|
||||
state.tests = data.records
|
||||
state.total_test = data.total
|
||||
},
|
||||
|
||||
update_selected_test(state, val) {
|
||||
state.selected_test =val
|
||||
},
|
||||
|
||||
update_search_test(state, val) {
|
||||
state.search_test = val
|
||||
},
|
||||
|
||||
update_regionals(state, data) {
|
||||
state.regionals = data.records
|
||||
state.total_regional = data.total
|
||||
},
|
||||
|
||||
update_selected_regional(state, val) {
|
||||
state.selected_regional = val
|
||||
state.branches = val.branches
|
||||
state.selected_branch = {}
|
||||
},
|
||||
|
||||
update_branches(state, data) {
|
||||
state.branches = data.records
|
||||
state.total_branch = data.total
|
||||
},
|
||||
|
||||
update_selected_branch(state, val) {
|
||||
state.selected_branch =val
|
||||
},
|
||||
|
||||
update_add_is_internal(state, val) {
|
||||
state.add_is_internal = val
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context) {
|
||||
context.commit("update_search_status", 1)
|
||||
try {
|
||||
let resp= await api.search(one_token(), context.state.sdate, context.state.nolab, context.state.search, context.state.curr_patient_page)
|
||||
|
||||
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_page: resp.data.total_page
|
||||
}
|
||||
context.commit("update_pxs", data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async search_company(context, prm) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
let resp= await api.search_company(context.state.search_company)
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status",2)
|
||||
context.commit("update_search_error_message","")
|
||||
let data = {
|
||||
records : resp.data.records,
|
||||
total: resp.data.total
|
||||
}
|
||||
|
||||
context.commit("update_companies", data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
},
|
||||
|
||||
async search_test(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
|
||||
let ids = []
|
||||
for (let i in context.state.pxs)
|
||||
ids.push(context.state.pxs[i].T_TestID)
|
||||
|
||||
let resp = await api.search_px(context.state.search_test, JSON.stringify(ids))
|
||||
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 save(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
|
||||
let data = []
|
||||
for (let i in context.state.pxs) {
|
||||
data.push({
|
||||
t_id:context.state.pxs[i].T_TestID,
|
||||
c_id:context.state.pxs[i].M_CompanyID,
|
||||
id:context.state.pxs[i].T_OrderRefMasterID,
|
||||
b_id:context.state.pxs[i].M_BranchID,
|
||||
g_id:context.state.pxs[i].S_RegionalID,
|
||||
is_int:context.state.pxs[i].is_internal
|
||||
})
|
||||
}
|
||||
|
||||
let resp= await api.save(JSON.stringify(data))
|
||||
if (resp.status != "OK") {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message", resp.message)
|
||||
} else {
|
||||
context.commit("update_search_status",2)
|
||||
context.commit("update_search_error_message","")
|
||||
|
||||
context.dispatch("search")
|
||||
context.commit('update_dialog_main', false)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
|
||||
async search_regional(context) {
|
||||
context.commit("update_search_status",1)
|
||||
try {
|
||||
|
||||
let resp = await api.search_regional()
|
||||
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_regionals", data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
137
test/vuex/one-process-reference-out/modules/ro_patient.js
Normal file
137
test/vuex/one-process-reference-out/modules/ro_patient.js
Normal file
@@ -0,0 +1,137 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/ro_patient.js"
|
||||
window.api = api
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
order_id:0,
|
||||
search: '',
|
||||
nolab: '',
|
||||
sdate: null,
|
||||
edate: null,
|
||||
|
||||
search_status:0,
|
||||
search_error_message:'',
|
||||
search_dialog_is_active: false,
|
||||
|
||||
patients: [],
|
||||
total_patient: 0,
|
||||
total_patient_page: 0,
|
||||
curr_patient_page: 1,
|
||||
selected_patient: { },
|
||||
selected_patients: [],
|
||||
checked: [],
|
||||
|
||||
|
||||
// PX
|
||||
total_px: 0,
|
||||
pxs: [],
|
||||
|
||||
// Print
|
||||
print_dialog: false,
|
||||
rpt_url: ''
|
||||
},
|
||||
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_nolab(state, val) {
|
||||
state.nolab = 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_patient_page = data.total_page
|
||||
|
||||
let x = []
|
||||
for (let i in data.records)
|
||||
x.push("N")
|
||||
state.checked = x
|
||||
},
|
||||
|
||||
update_curr_patient_page(state, data) {
|
||||
state.curr_patient_page = data
|
||||
},
|
||||
|
||||
update_selected_patient(state,val) {
|
||||
state.selected_patient=val
|
||||
},
|
||||
|
||||
update_id(state, id) {
|
||||
state.order_id = id
|
||||
},
|
||||
|
||||
update_sdate(state, date) {
|
||||
state.sdate = date
|
||||
},
|
||||
|
||||
update_edate(state, date) {
|
||||
state.edate = date
|
||||
},
|
||||
|
||||
update_print_dialog(state, v) {
|
||||
state.print_dialog = v
|
||||
},
|
||||
|
||||
update_rpt_url(state, v) {
|
||||
state.rpt_url = v
|
||||
},
|
||||
|
||||
update_checked(state, v) {
|
||||
let x = state.checked
|
||||
x[v.idx] = v.val
|
||||
|
||||
// Update selected patients
|
||||
let y = []
|
||||
for (let i in x)
|
||||
if (x[i] == "Y")
|
||||
y.push(state.patients[i])
|
||||
|
||||
state.selected_patients = y
|
||||
state.checked = x
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context) {
|
||||
context.commit("update_search_status", 1)
|
||||
try {
|
||||
let resp= await api.search(one_token(), context.state.sdate, context.state.edate, context.state.nolab, context.state.search, context.state.curr_patient_page)
|
||||
|
||||
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_page: resp.data.total_page
|
||||
}
|
||||
context.commit("update_patients", data)
|
||||
}
|
||||
} catch(e) {
|
||||
context.commit("update_search_status",3)
|
||||
context.commit("update_search_error_message",e.message )
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
83
test/vuex/one-process-reference-out/modules/ro_send.js
Normal file
83
test/vuex/one-process-reference-out/modules/ro_send.js
Normal file
@@ -0,0 +1,83 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/ro_send.js"
|
||||
window.api = api
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
order_id: 0,
|
||||
dialog_main: false,
|
||||
dialog_all: false
|
||||
},
|
||||
mutations: {
|
||||
update_dialog_main(state, v) {
|
||||
state.dialog_main = v
|
||||
},
|
||||
|
||||
update_dialog_all(state, v) {
|
||||
state.dialog_all = v
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async send(context) {
|
||||
|
||||
try {
|
||||
|
||||
let data = []
|
||||
let ptn = context.rootState.ro_patient.selected_patient
|
||||
let tst = ptn.T_TestName
|
||||
for (let i in tst) {
|
||||
if (tst[i].sent != "Y")
|
||||
data.push({o_id:ptn.T_OrderHeaderID, t_id:tst[i].T_TestID, c_id:tst[i].M_CompanyID,
|
||||
is_int:tst[i].is_internal, b_id:tst[i].M_BranchID})
|
||||
}
|
||||
|
||||
let resp = await api.send(one_token(), JSON.stringify(data))
|
||||
if (resp.status != "OK") {
|
||||
alert('error')
|
||||
} else {
|
||||
|
||||
|
||||
context.commit("update_dialog_main", false)
|
||||
context.dispatch("ro_patient/search", null, {root:true})
|
||||
}
|
||||
} catch(e) {
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
|
||||
async send_all(context) {
|
||||
|
||||
try {
|
||||
|
||||
let data = []
|
||||
let ptns = context.rootState.ro_patient.selected_patients
|
||||
|
||||
for (let j in ptns) {
|
||||
let ptn = ptns[j]
|
||||
let tst = ptn.T_TestName
|
||||
|
||||
for (let i in tst) {
|
||||
if (tst[i].sent != "Y")
|
||||
data.push({o_id:ptn.T_OrderHeaderID, t_id:tst[i].T_TestID, c_id:tst[i].M_CompanyID,
|
||||
is_int:tst[i].is_internal, b_id:tst[i].M_BranchID})
|
||||
}
|
||||
}
|
||||
|
||||
let resp = await api.send(one_token(), JSON.stringify(data))
|
||||
if (resp.status != "OK") {
|
||||
alert('error')
|
||||
} else {
|
||||
|
||||
|
||||
context.commit("update_dialog_all", false)
|
||||
context.dispatch("ro_patient/search", null, {root:true})
|
||||
}
|
||||
} catch(e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user