Prechádzať zdrojové kódy

Merge branch 'master' of http://111.75.220.136:10030/13246659623/jxyh

sbtjtserver/zhaoxh 5 mesiacov pred
rodič
commit
edbaacac52

+ 556 - 0
src/main/java/kd/fi/er/formplugin/mobile/TripReqSectionEx.java

@@ -0,0 +1,556 @@
+package kd.fi.er.formplugin.mobile;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.util.Date;
+import java.util.EventObject;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Objects;
+import java.util.TreeMap;
+import kd.bos.bill.AbstractMobBillPlugIn;
+import kd.bos.dataentity.entity.DynamicObject;
+import kd.bos.dataentity.entity.DynamicObjectCollection;
+import kd.bos.dataentity.resource.ResManager;
+import kd.bos.entity.cache.RedisModelCache;
+import kd.bos.entity.datamodel.IDataModel;
+import kd.bos.entity.datamodel.IRefrencedataProvider;
+import kd.bos.entity.datamodel.ListSelectedRowCollection;
+import kd.bos.entity.datamodel.events.AfterDeleteRowEventArgs;
+import kd.bos.entity.datamodel.events.ChangeData;
+import kd.bos.entity.datamodel.events.PropertyChangedArgs;
+import kd.bos.form.ConfirmCallBackListener;
+import kd.bos.form.FormShowParameter;
+import kd.bos.form.IFormView;
+import kd.bos.form.IMobileView;
+import kd.bos.form.MessageBoxOptions;
+import kd.bos.form.MessageBoxResult;
+import kd.bos.form.cardentry.CardEntry;
+import kd.bos.form.control.Control;
+import kd.bos.form.control.events.ClickListener;
+import kd.bos.form.events.AfterDoOperationEventArgs;
+import kd.bos.form.events.BeforeClosedEvent;
+import kd.bos.form.events.ClosedCallBackEvent;
+import kd.bos.form.events.MessageBoxClosedEvent;
+import kd.bos.form.field.DateTimeEdit;
+import kd.bos.form.field.FieldEdit;
+import kd.bos.form.field.MulBasedataEdit;
+import kd.fi.er.business.servicehelper.CommonServiceHelper;
+import kd.fi.er.business.utils.AmountUtils;
+import kd.fi.er.business.utils.ErCommonUtils;
+import kd.fi.er.business.utils.ErStdConfig;
+import kd.fi.er.business.utils.SystemParamterUtil;
+import kd.fi.er.business.utils.TripBillTravelerUtils;
+import kd.fi.er.common.ShowPageUtils;
+import kd.fi.er.formplugin.budget.BudgetCommonUtil;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.ObjectUtils;
+
+public class TripReqSectionEx extends AbstractMobBillPlugIn implements ClickListener {
+    public TripReqSectionEx() {
+    }
+
+    public void registerListener(EventObject e) {
+        this.addClickListeners(new String[]{"btn_save", "btn_addsection"});
+        IFormView view = this.getView();
+        MulBasedataEdit travelersF7 = (MulBasedataEdit)this.getControl("travelers");
+        DynamicObject company = (DynamicObject)view.getParentView().getModel().getValue("company");
+        DynamicObject org = (DynamicObject)view.getParentView().getModel().getValue("org");
+        TripBillTravelerUtils.getF7FilterInfo(company, org, travelersF7);
+    }
+
+    public void afterCreateNewData(EventObject e) {
+        super.afterCreateNewData(e);
+        FormShowParameter param = this.getView().getFormShowParameter();
+        IDataModel model = this.getModel();
+        IFormView parentView = this.getView().getParentView();
+        IDataModel parentModel = parentView.getModel();
+        model.setValue("currency", ErCommonUtils.getPk(parentModel.getValue("currency")));
+        model.setValue("billstatus", parentModel.getValue("billstatus"));
+        CoreBaseBillEdit coreBaseBillEdit = new CoreBaseBillEdit();
+        Boolean isCurrency = coreBaseBillEdit.refreshIsCurrency(parentModel);
+        model.setValue("iscurrency", isCurrency);
+        model.setValue("istravelers", parentModel.getValue("istravelers"));
+        model.setValue("isloan", parentModel.getValue("isloan"));
+        model.setValue("ismulwayto", parentModel.getValue("ismulwayto"));
+        model.setValue("bizdate", parentModel.getValue("bizdate"));
+        CommonServiceHelper.setMulWayToVisible(parentModel, this.getView());
+        if (param.getCustomParam("entryedit") != null) {
+            this.getView().setVisible(false, new String[]{"btn_addsection"});
+            int index = (Integer)param.getCustomParam("index");
+            DynamicObject dobject = parentModel.getEntryRowEntity("tripentry", index);
+            DynamicObjectCollection dc = model.getEntryEntity("tripentry");
+            dc.add(dobject);
+            model.setValue("index", index + 1, 0);
+        } else {
+            Long cityId = ((IMobileView)this.getView()).getCurrentCityId();
+            int rowIndex = model.createNewEntryRow("tripentry");
+            Object to = param.getCustomParam("to");
+            Object date = param.getCustomParam("enddate");
+            if (null != to) {
+                cityId = Long.valueOf(to.toString());
+            }
+
+            if (null != date) {
+                model.setValue("startdate", date, 0);
+            }
+
+            model.setValue("from", cityId, 0);
+            int count = parentModel.getEntryRowCount("tripentry");
+            model.setValue("index", count + 1, rowIndex);
+            this.initTripEntryDefaultData(model, rowIndex);
+            Object currencyId = ErCommonUtils.getPk(parentModel.getValue("currency"));
+            model.setValue("rcurrency", currencyId, rowIndex);
+            model.setValue("tripcurrency", currencyId, rowIndex);
+            Long[] applierIds = new Long[]{ErCommonUtils.getPk(parentModel.getValue("applier"))};
+            model.setValue("travelers", applierIds, rowIndex);
+            model.setValue("entrycostdept", parentModel.getValue("costdept"), rowIndex);
+            model.setValue("entrycostcompany", parentModel.getValue("costcompany"), rowIndex);
+            model.setValue("std_entrycostcenter", parentModel.getValue("std_costcenter"), rowIndex);
+            model.setValue("company", parentModel.getValue("company"), rowIndex);
+        }
+
+    }
+
+    public void afterBindData(EventObject e) {
+        super.afterBindData(e);
+        FormShowParameter formShowParameter = this.getView().getFormShowParameter();
+        Map<String, Object> customParams = formShowParameter.getCustomParams();
+        boolean isQueryBudget = (Boolean)customParams.get("isquerybudget");
+        BudgetCommonUtil.setIsQueryBudgetFlag(this.getPageCache(), isQueryBudget);
+        Long companyId = ErCommonUtils.getPk(this.getView().getParentView().getModel().getValue("company"));
+        this.setTripExpenseItemShow(companyId, 0);
+        this.setBudgetShow(0);
+        this.setVehicleVisible();
+        if (Objects.nonNull(this.getModel().getDataEntityType().getProperty("costorgusemode"))) {
+            this.getModel().setValue("costorgusemode", this.getView().getParentView().getModel().getValue("costorgusemode"));
+        }
+
+        ShowPageUtils.setMobilePageFormStatus(this.getView());
+        if (StringUtils.equals("1", ErCommonUtils.getTripDateSelectRange(companyId))) {
+            DateTimeEdit tripDate = (DateTimeEdit)this.getControl("startdate");
+            tripDate.setMinDate(ErCommonUtils.getDateFromLocalDate(LocalDate.now()));
+            tripDate = (DateTimeEdit)this.getControl("enddate");
+            tripDate.setMinDate(ErCommonUtils.getDateFromLocalDate(LocalDate.now()));
+        }
+
+    }
+
+    private void setVehicleVisible() {
+        String vihicleKey = null;
+        if (!this.readOnly() && this.getVihicleFromStdConfig()) {
+            vihicleKey = "vehicles";
+        } else {
+            vihicleKey = "vehicle";
+        }
+
+        CardEntry tripentry = (CardEntry)this.getControl("tripentry");
+        int tripentryLen = this.getModel().getEntryRowCount("tripentry");
+
+        for(int i = 0; i < tripentryLen; ++i) {
+            tripentry.setChildVisible(false, i, new String[]{vihicleKey});
+        }
+
+    }
+
+    protected boolean readOnly() {
+        IFormView parentView = this.getView().getParentView();
+        return parentView != null && !"A".equals(parentView.getModel().getValue("billstatus")) && !"D".equals(parentView.getModel().getValue("billstatus"));
+    }
+
+    protected boolean getVihicleFromStdConfig() {
+        return StringUtils.equals(ErStdConfig.get("notMultiVehicles"), "true");
+    }
+
+    public void propertyChanged(PropertyChangedArgs e) {
+        super.propertyChanged(e);
+        IDataModel model = this.getModel();
+        String propName = e.getProperty().getName();
+        ChangeData[] valueSet = e.getChangeSet();
+        int rowIndex = valueSet[0].getRowIndex();
+        Object propValue = valueSet[0].getNewValue();
+        BigDecimal tripOriAmount;
+        BigDecimal exchangeRate;
+        String tripQuoteType;
+        BigDecimal tripAmount;
+        Date startDate;
+        Date endDate;
+        Long tripDays;
+        switch (propName) {
+            case "triporiamount":
+                tripOriAmount = (BigDecimal)propValue;
+                exchangeRate = (BigDecimal)ObjectUtils.defaultIfNull((BigDecimal)model.getValue("tripexchangerate", rowIndex), BigDecimal.ONE);
+                tripQuoteType = (String)ObjectUtils.defaultIfNull((String)model.getValue("tripquotetype", rowIndex), "0");
+                tripAmount = AmountUtils.getCurrencyAmount(tripOriAmount, exchangeRate, AmountUtils.getCurrencyPrecision(model, "currency"), tripQuoteType);
+                model.setValue("tripamount", tripAmount, rowIndex);
+                break;
+            case "tripcurrency":
+                IDataModel parentModel = this.getView().getParentView().getModel();
+                DynamicObject tripCurrency = (DynamicObject)propValue;
+                DynamicObject currency = (DynamicObject)parentModel.getValue("currency");
+                if (tripCurrency != null && currency != null) {
+                    long sourceCurrencyId = tripCurrency.getLong("id");
+                    long targetCurrencyId = currency.getLong("id");
+                    long companyId = (Long)parentModel.getValue("company_Id");
+                    Object costCompany = parentModel.getValue("costcompany");
+                    Object bizdate = parentModel.getValue("bizdate");
+                    Map<String, Object> exchangeMap = CommonServiceHelper.getExchangeRateFromSysParams(companyId, costCompany, sourceCurrencyId, targetCurrencyId, bizdate);
+                    String quoteType = (String)ObjectUtils.defaultIfNull((String)exchangeMap.get("quoteType"), "0");
+                    exchangeRate = (BigDecimal)ObjectUtils.defaultIfNull((BigDecimal)exchangeMap.get("exchangeRate"), BigDecimal.ONE);
+                    if (this.getModel().getProperty("tripquotetype") != null) {
+                        this.getModel().setValue("tripquotetype", quoteType, rowIndex);
+                    }
+
+                    this.getModel().setValue("tripexchangerate", exchangeRate, rowIndex);
+                }
+
+                if (tripCurrency == null && valueSet[0].getOldValue() != null) {
+                    DynamicObject oldValue = (DynamicObject)valueSet[0].getOldValue();
+                    model.setValue("tripcurrency", ErCommonUtils.getPk(oldValue), rowIndex);
+                }
+                break;
+            case "tripexchangerate":
+                exchangeRate = (BigDecimal)ObjectUtils.defaultIfNull((BigDecimal)propValue, BigDecimal.ONE);
+                tripOriAmount = (BigDecimal)model.getValue("triporiamount");
+                if (tripOriAmount.compareTo(BigDecimal.ZERO) != 0) {
+                    tripQuoteType = (String)ObjectUtils.defaultIfNull((String)model.getValue("tripquotetype", rowIndex), "0");
+                    tripAmount = AmountUtils.getCurrencyAmount(tripOriAmount, exchangeRate, AmountUtils.getCurrencyPrecision(model, "currency"), tripQuoteType);
+                    model.setValue("tripamount", tripAmount, rowIndex);
+                }
+                break;
+            case "startdate":
+                startDate = (Date)propValue;
+                endDate = (Date)model.getValue("enddate");
+                tripDays = CommonServiceHelper.calcDays(startDate, endDate);
+                model.setValue("tripday", tripDays, rowIndex);
+                break;
+            case "enddate":
+                endDate = (Date)propValue;
+                startDate = (Date)model.getValue("startdate");
+                tripDays = CommonServiceHelper.calcDays(startDate, endDate);
+                model.setValue("tripday", tripDays, rowIndex);
+                break;
+            case "tripexpenseitem":
+                if (BudgetCommonUtil.getIsQueryBudgetFlag(this.getPageCache()) && propValue != null) {
+                    BudgetCommonUtil.buildBudgetAmountField(this.getView(), rowIndex);
+                }
+                break;
+            case "std_project":
+                if (BudgetCommonUtil.getIsQueryBudgetFlag(this.getPageCache())) {
+                    BudgetCommonUtil.buildBudgetAmountField(this.getView(), rowIndex);
+                }
+                break;
+            case "vehicle":
+                if (this.getVihicleFromStdConfig()) {
+                    this.getModel().setValue("vehicles", propValue);
+                }
+        }
+
+    }
+
+    public void click(EventObject evt) {
+        Control source = (Control)evt.getSource();
+        String key = source.getKey();
+        IDataModel model = this.getModel();
+        IDataModel parentModel = this.getView().getParentView().getModel();
+        Long companyId = ErCommonUtils.getPk(parentModel.getValue("company"));
+        switch (key) {
+            case "btn_save":
+                StringBuilder requireds = new StringBuilder();
+                requireds.append("from,to,startdate,enddate,vehicles");
+                Boolean isLoan = (Boolean)model.getValue("isloan");
+                if (isLoan || BudgetCommonUtil.getIsQueryBudgetFlag(this.getPageCache()) || BudgetCommonUtil.getIsQueryEASBudgetFlag(this.getPageCache()) || BudgetCommonUtil.getIsTripReqShowExpenseitemFlag(this.getPageCache()) || this.getModel().getDataEntity(true).getBoolean("istravelers") || SystemParamterUtil.getTripexpenseitemMustInput(companyId)) {
+                    requireds.append(",tripexpenseitem");
+                }
+
+                DynamicObject dataEntity = model.getDataEntity(true);
+                DynamicObjectCollection tripentry = dataEntity.getDynamicObjectCollection("tripentry");
+                Boolean confirm = Boolean.FALSE;
+                Boolean istravelers = (Boolean)this.getModel().getValue("istravelers");
+                Iterator var21 = tripentry.iterator();
+
+                while(var21.hasNext()) {
+                    DynamicObject dobjet = (DynamicObject)var21.next();
+                    String vehicles = (String)model.getValue("vehicles");
+                    if (vehicles == null) {
+                        this.getView().showTipNotification(String.format(ResManager.loadKDString("请填写“交通工具”。", "CommonServiceHelper_1", "fi-er-business", new Object[0])));
+                        return;
+                    }
+
+                    String[] split = vehicles.split(",");
+                    if (split == null || split.length == 0) {
+                        this.getView().showTipNotification(String.format(ResManager.loadKDString("请填写“交通工具”。", "CommonServiceHelper_1", "fi-er-business", new Object[0])));
+                        return;
+                    }
+
+                    DynamicObjectCollection travelers = dobjet.getDynamicObjectCollection("travelers");
+                    if (istravelers && (travelers == null || travelers.size() == 0)) {
+                        this.getView().showTipNotification(String.format(ResManager.loadKDString("请填写“出差人”。", "TripReqSection_7", "fi-er-formplugin", new Object[0])));
+                        return;
+                    }
+
+                    if (!CommonServiceHelper.requireValidate(dobjet, requireds.toString().split(","), this)) {
+                        return;
+                    }
+
+                    Object from = dobjet.get("from");
+                    Object to = dobjet.get("to");
+                    if (from.equals(to)) {
+                        confirm = Boolean.TRUE;
+                    }
+
+                    dobjet.set("triporiaccappamount", dobjet.get("triporiamount"));
+                    dobjet.set("tripaccappamount", dobjet.get("tripamount"));
+                    dobjet.set("oriaccbalanceamount", dobjet.get("triporiamount"));
+                    dobjet.set("accbalanceamount", dobjet.get("tripamount"));
+                }
+
+                if (parentModel.getValue("istravelers") != null && !(Boolean)parentModel.getValue("istravelers")) {
+                    String error = this.validateTripDate(parentModel);
+                    if (StringUtils.isNotBlank(error)) {
+                        this.getView().showErrorNotification(error);
+                        return;
+                    }
+                }
+
+                if (confirm) {
+                    this.getView().showConfirm(ResManager.loadKDString("出发地与目的地相同,是否继续?", "TripReqSection_0", "fi-er-formplugin", new Object[0]), MessageBoxOptions.OKCancel, new ConfirmCallBackListener("ok", this));
+                } else {
+                    this.clickOk(model, parentModel, dataEntity, tripentry);
+                }
+                break;
+            case "btn_addsection":
+                int tripentryCurIndex = model.getEntryCurrentRowIndex("tripentry");
+                model.setValue("tripcurrency", ErCommonUtils.getPk(parentModel.getValue("currency")), tripentryCurIndex);
+                Long[] applierIds = new Long[]{ErCommonUtils.getPk(parentModel.getValue("applier"))};
+                model.setValue("travelers", applierIds, tripentryCurIndex);
+                this.setTripExpenseItemShow(companyId, tripentryCurIndex);
+                this.setBudgetShow(tripentryCurIndex);
+                this.setVehicleVisible();
+        }
+
+    }
+
+    private void clickOk(IDataModel model, IDataModel parentModel, DynamicObject dataEntity, DynamicObjectCollection tripentry) {
+        if (tripentry != null && tripentry.size() >= 1) {
+            long firstPageCurrencyId = ErCommonUtils.getPk(parentModel.getValue("currency"));
+            long secondPageCurrencyId = ErCommonUtils.getPk(model.getValue("currency"));
+            IFormView parentView = this.getView().getParentView();
+            DynamicObject parentDataEntity = parentModel.getDataEntity(true);
+            DynamicObjectCollection partripentry = parentDataEntity.getDynamicObjectCollection("tripentry");
+            if (partripentry.isEmpty() && firstPageCurrencyId != secondPageCurrencyId) {
+                parentView.updateView();
+                this.getView().sendFormAction(parentView);
+                this.getView().close();
+            } else {
+                FormShowParameter param = this.getView().getFormShowParameter();
+                String pageId = parentView.getPageId();
+                if (param.getCustomParam("entryedit") != null) {
+                    int index = (Integer)param.getCustomParam("index");
+                    partripentry.remove(index);
+                    partripentry.addAll(index, tripentry);
+                } else {
+                    partripentry.addAll(tripentry);
+                }
+
+                RedisModelCache redisModelCache = new RedisModelCache((IRefrencedataProvider)null, model.getDataEntityType(), pageId);
+                redisModelCache.storeAll(dataEntity);
+                parentView.updateView();
+                this.getView().sendFormAction(parentView);
+                this.getView().close();
+            }
+        } else {
+            this.getView().showTipNotification(ResManager.loadKDString("请填写行程信息。", "TripReqSection_5", "fi-er-formplugin", new Object[0]));
+        }
+    }
+
+    private String validateTripDate(IDataModel parentModel) {
+        DynamicObjectCollection parentTripEntry = parentModel.getEntryEntity("tripentry");
+        int parentSize = parentTripEntry.size();
+        DynamicObjectCollection curEntryEntity = this.getModel().getEntryEntity("tripentry");
+        int curSize = curEntryEntity.size();
+        Map<Integer, Object> sortMap = new TreeMap();
+        if (curSize > 0) {
+            curEntryEntity.forEach((entity) -> {
+                sortMap.put(entity.getInt("index"), entity);
+            });
+        }
+
+        if (parentSize > 0) {
+            parentTripEntry.forEach((entity) -> {
+                if (!sortMap.containsKey(entity.getInt("seq"))) {
+                    sortMap.put(entity.getInt("seq"), entity);
+                }
+
+            });
+        }
+
+        Date startDate = null;
+        Date endDate = null;
+        String tip = null;
+
+        for(int i = 0; i < curEntryEntity.size(); ++i) {
+            DynamicObject curTripEntry = (DynamicObject)curEntryEntity.get(i);
+            int index = curTripEntry.getInt("index");
+            DynamicObject lastTripEntry = (DynamicObject)sortMap.get(index - 1);
+            if (lastTripEntry != null) {
+                startDate = curTripEntry.getDate("startdate");
+                endDate = lastTripEntry.getDate("enddate");
+                if (startDate.before(endDate)) {
+                    tip = ResManager.loadKDString("第%1$s程行程期间不能早于第%2$s程行程期间。", "TripReqSection_2", "fi-er-formplugin", new Object[0]);
+                    return String.format(tip, index, index - 1);
+                }
+            }
+
+            DynamicObject nextTripEntry = (DynamicObject)sortMap.get(index + 1);
+            if (nextTripEntry != null) {
+                endDate = curTripEntry.getDate("enddate");
+                startDate = nextTripEntry.getDate("startdate");
+                if (startDate.before(endDate)) {
+                    tip = ResManager.loadKDString("第%1$s程行程期间不能晚于第%2$s程行程期间。", "TripReqSection_4", "fi-er-formplugin", new Object[0]);
+                    return String.format(tip, index, index + 1);
+                }
+            }
+        }
+
+        return null;
+    }
+
+    private void setTripExpenseItemShow(Long companyId, int rowIndex) {
+        Boolean isLoan = (Boolean)this.getModel().getValue("isloan");
+        CardEntry tripCardEntry = (CardEntry)this.getControl("tripentry");
+        if (!isLoan && !BudgetCommonUtil.getIsQueryBudgetFlag(this.getPageCache()) && !BudgetCommonUtil.getIsQueryEASBudgetFlag(this.getPageCache()) && !BudgetCommonUtil.getIsTripReqShowExpenseitemFlag(this.getPageCache()) && !this.getModel().getDataEntity(true).getBoolean("istravelers") && !SystemParamterUtil.getTripexpenseitemMustInput(companyId)) {
+            tripCardEntry.setChildVisible(false, rowIndex, new String[]{"cardtripexpenseitem", "tripexpenseitem"});
+        } else {
+            tripCardEntry.setChildVisible(true, rowIndex, new String[]{"cardtripexpenseitem", "tripexpenseitem"});
+            FieldEdit editor = (FieldEdit)this.getView().getControl("tripexpenseitem");
+            editor.setMustInput(false);
+        }
+
+    }
+
+    private void setBudgetShow(int rowIndex) {
+        CardEntry tripCardEntry = (CardEntry)this.getControl("tripentry");
+        if (tripCardEntry != null) {
+            if (!BudgetCommonUtil.getIsQueryBudgetFlag(this.getPageCache()) && !BudgetCommonUtil.getIsQueryEASBudgetFlag(this.getPageCache())) {
+                tripCardEntry.setChildVisible(false, rowIndex, new String[]{"cardbudget", "budgetamount"});
+                tripCardEntry.setChildVisible(false, rowIndex, new String[]{"cardbudget1", "budgetmsg"});
+            } else {
+                IFormView parentView = this.getView().getParentView();
+                if (parentView != null) {
+                    String budgeMsgValue = (String)ErCommonUtils.getEMParameter(ErCommonUtils.getPk(parentView.getModel().getValue("company")), "budgeMsgControl");
+                    if (StringUtils.isNotEmpty(budgeMsgValue)) {
+                        if ("0".equals(budgeMsgValue)) {
+                            tripCardEntry.setChildVisible(true, rowIndex, new String[]{"cardbudget", "budgetamount"});
+                            tripCardEntry.setChildVisible(false, rowIndex, new String[]{"cardbudget1", "budgetmsg"});
+                        } else if ("1".equals(budgeMsgValue)) {
+                            tripCardEntry.setChildVisible(false, rowIndex, new String[]{"cardbudget", "budgetamount"});
+                            tripCardEntry.setChildVisible(true, rowIndex, new String[]{"cardbudget1", "budgetmsg"});
+                        }
+                    } else {
+                        tripCardEntry.setChildVisible(false, rowIndex, new String[]{"cardbudget", "budgetamount"});
+                        tripCardEntry.setChildVisible(false, rowIndex, new String[]{"cardbudget1", "budgetmsg"});
+                    }
+                } else {
+                    tripCardEntry.setChildVisible(false, rowIndex, new String[]{"cardbudget", "budgetamount"});
+                    tripCardEntry.setChildVisible(false, rowIndex, new String[]{"cardbudget1", "budgetmsg"});
+                }
+            }
+        }
+
+    }
+
+    private void initTripEntryDefaultData(IDataModel model, int rowIndex) {
+        model.setValue("tripexchangerate", BigDecimal.ONE, rowIndex);
+    }
+
+    public void afterDeleteRow(AfterDeleteRowEventArgs e) {
+        super.afterDeleteRow(e);
+        int[] rowIndexs = e.getRowIndexs();
+        int rowIndex = rowIndexs[0];
+
+        for(int tripEntrySize = this.getModel().getEntryRowCount("tripentry"); rowIndex < tripEntrySize; ++rowIndex) {
+            int index = (Integer)this.getModel().getValue("index", rowIndex);
+            this.getModel().setValue("index", index - 1, rowIndex);
+        }
+
+    }
+
+    public void afterDoOperation(AfterDoOperationEventArgs afterDoOperationEventArgs) {
+        super.afterDoOperation(afterDoOperationEventArgs);
+        IDataModel model = this.getModel();
+        IDataModel paremodel = this.getView().getParentView().getModel();
+        int rowIndex = model.getEntryCurrentRowIndex("tripentry");
+        int thisCount = model.getEntryRowCount("tripentry");
+        DynamicObjectCollection tripentryCol = model.getEntryEntity("tripentry");
+        int tripenytryCount = tripentryCol.size();
+        if (thisCount != 0) {
+            int tripEntryRowCount;
+            if ("newtripentry".equalsIgnoreCase(afterDoOperationEventArgs.getOperateKey())) {
+                if (tripenytryCount > 1) {
+                    Object lastCity = ((DynamicObject)tripentryCol.get(tripenytryCount - 2)).get("to_Id");
+                    Object nextStartDate = ((DynamicObject)tripentryCol.get(tripenytryCount - 2)).get("enddate");
+                    if (lastCity != null) {
+                        model.setValue("from", lastCity, tripenytryCount - 1);
+                    }
+
+                    if (nextStartDate != null) {
+                        model.setValue("startdate", nextStartDate, tripenytryCount - 1);
+                    }
+                }
+
+                tripEntryRowCount = model.getEntryRowCount("tripentry") + paremodel.getEntryRowCount("tripentry");
+                model.setValue("index", tripEntryRowCount, model.getEntryRowCount("tripentry") - 1);
+                Object currencyId = ErCommonUtils.getPk(paremodel.getValue("currency"));
+                model.setValue("rcurrency", currencyId, rowIndex);
+                model.setValue("tripcurrency", currencyId, rowIndex);
+                this.initTripEntryDefaultData(model, rowIndex);
+            }
+
+            tripEntryRowCount = model.getEntryRowCount("tripentry");
+            int parentTripEntryRowCount = paremodel.getEntryRowCount("tripentry");
+            if (Objects.equals(afterDoOperationEventArgs.getOperateKey(), "deletetripentry")) {
+                for(int i = 0; i < tripEntryRowCount; ++i) {
+                    model.setValue("index", parentTripEntryRowCount + i + 1, i);
+                }
+            }
+
+        }
+    }
+
+    public void confirmCallBack(MessageBoxClosedEvent messageBoxClosedEvent) {
+        super.confirmCallBack(messageBoxClosedEvent);
+        if (MessageBoxResult.Yes.equals(messageBoxClosedEvent.getResult())) {
+            IFormView parentView = this.getView().getParentView();
+            IDataModel parentModel = parentView.getModel();
+            DynamicObject dataEntity = this.getModel().getDataEntity(true);
+            DynamicObjectCollection tripentry = dataEntity.getDynamicObjectCollection("tripentry");
+            this.clickOk(this.getModel(), parentModel, dataEntity, tripentry);
+        }
+
+    }
+
+    public void closedCallBack(ClosedCallBackEvent closedCallBackEvent) {
+        super.closedCallBack(closedCallBackEvent);
+        if ("people_choose".equalsIgnoreCase(closedCallBackEvent.getActionId())) {
+            ListSelectedRowCollection rowCollection = (ListSelectedRowCollection)closedCallBackEvent.getReturnData();
+            int index = this.getModel().getEntryCurrentRowIndex("tripentry");
+            Object[] users = null;
+            if (rowCollection != null) {
+                users = rowCollection.stream().map((v) -> {
+                    return v.getPrimaryKeyValue();
+                }).toArray();
+            } else {
+                users = new Object[0];
+            }
+
+            this.getModel().setValue("travelers", users, index);
+        }
+
+    }
+
+    public void beforeClosed(BeforeClosedEvent e) {
+        e.setCheckDataChange(false);
+        super.beforeClosed(e);
+    }
+}