data-learner commited on
Commit
3ac3ef5
·
verified ·
1 Parent(s): b29ef2f

Upload index.html with huggingface_hub

Browse files
Files changed (1) hide show
  1. index.html +28 -6
index.html CHANGED
@@ -386,8 +386,17 @@ const extractWorkItems = (text) => {
386
  const parseMemoText = (text) => {
387
  const normalized = normalizeText(text);
388
  const visitDate = normalizeDate(normalized);
389
- const personInCharge = extractFirst(normalized, [/(?:活动负责人|负责人|执行人员|执行人)[::]\s*([^\s,,。;;\n]+)/,/(?:活动负责人|负责人|执行人员|执行人)\s*([^\s,,。;;\n]+)/,/执行人员[::]\s*([^\s,,。;;\n]+)/]);
390
- const region = extractFirst(normalized, [/(?:服务省份及地区|服务地区|服务省份|地区|城市)[::,,]\s*([^,,。;;\n]+)/,/(?:服务省份及地区|服务地区|服务省份|地区|城市)\s*([^,,。;;\n]+)/]);
 
 
 
 
 
 
 
 
 
391
  const pharmacies = extractPharmacies(normalized);
392
  const expectedCount = extractExpectedCount(normalized);
393
  const shopCount = expectedCount || pharmacies.length;
@@ -486,7 +495,10 @@ const uploadScreenshot = async (fileInput) => {
486
  if (text && text.trim().length > 0) {
487
  document.getElementById('memo-input').value = text.trim();
488
  autoParse();
489
- statusEl.innerHTML = '<div class="alert alert-success">OCR识别成功!已自动填充并解析(请核对药店名称和人名)</div>';
 
 
 
490
  addLog('OCR识别', `识别成功,提取${text.trim().length}个字符`, 'pass');
491
  } else {
492
  throw new Error('未识别到文字');
@@ -1409,12 +1421,22 @@ const generateDocx = (visit) => {
1409
  const exportWord = async (id) => {
1410
  const visit = getVisit(id);
1411
  if (!visit) return;
 
 
 
 
 
 
 
 
 
 
1412
  if (typeof docx === 'undefined') {
1413
- alert('Word导出库尚未加载完成,请稍后重试');
 
 
1414
  return;
1415
  }
1416
- const btn = document.getElementById('export-btn');
1417
- btn.disabled = true;
1418
  btn.textContent = '生成中...';
1419
  try {
1420
  const doc = generateDocx(visit);
 
386
  const parseMemoText = (text) => {
387
  const normalized = normalizeText(text);
388
  const visitDate = normalizeDate(normalized);
389
+ const personInCharge = extractFirst(normalized, [
390
+ /(?:活动负责人|负责人|执行人员|执行人)[::\s]\s*([^\s,,。;;\n]+)/,
391
+ /(?:活动负责人|负责人|执行人员|执行人)\s*[::]?\s*([\u4e00-\u9fa5]{2,4})/,
392
+ /执行人员[::\s]\s*([^\s,,。;;\n]+)/,
393
+ /人员[::\s]\s*([\u4e00-\u9fa5]{2,4})/,
394
+ ]);
395
+ const region = extractFirst(normalized, [
396
+ /(?:服务省份及地区|服务地区|服务省份|地区|城市)[::,,\s]\s*([^,,。;;\n]+)/,
397
+ /(?:服务省份及地区|服务地区|服务省份|地区|城市)\s*[::]?\s*([\u4e00-\u9fa5]{2,6})/,
398
+ /省份[::\s]\s*([^,,。;;\n]+)/,
399
+ ]);
400
  const pharmacies = extractPharmacies(normalized);
401
  const expectedCount = extractExpectedCount(normalized);
402
  const shopCount = expectedCount || pharmacies.length;
 
495
  if (text && text.trim().length > 0) {
496
  document.getElementById('memo-input').value = text.trim();
497
  autoParse();
498
+ const parsed = currentParsed;
499
+ const missing = parsed && parsed.missingFields.length > 0 ? parsed.missingFields.join('、') : '';
500
+ const warnMsg = missing ? `<div class="alert alert-warning" style="margin-top:8px;">以下字段未能自动识别,请手动补充: ${missing}<br><small>可点击下方"查看识别原文"核对OCR文本,或直接在文本框中修改后点"重新解析"</small></div>` : '';
501
+ statusEl.innerHTML = '<div class="alert alert-success">OCR识别成功!已自动填充并解析(请核对药店名称和人名)</div>' + warnMsg + '<details style="margin-top:8px;"><summary style="cursor:pointer;font-size:13px;color:#2563eb;">查看识别原文</summary><pre style="margin-top:8px;padding:12px;background:#f8fafc;border-radius:8px;font-size:12px;white-space:pre-wrap;word-break:break-all;max-height:300px;overflow:auto;">' + text.trim().replace(/</g,'&lt;').replace(/>/g,'&gt;') + '</pre></details>';
502
  addLog('OCR识别', `识别成功,提取${text.trim().length}个字符`, 'pass');
503
  } else {
504
  throw new Error('未识别到文字');
 
1421
  const exportWord = async (id) => {
1422
  const visit = getVisit(id);
1423
  if (!visit) return;
1424
+ const btn = document.getElementById('export-btn');
1425
+ btn.disabled = true;
1426
+ btn.textContent = '正在加载导出组件...';
1427
+ // 等待docx库加载完成(最多等30秒)
1428
+ let waitCount = 0;
1429
+ while (typeof docx === 'undefined' && waitCount < 60) {
1430
+ await new Promise(r => setTimeout(r, 500));
1431
+ waitCount++;
1432
+ btn.textContent = `正在加载导出组件...(${waitCount*0.5}秒)`;
1433
+ }
1434
  if (typeof docx === 'undefined') {
1435
+ btn.disabled = false;
1436
+ btn.textContent = '导出Word文档(.docx)';
1437
+ alert('Word导出组件加载超时,请检查网络后刷新页面重试');
1438
  return;
1439
  }
 
 
1440
  btn.textContent = '生成中...';
1441
  try {
1442
  const doc = generateDocx(visit);