// 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) } } } }