diff --git a/client/actions/project.js b/client/actions/project.js
index 614813f8..c71ecb4f 100644
--- a/client/actions/project.js
+++ b/client/actions/project.js
@@ -1,15 +1,16 @@
import {
FETCH_PROJECT_LIST,
- PROJECT_ADD
+ PROJECT_ADD,
+ PROJECT_DEL
} from '../constants/action-types.js';
import axios from 'axios';
-const fetchProjectList = (data) => {
+const fetchProjectList = (id) => {
return {
type: FETCH_PROJECT_LIST,
- payload: axios.get('/project/list', {params: data})
- }
-}
+ payload: axios.get('/project/list', {params: { group_id: id }})
+ };
+};
const addProject = (data) => {
const { name, prd_host, basepath, desc, group_id } = data;
@@ -19,15 +20,25 @@ const addProject = (data) => {
basepath,
desc,
group_id
- }
+ };
return {
type: PROJECT_ADD,
// payload 可以返回 Promise,异步请求使用 axios 即可
payload: axios.post('/project/add', param)
- }
-}
+ };
+};
+
+const delProject = (id) => {
+ const param = { id };
+ return {
+ type: PROJECT_DEL,
+ // payload 可以返回 Promise,异步请求使用 axios 即可
+ payload: axios.post('/project/del', param)
+ };
+};
export default {
fetchProjectList,
- addProject
-}
+ addProject,
+ delProject
+};
diff --git a/client/constants/action-types.js b/client/constants/action-types.js
index 6f4185d6..ec863212 100644
--- a/client/constants/action-types.js
+++ b/client/constants/action-types.js
@@ -10,6 +10,7 @@ export const SET_CURR_GROUP = 'SET_CURR_GROUP'
// project
export const FETCH_PROJECT_LIST = 'FETCH_PROJECT_LIST'
export const PROJECT_ADD = 'PROJECT_ADD'
+export const PROJECT_DEL = 'PROJECT_DEL'
// login
export const LOGIN = 'LOGIN';
diff --git a/client/containers/ProjectGroups/ProjectList/index.js b/client/containers/ProjectGroups/ProjectList/index.js
index 4c230cb7..387849b5 100644
--- a/client/containers/ProjectGroups/ProjectList/index.js
+++ b/client/containers/ProjectGroups/ProjectList/index.js
@@ -1,38 +1,57 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
-import { Table, Button, Modal, Form, Input, Icon, Tooltip, Select } from 'antd';
-import { addProject, fetchProjectList } from '../../../actions/project';
+import { Table, Button, Modal, Form, Input, Icon, Tooltip, Select, Popconfirm, message } from 'antd';
+import { addProject, fetchProjectList, delProject } from '../../../actions/project';
const { TextArea } = Input;
const FormItem = Form.Item;
const Option = Select.Option;
import './ProjectList.scss'
-const columns = [{
- title: '项目名称',
- dataIndex: 'name',
- key: 'name',
- render: text => {text}
-}, {
- title: '创建人',
- dataIndex: 'owner',
- key: 'owner'
-}, {
- title: '创建时间',
- dataIndex: 'add_time',
- key: 'add_time'
-}, {
- title: '操作',
- key: 'action',
- render: () => (
-
- 修改
-
- 删除
-
- )
-}];
+const confirm = (id, handleDelete, currGroupId, handleFetchList) => {
+ const test = () => {
+ handleDelete(id).then((res) => {
+ console.log(res);
+ console.log(handleFetchList, currGroupId);
+ handleFetchList(currGroupId).then((res) => {
+ console.log(res);
+ });
+ });
+ }
+ return test;
+};
+
+const getColumns = (data, handleDelete, currGroupId, handleFetchList) => {
+ return [{
+ title: '项目名称',
+ dataIndex: 'name',
+ key: 'name',
+ render: text => {text}
+ }, {
+ title: '创建人',
+ dataIndex: 'owner',
+ key: 'owner'
+ }, {
+ title: '创建时间',
+ dataIndex: 'add_time',
+ key: 'add_time'
+ }, {
+ title: '操作',
+ key: 'action',
+ render: (text, record) => {
+ const id = record._id;
+ return (
+
+ 修改
+
+