87 lines
3.0 KiB
JavaScript
87 lines
3.0 KiB
JavaScript
|
|
// 2 => DONE
|
|
// 3 => ERROR
|
|
import * as api from "../api/email.js"
|
|
|
|
export default {
|
|
namespaced: true,
|
|
state: {
|
|
loading: false,
|
|
error: '',
|
|
format:'',
|
|
},
|
|
mutations: {
|
|
update_loading(state, val) {
|
|
state.loading= val
|
|
},
|
|
update_error(state, val) {
|
|
state.error= val
|
|
},
|
|
update_format(state, val) {
|
|
state.format = val
|
|
},
|
|
},
|
|
actions: {
|
|
async get(context, trx) {
|
|
context.commit("update_loading", true)
|
|
try {
|
|
let type= context.rootState.sample.typeresult.id
|
|
let prm = {orderID : trx.trx_id,
|
|
type: type,
|
|
token: one_token()
|
|
}
|
|
context.commit("update_format", '')
|
|
let resp = await api.get(prm)
|
|
context.commit("update_loading", false)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_error", resp.message)
|
|
} else {
|
|
context.commit("update_error", "")
|
|
let dt = resp.data
|
|
if (dt.length > 0 ) {
|
|
let format = dt[0].T_EmailNonLabFormat
|
|
context.commit("update_format", format)
|
|
}
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_error", e.message)
|
|
}
|
|
},
|
|
async save(context, prm) {
|
|
context.commit("update_loading", true)
|
|
try {
|
|
prm.token = one_token()
|
|
context.commit("update_format", '')
|
|
let resp = await api.save(prm)
|
|
context.commit("update_loading", false)
|
|
if (resp.status != "OK") {
|
|
context.commit("update_error", resp.message)
|
|
} else {
|
|
context.commit("update_error", "")
|
|
console.log("dasdasdas")
|
|
|
|
var xprm = {
|
|
startdate:context.rootState.sample.start_date,
|
|
companyid:context.rootState.sample.selected_company.id,
|
|
switch_exclude:context.rootState.sample.switch_exclude,
|
|
search:context.rootState.sample.name_lab,
|
|
stationid:context.rootState.sample.selected_station.id,
|
|
groupid:context.rootState.sample.select_item_group.id,
|
|
subgroupid:context.rootState.sample.select_item_subgroup.id,
|
|
current_page:context.rootState.sample.current_page,
|
|
lastid:context.rootState.sample.last_id
|
|
}
|
|
|
|
console.log(xprm)
|
|
context.dispatch("sample/search",xprm,{root:true})
|
|
|
|
|
|
}
|
|
} catch (e) {
|
|
context.commit("update_error", e.message)
|
|
}
|
|
},
|
|
}
|
|
}
|