From 2031a460f6c0827fe80f8c625dd98333d1631d2f Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 08 五月 2020 22:10:48 +0800
Subject: [PATCH] 2020-05-08

---
 src/templates/sharecomponent/searchcomponent/searcheditable/index.jsx |   58 +++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 51 insertions(+), 7 deletions(-)

diff --git a/src/templates/sharecomponent/searchcomponent/searcheditable/index.jsx b/src/templates/sharecomponent/searchcomponent/searcheditable/index.jsx
index 8abe02b..cfb435a 100644
--- a/src/templates/sharecomponent/searchcomponent/searcheditable/index.jsx
+++ b/src/templates/sharecomponent/searchcomponent/searcheditable/index.jsx
@@ -112,9 +112,18 @@
         dataIndex: 'operation',
         render: (text, record) =>
           this.state.dataSource.length >= 1 ? (
-            <Popconfirm title="Sure to delete?" onConfirm={() => this.handleDelete(record.key)}>
-              <span style={{color: '#1890ff', cursor: 'pointer'}}><Icon type="delete" /></span>
-            </Popconfirm>
+            <div>
+              <span className="operation-btn" title={props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span>
+              <span className="operation-btn" title={props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span>
+              <Popconfirm
+                title={props.dict['header.form.query.delete']}
+                okText={props.dict['model.confirm']}
+                cancelText={props.dict['header.cancel']}
+                onConfirm={() => this.handleDelete(record.key)
+              }>
+                <span style={{color: '#1890ff', cursor: 'pointer'}}><Icon type="delete" /></span>
+              </Popconfirm>
+            </div>
           ) : null,
       }
     ]
@@ -134,6 +143,32 @@
       count: props.data.length,
       type: props.type
     }
+  }
+
+  handleUpDown = (record, direction) => {
+    const { dataSource } = this.state
+    let index = 0
+
+    let _data = dataSource.filter((item, i) => {
+      if (item.key === record.key) {
+        index = i
+      }
+
+      return item.key !== record.key
+    })
+    if ((index === 0 && direction === 'up') || (index === dataSource.length - 1 && direction === 'down')) {
+      return
+    }
+
+    if (direction === 'up') {
+      _data.splice(index - 1, 0, record)
+    } else {
+      _data.splice(index + 1, 0, record)
+    }
+
+    this.setState({
+      dataSource: _data
+    })
   }
 
   handleDelete = key => {
@@ -188,9 +223,18 @@
         dataIndex: 'operation',
         render: (text, record) =>
           this.state.dataSource.length >= 1 ? (
-            <Popconfirm title="Sure to delete?" onConfirm={() => this.handleDelete(record.key)}>
-              <span style={{color: '#1890ff', cursor: 'pointer'}}><Icon type="delete" /></span>
-            </Popconfirm>
+            <div>
+              <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span>
+              <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span>
+              <Popconfirm
+                title={this.props.dict['header.form.query.delete']}
+                okText={this.props.dict['model.confirm']}
+                cancelText={this.props.dict['header.cancel']}
+                onConfirm={() => this.handleDelete(record.key)
+              }>
+                <span style={{color: '#1890ff', cursor: 'pointer'}}><Icon type="delete" /></span>
+              </Popconfirm>
+            </div>
           ) : null,
       }
     ]
@@ -245,7 +289,7 @@
       }
     })
     return (
-      <div className="common-modal-edit-table">
+      <div className="model-search-edit-table">
         <Button onClick={this.handleAdd} type="primary" className="add-row">
           Add
         </Button>

--
Gitblit v1.8.0