app_info.js 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. setInterval(function () {
  21. $.get('/agg_task_status', {examId: examId, caseId: caseId}, function (result) {
  22. if (result == 1) {
  23. agg_success();
  24. }
  25. });
  26. }, 10000)
  27. });
  28. });
  29. $('#deliver-btn').click(function () {
  30. if (confirm("是否确定全部交付?") == true) {
  31. $(this).attr('disabled', true);
  32. $(this).find('span').text('处理中...');
  33. $.get('/appendBugToFinalReport', {examId: examId, caseId: caseId}, function () {
  34. alert("处理完成");
  35. location.reload();
  36. });
  37. }
  38. });
  39. });
  40. function agg_success() {
  41. var rand = Math.round(Math.random() * 100);
  42. var count = $('#report-list tbody tr').length;
  43. $('#report-list tbody tr').each(function (i, el) {
  44. setTimeout(function () {
  45. rand = Math.round(Math.random() * 100);
  46. // 在此条记录最后添加loading的图标
  47. $(el).find('td:last').after('<td><i class=\'fa fa-spinner\'></i></td>');
  48. // get value
  49. var _id = $(el).children('td.report-id').attr('value');
  50. $.get('/aggregate_info', {bugId: _id}, function (data) {
  51. var aggregator = data.masterId;
  52. var printAggregator = 'ML-AG-' + data.masterId.substring(10);
  53. function fadeInAggreagator() {
  54. // $(el).children('td.report-aggregator').hide();
  55. if ($.trim(aggregator)) {//找到了重复报告
  56. $(el).children('td.report-aggregator').attr('value', aggregator);
  57. var aggregatorHtml = "<a href=/report?masterId=" + aggregator + "&examId=" + examId + "&caseId=" + caseId + ">" + printAggregator + "</a>";
  58. $(el).children('td.report-aggregator').html(aggregatorHtml).fadeIn(rand * 2);
  59. }
  60. }
  61. function fadeInStatus() {
  62. $(el).find('td:last').hide();
  63. // 如果data.assignee 不为None,则最后添加对勾图标,否则添加叉叉图标
  64. if ($.trim(aggregator)) {//找到了负责人
  65. $(el).find('td:last').html('<i class=\'fa fa-check-circle text-inverse\'></i>').fadeIn(rand * 2);
  66. $(el).find('td:last').addClass('row-success');
  67. } else {
  68. $(el).find('td:last').html('<i class=\'fa fa-history text-inverse\'></i>').fadeIn(rand * 2);
  69. $(el).find('td:last').addClass('row-danger');
  70. }
  71. }
  72. setTimeout(fadeInAggreagator, 0);
  73. setTimeout(fadeInStatus, rand);
  74. });
  75. }, rand * 3 * i);
  76. });
  77. //假设此time之后所有assign操作均已完成
  78. setTimeout(function () {
  79. location.reload();
  80. }, rand * 3 * (count + 1));
  81. };