123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <!--上报审批 自检-->
- <div class="modal fade" id="check" data-backdrop="static">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title">上报审批</h5>
- </div>
- <div class="modal-body">
- <h5>数据计算中,完成后会自动进入审批流程设置。</h5>
- <div class="progress">
- <div class="progress-bar" id="check-progress" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">0%</div>
- </div>
- </div>
- </div>
- </div>
- </div>
- <!--上报审批 自检 计算错误-->
- <div class="modal fade" id="check-error-hint" data-backdrop="static">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <h5 class="modal-title">上报审批</h5>
- </div>
- <div class="modal-body">
- <div class="alert alert-danger" role="alert">
- 部分清单存在问题,请前往错误列表进行查看,并进行修改。
- </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-sm btn-primary" data-dismiss="modal" id="show-error-list">查看错误列表</button>
- </div>
- </div>
- </div>
- </div>
- <script>
- /**
- *
- * @param setting
- * {
- * checkUrl,
- * checkData,
- * reloadDifferSource,
- * errorList
- * }
- */
- const DataChecker = function (setting) {
- let progressInterval;
- $('#show-error-list').click(function () {
- <% if (!ctx.stage || ctx.url === '/tender/' + ctx.tender.id + '/measure/stage/' + ctx.stage.order) { %>
- $('#check').modal('hide');
- setting.errorList.show();
- <% } else { %>
- setting.errorList.autoShowHistory(true);
- window.location.pathname = '/tender/<%- ctx.tender.id %>/measure/stage/<%- ctx.stage.order %>';
- <% } %>
- });
- const progress = function (percent) {
- $('#check-progress').attr('aria-valuenow', percent).width(percent + '%').html(percent + '%');
- }
- const fakeProgress = function () {
- const processObj = $('#check-progress');
- let count = 0;
- progressInterval = setInterval(function () {
- const pos = parseInt(processObj.attr('aria-valuenow'));
- if (pos < 10) { // 1
- progress(pos + 2);
- } else if (pos < 20) { // 2
- progress(pos + 1);
- } else if (pos < 90) { // 4
- count += 1;
- if (count % 2 === 0) {
- progress(pos + 1);
- }
- } else if (pos < 100) { // 20
- count += 1;
- if (count % 40 === 0) {
- progress(pos + 1);
- }
- }
- }, 100);
- }
- const stopFakeProgess = function (fun) {
- progress(100);
- clearInterval(progressInterval);
- }
- const checkAndPost = async function (url, data) {
- progress(0);
- $('#check').modal('show');
- fakeProgress();
- postData(setting.checkUrl, setting.checkData ? setting.checkData : {}, function (result) {
- if (result.error && result.error.length > 0) {
- if (setting.completeData) setting.completeData(result);
- setting.errorList.loadErrorData(result.error);
- stopFakeProgess();
- setTimeout(function () {
- $('#check-error-hint').modal('show');
- }, 300);
- } else {
- stopFakeProgess();
- setTimeout(function () {
- setting.errorList.clearErrorData();
- postData(url, data, function () {
- window.location.reload();
- }, function () {
- window.location.reload();
- });
- }, 300);
- }
- }, function () {
- $('#check').modal('hide');
- stopFakeProgess();
- });
- }
- return {checkAndPost};
- }
- </script>
|