From 52c16c7e5a9611579dc549a0fafa380332f72b6e Mon Sep 17 00:00:00 2001 From: chenshaoxin <1981897232@qq.com> Date: Mon, 18 Nov 2024 14:07:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=8F=90=E4=BA=A4=20?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BA=BA=EF=BC=9A=E9=99=88=E7=BB=8D=E9=91=AB?= =?UTF-8?q?=20=E6=97=B6=E9=97=B4=EF=BC=9A2024/11/16=20=2014=EF=BC=9A00=20?= =?UTF-8?q?=E5=86=85=E5=AE=B9=EF=BC=9A=E9=A1=B9=E7=9B=AE=E5=BB=BA=E7=AB=8B?= =?UTF-8?q?=E6=8F=92=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../repmd/formplugin/ProjectBillPlugin.java | 58 +++++++++++++++++++ .../repmd/formplugin/WorkQuantityPlugin.java | 51 ++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 main/java/shkd/repc/repmd/formplugin/ProjectBillPlugin.java create mode 100644 main/java/shkd/repc/repmd/formplugin/WorkQuantityPlugin.java diff --git a/main/java/shkd/repc/repmd/formplugin/ProjectBillPlugin.java b/main/java/shkd/repc/repmd/formplugin/ProjectBillPlugin.java new file mode 100644 index 0000000..2535840 --- /dev/null +++ b/main/java/shkd/repc/repmd/formplugin/ProjectBillPlugin.java @@ -0,0 +1,58 @@ +package shkd.repc.repmd.formplugin; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.OrmLocaleValue; +import kd.bos.form.FormShowParameter; +import kd.bos.form.field.BasedataEdit; +import kd.bos.form.field.events.BeforeQuickAddNewEvent; +import kd.bos.form.field.events.BeforeQuickAddNewListener; +import kd.bos.form.operate.FormOperate; +import kd.bos.form.plugin.AbstractFormPlugin; + +import java.util.EventObject; + +public class ProjectBillPlugin extends AbstractFormPlugin implements BeforeQuickAddNewListener { + + @Override + public void registerListener(EventObject e) { + super.registerListener(e); + BasedataEdit qeug_gcl = this.getControl("qeug_gcl"); + qeug_gcl.addBeforeQuickAddNewListener(this); + } + + @Override + public void beforeQuickAddNew(BeforeQuickAddNewEvent beforeQuickAddNewEvent) { + + BasedataEdit operate = (BasedataEdit)beforeQuickAddNewEvent.getSource(); + String operateKey = String.valueOf(operate.getDisplayName()); + int productentry = this.getModel().getEntryCurrentRowIndex("productentry"); + if (operateKey.equals("工程量")){ + FormShowParameter showParameter = beforeQuickAddNewEvent.getShowParameter(); + + String billno = (String) this.getModel().getValue("billno"); + if (billno == null || billno.isEmpty()) { + beforeQuickAddNewEvent.setCancel(true); + this.getView().showSuccessNotification("请填写项目编号"); + return; + } + OrmLocaleValue billname = (OrmLocaleValue) this.getModel().getValue("billname"); + String zh_cn = billname.get("zh_CN"); + if (billname.size()==0) { + beforeQuickAddNewEvent.setCancel(true); + this.getView().showSuccessNotification("请填写项目名称"); + return; + } + DynamicObject productentry_producttype = (DynamicObject) this.getModel().getValue("productentry_producttype",productentry); + if (productentry_producttype==null){ + beforeQuickAddNewEvent.setCancel(true); + this.getView().showSuccessNotification("请填写对应行的产品类型"); + return; + } + showParameter.setCustomParam("billno",billno); + showParameter.setCustomParam("billname",zh_cn); + showParameter.setCustomParam("productentry_producttype",productentry_producttype.getPkValue().toString()); + showParameter.setCustomParam("versionnum",this.getModel().getValue("versionnum")); + } + } + +} diff --git a/main/java/shkd/repc/repmd/formplugin/WorkQuantityPlugin.java b/main/java/shkd/repc/repmd/formplugin/WorkQuantityPlugin.java new file mode 100644 index 0000000..31a3678 --- /dev/null +++ b/main/java/shkd/repc/repmd/formplugin/WorkQuantityPlugin.java @@ -0,0 +1,51 @@ +package shkd.repc.repmd.formplugin; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.entity.DynamicObjectCollection; +import kd.bos.entity.operate.Save; +import kd.bos.form.events.AfterDoOperationEventArgs; +import kd.bos.form.events.BeforeDoOperationEventArgs; +import kd.bos.form.operate.FormOperate; +import kd.bos.form.plugin.AbstractFormPlugin; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.QueryServiceHelper; + +import java.util.EventObject; + +public class WorkQuantityPlugin extends AbstractFormPlugin { + @Override + public void afterBindData(EventObject e) { + super.afterBindData(e); + String billno = this.getView().getFormShowParameter().getCustomParam("billno"); + String billname = this.getView().getFormShowParameter().getCustomParam("billname"); + String versionnum = this.getView().getFormShowParameter().getCustomParam("versionnum"); + String productentry_producttype = this.getView().getFormShowParameter().getCustomParam("productentry_producttype"); + this.getModel().setValue("qeug_xmnumber",billno); + this.getModel().setValue("name",billname); + this.getModel().setValue("qeug_cpmc",productentry_producttype); + this.getModel().setValue("qeug_bbh",versionnum); + } + + @Override + public void beforeDoOperation(BeforeDoOperationEventArgs args) { + if (args.getSource() instanceof Save){ + String qeug_xmnumber = (String) this.getModel().getValue("qeug_xmnumber"); + String qeug_bbh = (String) this.getModel().getValue("qeug_bbh"); + QFilter filter = new QFilter("qeug_xmnumber", QCP.equals, qeug_xmnumber).and(new QFilter("qeug_bbh", QCP.equals, qeug_bbh)); + DynamicObjectCollection query = QueryServiceHelper.query("qeug_gcl", "id", filter.toArray()); + if (query.size()!=0){ + this.getView().showSuccessNotification("已存在当前版本号的项目数据,不允许保存"); + args.setCancel(true); + } + } + } + + @Override + public void afterDoOperation(AfterDoOperationEventArgs afterDoOperationEventArgs) { + if (afterDoOperationEventArgs.getSource() instanceof Save){ + this.getView().invokeOperation("submit"); + this.getView().invokeOperation("audit"); + } + } +}