check_data_modal.ejs 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. $('#check').modal('hide');
  50. setting.errorList.show();
  51. });
  52. const progress = function (percent) {
  53. $('#check-progress').attr('aria-valuenow', percent).width(percent + '%').html(percent + '%');
  54. }
  55. const fakeProgress = function () {
  56. const processObj = $('#check-progress');
  57. let count = 0;
  58. progressInterval = setInterval(function () {
  59. const pos = parseInt(processObj.attr('aria-valuenow'));
  60. if (pos < 10) { // 1
  61. progress(pos + 2);
  62. } else if (pos < 20) { // 2
  63. progress(pos + 1);
  64. } else if (pos < 90) { // 4
  65. count += 1;
  66. if (count % 2 === 0) {
  67. progress(pos + 1);
  68. }
  69. } else if (pos < 100) { // 20
  70. count += 1;
  71. if (count % 40 === 0) {
  72. progress(pos + 1);
  73. }
  74. }
  75. }, 100);
  76. }
  77. const stopFakeProgess = function (fun) {
  78. progress(100);
  79. clearInterval(progressInterval);
  80. }
  81. const checkAndPost = async function (url, data) {
  82. $('#check').modal('show');
  83. fakeProgress();
  84. postData(setting.checkUrl, setting.checkData ? setting.checkData : {}, function (result) {
  85. if (result.error && result.error.length > 0) {
  86. setting.completeData(result);
  87. setting.errorList.loadErrorData(result.error);
  88. stopFakeProgess();
  89. setTimeout(function () {
  90. $('#check-error-hint').modal('show');
  91. }, 300);
  92. } else {
  93. stopFakeProgess();
  94. setTimeout(function () {
  95. setting.errorList.clearErrorData();
  96. postData(url, data, function () {
  97. window.location.reload();
  98. });
  99. }, 300);
  100. }
  101. }, function () {
  102. $('#check').modal('hide');
  103. stopFakeProgess();
  104. });
  105. }
  106. return {checkAndPost};
  107. }
  108. </script>