From 4d6b9f8a2d7b316633e43b489eae9ada949c07b5 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期二, 10 九月 2024 10:18:08 +0800
Subject: [PATCH] Merge branch 'master' into positec

---
 src/templates/sharecomponent/searchcomponent/searchform/index.jsx |  253 ++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 193 insertions(+), 60 deletions(-)

diff --git a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx
index 9cb4ffc..c2871bb 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 = [
   {
@@ -84,9 +84,12 @@
       {value: '[3, 0]', label: '杩戜笁澶�'},
       {value: '[7, 0]', label: '杩戜竷澶�'},
       {value: '[30, 0]', label: '杩�30澶�'},
+      {value: '[90, 0]', label: '杩�90澶�'},
       {value: '[7, -7]', label: '鍓嶅悗涓冨ぉ'},
       {value: '[30, -30]', label: '鍓嶅悗30澶�'},
       {value: '[90, -90]', label: '鍓嶅悗90澶�'},
+      {value: '[180, -180]', label: '鍓嶅悗180澶�'},
+      {value: '[365, -365]', label: '鍓嶅悗365澶�'},
       {value: '[-1, -1]', label: '鏄庡ぉ'},
       {value: '[-2, -2]', label: '鍚庡ぉ'}
     ]
@@ -95,9 +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'],
+  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'],
@@ -106,7 +110,7 @@
   group: ['label', 'type', 'field', 'datefield', 'initval', 'blacklist', 'ratio', 'items', 'required', 'labelShow', 'query', 'labelwidth'],
   switch: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'openVal', 'closeVal', 'openText', 'closeText', 'Hide', 'labelShow', 'advanced', 'query', 'labelwidth'],
   check: ['label', 'field', 'initval', 'type', 'match', 'ratio', 'blacklist', 'openVal', 'closeVal', 'checkTip', 'Hide', 'labelShow', 'advanced', 'query', 'labelwidth'],
-  range: ['label', 'type', 'field', 'initval', 'match', 'blacklist', 'Hide', 'required', 'maxValue', 'minValue', 'step', 'labelShow', 'query', 'labelwidth']
+  range: ['label', 'type', 'field', 'initval', 'match', 'ratio', 'blacklist', 'Hide', 'required', 'maxValue', 'minValue', 'step', 'labelShow', 'query', 'labelwidth', 'advanced']
 }
 
 class MainSearch extends Component {
@@ -117,11 +121,7 @@
   }
 
   state = {
-    openType: null,          // 鎼滅储鏉′欢鏄剧ず绫诲瀷
-    resourceType: null,      // 涓嬫媺鎼滅储鏃讹紝閫夐」鏉ユ簮绫诲瀷
-    formlist: null,          // 琛ㄥ崟
-    cFields: [],
-    textTooltip: '瀛楁鍚嶅彲浠ヤ娇鐢ㄩ�楀彿鍒嗛殧锛岃繘琛岀患鍚堟悳绱�',
+    formlist: null
   }
 
   record = {}
@@ -181,7 +181,7 @@
     let reRequired = {}
     let reLabel = {}
 
-    if (['multiselect', 'select', 'link'].includes(type)) {
+    if (['multiselect', 'select', 'link', 'radio'].includes(type)) {
       reRequired.linkField = true
       if (this.record.resourceType === '0') {        // 鑷畾涔夎祫婧�
         shows.push('options')
@@ -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,18 +211,42 @@
           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')
+          shows.push('options', 'fields', 'selectStyle', 'border')
         } else if (this.record.resourceType === '1') { // 鏁版嵁婧�
-          shows.push('dataSource', 'cardValField', 'fields', 'orderBy', 'orderType', 'database', 'selectStyle')
+          shows.push('dataSource', 'cardValField', 'fields', 'orderBy', 'orderType', 'database', 'selectStyle', 'border')
         }
         if (this.record.selectStyle === 'custom') {
           shows.push('backgroundColor')
         }
+        if (this.record.multiple === 'dropdown') {
+          shows.push('mark')
+          if (this.record.resourceType === '1') {
+            shows.push('parentField')
+          }
+        }
       }
       shows.push('linkField')
       reRequired.linkField = false
+    } else if (type === 'daterange' || type === 'datemonth') {
+      if (this.record.initval) {
+        shows.push('dateShift')
+      }
     }
 
     if (dateOptions.hasOwnProperty(type)) { // 鏍规嵁鎼滅储鏉′欢绫诲瀷锛岄�夋嫨鍒濆鍊肩殑绫诲瀷鍙婃暟鎹�
@@ -227,6 +259,7 @@
       reTypes.initval = 'text'
     }
 
+    reTooltip.match = ''
     if (type === 'text') {
       reOptions.match = matchReg.class1
     } else if (type === 'multiselect') {
@@ -235,14 +268,22 @@
       reOptions.match = matchReg.class1
     } else if (type === 'switch' || type === 'check') {
       reOptions.match = matchReg.class2
+      if (type === 'switch') {
+        reLabel.openVal = '寮�鍚��'
+        reLabel.closeVal = '鍏抽棴鍊�'
+      } else {
+        reLabel.openVal = '鍕鹃�夊��'
+        reLabel.closeVal = '涓嶅嬀閫夊��'
+      }
     } 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') {
-      if (this.record.multiple === 'false') {
+      if (this.record.multiple === 'false' || this.record.multiple === 'dropdown') {
         reOptions.match = matchReg.class1
       } else if (this.record.multiple === 'true') {
         reOptions.match = matchReg.class3
@@ -254,9 +295,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 {
@@ -317,7 +379,7 @@
               uuid: key
             }]
           }
-        } else if (['multiselect', 'select', 'link'].includes(value)) {
+        } else if (['multiselect', 'select', 'link', 'radio'].includes(value)) {
           if (!this.record.options[0].Text && this.record.fields.length > 0) {
             let field = this.record.fields[0].field
     
@@ -344,6 +406,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])) {
@@ -458,9 +523,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,
@@ -485,7 +550,7 @@
             <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />
           </AutoComplete>
         } else {
-          content = <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} />
+          content = <Input placeholder="" autoComplete="off" onPressEnter={this.handleSubmit} onChange={(e) => {this.optionChange(item.key, e.target.value)}}/>
         }
       } else if (item.type === 'number') {
         rules = [
@@ -533,43 +598,77 @@
           { required: item.required, message: '璇疯緭鍏�' + item.label + '!' }
         ]
         span = 24
-        className = 'text-area'
 
         if (this.record.type === 'select' || this.record.type === 'link') {
           extra = <span className="add-resource-empty" onClick={this.handleEmpty}>鍏ㄩ儴</span>
+        }
+        if (item.placeholder) {
+          className = 'show-public-var'
+          extra = <><span className="resource-public-var">{item.placeholder}</span>{extra}</>
         }
 
         content = <CodeMirror />
       } else if (item.type === 'options') {
         span = 24
-        className = 'text-area'
 
         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} 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
-        className = 'text-area'
 
         rules = [
           { 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 + '!' }
         ]
 
         content = <Checkbox.Group style={{width: '105%'}} options={item.options} onChange={(values) => this.optionChange(item.key, values)}/>
-      } else if (item.type === 'multiselect') { // 澶氶��
+      } else if (item.type === 'multiselect') {
         content = <Select
           showSearch
           mode="multiple"
@@ -579,8 +678,8 @@
             <Select.Option id={i} key={i} value={option.value}>{option.text}</Select.Option>
           )}
         </Select>
-      } else if (item.type === 'cascader') { // 澶氶��
-        content = <Cascader options={item.options} placeholder="" />
+      } else if (item.type === 'cascader') {
+        content = <Cascader options={item.options} />
       } else if (item.type === 'color') {
         className = 'color-form-item'
         rules = [
@@ -593,7 +692,7 @@
       fields.push(
         <Col span={span} key={index}>
           <Form.Item className={className} extra={extra} label={item.tooltip ?
-            <Tooltip placement="topLeft" title={item.tooltip}>
+            <Tooltip placement="topLeft" title={<div onClick={(e) => e.stopPropagation()}>{item.tooltip}</div>}>
               <QuestionCircleOutlined className="mk-form-tip" />
               {item.label}
             </Tooltip> : item.label
@@ -616,8 +715,34 @@
       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'].includes(values.type)) {
+          if (['multiselect', 'select', 'link', 'radio'].includes(values.type)) {
             if (values.resourceType === '0') {
               values.options = values.options || []
               values.dataSource = ''
@@ -663,10 +788,15 @@
               values.options = []
             }
           } else if (values.type === 'checkcard') {
+            if (values.multiple === 'dropdown' && values.display !== 'text') {
+              values.multiple = 'false'
+            }
+
             if (values.resourceType === '0') {
               values.options = values.options || []
               values.options = values.options.map(m => {
                 m.ParentID = m.ParentID || ''
+                m.pid = m.pid || ''
                 return m
               })
 
@@ -705,35 +835,45 @@
 
           if (values.type === 'range') {
             let error = ''
-            if (values.maxValue <= values.minValue) {
-              error = '鏈�澶у�煎繀椤诲ぇ浜庢渶灏忓��'
-            } else if (values.step <= 0) {
-              error = '姝ラ暱蹇呴』澶т簬0'
-            } else {
-              let s = (values.maxValue - values.minValue) / values.step
-              if (s !== parseInt(s)) {
-                error = '姝ラ暱蹇呴』琚� (max - min) 鏁撮櫎'
+            if (sessionStorage.getItem('appType') === 'mob') {
+              if (values.maxValue <= values.minValue) {
+                error = '鏈�澶у�煎繀椤诲ぇ浜庢渶灏忓��'
+              } else if (values.step <= 0) {
+                error = '姝ラ暱蹇呴』澶т簬0'
+              } else {
+                let s = (values.maxValue - values.minValue) / values.step
+                if (s !== parseInt(s)) {
+                  error = '姝ラ暱蹇呴』琚� (max - min) 鏁撮櫎'
+                }
               }
-            }
 
-            if (!error && values.initval) {
+              if (!error && values.initval) {
+                let vals = values.initval.split(',')
+                if (vals.length !== 2) {
+                  error = '鍒濆鍊艰缃敊璇紒'
+                } else if (isNaN(parseFloat(vals[0])) || isNaN(parseFloat(vals[1]))) {
+                  error = '鍒濆鍊艰缃敊璇紒'
+                } else {
+                  let start = parseFloat(vals[0])
+                  let end = parseFloat(vals[1])
+                  let s = (values.maxValue - start) / values.step
+                  let e = (values.maxValue - end) / values.step
+                  if (start > end || start < values.minValue || end > values.maxValue) {
+                    error = '鍒濆鍊艰缃敊璇紒'
+                  } else if (s !== parseInt(s) || e !== parseInt(e)) {
+                    error = '鍒濆鍊艰缃敊璇紒'
+                  }
+                }
+              }
+            } else if (values.initval) {
               let vals = values.initval.split(',')
               if (vals.length !== 2) {
                 error = '鍒濆鍊艰缃敊璇紒'
               } else if (isNaN(parseFloat(vals[0])) || isNaN(parseFloat(vals[1]))) {
                 error = '鍒濆鍊艰缃敊璇紒'
-              } else {
-                let start = parseFloat(vals[0])
-                let end = parseFloat(vals[1])
-                let s = (values.maxValue - start) / values.step
-                let e = (values.maxValue - end) / values.step
-                if (start > end || start < values.minValue || end > values.maxValue) {
-                  error = '鍒濆鍊艰缃敊璇紒'
-                } else if (s !== parseInt(s) || e !== parseInt(e)) {
-                  error = '鍒濆鍊艰缃敊璇紒'
-                }
               }
             }
+
             if (error) {
               notification.warning({
                 top: 92,
@@ -748,20 +888,13 @@
 
           ['linkField', 'valueField', 'valueText', 'orderBy'].forEach(item => {
             if (values[item]) {
-              values[item] = values[item].replace(/\s* | \t* | \v* | \r*/ig, '')
+              values[item] = values[item].replace(/\s+|\t+|\v+|\r+/ig, '')
             }
           })
 
-          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