fix: 修复mock null bug 和 group_member role bug

This commit is contained in:
suxiaoxin 2017-09-15 19:58:52 +08:00
parent d6239b6072
commit 2bee0b12b8
3 changed files with 13 additions and 8 deletions

View File

@ -9,7 +9,7 @@ import ErrMsg from '../../../components/ErrMsg/ErrMsg.js';
import UsernameAutoComplete from '../../../components/UsernameAutoComplete/UsernameAutoComplete.js';
const Option = Select.Option;
const arrayAddKey = (arr) => {
function arrayAddKey (arr) {
return arr.map((item, index) => {
return {
...item,
@ -136,6 +136,9 @@ class MemberList extends Component {
componentWillReceiveProps(nextProps) {
if(this._groupId !== this._groupId){
return null;
}
if (this.props.currGroup !== nextProps.currGroup) {
this.props.fetchGroupMemberList(nextProps.currGroup._id).then((res) => {
this.setState({
@ -151,7 +154,7 @@ class MemberList extends Component {
}
componentDidMount() {
const currGroupId = this.props.currGroup._id;
const currGroupId = this._groupId = this.props.currGroup._id;
this.props.fetchGroupMsg(currGroupId).then((res) => {
this.setState({
role: res.payload.data.data.role
@ -190,9 +193,9 @@ class MemberList extends Component {
if (this.state.role === 'owner' || this.state.role === 'admin') {
return (
<div>
<Select defaultValue={record.role+'-'+record.uid} className="select" onChange={this.changeUserRole}>
<Option value={'owner-'+record.uid}>组长</Option>
<Option value={'dev-'+record.uid}>开发者</Option>
<Select value={ record.role+'-'+record.uid} className="select" onChange={this.changeUserRole}>
<Option value={ 'owner-'+record.uid}>组长{record.role}</Option>
<Option value={'dev-'+record.uid}>开发者{record.role}</Option>
</Select>
<Popconfirm placement="topRight" title="你确定要删除吗? " onConfirm={this.deleteConfirm(record.uid)} okText="确定" cancelText="">
<Button type="danger" icon="minus" className="btn-danger" />

View File

@ -183,7 +183,7 @@ class ProjectMember extends Component {
if (this.state.role === 'owner' || this.state.role === 'admin') {
return (
<div>
<Select defaultValue={record.role+'-'+record.uid} className="select" onChange={this.changeUserRole}>
<Select value={record.role+'-'+record.uid} className="select" onChange={this.changeUserRole}>
<Option value={'owner-'+record.uid}>组长</Option>
<Option value={'dev-'+record.uid}>开发者</Option>
</Select>

View File

@ -16,10 +16,10 @@ function mock(mockJSON, context) {
if (!p.hasOwnProperty(i)) {
continue;
}
if (typeof p[i] === 'object') {
if (p[i] && typeof p[i] === 'object') {
c[i] = (p[i].constructor === Array) ? [] : {};
parse(p[i], c[i]);
} else {
} else if(p[i] && typeof p[i] === 'string'){
p[i] = handleStr(p[i]);
var filters = i.split(mockSplit), newFilters = [].concat(filters);
c[i] = p[i];
@ -34,6 +34,8 @@ function mock(mockJSON, context) {
}
}
}
}else{
c[i] = p[i];
}
}
return c;