payment_list.js 18 KB

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