update
This commit is contained in:
@@ -298,7 +298,7 @@
|
||||
<div class="form-section">
|
||||
<h2>职位信息结果</h2>
|
||||
<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 id="result-message"></div>
|
||||
<div class="table-container" id="result-table" style="display: none;">
|
||||
@@ -326,6 +326,7 @@
|
||||
// 复用同一个aa,确保selectPosition与getPositionTree的Referer一致
|
||||
let lastAa = '';
|
||||
let lastResults = [];
|
||||
let isCrawling = false; // 爬取状态标志
|
||||
|
||||
// 获取地区选项
|
||||
function getDsdmOptions() {
|
||||
@@ -538,7 +539,7 @@
|
||||
<td>${item.zwdm || ''}</td>
|
||||
<td>${item.zprs || 0}</td>
|
||||
<td>${item.bkrs || 0}</td>
|
||||
<td>${item.competition_ratio || '0.00'}</td>
|
||||
<td>${item.competition_ratio || '0:0'}</td>
|
||||
`;
|
||||
tbody.appendChild(tr);
|
||||
}
|
||||
@@ -599,6 +600,11 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// 开始爬取,禁用导出按钮
|
||||
isCrawling = true;
|
||||
document.getElementById('export-btn').disabled = true;
|
||||
document.getElementById('export-btn').textContent = '爬取中...';
|
||||
|
||||
// 清空旧数据
|
||||
lastResults = [];
|
||||
const tbody = document.getElementById('data-table-body');
|
||||
@@ -615,6 +621,10 @@
|
||||
|
||||
if (listResp.code !== 1 || !Array.isArray(listResp.data) || listResp.data.length === 0) {
|
||||
showMessage('result-message', listResp.msg || '未获取到职位代码', 'error');
|
||||
// 爬取失败,恢复按钮状态
|
||||
isCrawling = false;
|
||||
document.getElementById('export-btn').disabled = false;
|
||||
document.getElementById('export-btn').textContent = '导出CSV';
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -645,10 +655,19 @@
|
||||
}
|
||||
|
||||
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
|
||||
function exportCsv() {
|
||||
if (isCrawling) {
|
||||
showMessage('result-message', '爬取进行中,请等待完成后再导出', 'error');
|
||||
return;
|
||||
}
|
||||
if (!lastResults || lastResults.length === 0) {
|
||||
showMessage('result-message', '暂无数据可导出', 'error');
|
||||
return;
|
||||
@@ -664,7 +683,7 @@
|
||||
item.zwdm || '',
|
||||
item.zprs || 0,
|
||||
item.bkrs || 0,
|
||||
item.competition_ratio || '0.00'
|
||||
item.competition_ratio || '0:0'
|
||||
];
|
||||
lines.push(row.map(v => `"${String(v).replace(/"/g, '""')}"`).join(','));
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user