Commit the matter.

This commit is contained in:
lishuang
2020-06-06 00:05:24 +08:00
parent 3a2a5bab2a
commit 7bad1db7e6
7 changed files with 392 additions and 1 deletions
+1 -1
View File
@@ -121,7 +121,7 @@ export default class BaseEntity extends HttpBase {
getUrlList(): string {
let prefix = this.getUrlPrefix();
return prefix + '/list';
return prefix + '/page';
}
getUrlSort(): string {
+11
View File
@@ -0,0 +1,11 @@
.matter-detail {
padding: 20px;
overflow: auto;
background: white;
}
.matter {
width: 100%;
}
+111
View File
@@ -0,0 +1,111 @@
import React from 'react';
import { Link, RouteComponentProps } from 'react-router-dom';
import './Detail.less';
import BambooComponent from '../../common/component/BambooComponent';
import Matter from '../../common/model/matter/Matter';
import { Button, Col, Row, Spin } from 'antd';
import InfoCell from '../widget/InfoCell';
import StringUtil from '../../common/util/StringUtil';
import BambooTitle from '../widget/BambooTitle';
interface RouteParam {
uuid: string
}
interface IProps extends RouteComponentProps<RouteParam> {
}
interface IState {
}
export default class Detail extends BambooComponent<IProps, IState> {
matter: Matter = new Matter(this);
constructor(props: IProps) {
super(props);
this.state = {};
//matter的id设置晚了就来不及了
let match = this.props.match;
if (match.params.uuid) {
this.matter.uuid = match.params.uuid;
}
}
componentDidMount() {
//刷新一下列表
let that = this;
let match = this.props.match;
let matter = that.matter;
matter.httpDetail(function() {
});
}
render() {
let that = this;
let matter: Matter = that.matter;
//router中传入的路由相关对象
let match = this.props.match;
return (
<div className="matter-detail">
<BambooTitle name={'文件详情'}>
<Link title="编辑"
to={StringUtil.prePath(match.path, 2) + '/edit/' + matter.uuid}>
<Button className="mh10" type="primary" icon="edit">
编辑
</Button>
</Link>
</BambooTitle>
<Spin tip="加载中" spinning={matter.detailLoading}>
<div className="info">
{/*<Row>*/}
{/* <Col span={12}>*/}
{/* <InfoCell name="文件名称">*/}
{/* {matter.title}*/}
{/* </InfoCell>*/}
{/* </Col>*/}
{/* <Col span={12}>*/}
{/* <InfoCell name="作者">*/}
{/* {matter.author}*/}
{/* </InfoCell>*/}
{/* </Col>*/}
{/* <Col span={12}>*/}
{/* <InfoCell name="路径">*/}
{/* {matter.path}*/}
{/* </InfoCell>*/}
{/* </Col>*/}
{/*</Row>*/}
<div className="matter" dangerouslySetInnerHTML={{__html: ''+ matter.html}} />
</div>
</Spin>
</div>
);
}
}
+5
View File
@@ -0,0 +1,5 @@
.matter-edit {
padding: 20px;
background: white;
}
+84
View File
@@ -0,0 +1,84 @@
import React from 'react';
import { Link, RouteComponentProps } from 'react-router-dom';
import { Button, Col, DatePicker, Input, message as MessageBox, Row, Spin } from 'antd';
import BambooComponent from '../../common/component/BambooComponent';
import Matter from '../../common/model/matter/Matter';
import StringUtil from '../../common/util/StringUtil';
import './Edit.less';
import BambooTitle from '../widget/BambooTitle';
const { MonthPicker, RangePicker } = DatePicker;
interface RouteParam {
uuid: string
}
interface IProps {
}
interface IState {
}
class RawEdit extends BambooComponent<IProps, IState> {
createMode: boolean = true;
matter: Matter = new Matter(this);
constructor(props: IProps) {
super(props);
this.state = {
};
}
componentDidMount() {
//刷新一下列表
let matter = this.matter;
}
//获取上一级目录
getPrePath() {
return ""
}
//返回到列表页面
goToIndex() {
}
render() {
let that = this;
//router中传入的路由相关对象
let matter = this.matter;
return (
<div className="matter-edit">
<BambooTitle name={this.createMode ? '创建文件' : '编辑文件'}>
</BambooTitle>
</div>
);
}
}
export default RawEdit;
+8
View File
@@ -0,0 +1,8 @@
.matter-list {
padding: 5px;
.ant-table {
background-color: white;
}
}
+172
View File
@@ -0,0 +1,172 @@
import React from 'react';
import { Link, RouteComponentProps } from 'react-router-dom';
import './List.less';
import BambooComponent from '../../common/component/BambooComponent';
import SortDirection from '../../common/model/base/SortDirection';
import Pager from '../../common/model/base/Pager';
import Matter from '../../common/model/matter/Matter';
import Table, { ColumnProps } from 'antd/lib/table';
import StringUtil from '../../common/util/StringUtil';
import { Button, message as MessageBox, Popconfirm } from 'antd';
import DateUtil from '../../common/util/DateUtil';
import FilterPanel from '../widget/filter/FilterPanel';
import TableEmpty from '../widget/TableEmpty';
import Sun from '../../common/model/global/Sun';
import BambooTitle from '../widget/BambooTitle';
interface IProps extends RouteComponentProps {
}
interface IState {
}
export default class List extends BambooComponent<IProps, IState> {
//获取分页的一个帮助器
pager: Pager<Matter> = new Pager<Matter>(this, Matter, 10);
constructor(props: IProps) {
super(props);
this.state = {};
}
componentDidMount() {
//刷新一下列表
let that = this;
that.pager.enableHistory();
that.refresh();
}
search() {
let that = this;
that.pager.page = 0;
that.refresh();
}
refresh() {
let that = this;
//如果没有任何的排序,默认使用时间倒序
if (!that.pager.getCurrentSortFilter()) {
that.pager.setFilterValue('orderCreateTime', SortDirection.DESC);
}
that.pager.httpList();
}
createMatter() {
let that = this;
//router中传入的路由相关对象
let match = this.props.match;
let url: string = StringUtil.prePath(match.path) + `/create`;
Sun.navigateTo(url);
}
render() {
let that = this;
//router中传入的路由相关对象
let match = this.props.match;
//pager对象
let pager = this.pager;
const columns: ColumnProps<Matter>[] = [{
title: '文件名称',
dataIndex: 'title',
render: (text: any, record: Matter, index: number): React.ReactNode => (
<Link to={StringUtil.prePath(match.path) + '/detail/' + record.uuid}>{record.title}</Link>
),
}, {
title: '路径',
dataIndex: 'path',
}, {
title: '作者',
dataIndex: 'author',
}, {
title: '创建时间',
dataIndex: 'createTime',
sorter: true,
sortOrder: pager.getDefaultSortOrder('createTime'),
sortDirections: [SortDirection.DESCEND, SortDirection.ASCEND],
render: (text: any, record: Matter, index: number): React.ReactNode => (
DateUtil.simpleDateTime(text)
),
}, {
title: '修改时间',
dataIndex: 'updateTime',
sorter: true,
sortOrder: pager.getDefaultSortOrder('updateTime'),
sortDirections: [SortDirection.DESCEND, SortDirection.ASCEND],
render: (text: any, record: Matter, index: number): React.ReactNode => (
DateUtil.simpleDateTime(text)
),
}, {
title: '操作',
dataIndex: 'action',
render: (text: any, record: Matter) => (
<span>
<Link title="编辑"
to={StringUtil.prePath(match.path) + '/edit/' + record.uuid}>
编辑
</Link>
<Popconfirm title="确认删除该文件,删除后不可恢复?" onConfirm={(e: any) => {
record.httpDel(function() {
MessageBox.success('删除成功!');
that.refresh();
});
}} okText="确认" cancelText="取消">
<span>编辑</span>
</Popconfirm>
</span>
),
}];
return (
<div className="matter-list">
<BambooTitle name={'文件管理'}>
<Button type="primary" onClick={this.createMatter.bind(this)}>
新建文件
</Button>
</BambooTitle>
<div>
<FilterPanel filters={pager.filters} onChange={this.search.bind(this)}/>
</div>
<Table
rowKey="id"
loading={pager.loading}
dataSource={pager.data}
columns={columns}
pagination={pager.getPagination()}
onChange={pager.tableOnChange.bind(pager)}
locale={{ emptyText: (<TableEmpty pager={pager} onRefresh={this.refresh.bind(this)}/>) }}
/>
</div>
);
}
}