Skip to content

默认审批系统插件#

功能介绍#

默认审批系统插件安装后,会在审批管理菜单下面添加默认请求处理页面,用于处理分配给当前审批系统的审批请求

创建审批动作#

X7nDTH.png

X45oyq.png

生成审批请求#

X7nulV.png

由于上个步骤中已经配置了针对创建生命周期配置的审批动作,所以该请求返回403 X59seS.png

查看审批请求#

X5Pr5Q.png

X5PDUg.png

处理审批请求#

X5nksH.png

X5nFQe.png

X5nPzD.png

实现思路#

抽象方法实现:#

代码#

extension_root.com_longgui_approve_system_arkid.ApproveSystemArkIDExtension (ApproveSystemExtension) #

Source code in extension_root/com_longgui_approve_system_arkid/__init__.py
class ApproveSystemArkIDExtension(ApproveSystemExtension):
    def load(self):
        super().load()
        self.register_api(
            f'/approve_requests/',
            'GET',
            self.list_tenant_approve_requests,
            response=List[ApproveRequestListItemOut],
            tenant_path=True,
        )
        self.register_approve_system_schema(
            ApproveSystemArkIDConfigSchema, 'approve_system_arkid'
        )
        self.register_front_pages([router_page, waiting_page, approved_page])
        self.register_front_routers(router, approve_manage_router)

    @operation(List[ApproveRequestListItemOut], roles=[TENANT_ADMIN, PLATFORM_ADMIN])
    @paginate(CustomPagination)
    def list_tenant_approve_requests(
        self, request, tenant_id: str, is_approved: str = ''
    ):
        package = 'com.longgui.approve.system.arkid'
        requests = ApproveRequest.valid_objects.filter(
            tenant=request.tenant, action__extension__package=package
        )
        if is_approved == 'true':
            requests = requests.exclude(status="wait")
        elif is_approved == 'false':
            requests = requests.filter(status="wait")
        return requests

    def create_approve_request(self, event, **kwargs):
        pass

    def pass_approve_request(self, request, approve_request):
        response = restore_approve_request(approve_request)
        logger.info(f'Restore approve request with result: {response}')

    def deny_approve_request(self, request, approve_request):
        pass

create_approve_request(self, event, **kwargs) #

抽象方法

Parameters:

Name Type Description Default
event arkid.core.event.Event

创建审批请求事件

required
Source code in extension_root/com_longgui_approve_system_arkid/__init__.py
def create_approve_request(self, event, **kwargs):
    pass

deny_approve_request(self, request, approve_request) #

抽象方法

Parameters:

Name Type Description Default
request django.http.HttpRequest

HTTP 请求

required
approve_request arkid.core.models.ApproveRequest

需要拒绝的审批请求

required
Source code in extension_root/com_longgui_approve_system_arkid/__init__.py
def deny_approve_request(self, request, approve_request):
    pass

load(self) #

抽象方法,插件加载的入口方法

Source code in extension_root/com_longgui_approve_system_arkid/__init__.py
def load(self):
    super().load()
    self.register_api(
        f'/approve_requests/',
        'GET',
        self.list_tenant_approve_requests,
        response=List[ApproveRequestListItemOut],
        tenant_path=True,
    )
    self.register_approve_system_schema(
        ApproveSystemArkIDConfigSchema, 'approve_system_arkid'
    )
    self.register_front_pages([router_page, waiting_page, approved_page])
    self.register_front_routers(router, approve_manage_router)

pass_approve_request(self, request, approve_request) #

抽象方法

Parameters:

Name Type Description Default
request django.http.HttpRequest

HTTP 请求

required
approve_request arkid.core.models.ApproveRequest

需要同意的审批请求

required
Source code in extension_root/com_longgui_approve_system_arkid/__init__.py
def pass_approve_request(self, request, approve_request):
    response = restore_approve_request(approve_request)
    logger.info(f'Restore approve request with result: {response}')

评论