change_project_audit.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date 2019/2/27
  7. * @version
  8. */
  9. $(document).ready(function () {
  10. let timer = null
  11. let oldSearchVal = null
  12. $('#gr-search').bind('input propertychange', function(e) {
  13. oldSearchVal = e.target.value
  14. timer && clearTimeout(timer)
  15. timer = setTimeout(() => {
  16. const newVal = $('#gr-search').val()
  17. let html = ''
  18. if (newVal && newVal === oldSearchVal) {
  19. accountList.filter(item => item && cur_uid !== item.id && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
  20. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  21. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  22. class="ml-auto">${item.mobile || ''}</span></p>
  23. <span class="text-muted">${item.role || ''}</span>
  24. </dd>`
  25. })
  26. $('.book-list').empty()
  27. $('.book-list').append(html)
  28. } else {
  29. if (!$('.acc-btn').length) {
  30. accountGroup.forEach((group, idx) => {
  31. if (!group) return
  32. html += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>
  33. </a> ${group.groupName}</dt>
  34. <div class="dd-content" data-toggleid="${idx}">`
  35. group.groupList.forEach(item => {
  36. if (item.id !== cur_uid) {
  37. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  38. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  39. class="ml-auto">${item.mobile || ''}</span></p>
  40. <span class="text-muted">${item.role || ''}</span>
  41. </dd>`
  42. }
  43. });
  44. html += '</div>'
  45. })
  46. $('.book-list').empty()
  47. $('.book-list').append(html)
  48. }
  49. }
  50. }, 400);
  51. })
  52. // 添加审批流程按钮逻辑
  53. $('.book-list').on('click', 'dt', function () {
  54. const idx = $(this).find('.acc-btn').attr('data-groupid')
  55. const type = $(this).find('.acc-btn').attr('data-type')
  56. if (type === 'hide') {
  57. $(this).parent().find(`div[data-toggleid="${idx}"]`).show(() => {
  58. $(this).children().find('i').removeClass('fa-plus-square').addClass('fa-minus-square-o')
  59. $(this).find('.acc-btn').attr('data-type', 'show')
  60. })
  61. } else {
  62. $(this).parent().find(`div[data-toggleid="${idx}"]`).hide(() => {
  63. $(this).children().find('i').removeClass('fa-minus-square-o').addClass('fa-plus-square')
  64. $(this).find('.acc-btn').attr('data-type', 'hide')
  65. })
  66. }
  67. return false
  68. })
  69. // 添加到审批流程中
  70. $('dl').on('click', 'dd', function () {
  71. const id = parseInt($(this).data('id'));
  72. if (id) {
  73. postData(preUrl + '/audit/add', { auditorId: id }, (datas) => {
  74. const html = [];
  75. // 如果是重新上报,添加到重新上报列表中
  76. const auditorshtml = [];
  77. for (const [index,data] of datas.entries()) {
  78. if (index !== 0) {
  79. html.push('<li class="list-group-item" auditorId="'+ data.aid +'">');
  80. html.push('<a href="javascript: void(0)" class="text-danger pull-right">移除</a>');
  81. html.push('<span>');
  82. html.push(data.order + ' ');
  83. html.push(data.name + ' ');
  84. html.push('</span>');
  85. html.push('<small class="text-muted">');
  86. html.push(data.role);
  87. html.push('</small></li>');
  88. }
  89. // 添加新审批人流程修改
  90. auditorshtml.push('<li class="list-group-item" data-auditorid="' + data.aid + '">');
  91. auditorshtml.push('<i class="fa ' + (index+1 === datas.length ? 'fa-stop-circle' : 'fa-chevron-circle-down') + '"></i> ');
  92. auditorshtml.push(data.name + ' <small class="text-muted">' + data.role + '</small>');
  93. if (index === 0) {
  94. auditorshtml.push('<span class="pull-right">原报</span>');
  95. } else if (index+1 === datas.length) {
  96. auditorshtml.push('<span class="pull-right">终审</span>');
  97. } else {
  98. auditorshtml.push('<span class="pull-right">'+ transFormToChinese(index) +'审</span>');
  99. }
  100. auditorshtml.push('</li>');
  101. }
  102. $('#auditors').html(html.join(''));
  103. // 重新上报时。令其它的审批人流程图标转换
  104. // $('#auditors-list li i').removeClass('fa-stop-circle').addClass('fa-chevron-circle-down');
  105. // for (let i = 0; i < $('#auditors-list li').length; i++) {
  106. // $('#auditors-list li').eq(i).find('.pull-right').text(transFormToChinese(i+1) + '审');
  107. // $('#auditors-list2 li').eq(i).find('.pull-right').text(transFormToChinese(i+1) + '审');
  108. // }
  109. $('#auditors-list').html(auditorshtml.join(''));
  110. // const auditorshtml2 = [];
  111. // // 重新上报时。令其它的审批人流程图标转换
  112. // $('#auditors-list2 li i').removeClass('fa-stop-circle').addClass('fa-chevron-circle-down');
  113. // // 添加新审批人
  114. // auditorshtml2.push('<li class="list-group-item" data-auditid="' + data.aid + '">');
  115. // auditorshtml2.push('<h5 class="card-title"><i class="fa fa-stop-circle"></i> ');
  116. // auditorshtml2.push(data.name + ' <small class="text-muted">' + data.role + '</small>');
  117. // auditorshtml2.push('<span class="pull-right">终审</span>');
  118. // auditorshtml2.push('</h5></li>');
  119. // $('#auditors-list2').append(auditorshtml2.join(''));
  120. });
  121. }
  122. });
  123. // 删除审批人
  124. $('body').on('click', '#auditors li>a', function () {
  125. const li = $(this).parent();
  126. const data = {
  127. auditorId: parseInt(li.attr('auditorId')),
  128. };
  129. postData(preUrl + '/audit/delete', data, (result) => {
  130. li.remove();
  131. for (const rst of result) {
  132. const aLi = $('li[auditorId=' + rst.aid + ']');
  133. $('span', aLi).text(rst.order + ' ' + rst.name + ' ');
  134. }
  135. // 如果是重新上报
  136. // 令最后一个图标转换
  137. $('#auditors-list li[data-auditorid="' + data.auditorId + '"]').remove();
  138. if ($('#auditors-list li').length !== 0 && !$('#auditors-list li i').hasClass('fa-stop-circle')) {
  139. $('#auditors-list li').eq($('#auditors-list li').length-1).children('i')
  140. .removeClass('fa-chevron-circle-down').addClass('fa-stop-circle');
  141. }
  142. // $('#auditors-list2 li[data-auditid="' + data.auditorId + '"]').remove();
  143. // if ($('#auditors-list2 li').length !== 0 && !$('#auditors-list2 li i').hasClass('fa-stop-circle')) {
  144. // $('#auditors-list2 li').eq($('#auditors-list2 li').length-1).children('i')
  145. // .removeClass('fa-chevron-circle-down').addClass('fa-stop-circle');
  146. // }
  147. for (let i = 0; i < $('#auditors-list li').length; i++) {
  148. $('#auditors-list li').eq(i).find('.pull-right').text(i === 0 ? '原报' : (i+1 === $('#auditors-list li').length ? '终' : transFormToChinese(i)) + '审');
  149. // $('#auditors-list2').eq(i).find('.pull-right').text((i+1 === $('#auditors-list2').length ? '终' : transFormToChinese(i+1)) + '审');
  150. }
  151. });
  152. });
  153. // 退回选择修改审批人流程
  154. $('#hideSp').click(function () {
  155. $('#sp-list').modal('hide');
  156. });
  157. $('a[f-target]').click(function () {
  158. $($(this).attr('f-target')).modal('show');
  159. });
  160. // 多层modal关闭后的滚动bug修复
  161. $('#sp-list').on('hidden.bs.modal', function (e) {
  162. $(document.body).addClass('modal-open');
  163. });
  164. });
  165. // 检查上报情况
  166. function checkAuditorFrom () {
  167. if ($('#auditors li').length === 0) {
  168. // if(shenpi_status === shenpiConst.sp_status.gdspl) {
  169. // toastr.error('请联系管理员添加审批人');
  170. // } else {
  171. toastr.error('请先选择审批人,再上报数据');
  172. // }
  173. return false;
  174. }
  175. let flag = false;
  176. if (change.code === '') {
  177. toastr.error('立项书编号不能为空');
  178. flag = true;
  179. }
  180. if (change.name === '') {
  181. toastr.error('工程名称不能为空');
  182. flag = true;
  183. }
  184. if (!change.reason) {
  185. toastr.error('变更原因不能为空');
  186. flag = true;
  187. }
  188. if (flag) {
  189. return false;
  190. }
  191. $('#hide-all').show();
  192. }
  193. // texterea换行
  194. function auditCheck(i) {
  195. // const inlineRadio1 = $('#inlineRadio1:checked').val()
  196. // const inlineRadio2 = $('#inlineRadio2:checked').val()
  197. const opinion = $('textarea[name="opinion"]').eq(i).val().replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' ');
  198. $('textarea[name="opinion"]').eq(i).val(opinion);
  199. if (i === 2) {
  200. if ($('textarea[name="opinion"]').eq(i).val() === '') {
  201. toastr.error('请输入终止原因');
  202. return false;
  203. }
  204. }
  205. // if (i === 1) {
  206. // if (!inlineRadio1 && !inlineRadio2) {
  207. // if (!$('#warning-text').length) {
  208. // $('#reject-process').prepend('<p id="warning-text" style="color: red; margin: 0;">请选择退回流程</p>');
  209. // }
  210. // return false;
  211. // }
  212. // if ($('#warning-text').length) $('#warning-text').remove()
  213. // }
  214. return true;
  215. }