payment_detail_audit.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  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('/payment/' + tenderId + '/detail/' + detailId + '/save', { type: 'add_audit', 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. if (shenpi_status === shenpiConst.sp_status.sqspr || (shenpi_status === shenpiConst.sp_status.gdzs && index+1 !== datas.length)) {
  81. html.push('<a href="javascript: void(0)" class="text-danger pull-right">移除</a>');
  82. }
  83. html.push('<span>');
  84. html.push(data.order + ' ');
  85. html.push(data.name + ' ');
  86. html.push('</span>');
  87. html.push('<small class="text-muted">');
  88. html.push(data.role);
  89. html.push('</small></li>');
  90. }
  91. // 添加新审批人流程修改
  92. auditorshtml.push('<li class="list-group-item" data-auditorid="' + data.aid + '">');
  93. auditorshtml.push('<i class="fa ' + (index+1 === datas.length ? 'fa-stop-circle' : 'fa-chevron-circle-down') + '"></i> ');
  94. auditorshtml.push(data.name + ' <small class="text-muted">' + data.role + '</small>');
  95. if (index === 0) {
  96. auditorshtml.push('<span class="pull-right">原报</span>');
  97. } else if (index+1 === datas.length) {
  98. auditorshtml.push('<span class="pull-right">终审</span>');
  99. } else {
  100. auditorshtml.push('<span class="pull-right">'+ transFormToChinese(index) +'审</span>');
  101. }
  102. auditorshtml.push('</li>');
  103. }
  104. $('#auditors').html(html.join(''));
  105. // 重新上报时。令其它的审批人流程图标转换
  106. // $('#auditors-list li i').removeClass('fa-stop-circle').addClass('fa-chevron-circle-down');
  107. // for (let i = 0; i < $('#auditors-list li').length; i++) {
  108. // $('#auditors-list li').eq(i).find('.pull-right').text(transFormToChinese(i+1) + '审');
  109. // $('#auditors-list2 li').eq(i).find('.pull-right').text(transFormToChinese(i+1) + '审');
  110. // }
  111. $('#auditors-list').html(auditorshtml.join(''));
  112. // const auditorshtml2 = [];
  113. // // 重新上报时。令其它的审批人流程图标转换
  114. // $('#auditors-list2 li i').removeClass('fa-stop-circle').addClass('fa-chevron-circle-down');
  115. // // 添加新审批人
  116. // auditorshtml2.push('<li class="list-group-item" data-auditid="' + data.aid + '">');
  117. // auditorshtml2.push('<h5 class="card-title"><i class="fa fa-stop-circle"></i> ');
  118. // auditorshtml2.push(data.name + ' <small class="text-muted">' + data.role + '</small>');
  119. // auditorshtml2.push('<span class="pull-right">终审</span>');
  120. // auditorshtml2.push('</h5></li>');
  121. // $('#auditors-list2').append(auditorshtml2.join(''));
  122. });
  123. }
  124. });
  125. // 删除审批人
  126. $('body').on('click', '#auditors li>a', function () {
  127. const li = $(this).parent();
  128. postData('/payment/' + tenderId + '/detail/' + detailId + '/save', { type: 'del_audit', auditorId: parseInt(li.attr('auditorId')) }, (result) => {
  129. li.remove();
  130. for (const rst of result) {
  131. const aLi = $('li[auditorId=' + rst.aid + ']');
  132. $('span', aLi).text(rst.order + ' ' + rst.name + ' ');
  133. }
  134. // 如果是重新上报
  135. // 令最后一个图标转换
  136. $('#auditors-list li[data-auditorid="' + parseInt(li.attr('auditorId')) + '"]').remove();
  137. if ($('#auditors-list li').length !== 0 && !$('#auditors-list li i').hasClass('fa-stop-circle')) {
  138. $('#auditors-list li').eq($('#auditors-list li').length-1).children('i')
  139. .removeClass('fa-chevron-circle-down').addClass('fa-stop-circle');
  140. }
  141. // $('#auditors-list2 li[data-auditid="' + data.auditorId + '"]').remove();
  142. // if ($('#auditors-list2 li').length !== 0 && !$('#auditors-list2 li i').hasClass('fa-stop-circle')) {
  143. // $('#auditors-list2 li').eq($('#auditors-list2 li').length-1).children('i')
  144. // .removeClass('fa-chevron-circle-down').addClass('fa-stop-circle');
  145. // }
  146. for (let i = 0; i < $('#auditors-list li').length; i++) {
  147. $('#auditors-list li').eq(i).find('.pull-right').text(i === 0 ? '原报' : (i+1 === $('#auditors-list li').length ? '终' : transFormToChinese(i)) + '审');
  148. // $('#auditors-list2').eq(i).find('.pull-right').text((i+1 === $('#auditors-list2').length ? '终' : transFormToChinese(i+1)) + '审');
  149. }
  150. });
  151. });
  152. // 退回选择修改审批人流程
  153. $('#hideSp').click(function () {
  154. $('#sp-list').modal('hide');
  155. });
  156. $('a[f-target]').click(function () {
  157. $($(this).attr('f-target')).modal('show');
  158. });
  159. // 多层modal关闭后的滚动bug修复
  160. $('#sp-list').on('hidden.bs.modal', function (e) {
  161. $(document.body).addClass('modal-open');
  162. });
  163. // 重新审批获取手机验证码
  164. // 获取验证码
  165. let isPosting = false;
  166. $("#get-code").click(function() {
  167. if (isPosting) {
  168. return false;
  169. }
  170. const btn = $(this);
  171. $.ajax({
  172. url: '/profile/code?_csrf_j=' + csrf,
  173. type: 'post',
  174. data: { mobile: authMobile, type: 'shenpi' },
  175. dataTye: 'json',
  176. error: function() {
  177. isPosting = false;
  178. },
  179. beforeSend: function() {
  180. isPosting = true;
  181. },
  182. success: function(response) {
  183. isPosting = false;
  184. if (response.err === 0) {
  185. codeSuccess(btn);
  186. $("input[name='code']").removeAttr('readonly');
  187. $("#re-shenpi-btn").removeAttr('disabled');
  188. } else {
  189. toastr.error(response.msg);
  190. }
  191. }
  192. });
  193. });
  194. });
  195. // 检查上报情况
  196. function checkAuditorFrom () {
  197. if ($('#auditors li').length === 0) {
  198. if(shenpi_status === shenpiConst.sp_status.gdspl) {
  199. toastr.error('请联系管理员添加审批人');
  200. } else {
  201. toastr.error('请先选择审批人,再上报数据');
  202. }
  203. return false;
  204. }
  205. $('#hide-all').show();
  206. }
  207. // texterea换行
  208. function auditCheck(i) {
  209. const inlineRadio1 = $('#inlineRadio1:checked').val()
  210. const inlineRadio2 = $('#inlineRadio2:checked').val()
  211. const opinion = $('textarea[name="opinion"]').eq(i).val().replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' ');
  212. $('textarea[name="opinion"]').eq(i).val(opinion);
  213. if (i === 1) {
  214. if (!inlineRadio1 && !inlineRadio2) {
  215. if (!$('#warning-text').length) {
  216. $('#reject-process').prepend('<p id="warning-text" style="color: red; margin: 0;">请选择退回流程</p>');
  217. }
  218. return false;
  219. }
  220. if ($('#warning-text').length) $('#warning-text').remove()
  221. }
  222. return true;
  223. }
  224. /**
  225. * 获取成功后的操作
  226. *
  227. * @param {Object} btn - 点击的按钮
  228. * @return {void}
  229. */
  230. function codeSuccess(btn) {
  231. let counter = 60;
  232. btn.addClass('disabled').text('重新获取 ' + counter + 'S');
  233. btn.parent().siblings('input').removeAttr('readonly').attr('placeholder', '输入短信中的6位验证码');
  234. const bindBtn = $("#bind-btn");
  235. bindBtn.removeClass('btn-secondary disabled').addClass('btn-primary');
  236. const countDown = setInterval(function() {
  237. const countString = counter - 1 <= 0 ? '' : ' ' + (counter - 1) + 'S';
  238. // 倒数结束后
  239. if (countString === '') {
  240. clearInterval(countDown);
  241. btn.removeClass('disabled');
  242. }
  243. const text = '重新获取' + countString;
  244. btn.text(text);
  245. counter -= 1;
  246. }, 1000);
  247. }