From c8804ceb1fe2dea76f9949c5ea04423876ee2c81 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 28 六月 2024 14:02:47 +0800 Subject: [PATCH] 2024-06-28 --- src/templates/sharecomponent/searchcomponent/searchform/index.jsx | 150 ++++++++++++++++++++++++++++++++++--------------- 1 files changed, 104 insertions(+), 46 deletions(-) diff --git a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx index f0139ed..f093777 100644 --- a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx +++ b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx @@ -6,13 +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 EditTable = asyncComponent(() => import('@/templates/zshare/modalform/modaleditable')) +const FieldsTable = asyncComponent(() => import('@/templates/zshare/editTable')) const groupOptions = [ { @@ -97,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'], @@ -109,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 { @@ -233,12 +234,19 @@ if (this.record.selectStyle === 'custom') { shows.push('backgroundColor') } - if (this.record.multiple === 'dropdown' && this.record.resourceType === '1') { - shows.push('mark', 'parentField') + 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)) { // 鏍规嵁鎼滅储鏉′欢绫诲瀷锛岄�夋嫨鍒濆鍊肩殑绫诲瀷鍙婃暟鎹� @@ -251,6 +259,7 @@ reTypes.initval = 'text' } + reTooltip.match = '' if (type === 'text') { reOptions.match = matchReg.class1 } else if (type === 'multiselect') { @@ -259,10 +268,18 @@ 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') { @@ -283,6 +300,25 @@ } 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 { @@ -487,7 +523,7 @@ 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' || type === 'daterange') ? formRule.field.multipattern : formRule.field.pattern, message: formRule.field.message @@ -562,16 +598,18 @@ { 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 @@ -606,6 +644,7 @@ 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 => { @@ -617,20 +656,19 @@ } } 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" @@ -640,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 = [ @@ -654,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 @@ -684,6 +722,23 @@ 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 + } + } } // 涓嬫媺鑿滃崟鎴栬仈鍔ㄨ彍鍗� @@ -780,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, @@ -827,16 +892,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