场景列表。

This commit is contained in:
tengge1 2019-06-29 20:52:01 +08:00
parent 5196c71e39
commit c8a003d2b8
5 changed files with 69 additions and 12 deletions

View File

@ -10,12 +10,12 @@ class Icon extends React.Component {
render() {
const { className, style, icon, ...others } = this.props;
return <div
return <i
className={classNames('Icon', 'iconfont',
icon && 'icon-' + icon,
className)}
style={style}
{...others}></div>;
{...others}></i>;
}
}

View File

@ -2,29 +2,41 @@ import './css/ImageList.css';
import classNames from 'classnames/bind';
import PropTypes from 'prop-types';
import Icon from '../icon/Icon.jsx';
/**
* 图片列表
* @author tengge / https://github.com/tengge1
*/
class ImageList extends React.Component {
render() {
const { className, style, ...others } = this.props;
const { className, style, data } = this.props;
return <img
className={classNames('ImageList', className)}
style={style}
{...others}></img>;
return <div className={'ImageList'}>
{data.map(n => {
return <div className={'item'} key={n.ID}>
{n.Thumbnail ?
<img className={'img'} src={n.Thumbnail}></img> :
<div className={'no-img'}>
<Icon icon={'scenes'}></Icon>
</div>}
<div className={'title'}>{n.Name}</div>
</div>;
})}
</div>;
}
}
ImageList.propTypes = {
className: PropTypes.string,
style: PropTypes.object,
data: PropTypes.array,
};
ImageList.defaultProps = {
className: null,
style: null,
data: [],
};
export default ImageList;

View File

@ -0,0 +1,30 @@
.ImageList {
position: absolute;
width: 100%;
height: calc(100% - 30px);
overflow-y: auto;
}
.ImageList>.item {
width: calc(50% - 4px);
margin: 2px;
display: inline-block;
border: 1px solid #ddd;
box-sizing: border-box;
}
.ImageList>.item>.img {
width: 100%;
}
.ImageList>.item>.no-img {
width: 100%;
height: 100px;
display: flex;
align-items: center;
justify-content: center;
}
.ImageList>.item>.title {
font-size: 12px;
}

View File

@ -1,6 +1,7 @@
import './css/ScenePanel.css';
import { classNames, PropTypes, SearchField, ImageList } from '../../third_party';
import Ajax from '../../utils/Ajax';
import EditWindow from '../window/EditWindow';
import Converter from '../../serialization/Converter';
import GISScene from '../../gis/Scene';
@ -11,20 +12,29 @@ import GISScene from '../../gis/Scene';
class ScenePanel extends React.Component {
constructor(props) {
super(props);
this.state = {
data: [],
};
}
render() {
const { data } = this.state;
return <div className={'ScenePanel'}>
<SearchField></SearchField>
<ImageList></ImageList>
<ImageList data={data}></ImageList>
</div>;
}
componentDidMount() {
Ajax.getJson(`/api/Scene/List`, obj => {
this.data = obj.Data;
search.setValue('');
this.onSearch();
this.setState({
data: obj.Data,
});
// this.data = obj.Data;
// search.setValue('');
// this.onSearch();
});
}
}

View File

@ -0,0 +1,5 @@
.ScenePanel {
position: relative;
width: 100%;
height: 100%;
}