- 黑名单新增、删除、批量导入、批量移出在配置审批节点后,审批通过才生效 - 新增黑名单待提交后可提交审批;仅首节点未审批时可撤回,进入后续节点禁止撤回 - 增加黑名单审批列表、审批弹窗、审批操作日志及状态筛选 - 支持审批配置中的“黑名单审批”流程及对应菜单、模块权限、操作权限 - 黑名单审批中禁止同名记录覆盖备注;已在黑名单中的同名导入会明确提示本次将修改备注 - 未配置审批节点时保持原有直接生效行为 - 增加黑名单审批状态机单测,39/39 通过 - 修正撤回全部失败时仍提示“撤回审批成功”的问题
90 lines
3.5 KiB
C#
90 lines
3.5 KiB
C#
using YLErp.Model;
|
|
|
|
namespace YLErp.Modules.ClientModule
|
|
{
|
|
public static class ClientBlackApprovalPolicy
|
|
{
|
|
public static readonly string[] EffectiveStates =
|
|
{
|
|
client_black.已加入,
|
|
client_black.删除审批中,
|
|
client_black.删除已拒绝
|
|
};
|
|
|
|
public static bool IsEffective(string state)
|
|
{
|
|
return EffectiveStates.Contains(state);
|
|
}
|
|
|
|
public static bool CanSubmitAddition(string state)
|
|
{
|
|
return state == client_black.未提交 || state == client_black.新增已拒绝;
|
|
}
|
|
|
|
public static ClientBlackAdditionResult GetAdditionResult(bool hasApprovalProcess)
|
|
{
|
|
return hasApprovalProcess
|
|
? new ClientBlackAdditionResult(client_black.未提交, 0, false)
|
|
: new ClientBlackAdditionResult(client_black.已加入, -2, true);
|
|
}
|
|
|
|
public static bool CanRequestRemoval(string state)
|
|
{
|
|
return state == client_black.已加入 || state == client_black.删除已拒绝;
|
|
}
|
|
|
|
public static ClientBlackRemovalResult GetRemovalResult(bool hasApprovalProcess)
|
|
{
|
|
return hasApprovalProcess
|
|
? new ClientBlackRemovalResult(client_black.删除审批中, 1, false)
|
|
: new ClientBlackRemovalResult(client_black.已加入, -2, true);
|
|
}
|
|
|
|
public static bool CanReplaceRemarks(string state)
|
|
{
|
|
return state != client_black.新增审批中 && state != client_black.删除审批中;
|
|
}
|
|
|
|
public static bool CanWithdraw(string state, int approvalProcess)
|
|
{
|
|
return approvalProcess == 1 &&
|
|
(state == client_black.新增审批中 || state == client_black.删除审批中);
|
|
}
|
|
|
|
public static string GetRejectedState(string state)
|
|
{
|
|
return state switch
|
|
{
|
|
client_black.新增审批中 => client_black.新增已拒绝,
|
|
client_black.删除审批中 => client_black.删除已拒绝,
|
|
_ => throw new ArgumentException("当前状态不允许拒绝审批", nameof(state))
|
|
};
|
|
}
|
|
|
|
public static ClientBlackWithdrawResult GetWithdrawResult(string state)
|
|
{
|
|
return state switch
|
|
{
|
|
client_black.新增审批中 => new ClientBlackWithdrawResult(client_black.未提交, 0),
|
|
client_black.删除审批中 => new ClientBlackWithdrawResult(client_black.已加入, -2),
|
|
_ => throw new ArgumentException("当前状态不允许撤回审批", nameof(state))
|
|
};
|
|
}
|
|
|
|
public static ClientBlackFinalResult GetFinalResult(string state)
|
|
{
|
|
return state switch
|
|
{
|
|
client_black.新增审批中 => new ClientBlackFinalResult(client_black.已加入, false),
|
|
client_black.删除审批中 => new ClientBlackFinalResult(null, true),
|
|
_ => throw new ArgumentException("当前状态不允许完成审批", nameof(state))
|
|
};
|
|
}
|
|
}
|
|
|
|
public readonly record struct ClientBlackWithdrawResult(string State, int ApprovalProcess);
|
|
public readonly record struct ClientBlackFinalResult(string State, bool ShouldDelete);
|
|
public readonly record struct ClientBlackAdditionResult(string State, int ApprovalProcess, bool IsEffective);
|
|
public readonly record struct ClientBlackRemovalResult(string State, int ApprovalProcess, bool ShouldDelete);
|
|
}
|