forked from Gitlink/forgeplus-react
列表查询
This commit is contained in:
parent
2c3d917bd4
commit
efc2443bb8
|
@ -22,7 +22,6 @@ class Index extends Component {
|
||||||
sort: undefined,
|
sort: undefined,
|
||||||
total: 0,
|
total: 0,
|
||||||
isSpin: true,
|
isSpin: true,
|
||||||
project_type: undefined,
|
|
||||||
category_id: undefined,
|
category_id: undefined,
|
||||||
|
|
||||||
typeList: undefined,
|
typeList: undefined,
|
||||||
|
@ -36,8 +35,8 @@ class Index extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount = () => {
|
componentDidMount = () => {
|
||||||
const { page,search, sort, project_type, category_id , languageId } = this.state;
|
const { page,search, sort,category_id , languageId } = this.state;
|
||||||
this.getListData(page,search, sort, project_type, category_id , languageId);
|
this.getListData(page,search, sort,category_id , languageId);
|
||||||
|
|
||||||
this.getType();
|
this.getType();
|
||||||
|
|
||||||
|
@ -72,7 +71,7 @@ class Index extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取列表
|
// 获取列表
|
||||||
getListData = (page,search, sort, project_type, category_id,languageId) => {
|
getListData = (page,search, sort,category_id,language_id) => {
|
||||||
const { current_user } = this.props;
|
const { current_user } = this.props;
|
||||||
const url = `/projects.json`;
|
const url = `/projects.json`;
|
||||||
axios.get(url, {
|
axios.get(url, {
|
||||||
|
@ -82,9 +81,8 @@ class Index extends Component {
|
||||||
limit:15,
|
limit:15,
|
||||||
search,
|
search,
|
||||||
sort_by: sort,
|
sort_by: sort,
|
||||||
project_type,
|
|
||||||
category_id,
|
category_id,
|
||||||
language_id:languageId
|
language_id
|
||||||
}
|
}
|
||||||
}).then((result) => {
|
}).then((result) => {
|
||||||
if (result) {
|
if (result) {
|
||||||
|
@ -111,7 +109,7 @@ class Index extends Component {
|
||||||
this.setState({
|
this.setState({
|
||||||
typeList: list.map((item, key) => {
|
typeList: list.map((item, key) => {
|
||||||
return (
|
return (
|
||||||
<li key={key} className={active_type && active_type === item.project_type ? 'active' : ''} onClick={() => this.changeType(`${item.project_type}`, list)}>
|
<li key={key} className={active_type && parseInt(active_type) === item.id ? 'active' : ''} onClick={() => this.changeType(`${item.id}`, list)}>
|
||||||
<p>
|
<p>
|
||||||
<span className="font-16">{item.name}</span>
|
<span className="font-16">{item.name}</span>
|
||||||
<span className="color-blue">{item.projects_count}</span>
|
<span className="color-blue">{item.projects_count}</span>
|
||||||
|
@ -123,15 +121,15 @@ class Index extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 切换类型
|
// 切换类型
|
||||||
changeType = (type, list) => {
|
changeType = (id, list) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
isSpin: true,
|
isSpin: true,
|
||||||
project_type: type,
|
languageId: id,
|
||||||
search: undefined
|
search: undefined
|
||||||
})
|
})
|
||||||
this.setTypeList(list, type)
|
this.setTypeList(list, id)
|
||||||
const { page,sort, category_id , languageId } = this.state;
|
const { page,sort, category_id} = this.state;
|
||||||
this.getListData(page,undefined, sort, type, category_id , languageId);
|
this.getListData(page,undefined, sort,category_id , id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取类型
|
// 获取类型
|
||||||
|
@ -166,8 +164,8 @@ class Index extends Component {
|
||||||
page: 1
|
page: 1
|
||||||
});
|
});
|
||||||
this.setCategoryList(list, id)
|
this.setCategoryList(list, id)
|
||||||
const { sort, project_type , languageId } = this.state;
|
const { sort,languageId } = this.state;
|
||||||
this.getListData(1,undefined, sort, project_type, id , languageId);
|
this.getListData(1,undefined, sort,id , languageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 排序
|
// 排序
|
||||||
|
@ -178,8 +176,8 @@ class Index extends Component {
|
||||||
search: undefined,
|
search: undefined,
|
||||||
isSpin: true
|
isSpin: true
|
||||||
})
|
})
|
||||||
const {project_type, category_id , languageId } = this.state;
|
const {category_id , languageId } = this.state;
|
||||||
this.getListData(1,undefined, e.key, project_type, category_id , languageId);
|
this.getListData(1,undefined, e.key,category_id , languageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 搜索
|
// 搜索
|
||||||
|
@ -192,7 +190,7 @@ class Index extends Component {
|
||||||
sort: "updated_on"
|
sort: "updated_on"
|
||||||
})
|
})
|
||||||
const {sort, category_id , languageId } = this.state;
|
const {sort, category_id , languageId } = this.state;
|
||||||
this.getListData(1,value, sort, undefined, category_id , languageId);
|
this.getListData(1,value, sort,category_id , languageId);
|
||||||
}
|
}
|
||||||
changeSearchValue = (e) => {
|
changeSearchValue = (e) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
|
@ -204,23 +202,14 @@ class Index extends Component {
|
||||||
this.setState({
|
this.setState({
|
||||||
page
|
page
|
||||||
})
|
})
|
||||||
const {search, sort, project_type, category_id , languageId } = this.state;
|
const {search, sort,category_id , languageId } = this.state;
|
||||||
this.getListData(page,search, sort, project_type, category_id , languageId);
|
this.getListData(page,search, sort, category_id , languageId);
|
||||||
}
|
}
|
||||||
|
|
||||||
getoDetail=(login,identifier)=>{
|
getoDetail=(login,identifier)=>{
|
||||||
this.props.history.push(`/projects/${login}/${identifier}`);
|
this.props.history.push(`/projects/${login}/${identifier}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 选择语言类别
|
|
||||||
changeLanguage=(e)=>{
|
|
||||||
this.setState({
|
|
||||||
isSpin:true,
|
|
||||||
languageId:e === 0 ?undefined:e
|
|
||||||
})
|
|
||||||
const { page,sort , project_type , category_id } = this.state;
|
|
||||||
this.getListData(page, undefined, sort, project_type, category_id ,e === 0 ?undefined:e);
|
|
||||||
}
|
|
||||||
|
|
||||||
menu =()=> {
|
menu =()=> {
|
||||||
return(
|
return(
|
||||||
|
|
|
@ -227,7 +227,7 @@ class Infos extends Component {
|
||||||
|
|
||||||
<div className="bgcF">
|
<div className="bgcF">
|
||||||
<ul className="list-l-Menu">
|
<ul className="list-l-Menu">
|
||||||
<li className="MenuTitle" onClick={() => this.change_project_type(undefined)}>
|
<li className="MenuTitle" onClick={() => this.change_project_type()}>
|
||||||
<i className="iconfont icon-xiangmuleixing font-15 mr5"></i>
|
<i className="iconfont icon-xiangmuleixing font-15 mr5"></i>
|
||||||
项目类型
|
项目类型
|
||||||
<i className="iconfont icon-youjiantou font-15 mr20 color-grey-9 pull-right"></i>
|
<i className="iconfont icon-youjiantou font-15 mr20 color-grey-9 pull-right"></i>
|
||||||
|
|
Loading…
Reference in New Issue