From 920e94fc5483b081b3d43c86df8f56d838f2f14d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期六, 06 一月 2024 22:07:15 +0800
Subject: [PATCH] 2024-01-06

---
 src/templates/sharecomponent/searchcomponent/searchform/index.jsx |  144 +++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 124 insertions(+), 20 deletions(-)

diff --git a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx
index 34b71e8..21a7065 100644
--- a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx
+++ b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx
@@ -6,14 +6,14 @@
 
 import { dateOptions, matchReg, formRule } from '@/utils/option.js'
 import Utils from '@/utils/utils.js'
+import { checkSQL } from '@/utils/utils-custom.js'
 import CodeMirror from '@/templates/zshare/codemirror'
 import asyncComponent from '@/utils/asyncComponent'
 import './index.scss'
 
 const ColorSketch = asyncComponent(() => import('@/mob/colorsketch'))
-const FieldsTable = asyncComponent(() => import('@/templates/zshare/modalform/fieldtable'))
-const DataTable = asyncComponent(() => import('@/templates/zshare/modalform/datatable'))
 const EditTable = asyncComponent(() => import('@/templates/zshare/modalform/modaleditable'))
+const FieldsTable = asyncComponent(() => import('@/templates/zshare/editTable'))
 
 const groupOptions = [
   {
@@ -98,10 +98,10 @@
 
 const searchTypeOptions = {
   text: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'inputType', 'advanced', 'query', 'labelwidth'],
-  select: ['label', 'field', 'resourceType', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'setAll', 'dropdown', 'query', 'labelwidth'],
-  radio: ['label', 'field', 'resourceType', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'setAll', 'query', 'labelwidth'],
+  select: ['label', 'field', 'resourceType', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'dropdown', 'query', 'labelwidth'],
+  radio: ['label', 'field', 'resourceType', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'query', 'labelwidth'],
   multiselect: ['label', 'field', 'resourceType', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'query', 'labelwidth'],
-  link: ['label', 'field', 'resourceType', 'initval', 'type', 'linkField', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'setAll', 'dropdown', 'query', 'labelwidth'],
+  link: ['label', 'field', 'resourceType', 'initval', 'type', 'linkField', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'dropdown', 'query', 'labelwidth'],
   date: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'query', 'precision', 'labelwidth'],
   checkcard: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'resourceType', 'display', 'width', 'multiple', 'required', 'Hide', 'labelShow', 'advanced', 'query', 'labelwidth'],
   dateweek: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'required', 'Hide', 'labelShow', 'advanced', 'query', 'labelwidth'],
@@ -190,6 +190,14 @@
       }
     } else if (type === 'checkcard') {
       reRequired.fields = false
+      reOptions.multiple = [{
+        value: 'false',
+        text: '鍗曢��'
+      }, {
+        value: 'true',
+        text: '澶氶��'
+      }]
+
       if (this.record.display === 'picture') {
         if (this.record.resourceType === '0') {        // 鑷畾涔夎祫婧�
           shows.push('options', 'fields', 'picratio')
@@ -203,6 +211,20 @@
           shows.push('dataSource', 'cardValField', 'colorField', 'fields', 'orderBy', 'orderType', 'database')
         }
       } else {
+        let appType = sessionStorage.getItem('appType')
+        if (appType === '') {
+          reOptions.multiple = [{
+            value: 'false',
+            text: '鍗曢��'
+          }, {
+            value: 'true',
+            text: '澶氶��'
+          }, {
+            value: 'dropdown',
+            text: '涓嬫媺鑿滃崟'
+          }]
+        }
+
         reRequired.fields = true
         if (this.record.resourceType === '0') {        // 鑷畾涔夎祫婧�
           shows.push('options', 'fields', 'selectStyle', 'border')
@@ -218,6 +240,10 @@
       }
       shows.push('linkField')
       reRequired.linkField = false
+    } else if (type === 'daterange') {
+      if (this.record.initval) {
+        shows.push('dateShift')
+      }
     }
 
     if (dateOptions.hasOwnProperty(type)) { // 鏍规嵁鎼滅储鏉′欢绫诲瀷锛岄�夋嫨鍒濆鍊肩殑绫诲瀷鍙婃暟鎹�
@@ -230,6 +256,7 @@
       reTypes.initval = 'text'
     }
 
+    reTooltip.match = ''
     if (type === 'text') {
       reOptions.match = matchReg.class1
     } else if (type === 'multiselect') {
@@ -241,7 +268,8 @@
     } else if (type === 'date') {
       reOptions.match = matchReg.class4
     } else if (type === 'datemonth') {
-      reOptions.match = matchReg.class5
+      reTooltip.match = '鍖归厤妯″紡涓� between 鏃讹紝鎼滅储鏉′欢涓哄ぇ浜庢湀鍒濆皬浜庢湀鏈紝鍖归厤妯″紡涓� = 鏃讹紝鎼滅储鏉′欢涓虹瓑浜庡綋鍓嶆湀锛圷YYY-MM锛夈��'
+      reOptions.match = matchReg.class6
     } else if (type === 'dateweek' || type === 'daterange' || type === 'range') {
       reOptions.match = matchReg.class5
     } else if (type === 'checkcard') {
@@ -257,9 +285,30 @@
 
     if (type === 'text' || type === 'select') {
       reTooltip.field = '瀛楁鍚嶅彲浠ヤ娇鐢ㄩ�楀彿鍒嗛殧锛岃繘琛岀患鍚堟悳绱€��'
+    } else if (type === 'daterange') {
+      reTooltip.field = '瀛楁鍚嶅彲浠ヤ娇鐢ㄩ�楀彿鍒嗛殧锛屼緥濡俿tartTime,endTime銆�'
     } else if (type === 'group') {
       reTooltip.field = '鏌ヨ鏁版嵁鏃讹紙鑷畾涔夎剼鏈垨缁熻鏁版嵁婧愶級锛岀被鍨嬪瓧娈靛皢鐢ㄤ綔鏇挎崲鑴氭湰涓殑 @瀛楁@ 锛岀被鍨嬪瓧娈靛搴斿�间负锛氭棩 -> day锛涘懆 -> week锛涙湀 -> month锛涘 -> quarter锛涘勾 -> year锛涜嚜瀹氫箟 -> customized'
       reLabel.field = '绫诲瀷瀛楁'
+    }
+
+    reTooltip.initval = ''
+    if (type === 'select') {
+      if (this.record.resourceType === '0') {
+        reTooltip.initval = '鍒濆鍊煎簲涓烘暟鎹殑Value鍊硷紝鍙娇鐢ˊusername@銆丂fullName@'
+      } else if (this.record.resourceType === '1') {
+        reTooltip.initval = '鍒濆鍊煎簲涓恒�婂�悸峰瓧娈点�嬬殑鍊硷紝鍙娇鐢ˊusername@銆丂fullName@銆�$first銆傛敞锛氫娇鐢�$first鏃讹紝鎼滅储鏉′欢搴斾负蹇呭~銆�'
+      }
+    } else if (type === 'link') {
+      if (this.record.resourceType === '0') {
+        reTooltip.initval = '鍒濆鍊煎簲涓烘暟鎹殑Value鍊笺��'
+      } else if (this.record.resourceType === '1') {
+        reTooltip.initval = '鍒濆鍊煎簲涓恒�婂�悸峰瓧娈点�嬬殑鍊硷紝鍙娇鐢�$first銆傛敞锛氫娇鐢�$first鏃讹紝鎼滅储鏉′欢搴斾负蹇呭~銆�'
+      }
+    } else if (type === 'text') {
+      reTooltip.initval = '鍙娇鐢ˊusername@銆丂fullName@銆�'
+    } else if (type === 'range') {
+      reTooltip.initval = '浣跨敤閫楀彿鎷兼帴锛屼緥濡� 3,10'
     }
 
     return {
@@ -347,6 +396,9 @@
         this.record.match = 'like'
         _fieldval.match = 'like'
       }
+    } else if (key === 'display') {
+      this.record.multiple = 'false'
+      _fieldval.multiple = 'false'
     } else if (key === 'items') {
       let _initval = this.props.form.getFieldValue('initval')
       if (_initval && !value.includes(_initval[0])) {
@@ -461,9 +513,9 @@
         rules = [
           { required: item.required, message: '璇疯緭鍏�' + item.label + '!' }
         ]
-        if (item.key === 'field' || item.key === 'datefield') {
+        if (item.key === 'field' || item.key === 'datefield' || item.key === 'dateShift') {
           rules.push({
-            pattern: (type === 'text' || type === 'select') ? formRule.field.multipattern : formRule.field.pattern,
+            pattern: (type === 'text' || type === 'select' || type === 'daterange') ? formRule.field.multipattern : formRule.field.pattern,
             message: formRule.field.message
           }, {
             max: formRule.field.max,
@@ -550,12 +602,45 @@
         let type = this.record.type
         
         if (type !== 'checkcard') {
-          content = <EditTable type={type} module="search" transfield={{}} linkSubFields={[]} onChange={this.changeOptions}/>
+          let columns = []
+
+          if (type === 'link') {
+            columns.push({ title: 'ParentID', key: 'ParentID', strict: true })
+          }
+
+          columns.push({ title: 'Value', key: 'Value', strict: true })
+          columns.push({ title: 'Text', key: 'Text' })
+
+          content = <EditTable columns={columns} module="search" onChange={this.changeOptions}/>
         } else {
           if (this.record.linkField) {
             type = 'link'
           }
-          content = <DataTable type={type} multiple={this.record.multiple} display={this.record.display} linkSubFields={[]} transfield={{}} fields={this.record.fields || []} onChange={this.changeOptions}/>
+
+          let columns = []
+          let fields = this.record.fields || []
+          let keys = ['ParentID', 'pid']
+
+          if (type === 'link') {
+            columns.push({ title: 'ParentID', key: 'ParentID', strict: true })
+          } else if (this.record.multiple === 'dropdown' && this.record.display === 'text') {
+            columns.push({ title: 'pid', key: 'pid', strict: true })
+          }
+          columns.push({ title: 'Value', key: '$value', strict: true })
+
+          if (this.record.display === 'picture') {
+            columns.push({ title: 'url', key: '$url', type: 'file' })
+          } else if (this.record.display === 'color') {
+            columns.push({ title: 'Color', key: '$color' })
+            extra = <span>浣跨敤鍗佸叚杩涘埗鑹插僵浠g爜锛圚EX锛夋椂锛岃鍦ㄨ壊鍊煎墠娣诲姞 #</span>
+          }
+
+          fields.forEach(item => {
+            keys.push(item.field)
+            columns.push({ title: item.field, key: item.field })
+          })
+
+          content = <EditTable columns={columns} onChange={this.changeOptions}/>
         }
       } else if (item.type === 'fields') {
         span = 24
@@ -565,7 +650,7 @@
           { required: item.required, message: '璇锋坊鍔�' + item.label + '!' }
         ]
 
-        content = <FieldsTable onChange={this.changeField}/>
+        content = <FieldsTable indexShow={false} actions={['edit', 'move', 'del', 'add']} columns={item.columns} data={this.record.fields || []} onChange={this.changeField}/>
       } else if (item.type === 'checkbox') {
         rules = [
           { required: item.required, message: '璇烽�夋嫨' + item.label + '!' }
@@ -619,6 +704,32 @@
       this.props.form.validateFieldsAndScroll((err, values) => {
         if (!err) {
           values.uuid = this.props.card.uuid
+
+          if (/,/.test(values.field)) {
+            values.field = values.field.split(',').filter(Boolean)
+            if (values.type === 'daterange' && values.field.length > 2) {
+              values.field.length = 2
+            }
+            values.field = values.field.join(',')
+          }
+
+          if (['select', 'link'].includes(values.type)) {
+            if (values.resourceType === '1') {
+              if (/\$first/.test(values.initval) && values.initval.replace(/\s/g, '') === '$first') {
+                values.initval = '$first'
+              }
+
+              if (values.initval === '$first' && values.required !== 'true') {
+                notification.warning({
+                  top: 92,
+                  message: '浣跨敤$first鏃讹紝鎼滅储鏉′欢搴斾负蹇呭~锛�',
+                  duration: 5
+                })
+                return
+              }
+            }
+          }
+
           // 涓嬫媺鑿滃崟鎴栬仈鍔ㄨ彍鍗�
           if (['multiselect', 'select', 'link', 'radio'].includes(values.type)) {
             if (values.resourceType === '0') {
@@ -760,16 +871,9 @@
             }
           })
 
-          let error = Utils.verifySql(values.dataSource)
+          let pass = checkSQL(values.dataSource)
 
-          if (error) {
-            notification.warning({
-              top: 92,
-              message: '鏁版嵁婧愪腑涓嶅彲浣跨敤' + error,
-              duration: 5
-            })
-            return
-          }
+          if (!pass) return
 
           resolve(values)
         } else {

--
Gitblit v1.8.0