From 75fa1bb87cf216dc4525d1a427924de464b03e80 Mon Sep 17 00:00:00 2001
From: Mr Ke <kelq@hugeinfo.com.cn>
Date: Tue, 14 Apr 2020 10:33:39 +0800
Subject: [PATCH] 修稿favicon、修改bug
---
src/components/common/HotListTableView/index.jsx | 133 +++++++++++++++++++++++++++++++++++++++-----
1 files changed, 117 insertions(+), 16 deletions(-)
diff --git a/src/components/common/HotListTableView/index.jsx b/src/components/common/HotListTableView/index.jsx
index 0e30d9d..b4f484e 100644
--- a/src/components/common/HotListTableView/index.jsx
+++ b/src/components/common/HotListTableView/index.jsx
@@ -8,8 +8,10 @@
import React, { ReactNode, ReactEventHandler, Component } from 'react';
import BreadcrumbView from '../BreadcrumbView';
import TableView from '../TableView';
+import fetch from '../../../api/request';
+import moment from 'moment';
-import { Tabs } from 'antd';
+import { Tabs, Skeleton } from 'antd';
const { TabPane } = Tabs;
@@ -21,30 +23,129 @@
this.config = {
};
this.state = {
+ keywordlist: ['全部'],
+ formData: {
+ __key: Date.now(),
+ keyword: '',
+ page: 1,
+ size: 10,
+ },
+ loading: true
};
}
componentWillMount() { }
- componentDidMount() { }
+ componentDidMount() {
+ let { keywordlist } = this.state;
+ // 设置骨架屏
+ this.setState({
+ loading: true
+ })
+ fetch({
+ url: `api/news/keywordlist`
+ }).then(res => {
+ console.log('res', res);
+ this.setState({
+ loading: false
+ })
+ if (res) {
+ this.setState({
+ keywordlist: keywordlist.concat(res)
+ })
+ }
+ })
+ }
+
+ setFormData = data => {
+ console.log('form', data);
+ this.setState({
+ formData: data,
+ });
+ }
+
+ renderColumns = () => {
+ return [
+ {
+ title: '标题',
+ dataIndex: 'title',
+ key: 'title',
+ render: (cur, item) => {
+ return <a dangerouslySetInnerHTML={{ __html: cur }} target="_blank" href={item.url} >
+ </a>
+ }
+ },
+ {
+ title: '爬虫时间',
+ key: 'create_time',
+ dataIndex: 'create_time',
+
+ render: (cur) => {
+ return (
+ <React.Fragment>
+ {cur && moment(cur).format("YYYY-MM-DD HH:mm")}
+ </React.Fragment>
+ );
+ },
+ },
+ {
+ title: '来源',
+ dataIndex: 'author',
+ key: 'author',
+ },
+ ];
+ }
+
+ tabChange = (tab) => {
+ console.log('tab', tab);
+ let { formData } = this.state
+ if (tab == '全部') {
+ tab = '';
+ }
+ this.setState({
+ formData: {
+ __key: Date.now(),
+ keyword: tab,
+ page: 1,
+ size: 10,
+ }
+ })
+ }
render() {
+ let { keywordlist, formData, loading } = this.state;
+
+ let tableParams = {
+ url: `api/news/newslist`,
+ formData,
+ key: formData.__key,
+ columns: this.renderColumns(),
+ extraFromData: {
+ },
+ setFormData: this.setFormData
+ };
return (
<div className="hot-list-table-view-main">
- <BreadcrumbView data={[{ name: '行业热点知识库' }]} />
- <div className="hot-list-table-view-main-content">
- <Tabs defaultActiveKey="1" >
- <TabPane tab="Tab 1" key="1">
- Content of Tab Pane 1
- </TabPane>
- <TabPane tab="Tab 2" key="2">
- Content of Tab Pane 2
- </TabPane>
- <TabPane tab="Tab 3" key="3">
- Content of Tab Pane 3
- </TabPane>
- </Tabs>
- </div>
+ <Skeleton loading={loading}>
+ <BreadcrumbView data={[{ name: '行业热点知识库' }]} />
+ <div className="hot-list-table-view-main-content">
+ <Tabs defaultActiveKey={'全部'} onChange={this.tabChange}>
+ {
+ keywordlist.length &&
+ keywordlist.map((key) => (
+ <TabPane tab={key} key={key}>
+ </TabPane>
+ ))
+ }
+ </Tabs>
+ {/* 避免请求两遍 */}
+ {
+ !loading &&
+ <TableView {...tableParams} />
+
+ }
+ </div>
+ </Skeleton>
</div>
)
}
--
Gitblit v1.8.0