From 2c0e07ad097eb692c9909efdc614cc40b8653de2 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 01 四月 2020 14:13:36 +0800
Subject: [PATCH] 2020-04-01

---
 src/templates/zshare/verifycardexcelin/index.jsx |  141 ++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 134 insertions(+), 7 deletions(-)

diff --git a/src/templates/zshare/verifycardexcelin/index.jsx b/src/templates/zshare/verifycardexcelin/index.jsx
index 0cc7084..3113e4e 100644
--- a/src/templates/zshare/verifycardexcelin/index.jsx
+++ b/src/templates/zshare/verifycardexcelin/index.jsx
@@ -4,6 +4,7 @@
 
 import Utils from '@/utils/utils.js'
 
+import UniqueForm from './uniqueform'
 import ColumnForm from './columnform'
 import CustomScript from './customscript'
 import './index.scss'
@@ -73,10 +74,67 @@
                 cancelText={this.props.dict['header.cancel']}
                 onConfirm={() => this.handleDelete(record, 'columns')
               }>
-                <span style={{color: '#1890ff', cursor: 'pointer'}}><Icon type="delete" /></span>
+                <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span>
               </Popconfirm>
             </div>
           )
+      }
+    ],
+    uniqueColumns: [
+      {
+        title: '瀛楁鍚�',
+        dataIndex: 'field',
+        width: '35%'
+      },
+      {
+        title: '鎶ラ敊缂栫爜',
+        dataIndex: 'errorCode',
+        width: '12%'
+      },
+      {
+        title: '楠岃瘉绫诲瀷',
+        dataIndex: 'verifyType',
+        width: '13%',
+        render: (text, record) => record.verifyType === 'logic' ? '閫昏緫楠岃瘉' : '鐗╃悊楠岃瘉'
+      },
+      {
+        title: '鐘舵��',
+        dataIndex: 'status',
+        width: '15%',
+        render: (text, record) => record.status === 'false' ?
+          (
+            <div>
+              {this.props.dict['header.form.status.forbidden']}
+              <Icon style={{marginLeft: '5px'}} type="stop" theme="twoTone" twoToneColor="#ff4d4f" />
+            </div>
+          ) :
+          (
+            <div>
+              {this.props.dict['header.form.status.open']}
+              <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" />
+            </div>
+          )
+      },
+      {
+        title: '鎿嶄綔',
+        align: 'center',
+        width: '25%',
+        dataIndex: 'operation',
+        render: (text, record) =>
+          (<div>
+            <span className="operation-btn" title={this.props.dict['header.edit']} onClick={() => this.handleEdit(record, 'unique')} style={{color: '#1890ff'}}><Icon type="edit" /></span>
+            <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'unique', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span>
+            <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'unique', 'down')} style={{color: '#ff4d4f'}}><Icon type="arrow-down" /></span>
+            <span className="operation-btn" title={this.props.dict['header.form.status.change']} onClick={() => this.handleStatus(record, 'unique')} style={{color: '#8E44AD'}}><Icon type="swap" /></span>
+            <Popconfirm
+              title={this.props.dict['header.form.query.delete']}
+              okText={this.props.dict['header.confirm']}
+              cancelText={this.props.dict['header.cancel']}
+              onConfirm={() => this.handleDelete(record, 'unique')
+            }>
+              <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span>
+            </Popconfirm>
+          </div>)
       }
     ],
     scriptsColumns: [
@@ -153,7 +211,8 @@
         sheet: _verify.sheet || 'Sheet1',
         range: _verify.range || 0,
         columns: _columns,
-        scripts: _verify.scripts || []
+        scripts: _verify.scripts || [],
+        uniques: _verify.uniques || []
       }
     })
   }
@@ -225,6 +284,27 @@
     })
   }
 
+  uniqueChange = (values) => {
+    let verify = JSON.parse(JSON.stringify(this.state.verify))
+
+    if (values.uuid) {
+      verify.uniques = verify.uniques.map(item => {
+        if (item.uuid === values.uuid) {
+          return values
+        } else {
+          return item
+        }
+      })
+    } else {
+      values.uuid = Utils.getuuid()
+      verify.uniques.push(values)
+    }
+
+    this.setState({
+      verify: verify
+    })
+  }
+
   scriptsChange = (values) => {
     let verify = JSON.parse(JSON.stringify(this.state.verify))
 
@@ -253,7 +333,10 @@
       verify.columns = verify.columns.filter(item => item.uuid !== record.uuid)
     } else if (type === 'scripts') {
       verify.scripts = verify.scripts.filter(item => item.uuid !== record.uuid)
+    } else if (type === 'unique') {
+      verify.uniques = verify.uniques.filter(item => item.uuid !== record.uuid)
     }
+
     this.setState({ verify: verify })
   }
 
@@ -262,6 +345,8 @@
       this.columnForm.edit(record)
     } else if (type === 'scripts') {
       this.scriptsForm.edit(record)
+    } else if (type === 'unique') {
+      this.uniqueForm.edit(record)
     }
 
     let node = document.getElementById('verify-excel-box-tab').parentNode
@@ -286,6 +371,14 @@
 
     if (type === 'scripts') {
       verify.scripts = verify.scripts.map(item => {
+        if (item.uuid === record.uuid) {
+          return record
+        } else {
+          return item
+        }
+      })
+    } else if (type === 'unique') {
+      verify.uniques = verify.uniques.map(item => {
         if (item.uuid === record.uuid) {
           return record
         } else {
@@ -319,6 +412,23 @@
         verify.columns.splice(index - 1, 0, record)
       } else {
         verify.columns.splice(index + 1, 0, record)
+      }
+    } else if (type === 'unique') {
+      verify.uniques = verify.uniques.filter((item, i) => {
+        if (item.uuid === record.uuid) {
+          index = i
+        }
+
+        return item.uuid !== record.uuid
+      })
+      if ((index === 0 && direction === 'up') || (index === verify.uniques.length && direction === 'down')) {
+        return
+      }
+
+      if (direction === 'up') {
+        verify.uniques.splice(index - 1, 0, record)
+      } else {
+        verify.uniques.splice(index + 1, 0, record)
       }
     } else if (type === 'scripts') {
       verify.scripts = verify.scripts.filter((item, i) => {
@@ -444,8 +554,9 @@
   }
 
   render() {
+    const { card } = this.props
     const { getFieldDecorator } = this.props.form
-    const { verify, excelColumns, scriptsColumns } = this.state
+    const { verify, excelColumns, scriptsColumns, uniqueColumns } = this.state
     const formItemLayout = {
       labelCol: {
         xs: { span: 24 },
@@ -483,14 +594,14 @@
                     })(<InputNumber min={0} max={100} precision={0} />)}
                   </Form.Item>
                 </Col>
-                <Col span={8}>
+                {card.intertype === 'inner' && !card.innerFunc ? <Col span={8}>
                   <Form.Item label={'榛樿sql'}>
                     <Radio.Group value={verify.default} onChange={this.onOptionChange}>
                       <Radio value="true">鎵ц</Radio>
                       <Radio value="false">涓嶆墽琛�</Radio>
                     </Radio.Group>
                   </Form.Item>
-                </Col>
+                </Col> : null}
               </Row>
             </Form>
           </TabPane>
@@ -513,7 +624,23 @@
               pagination={false}
             />
           </TabPane>
-          <TabPane tab="鑷畾涔夎剼鏈�" key="6">
+          {card.intertype === 'inner' && !card.innerFunc ? <TabPane tab="鍞竴鎬ч獙璇�" key="3">
+            <UniqueForm
+              fields={verify.columns}
+              dict={this.props.dict}
+              uniqueChange={this.uniqueChange}
+              wrappedComponentRef={(inst) => this.uniqueForm = inst}
+            />
+            <Table
+              bordered
+              rowKey="uuid"
+              className="custom-table"
+              dataSource={verify.uniques}
+              columns={uniqueColumns}
+              pagination={false}
+            />
+          </TabPane> : null}
+          {card.intertype === 'inner' && !card.innerFunc ? <TabPane tab="鑷畾涔夎剼鏈�" key="6">
             <CustomScript
               dict={this.props.dict}
               btn={this.props.card}
@@ -531,7 +658,7 @@
               columns={scriptsColumns}
               pagination={false}
             />
-          </TabPane>
+          </TabPane> : null}
           <TabPane tab="淇℃伅鎻愮ず" key="7">
             <Form {...formItemLayout}>
               <Row gutter={24}>

--
Gitblit v1.8.0