From b208c7513b5d322c32786076bf4c0b2c6895d33c Mon Sep 17 00:00:00 2001 From: xuhaihui <2098865055@qq.com> Date: Wed, 13 Aug 2025 10:38:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=B3=E5=8A=A1=E7=8F=AD=E7=BB=84=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E6=8F=92=E4=BB=B6=E6=A0=87=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pr/plugin/form/LabourEditPluginExt.java | 161 ++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/LabourEditPluginExt.java diff --git a/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/LabourEditPluginExt.java b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/LabourEditPluginExt.java new file mode 100644 index 0000000..f4ae9a3 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-pr/src/main/java/zcgj/zcdev/zcdev/pr/plugin/form/LabourEditPluginExt.java @@ -0,0 +1,161 @@ +// +// Source code recreated from a .class file by IntelliJ IDEA +// (powered by FernFlower decompiler) +// + +package zcgj.zcdev.zcdev.pr.plugin.form; + +import java.util.EventObject; + +import kd.bos.bill.AbstractBillPlugIn; +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.dataentity.resource.ResManager; +import kd.bos.dataentity.utils.ObjectUtils; +import kd.bos.dataentity.utils.StringUtils; +import kd.bos.entity.datamodel.events.PropertyChangedArgs; +import kd.bos.form.events.BeforeDoOperationEventArgs; +import kd.bos.form.field.BasedataEdit; +import kd.bos.form.field.FieldEdit; +import kd.bos.form.field.events.BeforeF7SelectEvent; +import kd.bos.form.field.events.BeforeF7SelectListener; +import kd.bos.form.operate.FormOperate; +import kd.bos.list.ListShowParameter; +import kd.bos.orm.query.QFilter; + +public class LabourEditPluginExt extends AbstractBillPlugIn implements BeforeF7SelectListener { + public LabourEditPluginExt() { + } + + public void afterCreateNewData(EventObject e) { + super.afterCreateNewData(e); + } + + public void registerListener(EventObject e) { + super.registerListener(e); + BasedataEdit contract = (BasedataEdit) this.getControl("contract"); + contract.addBeforeF7SelectListener(this); + BasedataEdit unitProject = (BasedataEdit) this.getControl("unitproject"); + if (unitProject != null) { + unitProject.addBeforeF7SelectListener(this); + } + + BasedataEdit project = (BasedataEdit) this.getControl("project"); + if (project != null) { + project.addBeforeF7SelectListener(this); + } + + } + + public void afterBindData(EventObject e) { + super.afterBindData(e); + this.teamChanged(); + this.setUnitProject(); + } + + public void propertyChanged(PropertyChangedArgs e) { + super.propertyChanged(e); + String propertyName = e.getProperty().getName(); + if (StringUtils.equals(propertyName, "team")) { + this.teamChanged(); + this.getModel().deleteEntryData("entryentity"); + } else { + DynamicObject contract; + if (StringUtils.equals(propertyName, "supplier")) { + contract = (DynamicObject) this.getModel().getValue("supplier"); + if (null != contract) { + this.getModel().setValue("supplierman", contract.getString("linkman")); + this.getModel().setValue("supplieridcard", contract.getString("tx_register_no")); + this.getModel().setValue("suppliertel", contract.getString("bizpartner_phone")); + } + } else if (StringUtils.equals(propertyName, "contract")) { + contract = (DynamicObject) this.getModel().getValue("contract"); + if (null != contract && null != contract.getDynamicObject("partb")) { + this.getModel().setValue("supplier", contract.getDynamicObject("partb").getPkValue()); + } + } else if (StringUtils.equals(propertyName, "project")) { + this.getModel().setValue("unitproject", (Object) null); + this.setUnitProject(); + this.getView().updateView("unitproject"); + } + } + + } + + protected void setUnitProject() { + DynamicObject project = (DynamicObject) this.getModel().getValue("project"); + if (project == null) { + this.getView().setEnable(false, new String[]{"unitproject"}); + } else { + boolean editOnUnit = project.getBoolean("editonunit"); + FieldEdit unitProjectEdit = (FieldEdit) this.getView().getControl("unitproject"); + if (editOnUnit) { + this.getView().setEnable(true, new String[]{"unitproject"}); + } else { + unitProjectEdit.setMustInput(false); + this.getView().setEnable(false, new String[]{"unitproject"}); + } + + } + } + + private void teamChanged() { + String team = (String) this.getModel().getValue("team"); + BasedataEdit supplier = (BasedataEdit) this.getControl("supplier"); + BasedataEdit f7pickmaterials = (BasedataEdit) this.getControl("pickmaterials"); + FieldEdit pickmaterialsName = (FieldEdit) this.getControl("pickmaterialsname"); + if (StringUtils.equals(team, "01")) { + supplier.setMustInput(false); + this.getView().setVisible(false, new String[]{"pickmaterialsname"}); + pickmaterialsName.setMustInput(false); + this.getView().setVisible(true, new String[]{"pickmaterials"}); + f7pickmaterials.setMustInput(true); + this.getModel().setValue("supplier", (Object) null); + } else if (StringUtils.equals(team, "02")) { + supplier.setMustInput(true); + this.getView().setVisible(true, new String[]{"pickmaterialsname"}); + pickmaterialsName.setMustInput(true); + this.getView().setVisible(false, new String[]{"pickmaterials"}); + f7pickmaterials.setMustInput(false); + } + + } + + public void beforeDoOperation(BeforeDoOperationEventArgs args) { + super.beforeDoOperation(args); + FormOperate operate = (FormOperate) args.getSource(); + String operateKey = operate.getOperateKey(); + if (StringUtils.equals(operateKey, "save") || StringUtils.equals(operateKey, "submit")) { + String team = (String) this.getModel().getValue("team"); + DynamicObjectCollection entryCollection = this.getModel().getEntryEntity("entryentity"); + if (null != entryCollection && entryCollection.size() > 0) { + for (int i = 0; i < entryCollection.size(); ++i) { + if (StringUtils.equals(team, "01")) { + if (ObjectUtils.isEmpty(((DynamicObject) entryCollection.get(i)).get("pickmaterials"))) { + this.getView().showTipNotification(String.format(ResManager.loadKDString("领料人设置分录,第[%s]行领料人姓名为空。", "LabourEditPlugin_0", "ec-ecma-formplugin", new Object[0]), i + 1)); + args.setCancel(true); + return; + } + } else if (StringUtils.equals(team, "02") && StringUtils.isEmpty(((DynamicObject) entryCollection.get(i)).get("pickmaterialsname").toString().trim())) { + this.getView().showTipNotification(String.format(ResManager.loadKDString("领料人设置分录,第[%s]行领料人姓名为空。", "LabourEditPlugin_0", "ec-ecma-formplugin", new Object[0]), i + 1)); + args.setCancel(true); + return; + } + } + } + } + + } + + public void beforeF7Select(BeforeF7SelectEvent arg0) { + BasedataEdit source = (BasedataEdit) arg0.getSource(); + String key = source.getFieldKey(); + if (StringUtils.equals(key, "contract")) { + ListShowParameter showParameter = (ListShowParameter) arg0.getFormShowParameter(); + QFilter typpeFilter = new QFilter("contracttype.contattr.basictype", "=", "03"); + showParameter.getListFilterParameter().setFilter(typpeFilter); + } else if (StringUtils.equals("unitproject", key)) { + } + + } +}