From fe21d23b147ed5cec22b4f76a88840b05495d4ad Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 18 六月 2022 22:33:59 +0800
Subject: [PATCH] 2022-06-18

---
 src/templates/zshare/verifycard/index.jsx |  209 ++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 163 insertions(+), 46 deletions(-)

diff --git a/src/templates/zshare/verifycard/index.jsx b/src/templates/zshare/verifycard/index.jsx
index 93e19b9..ba04881 100644
--- a/src/templates/zshare/verifycard/index.jsx
+++ b/src/templates/zshare/verifycard/index.jsx
@@ -2,7 +2,9 @@
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
 import { Form, Tabs, Row, Col, Radio, Button, Select, Popconfirm, notification, Modal, message, InputNumber, Tooltip, Typography } from 'antd'
-import { QuestionCircleOutlined, CheckCircleOutlined, StopOutlined, EditOutlined, SwapOutlined, DeleteOutlined, ExclamationOutlined } from '@ant-design/icons'
+import { QuestionCircleOutlined, CheckCircleOutlined, StopOutlined, EditOutlined, SwapOutlined, DeleteOutlined, ExclamationOutlined, BorderOutlined } from '@ant-design/icons'
+import Toast from 'antd-mobile/es/components/toast'
+import Dialog from 'antd-mobile/es/components/dialog'
 import moment from 'moment'
 
 import Api from '@/api'
@@ -18,6 +20,7 @@
 import asyncComponent from '@/utils/asyncComponent'
 import { updateForm } from '@/utils/utils-update.js'
 import MKEmitter from '@/utils/events.js'
+import MinView from '@/assets/img/minview.png'
 import './index.scss'
 
 const { TabPane } = Tabs
@@ -36,8 +39,11 @@
 
   state = {
     initsql: '',            // sql楠岃瘉鏃跺彉閲忓0鏄庡強璧嬪��
+    appType: sessionStorage.getItem('appType'),
     notes: [],              // 鐭俊妯℃澘
     setting: null,
+    visible: false,
+    scriptId: '',
     verify: {},
     fields: [],
     usefulfields: '',
@@ -233,7 +239,7 @@
 
           return (
             <div>
-              {title ? <span style={{color: '#a50'}}>{title}</span> : null}
+              {title ? <span style={{color: '#a50'}}>{title}<span style={{fontSize: '12px', marginLeft: '5px'}}>{_text.length}</span></span> : null}
               <Paragraph copyable={{ text: text }} ellipsis={{ rows: 4, expandable: true }}>{_text}</Paragraph>
             </div>
           )
@@ -303,7 +309,7 @@
 
           return (
             <div>
-              {title ? <span style={{color: '#a50'}}>{title}</span> : null}
+              {title ? <span style={{color: '#a50'}}>{title}<span style={{fontSize: '12px', marginLeft: '5px'}}>{_text.length}</span></span> : null}
               <Paragraph copyable={{ text: text }} ellipsis={{ rows: 4, expandable: true }}>{_text}</Paragraph>
             </div>
           )
@@ -372,7 +378,7 @@
 
           return (
             <div>
-              {title ? <span style={{color: '#a50'}}>{title}</span> : null}
+              {title ? <span style={{color: '#a50'}}>{title}<span style={{fontSize: '12px', marginLeft: '5px'}}>{_text.length}</span></span> : null}
               <Paragraph copyable={{ text: text }} ellipsis={{ rows: 4, expandable: true }}>{_text}</Paragraph>
             </div>
           )
@@ -470,7 +476,7 @@
           let _type = record.Type
           if (_type && typeof(_type) === 'string') {
             _type = parseInt(_type)
-          } else {
+          } else if (!_type) {
             _type = 4
           }
 
@@ -532,7 +538,7 @@
 
   UNSAFE_componentWillMount() {
     const { columns, config, card, btnTab } = this.props
-    let _verify = card.verify || {}
+    let _verify = fromJS(card.verify || {}).toJS()
 
     let _invalid = _verify.invalid
 
@@ -646,14 +652,20 @@
         resolve(_fields)
       }
     }).then(_fields => {
-      let _usefulfields = ['BID', 'ID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey', 'UserName', 'FullName', 'RoleID', 'mk_departmentcode', 'mk_organization', 'login_city', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear', 'ModularDetailCode']
-      let _declare = ['@UserName nvarchar(50)', '@FullName nvarchar(50)', '@RoleID nvarchar(512)', '@mk_departmentcode nvarchar(50)', '@mk_organization nvarchar(50)', '@login_city nvarchar(50)', '@ErrorCode nvarchar(50)', '@retmsg nvarchar(4000)', '@BillCode nvarchar(50)', '@BVoucher nvarchar(50)', '@FIBVoucherDate nvarchar(50)', '@FiYear nvarchar(50)', '@ModularDetailCode nvarchar(50)']
-      let _select = ['@UserName=\'\'', '@FullName=\'\'', '@RoleID=\'\'', '@mk_departmentcode=\'\'', '@mk_organization=\'\'', '@login_city=\'\'', '@ErrorCode=\'\'', '@retmsg=\'\'', '@BillCode=\'\'', '@BVoucher=\'\'', '@FIBVoucherDate=\'\'', '@FiYear=\'\'', '@ModularDetailCode=\'\'']
+      let _usefulfields = ['UserName', 'FullName', 'RoleID', 'mk_departmentcode', 'mk_organization', 'login_city', 'BillCode', 'BVoucher', 'FIBVoucherDate', 'FiYear', 'ModularDetailCode']
+      let _declare = ['@UserName nvarchar(50)', '@FullName nvarchar(50)', '@RoleID nvarchar(512)', '@mk_departmentcode nvarchar(50)', '@mk_organization nvarchar(50)', '@login_city nvarchar(50)', '@ErrorCode nvarchar(50)', '@retmsg nvarchar(4000)', '@BillCode nvarchar(50)', '@BVoucher nvarchar(50)', '@FIBVoucherDate nvarchar(50)', '@FiYear nvarchar(50)', '@ModularDetailCode nvarchar(50)', '@bid nvarchar(50)']
+      let _select = ['@UserName=\'\'', '@FullName=\'\'', '@RoleID=\'\'', '@mk_departmentcode=\'\'', '@mk_organization=\'\'', '@login_city=\'\'', '@ErrorCode=\'\'', '@retmsg=\'\'', '@BillCode=\'\'', '@BVoucher=\'\'', '@FIBVoucherDate=\'\'', '@FiYear=\'\'', '@ModularDetailCode=\'\'', '@bid=\'\'']
       let fieldArr = _usefulfields.map(_f => _f.toLowerCase())
       let hasBid = false
+      
+      fieldArr.push('bid')
 
       _fields = _fields.filter(_f => _f.field)
       _fields.forEach(_f => {
+        if (_f.field.toLowerCase() === 'bid') {
+          hasBid = true
+        }
+
         if (fieldArr.includes(_f.field.toLowerCase())) return
 
         fieldArr.push(_f.field.toLowerCase())
@@ -674,7 +686,7 @@
 
         if (_f.type.match(/date/ig)) {
           _type = 'datetime'
-          _select.push(`@${_f.field}='1900-01-01'`)
+          _select.push(`@${_f.field}='1949-10-01'`)
         } else if (_f.type === 'number') {
           _type = `decimal(18,${_fieldlen})`
           _select.push(`@${_f.field}=0`)
@@ -686,10 +698,6 @@
         }
 
         _declare.push(`@${_f.field} ${_type}`)
-
-        if (_f.field.toLowerCase() === 'bid') {
-          hasBid = true
-        }
       })
 
       let uniqueFields = fromJS(_fields).toJS()
@@ -697,9 +705,6 @@
       if (!hasBid) { // 鍞竴鎬ч獙璇佹坊鍔燘ID
         uniqueFields.unshift({ uuid: 'BID', field: 'BID', label: 'BID', type: 'text' })
         _fields.unshift({ uuid: 'BID', field: 'BID', label: 'BID', type: 'text' })
-        fieldArr.push('bid')
-        _declare.push(`@bid nvarchar(50)`)
-        _select.push(`@bid=''`)
       }
 
       let hasColumn = false
@@ -924,7 +929,7 @@
         columnsFields: _columns,
         initsql: _sql,
         defaultsql: _defaultsql,
-        usefulfields: _usefulfields.join(', '),
+        usefulfields: ['BID', 'ID', 'LoginUID', 'SessionUid', 'UserID', 'Appkey', ..._usefulfields].join(', '),
         uniqueColumns: this.state.uniqueColumns.map(col => {
           if (col.dataIndex === 'field') {
             col.options = uniqueFields
@@ -1271,35 +1276,66 @@
   }
 
   showError = (errorType) => {
+    const { verify, appType } = this.state
+
     if (errorType === 'S') {
-      notification.success({
-        top: 92,
-        message: '鎵ц鎴愬姛锛�',
-        duration: 2
-      })
+      let time = verify.stime || 2
+      if (appType === 'mob') {
+        Toast.show({ icon: 'success', content: '鎵ц鎴愬姛锛�', duration: time * 1000 })
+      } else {
+        notification.success({
+          top: 92,
+          message: '鎵ц鎴愬姛锛�',
+          duration: time
+        })
+      }
+      
     } else if (errorType === 'Y') {
-      Modal.success({
-        title: '鎵ц鎴愬姛锛�'
-      })
+      if (appType === 'mob') {
+        Dialog.alert({content: '鎵ц鎴愬姛锛�', confirmText: '鐭ラ亾浜�'})
+      } else {
+        Modal.success({
+          title: '鎵ц鎴愬姛锛�'
+        })
+      }
     } else if (errorType === 'F') {
-      notification.error({
-        className: 'notification-custom-error',
-        top: 92,
-        message: '鎵ц澶辫触锛�',
-        duration: 10
-      })
+      if (appType === 'mob') {
+        let time = verify.ftime || 3
+        Toast.show({ icon: 'fail', content: '鎵ц澶辫触锛�', duration: time * 1000 })
+      } else {
+        notification.error({
+          className: 'notification-custom-error',
+          top: 92,
+          message: '鎵ц澶辫触锛�',
+          duration: verify.ftime || 10
+        })
+      }
     } else if (errorType === 'N') {
-      notification.error({
-        top: 92,
-        message: '鎵ц澶辫触锛�',
-        duration: 10
-      })
+      if (appType === 'mob') {
+        let time = verify.ntime || 3
+        Toast.show({ content: '鎵ц澶辫触锛�', duration: time * 1000 })
+      } else {
+        notification.error({
+          top: 92,
+          message: '鎵ц澶辫触锛�',
+          duration: verify.ntime || 10
+        })
+      }
     } else if (errorType === 'E') {
-      Modal.error({
-        title: '鎵ц澶辫触锛�'
-      })
+      if (appType === 'mob') {
+        Dialog.alert({content: '鎵ц澶辫触锛�', confirmText: '鐭ラ亾浜�'})
+      } else {
+        Modal.error({
+          title: '鎵ц澶辫触锛�'
+        })
+      }
     } else if (errorType === 'NM') {
-      message.error('鎵ц澶辫触锛�')
+      if (appType === 'mob') {
+        let time = verify.ntime || 3
+        Toast.show({ content: '鎵ц澶辫触锛�', duration: time * 1000 })
+      } else {
+        message.error('鎵ц澶辫触锛�')
+      }
     }
   }
 
@@ -1452,7 +1488,7 @@
 
   render() {
     const { card } = this.props
-    const { verify, fields, uniqueFields, uniqueColumns, unionFields, onceUniqueColumns, columnsFields, contrastColumns, customColumns, orderColumns, scriptsColumns, cbScriptsColumns, orderModular, orderModularDetail, voucher, voucherDetail, notes } = this.state
+    const { verify, fields, visible, uniqueFields, uniqueColumns, unionFields, onceUniqueColumns, columnsFields, contrastColumns, customColumns, orderColumns, scriptsColumns, cbScriptsColumns, orderModular, orderModularDetail, voucher, voucherDetail, notes, appType } = this.state
     const formItemLayout = {
       labelCol: {
         xs: { span: 24 },
@@ -1586,7 +1622,7 @@
             </span>
           } key="2x">
             <ContrastForm dict={this.props.dict} contrastChange={this.contrastChange}/>
-            <EditTable actions={['edit', 'move', 'copy', 'del']} type="contrastverify" data={verify.contrasts} columns={contrastColumns} onChange={(contrasts) => this.setState({verify: {...verify, contrasts}})}/>
+            <EditTable actions={['edit', 'move', 'copy', 'del', 'status']} type="contrastverify" data={verify.contrasts} columns={contrastColumns} onChange={(contrasts) => this.setState({verify: {...verify, contrasts}})}/>
           </TabPane> : null}
           {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab={
             <span>
@@ -1635,7 +1671,7 @@
               dict={this.props.dict}
               uniqueChange={this.uniqueChange}
             />
-            <EditTable actions={['edit', 'move', 'del']} data={verify.uniques} columns={card.Ot !== 'requiredOnce' ? uniqueColumns : onceUniqueColumns} onChange={this.changeUniques}/>
+            <EditTable actions={['edit', 'move', 'del', 'status']} data={verify.uniques} columns={card.Ot !== 'requiredOnce' ? uniqueColumns : onceUniqueColumns} onChange={this.changeUniques}/>
           </TabPane> : null}
           {card.intertype === 'system' || (card.intertype === 'custom' && card.procMode === 'system') ? <TabPane tab={
             <span>
@@ -1659,6 +1695,17 @@
               {verify.scripts.length ? <span className="count-tip">{verify.scripts.length}</span> : null}
             </span>
           } key="6">
+            <BorderOutlined className="full-scripts" onClick={() => {
+              if (this.scriptsForm && (this.scriptsForm.state.editItem || (this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))))) {
+                notification.warning({
+                  top: 92,
+                  message: '璇蜂繚瀛樿嚜瀹氫箟鑴氭湰锛�',
+                  duration: 5
+                })
+                return
+              }
+              this.setState({visible: true, scriptId: ''})
+            }}/>
             <CustomScript
               btn={this.props.card}
               dict={this.props.dict}
@@ -1728,7 +1775,7 @@
                 </Col>
                 <Col span={8}>
                   <Form.Item label={'鍋滅暀鏃堕棿'}>
-                    <InputNumber defaultValue={verify.ntime || 10} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'ntime')}} />
+                    <InputNumber defaultValue={verify.ntime || (appType === 'mob' ? 3 : 10)} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'ntime')}} />
                   </Form.Item>
                 </Col>
               </Row>
@@ -1743,7 +1790,7 @@
                 </Col>
                 <Col span={8}>
                   <Form.Item label={'鍋滅暀鏃堕棿'}>
-                    <InputNumber defaultValue={verify.ftime || 10} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'ftime')}} />
+                    <InputNumber defaultValue={verify.ftime || (appType === 'mob' ? 3 : 10)} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'ftime')}} />
                   </Form.Item>
                 </Col>
               </Row>
@@ -1778,6 +1825,76 @@
             </Form>
           </TabPane>
         </Tabs>
+        <Modal
+          wrapClassName="model-custom-scripts-modal"
+          title="鑷畾涔夎剼鏈�"
+          visible={visible}
+          width={'95vw'}
+          maskClosable={false}
+          destroyOnClose
+        >
+          <img className="unfull-scripts" src={MinView} onClick={() => this.setState({visible: false, scriptId: ''})} alt=""/>
+          <div className="script-table-wrap">
+            {verify.scripts.map(item => {
+              let title = item.sql.match(/^\s*\/\*.+\*\//)
+              title = title && title[0] ? title[0] : ''
+              let _text = title ? item.sql.replace(title, '') : item.sql
+
+              let position = null
+              if (item.position === 'init') {
+                position = <span style={{color: 'orange'}}>鍒濆鍖�</span>
+              } else if (item.position === 'front') {
+                position = <span style={{color: '#26C281'}}>sql鍓�</span>
+              } else {
+                position = <span style={{color: '#1890ff'}}>sql鍚�</span>
+              }
+
+              return (
+                <div className={'script-item ' + (this.state.scriptId === item.uuid ? 'active' : '') } key={item.uuid}>
+                  <div style={{cursor: 'pointer'}} onClick={() => {
+                    this.scriptsFullForm.edit(item)
+                    this.setState({scriptId: item.uuid})
+                  }}>
+                    {title ? <div style={{color: '#a50', whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis'}}>{title}</div> : null}
+                    <Paragraph copyable={{ text: item.sql }} ellipsis={{ rows: 4 }}>{_text}</Paragraph>
+                    <div>{position}{item.status === 'false' ?
+                      <span style={{color: '#ff4d4f', marginLeft: '20px'}}>
+                        绂佺敤
+                        <StopOutlined style={{marginLeft: '5px'}} />
+                      </span> : 
+                      <span style={{color: '#26C281', marginLeft: '20px'}}>
+                        鍚敤
+                        <CheckCircleOutlined style={{marginLeft: '5px'}}/>
+                      </span>}
+                    </div>
+                  </div>
+                  <div style={{textAlign: 'right'}}>
+                    <span className="operation-btn" onClick={() => this.handleStatus(item, 'scripts')} style={{color: '#8E44AD'}}><SwapOutlined /></span>
+                    <Popconfirm
+                      overlayClassName="popover-confirm"
+                      title={this.props.dict['model.query.delete']}
+                      onConfirm={() => this.handleDelete(item, 'scripts')
+                    }>
+                      <span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span>
+                    </Popconfirm>
+                  </div>
+                </div>
+              )
+            })}
+          </div>
+          <CustomScript
+            type="fullscreen"
+            btn={this.props.card}
+            dict={this.props.dict}
+            initsql={this.state.initsql}
+            customScripts={verify.scripts}
+            defaultsql={this.state.defaultsql}
+            usefulfields={this.state.usefulfields}
+            systemScripts={this.state.systemScripts}
+            scriptsChange={this.scriptsChange}
+            wrappedComponentRef={(inst) => this.scriptsFullForm = inst}
+          />
+        </Modal>
       </div>
     )
   }

--
Gitblit v1.8.0