Skip to main content

表达式帮助文档

表达式简介

表达式根据函数或函数的组合改变值。

您可以将表达式用于工作流、页面或逻辑。表达式通常用于为特定活动或属性配置条件。比如,逻辑或工作流的决策元件都可以使用表达式写条件。

符号说明

符号功能案例
#引用变量#variable
.引用变量的属性#variable.attritube
+
-
*
/
>大于
>=大于等于
<小于
<=小于等于
==等于
!=不等于
&&并且x && y x 为真,并且 y 为真的情况下,结果为 true,否则 false
!否定!x 如果 x 为 true,则结果为 false,反之则为 true
()运算优先级
''表示字符串'hello, world'

函数说明

类别函数名返回类型描述

time.diffTimeVisual(timestamp)String将数字转换成可视化的时间,数字精确到毫秒:600000=》10 分钟
time.diff(after, before)Long返回 after 日期比 before 日期大多少秒值,可能会返回负数
time.format(localDateTime, format)String将时间类型的对象转换成指定格式的字符串
time.timestampFormat(timestamp)LocalDateTime将数字转换成日期,数字精确到毫秒:1649665042000=》2022-04-11 16:17:22
now()LocalDateTime获取当前时间
now(format)LocalDateTime按照指定格式,获取当前时间
startOfToday()LocalDateTime获取当前日期的开始时间
startOfWeek()LocalDateTime获取本周的开始时间
startOfMonth()LocalDateTime获取本月开始时间
endOfToday()LocalDateTime获取当前日期的最后时间
endOfWeek()LocalDateTime获取本周的最后时间
endOfMonth()LocalDateTime获取本月的最后时间
moveMinute(localDateTime, amount)LocalDateTime给定时间对象,按分钟级别做前后移动。例如 localDateTime = 2021-12-15 15:01:01, amount = -1,"
+ "结果返回 2021-12-15 15:00:01
moveHour(localDateTime, amount)LocalDateTime给定时间对象,按小时级别做前后移动。例如 localDateTime = 2021-12-15 15:01:01, amount = -1,结果返回 2021-12-15 14:01:01
moveDay(localDateTime, amount)LocalDateTime给定时间对象,按天级别做前后移动。例如 localDateTime = 2021-12-15 15:01:01, amount = -1,结果返回 2021-12-14 15:01:01
moveMonth(localDateTime, amount)LocalDateTime给定时间对象,按月级别做前后移动。例如 localDateTime = 2021-12-15 15:01:01, amount = -1,结果返回 2021-11-15 15:01:01
time.timestampFormat(timestamp)LocalDateTime将数字转换成日期,数字精确到毫秒:1649665042000=》2022-04-11 16:17:22
weekEnd(localDateTime, amount)LocalDateTime给定时间对象,获取移动数量的目标周结束时间。例如 localDateTime = 2022-06-09 15:37:00, amount = -1,结果返回 2022-06-05 23:59:59
weekStart(localDateTime, amount)LocalDateTime给定时间对象,获取移动数量的目标周开始时间。例如 localDateTime = 2022-06-09 15:37:00, amount = -1,结果返回 2022-05-30 00:00:00
time.timeZoneConvert(time, currentZoneId, targetZoneId)LocalDateTime将时间从当前的时区转换成目标时区对应的时间
time.convertToUTC(time)LocalDateTime将时间转换为 UTC 对应的时间,当前时间默认为操作人所在时区的时间
time.convertToUTC(time, currentZoneId)LocalDateTime将时间转换为 UTC 对应的时间
time.convertToCurrent(time)LocalDateTime将时间转换为当前操作人所在时区对应的时间,当前时间默认为 UTC 时间
time.convertToCurrent(time, originalZoneId)LocalDateTime将时间转换为操作人所在时区对应的时间
time.objectTimeZoneConvert(obj, currentZoneId, targetZoneId)Object 或 List将实体(实体集合)中的时间从当前的时区转换成目标时区对应的时间
time.objectConvertToUTC(obj)Object 或 List将实体(实体集合)中的时间转换成目标时区对应的时间,当前时间默认为操作人所在时区的时间
time.objectConvertToUTC(obj, currentZoneId)Object 或 List将实体(实体集合)中的时间转换成目标时区对应的时间
time.objectConvertToCurrent(obj)Object 或 List将实体(实体集合)中的时间转换成当前操作人所在时区对应的时间,当前时间默认为 UTC 时间
time.objectConvertToCurrent(obj, originalZoneId)Object 或 List将实体(实体集合)中的时间转换成当前操作人所在时区对应的时间


string.contains(father, child)Booleanfather 字符串是否包含 child 字符串
string.endsWith(father, end)Booleanfather 字符串是否以 end 字符串结尾
string.indexOf(father, child)Longchild 字符串在 father 字符串当中的开始位置
string.lastIndexOf(father, child)Longchild 字符串在 father 字符串当中的最后出现的位置
string.isBlank(str)Booleanstr 是空串,返回真
string.isNotBlank(str)Booleanstr 不是空串,返回真
string.join(target)String把 target 集合或者数组,按''拼接成一个字符串
string.join(target, split)String把 target 集合或者数组,按 split 拼接成一个字符串
string.length(target)Long返回 target 字符串的长度
string.replaceAll(target, regex, replacement)String把 target 字符串里面的满足 regex 条件的字符串,全部替换为 replacement 字符串,并返回一个新字符串
string.replaceFirst(target, regex, replacement)String把 target 字符串里面的满足 regex 条件的第一个字符串,替换为 replacement 字符串,并返回一个新字符串
string.split(target, regex, limit)Array把 target 字符串,按满足 regex 条件的子串,分割成最多 limit 个元素的数组
string.split(target, regex)Array把 target 字符串,按满足 regex 条件的子串,分割成数组
string.startsWith(father, start)Booleanfather 字符串是否以 start 字符串为开头
string.substring(target, beginIndex, endIndex)String从 target 字符串,按索引位置[beginIndex, endIndex),挑出一个子串并返回
string.substring(target, beginIndex)String从 target 字符串,从索引位置 beginIndex 开始,挑出一个子串并返回
string.trim(target)String去除 target 字符串的左右空格
string.bcrypt_hash('pw')String对明文 pw 字符串做 b 加密,并返回加密后的密文
string.bcrypt_match('pw', 'hash')Boolean使用 b 加密算法,判断明文 pw 字符串是否与密文 hash 字符串匹配
string.ChinaNumberFormat(number)Stringnumber=23648.68,返回'23,648.68'
string.ChinaNumberFormat(number, scale)Stringnumber=23648.687, scale=2,返回'23,648.69'
string.format(format, args)String字符串格式化,需要替换的字符占位符为 %s
string.toJson(obj)Stringobj 对象转换成 json 字符串
string.uuid()String返回 uuid

math.abs(number)Number计算给出数值的绝对值
math.ceil(number)Double返回大于或等于给出数值且等于数学整数的最小 double 值
math.cos(number)Double计算给出数值的余弦值
math.floor(number)Double返回小于或等于参数且等于数学整数的最大 double 精度值
math.log10(number)Double计算给出数值的以 10 为底的对数
math.log(number)Double计算给出数值的对数值
math.max(number1,number2)Double计算给出数值的最大值
math.min(number1,number2)Double计算给出数值的最小值
math.pageLimit(pageSize)Long分页返回的最大行数,默认为 10
math.pageOffset(pageNumber, pageSize)Long返回分页需跳过的记录数
math.pow(number1,number2)Double计算给出数值的参数次方值
math.round(number)Long计算给出数值四舍五入到最接近的 long 值
math.sin(number)Double计算给出数值的正弦值
math.sqrt(number)Double计算给出数值的开方值
math.tan(number)Double计算给出数值的正切值

seq.asc(domainObjectList, 'fieldName')List根据 domainObjectList 里面的 fieldName 升序
seq.desc(domainObjectList, 'fieldName')List根据 domainObjectList 里面的 fieldName 降序
seq.contains(collection, value)Boolean根据指定属性的值,判断是否包含在集合中,浮点数最大支持 9 位小数
seq.distinct(domainObjectList, 'fieldName')List根据 domainObjectList 里面的 fieldName 去重,默认保留最新的
seq.distinct(domainObjectList, 'fieldName1', 'fieldName2')List优先根据 domainObjectList 里面的 fieldName1 去重,其次根据 domainObjectList 里面的 fieldName2 去重,默认保留最新的
seq.filter(list, fieldName, value)List根据指定的属性和值,从集合中过滤出
seq.get(list, i)Object获取 list 中下标为 i 的元素
seq.isEmpty(seq)Boolean判断集合是否为空
seq.new()List创建一个空数组
seq.size(seq)Long返回集合内元素的个数
seq.toTree(domainObjectList, 'idFieldName', 'pIdFieldName', 'childFieldName')Listlist 集合转树
seq.toSimpleList(domainObjectList, 'fieldName')List抽取 domainObjectList 里面每一个对象的 fieldName 属性的值,组成一个新的集合


(轻应用版本
)
fileName(file)String获取 file 的文件名
system.httpHeader('key')String从请求头中获取 key 的值
system.cookie('key')String从 cookie 中获取 key 的值
isNotNull(obj)Boolean判断 obj 对象是否不为 null
isNull(obj)Boolean判断 obj 对象是否为 null
base64.encode(obj)String对明文 obj 做加密,并返回加密后的密文
downloadFile(url, fileName)File根据 url 下载文件
system.getRemoteIp()String获取当前请求的来源 ip
json 函数json.toJsonString(obj)String将 obj 转换为 jsonString
json.getByPath(json, expression)String根据 jsonpath 获取值
入参 json 可以为 json 的字符串,或者某个实体对象,或者实体集合
入参 expression 自行参考 JSONPath 语法规范
返回值为 String 类型,用户需要根据自己的实际需求使用创建变量,或复用对象,或复用集合 来转换为自己需要的值
环境变量env.getProperty(key)String根据环境变量编码 key 值,获取当前环境下变量的值

四、平台数据函数支持

类别函数名返回类型描述
用户platform.user.selectById(id)system$platform_user根据 ID 查询
Ex:
> platform.user.selectByIds(123)
platform.user.selectByIds(ids)List根据 ID 批量查询
Ex:
> platform.user.selectByIds(seq.new(123,234))
platform.user.selectOne(where)system$platform_user根据自定义条件查询一个
Ex:
> platform.user.selectOne(" full_name like '%www%' ")
platform.user.selectList(where)List根据自定义条件查询
Ex:
> platform.user.selectList(" full_name like '% 邓 %' ")
platform.user.selectList(where,limit,offset)List根据自定义条件查询
Ex:
> platform.user.selectList(" full_name like '% 邓 %' ",2,0)
platform.user.selectCount(where)Long根据自定义条件查询总数
Ex:
> platform.user.selectCount(" full_name like '% 邓 %' ")
platform.user.selectByField(field,value)List根据字段查询
Ex:
> platform.user.selectByField("phone_number","18626307244")
platform.user.selectByOrg(orgId/orgIds)List根据组织 ID 查询用户
Ex:
> platform.user.selectByOrg(3220931999319488)platform.user.selectByOrg(seq.new(3220931999319488,3220931999319479))
platform.user.selectByRole(roleId/roleIds)List根据角色 ID 查询用户
Ex:
> platform.user.selectByRole(3220931999319488)platform.user.selectByRole(seq.new(3220931999319488,3220931999319479))
platform.user.intersRoleCode(roleCode/roleCodeList)boolean判断当前用户的角色是否包含某角色编码
输入角色编码可以是单个,或者集合
Ex:
> platform.user.intersRoleCode('create_app')platform.user.intersRoleCode(seq.new('create_app','create_app2'))
platform.user.intersRoleCode(userId, roleCode/roleCodeList)boolean判断指定用户的角色是否包含某角色编码
输入角色编码可以是单个,或者集合
Ex:
> platform.user.intersRoleCode(1234,'create_app')platform.user.intersRoleCode(1234,seq.new('create_app','create_app2'))
角色platform.role.selectById(id)system$platform_role根据 ID 查询
Ex:
> platform.role.selectByIds(123)
platform.role.selectByIds(ids)List根据 ID 批量查询
Ex:
> platform.role.selectByIds(seq.new(123,234))
platform.role.selectOne(where)system$platform_role根据自定义条件查询一个
Ex:
> platform.role.selectOne(" role_name like '% 企业 %' ")
platform.role.selectList(where)List根据自定义条件查询
Ex:
> platform.role.selectList(" role_name like '% 企业 %' ")
platform.role.selectList(where,limit,offset)List根据自定义条件查询
Ex:
> platform.role.selectList(" role_name like '% 企业 %' ",2,0)
platform.role.selectCount(where)Long根据自定义条件查询总数
Ex:
> platform.role.selectCount(" role_name like '% 企业 %' ")
platform.role.selectByField(field,value)List根据字段查询
Ex:
> platform.role.selectByField("role_name","企业管理员")
platform.role.selectByOrg(orgId/orgIds)List根据组织 ID 查询角色
Ex:
> platform.role.selectByOrg(3220931999319488)platform.role.selectByOrg(seq.new(3220931999319488,3220931999319479))
platform.role.selectByUser(userId/userIds)List根据用户 ID 查询角色
Ex:
> platform.role.selectByUser(357)platform.role.selectByUser(seq.new(357,466))
组织platform.org.selectById(id)system$platform_organization根据 ID 查询
Ex:
> platform.org.selectByIds(123)
platform.org.selectByIds(ids)List根据 ID 批量查询
Ex:
> platform.org.selectByIds(seq.new(123,234))
platform.org.selectOne(where)system$platform_organization根据自定义条件查询一个
Ex:
> platform.org.selectOne(" org_name like '% 应用 %' ")
platform.org.selectList(where)List根据自定义条件查询
Ex:
> platform.org.selectList(" org_name like '% 应用 %' ")
platform.org.selectList(where,limit,offset)List根据自定义条件查询
Ex:
> platform.org.selectList(" org_name like '% 应用 %' ",2,0)
platform.org.selectCount(where)Long根据自定义条件查询总数
Ex:
> platform.org.selectCount(" org_name like '% 应用 %' ")
platform.org.selectByField(field,value)List根据字段查询
Ex:
> platform.org.selectByField("org_name","应用技术部")
platform.org.selectByRole(orgId/orgIds)List根据角色 ID 查询组织
Ex:
> platform.org.selectByRole(3220931999319488)platform.org.selectByRole(seq.new(3220931999319488,3220931999319479))
platform.org.selectByUser(userId/userIds)List根据用户 ID 查询组织
Ex:
> platform.org.selectByUser(357)platform.org.selectByUser(seq.new(357,466))

五、页面特有的表达式

内容组件对象通用函数组件实例属性
currentObject对象- 实体对应的属性、关联关系对象- 场景一:
基础组件放置到数据容器内部,#currentObject 指向当前上层的数据容器
例如:文本、表达式文本放置到数据视图里面,#currentObject 指向的是数据视图绑定的实体对象
#currentObject 与 #DataView_${code}对象拿到的数据一致
- 场景二:
当前配置的内容或者组件放置在集合数据容器内部,#currentObject 指向的是当前集合容器这一行的数据
例如:集合容器里面操作按钮处配置个删除按钮操作,删除按钮配置逻辑,将当前的这一行的数据传递给逻辑,配置为#currentObject,这一行的数据不是集合容器的数据,而是某一行上的行数据


searchObj对象查询字段
分页信息
场景一:
在有查询条件的数据表格中使用
检索容器的对象数据 & 集合容器的分页数据
DataView_${组件 code}数据视图对象- 实体对应的属性、关联关系对象当前数据视图绑定的实体对象
DataGrid_${组件 code}数据表格组件实例- selectDatas 对应实例 getSelectRows 方法返回值 当前选中的行数据
- selectDataKeys 对应实例 getSelectRowKeys 方法返回值 获取当前选中的行的主键 id 集合
- allSelectDatas 对应实例 getAllSelectRows 方法返回值 获取列表数据
- getAllDatas 获取数据表格数据源数据
可以根据数据表格实例暴露出来的方法,获取当前多选选中的数据,也可以获取到当前数据表格本身的集合数据
DataGridEdit_${组件 code}可编辑表格组件实例- selectDatas 对应实例 getSelectRows 方法返回值 当前选中的行数据
- selectDataKeys 对应实例 getSelectRowKeys 方法返回值 获取当前选中的行的主键 id 集合
- allSelectDatas 对应实例 getAllSelectRows 方法返回值 获取列表数据
- selectEditDatas 对应实例方法 getSelectEditRows 返回值,可编辑表格勾选的编辑数据,用于批量保存
- getEditDatas 对应实例方法 getTableLocalEditData 返回值,获取当前可编辑表格编辑列数据
- getAllDatas 对应实例方法 getTableLocalEditData 返回值,获取当前表格数据源数据
可编辑表格实例,主要暴露出选中行数据,选中编辑的数据,以及组件本身的集合数据
TreeTable_${组件 code}树表格组件实例- selectDatas 对应实例 getSelectRows 方法返回值 当前选中的行数据
- selectDataKeys 对应实例 getSelectRowKeys 方法返回值 获取当前选中的行的主键 id 集合
- allSelectDatas 对应实例 getAllSelectRows 方法返回值 获取列表数据
FilterContainer_${组件 code}检索容器对象- 外部检索容器对应的查询条件对象数据检索容器暴露出来的是内部的 getSearchData 方法函数
TabContainer_${组件 code}标签容器组件实例- activeKey当前标签容器选中的值
global.store.getUserInfo()通用方法- 登录用户数据获取当前登录的用户数据
global.store.userRole()通用方法- 登录用户的角色获取当前登录的用户的角色
timeFormat()通用方法格式化时间数据
timeFormat(#currentObject.xx, 'YYYY-MM-DD HH:mm')
更多格式 -- Moment.js 中文网 (momentjs.cn)
hasButtonPermission()通用方法基于条件定义组件可见性时使用,
注意:应用安全模式为【第三方管理】时使用,参考内置平台管理模组