workflow_approval/wwwroot/api/workflow_update.dspy
yumoqing 5472211972 sync: local modifications to workflow_approval
- 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
2026-04-28 18:55:29 +08:00

41 lines
1.9 KiB
Python

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Update approval workflow"""
import json, time
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}}
try:
record_id = params_kw.get('id', '')
workflow_name = params_kw.get('workflow_name', '')
module_type = params_kw.get('module_type', '')
trigger_condition = params_kw.get('trigger_condition', '')
description = params_kw.get('description', '')
is_active = params_kw.get('is_active', 'Y')
if not record_id:
result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'}
else:
dbname = get_module_dbname('workflow_approval')
now = time.strftime('%Y-%m-%d %H:%M:%S')
async with DBPools().sqlorContext(dbname) as sor:
existing = await sor.sqlExe("SELECT id FROM approval_workflow WHERE id=${id}$", {'id': record_id})
if not existing:
result['options'] = {'title': 'Error', 'message': '工作流不存在', 'type': 'error'}
else:
await sor.sqlExe("""
UPDATE approval_workflow SET name=${name}$, module=${module}$,
trigger_event=${trigger_event}$, description=${description}$, status=${status}$,
updated_at=${updated_at}$ WHERE id=${id}$
""", {
'id': record_id, 'name': workflow_name, 'module': module_type,
'trigger_event': trigger_condition, 'description': description,
'status': is_active, 'updated_at': now
})
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)