optimized project

This commit is contained in:
marvzhang
2020-02-02 14:14:59 +08:00
parent 6931211cbd
commit 40e97c9e54
3 changed files with 38 additions and 6 deletions

View File

@@ -2,7 +2,8 @@ import request from '../../api/request'
const state = {
projectForm: {},
projectList: []
projectList: [],
projectTags: []
}
const getters = {}
@@ -13,12 +14,15 @@ const mutations = {
},
SET_PROJECT_LIST: (state, value) => {
state.projectList = value
},
SET_PROJECT_TAGS: (state, value) => {
state.projectTags = value
}
}
const actions = {
getProjectList ({ state, commit }) {
request.get('/projects')
getProjectList ({ state, commit }, payload) {
request.get('/projects', payload)
.then(response => {
if (response.data.data) {
commit('SET_PROJECT_LIST', response.data.data.map(d => {
@@ -28,6 +32,14 @@ const actions = {
}
})
},
getProjectTags ({ state, commit }) {
request.get('/projects/tags')
.then(response => {
if (response.data.data) {
commit('SET_PROJECT_TAGS', response.data.data.map(d => d.tag))
}
})
},
addProject ({ state }) {
request.put('/projects', state.projectForm)
},