-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Open
Labels
Description
描述问题:
Office Viewer 组件数据来源于上层的service组件,service组件接口返回的数据有两层,一层是主表单数据,还有一层是带子表需要行循环的数据,表格行循环时,如果有与主表单中同名变量,它会优先取主表单中的变量值,没有取行内本身的变量值。
截图或视频:

如何复现(请务必完整填写下面内容):
-
你是如何使用 amis 的?
sdk
-
amis 版本是什么?请先在最新 beta 版本测试问题是否存在
6.13.0,6.3.0 -
粘贴有问题的完整
amis schema
代码:
{
"type": "service",
"body": [
{
"type": "action",
"label": "打印",
"onEvent": {
"click": {
"actions": [
{
"actionType": "print",
"componentId": "office-viewer-print"
}
]
}
}
},
{
"type": "office-viewer",
"id": "office-viewer-print",
"src": `/service/api/print-template/getDocxFile/${printId}`,
"wordOptions": {
"enableVar": true,
"padding": paddings,
"bulletUseFont": false,
"ignoreWidth": ignore_width,
"padding": padding,
"page": false,
"pageBackground": page_background,
"pageShadow": page_shadow,
"pageWrap": page_wrap,
"pageWrapBackground": page_wrap_background,
"zoom": zoom,
"zoomFitWidth": zoom_fit_width
},
"visibleOn": "${__visible}"
}
],
"id": "u:0a327ee48444",
"messages": {
},
"api": {
"url": `/service/api/print-template/queryPrintRecords/${printId}`,
"method": "post",
"messages": {
},
"requestAdaptor": "",
"adaptor": "",
"headers": {
"Authorization": "Bearer ${context.tenantId},${context.authToken}"
},
"data": {
"filters": "${filters}"
}
}
}
- 操作步骤
如上schema所示,Office Viewer 组件数据来源于上层的service组件/service/api/print-template/queryPrintRecords/${printId}接口,这个接口返回的数据示例:
{
"name": "a8666",
"created": "2025-07-08 14:02",
"created_by": "YLH1",
"bool__c": "",
"txt__c": "",
"field_types": [
{
"name": "a",
"f0a9rn": "YLH1",
"fa8yjq": "aaa",
"created": "2025-09-30 13:30",
"created_by": "YLH1"
},
{
"name": "BB",
"f0a9rn": "YLH1==",
"fa8yjq": "aaa===",
"created": "2025-10-02 09:27",
"created_by": "YLH1"
}
]
}
最终显示结果,可以看到行循环的数据name取了主表中的name变量值,created也一样。
