|
@@ -8,7 +8,7 @@
|
|
|
<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 class="progress-bar" id="check-progress" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">0%</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
@@ -37,9 +37,9 @@
|
|
|
*
|
|
|
* @param setting
|
|
|
* {
|
|
|
- * loadUrl,
|
|
|
- * loadData,
|
|
|
- * checkFun,
|
|
|
+ * checkUrl,
|
|
|
+ * checkData,
|
|
|
+ * reloadDifferSource,
|
|
|
* errorList
|
|
|
* }
|
|
|
*/
|
|
@@ -49,82 +49,59 @@
|
|
|
$('#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 + '%');
|
|
|
+ $('#check-progress').attr('aria-valuenow', percent).width(percent + '%').html(percent + '%');
|
|
|
}
|
|
|
- const fakeProgresTo = function (percent) {
|
|
|
- const processObj = $('.progress-bar');
|
|
|
+ const fakeProgress = function () {
|
|
|
+ const processObj = $('#check-progress');
|
|
|
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
|
|
|
+ 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) {
|
|
|
- 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) + '%');
|
|
|
+ progress(pos + 1);
|
|
|
}
|
|
|
- } else if (pos < 50) { // 20
|
|
|
+ } else if (pos < 100) { // 20
|
|
|
count += 1;
|
|
|
if (count % 40 === 0) {
|
|
|
- processObj.attr('aria-valuenow', pos + 1);
|
|
|
- processObj.width((pos + 1) + '%');
|
|
|
+ progress(pos + 1);
|
|
|
}
|
|
|
}
|
|
|
}, 100);
|
|
|
}
|
|
|
- const stopFakeProgress = function (percent) {
|
|
|
+ const stopFakeProgess = function (fun) {
|
|
|
+ progress(100);
|
|
|
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);
|
|
|
+ fakeProgress();
|
|
|
+ postData(setting.checkUrl, setting.checkData ? setting.checkData : {}, function (result) {
|
|
|
+ if (result.error && result.error.length > 0) {
|
|
|
+ setting.completeData(result);
|
|
|
+ setting.errorList.loadErrorData(result.error);
|
|
|
+ stopFakeProgess();
|
|
|
+ setTimeout(function () {
|
|
|
+ $('#check-error-hint').modal('show');
|
|
|
+ }, 300);
|
|
|
} else {
|
|
|
- setting.errorList.clearErrorData();
|
|
|
- postDataWithFile(postUrl, postForm, function () {
|
|
|
- window.location.reload();
|
|
|
- });
|
|
|
+ stopFakeProgess();
|
|
|
+ setTimeout(function () {
|
|
|
+ setting.errorList.clearErrorData();
|
|
|
+ postDataWithFile(postUrl, postForm, function () {
|
|
|
+ window.location.reload();
|
|
|
+ });
|
|
|
+ }, 300);
|
|
|
}
|
|
|
- }, 1000);
|
|
|
+ }, function () {
|
|
|
+ $('#check').modal('hide');
|
|
|
+ stopFakeProgess();
|
|
|
+ });
|
|
|
}
|
|
|
return {checkAndPost};
|
|
|
}
|