Procházet zdrojové kódy

流程:按钮控制

4.0
郑根木 před 2 roky
rodič
revize
54f07d25ef
1 změnil soubory, kde provedl 41 přidání a 88 odebrání
  1. +41
    -88
      smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowInstance.java

+ 41
- 88
smtweb-framework/bpm/src/main/java/cc/smtweb/system/bpm/web/engine/flow/FlowInstance.java Zobrazit soubor

@@ -1,5 +1,6 @@
package cc.smtweb.system.bpm.web.engine.flow;

import cc.smtweb.framework.core.common.AbstractEnum;
import cc.smtweb.framework.core.common.SwMap;
import cc.smtweb.framework.core.db.DbEngine;
import cc.smtweb.framework.core.db.EntityDao;
@@ -17,6 +18,7 @@ import cc.smtweb.system.bpm.web.design.flow.ModelProcHelper;
import cc.smtweb.system.bpm.web.design.flow.define.Activity;
import cc.smtweb.system.bpm.web.design.flow.define.ProcInfo;
import cc.smtweb.system.bpm.web.engine.flow.entity.*;
import cc.smtweb.system.bpm.web.sys.base.billFlow.BillFlow;
import cc.smtweb.system.bpm.web.sys.user.dept.Dept;
import cc.smtweb.system.bpm.web.sys.user.dept.DeptCache;
import cc.smtweb.system.bpm.web.sys.user.party.Party;
@@ -392,101 +394,52 @@ public class FlowInstance {
}
}
extra.put("preTasks", tasks);
resetButtons();
List<SwMap> buttons = new ArrayList<>();
resetButtons(buttons);
extra.put("buttons", buttons);
}

public void resetButtons() {
Map<String, Integer> buttons = new HashMap<>();
private SwMap createButton(AbstractEnum.StrEnumBean type, boolean valid) {
SwMap button = new SwMap();
button.put("type", type);
button.put("label", type.name);
button.put("valid", valid);
return button;
}

public void resetButtons(List<SwMap> buttons) {
//按钮
buttons.clear();
long user_id = us.getUserId();
/*
//菜单权限
Map<String, String> mapPermisson = MenuHelper.getPermission(context);
//新增不要显示历史
boolean isNew = opt_mode == FlowConst.OperatorType.NEW;
boolean isAdmin = UserBaseEntityBuffer.getInstance().isAdmin(user_id);
boolean canEdit = MenuHelper.hasPermisson(mapPermisson, FlowConst.MenuFuncRight.ADD.value) || MenuHelper.hasPermisson(mapPermisson, FlowConst.MenuFuncRight.UPD.value);
boolean isNew = procDef.isNew();
boolean isFinish = procInst.getStatu() > FlowConst.InstanceStatu.RUNING.value;
//能否新增,菜单有授权+单据有流程分配
boolean canAdd = canEdit && BillFlowWfHelper.getBillProc(procInst.getBillType(), user_id) != null;
boolean canDel = MenuHelper.hasPermisson(mapPermisson, FlowConst.MenuFuncRight.DEL.value);
boolean canDis = MenuHelper.hasPermisson(mapPermisson, FlowConst.MenuFuncRight.DIS.value) && canEdit && !isNew;
//非制单人能否修改单据
boolean othCanEdit = BillFlowWfHelper.getPropBool(procDef.getEntityId(), FlowConst.NULL_STR, FlowConst.ProcProperty.CAN_EDIT_OTHER);

buttons.put(FlowConst.Button.LOG, isNew ? 0 : 1);
buttons.put(FlowConst.Button.WORD, isNew || !MenuHelper.hasPermisson(mapPermisson, FlowConst.MenuFuncRight.EXP.value) ? 0 : 1);
buttons.put(FlowConst.Button.EXCEL, isNew || !MenuHelper.hasPermisson(mapPermisson, FlowConst.MenuFuncRight.EXP.value) ? 0 : 1);
buttons.put(FlowConst.Button.DEL, !isNew ? 1 : 0);
buttons.put(FlowConst.Button.ADD, canAdd ? 1 : 0);
//buttons.put(FlowConst.Button.DISUSE, canDis ? 1 : 0);
buttons.put(FlowConst.Button.DISUSE, 0);

//单据作废
if (procInst.getStatu() == FlowConst.InstanceStatu.DISUSE.value) {
buttons.put(FlowConst.Button.DISUSE, 0);
buttons.put(FlowConst.Button.DEL, 0);
context.getDfpResponse().put("buttons", buttons);
return;
}
if (procInst.getStatu() == FlowConst.InstanceStatu.FINISH.value) {
buttons.put(FlowConst.Button.DEL, 0);
}
ActivityEntity act = ActivityEntityBuffer.getInstance().get(actInst.getActId());
//非制单状态时 编辑权限受 功能权限+流程修改权限+流程节点修改权限
boolean notMakeEdit = act != null && act.getActEdit() && othCanEdit && MenuHelper.hasPermisson(mapPermisson, FlowConst.MenuFuncRight.UPD.value);
boolean handler_make = isHandleMakeEx(act);

//当前任务是我办理的(我的待办任务,前面读取的时候也已经写了办理人为我了):
if (act == null || act.getType() == FlowConst.ActivityType.END.value) {
if (isAdmin) buttons.put(FlowConst.Button.RETAKE, 1);
buttons.put(FlowConst.Button.DISUSE, 0);
} else if (user_id.equalsIgnoreCase(actInst.getHandler()) || isAdmin) {
if (actInst.getStatu() == FlowConst.ActivityStatu.WAIT.value) {
//待办任务,显示办理按钮
if (notMakeEdit || handler_make) {
buttons.put(FlowConst.Button.HANDLER, 1);
buttons.put(FlowConst.Button.SUBMIT, 0);
} else {
buttons.put(FlowConst.Button.SUBMIT, 1);
buttons.put(FlowConst.Button.REJECT, 1);
buttons.put(FlowConst.Button.REJECT_MAKE, 1);
}
} else if (actInst.getStatu() == FlowConst.ActivityStatu.HANDLE.value) {
buttons.put(FlowConst.Button.SUBMIT, 1);
//办理中任务,提交/驳回
if (actInst.isMake()) {
buttons.put(FlowConst.Button.SAVE, 1);
if (canDel && !isNew) {
buttons.put(FlowConst.Button.DEL, 1);
}
} else {
if (notMakeEdit || handler_make) {
buttons.put(FlowConst.Button.SAVE, 1);
}
buttons.put(FlowConst.Button.REJECT, 1);
buttons.put(FlowConst.Button.REJECT_MAKE, 1);
}
} else if (actInst.getStatu() == FlowConst.ActivityStatu.SUBMIT.value) {
//我已提交的任务,取回(前面已经过滤掉不能取回的任务:下一任务已办理)
buttons.put(FlowConst.Button.RETAKE, 1);
}
} else if (actInst.getStatu() == FlowConst.ActivityStatu.WAIT.value && new ActinstDao().isMyWaitedTask(actInst.getTaskId(), user_id)) {
//待办任务,显示办理按钮
if (notMakeEdit || handler_make) {
buttons.put(FlowConst.Button.HANDLER, 1);
buttons.put(FlowConst.Button.SUBMIT, 0);
} else buttons.put(FlowConst.Button.SUBMIT, 1);
} else if (actInst.isMake() && actInst.getStatu() == FlowConst.ActivityStatu.HANDLE.value && canEdit && BillFlowWfHelper.getPropBool(procDef.getEntityId(), FlowConst.NULL_STR, FlowConst.ProcProperty.CAN_EDIT_OTHER)) {
//不是我的任务,制单任务判断属性,是否可以修改他人单据
ProcdefEntity def = BillFlowWfHelper.getBillProc(procInst.getBillType(), user_id);
if (def != null && def.getEntityId().equals(procDef.getEntityId())) {
buttons.put(FlowConst.Button.SAVE, 1);
buttons.put(FlowConst.Button.SUBMIT, 1);
}
}
context.getDfpResponse().put("buttons", buttons);
*/
boolean canAdd = ModelProcHelper.getBillProc(procInst.getBillType(), user_id) != null;
buttons.add(createButton(FlowConst.Button.ADD, canAdd));

boolean canDel = !isFinish && actInst.isMake() && !isNew;
buttons.add(createButton(FlowConst.Button.DEL, canDel));
buttons.add(createButton(FlowConst.Button.DISUSE, !isNew));
buttons.add(createButton(FlowConst.Button.LOG, !isNew));
buttons.add(createButton(FlowConst.Button.WORD, !isNew));
buttons.add(createButton(FlowConst.Button.EXCEL, !isNew));
buttons.add(createButton(FlowConst.Button.SAVE, !isFinish && actInst.isMake() && actInst.getHandler() == user_id));

boolean canHandle = !isFinish && actInst.getStatu() == FlowConst.ActivityStatu.WAIT.value && actInst.getHandler() == user_id;
buttons.add(createButton(FlowConst.Button.HANDLE, canHandle));

boolean canSubmit = !isFinish && actInst.getStatu() < FlowConst.ActivityStatu.SUBMIT.value && actInst.getHandler() == user_id;
buttons.add(createButton(FlowConst.Button.SUBMIT, canSubmit));

boolean canReject = !isFinish && !actInst.isMake() && actInst.getStatu() < FlowConst.ActivityStatu.SUBMIT.value && actInst.getHandler() == user_id;
buttons.add(createButton(FlowConst.Button.SUBMIT, canReject));
buttons.add(createButton(FlowConst.Button.INTERRUPT, canReject));

//我已提交的任务,取回(前面已经过滤掉不能取回的任务:下一任务已办理)
boolean canRetake = !isFinish && actInst.getStatu() == FlowConst.ActivityStatu.SUBMIT.value && actInst.getHandler() == user_id;
buttons.add(createButton(FlowConst.Button.RETAKE, canRetake));
}

/**


Načítá se…
Zrušit
Uložit