From b4744510a44b2f59b7ecece75085d4b70da2b059 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 05 二月 2020 19:02:50 +0800
Subject: [PATCH] 2020-02-05

---
 src/templates/tableshare/verifycard/index.jsx |  193 ++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 171 insertions(+), 22 deletions(-)

diff --git a/src/templates/tableshare/verifycard/index.jsx b/src/templates/tableshare/verifycard/index.jsx
index 5a0a790..e9e35a7 100644
--- a/src/templates/tableshare/verifycard/index.jsx
+++ b/src/templates/tableshare/verifycard/index.jsx
@@ -7,6 +7,7 @@
 import Utils from '@/utils/utils.js'
 
 import UniqueForm from './uniqueform'
+import ContrastForm from './contrastform'
 import CustomForm from './customform'
 import CustomScript from './customscript'
 import BillcodeForm from './billcodeform'
@@ -26,6 +27,7 @@
   state = {
     verify: {},
     fields: [],
+    usefulfields: '',
     orderModular: [],
     orderModularDetail: [],
     voucher: [],
@@ -34,12 +36,18 @@
       {
         title: '瀛楁鍚�',
         dataIndex: 'field',
-        width: '45%'
+        width: '35%'
       },
       {
         title: '鎶ラ敊缂栫爜',
         dataIndex: 'errorCode',
-        width: '15%'
+        width: '12%'
+      },
+      {
+        title: '楠岃瘉绫诲瀷',
+        dataIndex: 'verifyType',
+        width: '13%',
+        render: (text, record) => record.verifyType === 'logic' ? '閫昏緫楠岃瘉' : '鐗╃悊楠岃瘉'
       },
       {
         title: '鐘舵��',
@@ -78,6 +86,72 @@
             <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>
+          </div>)
+      }
+    ],
+    contrastColumns: [
+      {
+        title: '鍐呭1',
+        dataIndex: 'frontfield',
+        width: '13%'
+      },
+      {
+        title: '杩愮畻绗�',
+        dataIndex: 'operator',
+        width: '13%'
+      },
+      {
+        title: '鍐呭2',
+        dataIndex: 'backfield',
+        width: '13%',
+      },
+      {
+        title: '鎻愮ず淇℃伅',
+        dataIndex: 'errmsg',
+        width: '13%'
+      },
+      {
+        title: '鎶ラ敊缂栫爜',
+        dataIndex: 'errorCode',
+        width: '13%'
+      },
+      {
+        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: '20%',
+        dataIndex: 'operation',
+        render: (text, record) =>
+          (<div>
+            <span className="operation-btn" title={this.props.dict['header.edit']} onClick={() => this.handleEdit(record, 'contrast')} style={{color: '#1890ff'}}><Icon type="edit" /></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, 'contrast')
+            }>
+              <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span>
+            </Popconfirm>
+            <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'contrast', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span>
+            <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'contrast', '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, 'contrast')} style={{color: '#8E44AD'}}><Icon type="swap" /></span>
           </div>)
       }
     ],
@@ -190,7 +264,7 @@
     ],
     orderColumns: [
       {
-        title: '鍑芥暟鍙橀噺',
+        title: this.props.dict['header.form.funcvar'],
         dataIndex: 'fieldName',
         width: '13%',
         render: (text, record) => (`${record.fieldName || ''}(${record.field})`)
@@ -282,12 +356,14 @@
   }
 
   UNSAFE_componentWillMount() {
+    const { columns } = this.props
     let _verify = this.props.card.verify || {}
 
     this.setState({
       verify: {
         invalid: _verify.invalid || 'false',
         uniques: _verify.uniques || [],
+        contrasts: _verify.contrasts || [],
         accountdate: _verify.accountdate || 'false',
         customverifys: _verify.customverifys || [],
         billcodes: _verify.billcodes || [],
@@ -325,8 +401,28 @@
             _fields = _LongParam.fields
           }
 
+          let _usefulfields = []
+          _fields.forEach(_f => {
+            if (_f.field) {
+              _usefulfields.push(_f.field)
+            }
+          })
+
+          if (columns && columns.length > 0) {
+            columns.forEach(_f => {
+              if (_f.field) {
+                _usefulfields.push(_f.field)
+              }
+            })
+          }
+
+          _usefulfields = Array.from(new Set(_usefulfields))
+          _usefulfields = _usefulfields.join(', ')
+
+
           this.setState({
-            fields: _fields
+            fields: _fields,
+            usefulfields: _usefulfields
           })
         } else {
           notification.warning({
@@ -488,6 +584,27 @@
     })
   }
 
+  contrastChange = (values) => {
+    let verify = JSON.parse(JSON.stringify(this.state.verify))
+
+    if (values.uuid) {
+      verify.contrasts = verify.contrasts.map(item => {
+        if (item.uuid === values.uuid) {
+          return values
+        } else {
+          return item
+        }
+      })
+    } else {
+      values.uuid = Utils.getuuid()
+      verify.contrasts.push(values)
+    }
+
+    this.setState({
+      verify: verify
+    })
+  }
+
   customChange = (values) => {
     let verify = JSON.parse(JSON.stringify(this.state.verify))
 
@@ -571,6 +688,8 @@
       verify.billcodes = verify.billcodes.filter(item => item.uuid !== record.uuid)
     } else if (type === 'scripts') {
       verify.scripts = verify.scripts.filter(item => item.uuid !== record.uuid)
+    } else if (type === 'contrast') {
+      verify.contrasts = verify.contrasts.filter(item => item.uuid !== record.uuid)
     }
 
     this.setState({ verify: verify })
@@ -585,6 +704,8 @@
       this.orderForm.edit(record)
     } else if (type === 'scripts') {
       this.scriptsForm.edit(record)
+    } else if (type === 'contrast') {
+      this.contrastForm.edit(record)
     }
   }
 
@@ -602,6 +723,14 @@
       })
     } else if (type === 'unique') {
       verify.uniques = verify.uniques.map(item => {
+        if (item.uuid === record.uuid) {
+          return record
+        } else {
+          return item
+        }
+      })
+    } else if (type === 'contrast') {
+      verify.contrasts = verify.contrasts.map(item => {
         if (item.uuid === record.uuid) {
           return record
         } else {
@@ -652,10 +781,6 @@
       } else {
         verify.customverifys.splice(index + 1, 0, record)
       }
-  
-      this.setState({
-        verify: verify
-      })
     } else if (type === 'unique') {
       verify.uniques = verify.uniques.filter((item, i) => {
         if (item.uuid === record.uuid) {
@@ -673,10 +798,23 @@
       } else {
         verify.uniques.splice(index + 1, 0, record)
       }
-  
-      this.setState({
-        verify: verify
+    } else if (type === 'contrast') {
+      verify.contrasts = verify.contrasts.filter((item, i) => {
+        if (item.uuid === record.uuid) {
+          index = i
+        }
+
+        return item.uuid !== record.uuid
       })
+      if ((index === 0 && direction === 'up') || (index === verify.contrasts.length && direction === 'down')) {
+        return
+      }
+
+      if (direction === 'up') {
+        verify.contrasts.splice(index - 1, 0, record)
+      } else {
+        verify.contrasts.splice(index + 1, 0, record)
+      }
     } else if (type === 'ordercode') {
       verify.billcodes = verify.billcodes.filter((item, i) => {
         if (item.uuid === record.uuid) {
@@ -694,10 +832,6 @@
       } else {
         verify.billcodes.splice(index + 1, 0, record)
       }
-  
-      this.setState({
-        verify: verify
-      })
     } else if (type === 'scripts') {
       verify.scripts = verify.scripts.filter((item, i) => {
         if (item.uuid === record.uuid) {
@@ -715,11 +849,11 @@
       } else {
         verify.scripts.splice(index + 1, 0, record)
       }
-  
-      this.setState({
-        verify: verify
-      })
     }
+
+    this.setState({
+      verify: verify
+    })
   }
 
   voucherChange = (voucher) => {
@@ -771,8 +905,7 @@
   }
 
   render() {
-    // const { getFieldDecorator } = this.props.form
-    const { verify, fields, uniqueColumns, customColumns, orderColumns, scriptsColumns, orderModular, orderModularDetail, voucher, voucherDetail } = this.state
+    const { verify, fields, uniqueColumns, contrastColumns, customColumns, orderColumns, scriptsColumns, orderModular, orderModularDetail, voucher, voucherDetail } = this.state
     const formItemLayout = {
       labelCol: {
         xs: { span: 24 },
@@ -808,6 +941,21 @@
             </Row>
           </Form>
         </TabPane>
+        <TabPane tab="姣旇緝楠岃瘉" key="2x">
+          <ContrastForm
+            dict={this.props.dict}
+            contrastChange={this.contrastChange}
+            wrappedComponentRef={(inst) => this.contrastForm = inst}
+          />
+          <Table
+            bordered
+            rowKey="uuid"
+            className="custom-table"
+            dataSource={verify.contrasts}
+            columns={contrastColumns}
+            pagination={false}
+          />
+        </TabPane>
         <TabPane tab="鍞竴鎬ч獙璇�" key="2">
           <UniqueForm
             fields={fields}
@@ -827,6 +975,7 @@
         <TabPane tab="鑷畾涔夐獙璇�" key="3">
           <CustomForm
             dict={this.props.dict}
+            usefulfields={this.state.usefulfields}
             customChange={this.customChange}
             wrappedComponentRef={(inst) => this.customForm = inst}
           />
@@ -873,7 +1022,7 @@
         </TabPane>
         <TabPane tab="鑷畾涔夎剼鏈�" key="6">
           <CustomScript
-            fields={fields}
+            usefulfields={this.state.usefulfields}
             dict={this.props.dict}
             scriptsChange={this.scriptsChange}
             wrappedComponentRef={(inst) => this.scriptsForm = inst}

--
Gitblit v1.8.0