app_info.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. $(function () {
  2. // collapse click, toggle itself
  3. var urlParams = new URLSearchParams(window.location.search);
  4. var examId = urlParams.get('examId');
  5. var caseId = urlParams.get('caseId');
  6. $('table#report-list .collapse').click(function () {
  7. $(this).collapse('toggle');
  8. });
  9. // load table
  10. var reportListTable = $('#report-list').DataTable({
  11. searching: false,
  12. pageLength: 25
  13. });
  14. // assign click
  15. $('#assign-btn').click(function () {
  16. // 修改assign-btn的文字以及让其处于不可用状态
  17. $(this).attr('disabled', true);
  18. $(this).find('span').text('融合中...');
  19. $.get('/aggregate', {examId: examId, caseId: caseId}, function () {
  20. debugger
  21. var rand = Math.round(Math.random() * 100);
  22. var count = $('#report-list tbody tr').length;
  23. $('#report-list tbody tr').each(function (i, el) {
  24. setTimeout(function () {
  25. rand = Math.round(Math.random() * 100);
  26. // 在此条记录最后添加loading的图标
  27. $(el).find('td:last').after('<td><i class=\'fa fa-spinner\'></i></td>');
  28. // get value
  29. var _id = $(el).children('td.report-id').attr('value');
  30. $.get('/aggregate_info', { bugId: _id }, function(data) {
  31. var aggregator = data.masterId;
  32. var printAggregator = 'ML-AG-' + data.masterId.substring(10);
  33. function fadeInAggreagator() {
  34. // $(el).children('td.report-aggregator').hide();
  35. if($.trim(aggregator)) {//找到了重复报告
  36. $(el).children('td.report-aggregator').attr('value', aggregator);
  37. var aggregatorHtml = "<a href=/report?masterId="+aggregator+"&examId="+examId+"&caseId="+caseId+">"+printAggregator+"</a>";
  38. $(el).children('td.report-aggregator').html(aggregatorHtml).fadeIn(rand * 2);
  39. }
  40. }
  41. function fadeInStatus() {
  42. $(el).find('td:last').hide();
  43. // 如果data.assignee 不为None,则最后添加对勾图标,否则添加叉叉图标
  44. if($.trim(aggregator)) {//找到了负责人
  45. $(el).find('td:last').html('<i class=\'fa fa-check-circle text-inverse\'></i>').fadeIn(rand * 2);
  46. $(el).find('td:last').addClass('row-success');
  47. } else {
  48. $(el).find('td:last').html('<i class=\'fa fa-history text-inverse\'></i>').fadeIn(rand * 2);
  49. $(el).find('td:last').addClass('row-danger');
  50. }
  51. }
  52. setTimeout(fadeInAggreagator, 0);
  53. setTimeout(fadeInStatus, rand);
  54. });
  55. }, rand * 3 *i);
  56. });
  57. //假设此time之后所有assign操作均已完成
  58. setTimeout(function () {
  59. location.reload();
  60. }, rand * 3 * (count+1));
  61. });
  62. });
  63. });