irc_web/src/store/modules/trials.js

87 lines
2.0 KiB
JavaScript

import { getSignText } from '@/api/trials'
const getDefaultState = () => {
return {
trialDetailActiveName: '',
trialQuery: null,
subjectQuery: null,
visitPlanQuery: null,
visitPointQuery: null,
studyListQuery: null,
unlock: false,
config: {},
uploadTip: '0.00KB/s',
timer: null,
whiteList: [],
checkTaskId: null
}
}
const state = getDefaultState
const mutations = {
RESET_TRIALS: (state) => {
Object.assign(state, getDefaultState())
},
SET_UNLOCK: (state, unlock) => {
state.unlock = unlock
},
SET_CONFIG: (state, config) => {
state.config = config
},
SET_ACTIVENAME: (state, activeName) => {
state.trialDetailActiveName = activeName
},
SET_QUERYPARAM: (state, trialQuery) => {
state.trialQuery = trialQuery
},
SET_SUBJECTPARAM: (state, subjectQuery) => {
state.subjectQuery = subjectQuery
},
SET_VISITPLANPARAM: (state, visitPlanQuery) => {
state.visitPlanQuery = visitPlanQuery
},
SET_VISITPOINTPARAM: (state, visitPointQuery) => {
state.visitPointQuery = visitPointQuery
},
SET_STUDYLISTPARAM: (state, studyListQuery) => {
state.studyListQuery = studyListQuery
}
}
const actions = {
setUnLock({ commit }, unlock) {
commit('SET_UNLOCK', unlock)
},
setConfig({ commit }, config) {
commit('SET_CONFIG', config)
},
setActiveName({ commit }, activeName) {
commit('SET_ACTIVENAME', activeName)
},
resetState({ commit }) {
commit('RESET_TRIALS')
},
getSignInfo({ commit }, signInfo) {
const { signCode } = signInfo
return new Promise((resolve, reject) => {
getSignText(signCode).then(response => {
if (response.IsSuccess) {
resolve(response.Result)
} else {
reject(response.ErrorMessage)
}
}).catch(() => {
reject()
})
})
}
}
export default {
namespaced: true,
state,
mutations,
actions
}