From 2ae980243b7ad705dea575eadcfc4cf4e24073bd Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 17 五月 2022 22:57:19 +0800
Subject: [PATCH] Merge branch 'master' into positec

---
 src/templates/sharecomponent/settingcomponent/settingform/index.jsx |  105 +++++++++++++++++++++++++++++++++-------------------
 1 files changed, 67 insertions(+), 38 deletions(-)

diff --git a/src/templates/sharecomponent/settingcomponent/settingform/index.jsx b/src/templates/sharecomponent/settingcomponent/settingform/index.jsx
index 0ad95b9..b60fc7f 100644
--- a/src/templates/sharecomponent/settingcomponent/settingform/index.jsx
+++ b/src/templates/sharecomponent/settingcomponent/settingform/index.jsx
@@ -20,7 +20,8 @@
     dict: PropTypes.object,         // 瀛楀吀椤�
     menu: PropTypes.object,         // 鑿滃崟淇℃伅
     config: PropTypes.object,       // 椤甸潰閰嶇疆淇℃伅
-    search: PropTypes.array         // 鎼滅储鏉′欢
+    search: PropTypes.array,        // 鎼滅储鏉′欢
+    updRecord: PropTypes.func
   }
 
   state = {
@@ -85,7 +86,7 @@
     status.requestMode = status.requestMode || 'system'
     status.procMode = status.procMode || 'script'
     status.callbackType = status.callbackType || 'script'
-    let regoptions = Utils.getRegOptions(search)
+    let regoptions = this.getRegOptions(search)
 
     if (config.urlFields && config.urlFields.length > 0) {
       config.urlFields.forEach(field => {
@@ -126,6 +127,62 @@
       cbScripts: _cbScripts,
       status
     })
+  }
+
+  componentDidMount () {
+    this.props.updRecord(this.state.status)
+  }
+
+  getRegOptions = (searches) => {
+    if (!searches || searches.length === 0) return []
+
+    let options = []
+    let fieldmap = new Map()
+    searches.forEach(search => {
+      let item = {
+        key: search.field,
+        value: '0'
+      }
+
+      if (fieldmap.has(item.key)) {
+        item.key = item.key + '1'
+      }
+
+      fieldmap.set(item.key, true)
+
+      if (search.type === 'group') {
+        options.push({
+          key: search.field,
+          value: '0'
+        })
+        options.push({
+          key: search.datefield,
+          value: '0'
+        })
+        options.push({
+          key: search.datefield + '1',
+          value: '0'
+        })
+        options.push(item)
+      } else if (['datemonth', 'dateweek', 'daterange'].includes(search.type)) {
+        options.push(item)
+        options.push({
+          key: item.key + '1',
+          value: '0'
+        })
+      } else if (search.type === 'text' || search.type === 'select') {
+        item.key.split(',').forEach(field => {
+          let cell = JSON.parse(JSON.stringify(item))
+          cell.key = field
+
+          options.push(cell)
+        })
+      } else {
+        options.push(item)
+      }
+    })
+
+    return options
   }
 
   /**
@@ -205,26 +262,6 @@
     if (activeKey === 'setting') {
       return new Promise((resolve, reject) => {
         this.settingForm.handleConfirm().then(res => {
-          if (trigger === 'func' && res.interType !== 'inner') {
-            notification.warning({
-              top: 92,
-              message: '浣跨敤鍐呴儴鎺ュ彛锛屾墠鍙互鍒涘缓瀛樺偍杩囩▼锛�',
-              duration: 5
-            })
-            this.setState({loading: false})
-            reject()
-            return
-          } else if (trigger === 'interface' && res.interType !== 'system') {
-            notification.warning({
-              top: 92,
-              message: '浣跨敤绯荤粺鎺ュ彛鏃讹紝鎵嶅彲浠ュ垱寤烘帴鍙o紒',
-              duration: 5
-            })
-            this.setState({loading: false})
-            reject()
-            return
-          }
-
           this.setState({
             setting: res
           }, () => {
@@ -243,23 +280,13 @@
       })
     } else if (activeKey === 'scripts') {
       return new Promise((resolve, reject) => {
-        if (trigger === 'func' && setting.interType !== 'inner') {
-          notification.warning({
-            top: 92,
-            message: '浣跨敤鍐呴儴鎺ュ彛锛屾墠鍙互鍒涘缓瀛樺偍杩囩▼锛�',
-            duration: 5
-          })
+        this.sqlverify(() => {
+          this.setState({loading: false})
+          resolve({...setting, scripts, preScripts, cbScripts})
+        }, () => {
           this.setState({loading: false})
           reject()
-        } else {
-          this.sqlverify(() => {
-            this.setState({loading: false})
-            resolve({...setting, scripts, preScripts, cbScripts})
-          }, () => {
-            this.setState({loading: false})
-            reject()
-          }, 'submit')
-        }
+        }, 'submit')
       })
     } else {
       this.setState({loading: false})
@@ -467,7 +494,9 @@
   }
 
   updateStatus = (status) => {
-    this.setState({status: {...this.state.status, ...status}})
+    let _status = {...this.state.status, ...status}
+    this.setState({status: _status})
+    this.props.updRecord(_status)
   }
 
   render() {

--
Gitblit v1.8.0