From fa8df43a5feeeddeed17fbe996dce3a8e760d86a Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 16 Apr 2026 15:07:08 +0800 Subject: [PATCH] bugfix --- README.md | 159 --------------- app/integrated_crm_app.py | 37 ++++ build.sh | 183 ++++++++++-------- conf/config.json | 33 ++++ integrated_crm_app/__init__.py | 1 - .../__pycache__/__init__.cpython-310.pyc | Bin 160 -> 0 bytes integrated_crm_app/init.py | 76 -------- integrated_crm_app_schema.sql | 71 ------- pyproject.toml | 38 ---- skill/SKILL.md | 168 ---------------- test_integration.py | 48 ----- wwwroot/base.ui | 116 ----------- wwwroot/login.dspy | 18 -- wwwroot/login.ui | 43 ---- wwwroot/main/base.ui | 1 - wwwroot/main/login.dspy | 1 - wwwroot/main/login.ui | 1 - wwwroot/modules/appbase | 1 - wwwroot/modules/contract_management | 1 - wwwroot/modules/customer_management | 1 - wwwroot/modules/financial_management | 1 - wwwroot/modules/opportunity_management | 1 - wwwroot/modules/rbac | 1 - 23 files changed, 171 insertions(+), 829 deletions(-) delete mode 100644 README.md create mode 100644 app/integrated_crm_app.py create mode 100644 conf/config.json delete mode 100644 integrated_crm_app/__init__.py delete mode 100644 integrated_crm_app/__pycache__/__init__.cpython-310.pyc delete mode 100644 integrated_crm_app/init.py delete mode 100644 integrated_crm_app_schema.sql delete mode 100644 pyproject.toml delete mode 100644 skill/SKILL.md delete mode 100644 test_integration.py delete mode 100644 wwwroot/base.ui delete mode 100644 wwwroot/login.dspy delete mode 100644 wwwroot/login.ui delete mode 120000 wwwroot/main/base.ui delete mode 120000 wwwroot/main/login.dspy delete mode 120000 wwwroot/main/login.ui delete mode 120000 wwwroot/modules/appbase delete mode 120000 wwwroot/modules/contract_management delete mode 120000 wwwroot/modules/customer_management delete mode 120000 wwwroot/modules/financial_management delete mode 120000 wwwroot/modules/opportunity_management delete mode 120000 wwwroot/modules/rbac diff --git a/README.md b/README.md deleted file mode 100644 index 26b21b5..0000000 --- a/README.md +++ /dev/null @@ -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应用程序为企业客户关系管理提供了坚实的基础,具有完全的可扩展性和定制能力。 \ No newline at end of file diff --git a/app/integrated_crm_app.py b/app/integrated_crm_app.py new file mode 100644 index 0000000..0d2c054 --- /dev/null +++ b/app/integrated_crm_app.py @@ -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) \ No newline at end of file diff --git a/build.sh b/build.sh index dc223f0..0176904 100755 --- a/build.sh +++ b/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 "" \ No newline at end of file +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" \ No newline at end of file diff --git a/conf/config.json b/conf/config.json new file mode 100644 index 0000000..234d10b --- /dev/null +++ b/conf/config.json @@ -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 + } +} \ No newline at end of file diff --git a/integrated_crm_app/__init__.py b/integrated_crm_app/__init__.py deleted file mode 100644 index 7bb0654..0000000 --- a/integrated_crm_app/__init__.py +++ /dev/null @@ -1 +0,0 @@ -# Integrated CRM Application Package \ No newline at end of file diff --git a/integrated_crm_app/__pycache__/__init__.cpython-310.pyc b/integrated_crm_app/__pycache__/__init__.cpython-310.pyc deleted file mode 100644 index f3df67243d884bce50cb969a1c060498169ee2c9..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 160 zcmd1j<>g`k0=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*"] \ No newline at end of file diff --git a/skill/SKILL.md b/skill/SKILL.md deleted file mode 100644 index 187320d..0000000 --- a/skill/SKILL.md +++ /dev/null @@ -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. \ No newline at end of file diff --git a/test_integration.py b/test_integration.py deleted file mode 100644 index 2cdade4..0000000 --- a/test_integration.py +++ /dev/null @@ -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) \ No newline at end of file diff --git a/wwwroot/base.ui b/wwwroot/base.ui deleted file mode 100644 index c711cb3..0000000 --- a/wwwroot/base.ui +++ /dev/null @@ -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" - } - } - } - ] - } - } - } - ] - } - } - ] -} \ No newline at end of file diff --git a/wwwroot/login.dspy b/wwwroot/login.dspy deleted file mode 100644 index 01f0144..0000000 --- a/wwwroot/login.dspy +++ /dev/null @@ -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)}"} \ No newline at end of file diff --git a/wwwroot/login.ui b/wwwroot/login.ui deleted file mode 100644 index b46d251..0000000 --- a/wwwroot/login.ui +++ /dev/null @@ -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" - } - } - ] -} \ No newline at end of file diff --git a/wwwroot/main/base.ui b/wwwroot/main/base.ui deleted file mode 120000 index e3034ee..0000000 --- a/wwwroot/main/base.ui +++ /dev/null @@ -1 +0,0 @@ -/d/hermesai/repos/integrated_crm_app/wwwroot/base.ui \ No newline at end of file diff --git a/wwwroot/main/login.dspy b/wwwroot/main/login.dspy deleted file mode 120000 index eb8928d..0000000 --- a/wwwroot/main/login.dspy +++ /dev/null @@ -1 +0,0 @@ -/d/hermesai/repos/integrated_crm_app/wwwroot/login.dspy \ No newline at end of file diff --git a/wwwroot/main/login.ui b/wwwroot/main/login.ui deleted file mode 120000 index 607a801..0000000 --- a/wwwroot/main/login.ui +++ /dev/null @@ -1 +0,0 @@ -/d/hermesai/repos/integrated_crm_app/wwwroot/login.ui \ No newline at end of file diff --git a/wwwroot/modules/appbase b/wwwroot/modules/appbase deleted file mode 120000 index 5a3ce13..0000000 --- a/wwwroot/modules/appbase +++ /dev/null @@ -1 +0,0 @@ -/d/hermesai/repos/appbase/wwwroot \ No newline at end of file diff --git a/wwwroot/modules/contract_management b/wwwroot/modules/contract_management deleted file mode 120000 index 0322b3f..0000000 --- a/wwwroot/modules/contract_management +++ /dev/null @@ -1 +0,0 @@ -/d/hermesai/repos/contract_management/wwwroot \ No newline at end of file diff --git a/wwwroot/modules/customer_management b/wwwroot/modules/customer_management deleted file mode 120000 index aa5483d..0000000 --- a/wwwroot/modules/customer_management +++ /dev/null @@ -1 +0,0 @@ -/d/hermesai/repos/customer_management/wwwroot \ No newline at end of file diff --git a/wwwroot/modules/financial_management b/wwwroot/modules/financial_management deleted file mode 120000 index e052d5a..0000000 --- a/wwwroot/modules/financial_management +++ /dev/null @@ -1 +0,0 @@ -/d/hermesai/repos/financial_management/wwwroot \ No newline at end of file diff --git a/wwwroot/modules/opportunity_management b/wwwroot/modules/opportunity_management deleted file mode 120000 index 6739ffe..0000000 --- a/wwwroot/modules/opportunity_management +++ /dev/null @@ -1 +0,0 @@ -/d/hermesai/repos/opportunity_management/wwwroot \ No newline at end of file diff --git a/wwwroot/modules/rbac b/wwwroot/modules/rbac deleted file mode 120000 index e95d1cd..0000000 --- a/wwwroot/modules/rbac +++ /dev/null @@ -1 +0,0 @@ -/d/hermesai/repos/rbac/wwwroot \ No newline at end of file