File size: 8,874 Bytes
2255bc0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
e64f1fb
 
 
 
 
2255bc0
 
 
 
e64f1fb
2255bc0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
// PyQuantFlow - Main JavaScript

document.addEventListener('DOMContentLoaded', function() {
    // Initialize Feather Icons
    if (typeof feather !== 'undefined') {
        feather.replace();
    }

    // Sample data for tracker table
    const trackerData = [
        { id: 1, name: "SDK核心架构设计", status: "已完成", owner: "张明", deadline: "2024-01-15", progress: 100 },
        { id: 2, name: "量化算法集成", status: "进行中", owner: "李华", deadline: "2024-02-28", progress: 75 },
        { id: 3, name: "多平台兼容测试", status: "进行中", owner: "王伟", deadline: "2024-03-15", progress: 60 },
        { id: 4, name: "用户界面开发", status: "待开始", owner: "刘芳", deadline: "2024-04-10", progress: 0 },
        { id: 5, name: "性能优化测试", status: "进行中", owner: "陈强", deadline: "2024-03-01", progress: 40 },
        { id: 6, name: "文档编写", status: "已完成", owner: "赵敏", deadline: "2024-01-31", progress: 100 },
        { id: 7, name: "安全审计", status: "待开始", owner: "孙浩", deadline: "2024-04-20", progress: 0 },
        { id: 8, name: "发布准备", status: "待开始", owner: "周婷", deadline: "2024-05-01", progress: 0 }
    ];

    // Populate tracker table
    const trackerTable = document.getElementById('trackerTable');
    if (trackerTable) {
        trackerData.forEach(item => {
            const row = document.createElement('tr');
            row.className = 'table-row-hover hover:bg-red-50/30';
            row.innerHTML = `
                <td class="px-4 py-3 whitespace-nowrap text-sm font-medium text-gray-900">${item.id}</td>
                <td class="px-4 py-3 whitespace-nowrap text-sm text-gray-700">${item.name}</td>
                <td class="px-4 py-3 whitespace-nowrap">
                    <span class="status-badge status-${item.status === '已完成' ? 'complete' : item.status === '进行中' ? 'in-progress' : 'pending'}">${item.status}</span>
                </td>
                <td class="px-4 py-3 whitespace-nowrap text-sm text-gray-700">${item.owner}</td>
                <td class="px-4 py-3 whitespace-nowrap text-sm text-gray-700">${item.deadline}</td>
                <td class="px-4 py-3 whitespace-nowrap">
                    <div class="flex items-center">
                        <div class="w-full bg-gray-200 rounded-full h-2.5 mr-2">
                            <div class="progress-fill h-2.5 rounded-full" style="width: ${item.progress}%"></div>
                        </div>
                        <span class="text-sm text-gray-700">${item.progress}%</span>
                    </div>
                </td>
            `;
            trackerTable.appendChild(row);
        });
    }
    // Add new row functionality
    const addRowBtn = document.getElementById('addRowBtn');
    if (addRowBtn && trackerTable) {
        addRowBtn.addEventListener('click', function() {
            const newId = trackerData.length + 1;
            const newRow = document.createElement('tr');
            newRow.className = 'table-row-hover hover:bg-red-50/30 fade-in';
            newRow.innerHTML = `
                <td class="px-4 py-3 whitespace-nowrap text-sm font-medium text-gray-900">${newId}</td>
                <td class="px-4 py-3 whitespace-nowrap">
                    <input type="text" class="w-full px-2 py-1 border rounded focus:outline-none focus:ring-2 focus:ring-primary" placeholder="输入任务名称">
                </td>
                <td class="px-4 py-3 whitespace-nowrap">
                    <select class="w-full px-2 py-1 border rounded focus:outline-none focus:ring-2 focus:ring-primary">
                        <option value="待开始">待开始</option>
                        <option value="进行中">进行中</option>
                        <option value="已完成">已完成</option>
                    </select>
                </td>
                <td class="px-4 py-3 whitespace-nowrap">
                    <input type="text" class="w-full px-2 py-1 border rounded focus:outline-none focus:ring-2 focus:ring-primary" placeholder="负责人">
                </td>
                <td class="px-4 py-3 whitespace-nowrap">
                    <input type="date" class="w-full px-2 py-1 border rounded focus:outline-none focus:ring-2 focus:ring-primary">
                </td>
                <td class="px-4 py-3 whitespace-nowrap">
                    <div class="flex items-center">
                        <div class="w-full bg-gray-200 rounded-full h-2.5 mr-2">
                            <div class="progress-fill h-2.5 rounded-full" style="width: 0%"></div>
                        </div>
                        <span class="text-sm text-gray-700">0%</span>
                    </div>
                </td>
            `;
            trackerTable.appendChild(newRow);
            
            // Re-initialize icons in the new row
            if (typeof feather !== 'undefined') {
                feather.replace();
            }
            
            // Show success message
            showNotification('成功添加新记录行!', 'success');
        });
    }
// Notification System
    function showNotification(message, type = 'info') {
        const notification = document.createElement('div');
        notification.className = `fixed top-4 right-4 z-50 p-4 rounded-lg shadow-hard transform transition-transform duration-300 translate-x-0 ${
                type === 'success' ? 'bg-green-500 text-white' : 
                type === 'error' ? 'bg-red-500 text-white' :
                'bg-blue-500 text-white'
            }`;
        notification.innerHTML = `
            <div class="flex items-center">
                <i data-feather="${type === 'success' ? 'check-circle' : type === 'error' ? 'alert-circle' : 'info'}" class="mr-2"></i>
                <span>${message}</span>
            </div>
        `;
        
        document.body.appendChild(notification);
        
        // Update icons
        if (typeof feather !== 'undefined') {
            feather.replace({ selector: 'i' });
        }
        
        // Auto remove after 3 seconds
        setTimeout(() => {
            notification.style.transform = 'translateX(100%)';
            setTimeout(() => {
                if (notification.parentNode) {
                    notification.parentNode.removeChild(notification);
                }
            }, 300);
        }, 3000);
    }

    // Update progress bars on page load
    function initializeProgressBars() {
        document.querySelectorAll('.progress-fill').forEach(bar => {
            const currentWidth = bar.style.width;
            bar.style.width = '0%';
            setTimeout(() => {
                bar.style.width = currentWidth;
            }, 100);
        });
    }

    // Initialize everything
    initializeProgressBars();

    // Add keyboard shortcuts
    document.addEventListener('keydown', function(e) {
        // Ctrl/Cmd + N to add new row
        if ((e.ctrlKey || e.metaKey) && e.key === 'n') {
            e.preventDefault();
            if (addRowBtn) addRowBtn.click();
        }
        
        // Escape to clear notifications
        if (e.key === 'Escape') {
            document.querySelectorAll('.fixed.top-4.right-4').forEach(notification => {
                notification.remove();
            });
        }
    });

    // Make table rows clickable for details
    if (trackerTable) {
        trackerTable.addEventListener('click', function(e) {
            const row = e.target.closest('tr');
            if (row && !e.target.closest('input') && !e.target.closest('select')) {
                const taskId = row.cells[0].textContent;
                const taskName = row.cells[1].textContent;
                showNotification(`查看任务详情: ${taskName} (ID: ${taskId})`, 'info');
            }
        });
    }

    // Simulate real-time updates
    setInterval(() => {
        const stats = document.querySelectorAll('.text-3xl.font-bold');
        if (stats.length > 0) {
            const randomIncrement = Math.floor(Math.random() * 3);
            const currentValue = parseInt(stats[1].textContent);
            stats[1].textContent = currentValue + randomIncrement;
            
            // Update random progress
            const randomRow = Math.floor(Math.random() * trackerData.length);
            const progressBars = document.querySelectorAll('.progress-fill');
            if (progressBars.length > randomRow) {
                const newProgress = Math.min(progressBars[randomRow].style.width ? parseInt(progressBars[randomRow].style.width) + 5 : 5;
            progressBars[randomRow].style.width = `${newProgress}%`;
            progressBars[randomRow].nextElementSibling.textContent = `${newProgress}%`;
            }
        }
    }, 10000);
});