debug-approval-page.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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>出国审批页面API调试</title>
  7. <style>
  8. body { font-family: Arial, sans-serif; margin: 20px; }
  9. .error { color: red; }
  10. .success { color: green; }
  11. .info { color: blue; }
  12. pre { background: #f5f5f5; padding: 10px; overflow-x: auto; }
  13. button { margin: 5px; padding: 8px 16px; }
  14. </style>
  15. </head>
  16. <body>
  17. <h1>出国审批页面API调试工具</h1>
  18. <div id="status">正在检查...</div>
  19. <h2>测试结果</h2>
  20. <div id="results"></div>
  21. <h2>控制台日志</h2>
  22. <pre id="console-log"></pre>
  23. <script>
  24. const baseURL = 'http://localhost:8080';
  25. const results = document.getElementById('results');
  26. const consoleLog = document.getElementById('console-log');
  27. const status = document.getElementById('status');
  28. // 劫持console.log来显示在页面上
  29. const originalLog = console.log;
  30. const originalError = console.error;
  31. console.log = function(...args) {
  32. originalLog.apply(console, args);
  33. consoleLog.innerHTML += '[LOG] ' + args.join(' ') + '\n';
  34. };
  35. console.error = function(...args) {
  36. originalError.apply(console, args);
  37. consoleLog.innerHTML += '[ERROR] ' + args.join(' ') + '\n';
  38. };
  39. async function testAPI() {
  40. status.innerHTML = '<span class="info">开始测试API...</span>';
  41. // 测试1: 检查基础连接
  42. try {
  43. console.log('测试1: 检查后端服务连接...');
  44. const response = await fetch(`${baseURL}/actuator/health`);
  45. const data = await response.text();
  46. addResult('✅ 后端服务连接', 'success', `状态码: ${response.status}, 响应: ${data.substring(0, 100)}`);
  47. } catch (error) {
  48. addResult('❌ 后端服务连接失败', 'error', error.message);
  49. return;
  50. }
  51. // 测试2: 检查待审批申请API(需要token)
  52. try {
  53. console.log('测试2: 检查待审批申请API...');
  54. const response = await fetch(`${baseURL}/rs/overseas/application/pending/list?pageNum=1&pageSize=10`, {
  55. method: 'GET',
  56. headers: {
  57. 'Accept': 'application/json',
  58. 'Content-Type': 'application/json'
  59. }
  60. });
  61. const data = await response.json();
  62. if (response.status === 401) {
  63. addResult('⚠️ 待审批申请API需要认证', 'info', `状态码: ${response.status}, 消息: ${data.msg}`);
  64. } else if (response.ok) {
  65. addResult('✅ 待审批申请API正常', 'success', `返回数据: ${JSON.stringify(data, null, 2)}`);
  66. } else {
  67. addResult('❌ 待审批申请API异常', 'error', `状态码: ${response.status}, 响应: ${JSON.stringify(data, null, 2)}`);
  68. }
  69. } catch (error) {
  70. addResult('❌ 待审批申请API请求失败', 'error', error.message);
  71. }
  72. // 测试3: 检查审批记录API(需要token)
  73. try {
  74. console.log('测试3: 检查审批记录API...');
  75. const response = await fetch(`${baseURL}/rs/overseas/approval/my/list?pageNum=1&pageSize=10`, {
  76. method: 'GET',
  77. headers: {
  78. 'Accept': 'application/json',
  79. 'Content-Type': 'application/json'
  80. }
  81. });
  82. const data = await response.json();
  83. if (response.status === 401) {
  84. addResult('⚠️ 审批记录API需要认证', 'info', `状态码: ${response.status}, 消息: ${data.msg}`);
  85. } else if (response.ok) {
  86. addResult('✅ 审批记录API正常', 'success', `返回数据: ${JSON.stringify(data, null, 2)}`);
  87. } else {
  88. addResult('❌ 审批记录API异常', 'error', `状态码: ${response.status}, 响应: ${JSON.stringify(data, null, 2)}`);
  89. }
  90. } catch (error) {
  91. addResult('❌ 审批记录API请求失败', 'error', error.message);
  92. }
  93. status.innerHTML = '<span class="success">测试完成!</span>';
  94. }
  95. function addResult(title, type, detail) {
  96. const div = document.createElement('div');
  97. div.innerHTML = `<h3 class="${type}">${title}</h3><pre>${detail}</pre>`;
  98. results.appendChild(div);
  99. }
  100. // 页面加载后自动执行测试
  101. window.onload = function() {
  102. testAPI();
  103. };
  104. </script>
  105. </body>
  106. </html>