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/tabviews/tableshare/mutilform/index.jsx                 |    7 
 src/templates/tableshare/verifycard/contrastform/index.jsx  |  165 ++++++++++++++++
 src/templates/tableshare/verifycard/customform/index.jsx    |   12 
 src/templates/modalconfig/source.jsx                        |    8 
 src/templates/tableshare/verifycard/uniqueform/index.jsx    |   21 ++
 src/templates/tableshare/searchform/index.jsx               |    6 
 src/templates/tableshare/verifycard/contrastform/index.scss |    0 
 src/templates/tableshare/verifycard/customscript/index.jsx  |   15 
 src/templates/tableshare/verifycard/index.jsx               |  193 +++++++++++++++++--
 src/templates/tableshare/verifycard/billcodeform/index.jsx  |    4 
 src/utils/utils.js                                          |  119 ++++++-----
 src/templates/ushare/modalform/index.jsx                    |    6 
 12 files changed, 456 insertions(+), 100 deletions(-)

diff --git a/src/tabviews/tableshare/mutilform/index.jsx b/src/tabviews/tableshare/mutilform/index.jsx
index eecbb2d..c4ec170 100644
--- a/src/tabviews/tableshare/mutilform/index.jsx
+++ b/src/tabviews/tableshare/mutilform/index.jsx
@@ -588,20 +588,19 @@
                 key: key,
                 value: vals.join(',')
               })
-            } else if (this.state.datatype[key] === 'funcvar') {
+            } else if (this.state.datatype[key] === 'text') {
               search.push({
                 type: this.state.datatype[key],
                 readonly: this.state.readtype[key],
                 key: key,
-                value: values[key]
+                value: values[key].replace(/(^\s*|\s*$) | \t* | \v*/ig, '')
               })
             } else {
               search.push({
                 type: this.state.datatype[key],
                 readonly: this.state.readtype[key],
                 key: key,
-                value: values[key].replace(/(^\s*|\s*$)/ig, '')
-                // value: values[key].replace(/[\x00-\xff]+/ig, '')
+                value: values[key]
               })
             }
           })
diff --git a/src/templates/modalconfig/source.jsx b/src/templates/modalconfig/source.jsx
index ff5f72b..ea95e00 100644
--- a/src/templates/modalconfig/source.jsx
+++ b/src/templates/modalconfig/source.jsx
@@ -1,8 +1,8 @@
 import Utils from '@/utils/utils.js'
-// import zhCN from '@/locales/zh-CN/comtable.js'
-// import enUS from '@/locales/en-US/comtable.js'
+import zhCN from '@/locales/zh-CN/comtable.js'
+import enUS from '@/locales/en-US/comtable.js'
 
-// const CommonDict = (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS
+const CommonDict = (!localStorage.getItem('lang') || localStorage.getItem('lang') === 'zh-CN') ? zhCN : enUS
 
 class CommonTableBaseData {
   baseConfig = {
@@ -117,7 +117,7 @@
     },
     {
       type: 'form',
-      label: '鍑芥暟鍙橀噺',
+      label: CommonDict['header.form.funcvar'],
       subType: 'funcvar',
       url: ''
     }
diff --git a/src/templates/tableshare/searchform/index.jsx b/src/templates/tableshare/searchform/index.jsx
index d66a79c..840f47d 100644
--- a/src/templates/tableshare/searchform/index.jsx
+++ b/src/templates/tableshare/searchform/index.jsx
@@ -346,6 +346,12 @@
           }
 
           if (isvalid) {
+            ['linkField', 'valueField', 'valueText', 'orderBy'].forEach(item => {
+              if (values[item]) {
+                values[item] = values[item].replace(/\s* | \t* | \v* | \r*/ig, '')
+              }
+            })
+
             resolve(values)
           } else {
             notification.warning({
diff --git a/src/templates/tableshare/verifycard/billcodeform/index.jsx b/src/templates/tableshare/verifycard/billcodeform/index.jsx
index 2df33e0..e954c77 100644
--- a/src/templates/tableshare/verifycard/billcodeform/index.jsx
+++ b/src/templates/tableshare/verifycard/billcodeform/index.jsx
@@ -213,13 +213,13 @@
       <Form {...formItemLayout} className="verify-form">
         <Row gutter={24}>
           <Col span={10}>
-            <Form.Item label={'鍑芥暟鍙橀噺'}>
+            <Form.Item label={this.props.dict['header.form.funcvar']}>
               {getFieldDecorator('field', {
                 initialValue: '',
                 rules: [
                   {
                     required: true,
-                    message: this.props.dict['form.required.input'] + '鍑芥暟鍙橀噺!'
+                    message: this.props.dict['form.required.input'] + this.props.dict['header.form.funcvar'] + '!'
                   }
                 ]
               })(
diff --git a/src/templates/tableshare/verifycard/contrastform/index.jsx b/src/templates/tableshare/verifycard/contrastform/index.jsx
new file mode 100644
index 0000000..dbff28f
--- /dev/null
+++ b/src/templates/tableshare/verifycard/contrastform/index.jsx
@@ -0,0 +1,165 @@
+import React, {Component} from 'react'
+import PropTypes from 'prop-types'
+import { Form, Row, Col, Select, Button, Input } from 'antd'
+import './index.scss'
+
+
+class UniqueForm extends Component {
+  static propTpyes = {
+    dict: PropTypes.object,       // 瀛楀吀椤�
+    contrastChange: PropTypes.func  // 淇敼鍑芥暟
+  }
+
+  state = {
+    editItem: null // 缂栬緫鍏冪礌
+  }
+
+  edit = (record) => {
+    this.setState({
+      editItem: record
+    })
+
+    this.props.form.setFieldsValue({
+      frontfield: record.frontfield,
+      operator: record.operator,
+      backfield: record.backfield,
+      errmsg: record.errmsg,
+      errorCode: record.errorCode
+    })
+  }
+
+
+  handleConfirm = () => {
+    // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭�
+    this.props.form.validateFieldsAndScroll((err, values) => {
+      if (!err) {
+        values.uuid = this.state.editItem ? this.state.editItem.uuid : ''
+
+        this.props.contrastChange(values)
+        this.setState({
+          editItem: null
+        })
+        this.props.form.setFieldsValue({
+          frontfield: '',
+          backfield: '',
+          errmsg: ''
+        })
+      }
+    })
+  }
+
+  render() {
+    const { getFieldDecorator } = this.props.form
+    const formItemLayout = {
+      labelCol: {
+        xs: { span: 24 },
+        sm: { span: 8 }
+      },
+      wrapperCol: {
+        xs: { span: 24 },
+        sm: { span: 16 }
+      }
+    }
+
+    return (
+      <Form {...formItemLayout} className="verify-form" id="verifycard1">
+        <Row gutter={24}>
+          <Col span={7}>
+            <Form.Item label={'鍐呭1'}>
+              {getFieldDecorator('frontfield', {
+                initialValue: '',
+                rules: [
+                  {
+                    required: true,
+                    message: this.props.dict['form.required.input'] + '鍐呭1!'
+                  }
+                ]
+              })(<Input placeholder="" autoComplete="off" />)}
+            </Form.Item>
+          </Col>
+          <Col span={7}>
+            <Form.Item label={'杩愮畻绗�'}>
+              {getFieldDecorator('operator', {
+                initialValue: '=',
+                rules: [
+                  {
+                    required: true,
+                    message: this.props.dict['form.required.select'] + '杩愮畻绗�!'
+                  }
+                ]
+              })(
+                <Select>
+                  <Select.Option value="="> = </Select.Option>
+                  <Select.Option value="!="> != </Select.Option>
+                  <Select.Option value=">"> &gt; </Select.Option>
+                  <Select.Option value="<"> &lt; </Select.Option>
+                  <Select.Option value=">="> &gt;= </Select.Option>
+                  <Select.Option value="<="> &lt;= </Select.Option>
+                  <Select.Option value="in"> in </Select.Option>
+                  <Select.Option value="like"> like </Select.Option>
+                </Select>
+              )}
+            </Form.Item>
+          </Col>
+          <Col span={7}>
+            <Form.Item label={'鍐呭2'}>
+              {getFieldDecorator('backfield', {
+                initialValue: '',
+                rules: [
+                  {
+                    required: true,
+                    message: this.props.dict['form.required.input'] + '鍐呭2!'
+                  }
+                ]
+              })(<Input placeholder="" autoComplete="off" />)}
+            </Form.Item>
+          </Col>
+          <Col span={3} className="add">
+            <Button onClick={this.handleConfirm} type="primary" className="add-row">
+              纭畾
+            </Button>
+          </Col>
+          <Col span={7}>
+            <Form.Item label={'鎻愮ず淇℃伅'}>
+              {getFieldDecorator('errmsg', {
+                initialValue: '',
+                rules: [
+                  {
+                    required: true,
+                    message: this.props.dict['form.required.input'] + '鎻愮ず淇℃伅!'
+                  },
+                  {
+                    pattern: /^[^']*$/ig,
+                    message: '鎻愮ず淇℃伅涓嶅厑璁稿寘鍚玕''
+                  }
+                ]
+              })(<Input placeholder="" autoComplete="off" />)}
+            </Form.Item>
+          </Col>
+          <Col span={7}>
+            <Form.Item label={'鎶ラ敊缂栫爜'}>
+              {getFieldDecorator('errorCode', {
+                initialValue: 'E',
+                rules: [
+                  {
+                    required: true,
+                    message: this.props.dict['form.required.select'] + '鎶ラ敊缂栫爜!'
+                  }
+                ]
+              })(
+                <Select>
+                  <Select.Option value="E"> E </Select.Option>
+                  <Select.Option value="N"> N </Select.Option>
+                  <Select.Option value="F"> F </Select.Option>
+                  <Select.Option value="NM"> NM </Select.Option>
+                </Select>
+              )}
+            </Form.Item>
+          </Col>
+        </Row>
+      </Form>
+    )
+  }
+}
+
+export default Form.create()(UniqueForm)
\ No newline at end of file
diff --git a/src/templates/tableshare/verifycard/contrastform/index.scss b/src/templates/tableshare/verifycard/contrastform/index.scss
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/templates/tableshare/verifycard/contrastform/index.scss
diff --git a/src/templates/tableshare/verifycard/customform/index.jsx b/src/templates/tableshare/verifycard/customform/index.jsx
index d13eb4c..2ed3c12 100644
--- a/src/templates/tableshare/verifycard/customform/index.jsx
+++ b/src/templates/tableshare/verifycard/customform/index.jsx
@@ -7,9 +7,9 @@
 
 class CustomForm extends Component {
   static propTpyes = {
-    dict: PropTypes.object,  // 瀛楀吀椤�
-    fields: PropTypes.array,  // 琛ㄥ崟
-    customChange: PropTypes.func  // 琛ㄥ崟
+    dict: PropTypes.object,         // 瀛楀吀椤�
+    usefulfields: PropTypes.string, // 鍙敤瀛楁
+    customChange: PropTypes.func    // 琛ㄥ崟
   }
 
   state = {
@@ -74,6 +74,7 @@
   }
 
   render() {
+    const { usefulfields } = this.props
     const { getFieldDecorator } = this.props.form
     const formItemLayout = {
       labelCol: {
@@ -88,6 +89,11 @@
     return (
       <Form {...formItemLayout} className="verify-form" id="verifycard2">
         <Row gutter={24}>
+          {usefulfields ? <Col span={21} className="sqlfield">
+            <Form.Item label={'鍙敤瀛楁'}>
+              {usefulfields}
+            </Form.Item>
+          </Col> : null}
           <Col span={21} className="sql">
             <Form.Item label={'sql'}>
               {getFieldDecorator('sql', {
diff --git a/src/templates/tableshare/verifycard/customscript/index.jsx b/src/templates/tableshare/verifycard/customscript/index.jsx
index 5379c91..4079de4 100644
--- a/src/templates/tableshare/verifycard/customscript/index.jsx
+++ b/src/templates/tableshare/verifycard/customscript/index.jsx
@@ -7,9 +7,9 @@
 
 class CustomForm extends Component {
   static propTpyes = {
-    dict: PropTypes.object,       // 瀛楀吀椤�
-    fields: PropTypes.array,      // 琛ㄥ崟
-    scriptsChange: PropTypes.func  // 琛ㄥ崟
+    dict: PropTypes.object,         // 瀛楀吀椤�
+    usefulfields: PropTypes.string, // 鍙敤瀛楁
+    scriptsChange: PropTypes.func   // 琛ㄥ崟
   }
 
   state = {
@@ -69,7 +69,7 @@
   }
 
   render() {
-    const { fields } = this.props
+    const { usefulfields } = this.props
     const { getFieldDecorator } = this.props.form
     const formItemLayout = {
       labelCol: {
@@ -81,14 +81,13 @@
         sm: { span: 16 }
       }
     }
-    let _fields = fields.map(item => item.field)
 
     return (
       <Form {...formItemLayout} className="verify-form" id="verifycard2">
         <Row gutter={24}>
-          {fields && fields.length > 0 ? <Col span={21} className="sqlfield">
-            <Form.Item label={'琛ㄥ崟瀛楁'}>
-              {_fields.join(', ')}
+          {usefulfields ? <Col span={21} className="sqlfield">
+            <Form.Item label={'鍙敤瀛楁'}>
+              {usefulfields}
             </Form.Item>
           </Col> : null}
           <Col span={21} className="sql">
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}
diff --git a/src/templates/tableshare/verifycard/uniqueform/index.jsx b/src/templates/tableshare/verifycard/uniqueform/index.jsx
index 9e4b5f1..71413be 100644
--- a/src/templates/tableshare/verifycard/uniqueform/index.jsx
+++ b/src/templates/tableshare/verifycard/uniqueform/index.jsx
@@ -22,7 +22,8 @@
 
     this.props.form.setFieldsValue({
       field: record.field.split(','),
-      errorCode: record.errorCode
+      errorCode: record.errorCode,
+      verifyType: record.verifyType || 'physical'
     })
   }
 
@@ -114,6 +115,24 @@
               )}
             </Form.Item>
           </Col>
+          <Col span={6}>
+            <Form.Item label={'楠岃瘉绫诲瀷'}>
+              {getFieldDecorator('verifyType', {
+                initialValue: 'physical',
+                rules: [
+                  {
+                    required: true,
+                    message: this.props.dict['form.required.select'] + '楠岃瘉绫诲瀷!'
+                  }
+                ]
+              })(
+                <Select>
+                  <Select.Option value="physical"> 鐗╃悊楠岃瘉 </Select.Option>
+                  <Select.Option value="logic"> 閫昏緫楠岃瘉 </Select.Option>
+                </Select>
+              )}
+            </Form.Item>
+          </Col>
           <Col span={2} className="add">
             <Button onClick={this.handleConfirm} type="primary" className="add-row">
               纭畾
diff --git a/src/templates/ushare/modalform/index.jsx b/src/templates/ushare/modalform/index.jsx
index d870560..7bde0cf 100644
--- a/src/templates/ushare/modalform/index.jsx
+++ b/src/templates/ushare/modalform/index.jsx
@@ -391,6 +391,12 @@
             values.initval = ''
           }
 
+          ['linkField', 'valueField', 'valueText', 'orderBy'].forEach(item => {
+            if (values[item]) {
+              values[item] = values[item].replace(/\s* | \t* | \v* | \r*/ig, '')
+            }
+          })
+
           if (isvalid) {
             resolve(values)
           }
diff --git a/src/utils/utils.js b/src/utils/utils.js
index 2f0b702..df4d668 100644
--- a/src/utils/utils.js
+++ b/src/utils/utils.js
@@ -450,9 +450,8 @@
     let BID = param.BID
     let verify = btn.verify
     let _formFieldValue = {}
-
     // 闇�瑕佸0鏄庣殑鍙橀噺闆�
-    let _vars = ['tbid', 'ErrorCode', 'retmsg', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear', 'UserName', 'FullName']
+    let _vars = ['tbid', 'ErrorCode', 'retmsg', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear', 'UserName', 'FullName', 'ID', 'BID']
 
     // 涓婚敭瀛楁
     let primaryKey = setting.primaryKey || 'id'
@@ -468,8 +467,50 @@
       })
     }
 
+    // 娣诲姞鏁版嵁涓瓧娈碉紝琛ㄥ崟鍊间紭鍏�
+    if (data) {
+      _formFieldValue = {...data, ..._formFieldValue}
+    }
+
+    // 娣诲姞鏃朵富閿负绌�
+    if (btn.sqlType === 'insert') {
+      primaryId = ''
+    }
+
+    // 澹版槑琛ㄥ崟鍙婂垪琛ㄦ暟鎹瓧娈碉紝鍒濆鍖栬祴鍊�
+    let keys = Object.keys(_formFieldValue)
+    let _initfields = []
+    let _initvars = ['ID', 'BID']
+    let _formfields = []
+    keys.forEach(key => {
+      if (!_initvars.includes(key)) {
+        _initvars.push(key)
+        _initfields.push(`@${key}='${_formFieldValue[key]}'`)
+      }
+      
+      if (!_vars.includes(key)) {
+        _vars.push(key)
+        _formfields.push(`@${key} nvarchar(50)`)
+      }
+    })
+
+    _formfields = _formfields.join(',')
+    if (_formfields) {
+      _sql += `,${_formfields}
+        `
+    }
+
+    _initfields = _initfields.join(',')
+    if (_initfields) {
+      _sql += `select ${_initfields}
+        `
+    }
+
     // 鍘婚櫎绂佺敤鐨勯獙璇�
     if (verify) {
+      if (verify.contrasts) {
+        verify.contrasts = verify.contrasts.filter(item => item.status !== 'false')
+      }
       if (verify.uniques) {
         verify.uniques = verify.uniques.filter(item => item.status !== 'false')
       }
@@ -482,28 +523,6 @@
       if (verify.scripts) {
         verify.scripts = verify.scripts.filter(item => item.status !== 'false')
       }
-    }
-
-    // 璁剧疆鏈夎嚜瀹氫箟鑴氭湰鏃讹紝澹版槑鍙橀噺涓坊鍔犳墍鏈夎〃鍗曞瓧娈碉紝骞堕伩鍏嶉噸澶�
-    if (verify && verify.scripts && verify.scripts.length > 0 && formdata && formdata.length > 0) {
-      let _initfields = []
-      let _formfields = formdata.filter(form => {
-        _initfields.push(`@${form.key}='${form.value}'`)
-
-        return !_vars.includes(form.key)
-      })
-
-      _formfields = _formfields.map(form => {
-        _vars.push(form.key)
-        return `@${form.key} nvarchar(50)`
-      })
-      _formfields = _formfields.join(',')
-      _sql += `,${_formfields}
-        `
-      _initfields = _initfields.join(',')
-      _sql += `select ${_initfields}
-        `
-
     }
 
     // 鍒濆鍖栧嚟璇佸瓧娈�
@@ -535,13 +554,20 @@
         `
     }
 
+    // 姣旇緝楠岃瘉
+    if (verify && verify.contrasts && verify.contrasts.length > 0) {
+      verify.contrasts.forEach(item => {
+        _sql += `If ${item.frontfield} ${item.operator} ${item.backfield}
+          Begin
+            select @ErrorCode='${item.errorCode}',@retmsg='${item.errmsg}'
+              goto aaa
+          end
+          `
+      })
+    }
+
     // 鍞竴鎬ч獙璇侊紝蹇呴』瀛樺湪琛ㄥ崟锛堣〃鍗曞瓨鍦ㄦ椂锛屼富閿潎涓哄崟鍊硷級,蹇呴』濉啓鏁版嵁婧�
     if (formdata && verify && verify.uniques.length > 0) {
-      let _primaryId = primaryId
-      if (btn.sqlType === 'insert') {
-        _primaryId = ''
-      }
-
       verify.uniques.forEach(item => {
         let _fieldValue = []                     // 琛ㄥ崟閿�煎field=value
         let _value = []                          // 琛ㄥ崟鍊硷紝鐢ㄤ簬閿欒鎻愮ず
@@ -552,8 +578,13 @@
           _value.push(`${_labels[index] || ''}锛�${_formFieldValue[_field] || ''}`)
         })
 
+        let _verifyType = ''
+        if (item.verifyType === 'logic') {
+          _verifyType = ' and deleted=0'
+        }
+
         _sql += `select @tbid='', @ErrorCode='',@retmsg=''
-          select @tbid='X' from ${btn.sql} where ${_fieldValue.join(' and ')} and ${primaryKey} !='${_primaryId}'
+          select @tbid='X' from ${btn.sql} where ${_fieldValue.join(' and ')} and ${primaryKey} !='${primaryId}'${_verifyType}
           If @tbid!=''
           Begin
             select @ErrorCode='${item.errorCode}',@retmsg='${_value.join(', ')} 宸插瓨鍦�'
@@ -563,35 +594,11 @@
       })
     }
     
-    // 鑷畾涔夐獙璇侊紝浣跨敤鍒楄〃鍙婅〃鍗曟暟鎹紙琛ㄥ崟浼樺厛锛夛紝鏇挎崲鎵�鏈堾鐩稿悓瀛楁銆丂ID銆丂BID
+    // 鑷畾涔夐獙璇�
     if (verify && verify.customverifys.length > 0) {
-      let _primaryId = primaryId
-      if (btn.sqlType === 'insert') {
-        _primaryId = ''
-      }
-
       verify.customverifys.forEach(item => {
-        let _cuSql = item.sql
-        if (data) {
-          _formFieldValue = {...data, ..._formFieldValue}
-        }
-        let keys = Object.keys(_formFieldValue)
-        keys = keys.sort((a, b) => {
-          return b.length - a.length
-        })
-
-        keys.forEach(key => {
-          let reg = new RegExp('@' + key, 'ig')
-          _cuSql = _cuSql.replace(reg, `'${_formFieldValue[key]}'`)
-        })
-        let idreg = new RegExp('@ID', 'ig')
-        _cuSql = _cuSql.replace(idreg, `'${_primaryId}'`)
-
-        let bidreg = new RegExp('@BID', 'ig')
-        _cuSql = _cuSql.replace(bidreg, `'${BID}'`)
-
         _sql += `select @tbid='', @ErrorCode='',@retmsg=''
-          select top 1 @tbid='X' from (${_cuSql}) a
+          select top 1 @tbid='X' from (${item.sql}) a
           If @tbid ${item.result === 'true' ? '!=' : '='}''
           Begin
             select @ErrorCode='${item.errorCode}',@retmsg='${item.errmsg}'

--
Gitblit v1.8.0