From 1e4a7720c748bc0206b02b30f4a2e0b3dafb54f3 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期一, 19 二月 2024 13:31:13 +0800
Subject: [PATCH] 2024-02-19

---
 src/templates/zshare/customscript/index.jsx |   26 ++------------------------
 1 files changed, 2 insertions(+), 24 deletions(-)

diff --git a/src/templates/zshare/customscript/index.jsx b/src/templates/zshare/customscript/index.jsx
index 856acc8..50e6ad5 100644
--- a/src/templates/zshare/customscript/index.jsx
+++ b/src/templates/zshare/customscript/index.jsx
@@ -7,7 +7,7 @@
 
 import Utils from '@/utils/utils.js'
 import Api from '@/api'
-import { checkSQL } from '@/utils/utils-custom.js'
+import { checkSQL, getSearchFields } from '@/utils/utils-custom.js'
 import CodeMirror from '@/templates/zshare/codemirror'
 import asyncComponent from '@/utils/asyncComponent'
 import MKEmitter from '@/utils/events.js'
@@ -93,31 +93,9 @@
   UNSAFE_componentWillMount() {
     const { searches, scripts, urlFields } = this.props
 
-    let _usefulFields = []
-    searches.forEach(item => {
-      if (['dateweek', 'datemonth'].includes(item.type)) {
-        _usefulFields.push(item.key)
-        _usefulFields.push(item.key + '1')
-      } else if (item.type === 'daterange') {
-        let _skey = item.key
-        let _ekey = item.key + '1'
-
-        if (/,/.test(item.key)) {
-          _skey = item.key.split(',')[0]
-          _ekey = item.key.split(',')[1]
-        }
-        _usefulFields.push(_skey)
-        _usefulFields.push(_ekey)
-      } else if (item.type === 'date' && _usefulFields.includes(item.key)) {
-        _usefulFields.push(item.key + '1')
-      } else {
-        _usefulFields.push(item.key.replace(/,/ig, ', '))
-      }
-    })
-
     this.setState({
       urlFields: urlFields ? urlFields.join(', ') : '',
-      usefulFields: _usefulFields.join(', '),
+      usefulFields: getSearchFields(searches),
       scripts: fromJS(scripts).toJS()
     })
   }

--
Gitblit v1.8.0