From 6bf92751fe8dfa0624285268968a1fd7a8a7e7e5 Mon Sep 17 00:00:00 2001
From: Mr Ke <kelq@hugeinfo.com.cn>
Date: Tue, 20 Oct 2020 14:39:49 +0800
Subject: [PATCH] 修改默认人员头像

---
 src/components/common/TableView/index.jsx |   59 ++++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 40 insertions(+), 19 deletions(-)

diff --git a/src/components/common/TableView/index.jsx b/src/components/common/TableView/index.jsx
index 643dcdd..11265b1 100644
--- a/src/components/common/TableView/index.jsx
+++ b/src/components/common/TableView/index.jsx
@@ -24,10 +24,8 @@
         };
     }
 
-    componentWillMount() { }
-
     componentDidMount() {
-        let { page, size } = this.props.formData;
+        let { page = 1, size } = this.props.formData;
         this.loadData(page, size);
     }
 
@@ -45,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,
+                        })
+                    }
+                }
         });
     };
 
@@ -86,19 +97,29 @@
         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, rowClassName = '' } = this.props;
+        const { page, size, } = this.props.formData;
         return (
             <div className="table-view-main">
                 <Table
+                    rowClassName={rowClassName}
                     rowSelection={rowSelection || null}
                     size="middle"
                     className="rowColor"
                     dataSource={this.state.tableData}
                     loading={{ spinning: this.state.loading }}
                     columns={columns}
-                    pagination={{
+                    pagination={showPagination ? {
                         pageSize: Number(size),
                         onChange: this.pageChange,
                         total: this.state.totalElements,
@@ -109,7 +130,7 @@
                         showQuickJumper: true,
                         defaultCurrent: 1,
                         current: Number(page),
-                    }} />
+                    } : false} />
             </div>
         )
     }

--
Gitblit v1.8.0