63 lines
2.1 KiB
JavaScript
63 lines
2.1 KiB
JavaScript
const PlansPage = {
|
|
async render() {
|
|
return '<div class="loading"><i class="fas fa-spinner"></i><p>加载中...</p></div>';
|
|
},
|
|
|
|
async mount() {
|
|
const container = document.getElementById('page-content');
|
|
document.getElementById('page-title').textContent = '计划管理';
|
|
document.getElementById('page-actions').innerHTML = '';
|
|
|
|
try {
|
|
const plans = await API.get('/plans');
|
|
this.renderList(container, plans);
|
|
} catch (err) {
|
|
container.innerHTML = `<div class="alert alert-danger">加载失败: ${err.message}</div>`;
|
|
}
|
|
},
|
|
|
|
renderList(container, plans) {
|
|
container.innerHTML = `
|
|
${plans.length === 0 ? `
|
|
<div class="empty-state">
|
|
<i class="fas fa-clipboard-list"></i>
|
|
<p>暂无计划</p>
|
|
</div>
|
|
` : `
|
|
<div class="card">
|
|
<div class="table-container">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>#</th>
|
|
<th>计划标题</th>
|
|
<th>关联投诉</th>
|
|
<th>状态</th>
|
|
<th>规划者</th>
|
|
<th>创建时间</th>
|
|
<th>操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
${plans.map(p => `
|
|
<tr>
|
|
<td>${p.id}</td>
|
|
<td><strong>${Utils.escapeHtml(p.title)}</strong></td>
|
|
<td><a href="#" onclick="App.navigate('complaint',${p.complaint_id});return false" style="color:var(--primary)">#${p.complaint_id} ${Utils.escapeHtml(p.complaint_title)}</a></td>
|
|
<td>${Utils.statusBadge(p.status)}</td>
|
|
<td>${p.planner_name || '-'}</td>
|
|
<td class="date">${Utils.formatDate(p.created_at)}</td>
|
|
<td>
|
|
<button class="btn btn-sm btn-outline" onclick="App.navigate('complaint',${p.complaint_id})"><i class="fas fa-eye"></i></button>
|
|
</td>
|
|
</tr>
|
|
`).join('')}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
`}
|
|
`;
|
|
}
|
|
};
|