Merge branch 'dev' of gitlab.corp.qunar.com:mfe/yapi into dev

This commit is contained in:
waliang.wang 2017-07-28 15:12:59 +08:00
commit 8450e7210d
7 changed files with 46 additions and 17 deletions

View File

@ -5,12 +5,18 @@ import { Icon, Input, AutoComplete } from 'antd'
import './Search.scss' import './Search.scss'
import { withRouter } from 'react-router'; import { withRouter } from 'react-router';
import axios from 'axios'; import axios from 'axios';
import { setCurrGroup } from '../../../actions/group'
import { changeMenuItem } from '../../../actions/menu'
const Option = AutoComplete.Option;
@connect( @connect(
state => ({ state => ({
groupList: state.group.groupList, groupList: state.group.groupList,
projectList: state.project.projectList projectList: state.project.projectList
}) }),{
setCurrGroup,
changeMenuItem
}
) )
@withRouter @withRouter
@ -27,14 +33,18 @@ export default class Srch extends Component{
projectList: PropTypes.array, projectList: PropTypes.array,
router: PropTypes.object, router: PropTypes.object,
history: PropTypes.object, history: PropTypes.object,
location: PropTypes.object location: PropTypes.object,
setCurrGroup: PropTypes.func,
changeMenuItem : PropTypes.func
} }
onSelect = (value) => { onSelect = (value,option) => {
if( value.split(":")[0] == "分组" ){ if( option.props.tpye == "分组" ){
this.props.history.push('/group/'+value.split(":")[1].trim()); this.props.changeMenuItem('/group');
this.props.history.push('/group/'+value);
this.props.setCurrGroup({"group_name":value,"_id":option.props['id']});
} else { } else {
this.props.history.push('/project/'+value.split("(")[1].slice(0,-1)); this.props.history.push('/project/'+option.props['id']);
} }
} }
@ -43,9 +53,27 @@ export default class Srch extends Component{
.then((res) => { .then((res) => {
if(res.data && res.data.errcode === 0){ if(res.data && res.data.errcode === 0){
const dataSource = []; const dataSource = [];
for(let title in res.data.data){ for(let title in res.data.data) {
res.data.data[title].map(item => { res.data.data[title].map(item => {
title == "group" ? dataSource.push( "分组"+": "+item.groupName ): dataSource.push( "项目"+": "+item.name+"("+item._id+")" ); dataSource.push(
title == "group" ?
( <Option
key={`${item._id}`}
tpye="分组"
value={`${item.groupName}`}
id={`${item._id}`}
>
{`分组: ${item.groupName}`}
</Option>) :
(<Option
key={`${item._id}`}
tpye="项目"
value={`${item._id}`}
id={`${item._id}`}
>
{`项目: ${item.name}`}
</Option>)
)
}) })
} }
this.setState({ this.setState({
@ -70,6 +98,7 @@ export default class Srch extends Component{
render(){ render(){
const { dataSource } = this.state; const { dataSource } = this.state;
return( return(
<div className="search-wrapper"> <div className="search-wrapper">
<AutoComplete <AutoComplete
@ -85,11 +114,7 @@ export default class Srch extends Component{
<Input <Input
prefix={<Icon type="search" className="srch-icon" />} prefix={<Icon type="search" className="srch-icon" />}
size="large" size="large"
style={{ style={{}}
// width: 200,
// borderColor:"#AAA",
// borderWidth:"1px",
}}
placeholder="搜索分组/项目" placeholder="搜索分组/项目"
className="search-input" className="search-input"
/> />

View File

@ -3,7 +3,6 @@ $color-grey:#979DA7;
.search-wrapper{ .search-wrapper{
.search-input{ .search-input{
width: 2rem; width: 2rem;
//transition: width 2s;
} }
.srch-icon{ .srch-icon{
} }

View File

@ -192,7 +192,7 @@ export default class GroupList extends Component {
const { currGroup } = this.props; const { currGroup } = this.props;
return ( return (
<div> <div className="m-group">
<div className="group-bar"> <div className="group-bar">
<div className="curr-group"> <div className="curr-group">
<div className="curr-group-name"> <div className="curr-group-name">

View File

@ -1,6 +1,8 @@
.group-bar { .group-bar {
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20); box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20);
border-radius: 4px; border-radius: 4px;
background-color: #fff;
min-height: 5rem;
.curr-group { .curr-group {
background: #34495E; background: #34495E;
border-radius: 4px 4px 0 0; border-radius: 4px 4px 0 0;
@ -54,6 +56,7 @@
border-bottom: 1px solid #e9e9e9; border-bottom: 1px solid #e9e9e9;
padding-bottom: 24px; padding-bottom: 24px;
border-radius: 0 0 4px 4px; border-radius: 0 0 4px 4px;
border: none;
.group-item { .group-item {
// height: 48px; // height: 48px;
// line-height: 48px; // line-height: 48px;

View File

@ -2,6 +2,5 @@
.g-doc { .g-doc {
@include row-width-limit; @include row-width-limit;
min-height: 5rem;
margin: .24rem auto; margin: .24rem auto;
} }

View File

@ -3,6 +3,7 @@
padding: 24px; padding: 24px;
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20); box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20);
border-radius: 4px; border-radius: 4px;
min-height: 5rem;
} }
.m-table { .m-table {

View File

@ -2,7 +2,6 @@
.g-doc { .g-doc {
margin: .24rem auto; margin: .24rem auto;
min-height: 5rem;
} }
/* .user-box.css */ /* .user-box.css */
@ -23,6 +22,7 @@
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20); box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20);
background: #FFF; background: #FFF;
border-radius:4px; border-radius:4px;
min-height: 5rem;
margin-top: 15px; margin-top: 15px;
.search{ .search{
padding: 5px; padding: 5px;
@ -55,6 +55,7 @@
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20); box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20);
background: #FFF; background: #FFF;
margin-top: 15px; margin-top: 15px;
min-height: 5rem;
.ant-table-wrapper table { .ant-table-wrapper table {
// font-size: .14rem; // font-size: .14rem;
@ -72,6 +73,7 @@
box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20); box-shadow: 0 2px 4px 0 rgba(0,0,0,0.20);
background: #FFF; background: #FFF;
border-radius: .04rem; border-radius: .04rem;
min-height: 5rem;
.user-item { .user-item {
min-height:35px; min-height:35px;
line-height:35px; line-height:35px;