全局
函数使得全局的状态管理和数据处理变得轻松且高效。
重置表单的值
使用方法
ctx.reset(); // 全部重置为默认值
ctx.reset({
[dataBind]: newValue,
[instanceId]: newValue,
}); // 指定的字段重置为指定值,其余字段重置为默认值
示例
ctx.reset();
ctx.reset({
"flow_purchase.ID": "新id",
"flow_purchase.pur_number": 10,
});
表单全局提交
提交未经验证的数据
ctx.getValue()
提交经过验证的数据
ctx.submit()
使用方法
危险
注意:submit() 会触发表单的验证,如果表单验证不通过,将不会提交数据。
ctx
.submit()
.then(() => {})
.catch((e) => {});
表单全局 loading 状态
提示
已经上线
loading(loading: boolean): () => void
示例
// 打开loading
const closeLoading = ctx.loading(true);
// 关闭loading
ctx.loading(false);
// 或
closeLoading();
在点击按钮时,打开 3 秒的 loading
module.exports = function (params, ctx, block) {
const closeLoading = ctx.loading();
setTimeout(() => {
closeLoading();
}, 3000);
};