Init project

This commit is contained in:
alirezakarari
2021-01-09 20:53:13 +03:30
commit 8d06c89a89
1005 changed files with 105625 additions and 0 deletions
+72
View File
@@ -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
}