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/customscript/index.jsx |  121 +++++++++++++++-------------------------
 1 files changed, 45 insertions(+), 76 deletions(-)

diff --git a/src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx b/src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx
index 07c8db4..ab01815 100644
--- a/src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx
+++ b/src/templates/sharecomponent/actioncomponent/verifyexcelin/customscript/index.jsx
@@ -3,12 +3,11 @@
 import { is, fromJS } from 'immutable'
 import { Form, Row, Col, Button, notification, Modal, Tooltip, Radio, Select, Switch } from 'antd'
 import { QuestionCircleOutlined } from '@ant-design/icons'
-import moment from 'moment'
 
-import Utils from '@/utils/utils.js'
 import Api from '@/api'
+import { checkSQL } from '@/utils/utils-custom.js'
 import CodeMirror from '@/templates/zshare/codemirror'
-import './index.scss'
+// import './index.scss'
 
 class CustomForm extends Component {
   static propTpyes = {
@@ -82,7 +81,7 @@
   }
 
   handleConfirm = () => {
-    const { type, btn } = this.props
+    const { type, btn, workFlow } = this.props
     const { editItem, skip } = this.state
 
     // 琛ㄥ崟鎻愪氦鏃舵鏌ヨ緭鍏ュ�兼槸鍚︽纭�
@@ -113,54 +112,9 @@
           values.status = editItem.status || 'true'
         }
 
-        let _quot = values.sql.match(/'{1}/g)
-        let _lparen = values.sql.match(/\({1}/g)
-        let _rparen = values.sql.match(/\){1}/g)
+        let pass = checkSQL(values.sql, 'customscript')
 
-        _quot = _quot ? _quot.length : 0
-        _lparen = _lparen ? _lparen.length : 0
-        _rparen = _rparen ? _rparen.length : 0
-
-        if (_quot % 2 !== 0) {
-          notification.warning({
-            top: 92,
-            message: 'sql涓璡'蹇呴』鎴愬鍑虹幇',
-            duration: 5
-          })
-          return
-        } else if (_lparen !== _rparen) {
-          notification.warning({
-            top: 92,
-            message: 'sql涓�()蹇呴』鎴愬鍑虹幇',
-            duration: 5
-          })
-          return
-        } else if (/--/ig.test(values.sql)) {
-          notification.warning({
-            top: 92,
-            message: '鑷畾涔塻ql璇彞涓紝涓嶅彲鍑虹幇瀛楃 -- 锛屾敞閲婅鐢� /*鍐呭*/',
-            duration: 5
-          })
-          return
-        } else if (/,,/ig.test(values.sql)) {
-          notification.warning({
-            top: 92,
-            message: '鑷畾涔塻ql璇彞涓紝涓嶅彲鍑虹幇杩炵画鐨勮嫳鏂囬�楀彿锛�,,锛�',
-            duration: 5
-          })
-          return
-        }
-
-        let error = Utils.verifySql(values.sql, 'customscript')
-
-        if (error) {
-          notification.warning({
-            top: 92,
-            message: 'sql涓笉鍙娇鐢�' + error,
-            duration: 5
-          })
-          return
-        }
+        if (!pass) return
 
         let sheet = btn.sheet.replace(/(.*)\.(.*)\.|@db@/ig, '')
         let tail = `
@@ -212,24 +166,21 @@
           }
         }
 
-        let param = {
-          func: 's_debug_sql',
-          exec_type: 'y',
-          LText: this.state.verifySql + _initCustomScript + _prevCustomScript + _backCustomScript + tail
+        let sql = this.state.verifySql + _initCustomScript + _prevCustomScript + _backCustomScript + tail
+        sql = sql.replace(/@\$|\$@/ig, '').replace(/\$check@|@check\$/ig, '').replace(/@datam@/ig, `''`).replace(/@typename@/ig, `'debug'`)
+        
+        if (workFlow === 'true') {
+          sql = sql.replace(/@works_flow_code@/ig, `'works_flow_code'`)
+          sql = sql.replace(/@works_flow_name@/ig, `'works_flow_name'`)
+          sql = sql.replace(/@works_flow_param@/ig, `'works_flow_param'`)
+          sql = sql.replace(/@works_flow_detail_id@/ig, `'works_flow_detail_id'`)
+          sql = sql.replace(/@status@/ig, `0`)
+          sql = sql.replace(/@statusname@/ig, `'寮�濮�'`)
+          sql = sql.replace(/@work_group@/ig, `'work_group'`)
+          sql = sql.replace(/@work_grade@/ig, '0')
+          sql = sql.replace(/@start_type@/ig, `'寮�濮�'`)
         }
 
-        param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-        param.LText = param.LText.replace(/@\$|\$@/ig, '').replace(/\$check@|@check\$/ig, '').replace(/@(BID|ID|LoginUID|SessionUid|UserID|Appkey|time_id|datam|typename)@/ig, `'${param.timestamp}'`)
-        param.LText = param.LText.replace(/\n/g, ' ')
-        
-        // 澶栬仈鏁版嵁搴撴浛鎹�
-        if (window.GLOB.externalDatabase !== null) {
-          param.LText = param.LText.replace(/@db@/ig, window.GLOB.externalDatabase)
-        }
-
-        param.LText = Utils.formatOptions(param.LText)
-        param.secretkey = Utils.encrypt('', param.timestamp)
-        
         if (skip) {
           this.setState({
             skip: false,
@@ -242,8 +193,8 @@
           })
         } else {
           this.setState({loading: true})
-          Api.genericInterface(param).then(res => {
-            if (res.status) {
+          Api.sDebug(sql).then(res => {
+            if (res.status || res.ErrCode === '-2') {
               this.setState({
                 loading: false,
                 editItem: null
@@ -294,6 +245,24 @@
       database = database ? (database[0] || '') : ''
 
       _value = `Insert into ${database}${sheet} (${fields}createuserid,createuser,createstaff,bid)\nSelect ${fields}@userid@,@username,@fullname,@BID@ From #${sheet}`
+    } else if (value === 'flowSql') {
+      let sheet = btn.sheet.replace(/(.*)\.(.*)\.|@db@/ig, '')
+
+      _value = `insert into s_my_works_flow (works_flow_id,works_flow_code,works_flow_name,works_flow_param,status,statusname,work_group,works_flow_detail_id,work_grade,bid,createuserid,CreateUser,CreateStaff,upid)
+      select jskey,@works_flow_code@,@works_flow_name@,@works_flow_param@,@status@,@statusname@,@work_group@,@works_flow_detail_id@,@work_grade@,@bid@,@UserID@,@UserName,@FullName,@time_id@
+      from #${sheet}
+                                                                 
+      insert into s_my_works_flow_log (works_flow_id,works_flow_code,works_flow_name,works_flow_param,status,statusname,works_flow_detail_id,work_group,work_grade,bid,createuserid,CreateUser,CreateStaff,upid)
+      select jskey,@works_flow_code@,@works_flow_name@ ,@works_flow_param@,@status@,@statusname@,@works_flow_detail_id@,@work_group@,@work_grade@,@bid@,@UserID@,@UserName,@FullName,@time_id@
+      from #${sheet}
+                                                                 
+      insert into s_my_works_flow_notice (works_flow_id,works_flow_code,works_flow_detail_id,userid,notice_type,createuserid,CreateUser,CreateStaff,upid)
+      select jskey,@works_flow_code@,@works_flow_detail_id@,@userid@,@start_type@,@userid@,@UserName,@FullName,@time_id@
+      from #${sheet}
+                                                                 
+      insert into s_my_works_flow_role (works_flow_id,works_flow_code,userid,works_flow_detail_id,createuserid,CreateUser,CreateStaff,upid,typecharone)
+      select jskey,@works_flow_code@,@userid@,@works_flow_detail_id@,@userid@,@UserName,@FullName,@time_id@,'begin'
+      from #${sheet}`
     } else {
       _value = value
     }
@@ -320,7 +289,7 @@
   }
 
   render() {
-    const { systemScripts, btn, type } = this.props
+    const { systemScripts, btn, type, workFlow } = this.props
     const { usefulfields, editItem, skip } = this.state
     const { getFieldDecorator } = this.props.form
     const formItemLayout = {
@@ -339,17 +308,18 @@
         <Row gutter={24}>
           {!type && btn.sheet ? <Col span={8}>
             <Form.Item label="琛ㄥ悕" style={{whiteSpace: 'nowrap', margin: 0}}>
-              {btn.sheet}锛堣〃鍙橀噺璇蜂娇鐢�#{btn.sheet.replace(/(.*)\.(.*)\.|@db@/ig, '')}锛�
+              {btn.sheet}锛堜复鏃惰〃璇蜂娇鐢�#{btn.sheet.replace(/(.*)\.(.*)\.|@db@/ig, '')}锛�
             </Form.Item>
           </Col> : null}
           {!type ? <Col span={10}>
             <Form.Item label="鎶ラ敊瀛楁" style={{margin: 0, whiteSpace: 'nowrap'}}>
-              ErrorCode锛堝鍔犲悗缂�NT琛ㄧず鏁版嵁涓嶅洖婊氾紝濡侲NT銆丯NT銆丗NT銆丯MNT銆丆NT銆�-2NT锛�, retmsg
+              errorcode锛堝鍔犲悗缂�NT琛ㄧず鏁版嵁涓嶅洖婊氾紝濡侲NT銆丯NT銆丗NT銆丯MNT銆丆NT銆�-2NT锛�, retmsg
             </Form.Item>
           </Col> : null}
           {!type ? <Col span={24} className="sqlfield">
             <Form.Item label="鍙敤瀛楁">
               <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'鍏叡鍊硷紝璇锋寜鐓xxx@鏍煎紡浣跨敤銆�'}><span style={{color: '#1890ff'}}>BID, ID, LoginUID, SessionUid, UserID, Appkey, time_id, typename</span></Tooltip>,&nbsp;
+              {workFlow === 'true' ? <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title="宸ヤ綔娴佸彉閲忥紝璇锋寜鐓xxx@鏍煎紡浣跨敤銆�"><span style={{color: '#26C281'}}>works_flow_code, works_flow_name, works_flow_param, works_flow_detail_id, status, statusname, work_group, work_grade, start_type, </span></Tooltip> : null}
               <Tooltip mouseLeaveDelay={0.3} mouseEnterDelay={0.3} placement="top" title={'绯荤粺鍙橀噺锛岀郴缁熶細瀹氫箟鍙橀噺骞惰祴鍊笺��'}><span style={{color: '#fa8c16'}}>UserName, FullName, RoleID, mk_departmentcode, mk_organization, mk_user_type, mk_nation, mk_province, mk_city, mk_district, mk_address</span></Tooltip>,&nbsp;
               {usefulfields}
             </Form.Item>
@@ -380,9 +350,8 @@
                 onSelect={this.selectScript}
                 getPopupContainer={() => document.getElementById('verify-excelin-custom-scripts')}
               >
-                <Select.Option key="default" value={'default'}>
-                  榛樿sql
-                </Select.Option>
+                <Select.Option key="default" value="default">榛樿sql</Select.Option>
+                {workFlow === 'true' ? <Select.Option key="flow" value="flowSql">榛樿sql锛堝伐浣滄祦锛�</Select.Option> : null}
                 <Select.Option key="debugger" value={`z_debug: select @ErrorCode='E',@retmsg='娴嬭瘯鏂偣' goto aaa`}>
                   娴嬭瘯鏂偣
                 </Select.Option>
@@ -402,7 +371,7 @@
               鍙栨秷
             </Button>
           </Col>
-          <Col span={3} style={{paddingTop: '15px', fontSize: '12px', whiteSpace: 'nowrap'}}>
+          <Col span={3} className="forced" style={{paddingTop: '12px', fontSize: '12px', whiteSpace: 'nowrap'}}>
             寮哄埗淇濆瓨锛�
             <Switch checked={skip} size="small" onChange={() => this.setState({skip: !skip})}/>
           </Col>

--
Gitblit v1.8.0