表单项更新
当表单中发生数据变更时,如果该表单项有绑定表单项更新,即可执行对应的脚本代码。脚本代码为异步脚本模式,根据返回值更新表单数据。
参数
| 名称 | 类型 | 描述 |
|---|---|---|
| context | IApiContext | 当前视图上下文 |
| params | IApiParams | 当前视图参数 |
| data | IApiData | 当前业务数据 |
| targetName | string | 部件名称 |
| view | IApiViewController | 当前视图 |
| ctrl | IApiControlController | 当前部件 |
| document | Document | 当前文档对象 |
| selector | (className: string) => HTMLCollectionOf<Element> | 元素选择器 |
| env | IEnvironment | 当前环境对象 |
| appSession | IApiData | 当前应用会话对象 |
| topViewSession | IApiData | 当前顶级视图会话对象 |
| viewSession | IApiData | 当前视图会话对象 |
| viewParam | IApiParams | |
| app | IApiAppHubController | 当前应用 |
| topView | IApiViewController | 当前顶级视图 |
| parentView | IApiViewController | undefined | 当前父视图 |
| parent | IApiViewController | undefined | 当前父视图 |
| util | { message: IApiMessageUtil, notification: IApiNotificationUtil,modal: IApiModalUtil,confirm: IApiConfirmUtil,openView: IApiOpenViewUtil} | 工具集 |
调用示例
基于当前数据根据业务计算新值
typescript
let estimated_workload = form_data.estimated_workload;
let remaining_workload = form_data.remaining_workload;
let estimated = 0; // 预估工时
if(estimated_workload){
estimated = Number(estimated_workload);
}
let actual = 0; // 已登记的实际工时
if(actual_workload){
actual = Number(actual_workload);
}
let remaining = 0;
if(remaining_workload){
remaining = Number(remaining_workload);
}
if((actual + remaining) != 0){ // 计算工时进度
let schedule = ((actual / (actual + remaining)) * 100).toFixed(1);
data.workload_schedule = schedule;
}
return data;