$(function () { // collapse click, toggle itself var urlParams = new URLSearchParams(window.location.search); var examId = urlParams.get('examId'); var caseId = urlParams.get('caseId'); $('table#report-list .collapse').click(function () { $(this).collapse('toggle'); }); // load table var reportListTable = $('#report-list').DataTable({ searching: false, pageLength: 25 }); // assign click $('#assign-btn').click(function () { // 修改assign-btn的文字以及让其处于不可用状态 $(this).attr('disabled', true); $(this).find('span').text('融合中...'); $.get('/aggregate', {examId: examId, caseId: caseId}, function () { debugger var rand = Math.round(Math.random() * 100); var count = $('#report-list tbody tr').length; $('#report-list tbody tr').each(function (i, el) { setTimeout(function () { rand = Math.round(Math.random() * 100); // 在此条记录最后添加loading的图标 $(el).find('td:last').after(''); // get value var _id = $(el).children('td.report-id').attr('value'); $.get('/aggregate_info', { bugId: _id }, function(data) { var aggregator = data.masterId; var printAggregator = 'ML-AG-' + data.masterId.substring(10); function fadeInAggreagator() { // $(el).children('td.report-aggregator').hide(); if($.trim(aggregator)) {//找到了重复报告 $(el).children('td.report-aggregator').attr('value', aggregator); var aggregatorHtml = ""+printAggregator+""; $(el).children('td.report-aggregator').html(aggregatorHtml).fadeIn(rand * 2); } } function fadeInStatus() { $(el).find('td:last').hide(); // 如果data.assignee 不为None,则最后添加对勾图标,否则添加叉叉图标 if($.trim(aggregator)) {//找到了负责人 $(el).find('td:last').html('').fadeIn(rand * 2); $(el).find('td:last').addClass('row-success'); } else { $(el).find('td:last').html('').fadeIn(rand * 2); $(el).find('td:last').addClass('row-danger'); } } setTimeout(fadeInAggreagator, 0); setTimeout(fadeInStatus, rand); }); }, rand * 3 *i); }); //假设此time之后所有assign操作均已完成 setTimeout(function () { location.reload(); }, rand * 3 * (count+1)); }); }); });