AmisRenderer embed 前注册自定义 amis 动作 replayScriptCommands: scriptCommands.translateCommands 把后端 facade 返回的 29 UI 动词指令 翻译成 amis 动作(show/hidden/static/setValue/setOptions/addOption/ toast/reload/...),逐条经 amis-core runActions 重放;带 componentId 者走组件级路由,componentId=大写列名与字段 name 天然对齐。 e2e(playwright,后端 8086 + dev):2 真实 FULL_AUTO facade-only 模板 - 福利保险结算单 inited → setFieldVisible 隐藏 BEGINDATE(截图留档) - 办公用品领用申请 change → bindField(getFieldValue) 回填 OLD_STORE_ID (服务端 getFieldValue 从 item 求值闭环,截图留档),2 passed。 测试:vitest scriptCommands 12 + registerReplayAction 4;tsc+build 全绿。 工具链:devDeps 加 vitest/jsdom/testing-library/playwright + test script。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
50 lines
1.1 KiB
JSON
50 lines
1.1 KiB
JSON
{
|
|
"type": "page",
|
|
"title": "办公用品领用申请(P4-5 脚本挂回 e2e)",
|
|
"body": {
|
|
"type": "form",
|
|
"title": "",
|
|
"wrapWithPanel": false,
|
|
"api": "/api/entity/OA_OFFICE_COLLARAPPLY/save",
|
|
"body": [
|
|
{
|
|
"type": "input-text",
|
|
"name": "STORE_ID",
|
|
"label": "仓库",
|
|
"id": "STORE_ID"
|
|
},
|
|
{
|
|
"type": "input-text",
|
|
"name": "OLD_STORE_ID",
|
|
"label": "原仓库(脚本回填)",
|
|
"id": "OLD_STORE_ID"
|
|
}
|
|
],
|
|
"onEvent": {
|
|
"change": {
|
|
"actions": [
|
|
{
|
|
"actionType": "ajax",
|
|
"api": {
|
|
"method": "post",
|
|
"url": "/api/script/execute-template",
|
|
"data": {
|
|
"templateId": "021e3ba7-e03a-412a-9f0e-c20ef440a885",
|
|
"seq": 2,
|
|
"item": "${&}"
|
|
}
|
|
},
|
|
"outputVar": "scriptResult2"
|
|
},
|
|
{
|
|
"actionType": "replayScriptCommands",
|
|
"args": {
|
|
"commands": "${event.data.scriptResult2.commands}"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
}
|
|
}
|