// 1 => LOADING // 2 => DONE // 3 => ERROR import * as api from "../api/photo.js" window.api = api export default { namespaced: true, state: { dialog_photo: false, photo_64: '', photo_url: '/one-ui/undraw_tabs_tlxz.svg', default_photo_url: '/one-ui/undraw_tabs_tlxz.svg', patient_id: 0, resp_data: {}, resp_msg: '' }, mutations: { update_dialog_photo(state, v) { state.dialog_photo = v }, update_photo_64(state, data) { state.photo_64 = data }, update_photo_url(state, data) { state.photo_url = data }, update_patient_id(state, id) { state.patient_id = id }, update_resp_data(state, data) { state.resp_data = data }, update_resp_msg(state, data) { state.resp_msg = data } }, actions: { async upload(context) { try { console.log(context.rootState.patient.selected_patient) let resp = await api.upload(one_token(), context.rootState.patient.selected_patient.M_PatientID, context.state.photo_64) if (resp.status != "OK") { context.commit('update_resp_data', resp.data.message) console.log(resp) } else { context.commit('update_photo_url', resp.data.photo_url); context.commit('update_dialog_photo', false) context.commit('update_resp_data', resp.data.data) context.commit('update_resp_msg', resp.data.message) } } catch (e) { console.log(e) } } } }