zsh2517

Untitled

Oct 21st, 2024
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.73 KB | None | 0 0
  1.  
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <meta charset="UTF-8">
  6. <title>免责条款格式化</title>
  7. <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
  8. </head>
  9. <body class="bg-gray-100">
  10. <div class="container mx-auto px-4 py-8">
  11. <div class="max-w-3xl mx-auto bg-white rounded-lg shadow-md p-8">
  12. <h1 class="text-3xl font-bold mb-6 text-center text-indigo-600">免责条款格式化</h1>
  13. <div class="mb-8">
  14. <p class="mb-4 text-gray-700">请上传Excel文件,表中包含三列:产品编号,产品名称,产品免责文本。注意:表格首行为标题</p>
  15. <p class="text-gray-700">返回结果为一个Excel文件,包含五列:产品编号,产品名称,原文本,结构化信息(key),结构化信息(text)。点击上传后,需要等待一段时间(处理时长取决于上传的产品数量和免责条款长度,两个产品大概需要2~3分钟)</p>
  16. </div>
  17. <div class="flex justify-center mb-8">
  18. <div class="relative">
  19. <input type="file" id="fileInput" accept=".xlsx" class="absolute top-0 left-0 w-full h-full opacity-0 cursor-pointer">
  20. <label for="fileInput" class="bg-indigo-500 hover:bg-indigo-600 text-white font-semibold py-3 px-6 rounded-full flex items-center">
  21. <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
  22. <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v6m0 0v6m0-6h6m-6 0H6" />
  23. </svg>
  24. 选择文件
  25. </label>
  26. </div>
  27. </div>
  28. <div class="text-center">
  29. <button id="uploadButton" class="bg-green-500 hover:bg-green-600 text-white font-semibold py-3 px-8 rounded-full transition duration-300" disabled>
  30. 上传并处理
  31. </button>
  32. </div>
  33. </div>
  34. </div>
  35.  
  36. <script>
  37. // 保持原有的 JavaScript 逻辑不变
  38. const fileInput = document.getElementById('fileInput');
  39. const uploadButton = document.getElementById('uploadButton');
  40.  
  41. fileInput.addEventListener('change', function () {
  42. if (fileInput.files.length > 0) {
  43. uploadButton.disabled = false;
  44. } else {
  45. uploadButton.disabled = true;
  46. }
  47. });
  48.  
  49. uploadButton.addEventListener('click', function () {
  50. if (fileInput.files.length === 0) return;
  51.  
  52. const formData = new FormData();
  53. formData.append('file', fileInput.files[0]);
  54. console.log([...formData.entries()]);
  55.  
  56. fetch('http://101.36.73.164:29666/term_format', {
  57. method: 'POST',
  58. body: formData,
  59. timeout: 600000
  60. }).then(response => {
  61. if (!response.ok) {
  62. throw new Error('Network response was not ok ' + response.statusText);
  63. }
  64. return response.blob();
  65. })
  66. .then(blob => {
  67. const url = window.URL.createObjectURL(new Blob([blob]));
  68. const link = document.createElement('a');
  69. link.href = url;
  70. link.setAttribute('download', 'processed_file.xlsx');
  71. document.body.appendChild(link);
  72. link.click();
  73. link.parentNode.removeChild(link);
  74. })
  75. .catch(error => console.error('Error:', error));
  76. });
  77. </script>
  78. </body>
  79. </html>
  80.  
Advertisement
Add Comment
Please, Sign In to add comment