2017-07-14 18:02:01 +08:00
|
|
|
|
import {
|
2017-07-18 17:46:09 +08:00
|
|
|
|
FETCH_PROJECT_LIST,
|
2017-07-18 22:08:01 +08:00
|
|
|
|
PROJECT_ADD,
|
2017-07-19 20:59:59 +08:00
|
|
|
|
PROJECT_DEL,
|
|
|
|
|
OPRATE_UPDATE_MODAL,
|
|
|
|
|
PROJECT_UPDATE
|
2017-07-14 18:02:01 +08:00
|
|
|
|
} from '../constants/action-types.js';
|
|
|
|
|
import axios from 'axios';
|
|
|
|
|
|
2017-07-18 22:08:01 +08:00
|
|
|
|
const fetchProjectList = (id) => {
|
2017-07-18 17:46:09 +08:00
|
|
|
|
return {
|
|
|
|
|
type: FETCH_PROJECT_LIST,
|
2017-07-18 22:08:01 +08:00
|
|
|
|
payload: axios.get('/project/list', {params: { group_id: id }})
|
|
|
|
|
};
|
|
|
|
|
};
|
2017-07-18 17:46:09 +08:00
|
|
|
|
|
2017-07-19 20:59:59 +08:00
|
|
|
|
const changeUpdateModal = (data, index) => {
|
|
|
|
|
return {
|
|
|
|
|
type: OPRATE_UPDATE_MODAL,
|
|
|
|
|
payload: { data, index }
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2017-07-14 18:02:01 +08:00
|
|
|
|
const addProject = (data) => {
|
2017-07-18 14:58:57 +08:00
|
|
|
|
const { name, prd_host, basepath, desc, group_id } = data;
|
2017-07-14 18:02:01 +08:00
|
|
|
|
const param = {
|
|
|
|
|
name,
|
|
|
|
|
prd_host,
|
|
|
|
|
basepath,
|
2017-07-18 14:58:57 +08:00
|
|
|
|
desc,
|
|
|
|
|
group_id
|
2017-07-18 22:08:01 +08:00
|
|
|
|
};
|
2017-07-14 18:02:01 +08:00
|
|
|
|
return {
|
|
|
|
|
type: PROJECT_ADD,
|
|
|
|
|
// payload 可以返回 Promise,异步请求使用 axios 即可
|
2017-07-18 10:56:03 +08:00
|
|
|
|
payload: axios.post('/project/add', param)
|
2017-07-18 22:08:01 +08:00
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2017-07-19 20:59:59 +08:00
|
|
|
|
const updateProject = (data) => {
|
|
|
|
|
const { name, prd_host, basepath, desc, group_id } = data;
|
|
|
|
|
const param = {
|
|
|
|
|
name,
|
|
|
|
|
prd_host,
|
|
|
|
|
basepath,
|
|
|
|
|
desc,
|
|
|
|
|
group_id
|
|
|
|
|
};
|
|
|
|
|
return {
|
|
|
|
|
type: PROJECT_UPDATE,
|
|
|
|
|
// payload 可以返回 Promise,异步请求使用 axios 即可
|
|
|
|
|
payload: axios.post('/project/up', param)
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2017-07-18 22:08:01 +08:00
|
|
|
|
const delProject = (id) => {
|
|
|
|
|
const param = { id };
|
|
|
|
|
return {
|
|
|
|
|
type: PROJECT_DEL,
|
|
|
|
|
// payload 可以返回 Promise,异步请求使用 axios 即可
|
|
|
|
|
payload: axios.post('/project/del', param)
|
|
|
|
|
};
|
|
|
|
|
};
|
2017-07-14 18:02:01 +08:00
|
|
|
|
|
|
|
|
|
export default {
|
2017-07-18 17:46:09 +08:00
|
|
|
|
fetchProjectList,
|
2017-07-18 22:08:01 +08:00
|
|
|
|
addProject,
|
2017-07-19 20:59:59 +08:00
|
|
|
|
delProject,
|
|
|
|
|
changeUpdateModal,
|
|
|
|
|
updateProject
|
2017-07-18 22:08:01 +08:00
|
|
|
|
};
|