APL函數(shù)代碼開(kāi)放場(chǎng)景-UI事件Java接口說(shuō)明
2024-12-30 09:18:33 271 本站
package fx.custom.apl.example.ui_event;
import com.fxiaoke.functions.FunctionContext;
import com.fxiaoke.functions.Fx;
import com.fxiaoke.functions.client.DebugHelper;
import com.fxiaoke.functions.model.Remind;
import com.fxiaoke.functions.template.IUIEventAction;
import com.fxiaoke.functions.ui.UIEvent;
import com.fxiaoke.functions.utils.Maps;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
public class UIEventExample implements IUIEventAction {
/**
* UI事件函數(shù)的運(yùn)行方法
*/
@Override
public UIEvent execute(FunctionContext context, Map<String, Object> args) {
UIEvent.Builder builder = UIEvent.Builder.create(context);
//把字段設(shè)置為只讀、隱藏
builder.editMasterFields("field_I18ri__c").readOnly(true).hidden(true);
//設(shè)置提醒消息
builder.remind(Remind.Text("彈窗提醒"));
//通過(guò)修改主對(duì)象
Map map = Maps.newHashMap();
map.put("field1", "value1");//設(shè)置字段1為value1
map.put("field2", "value2");//設(shè)置字段2為value2
map.put("field3", null);//清空字段
builder.editMaster(map);
//添加一條從對(duì)象,添加從對(duì)象,必須指定業(yè)務(wù)類(lèi)型,而且是當(dāng)前布局展示的業(yè)務(wù)類(lèi)型
//如果業(yè)務(wù)類(lèi)型不匹配.從對(duì)象無(wú)法添加
builder.addDetail("detailApiName")
.set(Maps.of("a", 1, "b", 2));
//根據(jù)條件刪除 從對(duì)象, 刪除為where中返回為true的從對(duì)象
builder.removeDetail("detailApiName")
.where(x -> ((Integer) x.get("a")) > 0);
// 根據(jù)條件編輯從對(duì)象 和上同理只會(huì)處理where 中返回為true的從對(duì)象數(shù)據(jù),where方法使用lambda表達(dá)式
builder.editDetail("detailApiName")
.set(Maps.of("a", 1, "b", 2))
.where(x -> ((Integer) x.get("a")) > 0);
//removeDetail和editDetail 都可以不添加where這樣會(huì)直接作用于所有數(shù)據(jù)
//set的內(nèi)容和editMaster的內(nèi)容要保證是map也就是key:valued的形式
builder.removeDetail("detailApiName");
builder.editDetail("detailApiName")
.set(Maps.of("a", 1, "b", 2));
// 將apiName為object_0uyAd__c的從對(duì)象隱藏(注:從對(duì)象隱藏后,保存數(shù)據(jù)時(shí)會(huì)將隱藏的從對(duì)象數(shù)據(jù)清空,切記謹(jǐn)慎使用,可通過(guò)keepData來(lái)自定義是否保留數(shù)據(jù)。默認(rèn)為false)
builder.editObject("object_0uyAd__c").hidden(true).keepData(true)
UIEvent event = builder.getUIEvent()
return event;
}
public static void main(String[] args) throws IOException {
//調(diào)試器
DebugHelper helper = new DebugHelper();
helper.init();
Map<String, Object> param = new HashMap<>();
//模擬調(diào)試的上下文,例如開(kāi)發(fā)時(shí)想模擬一個(gè)客戶(hù)對(duì)象的上下文,以方便開(kāi)發(fā)
FunctionContext context = helper.context("object_zBB6O__c", "63fd7a30ffd89f00013c7be3");
UIEvent execute = new UIEventExample().execute(context, param);
Fx.log.info(execute);
}}
部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),如有侵權(quán),請(qǐng)聯(lián)系客服刪除處理。