shoufangupload.ejs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
  6. <meta http-equiv="x-ua-compatible" content="ie=edge">
  7. <title>收方单附件上传-计量支付</title>
  8. <link rel="stylesheet" href="/public/css/bootstrap/bootstrap.min.css">
  9. <link rel="stylesheet" href="/public/css/wap/main.css">
  10. <link rel="stylesheet" href="/public/css/toast.css">
  11. <link rel="stylesheet" href="/public/css/font-awesome/font-awesome.min.css">
  12. <link rel="stylesheet" href="/public/css/toastr.css">
  13. <link rel="shortcut icon" href="/public/images/favicon.ico">
  14. </head>
  15. <body>
  16. <div class="container">
  17. <!--顶部-->
  18. <nav class="fixed-top bg-dark">
  19. <div class="my-2 d-flex justify-content-between">
  20. <span class="text-white ml-3">收方单附件上传</span>
  21. <div class="mr-3">
  22. </div>
  23. </div>
  24. </nav>
  25. <!--标段列表-->
  26. <div class="py-5">
  27. <table class="table table-bordered">
  28. <tbody>
  29. <tr>
  30. <th>标段</th>
  31. <td><%- tender.name %></td>
  32. </tr>
  33. <tr>
  34. <th>计量期</th>
  35. <td>第 <%- order %> 期</td>
  36. </tr>
  37. <tr>
  38. <th>清单/计量单元</th>
  39. <td><%- name %></td>
  40. </tr>
  41. </tbody>
  42. </table>
  43. <table class="table table-bordered">
  44. <tr><th colspan="2" class="text-center">本次已上传文件</th></tr>
  45. <tbody id="file-list">
  46. </tbody>
  47. <!--<tr><td><a href="">202108098762.png</a></td><td><a href="" class="text-danger">删除</a></td></tr>-->
  48. </table>
  49. </div>
  50. <!--底栏菜单-->
  51. <nav class="fixed-bottom navbar-dark bg-light border-top">
  52. <ul class="nav nav-fill my-2">
  53. <li class="nav-item">
  54. <a class="nav-link" href="JavaScript:void(0);"><i class="fa fa-camera"></i> 拍照</a>
  55. <input id="uploadPhoto" type="file" accept="image/*" capture="camera" style="display: none">
  56. </li>
  57. <li class="nav-item">
  58. <a class="nav-link" href="JavaScript:void(0);"><i class="fa fa-upload"></i> 上传文件</a>
  59. <input id="uploadFile" multiple type="file" style="display: none">
  60. </li>
  61. </ul>
  62. </nav>
  63. </div>
  64. <!-- JS. -->
  65. <script src="/public/js/jquery/jquery-3.2.1.min.js"></script>
  66. <script src="/public/js/popper/popper.min.js"></script>
  67. <script src="/public/js/bootstrap/bootstrap.min.js"></script>
  68. <script src="/public/js/cookies.js"></script>
  69. <script src="/public/js/toastr.min.js"></script>
  70. <script src="/public/js/wap/global.js"></script>
  71. <script type="text/javascript">
  72. toastr.options = {
  73. "closeButton": false,
  74. "debug": false,
  75. "newestOnTop": false,
  76. "progressBar": false,
  77. "positionClass": "toast-top-center",
  78. "preventDuplicates": false,
  79. "onclick": null,
  80. "showDuration": "300",
  81. "hideDuration": "1000",
  82. "timeOut": "3000",
  83. "extendedTimeOut": "1000",
  84. "showEasing": "swing",
  85. "hideEasing": "linear",
  86. "showMethod": "fadeIn",
  87. "hideMethod": "fadeOut"
  88. };
  89. </script>
  90. <script>
  91. const whiteList = JSON.parse('<%- JSON.stringify(whiteList) %>');
  92. $(function () {
  93. $('.nav-link').on('click', function () {
  94. $(this).siblings('input').click();
  95. });
  96. $('#uploadPhoto').change(function () {
  97. const files = this.files;
  98. const formData = new FormData();
  99. formData.append('sfid', <%- sfid %>);
  100. for (const file of files) {
  101. if (file === undefined) {
  102. toastr.error('未选择上传文件!');
  103. return false;
  104. }
  105. const filesize = file.size;
  106. if (filesize > 30 * 1024 * 1024) {
  107. toastr.error('存在上传文件大小过大!');
  108. return false;
  109. }
  110. const ext = file.name.toLowerCase().split('.').splice(-1)[0];
  111. const imgStr = /(jpg|jpeg|png|bmp|BMP|JPG|PNG|JPEG)$/;
  112. if (!imgStr.test(ext)) {
  113. toastr.error('请上传正确的图片格式文件');
  114. return
  115. }
  116. formData.append('size', filesize);
  117. formData.append('file[]', file);
  118. }
  119. upload(formData);
  120. $('#uploadPhoto').val('');
  121. });
  122. $('#uploadFile').change(function () {
  123. const files = this.files;
  124. const formData = new FormData();
  125. formData.append('sfid', <%- sfid %>);
  126. for (const file of files) {
  127. if (file === undefined) {
  128. toastr.error('未选择上传文件!');
  129. return false;
  130. }
  131. const filesize = file.size;
  132. if (filesize > 30 * 1024 * 1024) {
  133. toastr.error('存在上传文件大小过大!');
  134. return false;
  135. }
  136. const fileext = '.' + file.name.toLowerCase().split('.').splice(-1)[0];
  137. if (whiteList.indexOf(fileext) === -1) {
  138. toastr.error('只能上传指定格式的附件!');
  139. return false;
  140. }
  141. formData.append('size', filesize);
  142. formData.append('file[]', file);
  143. }
  144. upload(formData);
  145. $('#uploadFile').val('');
  146. });
  147. $('body').on('click', '.del-att', function () {
  148. const id = $(this).data('id');
  149. const _self = $(this);
  150. const data = { id };
  151. postData('/wap/shoufang/delfile', data, function (result) {
  152. _self.parents('tr').remove();
  153. });
  154. })
  155. function upload(formData) {
  156. if (formData.length < 1) {
  157. return;
  158. }
  159. postDataWithFile('/wap/shoufang/upfile', formData, function (result) {
  160. let html = '';
  161. for (const att of result) {
  162. html += `<tr><td><a href="${att.filepath}" target="_blank">${att.filename}${att.fileext}</a></td><td><a href="javascript:void(0);" data-id="${att.id}" class="del-att text-danger">删除</a></td></tr>`;
  163. }
  164. $('#file-list').append(html);
  165. });
  166. }
  167. })
  168. </script>
  169. </body>
  170. </html>