华为云测试区,租户:DWCK0420,作业入口:财务智管家-电汇收款
问题:想要实现点击excel导入按钮后,上传一个excel文件,依上传文件内容调用稳态api写入表数据,同时刷新表单,但目前按如下hooks代码编写后运行报错
代码如下:
// 获取组件实例
const excelImportButton = component.getComponentById('606389c2-1f5e-40a3-9c84-67db1662d241'); // EXCEL导入按钮的ID
// 调用API将本地Excel文件内容写入表数据
options.utils.espApi.getEspByActionId({
actionId: 'esp_t100.oapi.receipt.checking.excel.data.create', // API的ActionId
parameter: {
file: e.target.files[0] // 获取上传的Excel文件
},
businessUnit: options.context.businessUnit, // 业务单元
executeContext: options.context // 执行上下文
}).subscribe((res) => {
// 成功回调,刷新表格显示
const tableComponent = component.getComponentById('ef0d62fb-9158-41fe-8327-c85d14e68948'); // 获取表格组件实例
tableComponent.setTableData(res.data); // 设置表格数据
tableComponent.markForCheck(); // 手动触发变更检测
}, (err) => {
// 失败回调,打印错误信息
console.error('API调用失败:', err);
});
|
最佳答案
查看完整内容
你好,关于 导入文件 这个按钮;
目前需要 添加额外的配置:
json路径:
"extendedFields": {
"actionId": "esp_pdemo.dealwithproblem.create"
},
|