- Updated core.py, init.py, opportunity_core.py, mysql.ddl.sql - Updated UI: base.ui, opportunity_management.ui - Added: opportunity.json, opportunity_stage_history.json - Added API files: opportunities CRUD, sales_stages_list, check_tables - Added UI/DSPY: opportunity_edit, opportunity_list, sales_stages_list
26 lines
1.1 KiB
Python
26 lines
1.1 KiB
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""Opportunity delete API"""
|
|
import json
|
|
|
|
result = {'widgettype': 'Message', 'options': {'title': 'Error', 'message': 'Invalid request', 'type': 'error'}}
|
|
|
|
try:
|
|
record_id = params_kw.get('id', '').strip()
|
|
if not record_id:
|
|
result['options'] = {'title': 'Error', 'message': '记录ID不能为空', 'type': 'error'}
|
|
else:
|
|
dbname = get_module_dbname('opportunity_management')
|
|
async with DBPools().sqlorContext(dbname) as sor:
|
|
existing = await sor.sqlExe("SELECT id FROM opportunities WHERE id = ${id}$", {'id': record_id})
|
|
if not existing:
|
|
result['options'] = {'title': 'Error', 'message': '商机不存在', 'type': 'error'}
|
|
else:
|
|
await sor.sqlExe("DELETE FROM opportunities WHERE id = ${id}$", {'id': record_id})
|
|
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)
|