From 11b6387d74467f81e33eba8f882bff610f240115 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 18 九月 2023 20:01:09 +0800
Subject: [PATCH] Merge branch 'master' into positec

---
 src/menu/datasource/verifycard/index.jsx |  131 ++++++++++++++++++++++++++-----------------
 1 files changed, 78 insertions(+), 53 deletions(-)

diff --git a/src/menu/datasource/verifycard/index.jsx b/src/menu/datasource/verifycard/index.jsx
index f11fcde..266395c 100644
--- a/src/menu/datasource/verifycard/index.jsx
+++ b/src/menu/datasource/verifycard/index.jsx
@@ -22,6 +22,7 @@
 const { TabPane } = Tabs
 const { Paragraph } = Typography
 const { Search } = Input
+const { confirm } = Modal
 
 const CodeMirror = asyncComponent(() => import('@/templates/zshare/codemirror'))
 const FieldsComponent = asyncComponent(() => import('@/templates/sharecomponent/fieldscomponent'))
@@ -51,6 +52,7 @@
     reload: false,
     script: null,
     scriptValue: '',
+    cols: null,
     colColumns: [
       {
         title: '鍚嶇О',
@@ -383,7 +385,7 @@
     }
 
     return new Promise((resolve, reject) => {
-      this.sqlverify(resolve, reject, false, scripts)
+      this.sqlverify(resolve, reject, 'script', scripts)
     })
   }
 
@@ -447,7 +449,7 @@
               loading: false
             })
             this.getdefaultSql()
-          }, true)
+          }, 'change')
         })
       }, () => {
         this.setState({loading: false})
@@ -579,7 +581,7 @@
 
   submitDataSource = () => {
     const { config, mainSearch } = this.props
-    const { activeKey, setting, columns, subColumns, scripts } = this.state
+    const { activeKey, setting, columns, subColumns, scripts, cols } = this.state
 
     if (config.subtype === 'dualdatacard') {
       let arr = columns.map(col => col.field.toLowerCase())
@@ -620,7 +622,7 @@
             defaultSearch: _search,
             setting: res
           }, () => {
-            this.sqlverify(() => { resolve({setting: res, columns, subColumns, scripts }) }, reject, false)
+            this.sqlverify(() => { resolve({setting: res, columns, subColumns, scripts, cols }) }, reject, 'submit')
           })
         }, () => {
           reject()
@@ -635,7 +637,7 @@
           reject()
           return
         }
-        this.sqlverify(() => { resolve({setting, columns, subColumns, scripts }) }, reject, false)
+        this.sqlverify(() => { resolve({setting, columns, subColumns, scripts, cols }) }, reject, 'submit')
       } else if (activeKey === 'subcolumns') {
         if (this.subdatasource && this.subdatasource.state.editingKey) {
           notification.warning({
@@ -646,7 +648,7 @@
           reject()
           return
         }
-        this.sqlverify(() => { resolve({setting, columns, subColumns, scripts }) }, reject, false)
+        this.sqlverify(() => { resolve({setting, columns, subColumns, scripts, cols }) }, reject, 'submit')
       } else if (activeKey === 'scripts') {
         let _loading = false
         if (this.scriptsForm && this.scriptsForm.state.editItem) {
@@ -665,12 +667,12 @@
           return
         }
 
-        this.sqlverify(() => { resolve({setting, columns, subColumns, scripts }) }, reject, false)
+        this.sqlverify(() => { resolve({setting, columns, subColumns, scripts, cols }) }, reject, 'submit')
       }
     })
   }
 
-  sqlverify = (resolve, reject, change = false, testScripts) => {
+  sqlverify = (resolve, reject, type, testScripts) => {
     const { config } = this.props
     const { columns, setting, scripts, searches, defaultSearch, debugId } = this.state
 
@@ -679,7 +681,7 @@
     if (testScripts) {
       _scripts = testScripts.filter(item => item.status !== 'false')
     }
-    if (!change && setting.interType === 'system' && setting.execute === 'false' && _scripts.length === 0) {
+    if (type !== 'change' && setting.interType === 'system' && setting.execute === 'false' && _scripts.length === 0) {
       notification.warning({
         top: 92,
         message: '涓嶆墽琛岄粯璁ql鏃讹紝璇锋坊鍔犺嚜瀹氫箟鑴氭湰锛�',
@@ -689,14 +691,13 @@
       return
     }
 
-    if (change && columns.length === 0) {
+    if (type === 'change' && columns.length === 0) {
       reject()
       return
     }
 
     if ((setting.interType === 'system' && setting.execute !== 'false') || _scripts.length > 0) {
-      let timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-      let r = SettingUtils.getDebugSql(setting, _scripts, columns, searches, defaultSearch, config.type, '2023-04-20 15:29:37')
+      let r = SettingUtils.getDebugSql(setting, _scripts, columns, searches, defaultSearch, config.type)
 
       let _debugId = md5(r.sql)
 
@@ -713,52 +714,31 @@
         })
       }
 
-      let param = {
-        func: 's_debug_sql',
-        exec_type: 'y',
-        LText: r.sql
-      }
-      param.LText = Utils.formatOptions(param.LText)
-      param.timestamp = timestamp
-      param.secretkey = Utils.encrypt('', timestamp)
-
-      let sumParam = null
-      if (r.sumSql) {
-        sumParam = {
-          func: 's_debug_sql',
-          exec_type: 'y',
-          LText: r.sumSql
-        }
-        sumParam.LText = Utils.formatOptions(sumParam.LText)
-        sumParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-        sumParam.secretkey = Utils.encrypt('', sumParam.timestamp)
-      }
-      
-      Api.genericInterface(param).then(result => {
-        if (result.status) {
-          if (sumParam) {
-            Api.genericInterface(sumParam).then(res => {
-              if (res.status) {
-                this.setState({debugId: _debugId}, () => {
-                  resolve()
-                })
-              } else {
+      Api.sDebug(r.sql).then(result => {
+        if (result.status || result.ErrCode === '-2') {
+          this.setState({debugId: _debugId}, () => {
+            resolve()
+          })
+        } else {
+          if (type === 'submit') {
+            Modal.confirm({
+              title: result.message,
+              okText: '鐭ラ亾浜�',
+              cancelText: '寮哄埗淇濆瓨',
+              onOk: () => {
                 reject()
-                Modal.error({
-                  title: res.message
-                })
+              },
+              onCancel() {
+                resolve()
               }
             })
           } else {
-            this.setState({debugId: _debugId}, () => {
-              resolve()
+            reject()
+            Modal.error({
+              title: result.message,
+              okText: '鐭ラ亾浜�'
             })
           }
-        } else {
-          reject()
-          Modal.error({
-            title: result.message
-          })
         }
       })
     } else {
@@ -799,7 +779,7 @@
 
     this.setState({loading: true})
 
-    this.sqlverify(() => {this.setState({scripts: _scripts, script: null, scriptValue: '', loading: false})}, () => {this.setState({loading: false})}, false, _scripts)
+    this.sqlverify(() => {this.setState({scripts: _scripts, script: null, scriptValue: '', loading: false})}, () => {this.setState({loading: false})}, 'script', _scripts)
   }
 
   updatefields = (columns) => {
@@ -965,6 +945,49 @@
     message.success('澶嶅埗鎴愬姛銆�')
   }
 
+  addProcess = () => {
+    const { config } = this.props
+    const { columns } = this.state
+
+    if (config.subtype === 'dualdatacard') return
+
+    let fields = []
+    let cols = []
+    let _cols = columns.map(item => item.field.toLowerCase())
+
+    if (!_cols.includes('remark_w')) {
+      fields.push({ uuid: Utils.getuuid(), label: '澶囨敞', field: 'remark_w', datatype: 'Nvarchar(50)', fieldlength: 50, type: 'text' })
+      cols.push({ uuid: Utils.getuuid(), Width: 120, label: '澶囨敞', field: 'remark_w', type: 'text', Hide: 'false', IsSort: 'false', fieldlength: 50 })
+    }
+    if (!_cols.includes('statusname_w')) {
+      fields.push({ uuid: Utils.getuuid(), label: '鐘舵��', field: 'statusname_w', datatype: 'Nvarchar(50)', fieldlength: 50, type: 'text' })
+      cols.push({ uuid: Utils.getuuid(), Width: 120, label: '鐘舵��', field: 'statusname_w', type: 'text', Hide: 'false', IsSort: 'false', fieldlength: 50 })
+    }
+    if (!_cols.includes('works_flow_param')) {
+      fields.push({ uuid: Utils.getuuid(), label: '娴佺▼鍙傛暟', field: 'works_flow_param', datatype: 'Nvarchar(512)', fieldlength: 512, type: 'text' })
+      cols.push({ uuid: Utils.getuuid(), Width: 120, label: '娴佺▼鍙傛暟', field: 'works_flow_param', type: 'text', Hide: 'true', IsSort: 'false', fieldlength: 512 })
+    }
+
+    if (fields.length === 0) return
+
+    const that = this
+
+    if (config.subtype !== 'basetable') {
+      cols = null
+    }
+
+    confirm({
+      content: cols ? '鏄剧ず鍒椾腑鏄惁娣诲姞宸ヤ綔娴佸瓧娈碉紵' : '瀛楁闆嗕腑鏄惁娣诲姞宸ヤ綔娴佸瓧娈碉紵',
+      onOk() {
+        that.setState({
+          cols: cols,
+          columns: [...fields, ...columns]
+        })
+      },
+      onCancel() {}
+    })
+  }
+
   /**
    * @description 缁勪欢閿�姣侊紝娓呴櫎state鏇存柊
    */
@@ -995,6 +1018,7 @@
               setting={setting}
               scripts={scripts}
               updateStatus={this.updateStatus}
+              addProcess={this.addProcess}
               wrappedComponentRef={(inst) => this.settingForm = inst}
             /> : null}
           </TabPane>
@@ -1058,6 +1082,7 @@
               systemScripts={this.state.systemScripts}
               scriptsChange={this.scriptsChange}
               scriptSubmit={this.scriptSubmit}
+              addProcess={this.addProcess}
               wrappedComponentRef={(inst) => this.scriptsForm = inst}
             />
             <EditTable actions={['move']} data={scripts} columns={scriptsColumns} onChange={this.changeScripts}/>

--
Gitblit v1.8.0