Просмотр исходного кода

fix(salarygroup): 解决表单创建时父视图为空的异常问题

- 添加了对父视图的空值检查,避免空指针异常
- 引入IFormView接口用于类型安全的视图操作
- 保持原有的员工ID和薪资文件ID传递逻辑不变
Tyx 5 дней назад
Родитель
Сommit
f4e7363cb8

+ 11 - 7
code/swc/nckd-jxccl-swc/src/main/java/nckd/jxccl/swc/hsbs/formplugin/web/basedata/salarygroup/PerSalaryGroupEdit.java

@@ -1,5 +1,6 @@
 package nckd.jxccl.swc.hsbs.formplugin.web.basedata.salarygroup;
 package nckd.jxccl.swc.hsbs.formplugin.web.basedata.salarygroup;
 
 
+import kd.bos.form.IFormView;
 import kd.bos.form.plugin.AbstractFormPlugin;
 import kd.bos.form.plugin.AbstractFormPlugin;
 import kd.sdk.plugin.Plugin;
 import kd.sdk.plugin.Plugin;
 
 
@@ -13,13 +14,16 @@ public class PerSalaryGroupEdit extends AbstractFormPlugin implements Plugin {
 
 
     @Override
     @Override
     public void afterCreateNewData(EventObject e) {
     public void afterCreateNewData(EventObject e) {
-        Object employeeIdObj = this.getView().getParentView().getFormShowParameter().getCustomParam("employeeId");
-        if (null != employeeIdObj) {
-            this.getView().getModel().setValue("nckd_employee", Long.parseLong(String.valueOf(employeeIdObj)));
-        }
-        Object salaryFileObj = this.getView().getParentView().getFormShowParameter().getCustomParam("salaryfileId");
-        if (null != salaryFileObj) {
-            this.getView().getModel().setValue("nckd_salaryfile", Long.parseLong(String.valueOf(salaryFileObj)));
+        IFormView parentView = this.getView().getParentView();
+        if(parentView != null) {
+            Object employeeIdObj = this.getView().getParentView().getFormShowParameter().getCustomParam("employeeId");
+            if (null != employeeIdObj) {
+                this.getView().getModel().setValue("nckd_employee", Long.parseLong(String.valueOf(employeeIdObj)));
+            }
+            Object salaryFileObj = this.getView().getParentView().getFormShowParameter().getCustomParam("salaryfileId");
+            if (null != salaryFileObj) {
+                this.getView().getModel().setValue("nckd_salaryfile", Long.parseLong(String.valueOf(salaryFileObj)));
+            }
         }
         }
     }
     }
 }
 }