添加引导词和投递模板
This commit is contained in:
@@ -198,6 +198,17 @@
|
||||
</div>
|
||||
<div class="bl-tip" id="rsDetail">进度:- | 更新:-</div>
|
||||
|
||||
<div class="bl-add" style="flex-wrap:wrap;align-items:flex-end;">
|
||||
<div style="flex:2;min-width:220px;"><label style="font-size:12px;color:#666;">选择模板</label>
|
||||
<select id="rTemplate" style="width:100%;padding:9px 10px;border:1px solid #d9d9d9;border-radius:6px;">
|
||||
<option value="">-- 不使用模板 --</option>
|
||||
</select></div>
|
||||
<div style="display:flex;align-items:flex-end;gap:8px;padding-bottom:10px;">
|
||||
<button id="btnRefreshTemplates" type="button">刷新模板</button>
|
||||
<button id="btnSaveTemplateRemote" type="button">保存为模板</button>
|
||||
<button id="btnManageTemplatesRemote" type="button">管理模板</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="bl-add" style="flex-wrap:wrap;align-items:flex-end;">
|
||||
<div style="flex:2;min-width:220px;"><label style="font-size:12px;color:#666;">搜索关键词(多个用逗号分隔)</label>
|
||||
<input type="text" id="rKeywords" placeholder="如:Python开发,后端工程师" value="Python开发"></div>
|
||||
@@ -221,6 +232,10 @@
|
||||
<button id="btnStartRemote" style="background:#1890ff;">开始投递</button>
|
||||
<button id="btnStopRemote">结束投递</button>
|
||||
</div>
|
||||
<div class="bl-add" style="flex-wrap:wrap;align-items:flex-end;">
|
||||
<div style="flex:1;min-width:300px;"><label style="font-size:12px;color:#666;">AI 引导词(可选)</label>
|
||||
<textarea id="rPrompt" rows="3" style="width:100%;padding:9px 10px;border:1px solid #d9d9d9;border-radius:6px;resize:vertical;" placeholder="例如:优先投递 Java 后端岗位,接受 10-15K,有 AI 项目经验优先"></textarea></div>
|
||||
</div>
|
||||
<div class="bl-tip">任务下发后客户端 5 秒内认领执行;同类型任务未结束前不能重复下发。</div>
|
||||
|
||||
<table>
|
||||
@@ -503,6 +518,7 @@ document.getElementById('btnStartRemote').onclick = () => {
|
||||
daily_limit: parseInt(document.getElementById('rLimit').value, 10) || 0,
|
||||
boss_online_only: document.getElementById('rOnlineOnly').checked,
|
||||
allow_headhunter: document.getElementById('rHunter').checked,
|
||||
prompt: document.getElementById('rPrompt').value.trim() || null,
|
||||
});
|
||||
};
|
||||
document.getElementById('btnStopRemote').onclick = () => {
|
||||
@@ -520,6 +536,99 @@ document.getElementById('tbody').addEventListener('click', e => {
|
||||
}
|
||||
});
|
||||
|
||||
// 远程模板管理
|
||||
let remoteTemplates = [];
|
||||
|
||||
async function loadRemoteTemplates() {
|
||||
try {
|
||||
remoteTemplates = await api('/api/templates') || [];
|
||||
const select = document.getElementById('rTemplate');
|
||||
select.innerHTML = '<option value="">-- 不使用模板 --</option>';
|
||||
remoteTemplates.forEach(t => {
|
||||
const opt = document.createElement('option');
|
||||
opt.value = t.id;
|
||||
opt.textContent = t.name;
|
||||
select.appendChild(opt);
|
||||
});
|
||||
} catch (e) { console.error('加载模板失败', e); }
|
||||
}
|
||||
|
||||
function fillRemoteForm(t) {
|
||||
document.getElementById('rKeywords').value = (t.keywords || '').replace(/,/g, ', ');
|
||||
document.getElementById('rCity').value = t.city || '北京';
|
||||
document.getElementById('rScore').value = t.min_score || 65;
|
||||
document.getElementById('rSalaryMin').value = t.salary_min || 0;
|
||||
document.getElementById('rSalaryMax').value = t.salary_max || 0;
|
||||
document.getElementById('rLimit').value = t.daily_limit || 0;
|
||||
document.getElementById('rOnlineOnly').checked = !!t.boss_online_only;
|
||||
document.getElementById('rHunter').checked = !!t.allow_headhunter;
|
||||
document.getElementById('rPrompt').value = t.prompt || '';
|
||||
}
|
||||
|
||||
function collectRemoteTemplate() {
|
||||
return {
|
||||
keywords: document.getElementById('rKeywords').value.split(/[,,\s]+/).filter(Boolean).join(','),
|
||||
city: document.getElementById('rCity').value,
|
||||
salary_min: parseInt(document.getElementById('rSalaryMin').value, 10) || null,
|
||||
salary_max: parseInt(document.getElementById('rSalaryMax').value, 10) || null,
|
||||
min_score: parseInt(document.getElementById('rScore').value, 10) || 65,
|
||||
daily_limit: parseInt(document.getElementById('rLimit').value, 10) || 0,
|
||||
boss_online_only: document.getElementById('rOnlineOnly').checked,
|
||||
allow_headhunter: document.getElementById('rHunter').checked,
|
||||
prompt: document.getElementById('rPrompt').value.trim() || null,
|
||||
};
|
||||
}
|
||||
|
||||
document.getElementById('rTemplate').addEventListener('change', () => {
|
||||
const id = document.getElementById('rTemplate').value;
|
||||
if (!id) return;
|
||||
const t = remoteTemplates.find(x => String(x.id) === id);
|
||||
if (t) fillRemoteForm(t);
|
||||
});
|
||||
|
||||
document.getElementById('btnRefreshTemplates').onclick = loadRemoteTemplates;
|
||||
|
||||
document.getElementById('btnSaveTemplateRemote').onclick = async () => {
|
||||
const name = prompt('请输入模板名称:');
|
||||
if (!name || !name.trim()) return;
|
||||
try {
|
||||
await api('/api/templates', { method: 'POST', body: JSON.stringify({ name: name.trim(), ...collectRemoteTemplate() }) });
|
||||
alert('模板已保存');
|
||||
await loadRemoteTemplates();
|
||||
} catch (e) { alert('保存失败:' + (e.message || '')); }
|
||||
};
|
||||
|
||||
async function renderRemoteTemplates() {
|
||||
await loadRemoteTemplates();
|
||||
const tbody = document.getElementById('tmplTbody');
|
||||
if (!remoteTemplates.length) {
|
||||
tbody.innerHTML = '<tr><td colspan="4" style="text-align:center;color:#999;padding:12px;">暂无模板</td></tr>';
|
||||
return;
|
||||
}
|
||||
tbody.innerHTML = remoteTemplates.map(t => '<tr><td style="padding:8px;border-bottom:1px solid #f0f0f0;">' + esc(t.name) + '</td><td style="padding:8px;border-bottom:1px solid #f0f0f0;">' + esc(t.keywords || '-') + '</td><td style="padding:8px;border-bottom:1px solid #f0f0f0;">' + esc(t.city || '-') + '</td><td style="padding:8px;border-bottom:1px solid #f0f0f0;"><button data-tid="' + t.id + '" class="tmpl-apply" style="margin-right:6px;">套用</button><button data-tid="' + t.id + '" class="tmpl-del" style="color:#d00;">删除</button></td></tr>').join('');
|
||||
}
|
||||
|
||||
document.getElementById('btnManageTemplatesRemote').onclick = () => {
|
||||
document.getElementById('tmplModal').classList.remove('hidden');
|
||||
renderRemoteTemplates();
|
||||
};
|
||||
|
||||
document.getElementById('tmplClose').onclick = () => {
|
||||
document.getElementById('tmplModal').classList.add('hidden');
|
||||
};
|
||||
|
||||
document.getElementById('tmplTbody').addEventListener('click', async e => {
|
||||
const tid = parseInt(e.target.dataset.tid);
|
||||
if (e.target.classList.contains('tmpl-apply')) {
|
||||
const t = remoteTemplates.find(x => x.id === tid);
|
||||
if (t) { fillRemoteForm(t); document.getElementById('rTemplate').value = tid; document.getElementById('tmplModal').classList.add('hidden'); }
|
||||
} else if (e.target.classList.contains('tmpl-del')) {
|
||||
if (!confirm('确定删除该模板?')) return;
|
||||
try { await api('/api/templates/' + tid, { method: 'DELETE' }); alert('已删除'); await renderRemoteTemplates(); }
|
||||
catch (e) { alert('删除失败:' + (e.message || '')); }
|
||||
}
|
||||
});
|
||||
|
||||
async function enter() {
|
||||
showData();
|
||||
// 自定义日期默认填入今天
|
||||
@@ -528,6 +637,7 @@ async function enter() {
|
||||
document.getElementById('dateEnd').value = today;
|
||||
await loadBlacklist();
|
||||
await load();
|
||||
await loadRemoteTemplates();
|
||||
}
|
||||
|
||||
if (token()) enter(); else showLogin();
|
||||
@@ -538,5 +648,19 @@ setInterval(() => {
|
||||
}
|
||||
}, 5000);
|
||||
</script>
|
||||
|
||||
<!-- 模板管理弹窗 -->
|
||||
<div id="tmplModal" class="hidden" style="position:fixed;inset:0;background:rgba(0,0,0,0.45);z-index:2000;display:flex;align-items:center;justify-content:center;">
|
||||
<div style="background:#fff;border-radius:8px;padding:24px;width:760px;max-width:95vw;max-height:85vh;overflow:auto;">
|
||||
<h3 style="margin:0 0 16px;">管理投递模板</h3>
|
||||
<table style="width:100%;border-collapse:collapse;">
|
||||
<thead><tr><th style="text-align:left;border-bottom:1px solid #eee;padding:8px;">名称</th><th style="text-align:left;border-bottom:1px solid #eee;padding:8px;">关键词</th><th style="text-align:left;border-bottom:1px solid #eee;padding:8px;">城市</th><th style="text-align:left;border-bottom:1px solid #eee;padding:8px;">操作</th></tr></thead>
|
||||
<tbody id="tmplTbody"></tbody>
|
||||
</table>
|
||||
<div style="margin-top:16px;text-align:right;">
|
||||
<button id="tmplClose" style="padding:6px 14px;border-radius:4px;border:1px solid #d9d9d9;background:#fff;cursor:pointer;">关闭</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user