v1.0.20: 需求迭代(0808文档) - 文件管理迁入竞品资料+企业筛选弹窗(多条件且/或)+搜索框内嵌字段+渠道计划费用字段/状态行内编辑
This commit is contained in:
+59
-8
@@ -58,7 +58,6 @@ $(function () {
|
||||
' <span style="font-size:12px;color:#8a94a6;">根据历史数据有计划地拓展高效渠道</span>' +
|
||||
' </div>' +
|
||||
' <div class="toolbar">' +
|
||||
' <input type="text" data-filter="keyword" placeholder="来源详情/行业/备注关键词">' +
|
||||
' <select data-filter="channel_type"><option value="">全部渠道类别</option></select>' +
|
||||
' <select data-filter="status"><option value="">全部状态</option>' +
|
||||
' <option value="待启动">待启动</option><option value="已执行">已执行</option><option value="错过">错过</option></select>' +
|
||||
@@ -68,7 +67,7 @@ $(function () {
|
||||
' <button class="btn btn-success" id="btn-plan-add">+ 新增计划</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><th>创建时间</th><th>操作</th></tr></thead>' +
|
||||
' <thead><tr><th>ID</th><th>渠道类别</th><th>来源详情</th><th>所属行业</th><th>时间窗口</th><th>剩余天数</th><th>备注说明</th><th>状态反馈</th><th>费用(元)</th><th>创建时间</th></tr></thead>' +
|
||||
' <tbody id="plan-tbody"></tbody>' +
|
||||
' </table></div>' +
|
||||
' <div class="pagination" id="plan-pagination"></div>' +
|
||||
@@ -168,8 +167,7 @@ $(function () {
|
||||
var html = '';
|
||||
(r.details || []).forEach(function (item) {
|
||||
var src = item.source || '';
|
||||
var short = src.length > 8 ? src.substring(0, 8) + '…' : src;
|
||||
html += '<tr><td title="' + escHtml(src) + '">' + escHtml(short) + '</td><td>' + (item.count !== undefined ? item.count : item.cnt) + '</td></tr>';
|
||||
html += '<tr><td class="src-cell" title="' + escHtml(src) + '">' + escHtml(src) + '</td><td>' + (item.count !== undefined ? item.count : item.cnt) + '</td></tr>';
|
||||
});
|
||||
if (!(r.details || []).length) {
|
||||
html = '<tr><td colspan="2" style="color:#b6bfcc;text-align:center;padding:16px;">暂无明细</td></tr>';
|
||||
@@ -217,6 +215,12 @@ $(function () {
|
||||
var win = r.start_date && r.end_date
|
||||
? fmtWin(r.start_date) + ' 至 ' + fmtWin(r.end_date)
|
||||
: (r.start_date || r.end_date || '-');
|
||||
var statusSel = '<select class="plan-status" data-id="' + r.id + '" style="height:28px;padding:0 6px;font-size:12px;border:1px solid #d9dee8;border-radius:4px;">' +
|
||||
'<option value="待启动"' + (r.status === '待启动' ? ' selected' : '') + '>待启动</option>' +
|
||||
'<option value="已执行"' + (r.status === '已执行' ? ' selected' : '') + '>已执行</option>' +
|
||||
'<option value="错过"' + (r.status === '错过' ? ' selected' : '') + '>错过</option></select>';
|
||||
var costInput = '<input type="text" class="plan-cost" data-id="' + r.id + '" value="' + escHtml(r.cost !== null && r.cost !== undefined ? r.cost : '') + '" placeholder="0.00"' +
|
||||
(r.status === '已执行' ? '' : ' disabled style="background:#f2f4f8;color:#8a94a6;"') + ' style="width:90px;height:28px;padding:0 6px;font-size:12px;border:1px solid #d9dee8;border-radius:4px;text-align:right;">';
|
||||
html += '<tr>' +
|
||||
'<td>' + r.id + '</td>' +
|
||||
'<td>' + escHtml(r.channel_type) + '</td>' +
|
||||
@@ -225,19 +229,55 @@ $(function () {
|
||||
'<td>' + escHtml(win) + '</td>' +
|
||||
'<td>' + (r.remaining_days > 0 ? '<span class="tag' + (r.remaining_days <= 7 ? ' tag-red' : '') + '">' + r.remaining_days + ' 天</span>' : '<span class="tag tag-gray">已到期</span>') + '</td>' +
|
||||
'<td title="' + escHtml(r.remark || '') + '">' + escHtml((r.remark || '-').substring(0, 20)) + '</td>' +
|
||||
'<td>' + statusTag(r.status) + '</td>' +
|
||||
'<td>' + fmtDate(r.created_at) + '</td>' +
|
||||
'<td class="ops"><a onclick="editPlan(' + r.id + ')">编辑</a>' +
|
||||
'<a class="danger" onclick="delPlan(' + r.id + ')">删除</a></td></tr>';
|
||||
'<td>' + statusSel + '</td>' +
|
||||
'<td>' + costInput + '</td>' +
|
||||
'<td>' + fmtDate(r.created_at) + '</td></tr>';
|
||||
});
|
||||
if (!rows.length) {
|
||||
html = '<tr><td colspan="10" class="empty-tip" style="padding:40px 0;">暂无渠道新增计划</td></tr>';
|
||||
}
|
||||
$('#plan-tbody').html(html);
|
||||
bindPlanInlineEdit();
|
||||
renderPagination($('#plan-pagination'), data, loadPlans);
|
||||
});
|
||||
}
|
||||
|
||||
/** 行内实时编辑:状态下拉随时改;费用(元)仅在「已执行」时激活可输入 */
|
||||
function bindPlanInlineEdit() {
|
||||
$('.plan-status').off('change.plan').on('change.plan', function () {
|
||||
var id = $(this).data('id');
|
||||
var status = $(this).val();
|
||||
var $row = $(this).closest('tr');
|
||||
var $cost = $row.find('.plan-cost');
|
||||
if (status === '已执行') {
|
||||
$cost.prop('disabled', false).css({ background: '#fff', color: '#1e2a3a' });
|
||||
} else {
|
||||
$cost.prop('disabled', true).css({ background: '#f2f4f8', color: '#8a94a6' });
|
||||
}
|
||||
httpPost('channel/plan_save.php', { id: id, status: status }).then(function () {
|
||||
Dialog.toast('状态已更新为「' + status + '」');
|
||||
}).catch(function () {
|
||||
loadPlans(currentPage);
|
||||
});
|
||||
});
|
||||
$('.plan-cost').off('change.plan').on('change.plan', function () {
|
||||
var id = $(this).data('id');
|
||||
var val = $.trim($(this).val());
|
||||
if (val === '') return;
|
||||
if (isNaN(parseFloat(val))) {
|
||||
Dialog.error('费用(元)请输入数字');
|
||||
return;
|
||||
}
|
||||
var cost = Math.round(parseFloat(val) * 100) / 100;
|
||||
$(this).val(cost);
|
||||
httpPost('channel/plan_save.php', { id: id, cost: cost }).then(function () {
|
||||
Dialog.toast('费用已更新:¥' + cost.toFixed(2));
|
||||
}).catch(function () {
|
||||
loadPlans(currentPage);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/** 时间窗口显示格式:2025-4-1 */
|
||||
function fmtWin(d) {
|
||||
if (!d) return '';
|
||||
@@ -295,6 +335,8 @@ $(function () {
|
||||
' <option value="待启动"' + (!r.status || r.status === '待启动' ? ' selected' : '') + '>待启动</option>' +
|
||||
' <option value="已执行"' + (r.status === '已执行' ? ' selected' : '') + '>已执行</option>' +
|
||||
' <option value="错过"' + (r.status === '错过' ? ' selected' : '') + '>错过</option></select></div>' +
|
||||
' <div class="form-item"><label>费用(元)</label><input type="text" name="cost" value="' + escHtml(r.cost !== null && r.cost !== undefined ? r.cost : '') + '" placeholder="仅已执行时可填写"' +
|
||||
(r.status === '已执行' ? '' : ' disabled style="background:#f2f4f8;color:#8a94a6;"') + '></div>' +
|
||||
' <div class="form-item"><label>开始日期</label><input type="date" name="start_date" value="' + escHtml(r.start_date || '') + '"></div>' +
|
||||
' <div class="form-item"><label>结束日期</label><input type="date" name="end_date" value="' + escHtml(r.end_date || '') + '"></div>' +
|
||||
' <div class="form-item full"><label>备注说明</label><input type="text" name="remark" value="' + escHtml(r.remark || '') + '"></div>' +
|
||||
@@ -312,6 +354,15 @@ $(function () {
|
||||
|
||||
$('#plan-form-cancel').on('click', function () { Dialog.close(idx); });
|
||||
|
||||
// 状态反馈 → 费用(元) 联动:仅「已执行」可填写
|
||||
$('#plan-form select[name="status"]').on('change', function () {
|
||||
var enabled = $(this).val() === '已执行';
|
||||
var $cost = $('#plan-form input[name="cost"]');
|
||||
$cost.prop('disabled', !enabled);
|
||||
$cost.css({ background: enabled ? '#fff' : '#f2f4f8', color: enabled ? '#1e2a3a' : '#8a94a6' });
|
||||
if (!enabled) $cost.val('');
|
||||
});
|
||||
|
||||
$('#plan-form').on('submit', function (e) {
|
||||
e.preventDefault();
|
||||
var data = {};
|
||||
|
||||
Reference in New Issue
Block a user