From 0f6c07ed2f8dddd3ad6e37268bf06df6d82961ed Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 24 五月 2024 17:57:30 +0800
Subject: [PATCH] 2024-05-24

---
 src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx |  763 ++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 505 insertions(+), 258 deletions(-)

diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx
index 1fef86d..be7041f 100644
--- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx
+++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/index.jsx
@@ -1,8 +1,8 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { fromJS } from 'immutable'
-import { Form, Tabs, Row, Col, Input, Button, Table, Popconfirm, Icon, Tooltip, notification, Modal, message, InputNumber, Radio, Typography } from 'antd'
-import { QuestionCircleOutlined } from '@ant-design/icons'
+import { Form, Tabs, Row, Col, Input, Button, Popconfirm, Tooltip, notification, Modal, message, InputNumber, Radio, Typography } from 'antd'
+import { EditOutlined, QuestionCircleOutlined, StopOutlined, CheckCircleOutlined, SwapOutlined, DeleteOutlined } from '@ant-design/icons'
 import moment from 'moment'
 
 import Api from '@/api'
@@ -12,17 +12,21 @@
 import ColumnForm from './columnform'
 import CustomScript from './customscript'
 import asyncComponent from '@/utils/asyncComponent'
+import MKEmitter from '@/utils/events.js'
 import './index.scss'
 
 const { TabPane } = Tabs
 const { confirm } = Modal
+const { Search } = Input
 const { Paragraph } = Typography
+
 const EditTable = asyncComponent(() => import('@/templates/zshare/editTable'))
+const CodeMirror = asyncComponent(() => import('@/templates/zshare/codemirror'))
+const FullScripts = asyncComponent(() => import('@/templates/zshare/verifycard/fullScripts'))
 
 class VerifyCard extends Component {
   static propTpyes = {
     columns: PropTypes.array,  // 鏄剧ず鍒�
-    dict: PropTypes.object,    // 瀛楀吀椤�
     card: PropTypes.object,
   }
 
@@ -30,28 +34,34 @@
     verify: {},
     systemScripts: [],
     activeKey: 'basemsg',
+    searchKey: '',
     excelColumns: [
       {
-        title: this.props.dict['model.form.field'],
+        title: '瀛楁',
         dataIndex: 'Column',
         width: '14%',
         inputType: 'input',
         unique: true,
+        strict: true,
+        searchable: true,
+        copy: true,
         editable: true
       },
       {
-        title: this.props.dict['model.name'],
+        title: '鍚嶇О',
         dataIndex: 'Text',
         width: '14%',
         inputType: 'input',
+        searchable: true,
         editable: true
       },
       {
-        title: this.props.dict['model.form.type'],
+        title: '绫诲瀷',
         dataIndex: 'type',
         width: '15%',
         editable: true,
         inputType: 'select',
+        keyCol: true,
         options: [
           { value: 'Nvarchar(10)', text: 'Nvarchar(10)' },
           { value: 'Nvarchar(20)', text: 'Nvarchar(20)' },
@@ -61,30 +71,44 @@
           { value: 'Nvarchar(512)', text: 'Nvarchar(512)' },
           { value: 'Nvarchar(1024)', text: 'Nvarchar(1024)' },
           { value: 'Nvarchar(2048)', text: 'Nvarchar(2048)' },
+          { value: 'Nvarchar(4000)', text: 'Nvarchar(4000)' },
           { value: 'Nvarchar(max)', text: 'Nvarchar(max)' },
           { value: 'Int', text: 'Int' },
           { value: 'Decimal(18,0)', text: 'Decimal(18,0)' },
           { value: 'Decimal(18,2)', text: 'Decimal(18,2)' },
           { value: 'Decimal(18,4)', text: 'Decimal(18,4)' },
           { value: 'Decimal(18,6)', text: 'Decimal(18,6)' },
-          { value: 'date', text: 'date' }
+          { value: 'date', text: 'date' },
+          { value: 'datetime', text: 'datetime' }
         ]
       },
       {
-        title: this.props.dict['model.required'],
+        title: '瀵煎叆',
+        dataIndex: 'import',
+        width: '10%',
+        editable: true,
+        inputType: 'radio',
+        render: (text, record) => {
+          if (record.import === 'init') {
+            return '鍒濆鍖�'
+          } else if (record.import === 'false') {
+            return '鍚�'
+          }
+          return '鏄�'
+        },
+        options: [
+          { value: 'true', text: '鏄�' },
+          { value: 'false', text: '鍚�' },
+          { value: 'init', text: '鍒濆鍖�' }
+        ]
+      },
+      {
+        title: '蹇呭~',
         dataIndex: 'required',
         width: '10%',
         editable: true,
         inputType: 'switch',
-        render: (text, record) => record.required === 'true' ? this.props.dict['model.true'] : this.props.dict['model.false']
-      },
-      {
-        title: this.props.dict['model.import'],
-        dataIndex: 'import',
-        width: '10%',
-        editable: true,
-        inputType: 'switch',
-        render: (text, record) => record.import !== 'false' ? this.props.dict['model.true'] : this.props.dict['model.false']
+        render: (text, record) => record.required === 'true' ? '鏄�' : '鍚�'
       },
       {
         title: '鏈�灏忓��',
@@ -93,7 +117,10 @@
         required: false,
         inputType: 'number',
         unlimit: true,
-        editable: true
+        editable: true,
+        keyVals: ['Int', 'Decimal(18,0)', 'Decimal(18,2)', 'Decimal(18,4)', 'Decimal(18,6)'],
+        render: (text, record) => /^Decimal/ig.test(record.type) || /^int/ig.test(record.type) ? text : ''
+        
       },
       {
         title: '鏈�澶у��',
@@ -102,7 +129,9 @@
         required: false,
         inputType: 'number',
         unlimit: true,
-        editable: true
+        editable: true,
+        keyVals: ['Int', 'Decimal(18,0)', 'Decimal(18,2)', 'Decimal(18,4)', 'Decimal(18,6)'],
+        render: (text, record) => /^Decimal/ig.test(record.type) || /^int/ig.test(record.type) ? text : ''
       }
     ],
     uniqueColumns: [
@@ -122,7 +151,7 @@
       {
         title: '鎶ラ敊缂栫爜',
         dataIndex: 'errorCode',
-        width: '12%',
+        width: '10%',
         editable: true,
         inputType: 'select',
         options: [
@@ -135,13 +164,24 @@
       {
         title: '楠岃瘉绫诲瀷',
         dataIndex: 'verifyType',
-        width: '12%',
-        render: (text, record) => record.verifyType === 'logic' ? '閫昏緫楠岃瘉' : '鐗╃悊楠岃瘉',
+        width: '14%',
+        render: (text, record) => {
+          let names = {
+            physical: '鐗╃悊楠岃瘉锛堝叏閲忛獙璇侊級',
+            logic: '閫昏緫楠岃瘉锛堝叏閲忛獙璇侊級',
+            physical_temp: '鐗╃悊楠岃瘉锛堜粎涓存椂琛級',
+            logic_temp: '閫昏緫楠岃瘉锛堜粎涓存椂琛級',
+          }
+
+          return names[text] || '鐗╃悊楠岃瘉锛堝叏閲忛獙璇侊級'
+        },
         inputType: 'select',
         editable: true,
         options: [
-          { value: 'physical', text: '鐗╃悊楠岃瘉' },
-          { value: 'logic', text: '閫昏緫楠岃瘉' }
+          { value: 'physical', text: '鐗╃悊楠岃瘉锛堝叏閲忛獙璇侊級' },
+          { value: 'logic', text: '閫昏緫楠岃瘉锛堝叏閲忛獙璇侊級' },
+          { value: 'physical_temp', text: '鐗╃悊楠岃瘉锛堜粎涓存椂琛級' },
+          { value: 'logic_temp', text: '閫昏緫楠岃瘉锛堜粎涓存椂琛級' }
         ]
       },
       {
@@ -153,18 +193,101 @@
         inputType: 'switch',
         render: (text, record) => record.status === 'false' ?
           (
-            <div>
-              {this.props.dict['model.status.forbidden']}
-              <Icon style={{marginLeft: '5px'}} type="stop" theme="twoTone" twoToneColor="#ff4d4f" />
+            <div style={{color: '#ff4d4f'}}>
+              绂佺敤
+              <StopOutlined style={{marginLeft: '5px'}} />
             </div>
           ) :
           (
-            <div>
-              {this.props.dict['model.status.open']}
-              <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" />
+            <div style={{color: '#26C281'}}>
+              鍚敤
+              <CheckCircleOutlined style={{marginLeft: '5px'}}/>
             </div>
           )
       },
+      {
+        dataIndex: 'sqlRender',
+        render: (record) => {
+          let columns = this.state.verify.columns
+
+          let textFields = []
+          let numberFields = []
+          let dateFields = []
+          columns.forEach((col) => {
+            if (/Nvarchar/ig.test(col.type)) {
+              textFields.push(col.Column)
+            } else if (/Decimal|int/ig.test(col.type)) {
+              numberFields.push(col.Column)
+            } else if (/date/ig.test(col.type)) {
+              dateFields.push(col.Column)
+            }
+          })
+
+          let _fields = record.field.split(',')
+          let _fields_ = _fields.map(_field => `a.${_field}=b.${_field}`)
+          _fields_ = _fields_.join(' and ')
+
+          let _where = []
+          _fields.forEach(f => {
+            if (textFields.includes(f)) {
+              _where.push(`${f}!=''`)
+            } else if (numberFields.includes(f)) {
+              _where.push(`${f}!=0`)
+            } else if (dateFields.includes(f)) {
+              _where.push(`${f}>'1949-10-01'`)
+            }
+          })
+          _where = _where.length ? `where ${_where.join(' and ')} ` : ''
+
+          if (record.verifyType === 'logic' || record.verifyType === 'logic_temp') {
+            _fields_ += ' and b.deleted=0'
+          }
+
+          let _afields = []
+          _fields = _fields.map(f => {
+            if (numberFields.includes(f)) {
+              _afields.push(`cast(a.${f} as nvarchar(50))`)
+              return `cast(${f} as nvarchar(50))`
+            } else if (dateFields.includes(f)) {
+              _afields.push(`CONVERT(nvarchar(50), a.${f}, 21)`)
+              return `CONVERT(nvarchar(50), ${f}, 21)`
+            }
+            _afields.push(`a.${f}`)
+
+            return f
+          })
+
+          let _sheet = this.props.card.sheet
+
+          let database = _sheet.match(/(.*)\.(.*)\.|@db@/ig) || ''
+          let sheet = _sheet.replace(/(.*)\.(.*)\.|@db@/ig, '')
+          
+          database = database ? (database[0] || '') : ''
+
+          let sql = `
+          /* 閲嶅鎬ч獙璇� */
+          Set @tbid=''
+          Select top 1 @tbid=${_fields.join('+\' \'+')} from (select 1 as n,${record.field} from #${sheet} ${_where}) a group by ${record.field} having sum(n)>1
+          
+          If @tbid!=''
+          Begin
+            select @ErrorCode='${record.errorCode}',@retmsg=@tbid+' 閲嶅'
+            goto aaa
+          end
+          
+          ${record.verifyType.indexOf('temp') === -1 ? `Set @tbid=''
+          Select top 1 @tbid=${_afields.join('+\' \'+')} from ${_where ? `(select * from #${sheet} ${_where})` : `#${sheet}`} a Inner join ${database}${sheet} b on ${_fields_}
+          
+          If @tbid!=''
+          Begin
+            select @ErrorCode='${record.errorCode}',@retmsg=@tbid+' 涓庡凡鏈夋暟鎹噸澶�'
+            goto aaa
+          end` : ''}
+          `
+          
+          return sql.split(/\n\s{10}/ig).map(n => n.replace(/^\s{2}/ig, '&nbsp;&nbsp;'))
+        }
+      }
     ],
     scriptsColumns: [
       {
@@ -174,12 +297,12 @@
         render: (text) => {
           let title = text.match(/^\s*\/\*.+\*\//)
           title = title && title[0] ? title[0] : ''
-          text = title ? text.replace(title, '') : text
+          let _text = title ? text.replace(title, '') : text
 
           return (
             <div>
-              {title ? <span style={{color: '#a50'}}>{title}</span> : null}
-              <Paragraph copyable ellipsis={{ rows: 4, expandable: true }}>{text}</Paragraph>
+              {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>
           )
         }
@@ -189,15 +312,13 @@
         dataIndex: 'position',
         width: '10%',
         render: (text, record) => {
-          let _text = ''
-          if (record.position === 'front') {
-            _text = 'sql鍓�'
-          } else if (record.position === 'init') {
-            _text = '鍒濆鍖�'
+          if (record.position === 'init') {
+            return <span style={{color: 'orange'}}>鍒濆鍖�</span>
+          } else if (record.position === 'front') {
+            return <span style={{color: '#26C281'}}>sql鍓�</span>
           } else {
-            _text = 'sql鍚�'
+            return <span style={{color: '#1890ff'}}>sql鍚�</span>
           }
-          return _text
         }
       },
       {
@@ -206,35 +327,33 @@
         width: '10%',
         render: (text, record) => record.status === 'false' ?
           (
-            <div>
-              {this.props.dict['model.status.forbidden']}
-              <Icon style={{marginLeft: '5px'}} type="stop" theme="twoTone" twoToneColor="#ff4d4f" />
+            <div style={{color: '#ff4d4f'}}>
+              绂佺敤
+              <StopOutlined style={{marginLeft: '5px'}} />
             </div>
           ) :
           (
-            <div>
-              {this.props.dict['model.status.open']}
-              <Icon style={{marginLeft: '5px'}} type="check-circle" theme="twoTone" twoToneColor="#52c41a" />
+            <div style={{color: '#26C281'}}>
+              鍚敤
+              <CheckCircleOutlined style={{marginLeft: '5px'}}/>
             </div>
           )
       },
       {
         title: '鎿嶄綔',
         align: 'center',
-        width: '20%',
+        width: '140px',
         dataIndex: 'operation',
         render: (text, record) =>
-          (<div>
-            <span className="operation-btn" title={this.props.dict['model.edit']} onClick={() => this.handleEdit(record, 'scripts')} style={{color: '#1890ff'}}><Icon type="edit" /></span>
-            <span className="operation-btn" title={this.props.dict['header.form.up']} onClick={() => this.handleUpDown(record, 'scripts', 'up')} style={{color: '#1890ff'}}><Icon type="arrow-up" /></span>
-            <span className="operation-btn" title={this.props.dict['header.form.down']} onClick={() => this.handleUpDown(record, 'scripts', '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, 'scripts')} style={{color: '#8E44AD'}}><Icon type="swap" /></span>
+          (<div style={{textAlign: 'center'}}>
+            <span className="operation-btn" title="缂栬緫" onClick={() => this.handleEdit(record, 'scripts')} style={{color: '#1890ff'}}><EditOutlined /></span>
+            <span className="operation-btn" title="鐘舵�佸垏鎹�" onClick={() => this.handleStatus(record, 'scripts')} style={{color: '#8E44AD'}}><SwapOutlined /></span>
             <Popconfirm
               overlayClassName="popover-confirm"
-              title={this.props.dict['model.query.delete']}
+              title="纭畾鍒犻櫎鍚�?"
               onConfirm={() => this.handleDelete(record, 'scripts')
             }>
-              <span className="operation-btn" style={{color: '#ff4d4f'}}><Icon type="delete" /></span>
+              <span className="operation-btn" style={{color: '#ff4d4f'}}><DeleteOutlined /></span>
             </Popconfirm>
           </div>)
       }
@@ -243,13 +362,20 @@
 
   UNSAFE_componentWillMount() {
     const { card } = this.props
-    let _verify = fromJS(card.verify || {range: 1}).toJS()
+    let _verify = fromJS(card.verify || {}).toJS()
     let _columns = _verify.columns || []
 
     // 鏃ф暟鎹吋瀹�
     _columns = _columns.map(col => {
       col.required = col.required || 'true'
       col.type = col.type || 'Nvarchar(50)'
+      col.import = col.import || 'true'
+
+      if (col.type === 'text' || col.type === 'image') {
+        col.type = 'Nvarchar(50)'
+      } else if (col.type === 'number') {
+        col.type = 'Decimal(18,2)'
+      }
       
       if (/^Nvarchar/ig.test(col.type)) {
         col.limit = col.type.match(/\d+/)[0]
@@ -262,47 +388,77 @@
       return col
     })
 
+    if (!_verify.hasOwnProperty('range')) {
+      _verify.range = 1
+    }
+
+    _verify.excelHandle = _verify.excelHandle || 'false'
+    _verify.default = _verify.default || 'true'
+    _verify.sheet = _verify.sheet || 'Sheet1'
+    _verify.range = _verify.range || 0
+    _verify.columns = _columns
+    _verify.scripts = _verify.scripts || []
+    _verify.uniques = _verify.uniques || []
+
+    if (window.GLOB.process && card.intertype === 'system') {
+      _verify.workFlow = _verify.workFlow || 'false'
+      _verify.flowType = 'start'
+      _verify.flowSql = _verify.flowSql || 'true'
+    } else {
+      delete _verify.workFlow
+      delete _verify.flowType
+      delete _verify.flowSql
+    }
+
     this.setState({
-      verify: {
-        ..._verify,
-        default: _verify.default || 'true',
-        sheet: _verify.sheet || 'Sheet1',
-        range: _verify.range || 0,
-        columns: _columns,
-        scripts: _verify.scripts || [],
-        uniques: _verify.uniques || []
-      }
+      searchKey: '',
+      verify: _verify
     }, () => {
       this.resetUniqueColumns()
     })
   }
 
   componentDidMount () {
+    this.getsysScript()
+  }
+
+  getsysScript = () => {
+    if (sessionStorage.getItem('mk_sys_scripts')) {
+      this.setState({
+        systemScripts: JSON.parse(sessionStorage.getItem('mk_sys_scripts'))
+      })
+      return
+    }
+    
     let _scriptSql = `Select distinct func+Remark as funcname,longparam, s.Sort from聽 s_custom_script s inner join (select OpenID from sapp where ID=@Appkey@) p on s.openid = case when s.appkey='' then s.openid else p.OpenID end order by s.Sort`
 
-    _scriptSql = Utils.formatOptions(_scriptSql)
+    _scriptSql = Utils.formatOptions(_scriptSql, 'x')
 
     let _sParam = {
       func: 'sPC_Get_SelectedList',
       LText: _scriptSql,
       obj_name: 'data',
-      arr_field: 'funcname,longparam'
+      arr_field: 'funcname,longparam',
+      exec_type: 'x'
     }
     
     _sParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-    _sParam.secretkey = Utils.encrypt(_sParam.LText, _sParam.timestamp)
-
+    _sParam.secretkey = Utils.encrypt('', _sParam.timestamp)
     _sParam.open_key = Utils.encryptOpenKey(_sParam.secretkey, _sParam.timestamp) // 浜戠鏁版嵁楠岃瘉
     
-    Api.getSystemConfig(_sParam).then(res => {
+    Api.getCloudConfig(_sParam).then(res => {
       if (res.status) {
+        let _scripts = res.data.map(item => {
+          return {
+            name: item.funcname,
+            value: window.decodeURIComponent(window.atob(item.longparam))
+          }
+        })
+
+        sessionStorage.setItem('mk_sys_scripts', JSON.stringify(_scripts))
+
         this.setState({
-          systemScripts: res.data.map(item => {
-            return {
-              name: item.funcname,
-              value: window.decodeURIComponent(window.atob(item.longparam))
-            }
-          })
+          systemScripts: _scripts
         })
       } else {
         notification.warning({
@@ -340,48 +496,102 @@
     const { verify } = this.state
 
     let _columns = JSON.parse(JSON.stringify(verify.columns))
+    let _names = {}
+    let _cols = _columns.map(item => {
+      let key = item.Column.toLowerCase()
+      _names[key] = item.Text
 
-    let _cols = _columns.map(col => col.Column )
+      return key
+    })
+    let names = {$up: false}
 
     columns.forEach(col => {
-      if (col.field && !_cols.includes(col.field)) {
-        let _type = 'Nvarchar(50)'
-        let _limit = '50'
-        if (col.type === 'number' && !col.decimal) {
-          _type = 'Int'
-          _limit = ''
-        } else if (col.type === 'number') {
-          _type = 'Decimal(18,' + col.decimal + ')'
-          _limit = col.decimal
+      if (!col.field) return
+      let key = col.field.toLowerCase()
+      if (_cols.includes(key)) {
+        if (_names[key] !== col.label) {
+          names.$up = true
+          names[key] = col.label
         }
-
-        let _cell = {
-          uuid: col.uuid,
-          Column: col.field,
-          Text: col.label,
-          type: _type,
-          limit: _limit,
-          import: 'true',
-          required: 'true'
-        }
-
-        if (_type !== 'Nvarchar(50)') {
-          _cell.min = 0
-          _cell.max = 999999
-        }
-
-        _columns.push(_cell)
+        return
       }
+
+      let _type = 'Nvarchar(50)'
+      let _limit = '50'
+      if (col.type === 'number' && !col.decimal) {
+        _type = 'Int'
+        _limit = ''
+      } else if (col.type === 'number') {
+        _type = 'Decimal(18,' + col.decimal + ')'
+        _limit = col.decimal
+      }
+
+      let _cell = {
+        uuid: col.uuid,
+        Column: col.field,
+        Text: col.label,
+        type: _type,
+        limit: _limit,
+        import: 'true',
+        required: 'true'
+      }
+
+      if (_type !== 'Nvarchar(50)') {
+        _cell.min = 0
+        _cell.max = 999999
+      }
+
+      _columns.push(_cell)
     })
 
-    this.setState({
-      verify: {
-        ...verify,
-        columns: _columns
-      }
-    }, () => {
-      this.resetUniqueColumns()
-    })
+    if (names.$up) {
+      const that = this
+
+      confirm({
+        content: '閮ㄥ垎瀛楁鍚嶇О涓庢樉绀哄垪涓嶄竴鑷达紝鏄惁鏇存柊锛�',
+        okText: '鏇存柊',
+        cancelText: '涓嶆洿鏂�',
+        onOk() {
+          _columns = _columns.map(item => {
+            let key = item.Column.toLowerCase()
+
+            if (names[key]) {
+              item.Text = names[key]
+            }
+
+            return item
+          })
+
+          that.setState({
+            verify: {
+              ...verify,
+              columns: _columns
+            }
+          }, () => {
+            that.resetUniqueColumns()
+          })
+        },
+        onCancel() {
+          that.setState({
+            verify: {
+              ...verify,
+              columns: _columns
+            }
+          }, () => {
+            that.resetUniqueColumns()
+          })
+        }
+      })
+    } else {
+      this.setState({
+        verify: {
+          ...verify,
+          columns: _columns
+        }
+      }, () => {
+        this.resetUniqueColumns()
+      })
+    }
   }
 
   clearField = () => {
@@ -404,7 +614,7 @@
     })
   }
 
-  columnChange = (values) => {
+  columnChange = (values, callback) => {
     let verify = JSON.parse(JSON.stringify(this.state.verify))
 
     let fields = verify.columns.map(item => item.Column)
@@ -415,6 +625,8 @@
         duration: 5
       })
       return
+    } else {
+      callback()
     }
 
     values.uuid = Utils.getuuid()
@@ -430,33 +642,32 @@
   changeColumns = (columns) => {
     const { verify } = this.state
 
-    if (columns[0] && (columns[0].type === 'image' || columns[0].type === 'text')) {
-      columns = columns.map(col => {
-        let _cell = {
-          uuid: Utils.getuuid(),
-          Column: col.Column,
-          Text: col.Text,
-          type: 'Nvarchar(50)',
-          limit: '50',
-          import: 'true',
-          required: 'true'
-        }
-
-        return _cell
-      })
-    }
-
     columns = columns.map(col => {
+      col.type = col.type || 'Nvarchar(50)'
+      if (col.type === 'text' || col.type === 'image') {
+        col.type = 'Nvarchar(50)'
+      } else if (col.type === 'number') {
+        col.type = 'Decimal(18,2)'
+      }
+
+      if (col.import === 'init') {
+        col.required = 'false'
+        col.min = ''
+        col.max = ''
+      }
+
       if (/^Nvarchar/ig.test(col.type)) {
         col.limit = col.type.match(/\d+/) ? col.type.match(/\d+/)[0] : '20000'
       } else if (/^Decimal/ig.test(col.type)) {
         col.limit = col.type.match(/\d+/ig)[1]
-        col.required = 'true'
       } else if (/^int/ig.test(col.type)) {
-        col.required = 'true'
+
       } else {
         col.limit = ''
       }
+
+      col.required = col.required || 'true'
+      col.import = col.import || 'true'
 
       return col
     })
@@ -520,6 +731,8 @@
       verify.scripts.push(values)
     }
 
+    MKEmitter.emit('editLineId', values.uuid)
+
     this.setState({
       verify: verify
     })
@@ -540,11 +753,12 @@
   }
 
   handleEdit = (record, type) => {
+    let node = null
+
     if (type === 'scripts') {
       this.scriptsForm.edit(record)
+      node = document.getElementById('mk-exin-script')
     }
-
-    let node = document.getElementById('verify-excel-box-tab').parentNode
 
     if (node && node.scrollTop) {
       let inter = Math.ceil(node.scrollTop / 10)
@@ -587,68 +801,6 @@
     })
   }
 
-  handleUpDown = (record, type, direction) => {
-    let verify = JSON.parse(JSON.stringify(this.state.verify))
-    let index = 0
-
-    if (type === 'columns') {
-      verify.columns = verify.columns.filter((item, i) => {
-        if (item.uuid === record.uuid) {
-          index = i
-        }
-
-        return item.uuid !== record.uuid
-      })
-      if ((index === 0 && direction === 'up') || (index === verify.columns.length && direction === 'down')) {
-        return
-      }
-
-      if (direction === 'up') {
-        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) => {
-        if (item.uuid === record.uuid) {
-          index = i
-        }
-
-        return item.uuid !== record.uuid
-      })
-      if ((index === 0 && direction === 'up') || (index === verify.scripts.length && direction === 'down')) {
-        return
-      }
-
-      if (direction === 'up') {
-        verify.scripts.splice(index - 1, 0, record)
-      } else {
-        verify.scripts.splice(index + 1, 0, record)
-      }
-    }
-
-    this.setState({
-      verify: verify
-    })
-  }
-
   handleConfirm = () => {
     const { verify } = this.state
     // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭�
@@ -657,34 +809,54 @@
         if (!err) {
           let _verify = {...verify, ...values}
 
-          let cols = _verify.columns.map(col => col.Column)
+          if (_verify.excelHandle !== 'true') { 
+            delete _verify.excel_func
+          }
+          if (_verify.default === 'false' && _verify.scripts.length === 0) {
+            notification.warning({
+              top: 92,
+              message: '涓嶆墽琛岄粯璁ql鏃讹紝蹇呴』璁剧疆鑷畾涔夎剼鏈紒',
+              duration: 5
+            })
+            return
+          }
+
+          let cols = _verify.columns.map(col => col.Column.toLowerCase())
           cols = Array.from(new Set(cols))
+          let error = ''
 
           if (_verify.columns.length === 0) {
-            notification.warning({
-              top: 92,
-              message: '璇疯缃瓻xcel鍒楀瓧娈�!',
-              duration: 5
-            })
-            return
+            error = '璇疯缃瓻xcel鍒楀瓧娈�!'
           } else if (_verify.columns.length > cols.length) {
-            notification.warning({
-              top: 92,
-              message: 'Excel鍒楀瓧娈靛悕锛屼笉鍙噸澶�!',
-              duration: 5
-            })
-            return
+            error = 'Excel鍒楀瓧娈靛悕锛屼笉鍙噸澶�!'
+          } else if (cols.includes('bid')) {
+            error = 'bid瀛楁涓轰繚鐣欏瓧锛屼笉鍙娇鐢�!'
+          } else if (cols.includes('jskey')) {
+            error = 'jskey瀛楁涓轰繚鐣欏瓧锛屼笉鍙娇鐢�!'
           } else if (_verify.range === 1) {
             let tEmptys = _verify.columns.filter(op => !op.Text)
             if (tEmptys.length > 0) {
-              notification.warning({
-                top: 92,
-                message: '蹇界暐棣栬鏃讹紝浼氫娇鐢═ext鍊兼牎楠孍xcel棣栬鍐呭锛孴ext鍊间笌Excel琛ㄩ琛屽唴瀹圭浉鍚岋紝涓斿潎涓嶅彲涓虹┖锛�',
-                duration: 5
-              })
-              return
+              error = '蹇界暐棣栬鏃讹紝浼氫娇鐢═ext鍊兼牎楠孍xcel棣栬鍐呭锛孴ext鍊间笌Excel琛ㄩ琛屽唴瀹圭浉鍚岋紝涓斿潎涓嶅彲涓虹┖锛�'
             }
           }
+
+          if (error) {
+            notification.warning({
+              top: 92,
+              message: error,
+              duration: 5
+            })
+            return
+          }
+
+          _verify.columns.sort((a, b) => {
+            if (a.import === 'init' && b.import !== 'init') {
+              return 1
+            } else if (a.import !== 'init' && b.import === 'init') {
+              return -1
+            }
+            return 0
+          })
 
           let _loading = false
           if (this.scriptsForm && this.scriptsForm.state.editItem) {
@@ -707,22 +879,17 @@
             resolve(_verify)
           }
         } else {
-          notification.warning({
-            top: 92,
-            message: '璇疯缃瓻xcel琛ㄥ悕!',
-            duration: 5
-          })
+          this.setState({activeKey: 'basemsg'})
         }
       })
     })
   }
 
-  onOptionChange = (e, key) => {
+  onOptionChange = (value, key) => {
     const { verify } = this.state
-    let value = e.target.value
 
     this.setState({
-      verify: {...verify, default: value}
+      verify: {...verify, [key]: value}
     })
   }
 
@@ -784,7 +951,7 @@
   render() {
     const { card } = this.props
     const { getFieldDecorator } = this.props.form
-    const { verify, excelColumns, scriptsColumns, uniqueColumns, activeKey } = this.state
+    const { verify, excelColumns, scriptsColumns, uniqueColumns, activeKey, searchKey } = this.state
     const formItemLayout = {
       labelCol: {
         xs: { span: 24 },
@@ -797,24 +964,54 @@
     }
 
     return (
-      <div id="verify-excel-box-tab">
-        <Tabs activeKey={activeKey} className="verify-card-box" onChange={this.tabchange}>
+      <div>
+        {card.label ? <div className="mk-com-name">{card.label} - 楠岃瘉淇℃伅</div> : null}
+        <Tabs activeKey={activeKey} className="excelin-verify-card-box" onChange={this.tabchange}>
           <TabPane tab="鍩虹楠岃瘉" key="basemsg">
             <Form {...formItemLayout}>
               <Row gutter={24}>
+                {card.intertype === 'system' ? <Col span={8}>
+                  <Form.Item label="榛樿sql">
+                    <Radio.Group value={verify.default} onChange={(e) => this.onOptionChange(e.target.value, 'default')}>
+                      <Radio value="true">鎵ц</Radio>
+                      <Radio value="false">涓嶆墽琛�</Radio>
+                    </Radio.Group>
+                  </Form.Item>
+                </Col> : null}
                 <Col span={8}>
-                  <Form.Item label={this.props.dict['model.form.tablename']}>
+                  <Form.Item label={
+                    <Tooltip placement="topRight" title="鑷畾涔夐獙璇丒xcel鏍煎紡锛屽彲鐢ㄥ弬鏁颁负 XLSX銆亀orkbook銆乥tn銆乧allback銆�">
+                      <QuestionCircleOutlined className="mk-form-tip" />
+                      瀵煎叆鏍煎紡
+                    </Tooltip>
+                  }>
+                    {getFieldDecorator('excelHandle', {
+                      initialValue: verify.excelHandle
+                    })(
+                    <Radio.Group onChange={(e) => this.onOptionChange(e.target.value, 'excelHandle')}>
+                      <Radio value="false">榛樿</Radio>
+                      <Radio value="true">鑷畾涔�</Radio>
+                    </Radio.Group>)}
+                  </Form.Item>
+                </Col>
+                {verify.excelHandle !== 'true' ? <Col span={8}>
+                  <Form.Item label={
+                    <Tooltip placement="bottomLeft" title="瀵煎叆鏃跺伐浣滆〃鍚嶄笌excel涓繀椤讳竴鑷达紝娉細宸ヤ綔琛ㄥ悕涓篠heet1涓攅xcel涓粎鏈変竴涓伐浣滆〃鏃朵笉杩涜琛ㄥ悕楠岃瘉銆�">
+                      <QuestionCircleOutlined className="mk-form-tip" />
+                      宸ヤ綔琛�
+                    </Tooltip>
+                  }>
                     {getFieldDecorator('sheet', {
                       initialValue: verify.sheet || '',
                       rules: [
                         {
                           required: true,
-                          message: this.props.dict['form.required.input'] + this.props.dict['model.form.tablename'] + '!'
+                          message: '璇疯緭鍏ュ伐浣滆〃鍚�!'
                         }
                       ]
                     })(<Input placeholder="" autoComplete="off" />)}
                   </Form.Item>
-                </Col>
+                </Col> : null}
                 <Col span={8}>
                   <Form.Item label={
                     <Tooltip placement="bottomLeft" title="蹇界暐棣栬鏃讹紝浼氭牎楠宔xcel涓〃澶村悕绉颁笌excel鍒楄缃槸鍚︿竴鑷淬��">
@@ -827,9 +1024,35 @@
                     })(<InputNumber min={0} max={100} precision={0} />)}
                   </Form.Item>
                 </Col>
-                {card.intertype === 'system' ? <Col span={8}>
-                  <Form.Item label={'榛樿sql'}>
-                    <Radio.Group value={verify.default} onChange={this.onOptionChange}>
+                {verify.excelHandle === 'true' ? <Col span={24} style={{paddingLeft: '30px'}}>
+                  <Form.Item wrapperCol={ {xs: { span: 24 }, sm: { span: 24 }} } label="">
+                    {getFieldDecorator('excel_func', {
+                      initialValue: verify.excel_func || '',
+                      rules: [
+                        {
+                          required: true,
+                          message: '璇峰~鍐欒嚜瀹氫箟閫昏緫!'
+                        }
+                      ]
+                    })(<CodeMirror mode="text/javascript" theme="cobalt" />)}
+                  </Form.Item>
+                </Col> : null}
+                {window.GLOB.process && card.intertype === 'system' ? <Col span={8}>
+                  <Form.Item label={
+                    <Tooltip placement="bottomLeft" title="瀵煎叆Excel宸ヤ綔娴佷粎鏀寔鍙戣捣娴佺▼銆�">
+                      <QuestionCircleOutlined className="mk-form-tip" />
+                      宸ヤ綔娴�
+                    </Tooltip>
+                  }>
+                    <Radio.Group value={verify.workFlow} onChange={(e) => {this.onOptionChange(e.target.value, 'workFlow')}}>
+                      <Radio value="true">寮�鍚�</Radio>
+                      <Radio value="false">涓嶅紑鍚�</Radio>
+                    </Radio.Group>
+                  </Form.Item>
+                </Col> : null}
+                {verify.workFlow === 'true' ? <Col span={8}>
+                  <Form.Item label="榛樿sql锛堝伐浣滄祦锛�">
+                    <Radio.Group value={verify.flowSql} onChange={(e) => {this.onOptionChange(e.target.value, 'flowSql')}}>
                       <Radio value="true">鎵ц</Radio>
                       <Radio value="false">涓嶆墽琛�</Radio>
                     </Radio.Group>
@@ -844,15 +1067,15 @@
               {verify.columns.length ? <span className="count-tip">{verify.columns.length}</span> : null}
             </span>
           } key="excelcolumn">
-            <ColumnForm dict={this.props.dict} columnChange={this.columnChange}/>
+            <ColumnForm columnChange={this.columnChange}/>
             <Button className="excel-col-add mk-green" title="娣诲姞鏄剧ず鍒楀瓧娈�" onClick={this.columnFieldInput}>
-              鍚屾鏄剧ず鍒�
+              鍚屾瀛楁闆�
             </Button>
             <Button className="excel-col-add mk-red" title="娓呯┖Excel鍒�" onClick={this.clearField}>
               娓呯┖Excel鍒�
             </Button>
-            <Col style={{fontSize: '12px', color: '#757575', paddingLeft: '10px'}} span={24}>娉細鏁板�肩被鍨嬶紙int 鎴� decimal锛夛紝鍐呭涓哄繀濉紱鏈�澶у�煎拰鏈�灏忓�煎湪绫诲瀷涓烘暟鍊兼椂鏈夋晥銆�</Col>
-            <EditTable actions={['edit', 'move', 'copy', 'del']} type="excelcolumn" data={verify.columns} columns={excelColumns} onChange={this.changeColumns}/>
+            <Col style={{fontSize: '12px', color: '#757575', paddingLeft: '10px'}} span={24}>娉細鏁板�肩被鍨嬶紙int 鎴� decimal锛夛紝鍐呭涓哄繀濉紱鏈�澶у�煎拰鏈�灏忓�煎湪绫诲瀷涓烘暟鍊兼椂鏈夋晥銆傚鍏�-鍒濆鍖栵細鐢ㄤ簬excel涓笉瀛樺湪锛屽鍏ユ椂闇�瑕佸垵濮嬪寲鐨勫瓧娈�</Col>
+            <EditTable actions={['edit', 'move', 'copy', 'del', 'extra:required:鏄惁蹇呭~']} searchKey={searchKey} type="excelcolumn" data={verify.columns} columns={excelColumns} onChange={this.changeColumns}/>
           </TabPane>
           {card.intertype === 'system' ? <TabPane tab={
             <span>
@@ -860,38 +1083,54 @@
               {verify.uniques.length ? <span className="count-tip">{verify.uniques.length}</span> : null}
             </span>
           } key="unique">
-            <UniqueForm fields={verify.columns} dict={this.props.dict} uniqueChange={this.uniqueChange}/>
-            <EditTable actions={['edit', 'move', 'del']} data={verify.uniques} columns={uniqueColumns} onChange={this.changeUniques}/>
+            <UniqueForm fields={verify.columns} uniqueChange={this.uniqueChange}/>
+            <EditTable actions={['edit', 'move', 'del', 'status', 'sql']} data={verify.uniques} columns={uniqueColumns} onChange={this.changeUniques}/>
           </TabPane> : null}
           {card.intertype === 'system' ? <TabPane tab={
             <span>
               鑷畾涔夎剼鏈�
               {verify.scripts.length ? <span className="count-tip">{verify.scripts.length}</span> : null}
             </span>
-          } key="scripts">
+          } key="scripts" id="mk-exin-script">
+            <FullScripts
+              scripts={verify.scripts}
+              getScriptsFullForm={() => this.scriptsFullForm}
+              getScriptsForm={() => this.scriptsForm}
+              handleStatus={this.handleStatus}
+              handleDelete={this.handleDelete}
+            >
+              <CustomScript
+                type="fullscreen"
+                btn={this.props.card}
+                usefulfields={verify.columns}
+                scripts={verify.scripts}
+                workFlow={verify.workFlow}
+                systemScripts={this.state.systemScripts}
+                scriptsChange={this.scriptsChange}
+                wrappedComponentRef={(inst) => this.scriptsFullForm = inst}
+              />
+            </FullScripts>
             <CustomScript
-              dict={this.props.dict}
               btn={this.props.card}
               usefulfields={verify.columns}
               scripts={verify.scripts}
+              workFlow={verify.workFlow}
               systemScripts={this.state.systemScripts}
               scriptsChange={this.scriptsChange}
               wrappedComponentRef={(inst) => this.scriptsForm = inst}
             />
-            <Table
-              bordered
-              rowKey="uuid"
-              className="custom-table"
-              dataSource={verify.scripts}
-              columns={scriptsColumns}
-              pagination={false}
-            />
+            <EditTable actions={['move']} data={verify.scripts} columns={scriptsColumns} onChange={(scripts) => {this.setState({verify: {...verify, scripts}})}}/>
           </TabPane> : null}
-          <TabPane tab="淇℃伅鎻愮ず" key="tip">
+          <TabPane tab={
+            <span>
+              淇℃伅鎻愮ず
+              {activeKey === 'excelcolumn' ? <span onClick={(e) => {e.stopPropagation()}}><Search className="mk-search-fields" defaultValue={searchKey} allowClear onSearch={(val, e) => {e.stopPropagation();this.setState({searchKey: val})}} /></span> : null}
+            </span>
+          } key="tip">
             <Form {...formItemLayout}>
               <Row gutter={24}>
                 <Col offset={6} span={6}>
-                  <Form.Item label={'鎻愮ず缂栫爜'}>
+                  <Form.Item label="鎻愮ず缂栫爜">
                     <span className="errorval"> S </span>
                     <Button onClick={() => {this.showError('S')}} type="primary" size="small">
                       鏌ョ湅
@@ -899,14 +1138,14 @@
                   </Form.Item>
                 </Col>
                 <Col span={8}>
-                  <Form.Item label={'鍋滅暀鏃堕棿'}>
+                  <Form.Item label="鍋滅暀鏃堕棿">
                     <InputNumber defaultValue={verify.stime || 2} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'stime')}} />
                   </Form.Item>
                 </Col>
               </Row>
               <Row gutter={24}>
                 <Col offset={6} span={6}>
-                  <Form.Item label={'鎻愮ず缂栫爜'}>
+                  <Form.Item label="鎻愮ず缂栫爜">
                     <span className="errorval"> Y </span>
                     <Button onClick={() => {this.showError('Y')}} type="primary" size="small">
                       鏌ョ湅
@@ -916,7 +1155,15 @@
               </Row>
               <Row gutter={24}>
                 <Col offset={6} span={6}>
-                  <Form.Item label={'鎻愮ず缂栫爜'}>
+                  <Form.Item label="鎻愮ず缂栫爜">
+                    <span className="errorval"> -1 </span>
+                    鎵ц鎴愬姛鏃犳彁绀恒��
+                  </Form.Item>
+                </Col>
+              </Row>
+              <Row gutter={24}>
+                <Col offset={6} span={6}>
+                  <Form.Item label="鎻愮ず缂栫爜">
                     <span className="errorval"> N </span>
                     <Button onClick={() => {this.showError('N')}} type="primary" size="small">
                       鏌ョ湅
@@ -924,14 +1171,14 @@
                   </Form.Item>
                 </Col>
                 <Col span={8}>
-                  <Form.Item label={'鍋滅暀鏃堕棿'}>
+                  <Form.Item label="鍋滅暀鏃堕棿">
                     <InputNumber defaultValue={verify.ntime || 10} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'ntime')}} />
                   </Form.Item>
                 </Col>
               </Row>
               <Row gutter={24}>
                 <Col offset={6} span={6}>
-                  <Form.Item label={'鎻愮ず缂栫爜'}>
+                  <Form.Item label="鎻愮ず缂栫爜">
                     <span className="errorval"> F </span>
                     <Button onClick={() => {this.showError('F')}} type="primary" size="small">
                       鏌ョ湅
@@ -939,14 +1186,14 @@
                   </Form.Item>
                 </Col>
                 <Col span={8}>
-                  <Form.Item label={'鍋滅暀鏃堕棿'}>
+                  <Form.Item label="鍋滅暀鏃堕棿">
                     <InputNumber defaultValue={verify.ftime || 10} min={1} max={10000} precision={0} onChange={(val) => {this.timeChange(val, 'ftime')}} />
                   </Form.Item>
                 </Col>
               </Row>
               <Row gutter={24}>
                 <Col offset={6} span={6}>
-                  <Form.Item label={'鎻愮ず缂栫爜'}>
+                  <Form.Item label="鎻愮ず缂栫爜">
                     <span className="errorval"> E </span>
                     <Button onClick={() => {this.showError('E')}} type="primary" size="small">
                       鏌ョ湅
@@ -956,7 +1203,7 @@
               </Row>
               <Row gutter={24}>
                 <Col offset={6} span={6}>
-                  <Form.Item label={'鎻愮ず缂栫爜'}>
+                  <Form.Item label="鎻愮ず缂栫爜">
                     <span className="errorval"> NM </span>
                     <Button onClick={() => {this.showError('NM')}} type="primary" size="small">
                       鏌ョ湅
@@ -966,9 +1213,9 @@
               </Row>
               <Row gutter={24}>
                 <Col offset={6} span={6}>
-                  <Form.Item label={'鎻愮ず缂栫爜'}>
-                    <span className="errorval"> -1 </span>
-                    涓嶆彁绀�
+                  <Form.Item label="鎻愮ず缂栫爜">
+                    <span className="errorval"> -2 </span>
+                    鎵ц澶辫触鏃犳彁绀�
                   </Form.Item>
                 </Col>
               </Row>

--
Gitblit v1.8.0