- 我想使用JS获取当前页面的信息,比如ID,料号这些,用什么方法,有没有此类方法的文档,请教一下大家遇到这些问题都是怎么找到对应的方法的
看下文档
这个我试了很久,发现获得当前区块的值我都找到方法了,但是找其他区块的值,或者我如果是点击上一个页面,但是下一个页面想获取我点击的那一行数据的值,有封装方法可以获取吗 ?找了很久没找到
这两个能否拿到数据
ctx.resource:集合级上下文的数据资源(如表格工具栏,含getSelectedRows()、refresh()等);ctx.record:记录级上下文的当前行记录(如表格行按钮);
const popupRecord = await ctx.resolveJsonTemplate(‘{{ ctx.popup.record }}’);
获取当前弹窗的值,解决了,太不容易了,附上折腾的时候,学到的js,供大家参考,给大家节省点事件
- 关闭当前页面
ctx.view.close() - // 获取弹窗中的记录
const popupRecord = await ctx.resolveJsonTemplate(‘{{ ctx.popup.record }}’); - // 或者直接访问特定字段
const productId = await ctx.resolveJsonTemplate(‘{{ ctx.popup.record.id }}’);
const productCode = await ctx.resolveJsonTemplate(‘{{ ctx.popup.record.product_code }}’); - // 获取当前资源对象
const resource = ctx.resource; - // 获取选中的行
const selectedRows = ctx.resource?.getSelectedRows?.() || ; - // 获取所有数据(如果是列表资源)
const allData = ctx.resource?.getData?.() || ; - // 获取元数据(分页信息等)
const meta = ctx.resource?.getMeta?.(); - // 处理选中行
if (selectedRows.length > 0) {
const ids = selectedRows.map(row => row.id).join(', ');
ctx.message.success(已选中 ${selectedRows.length} 行,ID: ${ids});
} else {
ctx.message.warning(‘请至少选择一行数据’);
} - 获取当前行,当前区块的数据
const currentRecord = ctx.record; - 获取用户信息
const currentUser = await ctx.resolveJsonTemplate(‘{{ ctx.user }}’);
const currentRole = await ctx.resolveJsonTemplate(‘{{ ctx.role }}’); - // 渲染到界面
ctx.element.innerHTML = displayContent;
12 // 显示成功消息
ctx.message.success(‘成功获取区块值’);



