From 5046d0d13dc6a8563b8e54e31913bc44cfa1072f Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 26 四月 2022 19:23:18 +0800
Subject: [PATCH] 2022-04-26

---
 src/templates/zshare/modalform/modaleditable/index.jsx |   51 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 49 insertions(+), 2 deletions(-)

diff --git a/src/templates/zshare/modalform/modaleditable/index.jsx b/src/templates/zshare/modalform/modaleditable/index.jsx
index 8670071..3e076af 100644
--- a/src/templates/zshare/modalform/modaleditable/index.jsx
+++ b/src/templates/zshare/modalform/modaleditable/index.jsx
@@ -67,7 +67,7 @@
     }
 
     return editing ? (
-      <Form.Item style={{ margin: 0 }}>
+      <Form.Item style={{ margin: '0 -5px 0 -5px' }}>
         {form.getFieldDecorator(dataIndex, {
           rules: [
             {
@@ -115,6 +115,7 @@
 class EditTable extends Component {
   static propTpyes = {
     type: PropTypes.string,         // 琛ㄥ崟绫诲瀷
+    module: PropTypes.string,       // 鍏冪礌绫诲瀷
     linkSubFields: PropTypes.array, // 鍏宠仈瀛楁
     transfield: PropTypes.object,   // 琛ㄥ崟瀛楁鍚嶇О
     onChange: PropTypes.func        // 鏁版嵁鍙樺寲
@@ -215,6 +216,20 @@
       _data.splice(index + 1, 0, record)
     }
 
+    this.setState({
+      dataSource: _data
+    }, () => {
+      this.props.onChange(_data)
+    })
+  }
+
+  handleHide = (record) => {
+    let _data = this.state.dataSource.map(item => {
+      if (item.key === record.key) {
+        item.Hide = !item.Hide
+      }
+      return item
+    })
     this.setState({
       dataSource: _data
     }, () => {
@@ -336,6 +351,7 @@
             <div style={{fontSize: '15px'}}>
               <span className="operation-btn" onClick={() => this.handleUpDown(record, 'up')} style={{color: '#1890ff'}}><ArrowUpOutlined /></span>
               <span className="operation-btn" onClick={() => this.handleUpDown(record, 'down')} style={{color: '#ff4d4f'}}><ArrowDownOutlined /></span>
+              <span className="operation-btn" title="鏄剧ず/闅愯棌" onClick={() => this.handleHide(record)} style={{color: 'rgb(142, 68, 173)'}}><SwapOutlined /></span>
               <Popconfirm
                 title="纭畾鍒犻櫎鍚楋紵"
                 overlayClassName="popover-confirm"
@@ -368,6 +384,35 @@
     }
   }
 
+  handleEmpty = (e) => {
+    e.stopPropagation()
+    const { linkSubFields, module } = this.props
+    const { dataSource } = this.state
+
+    if (dataSource.filter(item => item.Value === '').length > 0) {
+      message.warning('Value涓虹┖宸插瓨鍦紒')
+      return
+    }
+    const newData = {
+      key: Utils.getuuid(),
+      Value: '',
+      Text: module === 'form' ? '绌�' : '鍏ㄩ儴',
+      ParentID: ''
+    }
+
+    linkSubFields.forEach(m => {
+      newData[m] = newData[m] || ''
+    })
+
+    let _data = [newData, ...dataSource]
+
+    this.setState({
+      dataSource: _data,
+    }, () => {
+      this.props.onChange(_data)
+    })
+  }
+
   resetColumn = (type, linkSubFields) => {
     const { columns, dataSource } = this.getColumns(type, linkSubFields, this.state.dataSource)
 
@@ -392,6 +437,7 @@
   }
 
   render() {
+    const { module } = this.props
     const { dataSource } = this.state
     const components = {
       body: {
@@ -417,10 +463,11 @@
     })
     return (
       <div className="common-modal-edit-table">
+        <span className="add-row add-row-empty" onClick={this.handleEmpty}>{module === 'form' ? '绌�' : '鍏ㄩ儴'}</span>
         <PlusOutlined className="add-row" onClick={this.handleAdd} />
         <Table
           components={components}
-          rowClassName={() => 'editable-row'}
+          rowClassName={(record) => record.Hide ? 'editable-row hide' : 'editable-row'}
           bordered
           dataSource={dataSource}
           columns={columns}

--
Gitblit v1.8.0