- Updated all model JSON files: approval_instance, approval_step, approval_task, approval_workflow - Updated init.py, mysql.ddl.sql, mobile_base.ui - Added __init__.py - Added API files: instance CRUD, step CRUD, task approve/reject/list, workflow CRUD - Added UI files: base.ui, approval_instance.ui, approval_task.ui, approval_workflow.ui
41 lines
1.9 KiB
Python
41 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""Create approval step"""
|
|
import json, uuid
|
|
|
|
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}}
|
|
|
|
try:
|
|
workflow_id = params_kw.get('workflow_id', '')
|
|
step_name = params_kw.get('step_name', '')
|
|
step_order = params_kw.get('step_order', '1')
|
|
approver_type = params_kw.get('approver_type', '')
|
|
approver_value = params_kw.get('approver_value', '')
|
|
description = params_kw.get('description', '')
|
|
timeout_hours = params_kw.get('timeout_hours', '')
|
|
|
|
if not workflow_id or not step_name:
|
|
result['options'] = {'title': 'Error', 'message': '工作流ID和步骤名称不能为空', 'type': 'error'}
|
|
else:
|
|
dbname = get_module_dbname('workflow_approval')
|
|
new_id = str(uuid.uuid4()).replace('-', '')[:32]
|
|
org_id = '0'
|
|
|
|
async with DBPools().sqlorContext(dbname) as sor:
|
|
await sor.sqlExe("""
|
|
INSERT INTO approval_step (id, workflow_id, step_name, step_number, approver_role, approver_id, description, timeout_hours)
|
|
VALUES (${id}$, ${workflow_id}$, ${step_name}$, ${step_number}$, ${approver_role}$, ${approver_id}$, ${description}$, ${timeout_hours}$)
|
|
""", {
|
|
'id': new_id, 'workflow_id': workflow_id, 'step_name': step_name,
|
|
'step_number': int(step_order), 'approver_role': approver_type,
|
|
'approver_id': approver_value,
|
|
'description': description,
|
|
'timeout_hours': int(timeout_hours) if timeout_hours else None
|
|
})
|
|
|
|
result = {'widgettype': 'Message', 'options': {'title': 'Success', 'message': '步骤创建成功', 'type': 'success'}}
|
|
except Exception as e:
|
|
result['options'] = {'title': 'Error', 'message': f'创建失败: {str(e)}', 'type': 'error'}
|
|
|
|
return json.dumps(result, ensure_ascii=False)
|