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 | 64 +++++++++++++++++++++++++------- 1 files changed, 50 insertions(+), 14 deletions(-) diff --git a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx index 4e27e1d..21a7065 100644 --- a/src/templates/sharecomponent/searchcomponent/searchform/index.jsx +++ b/src/templates/sharecomponent/searchcomponent/searchform/index.jsx @@ -6,6 +6,7 @@ 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' @@ -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'], @@ -239,6 +240,10 @@ } shows.push('linkField') reRequired.linkField = false + } else if (type === 'daterange') { + if (this.record.initval) { + shows.push('dateShift') + } } if (dateOptions.hasOwnProperty(type)) { // 鏍规嵁鎼滅储鏉′欢绫诲瀷锛岄�夋嫨鍒濆鍊肩殑绫诲瀷鍙婃暟鎹� @@ -251,6 +256,7 @@ reTypes.initval = 'text' } + reTooltip.match = '' if (type === 'text') { reOptions.match = matchReg.class1 } else if (type === 'multiselect') { @@ -262,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') { @@ -283,6 +290,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 +513,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 @@ -687,6 +713,23 @@ 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') { @@ -828,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