导出 Excel 操作,新建路由文件:/apis/utils.http.yao
代码如下:
{"name": "下载Excel","version": "1.0.0","description": "下载Excel","group": "utils","guard": "-","paths": [{"guard": "-","path": "/export/:name","method": "GET","process": "flows.utils.export","in": ["$param.name"],"out": {"status": 200,"type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","headers": {"Content-Disposition": "attachment;filename=导出数据.xlsx"}}}]}
新建文件:/flows/utils/export.flow.yao
代码如下:
{"label": "下载","version": "1.0.0","description": "下载","nodes": [{"name": "打印","process": "xiang.helper.Print","args": ["{{$in}}"]},{"name": "文件","process": "yao.table.export","args": ["{{$in.0}}", { "wheres": [{ "column": "id", "value": 1 }] }, 100]},{"name": "打印","process": "xiang.helper.Print","args": ["{{$res.文件}}"]},{"name": "数据","process": "fs.system.ReadFile","args": ["{{$res.文件}}", false]}],"output": "{{$res.数据.content}}"}
在/tables/ticket.tab.yao
的layout["filter"]["actions"]
数组中加入导出按钮
{"icon": "icon-plus","title": "导出","action": [{"name": "HistoryPush","type": "Common.historyPush","payload": {"pathname": "/api/utils/export/ticket","public": true}}]}
导出 Excel 操作,新建路由文件:/apis/utils.http.yao
代码如下:
{"name": "下载Excel","version": "1.0.0","description": "下载Excel","group": "utils","guard": "-","paths": [{"guard": "-","path": "/export/:name","method": "GET","process": "flows.utils.export","in": ["$param.name"],"out": {"status": 200,"type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","headers": {"Content-Disposition": "attachment;filename=导出数据.xlsx"}}}]}
新建文件:/flows/utils/export.flow.yao
代码如下:
{"label": "下载","version": "1.0.0","description": "下载","nodes": [{"name": "打印","process": "xiang.helper.Print","args": ["{{$in}}"]},{"name": "文件","process": "yao.table.export","args": ["{{$in.0}}", { "wheres": [{ "column": "id", "value": 1 }] }, 100]},{"name": "打印","process": "xiang.helper.Print","args": ["{{$res.文件}}"]},{"name": "数据","process": "fs.system.ReadFile","args": ["{{$res.文件}}", false]}],"output": "{{$res.数据.content}}"}
在/tables/ticket.tab.yao
的layout["filter"]["actions"]
数组中加入导出按钮
{"icon": "icon-plus","title": "导出","action": [{"name": "HistoryPush","type": "Common.historyPush","payload": {"pathname": "/api/utils/export/ticket","public": true}}]}