1.根据组织携带项目的逻辑(缺省值:虚拟项目)

S
This commit is contained in:
weiyunlong 2024-12-17 19:16:01 +08:00
parent ab8d79b3d5
commit 35881d6a33
1 changed files with 73 additions and 0 deletions

View File

@ -0,0 +1,73 @@
package shkd.repc.recon.formplugin;
import kd.bos.bill.AbstractBillPlugIn;
import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.BusinessDataServiceHelper;
import java.util.EventObject;
public class PayreqProjectFormPlugin extends AbstractBillPlugIn {
@Override
public void afterBindData(EventObject e) {
super.afterBindData(e);
//根据组织携带项目
updateRenovationProject();
}
@Override
public void propertyChanged(PropertyChangedArgs e) {
super.propertyChanged(e);
String name = e.getProperty().getName();
//根据组织携带项目
if ("org".equals(name)) {
updateRenovationProject();
}
}
private void updateRenovationProject() {
DynamicObject org = (DynamicObject) this.getModel().getValue("org");
// 只有在需求组织不为空的情况下才进行查询
if (org != null) {
setRenovationProjectByOrg(org);
} else {
// 组织为空清空项目
this.getModel().setValue("project", null);
this.getView().updateView("project");
}
}
private void setRenovationProjectByOrg(DynamicObject org) {
// 采购项目
DynamicObject[] projectbills = BusinessDataServiceHelper.load("rebm_purproject", "id",
new QFilter[]{new QFilter("org.id", QCP.equals, org.getPkValue())});
DynamicObject projectbill = null;
if (projectbills.length > 0) {
DynamicObject projectbill1 = projectbills[0];
if (projectbill1 != null) {
//项目建立F7
DynamicObject add = BusinessDataServiceHelper.loadSingle("repmd_project_f7",
new QFilter[]{new QFilter("number", QCP.equals, projectbill1.getString("number"))});
if (add != null) {
projectbill = add;
}
}
} else {
DynamicObject add = BusinessDataServiceHelper.loadSingle("repmd_project_f7",
new QFilter[]{new QFilter("number", QCP.equals, "XM-202412-008")});
if (add != null) {
projectbill = add;
}
}
// 设置项目并更新视图
this.getModel().setValue("project", projectbill);
this.getView().updateView("project");
}
}