82 lines
3.6 KiB
JavaScript
82 lines
3.6 KiB
JavaScript
/**
|
|
* preliminary.js - 碎片处理逻辑(待定逻辑,暂做基础列表 + 状态统计)
|
|
*/
|
|
$(function () {
|
|
renderShell('碎片处理', '数据管理 / 碎片处理(占位)');
|
|
renderPage();
|
|
initPage('preliminary', function (user) {
|
|
if (!checkPagePermission('preliminary')) return;
|
|
loadStats();
|
|
loadList(1);
|
|
});
|
|
|
|
var currentPage = 1;
|
|
|
|
/** 渲染页面内容(统计卡+工具栏+表格+分页) */
|
|
function renderPage() {
|
|
$('#page-content').html(
|
|
'<div class="stat-cards" id="stat-cards"></div>' +
|
|
'<div class="card">' +
|
|
' <div class="toolbar">' +
|
|
' <input type="text" data-filter="keyword" placeholder="公司/姓名/电话/邮箱关键词">' +
|
|
' <select data-filter="source_type"><option value="">全部类型</option>' +
|
|
' <option value="company">公司</option><option value="person">人员</option>' +
|
|
' <option value="product">产品</option><option value="need">需求</option><option value="mixed">混合</option></select>' +
|
|
' <input type="date" data-filter="start_date" title="开始日期">' +
|
|
' <input type="date" data-filter="end_date" title="结束日期">' +
|
|
' <button class="btn btn-primary" id="btn-search">搜索</button>' +
|
|
' <button class="btn" id="btn-reset">重置</button>' +
|
|
' </div>' +
|
|
' <div class="table-wrap"><table class="grid">' +
|
|
' <thead><tr><th>ID</th><th>类型</th><th>公司</th><th>姓名</th><th>电话</th><th>邮箱</th><th>跟进人</th><th>录入时间</th></tr></thead>' +
|
|
' <tbody id="pre-tbody"></tbody>' +
|
|
' </table></div>' +
|
|
' <div class="pagination" id="pagination"></div>' +
|
|
'</div>'
|
|
);
|
|
}
|
|
|
|
function loadStats() {
|
|
httpGet('preliminary/stats.php').then(function (d) {
|
|
$('#stat-cards').html(
|
|
'<div class="stat-card c-blue"><div class="num">' + d.total + '</div><div class="label">碎片总数</div></div>' +
|
|
'<div class="stat-card c-green"><div class="num">' + d.today + '</div><div class="label">今日新增</div></div>'
|
|
);
|
|
});
|
|
}
|
|
|
|
function loadList(page) {
|
|
currentPage = page;
|
|
var params = buildFilterParam();
|
|
params.page = page;
|
|
params.limit = PAGE_SIZE;
|
|
|
|
httpGet('preliminary/list.php', params).then(function (data) {
|
|
var rows = data.list || [];
|
|
var html = '';
|
|
rows.forEach(function (r) {
|
|
html += '<tr>' +
|
|
'<td>' + r.id + '</td>' +
|
|
'<td>' + escHtml(r.source_type || '-') + '</td>' +
|
|
'<td>' + escHtml(r.company_name || '-') + '</td>' +
|
|
'<td>' + escHtml(r.person_name || '-') + '</td>' +
|
|
'<td>' + escHtml(r.contact_phone || '-') + '</td>' +
|
|
'<td>' + escHtml(r.contact_email || '-') + '</td>' +
|
|
'<td>' + escHtml(r.follow_person || '-') + '</td>' +
|
|
'<td>' + fmtDate(r.created_at) + '</td></tr>';
|
|
});
|
|
if (!rows.length) {
|
|
html = '<tr><td colspan="8" class="empty-tip" style="padding:40px 0;">暂无数据碎片</td></tr>';
|
|
}
|
|
$('#pre-tbody').html(html);
|
|
renderPagination($('#pagination'), data, loadList);
|
|
});
|
|
}
|
|
|
|
$('#btn-search').on('click', function () { loadList(1); });
|
|
$('#btn-reset').on('click', function () {
|
|
$('.toolbar [data-filter]').val('');
|
|
loadList(1);
|
|
});
|
|
});
|