payment_list.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. $(function () {
  2. autoFlashHeight();
  3. let timer = null;
  4. let oldSearchVal = null;
  5. $('body').on('input propertychange', '.gr-search', function(e) {
  6. oldSearchVal = e.target.value;
  7. timer && clearTimeout(timer);
  8. timer = setTimeout(() => {
  9. const newVal = $(this).val();
  10. const code = $(this).attr('data-code');
  11. let html = '';
  12. if (newVal && newVal === oldSearchVal) {
  13. accountList.filter(item => item && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
  14. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  15. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  16. class="ml-auto">${item.mobile || ''}</span></p>
  17. <span class="text-muted">${item.role || ''}</span>
  18. </dd>`
  19. });
  20. $('#' + code + '_dropdownMenu .book-list').empty();
  21. $('#' + code + '_dropdownMenu .book-list').append(html);
  22. } else {
  23. if (!$('#' + code + '_dropdownMenu .acc-btn').length) {
  24. accountGroup.forEach((group, idx) => {
  25. if (!group) return;
  26. html += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>
  27. </a> ${group.groupName}</dt>
  28. <div class="dd-content" data-toggleid="${idx}">`;
  29. group.groupList.forEach(item => {
  30. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  31. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  32. class="ml-auto">${item.mobile || ''}</span></p>
  33. <span class="text-muted">${item.role || ''}</span>
  34. </dd>`;
  35. });
  36. html += '</div>';
  37. });
  38. $('#' + code + '_dropdownMenu .book-list').empty();
  39. $('#' + code + '_dropdownMenu .book-list').append(html);
  40. }
  41. }
  42. }, 400);
  43. });
  44. // 添加审批流程按钮逻辑
  45. $('body').on('click', '.book-list dt', function () {
  46. const idx = $(this).find('.acc-btn').attr('data-groupid');
  47. const type = $(this).find('.acc-btn').attr('data-type');
  48. if (type === 'hide') {
  49. $(this).parent().find(`div[data-toggleid="${idx}"]`).show(() => {
  50. $(this).children().find('i').removeClass('fa-plus-square').addClass('fa-minus-square-o');
  51. $(this).find('.acc-btn').attr('data-type', 'show');
  52. })
  53. } else {
  54. $(this).parent().find(`div[data-toggleid="${idx}"]`).hide(() => {
  55. $(this).children().find('i').removeClass('fa-minus-square-o').addClass('fa-plus-square');
  56. $(this).find('.acc-btn').attr('data-type', 'hide');
  57. })
  58. }
  59. return false;
  60. });
  61. // 选中审批人
  62. $('body').on('click', 'dl dd', function () {
  63. const id = parseInt($(this).attr('data-id'));
  64. if (!id) return;
  65. const this_code = $(this).parents('.dropdown').data('code');
  66. if (_.findIndex(rpt_audit, { uid: id }) !== -1) {
  67. toastr.error('该表单角色已存在,请勿重复添加');
  68. return;
  69. }
  70. const user = _.find(accountList, function (item) {
  71. return item.id === id;
  72. });
  73. $('#' + this_code + '_user').html(`<span>${user.name}</span><i role="button" class="fa fa-close text-danger remove-audit stamp-img" data-code="${this_code}"></i>`);
  74. $(this).parents('.select-audit').hide();
  75. $('#' + this_code + '_user').show();
  76. rpt_audit[this_code].uid = id;
  77. rpt_audit[this_code].name = user.name;
  78. console.log(rpt_audit);
  79. });
  80. // 移除审批人
  81. $('body').on('click', '.remove-audit', function () {
  82. const this_code = parseInt($(this).attr('data-code'));
  83. $('#' + this_code + '_user').html(``);
  84. $('#' + this_code + '_user').hide();
  85. $('#' + this_code + '_user').siblings('.select-audit').show();
  86. rpt_audit[this_code].uid = null;
  87. delete rpt_audit[this_code].name;
  88. console.log(rpt_audit);
  89. });
  90. // 重新加载角色数据
  91. $('#set-bdjs').on('show.bs.modal', function () {
  92. if (old_rpt_audit) {
  93. for (const [i, r] of old_rpt_audit.entries()) {
  94. if (r.uid) {
  95. $('#' + i + '_user').html(`<span>${r.name}</span><i role="button" class="fa fa-close text-danger remove-audit stamp-img" data-code="${i}"></i>`);
  96. $('#' + i + '_user').show();
  97. $('#' + i + '_user').siblings('.select-audit').hide();
  98. } else {
  99. $('#' + i + '_user').html(``);
  100. $('#' + i + '_user').hide();
  101. $('#' + i + '_user').siblings('.select-audit').show();
  102. }
  103. }
  104. }
  105. rpt_audit = _.cloneDeep(old_rpt_audit);
  106. });
  107. // 绑定表单角色
  108. $('#bind_rpt_audit_btn').click(function () {
  109. postData('/payment/' + tenderId + '/list/' + trId + '/save', { type: 'rpt_audit', rpt_audit }, function (result) {
  110. toastr.success('设置成功');
  111. old_rpt_audit = _.cloneDeep(rpt_audit);
  112. if (result.is_first) {
  113. $('#first_msg').show();
  114. } else {
  115. $('#first_msg').hide();
  116. }
  117. $('#set-bdjs').modal('hide');
  118. });
  119. });
  120. $('#show-add-btn').click(function () {
  121. if (_.findIndex(old_rpt_audit, { uid: null }) !== -1) {
  122. toastr.error('未配置好表单角色无法新建表单');
  123. $('#set-bdjs').modal('show');
  124. } else {
  125. $('#add-catalogue').modal('show');
  126. }
  127. });
  128. $('#add-detail-btn').click(function () {
  129. if (_.trim($('#add-detail-code').val()) === '') {
  130. toastr.error('请输入编号');
  131. return false;
  132. }
  133. if ($('#add-detail-time').val() === '') {
  134. toastr.error('请输入日期');
  135. return false;
  136. }
  137. console.log($('#add-detail-time').val());
  138. postData('/payment/' + tenderId + '/list/' + trId + '/save', { type: 'add-detail', code: _.trim($('#add-detail-code').val()), s_time: $('#add-detail-time').val() }, function (result) {
  139. window.location.href = '/payment/' + tenderId + '/detail/' + result.id;
  140. });
  141. });
  142. // 获取审批流程
  143. $('a[data-target="#sp-list" ]').on('click', function () {
  144. const data = {
  145. order: $(this).attr('m-order'),
  146. };
  147. postData('/payment/' + tenderId + '/list/'+ trId + '/auditors', data, function (result) {
  148. const { auditHistory, auditors, user } = result
  149. let auditorsHTML = ''
  150. let historyHTML = ''
  151. auditors.forEach((auditor, idx) => {
  152. if (idx === 0) {
  153. auditorsHTML += `<li class="list-group-item">
  154. <i class="fa fa fa-play-circle fa-rotate-90"></i> ${auditor.name}
  155. <small class="text-muted">${auditor.role}</small>
  156. <span class="pull-right">原报</span>
  157. </li>`
  158. } else if(idx === auditors.length -1 && idx !== 0) {
  159. auditorsHTML += `<li class="list-group-item">
  160. <i class="fa fa fa-stop-circle"></i> ${auditor.name}
  161. <small class="text-muted">${auditor.role}</small>
  162. <span class="pull-right">终审</span>
  163. </li>`
  164. } else {
  165. auditorsHTML += `<li class="list-group-item">
  166. <i class="fa fa-chevron-circle-down"></i> ${auditor.name}
  167. <small class="text-muted">${auditor.role}</small>
  168. <span class="pull-right">${transFormToChinese(idx)}审</span>
  169. </li>`
  170. }
  171. })
  172. $('#auditor-list').empty()
  173. $('#auditor-list').append(auditorsHTML)
  174. const leftAuditors = auditors;
  175. auditHistory.forEach((auditors, idx) => {
  176. if(idx === auditHistory.length - 1 && auditHistory.length !== 1) {
  177. historyHTML += `<div class="text-right"><a href="javascript: void(0);" id="fold-btn" data-target="show"
  178. >展开历史审批流程</a></div>`
  179. }
  180. historyHTML += `<div class="${idx < auditHistory.length - 1 ? 'fold-card' : ''}">
  181. <div class="text-center text-muted">${idx + 1}#</div>
  182. <ul class="timeline-list list-unstyled mt-2">`
  183. auditors.forEach((auditor, index) => {
  184. if (index === 0) {
  185. historyHTML += `<li class="timeline-list-item pb-2">
  186. <div class="timeline-item-date">
  187. ${formatDate(auditor.begin_time)}
  188. </div>
  189. <div class="timeline-item-tail"></div>
  190. <div class="timeline-item-icon bg-success text-light">
  191. <i class="fa fa-caret-down"></i>
  192. </div>
  193. <div class="timeline-item-content">
  194. <div class="card">
  195. <div class="card-body p-3">
  196. <div class="card-text">
  197. <p class="mb-1"><span
  198. class="h5">${user.name}</span><span
  199. class="pull-right text-success">${idx !== 0 ? '重新' : ''}上报审批</span>
  200. </p>
  201. <p class="text-muted mb-0">${user.role}</p>
  202. </div>
  203. </div>
  204. </div>
  205. </div>
  206. </li>
  207. <li class="timeline-list-item pb-2">
  208. <div class="timeline-item-date">
  209. ${formatDate(auditor.end_time)}
  210. </div>`
  211. if(index < auditors.length - 1) {
  212. historyHTML += `<div class="timeline-item-tail"></div>`
  213. }
  214. if(auditor.status === auditConst.status.checked) {
  215. historyHTML += `<div class="timeline-item-icon bg-success text-light">
  216. <i class="fa fa-check"></i>
  217. </div>`
  218. } else if(auditor.status === auditConst.status.checkNo || auditor.status === auditConst.status.checkNoPre) {
  219. historyHTML += `<div class="timeline-item-icon bg-warning text-light">
  220. <i class="fa fa-level-up"></i>
  221. </div>`
  222. } else if(auditor.status === auditConst.status.checking) {
  223. historyHTML += `<div class="timeline-item-icon bg-warning text-light">
  224. <i class="fa fa-ellipsis-h"></i>
  225. </div>`
  226. } else {
  227. historyHTML += `<div class="timeline-item-icon bg-secondary text-light"></div>`
  228. }
  229. historyHTML += `<div class="timeline-item-content">
  230. <div class="card">
  231. <div class="card-body p-3">
  232. <div class="card-text">
  233. <p class="mb-1"><span class="h5">${auditor.name}</span><span
  234. class="pull-right ${auditConst.statusClass[auditor.status]}">${auditConst.statusString[auditor.status]}</span>
  235. </p>
  236. <p class="text-muted mb-0">${auditor.role}</p>
  237. </div>
  238. </div>`
  239. if (auditor.opinion) {
  240. historyHTML += `<div class="card-body p-3 border-top">
  241. <p style="margin: 0;">${auditor.opinion}</p>
  242. </div>`
  243. }
  244. historyHTML += `</div></div></li>`
  245. } else {
  246. historyHTML += `<li class="timeline-list-item pb-2">
  247. <div class="timeline-item-date">
  248. ${formatDate(auditor.end_time)}
  249. </div>`
  250. if(index < auditors.length - 1) {
  251. historyHTML += `<div class="timeline-item-tail"></div>`
  252. }
  253. if(auditor.status === auditConst.status.checked) {
  254. historyHTML += `<div class="timeline-item-icon bg-success text-light">
  255. <i class="fa fa-check"></i>
  256. </div>`
  257. } else if(auditor.status === auditConst.status.checkNo || auditor.status === auditConst.status.checkNoPre) {
  258. historyHTML += `<div class="timeline-item-icon bg-warning text-light">
  259. <i class="fa fa-level-up"></i>
  260. </div>`
  261. } else if(auditor.status === auditConst.status.checking) {
  262. historyHTML += `<div class="timeline-item-icon bg-warning text-light">
  263. <i class="fa fa-ellipsis-h"></i>
  264. </div>`
  265. } else {
  266. historyHTML += `<div class="timeline-item-icon bg-secondary text-light"></div>`
  267. }
  268. historyHTML += `<div class="timeline-item-content">
  269. <div class="card">
  270. <div class="card-body p-3">
  271. <div class="card-text">
  272. <p class="mb-1"><span class="h5">${auditor.name}</span>
  273. <span
  274. class="pull-right
  275. ${auditConst.statusClass[auditor.status]}">${auditor.status !== auditConst.status.uncheck ? auditConst.statusString[auditor.status] : ''}
  276. ${auditor.status === auditConst.status.checkNo ? user.name : ''}
  277. ${auditor.status === auditConst.status.checkNoPre ? leftAuditors.find(item => item.sort === auditor.sort-1).name : ''}
  278. </span>
  279. </p>
  280. <p class="text-muted mb-0">${auditor.role}</p>
  281. </div>
  282. </div>`
  283. if (auditor.opinion) {
  284. historyHTML += `<div class="card-body p-3 border-top">
  285. <p style="margin: 0;">${auditor.opinion} </p>
  286. </div>`
  287. }
  288. historyHTML += `</div></div></li>`
  289. }
  290. })
  291. historyHTML += '</ul></div>'
  292. })
  293. $('#audit-list').empty()
  294. $('#audit-list').append(historyHTML)
  295. });
  296. });
  297. // 展开/收起历史审核记录
  298. $('#audit-list').on('click', 'a', function() {
  299. const type = $(this).data('target')
  300. const auditCard = $(this).parent().parent()
  301. console.log('auditCard', auditCard)
  302. if (type === 'show') {
  303. $(this).data('target', 'hide')
  304. auditCard.find('.fold-card').slideDown('swing', () => {
  305. auditCard.find('#end-target').text($(this).data('idx') + '#')
  306. auditCard.find('#fold-btn').text('收起历史审核记录')
  307. })
  308. } else {
  309. $(this).data('target', 'show')
  310. auditCard.find('.fold-card').slideUp('swing', () => {
  311. auditCard.find('#end-target').text('1#')
  312. auditCard.find('#fold-btn').text('展开历史审核记录')
  313. })
  314. }
  315. });
  316. function formatDate(date) {
  317. if (!date) return '';
  318. date = new Date(date)
  319. const year = date.getFullYear();
  320. let mon = date.getMonth() + 1;
  321. let day = date.getDate();
  322. let hour = date.getHours();
  323. let minute = date.getMinutes();
  324. let scond = date.getSeconds();
  325. if (mon < 10) {
  326. mon = '0' + mon.toString();
  327. }
  328. if (day < 10) {
  329. day = '0' + day.toString();
  330. }
  331. if (hour < 10) {
  332. hour = '0' + hour.toString();
  333. }
  334. if (minute < 10) {
  335. minute = '0' + minute.toString();
  336. }
  337. if (scond < 10) {
  338. scond = '0' + scond.toString();
  339. }
  340. return `${year}<span>${mon}-${day}</span><span>${hour}:${minute}:${scond}</span>`;
  341. };
  342. });