phase_pay_audit.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. 'use strict';
  2. $(document).ready(() => {
  3. const auditFlow = {
  4. getAuditTypeText: function (type) {
  5. if (type === auditType.key.common) return '';
  6. return `<span class="text-${auditType.info[type].class}">${auditType.info[type].long}</span>`;
  7. },
  8. getSimpleAuditFlow: function(groups) {
  9. const html = [];
  10. for (const group of groups) {
  11. html.push(`<li class="list-group-item" data-auditorid="${group[0].audit_id}">`);
  12. html.push(`<i class="fa ${(group[0].is_final ? 'fa-stop-circle' : 'fa-chevron-circle-down')}"></i>`);
  13. html.push(`${group[0].name} <small class="text-muted">${group[0].role}</small>`);
  14. html.push('<span class="pull-right">${group[0].flow_name}</span>');
  15. html.push('</li>');
  16. }
  17. return html.join('');
  18. },
  19. getStartAuditFlow: function(groups) {
  20. const html = [];
  21. for (const group of groups) {
  22. if (group[0].audit_order === 0) continue;
  23. html.push('<li class="list-group-item d-flex" auditorId="'+ group[0].audit_id +'">');
  24. html.push(`<div class="col-auto">${group[0].audit_order}</div>`);
  25. html.push('<div class="col">');
  26. for (const auditor of group) {
  27. html.push(`<div class="d-inline-block mx-1"><i class="fa fa-user text-muted"></i> ${auditor.name} <small class="text-muted">${auditor.role}</small></div>`);
  28. }
  29. html.push('</div>');
  30. html.push('<div class="col-auto">');
  31. if (group[0].audit_type !== auditType.key.common) {
  32. html.push(`<span class="badge badge-pill badge-${auditType.info[group[0].audit_type].class} badge-bg-small"><small>${auditType.info[group[0].audit_type].long}</small></span>`);
  33. }
  34. if (shenpi_status === shenpiConst.sp_status.sqspr || (shenpi_status === shenpiConst.sp_status.gdzs && index+1 !== datas.length)) {
  35. html.push('<a href="javascript: void(0)" class="text-danger pull-right ml-1">移除</a>');
  36. }
  37. html.push('</div>');
  38. html.push('</li>');
  39. }
  40. return html.join('');
  41. },
  42. saveAudit: function(data, callback) {
  43. postData('audit/save', data, (result) => {
  44. callback(result);
  45. });
  46. }
  47. };
  48. // 搜索
  49. let timer = null;
  50. let oldSearchVal = null;
  51. $('#gr-search').bind('input propertychange', function(e) {
  52. oldSearchVal = e.target.value;
  53. timer && clearTimeout(timer);
  54. timer = setTimeout(() => {
  55. const newVal = $('#gr-search').val();
  56. let html = '';
  57. if (newVal && newVal === oldSearchVal) {
  58. accountList.filter(item => item && userID !== item.id && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
  59. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  60. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  61. class="ml-auto">${item.mobile || ''}</span></p>
  62. <span class="text-muted">${item.role || ''}</span>
  63. </dd>`
  64. });
  65. $('.book-list').empty();
  66. $('.book-list').append(html);
  67. } else {
  68. if (!$('.acc-btn').length) {
  69. accountGroup.forEach((group, idx) => {
  70. if (!group) return;
  71. html += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>
  72. </a> ${group.groupName}</dt>
  73. <div class="dd-content" data-toggleid="${idx}">`;
  74. group.groupList.forEach(item => {
  75. if (item.id !== userID) {
  76. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  77. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  78. class="ml-auto">${item.mobile || ''}</span></p>
  79. <span class="text-muted">${item.role || ''}</span>
  80. </dd>`
  81. }
  82. });
  83. html += '</div>';
  84. });
  85. $('.book-list').empty();
  86. $('.book-list').append(html);
  87. }
  88. }
  89. }, 400);
  90. });
  91. // 展开收起角色/公司
  92. $('body').on('click', '.book-list dt', function () {
  93. const idx = $(this).find('.acc-btn').attr('data-groupid');
  94. const type = $(this).find('.acc-btn').attr('data-type');
  95. if (type === 'hide') {
  96. $(this).parent().find(`div[data-toggleid="${idx}"]`).show(() => {
  97. $(this).children().find('i').removeClass('fa-plus-square').addClass('fa-minus-square-o');
  98. $(this).find('.acc-btn').attr('data-type', 'show');
  99. });
  100. } else {
  101. $(this).parent().find(`div[data-toggleid="${idx}"]`).hide(() => {
  102. $(this).children().find('i').removeClass('fa-minus-square-o').addClass('fa-plus-square');
  103. $(this).find('.acc-btn').attr('data-type', 'hide');
  104. });
  105. }
  106. return false;
  107. });
  108. // 添加审批人
  109. $('#book-list').on('click', 'dd', function () {
  110. const id = parseInt($(this).data('id'));
  111. if (!id) return;
  112. auditFlow.saveAudit({ operate: 'add', audit_id: id }, (result) => {
  113. $('#auditors').html(auditFlow.getStartAuditFlow(result));
  114. $('#auditors-list').html(auditFlow.getSimpleAuditFlow(result));
  115. });
  116. });
  117. // 移除审批人
  118. $('body').on('click', '#auditors li a', function () {
  119. const li = $(this).parents('li');
  120. const data = {
  121. operate: 'del',
  122. audit_id: parseInt(li.attr('auditorId')),
  123. };
  124. auditFlow.saveAudit(data, (result) => {
  125. $('#auditors').html(auditFlow.getStartAuditFlow(result));
  126. });
  127. });
  128. $('body').on('click', '.remove-audit', function () {
  129. const id = parseInt($(this).attr('data-id'));
  130. postData('audit/save', { operate: 'del', audit_id: id }, (datas) => {
  131. $('#admin-edit-shenpi-list').html(auditFlow.getStartAuditFlow(datas));
  132. auditFlow.getStartAuditFlow(datas);
  133. });
  134. });
  135. });