feat: 修复删除项目bug和完善删除分组功能

This commit is contained in:
sean 2017-08-16 12:19:53 +08:00
parent 5ae5fb8789
commit 3afc7a2dff
9 changed files with 37 additions and 14 deletions

View File

@ -1,14 +1,14 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import { connect } from 'react-redux'
import { Button, Icon, Popconfirm, Modal, Input, message, Menu, Row, Col } from 'antd'
import { Button, Icon, Modal,Alert, Input, message, Menu, Row, Col } from 'antd'
import { autobind } from 'core-decorators';
import axios from 'axios';
import { withRouter } from 'react-router';
const { TextArea } = Input;
const Search = Input.Search;
const TYPE_EDIT = 'edit';
const confirm = Modal.confirm;
import {
fetchGroupList,
setCurrGroup,
@ -155,6 +155,30 @@ export default class GroupList extends Component {
this.props.history.replace(`${currGroup._id}`);
}
showConfirm =()=> {
let that = this;
confirm({
title: that.props.currGroup.group_name,
content: <div style={{marginTop:'10px', fontSize: '14px', lineHeight: '25px'}}>
<Alert message="该操作会删除该分组下所有项目!" type="warning" />
<div style={{marginTop: '10px'}}><b>请输入分组名称</b><input id="group_name" /></div>
</div>,
onOk() {
let groupName = document.getElementById('group_name').value;
if(that.props.currGroup.group_name !== groupName){
message.error('分组名称有误')
return new Promise((resolve, reject)=>{
reject('error')
})
}else{
that.deleteGroup()
}
},
onCancel() { }
});
}
@autobind
async deleteGroup() {
const self = this;
@ -163,7 +187,7 @@ export default class GroupList extends Component {
if (res.data.errcode) {
message.error(res.data.errmsg);
} else {
message.success('删除成功');
message.success('删除成功')
await self.props.fetchGroupList()
const currGroup = self.props.groupList[0] || { group_name: '', group_desc: '' };
self.setState({groupList: self.props.groupList});
@ -185,9 +209,8 @@ export default class GroupList extends Component {
render () {
const { currGroup } = this.props;
const delmark = <Icon className="edit-group" type="edit" title="编辑分组" onClick={() => this.showModal(TYPE_EDIT)}/>
const editmark = (<Popconfirm title={`你确定要删除分组 ${currGroup.group_name}`} onConfirm={this.deleteGroup}>
<Icon className="delete-group" type="delete" title="删除分组"/>
</Popconfirm>)
const editmark = <Icon className="delete-group" onClick={()=> {this.showConfirm()}} type="delete" title="删除分组"/>
return (

View File

@ -113,7 +113,7 @@ class interfaceModel extends baseModel {
}
delByProjectId(id){
return this.model.delete({
return this.model.deleteMany({
project_id: id
})
}

View File

@ -61,7 +61,7 @@ class interfaceCase extends baseModel {
}
delByProjectId(id){
return this.model.delete({
return this.model.deleteMany({
project_id: id
})
}

View File

@ -47,7 +47,7 @@ class interfaceCol extends baseModel {
}
delByProjectId(id){
return this.model.delete({
return this.model.deleteMany({
project_id: id
})
}

View File

@ -88,7 +88,7 @@ class projectModel extends baseModel {
}
delByGroupid(groupId){
return this.model.delete({
return this.model.deleteMany({
group_id: groupId
})
}

View File

@ -157,7 +157,7 @@ var interfaceModel = function (_baseModel) {
}, {
key: 'delByProjectId',
value: function delByProjectId(id) {
return this.model.delete({
return this.model.deleteMany({
project_id: id
});
}

View File

@ -105,7 +105,7 @@ var interfaceCase = function (_baseModel) {
}, {
key: 'delByProjectId',
value: function delByProjectId(id) {
return this.model.delete({
return this.model.deleteMany({
project_id: id
});
}

View File

@ -92,7 +92,7 @@ var interfaceCol = function (_baseModel) {
}, {
key: 'delByProjectId',
value: function delByProjectId(id) {
return this.model.delete({
return this.model.deleteMany({
project_id: id
});
}

View File

@ -134,7 +134,7 @@ var projectModel = function (_baseModel) {
}, {
key: 'delByGroupid',
value: function delByGroupid(groupId) {
return this.model.delete({
return this.model.deleteMany({
group_id: groupId
});
}