|
@@ -0,0 +1,225 @@
|
|
|
+package fi.em.formPlugin;
|
|
|
+
|
|
|
+import kd.bos.dataentity.entity.DynamicObject;
|
|
|
+import kd.bos.entity.datamodel.events.ChangeData;
|
|
|
+import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
|
|
+import kd.bos.form.ConfirmCallBackListener;
|
|
|
+import kd.bos.form.ConfirmTypes;
|
|
|
+import kd.bos.form.MessageBoxOptions;
|
|
|
+import kd.bos.form.MessageBoxResult;
|
|
|
+import kd.bos.form.events.BeforeDoOperationEventArgs;
|
|
|
+import kd.bos.form.events.MessageBoxClosedEvent;
|
|
|
+import kd.bos.form.operate.FormOperate;
|
|
|
+import kd.bos.list.plugin.AbstractListPlugin;
|
|
|
+import kd.sdk.plugin.Plugin;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.EventObject;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author cjz
|
|
|
+ * @date 2024/8/19 9:01
|
|
|
+ * @description:薪酬计提单,根据业务类型显示分录
|
|
|
+ */
|
|
|
+public class SalaryDistributeEditPlugin extends AbstractListPlugin implements Plugin {
|
|
|
+
|
|
|
+ private static String nckd_entrytype="nckd_entrytype";//业务类型标识
|
|
|
+ private static String nckd_generalemployees="nckd_generalemployees";//薪酬明细(一般员工)分录标识
|
|
|
+ private static String nckd_earlyretired="nckd_earlyretired";//薪酬明细(内退)分录标识
|
|
|
+ private static String nckd_retired="nckd_retired";//薪酬明细(退休)分录标识
|
|
|
+ private static String nckd_pay="nckd_pay";//人力薪酬分录标识
|
|
|
+ private static String oldentryNum="oldentryNum";
|
|
|
+ private static String newentryNum="newentryNum";
|
|
|
+
|
|
|
+
|
|
|
+ public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
|
|
+// super.beforeDoOperation(args);
|
|
|
+// FormOperate source = (FormOperate) args.getSource();
|
|
|
+// String KEY_PAY = source.getOperateKey();
|
|
|
+// //判断是否是绑定操作编码
|
|
|
+// if (KEY_PAY.equals("操作编码")){
|
|
|
+// // 查询数据判断是否满足条件(校验):这里可以改成自已的逻辑
|
|
|
+// DynamicObject status = (DynamicObject) this.getModel().getValue("cqkd_workstatus");
|
|
|
+// if (status.getString("name").equals("xxx")){
|
|
|
+// // 显示确认消息
|
|
|
+// ConfirmCallBackListener confirmCallBacks = new ConfirmCallBackListener(KEY_PAY, this);
|
|
|
+// String confirmTip = "您确认要执行xxx操作吗?";
|
|
|
+// this.getView().showConfirm(confirmTip, MessageBoxOptions.YesNo, ConfirmTypes.Default, confirmCallBacks);
|
|
|
+// //确认或取消之前取消后续操作
|
|
|
+// args.setCancel(true);
|
|
|
+// }else {
|
|
|
+// //如果没有通过校验则显示xxx
|
|
|
+// this.getView().showMessage("xxx");
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+ }
|
|
|
+ //VieaFlag为分录标识,传入的分录显示,其他则隐藏
|
|
|
+ public void setVieeVisible(String Viewflag)
|
|
|
+ {
|
|
|
+ List<String> viewList=new ArrayList<>();
|
|
|
+ viewList.add(nckd_generalemployees);
|
|
|
+ viewList.add(nckd_earlyretired);
|
|
|
+ viewList.add(nckd_retired);
|
|
|
+ viewList.add(nckd_pay);
|
|
|
+
|
|
|
+ if (Viewflag.isEmpty()) {
|
|
|
+ for (String item:viewList) {
|
|
|
+ this.getView().setVisible(false,item);
|
|
|
+ }
|
|
|
+ //清空所有分录
|
|
|
+ //一般员工分录
|
|
|
+ this.getModel().deleteEntryData("nckd_staffentry");
|
|
|
+ //内退分录
|
|
|
+ this.getModel().deleteEntryData("nckd_earlyretiredentry");
|
|
|
+ //退休分录
|
|
|
+ this.getModel().deleteEntryData("nckd_retireentry");
|
|
|
+ //人力薪酬分录
|
|
|
+ this.getModel().deleteEntryData("nckd_salaryentry");
|
|
|
+ }
|
|
|
+ //薪酬明细(一般员工)分录
|
|
|
+ if (Viewflag.equals(nckd_generalemployees)) {
|
|
|
+ for (String item:viewList) {
|
|
|
+ this.getView().setVisible(false,item);
|
|
|
+ }
|
|
|
+ //内退分录
|
|
|
+ this.getModel().deleteEntryData("nckd_earlyretiredentry");
|
|
|
+ //退休分录
|
|
|
+ this.getModel().deleteEntryData("nckd_retireentry");
|
|
|
+ //人力薪酬分录
|
|
|
+ this.getModel().deleteEntryData("nckd_salaryentry");
|
|
|
+ this.getView().setVisible(true,nckd_generalemployees);
|
|
|
+ }
|
|
|
+ //薪酬明细(内退)分录
|
|
|
+ if (Viewflag.equals(nckd_earlyretired)) {
|
|
|
+ for (String item:viewList) {
|
|
|
+ this.getView().setVisible(false,item);
|
|
|
+ }
|
|
|
+ //一般员工分录
|
|
|
+ this.getModel().deleteEntryData("nckd_staffentry");
|
|
|
+ //退休分录
|
|
|
+ this.getModel().deleteEntryData("nckd_retireentry");
|
|
|
+ //人力薪酬分录
|
|
|
+ this.getModel().deleteEntryData("nckd_salaryentry");
|
|
|
+ this.getView().setVisible(true,nckd_earlyretired);
|
|
|
+ }
|
|
|
+ //薪酬明细(退休)分录
|
|
|
+ if (Viewflag.equals(nckd_retired)) {
|
|
|
+ for (String item:viewList) {
|
|
|
+ this.getView().setVisible(false,item);
|
|
|
+ }
|
|
|
+ //一般员工分录
|
|
|
+ this.getModel().deleteEntryData("nckd_staffentry");
|
|
|
+ //内退分录
|
|
|
+ this.getModel().deleteEntryData("nckd_earlyretiredentry");
|
|
|
+ //人力薪酬分录
|
|
|
+ this.getModel().deleteEntryData("nckd_salaryentry");
|
|
|
+ this.getView().setVisible(true,nckd_retired);
|
|
|
+ }
|
|
|
+ //人力薪酬分录
|
|
|
+ if (Viewflag.equals(nckd_pay)) {
|
|
|
+ for (String item:viewList) {
|
|
|
+ this.getView().setVisible(false,item);
|
|
|
+ }
|
|
|
+ //清空其他分录
|
|
|
+ //一般员工分录
|
|
|
+ this.getModel().deleteEntryData("nckd_staffentry");
|
|
|
+ //内退分录
|
|
|
+ this.getModel().deleteEntryData("nckd_earlyretiredentry");
|
|
|
+ //退休分录
|
|
|
+ this.getModel().deleteEntryData("nckd_retireentry");
|
|
|
+ this.getView().setVisible(true,nckd_pay);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ public void afterCreateNewData(EventObject e){
|
|
|
+ super.afterBindData(e);
|
|
|
+ //设置初始状态分录为不可见
|
|
|
+ this.setVieeVisible("");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public void propertyChanged(PropertyChangedArgs e)
|
|
|
+ {
|
|
|
+ super.beforePropertyChanged(e);
|
|
|
+ String name=e.getProperty().getName();
|
|
|
+ //获取单据模型
|
|
|
+ DynamicObject data=this.getModel().getDataEntity();
|
|
|
+
|
|
|
+ if (nckd_entrytype.equals(name)) {
|
|
|
+ //获取当前分录类型
|
|
|
+ ChangeData[] changeSet=e.getChangeSet();
|
|
|
+ ChangeData changeData=changeSet[0];
|
|
|
+// String oldValue =(String)changeData.getOldValue();
|
|
|
+// String newValue =(String)changeData.getNewValue() ;
|
|
|
+ oldentryNum=(String)changeData.getOldValue();
|
|
|
+ newentryNum=(String)changeData.getNewValue();
|
|
|
+ String entrytype=data.getString(nckd_entrytype);
|
|
|
+
|
|
|
+ if (entrytype.isEmpty()) {
|
|
|
+ this.setVieeVisible("");
|
|
|
+ }
|
|
|
+ //分录类型为薪酬明细(一般员工)
|
|
|
+ if (entrytype.equals("A")) {
|
|
|
+ ConfirmCallBackListener confirmCallBacks = new ConfirmCallBackListener(String.valueOf(false), this);
|
|
|
+ String confirmTip = "您确定要将分录类型改变为薪酬明细(一般员工)?操作会清空其他分录的数据,是否继续?";
|
|
|
+ this.getView().showConfirm(confirmTip,MessageBoxOptions.YesNo, ConfirmTypes.Default, confirmCallBacks);
|
|
|
+ }
|
|
|
+ //分录类型为薪酬明细(内退)
|
|
|
+ if (entrytype.equals("B")) {
|
|
|
+ ConfirmCallBackListener confirmCallBacks = new ConfirmCallBackListener(String.valueOf(false), this);
|
|
|
+ String confirmTip = "您确定要将分录类型改变为薪酬明细(内退)?操作会清空其他分录的数据,是否继续?";
|
|
|
+ this.getView().showConfirm(confirmTip,MessageBoxOptions.YesNo, ConfirmTypes.Default, confirmCallBacks);
|
|
|
+ }
|
|
|
+ //分录类型为薪酬明细退休
|
|
|
+ if (entrytype.equals("C")) {
|
|
|
+ ConfirmCallBackListener confirmCallBacks = new ConfirmCallBackListener(String.valueOf(false), this);
|
|
|
+ String confirmTip = "您确定要将分录类型改变为薪酬明细(退休)?操作会清空其他分录的数据,是否继续?";
|
|
|
+ this.getView().showConfirm(confirmTip,MessageBoxOptions.YesNo, ConfirmTypes.Default, confirmCallBacks);
|
|
|
+ }
|
|
|
+ //分录类型为人力薪酬
|
|
|
+ if (entrytype.equals("D")) {
|
|
|
+ ConfirmCallBackListener confirmCallBacks = new ConfirmCallBackListener(String.valueOf(false), this);
|
|
|
+ String confirmTip = "您确定要将分录类型改变为人力薪酬?操作会清空其他分录的数据,是否继续?";
|
|
|
+ this.getView().showConfirm(confirmTip,MessageBoxOptions.YesNo, ConfirmTypes.Default, confirmCallBacks);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //点击弹窗后回调
|
|
|
+ public void confirmCallBack(MessageBoxClosedEvent messageBoxClosedEvent) {
|
|
|
+ super.confirmCallBack(messageBoxClosedEvent);
|
|
|
+ DynamicObject data=this.getModel().getDataEntity();
|
|
|
+ //获取当前分录类型
|
|
|
+ String entrytype=data.getString(nckd_entrytype);
|
|
|
+ // 判断如果是确认按钮
|
|
|
+ if (messageBoxClosedEvent.getResult() == MessageBoxResult.Yes) {
|
|
|
+ //分录类型为薪酬明细(一般员工)
|
|
|
+ if (entrytype.equals("A")) {
|
|
|
+ this.setVieeVisible(nckd_generalemployees);
|
|
|
+ }
|
|
|
+ //分录类型为薪酬明细(内退)
|
|
|
+ if (entrytype.equals("B")) {
|
|
|
+ this.setVieeVisible(nckd_earlyretired);
|
|
|
+ }
|
|
|
+ //分录类型为薪酬明细退休
|
|
|
+ if (entrytype.equals("C")) {
|
|
|
+ this.setVieeVisible(nckd_retired);
|
|
|
+ }
|
|
|
+ //分录类型为人力薪酬
|
|
|
+ if (entrytype.equals("D")) {
|
|
|
+ this.setVieeVisible(nckd_pay);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //如果为取消,则
|
|
|
+ if (messageBoxClosedEvent.getResult()==MessageBoxResult.No)
|
|
|
+ {
|
|
|
+ //设置回原来的值,不触发值改变事件
|
|
|
+ this.getModel().beginInit();
|
|
|
+ data.set("nckd_entrytype",oldentryNum);
|
|
|
+ this.getModel().endInit();
|
|
|
+ this.getView().updateView();
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|