From a4f102defd2c7918617717f3307b6a3ef63859ff Mon Sep 17 00:00:00 2001
From: Mr Ke <kelq@hugeinfo.com.cn>
Date: Fri, 29 May 2020 18:03:17 +0800
Subject: [PATCH] 绩效总览 (列表、详情)、绩效指标 (配置)

---
 src/components/common/TableView/index.jsx |   56 +++++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 39 insertions(+), 17 deletions(-)

diff --git a/src/components/common/TableView/index.jsx b/src/components/common/TableView/index.jsx
index 41d88c8..3522f21 100644
--- a/src/components/common/TableView/index.jsx
+++ b/src/components/common/TableView/index.jsx
@@ -25,7 +25,7 @@
     }
 
     componentDidMount() {
-        let { page, size } = this.props.formData;
+        let { page = 1, size } = this.props.formData;
         this.loadData(page, size);
     }
 
@@ -43,18 +43,31 @@
                 size
             }
         }).then(res => {
-            if (res) {
-                res.content = res.content.map(({ ...a }, idx) => ({
-                    ...a,
-                    index: idx + 1 + 10 * (page - 1),
-                    key: idx,
-                }));
-            }
-            this.setState({
-                tableData: res ? res.content : [],
-                loading: false,
-                totalElements: res ? res.totalElements : 0,
-            });
+            if (res && res)
+                if (res) {
+                    if (res.content) {
+                        res.content = res.content.map(({ ...a }, idx) => ({
+                            ...a,
+                            index: idx + 1 + 10 * (page - 1),
+                            key: idx,
+                        }));
+                        this.setState({
+                            tableData: res ? res.content : [],
+                            loading: false,
+                            totalElements: res ? res.totalElements : 0,
+                        });
+                    } else {
+                        res = res.map(({ ...a }, idx) => ({
+                            ...a,
+                            index: idx + 1 + 10 * (page - 1),
+                            key: idx,
+                        }));
+                        this.setState({
+                            tableData: res,
+                            loading: false,
+                        })
+                    }
+                }
         });
     };
 
@@ -84,9 +97,18 @@
         return originalElement;
     };
 
+    onSetDataSource = ({ index, data }, callBack) => {
+        console.log(index, data);
+        let { tableData } = this.state;
+        tableData[index] = data;
+        this.setState({
+            tableData
+        })
+    }
+
     render() {
-        const { columns, rowSelection } = this.props;
-        const { page, size } = this.props.formData;
+        const { columns, rowSelection, showPagination = true } = this.props;
+        const { page, size, } = this.props.formData;
         return (
             <div className="table-view-main">
                 <Table
@@ -96,7 +118,7 @@
                     dataSource={this.state.tableData}
                     loading={{ spinning: this.state.loading }}
                     columns={columns}
-                    pagination={{
+                    pagination={showPagination ? {
                         pageSize: Number(size),
                         onChange: this.pageChange,
                         total: this.state.totalElements,
@@ -107,7 +129,7 @@
                         showQuickJumper: true,
                         defaultCurrent: 1,
                         current: Number(page),
-                    }} />
+                    } : false} />
             </div>
         )
     }

--
Gitblit v1.8.0