update
This commit is contained in:
@@ -366,10 +366,10 @@ class Crawler extends BaseController
|
|||||||
$item = $info;
|
$item = $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算竞争比
|
// 计算竞争比(格式:招聘人数:审核通过人数)
|
||||||
$zprs = isset($item['zprs']) ? intval($item['zprs']) : 0;
|
$zprs = isset($item['zprs']) ? intval($item['zprs']) : 0;
|
||||||
$bkrs = isset($item['bkrs']) ? intval($item['bkrs']) : 0;
|
$bkrs = isset($item['bkrs']) ? intval($item['bkrs']) : 0;
|
||||||
$competitionRatio = $zprs > 0 ? ($bkrs / $zprs) : 0;
|
$competitionRatio = $zprs > 0 && $bkrs > 0 ? $zprs . ':' . $bkrs : ($zprs > 0 ? $zprs . ':0' : '0:0');
|
||||||
|
|
||||||
$result = [
|
$result = [
|
||||||
'sbmc' => $item['sbmc'] ?? '', // 省份
|
'sbmc' => $item['sbmc'] ?? '', // 省份
|
||||||
@@ -379,7 +379,7 @@ class Crawler extends BaseController
|
|||||||
'zwdm' => $item['zwdm'] ?? $zwdm, // 职位代码
|
'zwdm' => $item['zwdm'] ?? $zwdm, // 职位代码
|
||||||
'zprs' => $zprs, // 招聘人数
|
'zprs' => $zprs, // 招聘人数
|
||||||
'bkrs' => $bkrs, // 审核通过人数
|
'bkrs' => $bkrs, // 审核通过人数
|
||||||
'competition_ratio' => number_format($competitionRatio, 2), // 竞争比
|
'competition_ratio' => $competitionRatio, // 竞争比(格式:招聘人数:审核通过人数)
|
||||||
];
|
];
|
||||||
|
|
||||||
return json([
|
return json([
|
||||||
|
|||||||
@@ -175,10 +175,10 @@ class CrawlerService
|
|||||||
$item = $info;
|
$item = $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算竞争比
|
// 计算竞争比(格式:招聘人数:审核通过人数)
|
||||||
$zprs = isset($item['zprs']) ? intval($item['zprs']) : 0;
|
$zprs = isset($item['zprs']) ? intval($item['zprs']) : 0;
|
||||||
$bkrs = isset($item['bkrs']) ? intval($item['bkrs']) : 0;
|
$bkrs = isset($item['bkrs']) ? intval($item['bkrs']) : 0;
|
||||||
$competitionRatio = $zprs > 0 ? ($bkrs / $zprs) : 0;
|
$competitionRatio = $zprs > 0 && $bkrs > 0 ? $zprs . ':' . $bkrs : ($zprs > 0 ? $zprs . ':0' : '0:0');
|
||||||
|
|
||||||
$results[] = [
|
$results[] = [
|
||||||
'sbmc' => $item['sbmc'] ?? '', // 省份
|
'sbmc' => $item['sbmc'] ?? '', // 省份
|
||||||
@@ -188,7 +188,7 @@ class CrawlerService
|
|||||||
'zwdm' => $item['zwdm'] ?? $zwdm, // 职位代码
|
'zwdm' => $item['zwdm'] ?? $zwdm, // 职位代码
|
||||||
'zprs' => $zprs, // 招聘人数
|
'zprs' => $zprs, // 招聘人数
|
||||||
'bkrs' => $bkrs, // 审核通过人数
|
'bkrs' => $bkrs, // 审核通过人数
|
||||||
'competition_ratio' => number_format($competitionRatio, 2), // 竞争比
|
'competition_ratio' => $competitionRatio, // 竞争比(格式:招聘人数:审核通过人数)
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -298,7 +298,7 @@
|
|||||||
<div class="form-section">
|
<div class="form-section">
|
||||||
<h2>职位信息结果</h2>
|
<h2>职位信息结果</h2>
|
||||||
<div class="action-buttons" style="margin-bottom: 15px;">
|
<div class="action-buttons" style="margin-bottom: 15px;">
|
||||||
<button class="btn btn-secondary" onclick="exportCsv()">导出CSV</button>
|
<button class="btn btn-secondary" id="export-btn" onclick="exportCsv()" disabled>导出CSV</button>
|
||||||
</div>
|
</div>
|
||||||
<div id="result-message"></div>
|
<div id="result-message"></div>
|
||||||
<div class="table-container" id="result-table" style="display: none;">
|
<div class="table-container" id="result-table" style="display: none;">
|
||||||
@@ -326,6 +326,7 @@
|
|||||||
// 复用同一个aa,确保selectPosition与getPositionTree的Referer一致
|
// 复用同一个aa,确保selectPosition与getPositionTree的Referer一致
|
||||||
let lastAa = '';
|
let lastAa = '';
|
||||||
let lastResults = [];
|
let lastResults = [];
|
||||||
|
let isCrawling = false; // 爬取状态标志
|
||||||
|
|
||||||
// 获取地区选项
|
// 获取地区选项
|
||||||
function getDsdmOptions() {
|
function getDsdmOptions() {
|
||||||
@@ -538,7 +539,7 @@
|
|||||||
<td>${item.zwdm || ''}</td>
|
<td>${item.zwdm || ''}</td>
|
||||||
<td>${item.zprs || 0}</td>
|
<td>${item.zprs || 0}</td>
|
||||||
<td>${item.bkrs || 0}</td>
|
<td>${item.bkrs || 0}</td>
|
||||||
<td>${item.competition_ratio || '0.00'}</td>
|
<td>${item.competition_ratio || '0:0'}</td>
|
||||||
`;
|
`;
|
||||||
tbody.appendChild(tr);
|
tbody.appendChild(tr);
|
||||||
}
|
}
|
||||||
@@ -599,6 +600,11 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 开始爬取,禁用导出按钮
|
||||||
|
isCrawling = true;
|
||||||
|
document.getElementById('export-btn').disabled = true;
|
||||||
|
document.getElementById('export-btn').textContent = '爬取中...';
|
||||||
|
|
||||||
// 清空旧数据
|
// 清空旧数据
|
||||||
lastResults = [];
|
lastResults = [];
|
||||||
const tbody = document.getElementById('data-table-body');
|
const tbody = document.getElementById('data-table-body');
|
||||||
@@ -615,6 +621,10 @@
|
|||||||
|
|
||||||
if (listResp.code !== 1 || !Array.isArray(listResp.data) || listResp.data.length === 0) {
|
if (listResp.code !== 1 || !Array.isArray(listResp.data) || listResp.data.length === 0) {
|
||||||
showMessage('result-message', listResp.msg || '未获取到职位代码', 'error');
|
showMessage('result-message', listResp.msg || '未获取到职位代码', 'error');
|
||||||
|
// 爬取失败,恢复按钮状态
|
||||||
|
isCrawling = false;
|
||||||
|
document.getElementById('export-btn').disabled = false;
|
||||||
|
document.getElementById('export-btn').textContent = '导出CSV';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -645,10 +655,19 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
showMessage('result-message', `完成,共 ${lastResults.length} 条成功,失败 ${codes.length - lastResults.length} 条`, 'success');
|
showMessage('result-message', `完成,共 ${lastResults.length} 条成功,失败 ${codes.length - lastResults.length} 条`, 'success');
|
||||||
|
|
||||||
|
// 爬取完成,启用导出按钮
|
||||||
|
isCrawling = false;
|
||||||
|
document.getElementById('export-btn').disabled = false;
|
||||||
|
document.getElementById('export-btn').textContent = '导出CSV';
|
||||||
}
|
}
|
||||||
|
|
||||||
// 导出CSV
|
// 导出CSV
|
||||||
function exportCsv() {
|
function exportCsv() {
|
||||||
|
if (isCrawling) {
|
||||||
|
showMessage('result-message', '爬取进行中,请等待完成后再导出', 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (!lastResults || lastResults.length === 0) {
|
if (!lastResults || lastResults.length === 0) {
|
||||||
showMessage('result-message', '暂无数据可导出', 'error');
|
showMessage('result-message', '暂无数据可导出', 'error');
|
||||||
return;
|
return;
|
||||||
@@ -664,7 +683,7 @@
|
|||||||
item.zwdm || '',
|
item.zwdm || '',
|
||||||
item.zprs || 0,
|
item.zprs || 0,
|
||||||
item.bkrs || 0,
|
item.bkrs || 0,
|
||||||
item.competition_ratio || '0.00'
|
item.competition_ratio || '0:0'
|
||||||
];
|
];
|
||||||
lines.push(row.map(v => `"${String(v).replace(/"/g, '""')}"`).join(','));
|
lines.push(row.map(v => `"${String(v).replace(/"/g, '""')}"`).join(','));
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user