From 1a11f7115e61c548f9ffc77d0a9e504307ca71b2 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 24 八月 2021 18:37:20 +0800
Subject: [PATCH] 2021-08-24

---
 src/templates/sharecomponent/settingcomponent/settingform/index.jsx |   75 +++++++++++++++++++++++++------------
 1 files changed, 50 insertions(+), 25 deletions(-)

diff --git a/src/templates/sharecomponent/settingcomponent/settingform/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/index.jsx
index e348b99..f68c91e 100644
--- a/src/templates/sharecomponent/settingcomponent/settingform/index.jsx
+++ b/src/templates/sharecomponent/settingcomponent/settingform/index.jsx
@@ -85,12 +85,41 @@
     status.requestMode = status.requestMode || 'system'
     status.procMode = status.procMode || 'script'
     status.callbackType = status.callbackType || 'script'
+    let regoptions = Utils.getRegOptions(search)
+
+    if (config.urlFields && config.urlFields.length > 0) {
+      config.urlFields.forEach(field => {
+        regoptions.push({
+          key: field,
+          value: '0',
+          type: 'url'
+        })
+      })
+    }
+
+    if (window.GLOB.funcs && window.GLOB.funcs.length > 0) {
+      window.GLOB.funcs.forEach(m => {
+        let reg = new RegExp(`\\/\\*\\$ex@${m.func_code}-begin\\*\\/[\\s\\S]+\\/\\*@ex\\$-end\\*\\/`, 'ig')
+        _scripts.forEach(item => {
+          item.sql = item.sql.replace(reg, `$ex@${m.func_code}@ex$`)
+        })
+        _preScripts.forEach(item => {
+          item.sql = item.sql.replace(reg, `$ex@${m.func_code}@ex$`)
+        })
+        _cbScripts.forEach(item => {
+          item.sql = item.sql.replace(reg, `$ex@${m.func_code}@ex$`)
+        })
+        if (_setting.dataresource) {
+          _setting.dataresource = _setting.dataresource.replace(reg, `$ex@${m.func_code}@ex$`)
+        }
+      })
+    }
 
     this.setState({
       setting: _setting,
       search: _search,
       arr_field: arr_field.join(','),
-      regoptions: Utils.getRegOptions(search), // 鎼滅储鏉′欢锛屾鍒欐浛鎹�
+      regoptions: regoptions, // 鎼滅储鏉′欢锛屾鍒欐浛鎹�
       columns: columns,
       scripts: _scripts,
       preScripts: _preScripts,
@@ -118,32 +147,26 @@
         value: search.initval,
         required: search.required === 'true'
       }
+      
       if (item.type === 'group') {
-        let copy = fromJS(item).toJS()
-        copy.key = search.datefield
+        item.key = search.datefield
+        item.type = 'daterange'
+        item.match = 'between'
+        item.value = [moment().format('YYYY-MM-DD'), moment().format('YYYY-MM-DD')].join(',')
 
-        item.value = search.initval && search.initval[0] ? search.initval[0] : '@$@'
-        item.match = '='
-        
-        copy.type = 'daterange'
-        copy.match = 'between'
-        copy.value = [moment().format('YYYY-MM-DD'), moment().format('YYYY-MM-DD')]
-
-        if (search.transfer === 'true') {
-          newsearches.push(item)
-        }
-        newsearches.push(copy)
+        newsearches.push(item)
         return
       } else if (item.type === 'date') {
         item.value = moment().format('YYYY-MM-DD')
       } else if (item.type === 'datemonth') {
         item.value = moment().format('YYYY-MM')
       } else if (item.type === 'dateweek') {
-        item.value = [moment().startOf('week').format('YYYY-MM-DD'), moment().endOf('week').format('YYYY-MM-DD')]
+        item.value = moment().format('YYYY-MM-DD')
       } else if (item.type === 'daterange') {
-        item.value = [moment().format('YYYY-MM-DD'), moment().format('YYYY-MM-DD')]
-      } else if (item.type === 'multiselect') {
-        item.value = ['@$@']
+        item.value = [moment().format('YYYY-MM-DD'), moment().format('YYYY-MM-DD')].join(',')
+      } else if (item.type === 'multiselect' || (item.type === 'checkcard' && search.multiple === 'true')) {
+        item.type = 'multi'
+        item.value = '@$@'
       } else {
         item.value = '@$@'
       }
@@ -157,11 +180,11 @@
     const { activeKey, setting, scripts, preScripts, cbScripts } = this.state
 
     let _loading = false
-    if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) {
+    if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))) {
       _loading = true
-    } else if (this.preScriptsForm && this.preScriptsForm.props.form.getFieldValue('sql')) {
+    } else if (this.preScriptsForm && this.preScriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.preScriptsForm.props.form.getFieldValue('sql'))) {
       _loading = true
-    } else if (this.cbScriptsForm && this.cbScriptsForm.props.form.getFieldValue('sql')) {
+    } else if (this.cbScriptsForm && this.cbScriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.cbScriptsForm.props.form.getFieldValue('sql'))) {
       _loading = true
     }
 
@@ -171,7 +194,7 @@
         message: '瀛樺湪鏈繚瀛樿剼鏈紝璇风偣鍑荤‘瀹氫繚瀛橈紝鎴栫偣鍑诲彇娑堟斁寮冧慨鏀癸紒',
         duration: 5
       })
-      return
+      return Promise.reject()
     }
 
     if (trigger) {
@@ -293,11 +316,11 @@
     const { activeKey, search, arr_field, setting } = this.state
 
     let _loading = false
-    if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql')) {
+    if (this.scriptsForm && this.scriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.scriptsForm.props.form.getFieldValue('sql'))) {
       _loading = true
-    } else if (this.preScriptsForm && this.preScriptsForm.props.form.getFieldValue('sql')) {
+    } else if (this.preScriptsForm && this.preScriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.preScriptsForm.props.form.getFieldValue('sql'))) {
       _loading = true
-    } else if (this.cbScriptsForm && this.cbScriptsForm.props.form.getFieldValue('sql')) {
+    } else if (this.cbScriptsForm && this.cbScriptsForm.props.form.getFieldValue('sql') && !/^\s+$/.test(this.cbScriptsForm.props.form.getFieldValue('sql'))) {
       _loading = true
     }
 
@@ -452,6 +475,7 @@
               setting={setting}
               scripts={scripts}
               defaultSql={defaultSql}
+              urlFields={config.urlFields}
               searches={this.props.search}
               scriptsChange={this.scriptsChange}
               scriptsUpdate={this.scriptsUpdate}
@@ -469,6 +493,7 @@
               setting={setting}
               scripts={preScripts}
               regoptions={regoptions}
+              urlFields={config.urlFields}
               searches={this.props.search}
               scriptsUpdate={this.preScriptsUpdate}
               wrappedComponentRef={(inst) => this.preScriptsForm = inst}

--
Gitblit v1.8.0