measure_material.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. 'use strict';
  2. /**
  3. * 期计量 - 期列表页面 js
  4. *
  5. * @author Mai
  6. * @date 2018/12/7
  7. * @version
  8. */
  9. $(function () {
  10. // 获取审批流程
  11. $('a[data-target="#sp-list" ]').on('click', function () {
  12. const data = {
  13. order: $(this).attr('m-order'),
  14. };
  15. postData('/tender/' + tenderId + '/measure/material/auditors', data, function (result) {
  16. const { auditHistory, auditors, user } = result
  17. let auditorsHTML = ''
  18. let historyHTML = ''
  19. auditors.forEach((auditor, idx) => {
  20. if (idx === 0) {
  21. auditorsHTML += `<li class="list-group-item">
  22. <i class="fa fa fa-play-circle fa-rotate-90"></i> ${auditor.name}
  23. <small class="text-muted">${auditor.role}</small>
  24. <span class="pull-right">原报</span>
  25. </li>`
  26. } else if(idx === auditors.length -1 && idx !== 0) {
  27. auditorsHTML += `<li class="list-group-item">
  28. <i class="fa fa fa-stop-circle"></i> ${auditor.name}
  29. <small class="text-muted">${auditor.role}</small>
  30. <span class="pull-right">终审</span>
  31. </li>`
  32. } else {
  33. auditorsHTML += `<li class="list-group-item">
  34. <i class="fa fa-chevron-circle-down"></i> ${auditor.name}
  35. <small class="text-muted">${auditor.role}</small>
  36. <span class="pull-right">${transFormToChinese(idx)}审</span>
  37. </li>`
  38. }
  39. })
  40. $('#auditor-list').empty()
  41. $('#auditor-list').append(auditorsHTML)
  42. auditHistory.forEach((auditors, idx) => {
  43. historyHTML += `<div class="${idx < auditHistory.length - 1 ? 'fold-card' : ''}">
  44. <div class="text-center text-muted"
  45. ${idx === auditHistory.length - 1 ? 'id="end-target"' : ""}>
  46. ${idx === auditHistory.length - 1 ? 1 : idx + 1}#</div>
  47. <ul class="timeline-list list-unstyled mt-2">`
  48. auditors.forEach((auditor, index) => {
  49. if (index === 0) {
  50. historyHTML += `<li class="timeline-list-item pb-2">
  51. <div class="timeline-item-date">
  52. ${formatDate(auditor.begin_time)}
  53. </div>
  54. <div class="timeline-item-tail"></div>
  55. <div class="timeline-item-icon bg-success text-light">
  56. <i class="fa fa-caret-down"></i>
  57. </div>
  58. <div class="timeline-item-content">
  59. <div class="card">
  60. <div class="card-body p-3">
  61. <div class="card-text">
  62. <p class="mb-1"><span
  63. class="h5">${user.name}</span><span
  64. class="pull-right text-success">${idx !== 0 ? '重新' : ''}上报审批</span>
  65. </p>
  66. <p class="text-muted mb-0">${user.role}</p>
  67. </div>
  68. </div>
  69. </div>
  70. </div>
  71. </li>
  72. <li class="timeline-list-item pb-2">
  73. <div class="timeline-item-date">
  74. ${formatDate(auditor.end_time)}
  75. </div>`
  76. if(index < auditors.length - 1) {
  77. historyHTML += `<div class="timeline-item-tail"></div>`
  78. }
  79. if(auditor.status === auditConst.status.checked) {
  80. historyHTML += `<div class="timeline-item-icon bg-success text-light">
  81. <i class="fa fa-check"></i>
  82. </div>`
  83. } else if(auditor.status === auditConst.status.checkNo || auditor.status === auditConst.status.checkNoPre) {
  84. historyHTML += `<div class="timeline-item-icon bg-warning text-light">
  85. <i class="fa fa-level-up"></i>
  86. </div>`
  87. } else if(auditor.status === auditConst.status.checking) {
  88. historyHTML += `<div class="timeline-item-icon bg-warning text-light">
  89. <i class="fa fa-ellipsis-h"></i>
  90. </div>`
  91. } else {
  92. historyHTML += `<div class="timeline-item-icon bg-secondary text-light"></div>`
  93. }
  94. historyHTML += `<div class="timeline-item-content">
  95. <div class="card">
  96. <div class="card-body p-3">
  97. <div class="card-text">
  98. <p class="mb-1"><span class="h5">${auditor.name}</span><span
  99. class="pull-right ${auditConst.statusClass[auditor.status]}">${auditConst.statusString[auditor.status]}</span>
  100. </p>
  101. <p class="text-muted mb-0">${auditor.role}</p>
  102. </div>
  103. </div>`
  104. if (auditor.opinion) {
  105. historyHTML += `<div class="card-body p-3 border-top">
  106. <p style="margin: 0;">${auditor.opinion}</p>
  107. </div>`
  108. }
  109. historyHTML += `</div></div></li>`
  110. } else {
  111. historyHTML += `<li class="timeline-list-item pb-2">
  112. <div class="timeline-item-date">
  113. ${formatDate(auditor.end_time)}
  114. </div>`
  115. if(index < auditors.length - 1) {
  116. historyHTML += `<div class="timeline-item-tail"></div>`
  117. }
  118. if(auditor.status === auditConst.status.checked) {
  119. historyHTML += `<div class="timeline-item-icon bg-success text-light">
  120. <i class="fa fa-check"></i>
  121. </div>`
  122. } else if(auditor.status === auditConst.status.checkNo || auditor.status === auditConst.status.checkNoPre) {
  123. historyHTML += `<div class="timeline-item-icon bg-warning text-light">
  124. <i class="fa fa-level-up"></i>
  125. </div>`
  126. } else if(auditor.status === auditConst.status.checking) {
  127. historyHTML += `<div class="timeline-item-icon bg-warning text-light">
  128. <i class="fa fa-ellipsis-h"></i>
  129. </div>`
  130. } else {
  131. historyHTML += `<div class="timeline-item-icon bg-secondary text-light"></div>`
  132. }
  133. historyHTML += `<div class="timeline-item-content">
  134. <div class="card">
  135. <div class="card-body p-3">
  136. <div class="card-text">
  137. <p class="mb-1"><span class="h5">${auditor.name}</span>
  138. <span
  139. class="pull-right
  140. ${auditConst.statusClass[auditor.status]}">${auditor.status !== auditConst.status.uncheck ? auditConst.statusString[auditor.status] : ''}
  141. ${auditor.status === auditConst.status.checkNo ? user.name : ''}
  142. ${auditor.status === auditConst.status.checkNoPre ? auditors[index-1].name : ''}
  143. </span>
  144. </p>
  145. <p class="text-muted mb-0">${auditor.role}</p>
  146. </div>
  147. </div>`
  148. if (auditor.opinion) {
  149. historyHTML += `<div class="card-body p-3 border-top">
  150. <p style="margin: 0;">${auditor.opinion} </p>
  151. </div>`
  152. }
  153. historyHTML += `</div></div></li>`
  154. }
  155. })
  156. historyHTML += '</ul></div>'
  157. if(idx === auditHistory.length - 1 && auditHistory.length !== 1) {
  158. historyHTML += `<div class="text-right"><a href="javascript: void(0);" id="fold-btn" data-target="show"
  159. data-idx="${idx + 1}">展开历史审批流程</a></div>`
  160. }
  161. })
  162. $('#audit-list').empty()
  163. $('#audit-list').append(historyHTML)
  164. });
  165. });
  166. // 展开/收起历史审核记录
  167. $('#audit-list').on('click', 'a', function() {
  168. const type = $(this).data('target')
  169. const auditCard = $(this).parent().parent()
  170. console.log('auditCard', auditCard)
  171. if (type === 'show') {
  172. $(this).data('target', 'hide')
  173. auditCard.find('.fold-card').slideDown('swing', () => {
  174. auditCard.find('#end-target').text($(this).data('idx') + '#')
  175. auditCard.find('#fold-btn').text('收起历史审核记录')
  176. })
  177. } else {
  178. $(this).data('target', 'show')
  179. auditCard.find('.fold-card').slideUp('swing', () => {
  180. auditCard.find('#end-target').text('1#')
  181. auditCard.find('#fold-btn').text('展开历史审核记录')
  182. })
  183. }
  184. });
  185. function formatDate(date) {
  186. if (!date) return '';
  187. date = new Date(date)
  188. const year = date.getFullYear();
  189. let mon = date.getMonth() + 1;
  190. let day = date.getDate();
  191. let hour = date.getHours();
  192. let minute = date.getMinutes();
  193. let scond = date.getSeconds();
  194. if (mon < 10) {
  195. mon = '0' + mon.toString();
  196. }
  197. if (day < 10) {
  198. day = '0' + day.toString();
  199. }
  200. if (hour < 10) {
  201. hour = '0' + hour.toString();
  202. }
  203. if (minute < 10) {
  204. minute = '0' + minute.toString();
  205. }
  206. if (scond < 10) {
  207. scond = '0' + scond.toString();
  208. }
  209. return `${year}<span>${mon}-${day}</span><span>${hour}:${minute}:${scond}</span>`;
  210. };
  211. // 计量期选中
  212. $('.select-stage-order').on('click', function () {
  213. const stageList = $('.select-stage-order:checked');
  214. if (stageList.length === 0) {
  215. $('#show_order').hide();
  216. $('#s_order').val('');
  217. } else {
  218. const order_array = [];
  219. for (let s = 0; s < stageList.length; s++) {
  220. order_array.push(stageList.eq(s).data('order'));
  221. // console.log(stageList.eq(s));
  222. }
  223. $('#show_order').html('第<b class="mx-2">' + order_array.join(',') + '</b>期');
  224. $('#show_order').show();
  225. $('#s_order').val(order_array.join(','));
  226. }
  227. });
  228. // 提交表单判断
  229. $('#addMaterial').click(function () {
  230. if ($('#s_order').val() == '') {
  231. toastr.error('请选择计量期');
  232. return false;
  233. }
  234. })
  235. });