你好,
1、后端一定要支持这些字段的模糊查询
2、可通过hooks实现,示例代码如下:
第一个hooks 添加在 文本输入框上 类型如下:
01
代码如下:
// 获取当前组件的实例
const control = component.getControl(); // 获取当前组件的Control实例
const currentValue = control.value; // 获取当前组件的值
options.dataStore.set('search_info',currentValue) //获取到的数据塞到上下文中
第二个hooks 添加在按钮上,类型如下:
02
代码如下:
// 获取当前组件实例的代理对象
const componentInstance = component.getComponentById('a5a804b3-c56e-4ac3-b3c0-6f2b9bd76579'); // 表格组件实例ID 换成自己的表格id
// 获取表格组件实例
const tableComponent = componentInstance.getComponentById('a5a804b3-c56e-4ac3-b3c0-6f2b9bd76579'); // 表格组件实例ID 换成自己的表格id
// 获取文本输入组件的值
const inputValue = options.dataStore.get('search_info'); // 从上下文中获取文本输入组件的值
// 组装条件
const search_info = {
"test_demo_data":{ // 这里换成你们自己的查询条件业务字段
"task_name":inputValue,
"task_no":inputValue
}
};
// 获取当前业务单元信息
const businessUnit = options.context.businessUnit;
// 调用 esp 接口
options.utils.espApi.getEspByActionId({
actionId: 'esp_pdemo.test.demo.data.get', // 替换为实际的actionId
parameter: search_info,
businessUnit: businessUnit,
executeContext: options.context
}).subscribe((response) => {
// 更新表格数据
tableComponent.setTableData(response.data); // 假设接口返回的数据在response.data中
tableComponent.markForCheck(); // 手动触发变更检测
}, (error) => {
console.error('调用ESP接口失败', error); // 打印错误信息
});
|