payment_list.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  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. if (!is_first) {
  110. if (_.findIndex(rpt_audit, { uid: null }) !== -1) {
  111. toastr.error('请绑定所有表单角色再提交');
  112. return;
  113. }
  114. }
  115. postData('/payment/' + tenderId + '/list/' + trId + '/save', { type: 'rpt_audit', rpt_audit }, function (result) {
  116. toastr.success('设置成功');
  117. old_rpt_audit = _.cloneDeep(rpt_audit);
  118. if (result.is_first) {
  119. $('#first_msg').show();
  120. } else {
  121. $('#first_msg').hide();
  122. }
  123. $('#set-bdjs').modal('hide');
  124. });
  125. });
  126. $('#show-add-btn').click(function () {
  127. if (_.findIndex(old_rpt_audit, { uid: null }) !== -1) {
  128. toastr.error('未配置好表单角色无法新建表单');
  129. $('#set-bdjs').modal('show');
  130. } else {
  131. $('#add-catalogue').modal('show');
  132. }
  133. });
  134. $('#add-detail-btn').click(function () {
  135. if (_.trim($('#add-detail-code').val()) === '') {
  136. toastr.error('请输入编号');
  137. return false;
  138. }
  139. if ($('#add-detail-time').val() === '') {
  140. toastr.error('请输入日期');
  141. return false;
  142. }
  143. console.log($('#add-detail-time').val());
  144. postData('/payment/' + tenderId + '/list/' + trId + '/save', { type: 'add-detail', code: _.trim($('#add-detail-code').val()), s_time: $('#add-detail-time').val() }, function (result) {
  145. window.location.href = '/payment/' + tenderId + '/detail/' + result.id;
  146. });
  147. });
  148. // 获取审批流程
  149. $('a[data-target="#sp-list" ]').on('click', function () {
  150. const data = {
  151. order: $(this).attr('m-order'),
  152. };
  153. postData('/payment/' + tenderId + '/list/'+ trId + '/auditors', data, function (result) {
  154. const { auditHistory, auditors, user } = result
  155. let auditorsHTML = ''
  156. let historyHTML = ''
  157. auditors.forEach((auditor, idx) => {
  158. if (idx === 0) {
  159. auditorsHTML += `<li class="list-group-item">
  160. <i class="fa fa fa-play-circle fa-rotate-90"></i> ${auditor.name}
  161. <small class="text-muted">${auditor.role}</small>
  162. <span class="pull-right">原报</span>
  163. </li>`
  164. } else if(idx === auditors.length -1 && idx !== 0) {
  165. auditorsHTML += `<li class="list-group-item">
  166. <i class="fa fa fa-stop-circle"></i> ${auditor.name}
  167. <small class="text-muted">${auditor.role}</small>
  168. <span class="pull-right">终审</span>
  169. </li>`
  170. } else {
  171. auditorsHTML += `<li class="list-group-item">
  172. <i class="fa fa-chevron-circle-down"></i> ${auditor.name}
  173. <small class="text-muted">${auditor.role}</small>
  174. <span class="pull-right">${transFormToChinese(idx)}审</span>
  175. </li>`
  176. }
  177. })
  178. $('#auditor-list').empty()
  179. $('#auditor-list').append(auditorsHTML)
  180. const leftAuditors = auditors;
  181. auditHistory.forEach((auditors, idx) => {
  182. if(idx === auditHistory.length - 1 && auditHistory.length !== 1) {
  183. historyHTML += `<div class="text-right"><a href="javascript: void(0);" id="fold-btn" data-target="show"
  184. >展开历史审批流程</a></div>`
  185. }
  186. historyHTML += `<div class="${idx < auditHistory.length - 1 ? 'fold-card' : ''}">
  187. <div class="text-center text-muted">${idx + 1}#</div>
  188. <ul class="timeline-list list-unstyled mt-2">`
  189. auditors.forEach((auditor, index) => {
  190. if (index === 0) {
  191. historyHTML += `<li class="timeline-list-item pb-2">
  192. <div class="timeline-item-date">
  193. ${formatDate(auditor.begin_time)}
  194. </div>
  195. <div class="timeline-item-tail"></div>
  196. <div class="timeline-item-icon bg-success text-light">
  197. <i class="fa fa-caret-down"></i>
  198. </div>
  199. <div class="timeline-item-content">
  200. <div class="card">
  201. <div class="card-body p-3">
  202. <div class="card-text">
  203. <p class="mb-1"><span
  204. class="h5">${user.name}</span><span
  205. class="pull-right text-success">${idx !== 0 ? '重新' : ''}上报审批</span>
  206. </p>
  207. <p class="text-muted mb-0">${user.role}</p>
  208. </div>
  209. </div>
  210. </div>
  211. </div>
  212. </li>
  213. <li class="timeline-list-item pb-2">
  214. <div class="timeline-item-date">
  215. ${formatDate(auditor.end_time)}
  216. </div>`
  217. if(index < auditors.length - 1) {
  218. historyHTML += `<div class="timeline-item-tail"></div>`
  219. }
  220. if(auditor.status === auditConst.status.checked) {
  221. historyHTML += `<div class="timeline-item-icon bg-success text-light">
  222. <i class="fa fa-check"></i>
  223. </div>`
  224. } else if(auditor.status === auditConst.status.checkNo || auditor.status === auditConst.status.checkNoPre) {
  225. historyHTML += `<div class="timeline-item-icon bg-warning text-light">
  226. <i class="fa fa-level-up"></i>
  227. </div>`
  228. } else if(auditor.status === auditConst.status.checking) {
  229. historyHTML += `<div class="timeline-item-icon bg-warning text-light">
  230. <i class="fa fa-ellipsis-h"></i>
  231. </div>`
  232. } else {
  233. historyHTML += `<div class="timeline-item-icon bg-secondary text-light"></div>`
  234. }
  235. historyHTML += `<div class="timeline-item-content">
  236. <div class="card">
  237. <div class="card-body p-3">
  238. <div class="card-text">
  239. <p class="mb-1"><span class="h5">${auditor.name}</span><span
  240. class="pull-right ${auditConst.statusClass[auditor.status]}">${auditConst.statusString[auditor.status]}</span>
  241. </p>
  242. <p class="text-muted mb-0">${auditor.role}</p>
  243. </div>
  244. </div>`
  245. if (auditor.opinion) {
  246. historyHTML += `<div class="card-body p-3 border-top">
  247. <p style="margin: 0;">${auditor.opinion}</p>
  248. </div>`
  249. }
  250. historyHTML += `</div></div></li>`
  251. } else {
  252. historyHTML += `<li class="timeline-list-item pb-2">
  253. <div class="timeline-item-date">
  254. ${formatDate(auditor.end_time)}
  255. </div>`
  256. if(index < auditors.length - 1) {
  257. historyHTML += `<div class="timeline-item-tail"></div>`
  258. }
  259. if(auditor.status === auditConst.status.checked) {
  260. historyHTML += `<div class="timeline-item-icon bg-success text-light">
  261. <i class="fa fa-check"></i>
  262. </div>`
  263. } else if(auditor.status === auditConst.status.checkNo || auditor.status === auditConst.status.checkNoPre) {
  264. historyHTML += `<div class="timeline-item-icon bg-warning text-light">
  265. <i class="fa fa-level-up"></i>
  266. </div>`
  267. } else if(auditor.status === auditConst.status.checking) {
  268. historyHTML += `<div class="timeline-item-icon bg-warning text-light">
  269. <i class="fa fa-ellipsis-h"></i>
  270. </div>`
  271. } else {
  272. historyHTML += `<div class="timeline-item-icon bg-secondary text-light"></div>`
  273. }
  274. historyHTML += `<div class="timeline-item-content">
  275. <div class="card">
  276. <div class="card-body p-3">
  277. <div class="card-text">
  278. <p class="mb-1"><span class="h5">${auditor.name}</span>
  279. <span
  280. class="pull-right
  281. ${auditConst.statusClass[auditor.status]}">${auditor.status !== auditConst.status.uncheck ? auditConst.statusString[auditor.status] : ''}
  282. ${auditor.status === auditConst.status.checkNo ? user.name : ''}
  283. ${auditor.status === auditConst.status.checkNoPre ? leftAuditors.find(item => item.sort === auditor.sort-1).name : ''}
  284. </span>
  285. </p>
  286. <p class="text-muted mb-0">${auditor.role}</p>
  287. </div>
  288. </div>`
  289. if (auditor.opinion) {
  290. historyHTML += `<div class="card-body p-3 border-top">
  291. <p style="margin: 0;">${auditor.opinion} </p>
  292. </div>`
  293. }
  294. historyHTML += `</div></div></li>`
  295. }
  296. })
  297. historyHTML += '</ul></div>'
  298. })
  299. $('#audit-list').empty()
  300. $('#audit-list').append(historyHTML)
  301. });
  302. });
  303. // 展开/收起历史审核记录
  304. $('#audit-list').on('click', 'a', function() {
  305. const type = $(this).data('target')
  306. const auditCard = $(this).parent().parent()
  307. console.log('auditCard', auditCard)
  308. if (type === 'show') {
  309. $(this).data('target', 'hide')
  310. auditCard.find('.fold-card').slideDown('swing', () => {
  311. auditCard.find('#end-target').text($(this).data('idx') + '#')
  312. auditCard.find('#fold-btn').text('收起历史审核记录')
  313. })
  314. } else {
  315. $(this).data('target', 'show')
  316. auditCard.find('.fold-card').slideUp('swing', () => {
  317. auditCard.find('#end-target').text('1#')
  318. auditCard.find('#fold-btn').text('展开历史审核记录')
  319. })
  320. }
  321. });
  322. function formatDate(date) {
  323. if (!date) return '';
  324. date = new Date(date)
  325. const year = date.getFullYear();
  326. let mon = date.getMonth() + 1;
  327. let day = date.getDate();
  328. let hour = date.getHours();
  329. let minute = date.getMinutes();
  330. let scond = date.getSeconds();
  331. if (mon < 10) {
  332. mon = '0' + mon.toString();
  333. }
  334. if (day < 10) {
  335. day = '0' + day.toString();
  336. }
  337. if (hour < 10) {
  338. hour = '0' + hour.toString();
  339. }
  340. if (minute < 10) {
  341. minute = '0' + minute.toString();
  342. }
  343. if (scond < 10) {
  344. scond = '0' + scond.toString();
  345. }
  346. return `${year}<span>${mon}-${day}</span><span>${hour}:${minute}:${scond}</span>`;
  347. };
  348. });