<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>VIP客户服务记录 - VIP客户服务机制</title>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            min-height: 100vh;
            padding: 20px;
        }

        .container {
            max-width: 1400px;
            margin: 0 auto;
        }

        .header {
            background: white;
            padding: 20px 30px;
            border-radius: 10px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
            margin-bottom: 20px;
        }

        .header-top {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 15px;
        }

        .header h1 {
            color: #333;
            font-size: 28px;
        }

        .nav-menu {
            display: flex;
            gap: 10px;
            flex-wrap: wrap;
        }

        .nav-item {
            padding: 8px 16px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            text-decoration: none;
            border-radius: 6px;
            font-size: 14px;
            transition: all 0.3s;
        }

        .nav-item:hover {
            transform: translateY(-2px);
            box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
        }

        .nav-item.active {
            background: #e74c3c;
        }

        .card {
            background: white;
            border-radius: 10px;
            padding: 25px;
            box-shadow: 0 4px 6px rgba(0,0,0,0.1);
            margin-bottom: 20px;
        }

        .card-title {
            font-size: 20px;
            font-weight: bold;
            color: #333;
            margin-bottom: 20px;
            padding-bottom: 10px;
            border-bottom: 2px solid #667eea;
        }

        .filter-bar {
            display: flex;
            gap: 15px;
            margin-bottom: 20px;
            flex-wrap: wrap;
        }

        .filter-item {
            flex: 1;
            min-width: 150px;
        }

        .filter-item label {
            display: block;
            margin-bottom: 5px;
            color: #555;
            font-size: 14px;
        }

        .filter-item select,
        .filter-item input {
            width: 100%;
            padding: 8px 12px;
            border: 2px solid #e0e0e0;
            border-radius: 6px;
            font-size: 14px;
        }

        .data-table {
            width: 100%;
            border-collapse: collapse;
            margin-top: 20px;
        }

        .data-table th,
        .data-table td {
            padding: 12px;
            text-align: left;
            border-bottom: 1px solid #e0e0e0;
        }

        .data-table th {
            background: #f8f9fa;
            font-weight: bold;
            color: #333;
        }

        .data-table tr:hover {
            background: #f8f9fa;
        }

        .badge {
            display: inline-block;
            padding: 4px 10px;
            border-radius: 4px;
            font-size: 12px;
            font-weight: bold;
        }

        .badge-success {
            background: #27ae60;
            color: white;
        }

        .badge-warning {
            background: #f39c12;
            color: white;
        }

        .badge-danger {
            background: #e74c3c;
            color: white;
        }

        .badge-vip {
            background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
            color: white;
        }

        .badge-svip {
            background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
            color: white;
        }

        .empty-state {
            text-align: center;
            padding: 60px 20px;
            color: #999;
        }

        .empty-state-icon {
            font-size: 64px;
            margin-bottom: 15px;
        }

        .stats-bar {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
            gap: 15px;
            margin-bottom: 20px;
        }

        .stat-card {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 20px;
            border-radius: 8px;
            text-align: center;
        }

        .stat-card.success {
            background: linear-gradient(135deg, #27ae60 0%, #229954 100%);
        }

        .stat-card.warning {
            background: linear-gradient(135deg, #f39c12 0%, #e67e22 100%);
        }

        .stat-value {
            font-size: 32px;
            font-weight: bold;
            margin: 10px 0;
        }

        .stat-label {
            font-size: 14px;
            opacity: 0.9;
        }
    </style>
</head>
<body>
    <div id="app">
        <div class="container">
            <div class="header">
                <div class="header-top">
                    <h1>📋 VIP客户服务记录</h1>
                    <div class="nav-menu">
                        <a href="1-VIP客户管理列表页.html" class="nav-item">VIP客户管理</a>
                        <a href="3-VIP专属负责人配置页.html" class="nav-item">负责人配置</a>
                        <a href="4-VIP服务工单列表页.html" class="nav-item">VIP工单</a>
                        <a href="5-VIP SLA规则配置页.html" class="nav-item">SLA配置</a>
                        <a href="6-VIP客户服务记录页.html" class="nav-item active">服务记录</a>
                        <a href="7-VIP客户服务看板.html" class="nav-item">服务看板</a>
                    </div>
                </div>
            </div>

            <!-- 统计卡片 -->
            <div class="stats-bar">
                <div class="stat-card">
                    <div class="stat-label">总服务次数</div>
                    <div class="stat-value">{{ stats.total }}</div>
                </div>
                <div class="stat-card success">
                    <div class="stat-label">已完成</div>
                    <div class="stat-value">{{ stats.completed }}</div>
                </div>
                <div class="stat-card warning">
                    <div class="stat-label">处理中</div>
                    <div class="stat-value">{{ stats.processing }}</div>
                </div>
                <div class="stat-card">
                    <div class="stat-label">本月服务</div>
                    <div class="stat-value">{{ stats.thisMonth }}</div>
                </div>
            </div>

            <div class="card">
                <div class="card-title">
                    VIP客户服务记录 (共 {{ filteredRecords.length }} 条)
                </div>

                <!-- 筛选栏 -->
                <div class="filter-bar">
                    <div class="filter-item">
                        <label>客户名称</label>
                        <input type="text" v-model="filters.customer" @input="applyFilters" placeholder="输入客户名称">
                    </div>
                    <div class="filter-item">
                        <label>服务类型</label>
                        <select v-model="filters.serviceType" @change="applyFilters">
                            <option value="">全部类型</option>
                            <option value="技术支持">技术支持</option>
                            <option value="故障处理">故障处理</option>
                            <option value="咨询解答">咨询解答</option>
                            <option value="维护服务">维护服务</option>
                        </select>
                    </div>
                    <div class="filter-item">
                        <label>服务状态</label>
                        <select v-model="filters.status" @change="applyFilters">
                            <option value="">全部状态</option>
                            <option value="completed">已完成</option>
                            <option value="processing">处理中</option>
                            <option value="pending">待处理</option>
                        </select>
                    </div>
                    <div class="filter-item">
                        <label>负责人</label>
                        <input type="text" v-model="filters.manager" @input="applyFilters" placeholder="输入负责人">
                    </div>
                    <div class="filter-item">
                        <label>时间范围</label>
                        <select v-model="filters.timeRange" @change="applyFilters">
                            <option value="all">全部时间</option>
                            <option value="today">今天</option>
                            <option value="week">最近7天</option>
                            <option value="month">最近30天</option>
                        </select>
                    </div>
                </div>

                <!-- 数据表格 -->
                <table class="data-table" v-if="filteredRecords.length > 0">
                    <thead>
                        <tr>
                            <th>客户名称</th>
                            <th>VIP等级</th>
                            <th>服务时间</th>
                            <th>服务类型</th>
                            <th>问题描述</th>
                            <th>处理结果</th>
                            <th>负责人</th>
                            <th>服务状态</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr v-for="record in filteredRecords" :key="record.id">
                            <td>{{ record.customerName }}</td>
                            <td>
                                <span class="badge" :class="record.vipLevel === 'vip' ? 'badge-vip' : 'badge-svip'">
                                    {{ record.vipLevel === 'vip' ? 'VIP' : 'SVIP' }}
                                </span>
                            </td>
                            <td>{{ formatTime(record.serviceTime) }}</td>
                            <td>{{ record.serviceType }}</td>
                            <td style="max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
                                {{ record.problemDescription }}
                            </td>
                            <td style="max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
                                {{ record.result || '-' }}
                            </td>
                            <td>{{ record.manager }}</td>
                            <td>
                                <span class="badge" :class="getStatusBadgeClass(record.status)">
                                    {{ getStatusText(record.status) }}
                                </span>
                            </td>
                        </tr>
                    </tbody>
                </table>

                <div class="empty-state" v-else>
                    <div class="empty-state-icon">📋</div>
                    <div>暂无服务记录</div>
                </div>
            </div>
        </div>
    </div>

    <script>
        const { createApp } = Vue;

        createApp({
            data() {
                return {
                    records: [],
                    filters: {
                        customer: '',
                        serviceType: '',
                        status: '',
                        manager: '',
                        timeRange: 'all'
                    }
                }
            },
            computed: {
                stats() {
                    const now = new Date();
                    const thisMonthStart = new Date(now.getFullYear(), now.getMonth(), 1).getTime();
                    
                    return {
                        total: this.records.length,
                        completed: this.records.filter(r => r.status === 'completed').length,
                        processing: this.records.filter(r => r.status === 'processing').length,
                        thisMonth: this.records.filter(r => r.serviceTime >= thisMonthStart).length
                    };
                },
                filteredRecords() {
                    let result = [...this.records];
                    
                    if (this.filters.customer) {
                        result = result.filter(r => 
                            r.customerName.toLowerCase().includes(this.filters.customer.toLowerCase())
                        );
                    }
                    
                    if (this.filters.serviceType) {
                        result = result.filter(r => r.serviceType === this.filters.serviceType);
                    }
                    
                    if (this.filters.status) {
                        result = result.filter(r => r.status === this.filters.status);
                    }
                    
                    if (this.filters.manager) {
                        result = result.filter(r => 
                            r.manager.toLowerCase().includes(this.filters.manager.toLowerCase())
                        );
                    }
                    
                    // 时间范围筛选
                    if (this.filters.timeRange === 'today') {
                        const today = new Date();
                        today.setHours(0, 0, 0, 0);
                        result = result.filter(r => r.serviceTime >= today.getTime());
                    } else if (this.filters.timeRange === 'week') {
                        const weekAgo = Date.now() - 7 * 24 * 60 * 60 * 1000;
                        result = result.filter(r => r.serviceTime >= weekAgo);
                    } else if (this.filters.timeRange === 'month') {
                        const monthAgo = Date.now() - 30 * 24 * 60 * 60 * 1000;
                        result = result.filter(r => r.serviceTime >= monthAgo);
                    }
                    
                    return result.sort((a, b) => b.serviceTime - a.serviceTime);
                }
            },
            mounted() {
                this.loadRecords();
            },
            methods: {
                loadRecords() {
                    const saved = localStorage.getItem('vipServiceRecords');
                    if (saved) {
                        this.records = JSON.parse(saved);
                    } else {
                        // 初始化示例数据
                        this.records = [
                            {
                                id: 1,
                                customerName: '客户A',
                                vipLevel: 'vip',
                                serviceTime: Date.now() - 2 * 24 * 60 * 60 * 1000,
                                serviceType: '技术支持',
                                problemDescription: '系统运行缓慢，需要优化',
                                result: '已优化系统配置，性能提升30%',
                                manager: '张三',
                                status: 'completed'
                            },
                            {
                                id: 2,
                                customerName: '客户B',
                                vipLevel: 'svip',
                                serviceTime: Date.now() - 1 * 24 * 60 * 60 * 1000,
                                serviceType: '故障处理',
                                problemDescription: '服务器宕机，紧急处理',
                                result: '已恢复服务，问题已解决',
                                manager: '李四',
                                status: 'completed'
                            },
                            {
                                id: 3,
                                customerName: '客户A',
                                vipLevel: 'vip',
                                serviceTime: Date.now() - 5 * 60 * 60 * 1000,
                                serviceType: '咨询解答',
                                problemDescription: '关于新功能的使用咨询',
                                result: '',
                                manager: '王五',
                                status: 'processing'
                            }
                        ];
                        this.saveRecords();
                    }
                },
                saveRecords() {
                    localStorage.setItem('vipServiceRecords', JSON.stringify(this.records));
                },
                applyFilters() {
                    // 筛选逻辑在computed中处理
                },
                getStatusText(status) {
                    const statusMap = {
                        'completed': '已完成',
                        'processing': '处理中',
                        'pending': '待处理'
                    };
                    return statusMap[status] || status;
                },
                getStatusBadgeClass(status) {
                    const classMap = {
                        'completed': 'badge-success',
                        'processing': 'badge-warning',
                        'pending': 'badge-danger'
                    };
                    return classMap[status] || '';
                },
                formatTime(timestamp) {
                    if (!timestamp) return '-';
                    const date = new Date(timestamp);
                    return date.toLocaleString('zh-CN');
                }
            }
        }).mount('#app');
    </script>
</body>
</html>

