feat: 创建项目请求

This commit is contained in:
wenbo.dong 2017-07-14 18:02:01 +08:00
parent 5a074533ae
commit dba1d60d26
3 changed files with 47 additions and 5 deletions

24
client/actions/project.js Normal file
View File

@ -0,0 +1,24 @@
import {
PROJECT_ADD
} from '../constants/action-types.js';
import axios from 'axios';
const addProject = (data) => {
const { name, prd_host, basepath, desc } = data;
const param = {
name,
prd_host,
basepath,
desc
}
console.log(param);
return {
type: PROJECT_ADD,
// payload 可以返回 Promise异步请求使用 axios 即可
payload: axios.get('/project/add', param)
}
}
export default {
addProject
}

View File

@ -7,9 +7,12 @@ export const PROJECT_MEMBER_INTERFACE = 'PROJECT_MEMBER_INTERFACE'
export const FETCH_GROUP_LIST = 'FETCH_GROUP_LIST' export const FETCH_GROUP_LIST = 'FETCH_GROUP_LIST'
export const FETCH_CURR_GROUP = 'FETCH_CURR_GROUP' export const FETCH_CURR_GROUP = 'FETCH_CURR_GROUP'
// project
export const PROJECT_ADD = 'PROJECT_ADD'
// login // login
export const LOGIN = 'LOGIN'; export const LOGIN = 'LOGIN';
export const REGISTER = 'REGISTER'; export const REGISTER = 'REGISTER';
//header //header
export const LOGIN_TYPE = 'LOGIN_TYPE'; export const LOGIN_TYPE = 'LOGIN_TYPE';

View File

@ -1,7 +1,8 @@
import React, { Component } from 'react' import React, { Component } from 'react';
import PropTypes from 'prop-types' import PropTypes from 'prop-types';
// import { connect } from 'react-redux' import { connect } from 'react-redux';
import { Table, Button, Modal, Form, Input, Icon, Tooltip } from 'antd'; import { Table, Button, Modal, Form, Input, Icon, Tooltip } from 'antd';
import { addProject } from '../../../actions/project';
const { TextArea } = Input; const { TextArea } = Input;
const FormItem = Form.Item; const FormItem = Form.Item;
@ -47,6 +48,18 @@ const formItemLayout = {
sm: { span: 14 } sm: { span: 14 }
} }
}; };
@connect(
state => {
return {
loginData: state.login
}
},
{
addProject
}
)
class ProjectList extends Component { class ProjectList extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
@ -55,7 +68,8 @@ class ProjectList extends Component {
} }
} }
static propTypes = { static propTypes = {
form: PropTypes.object form: PropTypes.object,
addProject: PropTypes.func
} }
addProject = () => { addProject = () => {
this.setState({ this.setState({
@ -70,6 +84,7 @@ class ProjectList extends Component {
this.setState({ this.setState({
visible: false visible: false
}); });
this.props.addProject(values);
} }
}); });
} }