payment_detail_audit.js 11 KB

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