update
This commit is contained in:
@@ -344,6 +344,7 @@
|
||||
<script>
|
||||
// 复用同一个aa,确保selectPosition与getPositionTree的Referer一致
|
||||
let lastAa = '';
|
||||
let lastResults = [];
|
||||
|
||||
// 获取地区选项
|
||||
function getDsdmOptions() {
|
||||
@@ -522,6 +523,7 @@
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 1) {
|
||||
lastResults = data.data;
|
||||
displayResults(data.data);
|
||||
showMessage('result-message', `成功获取 ${data.data.length} 条职位信息`, 'success');
|
||||
} else {
|
||||
@@ -563,6 +565,82 @@
|
||||
|
||||
document.getElementById('result-table').style.display = 'block';
|
||||
}
|
||||
|
||||
// 自动抓取全部职位代码并获取详情
|
||||
function autoFetchAllPositions() {
|
||||
const dsdm = document.getElementById('dsdm').value;
|
||||
const examid = document.getElementById('examid').value.trim();
|
||||
const bmid = document.getElementById('bmid').value.trim();
|
||||
const userid = document.getElementById('userid').value.trim();
|
||||
const cookieData = buildCookiesPayload('result-message');
|
||||
const aa = lastAa || Date.now().toString();
|
||||
|
||||
if (!dsdm) {
|
||||
showMessage('result-message', '请先选择地区', 'error');
|
||||
return;
|
||||
}
|
||||
if (!examid || !bmid || !userid) {
|
||||
showMessage('result-message', '请先填写examid、bmid和userid', 'error');
|
||||
return;
|
||||
}
|
||||
if (!cookieData) {
|
||||
return;
|
||||
}
|
||||
|
||||
showMessage('result-message', '正在自动抓取全部职位,请稍候...', 'info');
|
||||
|
||||
fetch('/crawler/fetchAllPositions', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
body: `dsdm=${encodeURIComponent(dsdm)}&examid=${encodeURIComponent(examid)}&bmid=${encodeURIComponent(bmid)}&userid=${encodeURIComponent(userid)}&aa=${encodeURIComponent(aa)}&cookies=${encodeURIComponent(JSON.stringify(cookieData))}`
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.code === 1) {
|
||||
lastResults = data.data;
|
||||
displayResults(data.data);
|
||||
showMessage('result-message', `成功获取 ${data.data.length} 条职位信息`, 'success');
|
||||
} else {
|
||||
showMessage('result-message', data.msg || '获取失败', 'error');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
showMessage('result-message', '请求失败: ' + error.message, 'error');
|
||||
});
|
||||
}
|
||||
|
||||
// 导出CSV
|
||||
function exportCsv() {
|
||||
if (!lastResults || lastResults.length === 0) {
|
||||
showMessage('result-message', '暂无数据可导出', 'error');
|
||||
return;
|
||||
}
|
||||
const headers = ['省份','地区','招聘单位/用人司局','职位名称','职位代码','招聘人数','审核通过人数','竞争比'];
|
||||
const lines = [headers.join(',')];
|
||||
lastResults.forEach(item => {
|
||||
const row = [
|
||||
item.sbmc || '',
|
||||
item.dsmc || '',
|
||||
item.zpdwmc || '',
|
||||
item.zwmc || '',
|
||||
item.zwdm || '',
|
||||
item.zprs || 0,
|
||||
item.bkrs || 0,
|
||||
item.competition_ratio || '0.00'
|
||||
];
|
||||
lines.push(row.map(v => `"${String(v).replace(/"/g, '""')}"`).join(','));
|
||||
});
|
||||
const blob = new Blob([lines.join('\n')], { type: 'text/csv;charset=utf-8;' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = 'positions.csv';
|
||||
link.click();
|
||||
URL.revokeObjectURL(url);
|
||||
showMessage('result-message', '已导出CSV', 'success');
|
||||
}
|
||||
|
||||
// 显示消息
|
||||
function showMessage(containerId, message, type) {
|
||||
|
||||
Reference in New Issue
Block a user