From aaaf56d7ca060f7c681d6b8a67aac46aa89a4dbc Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 09 五月 2020 14:50:39 +0800
Subject: [PATCH] 2020-05-09

---
 src/tabviews/subtabtable/index.jsx |   44 +++++++++++++++++++++++++++++++++++---------
 1 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/src/tabviews/subtabtable/index.jsx b/src/tabviews/subtabtable/index.jsx
index d426bec..0ad2d51 100644
--- a/src/tabviews/subtabtable/index.jsx
+++ b/src/tabviews/subtabtable/index.jsx
@@ -358,12 +358,15 @@
     const { setting, search } = this.state
     let param = ''
 
-    let requireFields = search.filter(item => item.required && !item.value)
+    let requireFields = search.filter(item => item.required && (!item.value || item.value.length === 0))
 
     if (requireFields.length > 0) {
+      let labels = requireFields.map(item => item.label)
+      labels = Array.from(new Set(labels))
+
       notification.warning({
         top: 92,
-        message: this.state.dict['form.required.input'] + requireFields.map(item => item.label).join('銆�') + ' !',
+        message: this.state.dict['form.required.input'] + labels.join('銆�') + ' !',
         duration: 3
       })
       return
@@ -469,20 +472,22 @@
       _dataresource = '(' + _dataresource + ') tb'
     }
 
-    if (setting.queryType === 'statistics') { // 缁熻鏁版嵁婧愶紝鍐呭鏇挎崲
+    let regoptions = null
+    if (setting.queryType === 'statistics' || param.custom_script) {
       let allSearch = Utils.getAllSearchOptions(search)
 
-      let options = allSearch.map(item => {
+      regoptions = allSearch.map(item => {
         return {
           reg: new RegExp('@' + item.key + '@', 'ig'),
-          value: item.value
+          value: `'${item.value}'`
         }
       })
+    }
 
-      options.forEach(item => {
-        _dataresource = _dataresource.replace(item.reg, `'${item.value}'`)
+    if (setting.queryType === 'statistics') { // 缁熻鏁版嵁婧愶紝鍐呭鏇挎崲
+      regoptions.forEach(item => {
+        _dataresource = _dataresource.replace(item.reg, item.value)
       })
-
       _search = ''
     }
 
@@ -494,7 +499,28 @@
       DateCount = ''
     }
 
-    param.custom_script = Utils.formatOptions(param.custom_script)
+    if (param.custom_script) {
+      regoptions.push({
+        reg: new RegExp('@orderBy@', 'ig'),
+        value: _orderBy
+      })
+      if (setting.laypage !== 'false') {
+        regoptions.push({
+          reg: new RegExp('@pageSize@', 'ig'),
+          value: pageSize
+        }, {
+          reg: new RegExp('@pageIndex@', 'ig'),
+          value: pageIndex
+        })
+      }
+
+      regoptions.forEach(item => {
+        param.custom_script = param.custom_script.replace(item.reg, item.value)
+      })
+
+      param.custom_script = Utils.formatOptions(param.custom_script)
+    }
+
     param.LText = Utils.formatOptions(LText)
     param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
     param.secretkey = Utils.encrypt(param.LText, param.timestamp)

--
Gitblit v1.8.0