123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <!--上报审批 自检-->
- <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" 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
- * {
- * loadUrl,
- * loadData,
- * checkFun,
- * errorList
- * }
- */
- const DataChecker = function (setting) {
- let progressInterval;
- $('#show-error-list').click(function () {
- $('#check').modal('hide');
- setting.errorList.show();
- });
- const loadCheckData = function () {
- const promise = new Promise(function (resolve, reject) {
- postData(setting.loadUrl, setting.loadData, function (result) {
- resolve(result);
- });
- });
- return promise;
- }
- const progress = function (percent) {
- $('.progress-bar').attr('aria-valuenow', percent).width(percent + '%').html(percent + '%');
- }
- const fakeProgresTo = function (percent) {
- const processObj = $('.progress-bar');
- let count = 0;
- progressInterval = setInterval(function () {
- const pos = parseInt(processObj.attr('aria-valuenow'));
- if (pos < 10) { // 1
- processObj.attr('aria-valuenow', pos + 2);
- processObj.width((pos + 2) + '%');
- } else if (pos < 20) { // 2
- processObj.attr('aria-valuenow', pos + 1);
- processObj.width((pos + 1) + '%');
- } else if (pos < 30) { // 4
- count += 1;
- if (count % 2 === 0) {
- processObj.attr('aria-valuenow', pos + 1);
- processObj.width((pos + 1) + '%');
- }
- } else if (pos < 40) { // 10
- count += 1;
- if (count % 5 === 0) {
- processObj.attr('aria-valuenow', pos + 1);
- processObj.width((pos + 1) + '%');
- }
- } else if (pos < 45) { // 15
- count += 1;
- if (count % 15 === 0) {
- processObj.attr('aria-valuenow', pos + 1);
- processObj.width((pos + 1) + '%');
- }
- } else if (pos < 50) { // 20
- count += 1;
- if (count % 40 === 0) {
- processObj.attr('aria-valuenow', pos + 1);
- processObj.width((pos + 1) + '%');
- }
- }
- }, 100);
- }
- const stopFakeProgress = function (percent) {
- clearInterval(progressInterval);
- progress(percent);
- }
- const addProgress = function (percent) {
- const oldPercent = parseInt($('.progress-bar').attr('aria-valuenow'));
- progress(oldPercent + parseInt(percent/2));
- }
- const checkAndPost = async function (postUrl, postForm) {
- progress(0);
- $('#check').modal('show');
- fakeProgresTo(50);
- const lastestData = await loadCheckData();
- stopFakeProgress(50);
- const result = setting.checkFun(lastestData, addProgress);
- progress(100);
- setTimeout(function () {
- if (result && result.length > 0) {
- $('#check-error-hint').modal('show');
- setting.errorList.loadErrorData(result);
- } else {
- setting.errorList.clearErrorData();
- postDataWithFile(postUrl, postForm, function () {
- window.location.reload();
- });
- }
- }, 1000);
- }
- return {checkAndPost};
- }
- </script>
|