表达式帮助文档
一、表达式简介
表达式根据函数或函数的组合改变值。
您可以将表达式用于工作流、页面或逻辑。表达式通常用于为特定活动或属性配置条件。比如,逻辑或工作流的决策元件都可以使用表达式写条件。
二、符号说明
符号 | 功能 | 案例 |
---|---|---|
# | 引用变量 | #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) | Boolean | father 字符串是否包含 child 字符串 |
string.endsWith(father, end) | Boolean | father 字符串是否以 end 字符串结尾 | |
string.indexOf(father, child) | Long | child 字符串在 father 字符串当中的开始位置 | |
string.lastIndexOf(father, child) | Long | child 字符串在 father 字符串当中的最后出现的位置 | |
string.isBlank(str) | Boolean | str 是空串,返回真 | |
string.isNotBlank(str) | Boolean | str 不是空串,返回真 | |
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) | Boolean | father 字符串是否以 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) | String | number=23648.68,返回'23,648.68' | |
string.ChinaNumberFormat(number, scale) | String | number=23648.687, scale=2,返回'23,648.69' | |
string.format(format, args) | String | 字符串格式化,需要替换的字符占位符为 %s | |
string.toJson(obj) | String | obj 对象转换成 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') | List | list 集合转树 | |
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() | 通用方法 | 基于条件定义组件可见性时使用, 注意:应用安全模式为【第三方管理】时使用,参考内置平台管理模组 |