Init project
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
import axios from '@/axios'
|
||||
|
||||
|
||||
const state = {
|
||||
loading: false,
|
||||
AdOneId:undefined,
|
||||
edit:[]
|
||||
};
|
||||
|
||||
const actions = {
|
||||
|
||||
async save({commit}, payload) {
|
||||
try {
|
||||
commit('LOADING', true);
|
||||
await axios.post('admin/ipc',{data: payload});
|
||||
} catch (e) {
|
||||
throw e;
|
||||
} finally {
|
||||
commit('LOADING', false);
|
||||
}
|
||||
},
|
||||
|
||||
async get({commit},id) {
|
||||
try {
|
||||
commit('LOADING', true);
|
||||
let res = await axios.get('admin/ipc/'+id);
|
||||
commit('AdPACKAGE_ID', res.data);
|
||||
} catch (e) {
|
||||
commit('ERROR', e);
|
||||
throw e;
|
||||
} finally {
|
||||
commit('LOADING', false);
|
||||
}
|
||||
},
|
||||
|
||||
async put({commit}, payload) {
|
||||
try{
|
||||
commit('LOADING', true);
|
||||
await axios.put('admin/ipc/'+payload.id, {id:payload.id,data:payload.data})
|
||||
commit('UPDATE_ADPACKAGE', payload);
|
||||
}catch (e) {
|
||||
commit('ERROR', e);
|
||||
} finally {
|
||||
commit('LOADING', false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const mutations = {
|
||||
LOADING(state, payload) {
|
||||
state.loading = payload;
|
||||
},
|
||||
AdPACKAGE_ID(state,payload){
|
||||
state.AdOneId = payload
|
||||
},
|
||||
UPDATE_ADPACKAGE(state, payload) {
|
||||
state.edit = state.edit.map(item => {
|
||||
if (item.id === payload.id) {
|
||||
return Object.assign({},item, payload.data)
|
||||
}
|
||||
return item
|
||||
})
|
||||
}
|
||||
};
|
||||
|
||||
export default {
|
||||
namespaced: true,
|
||||
state,
|
||||
mutations,
|
||||
actions
|
||||
}
|
||||
Reference in New Issue
Block a user