diff --git a/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TaskApproveFormCkPlugin.java b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TaskApproveFormCkPlugin.java new file mode 100644 index 0000000..ccbf805 --- /dev/null +++ b/code/zcdev/zcgj-zcdev-zcdev-fs/src/main/java/zcgj/zcdev/zcdev/fs/plugin/form/TaskApproveFormCkPlugin.java @@ -0,0 +1,84 @@ +package zcgj.zcdev.zcdev.fs.plugin.form; + +import kd.bos.dataentity.entity.DynamicObject; +import kd.bos.dataentity.utils.StringUtils; +import kd.bos.entity.datamodel.IDataModel; +import kd.bos.form.IFormView; +import kd.bos.form.control.Control; +import kd.bos.form.control.events.BeforeClickEvent; +import kd.bos.form.control.events.BeforeItemClickEvent; +import kd.bos.form.plugin.AbstractFormPlugin; +import kd.bos.orm.query.QCP; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.BusinessDataServiceHelper; +import kd.ssc.task.formplugin.util.VoucherUtil; + +import java.util.EventObject; +import java.util.Map; + +/** + * 我的共享,任务审批时增加付款完成校验 + */ +public class TaskApproveFormCkPlugin extends AbstractFormPlugin { + + // + public void registerListener(EventObject evt) { + this.addClickListeners(new String[]{"submit", "submitandnext"}); + } + + @Override + public void beforeItemClick(BeforeItemClickEvent evt) { + super.beforeItemClick(evt); + } + + @Override + public void beforeClick(BeforeClickEvent evt) { + super.beforeClick(evt); + Control control = (Control)evt.getSource(); + String fieldKey = control.getKey(); + if (StringUtils.equals(fieldKey, "submit") + || StringUtils.equals(fieldKey, "submitandnext")) { + IFormView view = this.getView(); + Map customParams = view.getFormShowParameter().getCustomParams(); + Long billtypeid = 0L; + Long tasktypeid = 0L; + String billnumber = ""; + String billid = ""; + String billNo = null; + if (customParams != null) { + billtypeid = (Long)customParams.get("billtypeid");//单据类型id + tasktypeid = (Long)customParams.get("tasktypeid");//任务类型id + billnumber = (String)customParams.get("billnumber");//单据编码(单据标识 entityName) + billid = (String)customParams.get("billid");//业务单据id + billNo = VoucherUtil.getTaskBillNo(billid);//业务单据编号 + + IDataModel model = this.getModel(); + String operation = (String)model.getValue("operationgroupfield"); + if ("1".equals(operation)) { //如果审批操作是通过 + if(StringUtils.isNotBlank(billNo) && StringUtils.isNotBlank(billid) && StringUtils.isNotBlank(billnumber) ) { + QFilter accountTableFilter = new QFilter("id", QCP.equals,Long.valueOf(billid)); + DynamicObject sourceBillObject = BusinessDataServiceHelper.loadSingle(billnumber, new QFilter[]{accountTableFilter}); + String billstatus = sourceBillObject.getString("billstatus"); + if(!"G".equals(billstatus)) { + if("er_repaymentbill".equals(billnumber)) { + this.getView().showErrorNotification(String.format("审批结算任务:当前单据的收款未完成,请完成收款后提交。")); + evt.setCancel(true); + }else{ + this.getView().showErrorNotification(String.format("审批结算任务:当前单据的付款未完成,请完成付款后提交。")); + evt.setCancel(true); + } + } + } + } + + } + //System.out.println(billtypeid); + //System.out.println(tasktypeid); + //System.out.println(billnumber); + //System.out.println(billid); + //System.out.println(billNo); + } + } + + +}