From 61cbda430ea91eee77dd8df5bc38a7ddf732f3c0 Mon Sep 17 00:00:00 2001 From: "wenbo.dong" Date: Wed, 16 Aug 2017 20:31:59 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=A1=B9=E7=9B=AE=E6=88=90=E5=91=98?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=88=A0=E9=99=A4=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../UsernameAutoComplete.js | 2 +- .../containers/Group/MemberList/MemberList.js | 55 +++++++++++++------ client/reducer/modules/group.js | 13 ++++- 3 files changed, 51 insertions(+), 19 deletions(-) diff --git a/client/components/UsernameAutoComplete/UsernameAutoComplete.js b/client/components/UsernameAutoComplete/UsernameAutoComplete.js index 40b07a22..55aef157 100644 --- a/client/components/UsernameAutoComplete/UsernameAutoComplete.js +++ b/client/components/UsernameAutoComplete/UsernameAutoComplete.js @@ -1,7 +1,7 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { AutoComplete } from 'antd'; -import axios from 'axios' +import axios from 'axios'; class UsernameAutoComplete extends Component { constructor(props) { diff --git a/client/containers/Group/MemberList/MemberList.js b/client/containers/Group/MemberList/MemberList.js index cafafb3d..5668128c 100644 --- a/client/containers/Group/MemberList/MemberList.js +++ b/client/containers/Group/MemberList/MemberList.js @@ -2,10 +2,10 @@ import React, { Component } from 'react'; import { Table } from 'antd'; import PropTypes from 'prop-types'; import { connect } from 'react-redux'; -import { Select, Button, Modal, Row, Col, message } from 'antd'; +import { Select, Button, Modal, Row, Col, message, Popconfirm } from 'antd'; import './MemberList.scss'; import { autobind } from 'core-decorators'; -import { fetchGroupMemberList, fetchGroupMsg, addMember } from '../../../reducer/modules/group.js' +import { fetchGroupMemberList, fetchGroupMsg, addMember, delMember } from '../../../reducer/modules/group.js' import UsernameAutoComplete from '../../../components/UsernameAutoComplete/UsernameAutoComplete.js'; const Option = Select.Option; @@ -29,7 +29,8 @@ const arrayAddKey = (arr) => { { fetchGroupMemberList, fetchGroupMsg, - addMember + addMember, + delMember } ) class MemberList extends Component { @@ -50,6 +51,7 @@ class MemberList extends Component { fetchGroupMemberList: PropTypes.func, fetchGroupMsg: PropTypes.func, addMember: PropTypes.func, + delMember: PropTypes.func, role: PropTypes.string } @@ -58,12 +60,36 @@ class MemberList extends Component { console.log(`selected ${value}`); } - showModal = () => { + @autobind + showAddMemberModal() { this.setState({ visible: true }); } + @autobind + reFetchList() { + this.props.fetchGroupMemberList(this.props.currGroup._id).then((res) => { + this.setState({ + userInfo: arrayAddKey(res.payload.data.data), + visible: false + }); + }); + } + + @autobind + deleteConfirm(member_uid) { + return () => { + const id = this.props.currGroup._id; + this.props.delMember({ id, member_uid }).then((res) => { + if (!res.payload.data.errcode) { + message.success(res.payload.data.errmsg); + this.reFetchList(); // 添加成功后重新获取分组成员列表 + } + }); + } + } + @autobind handleOk() { console.log(this.props.currGroup._id, this.state.inputUid); @@ -74,13 +100,7 @@ class MemberList extends Component { console.log(res); if (!res.payload.data.errcode) { message.success('添加成功!'); - // 添加成功后重新获取分组成员列表 - this.props.fetchGroupMemberList(this.props.currGroup._id).then((res) => { - this.setState({ - userInfo: arrayAddKey(res.payload.data.data), - visible: false - }); - }); + this.reFetchList(); // 添加成功后重新获取分组成员列表 } }); } @@ -94,8 +114,10 @@ class MemberList extends Component { } @autobind - changeMemberRole(e) { - console.log(e); + changeMemberRole(value) { + return () => { + console.log(this.props.currGroup._id, value); + } } componentWillReceiveProps(nextProps) { @@ -136,7 +158,6 @@ class MemberList extends Component { } render() { - console.log(this.state); const columns = [{ title: this.props.currGroup.group_name + ' 分组成员 ('+this.state.userInfo.length + ') 人', dataIndex: 'username', @@ -148,7 +169,7 @@ class MemberList extends Component { ); } }, { - title: (this.state.role === 'owner' || this.state.role === 'admin') ?
: '', + title: (this.state.role === 'owner' || this.state.role === 'admin') ?
: '', key: 'action', className: 'member-opration', render: (text, record) => { @@ -159,7 +180,9 @@ class MemberList extends Component { -