Flatten nested repos
This commit is contained in:
86
test/vuex/one-process-ref-out/modules/company.js
Normal file
86
test/vuex/one-process-ref-out/modules/company.js
Normal file
@@ -0,0 +1,86 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/company.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search_status: 0,
|
||||
search_error_message: '',
|
||||
|
||||
query: '',
|
||||
companies: [],
|
||||
selected_company: {},
|
||||
total_company: 0,
|
||||
total_company_page: 0,
|
||||
curr_company_page: 1,
|
||||
|
||||
is_internal: "N"
|
||||
},
|
||||
mutations: {
|
||||
|
||||
update_search_error_message(state, patient) {
|
||||
state.search_error_message = patient
|
||||
},
|
||||
|
||||
update_search_status(state, v) {
|
||||
state.search_status = v
|
||||
},
|
||||
|
||||
update_query(state, q) {
|
||||
state.query = q
|
||||
},
|
||||
|
||||
update_companies(state, d) {
|
||||
state.companies = d.records
|
||||
state.total_company = d.total
|
||||
state.total_company_page = d.total_page
|
||||
},
|
||||
|
||||
update_selected_company(state, d) {
|
||||
state.selected_company = d
|
||||
},
|
||||
|
||||
update_curr_company_page(state, d) {
|
||||
state.curr_company_page = d
|
||||
},
|
||||
|
||||
update_is_internal(state, d) {
|
||||
state.is_internal = d
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context) {
|
||||
|
||||
try {
|
||||
let resp = await api.search(context.state.query, context.state.is_internal, context.state.curr_company_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('patient/update_patients', {records:[],total:0,total_page:0}, {root:true})
|
||||
context.commit('patient/update_curr_patient_page', 1, {root:true})
|
||||
try {
|
||||
context.commit('update_selected_company', data.records[0])
|
||||
context.commit('patient/update_selected_order', [], {root:true})
|
||||
context.dispatch('patient/search', null, {root:true})
|
||||
} catch(ee) {}
|
||||
context.commit("update_companies", data)
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
111
test/vuex/one-process-ref-out/modules/patient.js
Normal file
111
test/vuex/one-process-ref-out/modules/patient.js
Normal file
@@ -0,0 +1,111 @@
|
||||
// 1 => LOADING
|
||||
// 2 => DONE
|
||||
// 3 => ERROR
|
||||
import * as api from "../api/patient.js"
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state: {
|
||||
search_status: 0,
|
||||
search_error_message: '',
|
||||
|
||||
query: '',
|
||||
patients: [],
|
||||
selected_patient: {},
|
||||
total_patient: 0,
|
||||
total_patient_page: 0,
|
||||
curr_patient_page: 1,
|
||||
|
||||
is_internal: "N",
|
||||
snackbar: false,
|
||||
selected_order: []
|
||||
},
|
||||
mutations: {
|
||||
|
||||
update_search_error_message(state, patient) {
|
||||
state.search_error_message = patient
|
||||
},
|
||||
|
||||
update_search_status(state, v) {
|
||||
state.search_status = v
|
||||
},
|
||||
|
||||
update_query(state, q) {
|
||||
state.query = q
|
||||
},
|
||||
|
||||
update_patients(state, d) {
|
||||
state.patients = d.records
|
||||
state.total_patient = d.total
|
||||
state.total_patient_page = d.total_page
|
||||
},
|
||||
|
||||
update_selected_patient(state, d) {
|
||||
state.selected_patient = d
|
||||
},
|
||||
|
||||
update_curr_patient_page(state, d) {
|
||||
state.curr_patient_page = d
|
||||
},
|
||||
|
||||
update_is_internal(state, d) {
|
||||
state.is_internal = d
|
||||
},
|
||||
|
||||
update_snackbar(state, d) {
|
||||
state.snackbar = d
|
||||
},
|
||||
|
||||
update_selected_order(state, d) {
|
||||
state.selected_order = d
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
async search(context) {
|
||||
|
||||
try {
|
||||
let resp = await api.search(context.state.query, context.rootState.company.selected_company.company_id, context.rootState.company.is_internal, 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)
|
||||
}
|
||||
},
|
||||
|
||||
async send(context, ids) {
|
||||
|
||||
try {
|
||||
let resp = await api.send(one_token(), 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", "")
|
||||
|
||||
context.commit('update_snackbar', true)
|
||||
context.commit('update_selected_order', [])
|
||||
context.dispatch("search")
|
||||
}
|
||||
} catch (e) {
|
||||
context.commit("update_search_status", 3)
|
||||
context.commit("update_search_error_message", e.message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user