diff --git a/src/components/DesignForm/formControlAttr.vue b/src/components/DesignForm/formControlAttr.vue index 07c8737..f538c99 100644 --- a/src/components/DesignForm/formControlAttr.vue +++ b/src/components/DesignForm/formControlAttr.vue @@ -3858,21 +3858,23 @@ const disabledIstrue = (val:string) => {
当满足以下条件时此控件隐藏
-
+
-
+
  • 请从左侧面板右击选择字段或选项
  • 支持的符号:'==', '>=', '>', '<=', '<', '!='
  • 支持"包含,不包含,当前用户"关键字,用于组织机构条件和角色条件
  • 参考举例:
  • 年龄>10
    - 企管部包含当前用户 + 企管部包含当前用户
    + 绩效考核执行人包含当前用户
    + 张三!=当前用户
@@ -3970,21 +3972,23 @@ const disabledIstrue = (val:string) => {
仅可选择符合以下条件的数据
-
+
-
+
  • 请从左侧面板右击选择字段或选项
  • 支持的符号:'==', '>=', '>', '<=', '<', '!='
  • 支持"包含,不包含,当前用户"关键字,用于组织机构条件和角色条件
  • 参考举例:
  • 年龄>10
    - 企管部包含当前用户 + 企管部包含当前用户
    + 绩效考核执行人包含当前用户
    + 张三!=当前用户
diff --git a/src/components/DesignForm/formControlPropertiNew.vue b/src/components/DesignForm/formControlPropertiNew.vue index 8930b93..84c7f19 100644 --- a/src/components/DesignForm/formControlPropertiNew.vue +++ b/src/components/DesignForm/formControlPropertiNew.vue @@ -3913,21 +3913,23 @@ const disabledIstrue = (val:string) => {
当满足以下条件时此控件隐藏
-
+
-
+
  • 请从左侧面板右击选择字段或选项
  • 支持的符号:'==', '>=', '>', '<=', '<', '!='
  • 支持"包含,不包含,当前用户"关键字,用于组织机构条件和角色条件
  • 参考举例:
  • 年龄>10
    - 企管部包含当前用户 + 企管部包含当前用户
    + 绩效考核执行人包含当前用户
    + 张三!=当前用户
@@ -4025,22 +4027,23 @@ const disabledIstrue = (val:string) => {
仅可选择符合以下条件的数据
-
+
-
+
  • 请从左侧面板右击选择字段或选项
  • -
  • 支持英文模式下运算符
  • - -
  • 支持"包含,不包含"关键字,用于组织机构条件和角色条件
  • -
  • 支持"当前用户"关键字,用于角色条件
  • -
  • 参考场景:
  • - 仅可选择关联表单中年龄大于10的数据,则可将数据范围设置为:年龄>10 +
  • 支持的符号:'==', '>=', '>', '<=', '<', '!='
  • +
  • 支持"包含,不包含,当前用户"关键字,用于组织机构条件和角色条件
  • +
  • 参考举例:
  • + 年龄>10
    + 企管部包含当前用户
    + 绩效考核执行人包含当前用户
    + 张三!=当前用户
diff --git a/src/components/DesignForm/public/form/form.vue b/src/components/DesignForm/public/form/form.vue index 197d0aa..2ddf3db 100644 --- a/src/components/DesignForm/public/form/form.vue +++ b/src/components/DesignForm/public/form/form.vue @@ -11,6 +11,7 @@ import FormGroup from '@/components/DesignForm/public/form/formGroup.vue' import { FormData,FormList,FormDataStyle } from '@/api/DesignForm/types' import { getRequest } from '@/api/DesignForm' +import request from '@/utils/request'; import { useRoute, useRouter } from 'vue-router' import { constGetControlByName, @@ -177,7 +178,7 @@ const forEachGetFormModel = (list: FormList[], obj: any) => { } } }) - showOrHide() + showOrHide("onMounted") } function arrayEqual(a: string[], b: any[]) { @@ -407,6 +408,10 @@ const recursionToGetFinallyHideFields = (hideFieldArr: any[],radioSelectArr3: st if(formProps.value.type!=5){ //console.log(hideFieldArr) props.formData.config.hideField?.push(...hideFieldArr)//实际造成隐藏效果 + + + + } }); @@ -418,16 +423,17 @@ if(formProps.value.type!=5){ } + // 表单组件值改变事件 tProp为子表格相关 provide(constControlChange, ({ key, value, data, tProp, type, attribute }: any) => { - // console.log("表单组件值改变事件----------1--------->",key) - // console.log("表单组件值改变事件----------2--------->",value) - // console.log("表单组件值改变事件----------3--------->",data) - // console.log("表单组件值改变事件----------4--------->",tProp) - // console.log("表单组件值改变事件----------5--------->",type) - // console.log("表单组件值改变事件----------6--------->",attribute) - // console.log("表单组件值改变事件----------11--------->",model.value) + /* console.log("表单组件值改变事件----------1--------->",key) + console.log("表单组件值改变事件----------2--------->",value) + console.log("表单组件值改变事件----------3--------->",data) + console.log("表单组件值改变事件----------4--------->",tProp) + console.log("表单组件值改变事件----------5--------->",type) + console.log("表单组件值改变事件----------6--------->",attribute) + console.log("表单组件值改变事件----------11--------->",model.value) */ let fieldVal = {} for(let i in model.value){ if(i == key){ @@ -493,7 +499,7 @@ provide(constControlChange, ({ key, value, data, tProp, type, attribute }: any) } // }) - showOrHide() + showOrHide(data) if (typeof props.changeKeyVal === 'function') { props.changeKeyVal(key, value,type,attribute) @@ -524,8 +530,114 @@ provide(constControlChange, ({ key, value, data, tProp, type, attribute }: any) */ }) +let mustBeHidden: any = [] +function showOrHide (data:any){ + //console.log(data) + + /* + 企管部有当前用户, + 当前用户是什么权限角色. + 某表单某字段值大于等于小于不等于某个值 + + 所需接口 + 接口1:当前用户是不是指定的权限角色 + 接口2:当前用户是否在指定的机构下或机构的祖先机构下 + 接口3:本表单(关联关联表单的表单)的某字段的当前值大于等于小于不等于指定的值???也许不需要接口呢? + + */ + + //关联表单隐藏条件判定 start + for(let i = 0; i < props.formData.list.length; i++){ + if(props.formData.list[i].type=="associatedForms"&&formProps.value.type!=5){ + //console.log(props.formData.list[i].name) + let asfHideCondition = props.formData.list[i].control.hideGongShi.mathsFormula + const leftOperatorsAndRight = splitString(asfHideCondition) + + if(leftOperatorsAndRight){ + + + let leftArr = leftOperatorsAndRight.left.split(":") + //console.log(leftArr) + if(data=="onMounted"||(leftArr[0]=="formField"&&leftArr.length==3)){ + if(data=="onMounted"||(data!="kong"&&data.name==leftArr[2])){//关联表单隐藏相关的值发生了变化 + + if(leftOperatorsAndRight.operator=="包含"){ + + if(leftOperatorsAndRight.right=="当前用户"){ + + if(leftOperatorsAndRight.left.startsWith("orgOrPerson")){ + //接口2 + + queryIfOrgOrPerson(leftOperatorsAndRight).then(({ data }) => { + if(data==true){ + props.formData.config.hideField = addStringIfNotExists(props.formData.config.hideField,props.formData.list[i].name) + mustBeHidden.push(props.formData.list[i].name) + } + }); + + }else if(leftOperatorsAndRight.left.startsWith("roleid")){ + //接口1 + } + } + }else if(leftOperatorsAndRight.operator=="不包含"){ + + if(leftOperatorsAndRight.right=="当前用户"){ + + if(leftOperatorsAndRight.left.startsWith("orgOrPerson")){ + + //接口2 + queryIfOrgOrPerson(leftOperatorsAndRight).then(({ data }) => { + if(data==false){ + props.formData.config.hideField = addStringIfNotExists(props.formData.config.hideField,props.formData.list[i].name) + mustBeHidden.push(props.formData.list[i].name) + } + }); + }else if(leftOperatorsAndRight.left.startsWith("roleid")){ + //接口1 + } + } + }else{ + //console.log(leftOperatorsAndRight) + if(leftOperatorsAndRight.right=="当前用户"){ + + if(leftOperatorsAndRight.operator=="=="){ + //接口2 + queryIfOrgOrPerson(leftOperatorsAndRight).then(({ data }) => { + if(data==true){ + props.formData.config.hideField = addStringIfNotExists(props.formData.config.hideField,props.formData.list[i].name) + mustBeHidden.push(props.formData.list[i].name) + } + }); + }else if(leftOperatorsAndRight.operator=="!="){ + //接口2 + queryIfOrgOrPerson(leftOperatorsAndRight).then(({ data }) => { + if(data==true){ + props.formData.config.hideField = addStringIfNotExists(props.formData.config.hideField,props.formData.list[i].name) + mustBeHidden.push(props.formData.list[i].name) + } + }); + } + }else{ + //接口3 + console.log(1) + } + } + } + } + + + + + + + } + } + } + + //关联表单隐藏条件判定 end + + -function showOrHide (){ //liwenxuan 关联选项设置效果实现 start /* console.log("监听表单-1-constControlChange-->",props.formData) console.log("监听表单-2-constControlChange-->",key) @@ -766,14 +878,11 @@ function showOrHide (){ hideFieldArr = recursionToGetFinallyHideFields(hideFieldArr,radioSelectArr3,defaultHideFields) } hideFieldArr = recursionToGetFinallyHideFields(hideFieldArr,radioSelectArr3,defaultHideFields) - - - - - - + props.formData.config.hideField?.push(...mustBeHidden) + + @@ -785,6 +894,46 @@ function showOrHide (){ //console.log("监听表单--constControlChange-->",key, value, data, tProp,type,attribute)//liwenxuan } + +function removeDuplicates(arr:any) { + //alert(1) + return arr.reduce((accumulator: any[], currentValue: any) => { + if (!accumulator.includes(currentValue)) { + accumulator.push(currentValue); + } + return accumulator; + }, []); +} + +function addStringIfNotExists(arr: string[], str: string) { + if (!arr.includes(str)) { + arr.push(str); + } + return arr; +} + +function queryIfOrgOrPerson(obj: { left: string; operator: string; right: string }) { + + return request({ + url: '/javasys/lowCode/AssociatedForms/queryIfOrgOrPerson', + method: 'post', + data: obj, + }); +} + +function splitString(str:string) { + const operators = ['==', '>', '>=', '<', '<=', '!=', '不包含' ,'包含']; + for (let operator of operators) { + if (str.includes(operator)) { + let index = str.indexOf(operator); + let left = str.slice(0, index).trim(); + let right = str.slice(index + operator.length).trim(); + return { left,operator, right }; + } + } + //return { left: str, right: '' }; +} + const dictForm = computed(() => { const storage = window.localStorage.getItem('akFormDict') let storageDict = {} @@ -1238,7 +1387,7 @@ onMounted(() => { nextTick(() => { appendRemoveStyle(true) }) - showOrHide() + showOrHide("kong") }) onUnmounted(() => { if (eventName) { diff --git a/src/widget/associatedforms/associatedFormsTinyace.vue b/src/widget/associatedforms/associatedFormsTinyace.vue index 471642e..b24d7fd 100644 --- a/src/widget/associatedforms/associatedFormsTinyace.vue +++ b/src/widget/associatedforms/associatedFormsTinyace.vue @@ -18,7 +18,7 @@ const tinymceInit = { language_url: "/tinymce/langs/zh-Hans.js", // 引入语言包(该语言包在public下,注意文件名称) language: "zh-Hans", // 这里名称根据 zh-Hans.js 里面写的名称而定 skin_url: "/tinymce/skins/ui/oxide", // 这里引入的样式 - height: 174, // 限制高度 + height: 164, // 限制高度 statusbar:false, toolbar:false, branding: false, //是否禁用“Powered by TinyMCE” @@ -87,10 +87,10 @@ watch(()=>tinymceHtml.value, (val:any) => { errorCondition("不允许出现多个蓝色块") }else if(!containsSingleComparator(gongShi.mathsFormula)&&!gongShi.mathsFormula.includes("包含")&&!gongShi.mathsFormula.includes("不包含")){ - errorCondition("不存在有效符号") + errorCondition("不存在有效符号或关键字") }else if(checkEnding(gongShi.mathsFormula)){ - errorCondition("不能以符号为结尾") + errorCondition("不能以符号或关键字为结尾") }else{ succCondition() } @@ -169,7 +169,7 @@ function errorCondition(str:string){ ElMessage.closeAll() ElMessage({ showClose: true, - message: '条件格式错误 : '+str+' , 正确条件格式如 : 年龄==10', + message: '条件格式错误 : '+str/* +' , 正确条件格式如 : 年龄==10' */, type: 'error', duration:3500, }) diff --git a/src/widget/associatedforms/associatedFormsTinyaceRange.vue b/src/widget/associatedforms/associatedFormsTinyaceRange.vue index e73b9c5..00708fb 100644 --- a/src/widget/associatedforms/associatedFormsTinyaceRange.vue +++ b/src/widget/associatedforms/associatedFormsTinyaceRange.vue @@ -17,7 +17,7 @@ const tinymceInit = { language_url: "/tinymce/langs/zh-Hans.js", // 引入语言包(该语言包在public下,注意文件名称) language: "zh-Hans", // 这里名称根据 zh-Hans.js 里面写的名称而定 skin_url: "/tinymce/skins/ui/oxide", // 这里引入的样式 - height: 174, // 限制高度 + height: 164, // 限制高度 statusbar:false, toolbar:false, branding: false, //是否禁用“Powered by TinyMCE” @@ -86,10 +86,10 @@ watch(()=>tinymceHtml.value, (val:any) => { errorCondition("不允许出现多个蓝色块") }else if(!containsSingleComparator(gongShi.mathsFormula)&&!gongShi.mathsFormula.includes("包含")&&!gongShi.mathsFormula.includes("不包含")){ - errorCondition("不存在有效符号") + errorCondition("不存在有效符号或关键字") }else if(checkEnding(gongShi.mathsFormula)){ - errorCondition("不能以符号为结尾") + errorCondition("不能以符号或关键字为结尾") }else{ succCondition() }