advance_audit.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author lanjianrong
  6. * @date 2020/8/7
  7. * @version
  8. */
  9. $(document).ready(function () {
  10. // 获取审核相关url
  11. function getUrlPre () {
  12. const path = window.location.pathname.split('/');
  13. return _.take(path, 3).join('/');
  14. }
  15. // 审批人分组选择
  16. $('#account_group').change(function () {
  17. let account_html = '<option value="0">选择审批人</option>'
  18. for (const account of accountList) {
  19. if ((parseInt($(this).val()) === 0 || parseInt($(this).val()) === account.account_group) && account.id !== parseInt(userID)) {
  20. const role = account.role !== '' ? '(' + account.role + ')' : ''
  21. const company = account.company !== '' ? ' -' + account.company : ''
  22. account_html += '<option value="' + account.id + '">' + account.name + role + company + '</option>'
  23. }
  24. }
  25. $('#account_list').html(account_html)
  26. });
  27. // 添加到审批流程中
  28. $('body').on('change', '#account_list', function () {
  29. let id = $(this).val()
  30. id = parseInt(id)
  31. if (id !== 0) {
  32. postData(getUrlPre() + '/audit/add', { auditorId: id }, (data) => {
  33. const html = []
  34. html.push('<li class="list-group-item" auditorId="'+ data.aid +'"><a href="javascript: void(0)" class="text-danger pull-right">移除</a>')
  35. html.push('<span>')
  36. html.push(data.order + ' ')
  37. html.push(data.name + ' ')
  38. html.push('</span>')
  39. html.push('<small class="text-muted">')
  40. html.push(data.role)
  41. html.push('</small></li>')
  42. $('#auditors').append(html.join(''))
  43. // 如果是重新上报,添加到重新上报列表中
  44. const auditorshtml = []
  45. // 重新上报时。令其它的审批人流程图标转换
  46. $('#auditors-list li i').removeClass('fa-stop-circle').addClass('fa-chevron-circle-down')
  47. for (let i = 0; i < $('#auditors-list li').length; i++) {
  48. $('#auditors-list li').eq(i).find('.pull-right').text(transFormToChinese(i+1) + '审')
  49. $('#auditors-list2 li').eq(i).find('.pull-right').text(transFormToChinese(i+1) + '审')
  50. }
  51. // 添加新审批人
  52. auditorshtml.push('<li class="list-group-item" data-auditid="' + data.aid + '">')
  53. auditorshtml.push('<i class="fa fa-stop-circle"></i> ')
  54. auditorshtml.push(data.name + ' <small class="text-muted">' + data.role + '</small>')
  55. auditorshtml.push('<span class="pull-right">终审</span>')
  56. auditorshtml.push('</li>')
  57. $('#auditors-list').append(auditorshtml.join(''))
  58. const auditorshtml2 = [];
  59. // 重新上报时。令其它的审批人流程图标转换
  60. $('#auditors-list2 li i').removeClass('fa-stop-circle').addClass('fa-chevron-circle-down')
  61. // 添加新审批人
  62. auditorshtml2.push('<li class="list-group-item" data-auditid="' + data.aid + '">')
  63. auditorshtml2.push('<h5 class="card-title"><i class="fa fa-stop-circle"></i> ')
  64. auditorshtml2.push(data.name + ' <small class="text-muted">' + data.role + '</small>')
  65. auditorshtml2.push('<span class="pull-right">终审</span>')
  66. auditorshtml2.push('</h5></li>');
  67. $('#auditors-list2').append(auditorshtml2.join(''))
  68. });
  69. }
  70. });
  71. // 删除审批人
  72. $('body').on('click', '#auditors li>a', function () {
  73. const li = $(this).parent()
  74. const data = {
  75. auditorId: parseInt(li.attr('auditorId')),
  76. };
  77. postData(getUrlPre() + '/audit/delete', data, (result) => {
  78. li.remove();
  79. for (const rst of result) {
  80. const aLi = $('li[auditorId=' + rst.aid + ']');
  81. $('span', aLi).text(rst.order + ' ' + rst.name + ' ')
  82. }
  83. // 如果是重新上报
  84. // 令最后一个图标转换
  85. $('#auditors-list li[data-auditid="' + data.auditorId + '"]').remove()
  86. if ($('#auditors-list li').length !== 0 && !$('#auditors-list li i').hasClass('fa-stop-circle')) {
  87. $('#auditors-list li').eq($('#auditors-list li').length-1).children('i')
  88. .removeClass('fa-chevron-circle-down').addClass('fa-stop-circle')
  89. }
  90. $('#auditors-list2 li[data-auditid="' + data.auditorId + '"]').remove();
  91. if ($('#auditors-list2 li').length !== 0 && !$('#auditors-list2 li i').hasClass('fa-stop-circle')) {
  92. $('#auditors-list2 li').eq($('#auditors-list2 li').length-1).children('i')
  93. .removeClass('fa-chevron-circle-down').addClass('fa-stop-circle')
  94. }
  95. for (let i = 0; i < $('#auditors-list li').length; i++) {
  96. $('#auditors-list li').eq(i).find('.pull-right').text((i+1 === $('#auditors-list li').length ? '终' : transFormToChinese(i+1)) + '审')
  97. $('#auditors-list2 li').eq(i).find('.pull-right').text((i+1 === $('#auditors-list2 li').length ? '终' : transFormToChinese(i+1)) + '审')
  98. }
  99. })
  100. })
  101. })