index.html 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>施工方案审查结果可视化工具</title>
  7. <style>
  8. * {
  9. margin: 0;
  10. padding: 0;
  11. box-sizing: border-box;
  12. }
  13. body {
  14. font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  15. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  16. min-height: 100vh;
  17. padding: 20px;
  18. }
  19. .container {
  20. max-width: 1400px;
  21. margin: 0 auto;
  22. }
  23. .header {
  24. background: white;
  25. border-radius: 16px;
  26. padding: 30px;
  27. margin-bottom: 20px;
  28. box-shadow: 0 10px 40px rgba(0,0,0,0.1);
  29. }
  30. .header h1 {
  31. font-size: 28px;
  32. color: #1a1a2e;
  33. margin-bottom: 10px;
  34. display: flex;
  35. align-items: center;
  36. gap: 12px;
  37. }
  38. .header h1::before {
  39. content: '📋';
  40. font-size: 32px;
  41. }
  42. .header .subtitle {
  43. color: #666;
  44. font-size: 14px;
  45. }
  46. .file-selector {
  47. margin-top: 20px;
  48. display: flex;
  49. gap: 15px;
  50. flex-wrap: wrap;
  51. align-items: center;
  52. }
  53. .file-selector input[type="file"] {
  54. display: none;
  55. }
  56. .btn {
  57. padding: 12px 24px;
  58. border: none;
  59. border-radius: 8px;
  60. cursor: pointer;
  61. font-size: 14px;
  62. font-weight: 500;
  63. transition: all 0.3s ease;
  64. display: inline-flex;
  65. align-items: center;
  66. gap: 8px;
  67. }
  68. .btn-primary {
  69. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  70. color: white;
  71. }
  72. .btn-primary:hover {
  73. transform: translateY(-2px);
  74. box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
  75. }
  76. .btn-secondary {
  77. background: #f0f0f0;
  78. color: #333;
  79. }
  80. .btn-secondary:hover {
  81. background: #e0e0e0;
  82. }
  83. .file-path {
  84. color: #666;
  85. font-size: 13px;
  86. padding: 8px 16px;
  87. background: #f8f9fa;
  88. border-radius: 6px;
  89. font-family: monospace;
  90. }
  91. .stats-bar {
  92. display: flex;
  93. gap: 20px;
  94. margin-top: 20px;
  95. flex-wrap: wrap;
  96. }
  97. .stat-card {
  98. background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  99. color: white;
  100. padding: 20px 30px;
  101. border-radius: 12px;
  102. min-width: 150px;
  103. text-align: center;
  104. }
  105. .stat-card.warning {
  106. background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  107. }
  108. .stat-card.success {
  109. background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  110. }
  111. .stat-card.info {
  112. background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
  113. }
  114. .stat-value {
  115. font-size: 32px;
  116. font-weight: bold;
  117. margin-bottom: 5px;
  118. }
  119. .stat-label {
  120. font-size: 13px;
  121. opacity: 0.9;
  122. }
  123. .filters {
  124. background: white;
  125. border-radius: 16px;
  126. padding: 20px;
  127. margin-bottom: 20px;
  128. box-shadow: 0 10px 40px rgba(0,0,0,0.1);
  129. display: flex;
  130. gap: 20px;
  131. flex-wrap: wrap;
  132. align-items: center;
  133. }
  134. .filter-group {
  135. display: flex;
  136. flex-direction: column;
  137. gap: 8px;
  138. }
  139. .filter-group label {
  140. font-size: 13px;
  141. color: #666;
  142. font-weight: 500;
  143. }
  144. .filter-group select,
  145. .filter-group input {
  146. padding: 10px 16px;
  147. border: 2px solid #e0e0e0;
  148. border-radius: 8px;
  149. font-size: 14px;
  150. min-width: 150px;
  151. transition: border-color 0.3s;
  152. }
  153. .filter-group select:focus,
  154. .filter-group input:focus {
  155. outline: none;
  156. border-color: #667eea;
  157. }
  158. .cards-container {
  159. display: grid;
  160. grid-template-columns: repeat(auto-fill, minmax(450px, 1fr));
  161. gap: 20px;
  162. }
  163. .review-card {
  164. background: white;
  165. border-radius: 16px;
  166. overflow: hidden;
  167. box-shadow: 0 10px 40px rgba(0,0,0,0.1);
  168. transition: all 0.3s ease;
  169. border-left: 5px solid #ddd;
  170. }
  171. .review-card:hover {
  172. transform: translateY(-5px);
  173. box-shadow: 0 20px 60px rgba(0,0,0,0.15);
  174. }
  175. .review-card.high-risk {
  176. border-left-color: #e74c3c;
  177. }
  178. .review-card.medium-risk {
  179. border-left-color: #f39c12;
  180. }
  181. .review-card.low-risk {
  182. border-left-color: #27ae60;
  183. }
  184. .review-card.no-risk {
  185. border-left-color: #95a5a6;
  186. }
  187. .card-header {
  188. padding: 20px;
  189. background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  190. border-bottom: 1px solid #e0e0e0;
  191. }
  192. .card-header-top {
  193. display: flex;
  194. justify-content: space-between;
  195. align-items: flex-start;
  196. margin-bottom: 10px;
  197. flex-wrap: wrap;
  198. gap: 10px;
  199. }
  200. .chapter-code {
  201. display: inline-block;
  202. padding: 6px 14px;
  203. background: #667eea;
  204. color: white;
  205. border-radius: 20px;
  206. font-size: 12px;
  207. font-weight: 600;
  208. text-transform: uppercase;
  209. letter-spacing: 0.5px;
  210. }
  211. .risk-badge {
  212. padding: 6px 14px;
  213. border-radius: 20px;
  214. font-size: 12px;
  215. font-weight: 600;
  216. text-transform: uppercase;
  217. }
  218. .risk-badge.high {
  219. background: #ffe5e5;
  220. color: #c0392b;
  221. }
  222. .risk-badge.medium {
  223. background: #fff3e0;
  224. color: #e67e22;
  225. }
  226. .risk-badge.low {
  227. background: #e8f5e9;
  228. color: #27ae60;
  229. }
  230. .risk-badge.none {
  231. background: #eceff1;
  232. color: #546e7a;
  233. }
  234. .check-item {
  235. font-size: 16px;
  236. font-weight: 600;
  237. color: #1a1a2e;
  238. margin-top: 10px;
  239. }
  240. .check-item-code {
  241. font-size: 12px;
  242. color: #888;
  243. font-family: monospace;
  244. margin-top: 4px;
  245. }
  246. .card-body {
  247. padding: 20px;
  248. }
  249. .info-row {
  250. margin-bottom: 16px;
  251. }
  252. .info-row:last-child {
  253. margin-bottom: 0;
  254. }
  255. .info-label {
  256. font-size: 12px;
  257. color: #888;
  258. text-transform: uppercase;
  259. letter-spacing: 0.5px;
  260. margin-bottom: 6px;
  261. font-weight: 600;
  262. }
  263. .info-content {
  264. font-size: 14px;
  265. color: #333;
  266. line-height: 1.6;
  267. background: #f8f9fa;
  268. padding: 12px;
  269. border-radius: 8px;
  270. word-break: break-word;
  271. }
  272. .info-content.issue {
  273. background: #fff3e0;
  274. border-left: 4px solid #f39c12;
  275. }
  276. .info-content.suggestion {
  277. background: #e3f2fd;
  278. border-left: 4px solid #2196f3;
  279. }
  280. .info-content.reason {
  281. background: #f3e5f5;
  282. border-left: 4px solid #9c27b0;
  283. }
  284. .info-content.location {
  285. background: #e8f5e9;
  286. border-left: 4px solid #4caf50;
  287. }
  288. .card-footer {
  289. padding: 15px 20px;
  290. background: #f8f9fa;
  291. border-top: 1px solid #e0e0e0;
  292. display: flex;
  293. justify-content: space-between;
  294. align-items: center;
  295. flex-wrap: wrap;
  296. gap: 10px;
  297. }
  298. .issue-status {
  299. display: flex;
  300. align-items: center;
  301. gap: 8px;
  302. font-size: 13px;
  303. font-weight: 600;
  304. }
  305. .issue-status.has-issue {
  306. color: #e74c3c;
  307. }
  308. .issue-status.no-issue {
  309. color: #27ae60;
  310. }
  311. .status-dot {
  312. width: 10px;
  313. height: 10px;
  314. border-radius: 50%;
  315. }
  316. .status-dot.has-issue {
  317. background: #e74c3c;
  318. animation: pulse 2s infinite;
  319. }
  320. .status-dot.no-issue {
  321. background: #27ae60;
  322. }
  323. @keyframes pulse {
  324. 0% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.4); }
  325. 70% { box-shadow: 0 0 0 10px rgba(231, 76, 60, 0); }
  326. 100% { box-shadow: 0 0 0 0 rgba(231, 76, 60, 0); }
  327. }
  328. .reference-source {
  329. font-size: 12px;
  330. color: #888;
  331. max-width: 200px;
  332. overflow: hidden;
  333. text-overflow: ellipsis;
  334. white-space: nowrap;
  335. }
  336. .empty-state {
  337. text-align: center;
  338. padding: 80px 20px;
  339. color: white;
  340. }
  341. .empty-state-icon {
  342. font-size: 80px;
  343. margin-bottom: 20px;
  344. opacity: 0.8;
  345. }
  346. .empty-state h2 {
  347. font-size: 24px;
  348. margin-bottom: 10px;
  349. }
  350. .empty-state p {
  351. opacity: 0.8;
  352. }
  353. .loading {
  354. text-align: center;
  355. padding: 60px;
  356. color: white;
  357. }
  358. .loading-spinner {
  359. width: 50px;
  360. height: 50px;
  361. border: 4px solid rgba(255,255,255,0.3);
  362. border-top-color: white;
  363. border-radius: 50%;
  364. animation: spin 1s linear infinite;
  365. margin: 0 auto 20px;
  366. }
  367. @keyframes spin {
  368. to { transform: rotate(360deg); }
  369. }
  370. .toast {
  371. position: fixed;
  372. bottom: 30px;
  373. right: 30px;
  374. background: white;
  375. padding: 16px 24px;
  376. border-radius: 12px;
  377. box-shadow: 0 10px 40px rgba(0,0,0,0.2);
  378. display: flex;
  379. align-items: center;
  380. gap: 12px;
  381. transform: translateX(400px);
  382. transition: transform 0.3s ease;
  383. z-index: 1000;
  384. }
  385. .toast.show {
  386. transform: translateX(0);
  387. }
  388. .toast-icon {
  389. font-size: 24px;
  390. }
  391. .toast.success .toast-icon { color: #27ae60; }
  392. .toast.error .toast-icon { color: #e74c3c; }
  393. @media (max-width: 768px) {
  394. .cards-container {
  395. grid-template-columns: 1fr;
  396. }
  397. .header h1 {
  398. font-size: 22px;
  399. }
  400. .filters {
  401. flex-direction: column;
  402. align-items: stretch;
  403. }
  404. .filter-group select,
  405. .filter-group input {
  406. width: 100%;
  407. }
  408. }
  409. .json-preview {
  410. background: #1e1e1e;
  411. color: #d4d4d4;
  412. padding: 20px;
  413. border-radius: 8px;
  414. font-family: 'Consolas', 'Monaco', monospace;
  415. font-size: 13px;
  416. overflow-x: auto;
  417. max-height: 300px;
  418. overflow-y: auto;
  419. display: none;
  420. }
  421. .json-preview.show {
  422. display: block;
  423. }
  424. .toggle-json {
  425. margin-top: 10px;
  426. color: #667eea;
  427. cursor: pointer;
  428. font-size: 13px;
  429. text-decoration: underline;
  430. }
  431. </style>
  432. </head>
  433. <body>
  434. <div class="container">
  435. <div class="header">
  436. <h1>施工方案可视化审查结果工具</h1>
  437. <p class="subtitle">直观展示AI审查结果,快速定位问题与风险</p>
  438. <div class="file-selector">
  439. <label class="btn btn-primary">
  440. 📁 选择JSON文件
  441. <input type="file" id="fileInput" accept=".json">
  442. </label>
  443. <button class="btn btn-secondary" onclick="loadFromDefault()">
  444. 📂 加载默认目录
  445. </button>
  446. <span class="file-path" id="filePath">temp\construction_review\final_result\</span>
  447. </div>
  448. <div class="stats-bar" id="statsBar" style="display: none;">
  449. <div class="stat-card">
  450. <div class="stat-value" id="totalCount">0</div>
  451. <div class="stat-label">总检查项</div>
  452. </div>
  453. <div class="stat-card warning">
  454. <div class="stat-value" id="highRiskCount">0</div>
  455. <div class="stat-label">高风险</div>
  456. </div>
  457. <div class="stat-card info">
  458. <div class="stat-value" id="mediumRiskCount">0</div>
  459. <div class="stat-label">中风险</div>
  460. </div>
  461. <div class="stat-card success">
  462. <div class="stat-value" id="lowRiskCount">0</div>
  463. <div class="stat-label">低风险/无风险</div>
  464. </div>
  465. </div>
  466. </div>
  467. <div class="filters" id="filters" style="display: none;">
  468. <div class="filter-group">
  469. <label>风险等级</label>
  470. <select id="riskFilter" onchange="applyFilters()">
  471. <option value="all">全部</option>
  472. <option value="high">高风险</option>
  473. <option value="medium">中风险</option>
  474. <option value="low">低风险</option>
  475. <option value="none">无风险</option>
  476. </select>
  477. </div>
  478. <div class="filter-group">
  479. <label>检查项类型</label>
  480. <select id="chapterFilter" onchange="applyFilters()">
  481. <option value="all">全部章节</option>
  482. </select>
  483. </div>
  484. <div class="filter-group">
  485. <label>问题状态</label>
  486. <select id="issueFilter" onchange="applyFilters()">
  487. <option value="all">全部</option>
  488. <option value="has-issue">存在问题</option>
  489. <option value="no-issue">无问题</option>
  490. </select>
  491. </div>
  492. <div class="filter-group">
  493. <label>搜索</label>
  494. <input type="text" id="searchInput" placeholder="搜索关键词..." oninput="applyFilters()">
  495. </div>
  496. </div>
  497. <div id="content">
  498. <div class="empty-state">
  499. <div class="empty-state-icon">📂</div>
  500. <h2>请选择审查结果文件</h2>
  501. <p>支持直接上传JSON文件或从默认目录加载</p>
  502. </div>
  503. </div>
  504. </div>
  505. <div class="toast" id="toast">
  506. <span class="toast-icon">✓</span>
  507. <span class="toast-message">操作成功</span>
  508. </div>
  509. <script>
  510. let allReviewItems = [];
  511. let filteredItems = [];
  512. document.getElementById('fileInput').addEventListener('change', handleFileSelect);
  513. function handleFileSelect(event) {
  514. const file = event.target.files[0];
  515. if (!file) return;
  516. const reader = new FileReader();
  517. reader.onload = function(e) {
  518. try {
  519. // 移除控制字符
  520. let content = e.target.result;
  521. content = content.replace(/[\x00-\x08\x0b-\x0c\x0e-\x1f]/g, '');
  522. const data = JSON.parse(content);
  523. processData(data);
  524. showToast('文件加载成功', 'success');
  525. } catch (err) {
  526. showToast('JSON解析错误: ' + err.message, 'error');
  527. console.error(err);
  528. }
  529. };
  530. reader.readAsText(file);
  531. }
  532. function loadFromDefault() {
  533. // 尝试加载默认目录中的第一个JSON文件
  534. fetch('../../temp/construction_review/final_result/')
  535. .then(response => {
  536. if (!response.ok) throw new Error('无法访问目录');
  537. return response.text();
  538. })
  539. .then(html => {
  540. // 解析目录列表
  541. const parser = new DOMParser();
  542. const doc = parser.parseFromString(html, 'text/html');
  543. const links = Array.from(doc.querySelectorAll('a'));
  544. const jsonFiles = links
  545. .map(a => a.href)
  546. .filter(href => href.endsWith('.json'))
  547. .map(href => href.split('/').pop());
  548. if (jsonFiles.length > 0) {
  549. loadJsonFile(jsonFiles[0]);
  550. } else {
  551. showToast('默认目录中没有找到JSON文件', 'error');
  552. }
  553. })
  554. .catch(err => {
  555. // 如果无法列出目录,尝试直接加载已知文件
  556. const defaultFiles = [
  557. 'f926d2ad4428bfcbe12be8702e2c32ce-1773041592.json'
  558. ];
  559. loadJsonFile(defaultFiles[0]);
  560. });
  561. }
  562. function loadJsonFile(filename) {
  563. fetch(`../../temp/construction_review/final_result/${filename}`)
  564. .then(response => {
  565. if (!response.ok) throw new Error('文件加载失败');
  566. return response.text();
  567. })
  568. .then(text => {
  569. // 移除控制字符
  570. text = text.replace(/[\x00-\x08\x0b-\x0c\x0e-\x1f]/g, '');
  571. const data = JSON.parse(text);
  572. processData(data);
  573. showToast(`已加载: ${filename}`, 'success');
  574. })
  575. .catch(err => {
  576. showToast('加载失败: ' + err.message, 'error');
  577. });
  578. }
  579. function processData(data) {
  580. allReviewItems = [];
  581. const aiReviewResult = data.ai_review_result || {};
  582. const reviewResults = aiReviewResult.review_results || [];
  583. reviewResults.forEach(result => {
  584. Object.values(result).forEach(unit => {
  585. if (unit.review_lists) {
  586. unit.review_lists.forEach(item => {
  587. allReviewItems.push(item);
  588. });
  589. }
  590. });
  591. });
  592. // 填充章节筛选器
  593. populateChapterFilter();
  594. // 显示统计
  595. updateStats();
  596. // 应用筛选并渲染
  597. applyFilters();
  598. // 显示筛选栏
  599. document.getElementById('filters').style.display = 'flex';
  600. document.getElementById('statsBar').style.display = 'flex';
  601. }
  602. function populateChapterFilter() {
  603. const chapters = [...new Set(allReviewItems.map(item => item.chapter_code))];
  604. const select = document.getElementById('chapterFilter');
  605. select.innerHTML = '<option value="all">全部章节</option>';
  606. chapters.forEach(chapter => {
  607. if (chapter) {
  608. const option = document.createElement('option');
  609. option.value = chapter;
  610. option.textContent = chapter;
  611. select.appendChild(option);
  612. }
  613. });
  614. }
  615. function updateStats() {
  616. let high = 0, medium = 0, low = 0, none = 0;
  617. allReviewItems.forEach(item => {
  618. const riskLevel = getRiskLevel(item);
  619. switch(riskLevel) {
  620. case 'high': high++; break;
  621. case 'medium': medium++; break;
  622. case 'low': low++; break;
  623. default: none++; break;
  624. }
  625. });
  626. document.getElementById('totalCount').textContent = allReviewItems.length;
  627. document.getElementById('highRiskCount').textContent = high;
  628. document.getElementById('mediumRiskCount').textContent = medium;
  629. document.getElementById('lowRiskCount').textContent = low + none;
  630. }
  631. function getRiskLevel(item) {
  632. const riskInfo = item.risk_info || {};
  633. const riskLevel = (riskInfo.risk_level || '').toLowerCase();
  634. if (riskLevel.includes('高') || riskLevel.includes('high')) return 'high';
  635. if (riskLevel.includes('中') || riskLevel.includes('medium')) return 'medium';
  636. if (riskLevel.includes('低') || riskLevel.includes('low')) return 'low';
  637. return 'none';
  638. }
  639. function getRiskClass(riskLevel) {
  640. switch(riskLevel) {
  641. case 'high': return 'high-risk';
  642. case 'medium': return 'medium-risk';
  643. case 'low': return 'low-risk';
  644. default: return 'no-risk';
  645. }
  646. }
  647. function getRiskBadgeClass(riskLevel) {
  648. switch(riskLevel) {
  649. case 'high': return 'high';
  650. case 'medium': return 'medium';
  651. case 'low': return 'low';
  652. default: return 'none';
  653. }
  654. }
  655. function getRiskLabel(riskLevel) {
  656. switch(riskLevel) {
  657. case 'high': return '高风险';
  658. case 'medium': return '中风险';
  659. case 'low': return '低风险';
  660. default: return '无风险';
  661. }
  662. }
  663. function applyFilters() {
  664. const riskFilter = document.getElementById('riskFilter').value;
  665. const chapterFilter = document.getElementById('chapterFilter').value;
  666. const issueFilter = document.getElementById('issueFilter').value;
  667. const searchInput = document.getElementById('searchInput').value.toLowerCase();
  668. filteredItems = allReviewItems.filter(item => {
  669. // 风险等级筛选
  670. if (riskFilter !== 'all') {
  671. const itemRisk = getRiskLevel(item);
  672. if (itemRisk !== riskFilter) return false;
  673. }
  674. // 章节筛选
  675. if (chapterFilter !== 'all' && item.chapter_code !== chapterFilter) {
  676. return false;
  677. }
  678. // 问题状态筛选
  679. if (issueFilter !== 'all') {
  680. const hasIssue = item.exist_issue === true;
  681. if (issueFilter === 'has-issue' && !hasIssue) return false;
  682. if (issueFilter === 'no-issue' && hasIssue) return false;
  683. }
  684. // 搜索筛选
  685. if (searchInput) {
  686. const searchText = [
  687. item.check_item,
  688. item.check_item_code,
  689. item.chapter_code,
  690. item.check_result,
  691. item.location,
  692. item.suggestion,
  693. item.reason
  694. ].join(' ').toLowerCase();
  695. if (!searchText.includes(searchInput)) return false;
  696. }
  697. return true;
  698. });
  699. renderCards();
  700. }
  701. function renderCards() {
  702. const content = document.getElementById('content');
  703. if (filteredItems.length === 0) {
  704. content.innerHTML = `
  705. <div class="empty-state">
  706. <div class="empty-state-icon">🔍</div>
  707. <h2>没有找到匹配的结果</h2>
  708. <p>请尝试调整筛选条件</p>
  709. </div>
  710. `;
  711. return;
  712. }
  713. const cardsHtml = filteredItems.map(item => {
  714. const riskLevel = getRiskLevel(item);
  715. const riskClass = getRiskClass(riskLevel);
  716. const badgeClass = getRiskBadgeClass(riskLevel);
  717. const riskLabel = getRiskLabel(riskLevel);
  718. const hasIssue = item.exist_issue === true;
  719. return `
  720. <div class="review-card ${riskClass}">
  721. <div class="card-header">
  722. <div class="card-header-top">
  723. <span class="chapter-code">${escapeHtml(item.chapter_code || '未知章节')}</span>
  724. <span class="risk-badge ${badgeClass}">${riskLabel}</span>
  725. </div>
  726. <div class="check-item">${escapeHtml(item.check_item || '未命名检查项')}</div>
  727. <div class="check-item-code">${escapeHtml(item.check_item_code || '')}</div>
  728. </div>
  729. <div class="card-body">
  730. <div class="info-row">
  731. <div class="info-label">📍 问题位置</div>
  732. <div class="info-content location">${escapeHtml(item.location || item.check_result || '未指定')}</div>
  733. </div>
  734. ${item.suggestion ? `
  735. <div class="info-row">
  736. <div class="info-label">💡 修改建议</div>
  737. <div class="info-content suggestion">${escapeHtml(item.suggestion)}</div>
  738. </div>
  739. ` : ''}
  740. ${item.reason ? `
  741. <div class="info-row">
  742. <div class="info-label">📝 审查依据</div>
  743. <div class="info-content reason">${escapeHtml(item.reason)}</div>
  744. </div>
  745. ` : ''}
  746. ${item.review_references ? `
  747. <div class="info-row">
  748. <div class="info-label">📚 参考标准</div>
  749. <div class="info-content">${escapeHtml(item.review_references)}</div>
  750. </div>
  751. ` : ''}
  752. </div>
  753. <div class="card-footer">
  754. <div class="issue-status ${hasIssue ? 'has-issue' : 'no-issue'}">
  755. <span class="status-dot ${hasIssue ? 'has-issue' : 'no-issue'}"></span>
  756. <span>${hasIssue ? '存在问题' : '无问题'}</span>
  757. </div>
  758. ${item.reference_source ? `
  759. <div class="reference-source" title="${escapeHtml(item.reference_source)}">
  760. 来源: ${escapeHtml(item.reference_source)}
  761. </div>
  762. ` : ''}
  763. </div>
  764. </div>
  765. `;
  766. }).join('');
  767. content.innerHTML = `<div class="cards-container">${cardsHtml}</div>`;
  768. }
  769. function escapeHtml(text) {
  770. if (!text) return '';
  771. const div = document.createElement('div');
  772. div.textContent = text;
  773. return div.innerHTML;
  774. }
  775. function showToast(message, type) {
  776. const toast = document.getElementById('toast');
  777. toast.className = `toast ${type} show`;
  778. toast.querySelector('.toast-icon').textContent = type === 'success' ? '✓' : '✗';
  779. toast.querySelector('.toast-message').textContent = message;
  780. setTimeout(() => {
  781. toast.classList.remove('show');
  782. }, 3000);
  783. }
  784. // 页面加载时尝试自动加载
  785. window.addEventListener('load', () => {
  786. // 可选:自动加载默认文件
  787. // loadFromDefault();
  788. });
  789. </script>
  790. </body>
  791. </html>