bugfix
This commit is contained in:
parent
b6ff13734c
commit
fa8df43a5f
159
README.md
159
README.md
@ -1,159 +0,0 @@
|
||||
# 集成CRM应用程序
|
||||
|
||||
## 📋 概述
|
||||
这是一个完整的集成CRM应用程序,将8个核心模块无缝整合到一个统一的Web界面中:
|
||||
|
||||
1. **客户管理** - 客户档案、交接管理、公海池
|
||||
2. **商机管理** - 销售漏斗、阶段管理、漏斗可视化、成交预测(偏差率≤15%)
|
||||
3. **合同管理** - AI分析、里程碑跟踪、履约管理
|
||||
4. **财务管理** - 记账、应收应付、财务报表
|
||||
5. **审批工作流** - 跨模块审批、统一审批中心、移动端支持
|
||||
6. **统一仪表板** - 实时KPI、业务智能、移动端优化报表
|
||||
7. **基础模块** - 代码管理、参数管理
|
||||
8. **RBAC鉴权** - 用户管理、角色权限、多租户安全
|
||||
|
||||
## 🚀 主要特性
|
||||
|
||||
### 统一界面
|
||||
- **TabPanel导航**: 单页面应用,7个主要标签页
|
||||
- **响应式设计**: 自动适配桌面和移动设备
|
||||
- **一致的用户体验**: 所有模块使用统一的设计语言
|
||||
- **集中认证**: 基于RBAC的统一登录系统
|
||||
|
||||
### 模块集成
|
||||
- **客户 ↔ 商机**: 客户360°视图包含关联商机
|
||||
- **商机 ↔ 合同**: 一键生成合同,状态自动同步
|
||||
- **合同 ↔ 财务**: 合同里程碑自动生成应收
|
||||
- **跨模块审批**: 统一审批中心处理所有模块的审批需求
|
||||
- **统一仪表板**: 实时聚合所有模块的关键数据
|
||||
|
||||
### 移动端支持
|
||||
- **专用移动UI**: 审批和报表模块有专门的移动端界面
|
||||
- **触摸优化**: 大按钮、简化操作流程
|
||||
- **离线支持**: 关键审批操作支持离线缓存
|
||||
- **性能优化**: 移动端数据加载和渲染优化
|
||||
|
||||
## 🛠️ 技术架构
|
||||
|
||||
### 前端架构
|
||||
- **Bricks Framework**: JSON驱动的组件化UI系统
|
||||
- **主布局**: `base.ui` 使用TabPanel组织所有模块
|
||||
- **认证界面**: `login.ui` + `login.dspy` 集成RBAC认证
|
||||
- **模块集成**: Frame组件加载各个模块的UI
|
||||
|
||||
### 后端架构
|
||||
- **模块加载器**: `init.py` 按依赖顺序加载8个模块
|
||||
- **依赖顺序**: AppBase → RBAC → 业务模块 → 增强模块
|
||||
- **函数暴露**: ServerEnv暴露所有必需的函数
|
||||
- **异步设计**: 正确使用awaitify处理同步函数
|
||||
|
||||
### 数据库架构
|
||||
- **共享模式**: 所有模块使用同一数据库,通过org_id隔离
|
||||
- **引用完整性**: 外键维护数据一致性
|
||||
- **性能优化**: 在频繁查询字段上建立战略索引
|
||||
- **DDL生成**: 从JSON/XLSX定义自动生成模式
|
||||
|
||||
## 📂 目录结构
|
||||
```
|
||||
integrated_crm_app/
|
||||
├── integrated_crm_app/ # Python包
|
||||
│ ├── __init__.py # 包标记
|
||||
│ └── init.py # 主模块加载器
|
||||
├── wwwroot/ # 主应用前端
|
||||
│ ├── base.ui # 统一布局(TabPanel)
|
||||
│ ├── login.ui # 集中登录表单
|
||||
│ └── login.dspy # RBAC集成认证处理器
|
||||
├── build.sh # 构建脚本(处理所有模块)
|
||||
├── pyproject.toml # 包配置
|
||||
├── README.md # 详细文档
|
||||
└── integrated_crm_app_schema.sql # 数据库模式(构建时生成)
|
||||
```
|
||||
|
||||
## ⚡ 快速开始
|
||||
|
||||
### 1. 构建应用
|
||||
```bash
|
||||
cd ~/repos/integrated_crm_app
|
||||
./build.sh
|
||||
```
|
||||
|
||||
### 2. 创建数据库
|
||||
```sql
|
||||
-- 执行生成的SQL脚本
|
||||
mysql -u your_user -p your_database < integrated_crm_app_schema.sql
|
||||
```
|
||||
|
||||
### 3. 启动服务器
|
||||
```bash
|
||||
# 使用AhServer(推荐)
|
||||
ahserver --port 8080 --root wwwroot/
|
||||
|
||||
# 或使用其他Web服务器
|
||||
python3 -m http.server 8080 --directory wwwroot
|
||||
```
|
||||
|
||||
### 4. 访问应用
|
||||
- **登录页面**: http://localhost:8080/main/login.ui
|
||||
- **主界面**: 登录后自动跳转到 http://localhost:8080/main/base.ui
|
||||
|
||||
## 🔧 导航说明
|
||||
|
||||
### 主要功能区
|
||||
- **客户管理**: 客户档案、公海池、交接流程
|
||||
- **商机管理**: 销售漏斗、商机创建、阶段变更、预测分析
|
||||
- **合同管理**: 合同创建、AI分析、里程碑跟踪
|
||||
- **财务管理**: 记账、应收应付、财务报表
|
||||
- **审批中心**: 待处理任务、审批历史、工作流配置
|
||||
- **仪表板**: KPI卡片、趋势图表、个性化配置
|
||||
- **系统管理**: 用户、角色、参数、代码管理
|
||||
|
||||
### 移动端访问
|
||||
- 在手机浏览器中直接访问相同URL
|
||||
- 系统自动检测并提供移动端优化界面
|
||||
- 审批和报表功能在移动端完全可用
|
||||
|
||||
## 🎯 自定义点
|
||||
|
||||
### UI定制
|
||||
- 修改 `base.ui` 重新排列或添加标签页
|
||||
- 调整样式通过 `wwwroot/styles/` 目录
|
||||
|
||||
### 认证扩展
|
||||
- 扩展 `login.dspy` 添加额外认证方法
|
||||
- 集成LDAP、OAuth等外部认证源
|
||||
|
||||
### 业务逻辑
|
||||
- 在各模块中添加跨模块验证逻辑
|
||||
- 扩展审批触发条件和工作流规则
|
||||
|
||||
### 报表创建
|
||||
- 使用统一仪表板创建新的数据源组合
|
||||
- 开发自定义报表模板满足特定需求
|
||||
|
||||
## ✅ 验证清单
|
||||
|
||||
- [x] 所有8个模块按正确顺序加载
|
||||
- [x] 统一TabPanel界面显示所有模块
|
||||
- [x] 集中认证与RBAC无缝集成
|
||||
- [x] 跨模块数据关系正常工作
|
||||
- [x] 基于组织的数据隔离已实施
|
||||
- [x] 响应式设计在移动/桌面设备上工作
|
||||
- [x] 构建脚本处理所有模块类型(JSON/XLSX)
|
||||
- [x] 生产就绪代码具有适当的错误处理
|
||||
- [x] 完整文档在README.md中
|
||||
|
||||
## 🚀 扩展机会
|
||||
|
||||
### 高级功能
|
||||
- **工作流自动化**: 跨模块审批工作流
|
||||
- **高级分析**: 跨所有模块的统一仪表板
|
||||
- **移动应用**: 使用相同后端的原生移动界面
|
||||
- **API网关**: 用于外部集成的RESTful API层
|
||||
|
||||
### 集成场景
|
||||
- **ERP集成**: 连接外部会计系统
|
||||
- **营销自动化**: 链接邮件/活动平台
|
||||
- **文档管理**: 集成文件存储服务
|
||||
- **支付网关**: 连接在线支付处理器
|
||||
|
||||
这个集成CRM应用程序为企业客户关系管理提供了坚实的基础,具有完全的可扩展性和定制能力。
|
||||
37
app/integrated_crm_app.py
Normal file
37
app/integrated_crm_app.py
Normal file
@ -0,0 +1,37 @@
|
||||
from ahserver.webapp import webapp
|
||||
from ahserver.serverenv import ServerEnv
|
||||
|
||||
# Import required modules using the standard pattern
|
||||
from appbase.init import load_appbase
|
||||
from rbac.init import load_rbac
|
||||
from customer_management.init import load_customer_management
|
||||
from opportunity_management.init import load_opportunity_management
|
||||
from contract_management.init import load_contract_management
|
||||
from accounting.init import load_accounting
|
||||
from workflow_approval.init import load_workflow_approval
|
||||
from unified_dashboard.init import load_unified_dashboard
|
||||
|
||||
def get_module_name(m):
|
||||
"""
|
||||
Required function for all database-using modules.
|
||||
Returns the database name configured in config.json.
|
||||
Each module can use different databases.
|
||||
"""
|
||||
return 'crm_db' # Must match database name in config.json
|
||||
|
||||
def init():
|
||||
env = ServerEnv()
|
||||
env.get_module_name = get_module_name
|
||||
|
||||
# Load all modules
|
||||
load_appbase()
|
||||
load_rbac()
|
||||
load_customer_management()
|
||||
load_opportunity_management()
|
||||
load_contract_management()
|
||||
load_accounting()
|
||||
load_workflow_approval()
|
||||
load_unified_dashboard()
|
||||
|
||||
if __name__ == '__main__':
|
||||
webapp(init)
|
||||
183
build.sh
183
build.sh
@ -1,107 +1,126 @@
|
||||
#!/bin/bash
|
||||
# 集成CRM应用构建脚本
|
||||
|
||||
# Integrated CRM Application Build Script - Web Application Specification Compliant
|
||||
set -e
|
||||
|
||||
APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
MODULES_DIR="$HOME/repos"
|
||||
echo "🚀 构建集成CRM应用在: $APP_DIR"
|
||||
echo "🚀 Building Integrated CRM Application at: $APP_DIR"
|
||||
|
||||
# 创建必要的目录
|
||||
mkdir -p "$APP_DIR/wwwroot/styles"
|
||||
mkdir -p "$APP_DIR/wwwroot/scripts"
|
||||
# Step 1: Create required directories
|
||||
mkdir -p "$APP_DIR/pkgs"
|
||||
mkdir -p "$APP_DIR/logs"
|
||||
mkdir -p "$APP_DIR/files"
|
||||
|
||||
# 步骤1: 验证所有必需模块是否存在
|
||||
REQUIRED_MODULES=(
|
||||
"appbase"
|
||||
"rbac"
|
||||
"customer_management"
|
||||
"opportunity_management"
|
||||
"contract_management"
|
||||
"accounting"
|
||||
"workflow_approval"
|
||||
"unified_dashboard"
|
||||
)
|
||||
# Step 2: Setup Python virtual environment and install core dependencies
|
||||
echo "📦 Installing core dependencies..."
|
||||
pip install git+https://git.opencomputing.cn/yumoqing/apppublic
|
||||
pip install git+https://git.opencomputing.cn/yumoqing/sqlor
|
||||
pip install git+https://git.opencomputing.cn/yumoqing/ahserver
|
||||
pip install xls2ddl
|
||||
|
||||
echo "🔍 验证必需模块..."
|
||||
for module in "${REQUIRED_MODULES[@]}"; do
|
||||
if [ ! -d "$MODULES_DIR/$module" ]; then
|
||||
echo "❌ 错误: 模块 $module 不存在!"
|
||||
exit 1
|
||||
fi
|
||||
echo "✅ 模块 $module 已找到"
|
||||
# Step 3: Clone and install database modules
|
||||
echo "📥 Cloning and installing database modules..."
|
||||
|
||||
# Foundation modules
|
||||
cd "$APP_DIR/pkgs"
|
||||
git clone https://git.opencomputing.cn/yumoqing/appbase.git
|
||||
git clone https://git.opencomputing.cn/yumoqing/rbac.git
|
||||
|
||||
# Business modules
|
||||
git clone https://git.opencomputing.cn/yumoqing/customer_management.git
|
||||
git clone https://git.opencomputing.cn/yumoqing/opportunity_management.git
|
||||
git clone https://git.opencomputing.cn/yumoqing/contract_management.git
|
||||
git clone https://git.opencomputing.cn/yumoqing/accounting.git
|
||||
git clone https://git.opencomputing.cn/yumoqing/workflow_approval.git
|
||||
git clone https://git.opencomputing.cn/yumoqing/unified_dashboard.git
|
||||
|
||||
# Install all modules
|
||||
for module in appbase rbac customer_management opportunity_management contract_management accounting workflow_approval unified_dashboard; do
|
||||
echo "Installing $module..."
|
||||
pip install -e "$APP_DIR/pkgs/$module"
|
||||
done
|
||||
|
||||
# 步骤2: 运行各模块的构建脚本(如果存在)
|
||||
echo "🔨 构建各个模块..."
|
||||
for module in "${REQUIRED_MODULES[@]}"; do
|
||||
if [ -f "$MODULES_DIR/$module/build.sh" ]; then
|
||||
echo "执行 $module 构建脚本..."
|
||||
cd "$MODULES_DIR/$module" && ./build.sh
|
||||
# Step 4: Generate database DDL for all modules with models/
|
||||
echo "📊 Generating database DDL..."
|
||||
|
||||
# Process each module that has models/
|
||||
for module in appbase rbac customer_management opportunity_management contract_management accounting workflow_approval unified_dashboard; do
|
||||
if [ -d "$APP_DIR/pkgs/$module/models" ]; then
|
||||
echo "Processing models for $module..."
|
||||
cd "$APP_DIR/pkgs/$module/models"
|
||||
|
||||
# Check for .xlsx files first
|
||||
if ls *.xlsx >/dev/null 2>&1; then
|
||||
xls2ddl mysql . > "$APP_DIR/pkgs/$module/mysql.ddl.sql"
|
||||
# Check for .json files
|
||||
elif ls *.json >/dev/null 2>&1; then
|
||||
json2ddl mysql . > "$APP_DIR/pkgs/$module/mysql.ddl.sql"
|
||||
fi
|
||||
|
||||
# Apply DDL if generated
|
||||
if [ -f "$APP_DIR/pkgs/$module/mysql.ddl.sql" ] && [ -s "$APP_DIR/pkgs/$module/mysql.ddl.sql" ]; then
|
||||
echo "Generated DDL for $module"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# 步骤3: 复制所有模块的wwwroot内容到主应用
|
||||
echo "📁 复制模块资源..."
|
||||
for module in "${REQUIRED_MODULES[@]}"; do
|
||||
if [ -d "$MODULES_DIR/$module/wwwroot" ]; then
|
||||
echo "复制 $module 资源..."
|
||||
cp -r "$MODULES_DIR/$module/wwwroot/"* "$APP_DIR/wwwroot/" 2>/dev/null || true
|
||||
# Step 5: Generate CRUD UI for all modules with json/
|
||||
echo "🎨 Generating CRUD UI..."
|
||||
|
||||
for module in appbase rbac customer_management opportunity_management contract_management accounting workflow_approval unified_dashboard; do
|
||||
if [ -d "$APP_DIR/pkgs/$module/json" ] && [ -d "$APP_DIR/pkgs/$module/models" ]; then
|
||||
echo "Generating UI for $module..."
|
||||
cd "$APP_DIR/pkgs/$module/json"
|
||||
xls2ui -m ../models -o ../wwwroot $module *.json
|
||||
fi
|
||||
done
|
||||
|
||||
# 步骤4: 生成数据库DDL脚本
|
||||
echo "📊 生成数据库模式..."
|
||||
DDL_FILES=()
|
||||
for module in "${REQUIRED_MODULES[@]}"; do
|
||||
if [ -f "$MODULES_DIR/$module/mysql.ddl.sql" ] && [ -s "$MODULES_DIR/$module/mysql.ddl.sql" ]; then
|
||||
DDL_FILES+=("$MODULES_DIR/$module/mysql.ddl.sql")
|
||||
# Step 6: Create symbolic links for wwwroot
|
||||
echo "🔗 Creating symbolic links..."
|
||||
|
||||
# Link all module wwwroot directories
|
||||
for module in appbase rbac customer_management opportunity_management contract_management accounting workflow_approval unified_dashboard; do
|
||||
if [ -d "$APP_DIR/pkgs/$module/wwwroot" ]; then
|
||||
ln -sf "$APP_DIR/pkgs/$module/wwwroot" "$APP_DIR/wwwroot/$module"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${#DDL_FILES[@]} -gt 0 ]; then
|
||||
echo "合并数据库DDL脚本..."
|
||||
{
|
||||
echo "-- 集成CRM应用数据库模式"
|
||||
echo "-- 生成时间: $(date)"
|
||||
echo ""
|
||||
for ddl_file in "${DDL_FILES[@]}"; do
|
||||
echo "-- 来源: $(basename "$ddl_file")"
|
||||
cat "$ddl_file"
|
||||
echo ""
|
||||
done
|
||||
} > "$APP_DIR/integrated_crm_app_schema.sql"
|
||||
echo "✅ 数据库模式已生成: integrated_crm_app_schema.sql"
|
||||
else
|
||||
echo "⚠️ 警告: 未找到任何DDL文件"
|
||||
# Step 7: Setup Bricks framework
|
||||
echo "🏗️ Setting up Bricks framework..."
|
||||
|
||||
if [ ! -d "$APP_DIR/pkgs/bricks" ]; then
|
||||
cd "$APP_DIR/pkgs"
|
||||
git clone https://git.opencomputing.cn/yumoqing/bricks.git
|
||||
fi
|
||||
|
||||
# 步骤5: 创建符号链接(如果使用AhServer)
|
||||
echo "🔗 创建符号链接..."
|
||||
if command -v ahserver &> /dev/null; then
|
||||
echo "AhServer可用,创建符号链接..."
|
||||
# 这里会根据实际部署环境创建适当的链接
|
||||
# Build bricks if needed
|
||||
if [ -f "$APP_DIR/pkgs/bricks/build.sh" ]; then
|
||||
cd "$APP_DIR/pkgs/bricks" && ./build.sh
|
||||
fi
|
||||
|
||||
# 步骤6: 验证集成
|
||||
echo "🧪 验证模块加载..."
|
||||
cd "$APP_DIR" && python3 -c "
|
||||
import sys
|
||||
sys.path.insert(0, '.')
|
||||
from integrated_crm_app.init import initialize_crm_application
|
||||
try:
|
||||
modules = initialize_crm_application()
|
||||
print('✅ 所有模块加载成功!')
|
||||
except Exception as e:
|
||||
print(f'❌ 模块加载失败: {e}')
|
||||
sys.exit(1)
|
||||
"
|
||||
# Link bricks dist directory
|
||||
ln -sf "$APP_DIR/pkgs/bricks/dist" "$APP_DIR/wwwroot/bricks"
|
||||
|
||||
# Step 8: Create systemd service (optional for development)
|
||||
echo "⚙️ Creating service scripts..."
|
||||
|
||||
cat > "$APP_DIR/start.sh" << 'EOF'
|
||||
#!/bin/bash
|
||||
source .env
|
||||
python3 app/integrated_crm_app.py --port 8080 --root wwwroot/
|
||||
EOF
|
||||
|
||||
cat > "$APP_DIR/stop.sh" << 'EOF'
|
||||
#!/bin/bash
|
||||
pkill -f "integrated_crm_app.py"
|
||||
EOF
|
||||
|
||||
chmod +x "$APP_DIR/start.sh" "$APP_DIR/stop.sh"
|
||||
|
||||
echo ""
|
||||
echo "🎉 集成CRM应用构建完成!"
|
||||
echo "✅ Integrated CRM Application build completed!"
|
||||
echo ""
|
||||
echo "📋 下一步操作:"
|
||||
echo "1. 执行数据库脚本: mysql -u user -p database < integrated_crm_app_schema.sql"
|
||||
echo "2. 启动应用服务器: ahserver --port 8080 --root wwwroot/"
|
||||
echo "3. 访问登录页面: http://localhost:8080/main/login.ui"
|
||||
echo ""
|
||||
echo "📋 Next steps:"
|
||||
echo "1. Update conf/config.json with your database credentials"
|
||||
echo "2. Source environment: source .env"
|
||||
echo "3. Start application: ./start.sh"
|
||||
echo "4. Access at: http://localhost:8080/main/login.ui"
|
||||
33
conf/config.json
Normal file
33
conf/config.json
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
"password_key": "your-encryption-key-here",
|
||||
"logger": {
|
||||
"name": "integrated_crm_app",
|
||||
"level": "info",
|
||||
"file": "$[workdir]$/logs/app.log"
|
||||
},
|
||||
"filesroot": "$[workdir]$/files",
|
||||
"databases": {
|
||||
"crm_db": {
|
||||
"driver": "mysql",
|
||||
"kwargs": {
|
||||
"host": "localhost",
|
||||
"port": 3306,
|
||||
"user": "crm_user",
|
||||
"passwd": "crm_password",
|
||||
"db": "crm_database"
|
||||
}
|
||||
}
|
||||
},
|
||||
"website": {
|
||||
"paths": [
|
||||
"/main/login.ui"
|
||||
],
|
||||
"processors": {
|
||||
".ui": "bui",
|
||||
".dspy": "dspy"
|
||||
},
|
||||
"session_max_time": 3600,
|
||||
"session_issue_time": 1800,
|
||||
"client_max_size": 10485760
|
||||
}
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
# Integrated CRM Application Package
|
||||
Binary file not shown.
@ -1,76 +0,0 @@
|
||||
"""
|
||||
集成CRM应用 - 主模块加载器
|
||||
|
||||
负责按正确顺序加载所有8个核心模块:
|
||||
1. AppBase (基础模块)
|
||||
2. RBAC (权限控制)
|
||||
3. Customer Management (客户管理)
|
||||
4. Opportunity Management (商机管理)
|
||||
5. Contract Management (合同管理)
|
||||
6. Financial Management (财务管理)
|
||||
7. Workflow Approval (审批工作流)
|
||||
8. Unified Dashboard (统一仪表板)
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# 添加模块路径到Python路径
|
||||
MODULES_DIR = Path("~/repos").expanduser()
|
||||
sys.path.insert(0, str(MODULES_DIR))
|
||||
|
||||
def load_module(module_name):
|
||||
"""动态加载模块"""
|
||||
try:
|
||||
module = __import__(module_name)
|
||||
print(f"✅ 成功加载模块: {module_name}")
|
||||
return module
|
||||
except ImportError as e:
|
||||
print(f"❌ 模块加载失败: {module_name} - {e}")
|
||||
raise
|
||||
|
||||
def initialize_crm_application():
|
||||
"""初始化完整的CRM应用程序"""
|
||||
print("🚀 开始初始化集成CRM应用程序...")
|
||||
|
||||
# 1. 加载基础模块 (AppBase)
|
||||
appbase = load_module('appbase')
|
||||
|
||||
# 2. 加载权限模块 (RBAC)
|
||||
rbac = load_module('rbac')
|
||||
|
||||
# 3. 加载业务模块
|
||||
customer_management = load_module('customer_management')
|
||||
opportunity_management = load_module('opportunity_management')
|
||||
contract_management = load_module('contract_management')
|
||||
accounting = load_module('accounting') # 财务管理模块
|
||||
|
||||
# 4. 加载增强模块
|
||||
workflow_approval = load_module('workflow_approval')
|
||||
unified_dashboard = load_module('unified_dashboard')
|
||||
|
||||
# 5. 验证模块信息
|
||||
modules_info = {
|
||||
'appbase': appbase.get_module_info() if hasattr(appbase, 'get_module_info') else {'name': 'appbase'},
|
||||
'rbac': rbac.get_module_info() if hasattr(rbac, 'get_module_info') else {'name': 'rbac'},
|
||||
'customer_management': customer_management.get_module_info() if hasattr(customer_management, 'get_module_info') else {'name': 'customer_management'},
|
||||
'opportunity_management': opportunity_management.get_module_info() if hasattr(opportunity_management, 'get_module_info') else {'name': 'opportunity_management'},
|
||||
'contract_management': contract_management.get_module_info() if hasattr(contract_management, 'get_module_info') else {'name': 'contract_management'},
|
||||
'accounting': accounting.get_module_info() if hasattr(accounting, 'get_module_info') else {'name': 'accounting'},
|
||||
'workflow_approval': workflow_approval.get_module_info() if hasattr(workflow_approval, 'get_module_info') else {'name': 'workflow_approval'},
|
||||
'unified_dashboard': unified_dashboard.get_module_info() if hasattr(unified_dashboard, 'get_module_info') else {'name': 'unified_dashboard'}
|
||||
}
|
||||
|
||||
print("\n📋 已成功加载的模块清单:")
|
||||
for module_name, info in modules_info.items():
|
||||
version = info.get('version', '未知')
|
||||
description = info.get('description', '无描述')
|
||||
print(f" • {module_name} v{version} - {description}")
|
||||
|
||||
print(f"\n🎉 集成CRM应用程序初始化完成!共加载 {len(modules_info)} 个模块")
|
||||
return modules_info
|
||||
|
||||
# 应用程序入口点
|
||||
if __name__ == "__main__":
|
||||
initialize_crm_application()
|
||||
@ -1,71 +0,0 @@
|
||||
-- 集成CRM应用数据库模式
|
||||
-- 生成时间: Thu Apr 16 14:27:53 CST 2026
|
||||
|
||||
-- 来源: mysql.ddl.sql
|
||||
-- 商机管理模块数据库表结构
|
||||
|
||||
-- 1. 商机表 (opportunities)
|
||||
CREATE TABLE IF NOT EXISTS opportunities (
|
||||
id VARCHAR(64) PRIMARY KEY,
|
||||
customer_name VARCHAR(255) NOT NULL COMMENT '客户名称',
|
||||
customer_id VARCHAR(64) COMMENT '客户ID(关联客户管理模块)',
|
||||
estimated_amount DECIMAL(15,2) NOT NULL COMMENT '预估金额',
|
||||
sales_stage VARCHAR(64) NOT NULL COMMENT '销售阶段',
|
||||
expected_close_date DATE NOT NULL COMMENT '预计成交时间',
|
||||
actual_close_date DATE COMMENT '实际成交时间',
|
||||
source VARCHAR(32) DEFAULT 'manual' COMMENT '来源: manual/lead_conversion',
|
||||
description TEXT COMMENT '描述',
|
||||
owner_id VARCHAR(64) NOT NULL COMMENT '负责人ID',
|
||||
org_id VARCHAR(64) NOT NULL COMMENT '组织ID',
|
||||
status VARCHAR(32) DEFAULT 'active' COMMENT '状态: active/won/lost/deleted',
|
||||
probability DECIMAL(5,4) DEFAULT 0.1000 COMMENT '成交概率',
|
||||
next_action_date DATE COMMENT '下次行动日期',
|
||||
next_action_description VARCHAR(255) COMMENT '下次行动描述',
|
||||
tags VARCHAR(255) COMMENT '标签',
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
INDEX idx_customer_id (customer_id),
|
||||
INDEX idx_sales_stage (sales_stage),
|
||||
INDEX idx_owner_id (owner_id),
|
||||
INDEX idx_org_id (org_id),
|
||||
INDEX idx_status (status),
|
||||
INDEX idx_expected_close_date (expected_close_date)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- 2. 商机阶段变更历史表 (opportunity_stage_history)
|
||||
CREATE TABLE IF NOT EXISTS opportunity_stage_history (
|
||||
id VARCHAR(64) PRIMARY KEY,
|
||||
opportunity_id VARCHAR(64) NOT NULL,
|
||||
old_stage VARCHAR(64) NOT NULL COMMENT '原阶段',
|
||||
new_stage VARCHAR(64) NOT NULL COMMENT '新阶段',
|
||||
change_reason TEXT NOT NULL COMMENT '变更原因',
|
||||
changed_by VARCHAR(64) NOT NULL COMMENT '变更人ID',
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
INDEX idx_opportunity_id (opportunity_id),
|
||||
INDEX idx_changed_by (changed_by),
|
||||
FOREIGN KEY (opportunity_id) REFERENCES opportunities(id) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- 3. 销售漏斗配置表 (sales_funnel_config)
|
||||
CREATE TABLE IF NOT EXISTS sales_funnel_config (
|
||||
id VARCHAR(64) PRIMARY KEY,
|
||||
org_id VARCHAR(64) NOT NULL,
|
||||
stage_name VARCHAR(64) NOT NULL COMMENT '阶段名称',
|
||||
stage_order INT NOT NULL COMMENT '阶段顺序',
|
||||
default_probability DECIMAL(5,4) NOT NULL COMMENT '默认成交概率',
|
||||
color_code VARCHAR(16) COMMENT '颜色代码',
|
||||
is_active TINYINT(1) DEFAULT 1 COMMENT '是否激活',
|
||||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
UNIQUE KEY uk_org_stage (org_id, stage_name),
|
||||
INDEX idx_org_id (org_id),
|
||||
INDEX idx_stage_order (stage_order)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- 插入默认销售漏斗配置
|
||||
INSERT IGNORE INTO sales_funnel_config (id, org_id, stage_name, stage_order, default_probability, color_code) VALUES
|
||||
(REPLACE(UUID(), '-', ''), 'default', '初步接洽', 1, 0.1000, '#FF6B6B'),
|
||||
(REPLACE(UUID(), '-', ''), 'default', '需求确认', 2, 0.3000, '#4ECDC4'),
|
||||
(REPLACE(UUID(), '-', ''), 'default', '方案报价', 3, 0.5000, '#45B7D1'),
|
||||
(REPLACE(UUID(), '-', ''), 'default', '合同谈判', 4, 0.7000, '#96CEB4'),
|
||||
(REPLACE(UUID(), '-', ''), 'default', '成交', 5, 1.0000, '#FFEAA7');
|
||||
@ -1,38 +0,0 @@
|
||||
[build-system]
|
||||
requires = ["setuptools>=45", "wheel"]
|
||||
build-backend = "setuptools.build_meta"
|
||||
|
||||
[project]
|
||||
name = "integrated-crm-app"
|
||||
version = "1.0.0"
|
||||
description = "Complete integrated CRM application combining customer management, contract management, opportunity management, financial management, workflow approval, unified dashboard, appbase foundation, and RBAC security modules"
|
||||
authors = [{name = "Hermes Agent", email = "hermes@ai"}]
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.8"
|
||||
classifiers = [
|
||||
"Development Status :: 5 - Production/Stable",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
]
|
||||
dependencies = [
|
||||
"appbase",
|
||||
"rbac",
|
||||
"customer_management",
|
||||
"opportunity_management",
|
||||
"contract_management",
|
||||
"accounting",
|
||||
"workflow_approval",
|
||||
"unified_dashboard"
|
||||
]
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://github.com/hermes-ai/integrated-crm-app"
|
||||
Repository = "https://github.com/hermes-ai/integrated-crm-app"
|
||||
|
||||
[tool.setuptools.packages.find]
|
||||
where = ["."]
|
||||
include = ["integrated_crm_app*"]
|
||||
168
skill/SKILL.md
168
skill/SKILL.md
@ -1,168 +0,0 @@
|
||||
---
|
||||
name: integrated-crm-app
|
||||
version: 1.0.0
|
||||
description: Complete integrated CRM application combining customer management, contract management, opportunity management, financial management, appbase foundation, and RBAC security modules into a unified web application.
|
||||
trigger_conditions:
|
||||
- User requests to create an integrated CRM system
|
||||
- Task involves combining multiple business modules into a single application
|
||||
- Need unified interface for customer, contract, opportunity, and financial management
|
||||
- Require RBAC security and appbase foundation integration
|
||||
---
|
||||
|
||||
# Integrated CRM Application
|
||||
|
||||
## Overview
|
||||
This skill provides a complete, production-ready integrated CRM application that seamlessly combines six core modules into a unified web interface:
|
||||
|
||||
1. **Customer Management** - Comprehensive client lifecycle management
|
||||
2. **Opportunity Management** - Sales pipeline and revenue forecasting
|
||||
3. **Contract Management** - AI-powered contract lifecycle with milestone tracking
|
||||
4. **Financial Management** - Order-level receivables and payments management
|
||||
5. **AppBase** - Foundation module for code and parameter management
|
||||
6. **RBAC** - Role-based access control and multi-tenant security
|
||||
|
||||
The application follows all established module development specifications and provides a cohesive user experience through a tab-based navigation interface.
|
||||
|
||||
## Core Features
|
||||
|
||||
### Unified Interface
|
||||
- **TabPanel Navigation**: Single-page application with six main tabs
|
||||
- **Responsive Design**: Adapts to different screen sizes and devices
|
||||
- **Consistent UX**: Uniform styling and interaction patterns across all modules
|
||||
- **Integrated Login**: Centralized authentication using RBAC module
|
||||
|
||||
### Module Integration Points
|
||||
|
||||
#### Customer ↔ Opportunity Integration
|
||||
- Customer 360° view includes associated opportunities
|
||||
- Opportunity creation can reference existing customers
|
||||
- Handover workflows include both customer and opportunity data
|
||||
|
||||
#### Opportunity ↔ Contract Integration
|
||||
- One-click contract generation from opportunities
|
||||
- Contract status automatically updates opportunity stage
|
||||
- Revenue forecasting considers both open opportunities and active contracts
|
||||
|
||||
#### Contract ↔ Financial Integration
|
||||
- Automatic receivable creation from contract payment milestones
|
||||
- Order-level financial tracking linked to contract fulfillment
|
||||
- Payment completion triggers contract milestone updates
|
||||
|
||||
#### Financial ↔ Customer Integration
|
||||
- Customer financial summary shows total receivables/payments
|
||||
- Overdue notifications sent to both sales and finance teams
|
||||
- Customer credit limits enforced during opportunity/contract creation
|
||||
|
||||
### Security and Multi-tenancy
|
||||
- **Organization Isolation**: All data separated by org_id
|
||||
- **RBAC Permissions**: Fine-grained access control per module and function
|
||||
- **Audit Trail**: Comprehensive logging of all critical operations
|
||||
- **API Key Management**: Programmatic access via userapp table
|
||||
|
||||
## Technical Architecture
|
||||
|
||||
### Frontend Architecture
|
||||
- **Bricks Framework**: JSON-driven component system
|
||||
- **Main Layout**: `base.ui` with TabPanel organizing all modules
|
||||
- **Authentication**: `login.ui` + `login.dspy` using RBAC functions
|
||||
- **Module Integration**: Frame components loading individual module UIs
|
||||
|
||||
### Backend Architecture
|
||||
- **Module Loader**: `init.py` loads all six modules in correct order
|
||||
- **Dependency Order**: AppBase → RBAC → Business Modules
|
||||
- **Function Exposure**: ServerEnv exposes all required functions
|
||||
- **Async Design**: Proper awaitify usage for synchronous functions
|
||||
|
||||
### Database Architecture
|
||||
- **Shared Schema**: All modules use same database with org_id isolation
|
||||
- **Referential Integrity**: Foreign keys maintain data consistency
|
||||
- **Performance Optimization**: Strategic indexing on frequently queried fields
|
||||
- **DDL Generation**: Automated schema creation from JSON/XLSX definitions
|
||||
|
||||
## Directory Structure
|
||||
```
|
||||
integrated_crm_app/
|
||||
├── integrated_crm_app/ # Python package
|
||||
│ ├── __init__.py # Package marker
|
||||
│ └── init.py # Main module loader
|
||||
├── wwwroot/ # Main application frontend
|
||||
│ ├── base.ui # Unified layout with TabPanel
|
||||
│ ├── login.ui # Centralized login form
|
||||
│ └── login.dspy # RBAC-integrated auth handler
|
||||
├── build.sh # Build script for all modules
|
||||
├── pyproject.toml # Package configuration
|
||||
└── README.md # Comprehensive documentation
|
||||
```
|
||||
|
||||
## Implementation Workflow
|
||||
|
||||
### Step 1: Module Preparation
|
||||
- Ensure all six modules exist in `~/repos/` directory
|
||||
- Verify each module follows development specifications
|
||||
- Confirm database table definitions are complete
|
||||
|
||||
### Step 2: Main Application Setup
|
||||
- Create main application directory structure
|
||||
- Implement unified `init.py` module loader
|
||||
- Design `base.ui` TabPanel layout
|
||||
- Create centralized authentication flow
|
||||
|
||||
### Step 3: Build Integration
|
||||
- Implement `build.sh` script to process all modules
|
||||
- Generate DDL scripts for database schema
|
||||
- Create symbolic links for frontend resources
|
||||
- Test module loading and function exposure
|
||||
|
||||
### Step 4: Testing and Validation
|
||||
- Verify all modules load without conflicts
|
||||
- Test cross-module data integration
|
||||
- Validate RBAC permissions across all functions
|
||||
- Confirm responsive design on different devices
|
||||
|
||||
## Usage Instructions
|
||||
|
||||
### Installation
|
||||
1. Place all six modules in `~/repos/` directory
|
||||
2. Run `./build.sh` to generate database schemas and links
|
||||
3. Execute DDL scripts to create database tables
|
||||
4. Start AhServer with the integrated application
|
||||
|
||||
### Navigation
|
||||
- **Login**: Access `/main/login.ui` for authentication
|
||||
- **Main Interface**: Redirects to `/main/base.ui` after login
|
||||
- **Module Switching**: Use TabPanel to navigate between modules
|
||||
- **System Admin**: Last tab contains RBAC and AppBase management
|
||||
|
||||
### Customization Points
|
||||
- **UI Layout**: Modify `base.ui` to rearrange or add tabs
|
||||
- **Authentication**: Extend `login.dspy` for additional auth methods
|
||||
- **Business Logic**: Add cross-module validation in individual modules
|
||||
- **Reporting**: Create new reports using combined data sources
|
||||
|
||||
## Verification Checklist
|
||||
|
||||
- [x] All six modules load correctly in dependency order
|
||||
- [x] Unified TabPanel interface displays all modules
|
||||
- [x] Centralized authentication works with RBAC
|
||||
- [x] Cross-module data relationships function properly
|
||||
- [x] Organization-based data isolation enforced
|
||||
- [x] Responsive design works on mobile/desktop
|
||||
- [x] Build script processes all module types (JSON/XLSX)
|
||||
- [x] Production-ready code with proper error handling
|
||||
- [x] Complete documentation in README.md
|
||||
|
||||
## Extension Opportunities
|
||||
|
||||
### Advanced Features
|
||||
- **Workflow Automation**: Cross-module approval workflows
|
||||
- **Advanced Analytics**: Unified dashboards across all modules
|
||||
- **Mobile App**: Native mobile interface using same backend
|
||||
- **API Gateway**: RESTful API layer for external integration
|
||||
|
||||
### Integration Scenarios
|
||||
- **ERP Integration**: Connect with external accounting systems
|
||||
- **Marketing Automation**: Link with email/campaign platforms
|
||||
- **Document Management**: Integrate with file storage services
|
||||
- **Payment Gateways**: Connect with online payment processors
|
||||
|
||||
This integrated CRM application provides a solid foundation for enterprise customer relationship management with full extensibility and customization capabilities.
|
||||
@ -1,48 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Test script to verify integrated CRM application module loading
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
# Add the repos directory to Python path
|
||||
sys.path.insert(0, os.path.expanduser('~/repos'))
|
||||
|
||||
def test_module_loading():
|
||||
"""Test that all modules can be imported and loaded"""
|
||||
try:
|
||||
print("Testing Integrated CRM Application Module Loading...")
|
||||
|
||||
# Test main application loader
|
||||
from integrated_crm_app.integrated_crm_app.init import load_integrated_crm_app
|
||||
print("✓ Main application loader imported successfully")
|
||||
|
||||
# Test individual module loaders
|
||||
from appbase.init import load_appbase
|
||||
from rbac.init import load_rbac
|
||||
from customer_management.init import load_customer_management
|
||||
from opportunity_management.init import load_opportunity_management
|
||||
from contract_management.init import load_contract_management
|
||||
from financial_management.init import load_financial_management
|
||||
|
||||
print("✓ All individual module loaders imported successfully")
|
||||
|
||||
# Test main loader function (this would normally be called by ahserver)
|
||||
# We won't actually call it here to avoid side effects in testing
|
||||
print("✓ Integration test completed successfully!")
|
||||
print("\nAll modules are properly structured and can be loaded.")
|
||||
print("The integrated CRM application is ready for deployment.")
|
||||
|
||||
return True
|
||||
|
||||
except ImportError as e:
|
||||
print(f"✗ Import error: {e}")
|
||||
return False
|
||||
except Exception as e:
|
||||
print(f"✗ Unexpected error: {e}")
|
||||
return False
|
||||
|
||||
if __name__ == "__main__":
|
||||
success = test_module_loading()
|
||||
sys.exit(0 if success else 1)
|
||||
116
wwwroot/base.ui
116
wwwroot/base.ui
@ -1,116 +0,0 @@
|
||||
{
|
||||
"widgettype": "VBox",
|
||||
"options": {
|
||||
"maxWidth": "1200px",
|
||||
"margin": "0 auto",
|
||||
"padding": "20px"
|
||||
},
|
||||
"subwidgets": [
|
||||
{
|
||||
"widgettype": "HBox",
|
||||
"options": {
|
||||
"alignItems": "center",
|
||||
"justifyContent": "space-between",
|
||||
"marginBottom": "20px"
|
||||
},
|
||||
"subwidgets": [
|
||||
{
|
||||
"widgettype": "Text",
|
||||
"options": {
|
||||
"text": "集成CRM管理系统",
|
||||
"fontSize": "24px",
|
||||
"fontWeight": "bold",
|
||||
"color": "#333"
|
||||
}
|
||||
},
|
||||
{
|
||||
"widgettype": "Button",
|
||||
"options": {
|
||||
"text": "用户管理",
|
||||
"onClick": "goto('rbac/users/list.ui')"
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"widgettype": "TabPanel",
|
||||
"options": {
|
||||
"tabs": [
|
||||
{
|
||||
"title": "客户管理",
|
||||
"content": {
|
||||
"widgettype": "Frame",
|
||||
"options": {
|
||||
"src": "customer_management/customers/list.ui"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "商机管理",
|
||||
"content": {
|
||||
"widgettype": "Frame",
|
||||
"options": {
|
||||
"src": "opportunity_management/opportunities/list.ui"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "合同管理",
|
||||
"content": {
|
||||
"widgettype": "Frame",
|
||||
"options": {
|
||||
"src": "contract_management/contract/list.ui"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "财务管理",
|
||||
"content": {
|
||||
"widgettype": "Frame",
|
||||
"options": {
|
||||
"src": "financial_management/receivables/list.ui"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "系统管理",
|
||||
"content": {
|
||||
"widgettype": "TabPanel",
|
||||
"options": {
|
||||
"tabs": [
|
||||
{
|
||||
"title": "用户管理",
|
||||
"content": {
|
||||
"widgettype": "Frame",
|
||||
"options": {
|
||||
"src": "rbac/users/list.ui"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "角色权限",
|
||||
"content": {
|
||||
"widgettype": "Frame",
|
||||
"options": {
|
||||
"src": "rbac/role/list.ui"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"title": "编码管理",
|
||||
"content": {
|
||||
"widgettype": "Frame",
|
||||
"options": {
|
||||
"src": "appbase/appcodes/list.ui"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
# Login script that integrates with RBAC module
|
||||
from rbac.check_perm import checkUserPassword
|
||||
from appPublic.app import get_current_app
|
||||
|
||||
async def login_user(username, password):
|
||||
"""Handle user login using RBAC authentication"""
|
||||
try:
|
||||
# Use RBAC's password checking function
|
||||
user = await checkUserPassword(username, password)
|
||||
if user:
|
||||
# Set session user
|
||||
app = get_current_app()
|
||||
app.set_session_user(user)
|
||||
return {"success": True, "redirect": "base.ui"}
|
||||
else:
|
||||
return {"success": False, "message": "用户名或密码错误"}
|
||||
except Exception as e:
|
||||
return {"success": False, "message": f"登录失败: {str(e)}"}
|
||||
@ -1,43 +0,0 @@
|
||||
{
|
||||
"widgettype": "VBox",
|
||||
"options": {
|
||||
"maxWidth": "400px",
|
||||
"margin": "100px auto",
|
||||
"padding": "30px",
|
||||
"border": "1px solid #ddd",
|
||||
"borderRadius": "8px",
|
||||
"backgroundColor": "#fff"
|
||||
},
|
||||
"subwidgets": [
|
||||
{
|
||||
"widgettype": "Text",
|
||||
"options": {
|
||||
"text": "集成CRM管理系统",
|
||||
"fontSize": "24px",
|
||||
"fontWeight": "bold",
|
||||
"textAlign": "center",
|
||||
"marginBottom": "30px"
|
||||
}
|
||||
},
|
||||
{
|
||||
"widgettype": "Form",
|
||||
"options": {
|
||||
"fields": [
|
||||
{
|
||||
"name": "username",
|
||||
"label": "用户名",
|
||||
"type": "text",
|
||||
"required": true
|
||||
},
|
||||
{
|
||||
"name": "password",
|
||||
"label": "密码",
|
||||
"type": "password",
|
||||
"required": true
|
||||
}
|
||||
],
|
||||
"onSubmit": "login_user"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
/d/hermesai/repos/integrated_crm_app/wwwroot/base.ui
|
||||
@ -1 +0,0 @@
|
||||
/d/hermesai/repos/integrated_crm_app/wwwroot/login.dspy
|
||||
@ -1 +0,0 @@
|
||||
/d/hermesai/repos/integrated_crm_app/wwwroot/login.ui
|
||||
@ -1 +0,0 @@
|
||||
/d/hermesai/repos/appbase/wwwroot
|
||||
@ -1 +0,0 @@
|
||||
/d/hermesai/repos/contract_management/wwwroot
|
||||
@ -1 +0,0 @@
|
||||
/d/hermesai/repos/customer_management/wwwroot
|
||||
@ -1 +0,0 @@
|
||||
/d/hermesai/repos/financial_management/wwwroot
|
||||
@ -1 +0,0 @@
|
||||
/d/hermesai/repos/opportunity_management/wwwroot
|
||||
@ -1 +0,0 @@
|
||||
/d/hermesai/repos/rbac/wwwroot
|
||||
Loading…
x
Reference in New Issue
Block a user