check_data_modal.ejs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <!--上报审批 自检-->
  2. <div class="modal fade" id="check" data-backdrop="static">
  3. <div class="modal-dialog" role="document">
  4. <div class="modal-content">
  5. <div class="modal-header">
  6. <h5 class="modal-title">上报审批</h5>
  7. </div>
  8. <div class="modal-body">
  9. <h5>数据计算中,完成后会自动进入审批流程设置。</h5>
  10. <div class="progress">
  11. <div class="progress-bar" id="check-progress" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">0%</div>
  12. </div>
  13. </div>
  14. </div>
  15. </div>
  16. </div>
  17. <!--上报审批 自检 计算错误-->
  18. <div class="modal fade" id="check-error-hint" data-backdrop="static">
  19. <div class="modal-dialog" role="document">
  20. <div class="modal-content">
  21. <div class="modal-header">
  22. <h5 class="modal-title">上报审批</h5>
  23. </div>
  24. <div class="modal-body">
  25. <div class="alert alert-danger" role="alert">
  26. 部分清单存在问题,请前往错误列表进行查看,并进行修改。
  27. </div>
  28. </div>
  29. <div class="modal-footer">
  30. <button type="button" class="btn btn-sm btn-primary" data-dismiss="modal" id="show-error-list">查看错误列表</button>
  31. </div>
  32. </div>
  33. </div>
  34. </div>
  35. <script>
  36. /**
  37. *
  38. * @param setting
  39. * {
  40. * checkUrl,
  41. * checkData,
  42. * reloadDifferSource,
  43. * errorList
  44. * }
  45. */
  46. const DataChecker = function (setting) {
  47. let progressInterval;
  48. $('#show-error-list').click(function () {
  49. <% if (!ctx.stage || ctx.url === '/tender/' + ctx.tender.id + '/measure/stage/' + ctx.stage.order) { %>
  50. $('#check').modal('hide');
  51. setting.errorList.show();
  52. <% } else { %>
  53. setting.errorList.autoShowHistory(true);
  54. window.location.pathname = '/tender/<%- ctx.tender.id %>/measure/stage/<%- ctx.stage.order %>';
  55. <% } %>
  56. });
  57. const progress = function (percent) {
  58. $('#check-progress').attr('aria-valuenow', percent).width(percent + '%').html(percent + '%');
  59. }
  60. const fakeProgress = function () {
  61. const processObj = $('#check-progress');
  62. let count = 0;
  63. progressInterval = setInterval(function () {
  64. const pos = parseInt(processObj.attr('aria-valuenow'));
  65. if (pos < 10) { // 1
  66. progress(pos + 2);
  67. } else if (pos < 20) { // 2
  68. progress(pos + 1);
  69. } else if (pos < 90) { // 4
  70. count += 1;
  71. if (count % 2 === 0) {
  72. progress(pos + 1);
  73. }
  74. } else if (pos < 100) { // 20
  75. count += 1;
  76. if (count % 40 === 0) {
  77. progress(pos + 1);
  78. }
  79. }
  80. }, 100);
  81. }
  82. const stopFakeProgess = function (fun) {
  83. progress(100);
  84. clearInterval(progressInterval);
  85. }
  86. const checkAndPost = async function (url, data) {
  87. progress(0);
  88. $('#check').modal('show');
  89. fakeProgress();
  90. postData(setting.checkUrl, setting.checkData ? setting.checkData : {}, function (result) {
  91. if (result.error && result.error.length > 0) {
  92. if (setting.completeData) setting.completeData(result);
  93. setting.errorList.loadErrorData(result.error);
  94. stopFakeProgess();
  95. setTimeout(function () {
  96. $('#check-error-hint').modal('show');
  97. }, 300);
  98. } else {
  99. stopFakeProgess();
  100. setTimeout(function () {
  101. setting.errorList.clearErrorData();
  102. postData(url, data, function () {
  103. window.location.reload();
  104. }, function () {
  105. window.location.reload();
  106. });
  107. }, 300);
  108. }
  109. }, function () {
  110. $('#check').modal('hide');
  111. stopFakeProgess();
  112. });
  113. }
  114. return {checkAndPost};
  115. }
  116. </script>