modal.ejs 63 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207
  1. <!--删除标段-->
  2. <div class="modal fade" id="del-bg" data-backdrop="static">
  3. <div class="modal-dialog" role="document">
  4. <div class="modal-content">
  5. <div class="modal-header">
  6. <h5 class="modal-title">确认删除变更</h5>
  7. </div>
  8. <div class="modal-body">
  9. <h5>删除后,数据无法恢复,请谨慎操作。</h5>
  10. </div>
  11. <form class="modal-footer" action="/tender/<%- tender.id %>/change/delete" method="post">
  12. <input type="hidden" name="cid" id="delete-cid" value="">
  13. <input type="hidden" name="_csrf_j" value="<%= ctx.csrf %>" />
  14. <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">取消</button>
  15. <button type="submit" class="btn btn-danger btn-sm">确定删除</button>
  16. </form>
  17. </div>
  18. </div>
  19. </div>
  20. <!--审批流程/结果-->
  21. <div class="modal fade" id="sp-list" data-backdrop="static">
  22. <div class="modal-dialog modal-lg" role="document">
  23. <div class="modal-content">
  24. <div class="modal-header">
  25. <h5 class="modal-title">审批流程</h5>
  26. </div>
  27. <div class="modal-body">
  28. <div class="row">
  29. <div class="col-4 modal-height-500" style="overflow: auto">
  30. <div class="card mt-3">
  31. <ul class="list-group list-group-flush" id="auditor-list">
  32. </ul>
  33. </div>
  34. </div>
  35. <div class="col-8 modal-height-500" style="overflow: auto" id="audit-list">
  36. </div>
  37. </div>
  38. </div>
  39. <div class="modal-footer">
  40. <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">关闭</button>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. <% if (tender.user_id === ctx.session.sessionUser.accountId) { %>
  46. <!--弹出添加变更令-->
  47. <div class="modal fade" id="add-bj-modal" data-backdrop="static">
  48. <div class="modal-dialog" role="document">
  49. <div class="modal-content">
  50. <div class="modal-header">
  51. <h5 class="modal-title">新建变更令</h5>
  52. </div>
  53. <div class="modal-body">
  54. <div class="form-group">
  55. <label>申请编号<b class="text-danger">*</b></label>
  56. <div class="input-group">
  57. <input type="text" class="form-control form-control-sm is-invalid" placeholder="请输入变更令号" value="变更申请编号" id="bj-code">
  58. <div class="input-group-append" id="autoCodeShow" <% if (codeRule.length === 0) { %>style="display: none"<% } %>>
  59. <button class="btn btn-sm btn-outline-secondary" type="button" title="自动编号" id="autoCode"><i class="fa fa-repeat"></i></button>
  60. </div>
  61. <div class="invalid-feedback" style="display: none" id="bjHint">您输入的编号已存在。</div>
  62. </div>
  63. </div>
  64. <% if (ctx.session.sessionProject.page_show.openChangePlan) { %>
  65. <style>
  66. .select2-container {
  67. /*display: inline-block!important;*/
  68. /*height: 27px;*/
  69. width: 100% !important;
  70. }
  71. .select2-container--bootstrap4 .select2-selection--single {
  72. height: calc(1.1em + .75rem + 2px) !important;
  73. }
  74. /*.select2-container--bootstrap4 .select2-selection {*/
  75. /* background-color: #f8f9fa;*/
  76. /* !*border-color: #f8f9fa;*!*/
  77. /* border: 1px solid #f8f9fa;*/
  78. /*}*/
  79. /*.select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered:focus{*/
  80. /* box-shadow: 0 0 0 0.2rem rgba(216,217,219,.5);*/
  81. /*}*/
  82. /*.select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered:hover {*/
  83. /* background-color: #e2e6ea;*/
  84. /* border-color: #dae0e5;*/
  85. /*}*/
  86. .select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered {
  87. line-height: calc(1.1em + .75rem);
  88. /*color: #007bff!important;*/
  89. border-radius: 0.2rem;
  90. /*background-color: #f8f9fa;*/
  91. /*border-color: #f8f9fa;*/
  92. }
  93. .select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow b {
  94. border-color: #007bff transparent transparent transparent;
  95. border-width: 4px 3.7px 0;
  96. }
  97. .select2-search--dropdown .select2-search__field {
  98. padding: 0.175rem 0.5rem;
  99. }
  100. </style>
  101. <div class="form-group">
  102. <label>关联变更方案</label>
  103. <select class="form-control form-control-sm" id="plan-code">
  104. <option></option>
  105. <% for (const cp of changePlanList) { %>
  106. <% if (ctx.helper._.indexOf(apLists, cp.code) === -1) { %>
  107. <option><%- cp.code %></option>
  108. <% } %>
  109. <% } %>
  110. </select>
  111. </div>
  112. <input value="" type="hidden" id="bj-name">
  113. <% } else { %>
  114. <div class="form-group">
  115. <label>变更工程名称<b class="text-danger">*</b></label>
  116. <input class="form-control form-control-sm" value="" type="text" id="bj-name">
  117. <div class="invalid-feedback" style="display: none" id="name_error_msg">名称超过100个字,请缩减名称。</div>
  118. </div>
  119. <input type="hidden" value="" id="plan-code">
  120. <% } %>
  121. </div>
  122. <div class="modal-footer">
  123. <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal" id="addCancel">关闭</button>
  124. <a href="javascript: void(0)" class="btn btn-primary btn-sm" id="addOk">确认新建</a>
  125. </div>
  126. </div>
  127. </div>
  128. </div>
  129. <!--设置-->
  130. <div class="modal fade" id="setting" data-backdrop="static">
  131. <div class="modal-dialog" role="document">
  132. <div class="modal-content">
  133. <div class="modal-header">
  134. <h5 class="modal-title">变更令设置</h5>
  135. </div>
  136. <div class="modal-body">
  137. <ul class="nav nav-tabs mb-3" role="tablist">
  138. <li class="nav-item">
  139. <a class="nav-link active" data-toggle="tab" href="#bianhao" role="tab" aria-controls="home" aria-selected="true">编号规则</a>
  140. </li>
  141. </ul>
  142. <div class="tab-content">
  143. <div class="tab-pane active" id="bianhao">
  144. <h5>
  145. 当前规则:
  146. <span id="preview">
  147. <% if (codeRule && codeRule instanceof Array) { %>
  148. <% const preview = []; %>
  149. <% for (const rule of codeRule) { %>
  150. <% preview.push(rule.preview); %>
  151. <% } %>
  152. <%- preview.join(tender.c_connector !== null && tender.c_connector !== '3' ? ruleConst.connectorString[tender.c_connector] : ''); %>
  153. <% } %>
  154. </span>
  155. </h5>
  156. <h5 id="ruleParts">
  157. <% if (codeRule && codeRule instanceof Array) { %>
  158. <% for (const rule of codeRule) { %>
  159. <span class="badge badge-light" title="<%- ruleConst.ruleString[rule.rule_type] %>">
  160. <span>
  161. <%- rule.preview %>
  162. </span>
  163. <a href="javascript: void(0);" class="text-danger" title="移除"><i class="fa fa-remove"></i></a>
  164. </span>
  165. <% } %>
  166. <% } %>
  167. </h5>
  168. <h5 class="my-3">连接符</h5>
  169. <div class="form-group">
  170. <select class="form-control form-control-sm connector-change">
  171. <option disabled selected>请选择</option>
  172. <% for (const index in ruleConst.connectorString) { %>
  173. <option value="<%- index %>" <% if (tender.c_connector !== null && tender.c_connector === parseInt(index)) { %>selected<% } %>><%- ruleConst.connectorString[index] %></option>
  174. <% } %>
  175. </select>
  176. </div>
  177. <h5 class="my-3">添加新规则组件</h5>
  178. <div class="form-group">
  179. <select class="form-control form-control-sm rule-change">
  180. <option disabled selected>请选择组件</option>
  181. <% for (const index in ruleConst.ruleString) { %>
  182. <option value="<%- index %>"><%- ruleConst.ruleString[index] %></option>
  183. <% } %>
  184. </select>
  185. </div>
  186. <div class="form-group" id="format" style="display: none">
  187. <label>自动编号位数</label>
  188. <input min="3" class="form-control form-control-sm" step="1" max="6" value="3" type="number">
  189. </div>
  190. <div class="form-group" id="text" style="display: none">
  191. <label>起始编号</label>
  192. <input class="form-control form-control-sm" value="001" type="text">
  193. </div>
  194. <button class="btn btn-sm btn-outline-primary" id="addRule">添加组件</button>
  195. </div>
  196. </div>
  197. </div>
  198. <div class="modal-footer">
  199. <% if (tender.c_rule_first) { %><button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal" id="changeFirst">暂时不需要</button><% } %>
  200. <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal" id="hide_modal" <% if (tender.c_rule_first) { %>style="display: none"<% } %>>关闭</button>
  201. <button type="button" class="btn btn-primary btn-sm" id="setRule">确定添加</button>
  202. </div>
  203. </div>
  204. </div>
  205. </div>
  206. <!--批量上报变更令-->
  207. <div class="modal fade" id="batch-sb" data-backdrop="static" style="">
  208. <div class="modal-dialog modal-lg" style="max-width:1100px;" role="document">
  209. <div class="modal-content">
  210. <div class="modal-header">
  211. <h5 class="modal-title">批量上报变更令</h5>
  212. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  213. <span aria-hidden="true">&times;</span>
  214. </button>
  215. </div>
  216. <div class="modal-body">
  217. <div class="row">
  218. <!-- 左侧变更令 -->
  219. <div class="col-6" >
  220. <div class="modal-height-500" style="overflow-y:auto;">
  221. <table class="table table-hover table-bordered">
  222. <thead>
  223. <tr>
  224. <th width="15%" class="text-center"><div class="align-middle"><input id="select-all-uncheck" type="checkbox"></div></th>
  225. <th width="40%">变更令编号</th>
  226. <th width="">原审批流程</th>
  227. </tr>
  228. </thead>
  229. <tbody id="uncheck_list">
  230. </tbody>
  231. </table>
  232. </div>
  233. </div>
  234. <!-- 右侧新审批流程 -->
  235. <div class="col-6">
  236. <div class=" ml-auto">
  237. <div class="dropdown text-right" id="show-audit-select">
  238. </div>
  239. <div class="card mt-1">
  240. <div class="card-header">
  241. 审批流程
  242. </div>
  243. <div class="modal-height-500" style="overflow-y:auto;">
  244. <ul class="list-group list-group-flush" id="auditList">
  245. </ul>
  246. </div>
  247. </div>
  248. </div>
  249. </div>
  250. </div>
  251. <div class="alert alert-warning mt-2 mb-0">批量操作会覆盖原审批流程,请合理选择。</div>
  252. </div>
  253. <div class="modal-footer">
  254. <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
  255. <button class="btn btn-sm btn-primary" id="batch_uncheck_btn">确定</button>
  256. </div>
  257. </div>
  258. </div>
  259. </div>
  260. <!--批量上报变更令进度条modal-->
  261. <div class="modal fade" id="batch-sb-progress" data-backdrop="static" style="">
  262. <div class="modal-dialog" role="document">
  263. <div class="modal-content">
  264. <div class="modal-header">
  265. <h5 class="modal-title">批量上报变更令</h5>
  266. </div>
  267. <div class="modal-body">
  268. <div class="progress">
  269. <div class="progress-tz-bar progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 100%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
  270. </div>
  271. <div class="mt-1 progress-tz-text">台账获取并处理中...</div>
  272. <div class="change-progress">
  273. </div>
  274. </div>
  275. <div class="modal-footer" style="display: none">
  276. <button class="btn btn-sm btn-primary" onclick="window.location.reload();">刷新页面</button>
  277. </div>
  278. </div>
  279. </div>
  280. </div>
  281. <% } %>
  282. <!--批量审批变更令-->
  283. <div class="modal fade" id="batch-sp" data-backdrop="static" style="">
  284. <div class="modal-dialog modal-lg" role="document">
  285. <div class="modal-content">
  286. <div class="modal-header">
  287. <h5 class="modal-title">批量审批变更令</h5>
  288. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  289. <span aria-hidden="true">&times;</span>
  290. </button>
  291. </div>
  292. <div class="modal-body">
  293. <div class="modal-height-500" style="overflow-y:auto;">
  294. <table class="table table-hover table-bordered">
  295. <thead>
  296. <tr>
  297. <th width="5%"><div class="align-middle text-center"><input type="checkbox" id="select-all-checking"></div></th>
  298. <th width="25%">变更令编号</th>
  299. <th width="">变更令名称</th>
  300. <th width="25%">批量编号</th>
  301. </tr>
  302. </thead>
  303. <tbody id="checking_list">
  304. </tbody>
  305. </table>
  306. </div>
  307. </div>
  308. <div class="modal-footer">
  309. <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
  310. <button type="button" class="btn btn-sm btn-primary" id="batch_checking_btn">确定</button>
  311. </div>
  312. </div>
  313. </div>
  314. </div>
  315. <!--批量审批变更令进度条modal-->
  316. <div class="modal fade" id="batch-sp-progress" data-backdrop="static" style="">
  317. <div class="modal-dialog" role="document">
  318. <div class="modal-content">
  319. <div class="modal-header">
  320. <h5 class="modal-title">批量审批变更令</h5>
  321. </div>
  322. <div class="modal-body">
  323. <div class="progress">
  324. <div class="progress-tz-bar progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 100%" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100"></div>
  325. </div>
  326. <div class="mt-1 progress-tz-text">台账获取并处理中...</div>
  327. <div class="change-progress">
  328. </div>
  329. </div>
  330. <div class="modal-footer" style="display: none">
  331. <button class="btn btn-sm btn-primary" onclick="window.location.reload();">刷新页面</button>
  332. </div>
  333. </div>
  334. </div>
  335. </div>
  336. <script>
  337. const ruleType = <%- ruleType %>;
  338. const ruleConst = JSON.parse('<%- JSON.stringify(ruleConst) %>');
  339. let codeRule = JSON.parse('<%- JSON.stringify(codeRule) %>');
  340. let connectorRule = '<%- tender.c_connector %>';
  341. let cRuleFirst = '<%- tender.c_rule_first %>';
  342. const tenderId = '<%- ctx.tender.id %>';
  343. const auditConst = JSON.parse(unescape('<%- escape(JSON.stringify(auditConst)) %>'));
  344. const auditType = JSON.parse('<%- JSON.stringify(auditType) %>');
  345. $('#audit-list').on('click', 'a', function() {
  346. const type = $(this).data('target')
  347. const auditCard = $(this).parent().parent()
  348. if (type === 'show') {
  349. $(this).data('target', 'hide')
  350. auditCard.find('.fold-card').slideDown('swing', () => {
  351. auditCard.find('#end-target').text($(this).data('idx') + '#')
  352. auditCard.find('#fold-btn').text('收起历史审核记录')
  353. })
  354. } else {
  355. $(this).data('target', 'show')
  356. auditCard.find('.fold-card').slideUp('swing', () => {
  357. auditCard.find('#end-target').text('1#')
  358. auditCard.find('#fold-btn').text('展开历史审核记录')
  359. })
  360. }
  361. });
  362. </script>
  363. <script src="/public/js/moment/moment.min.js"></script>
  364. <script src="/public/js/decimal.min.js"></script>
  365. <script src="/public/js/zh_calc.js"></script>
  366. <script src="/public/js/path_tree.js"></script>
  367. <script src="/public/js/gcl_gather.js"></script>
  368. <script>
  369. const shenpiConst = JSON.parse(unescape('<%- escape(JSON.stringify(shenpiConst)) %>'));
  370. const precision = JSON.parse('<%- JSON.stringify(precision) %>');
  371. $(function () {
  372. const intervalIds = {};
  373. <% if (tender.user_id === ctx.session.sessionUser.accountId) { %>
  374. let this_cid = null;
  375. let shenpi_status = shenpiConst.sp_status.sqspr;
  376. let accountList, accountGroup;
  377. let uncheckList = [];
  378. // 批量上报变更令部分
  379. $('#batch-sb').on('show.bs.modal', function () {
  380. postData(`/tender/${tenderId}/change/batch/fun`, { type: 'get_report_list' }, function (res) {
  381. let html = '';
  382. $('#select-all-uncheck').prop('checked', false);
  383. shenpi_status = res.shenpi_status;
  384. uncheckList = res.uncheckList;
  385. for (const l of res.uncheckList) {
  386. html += '<tr>' +
  387. `<td class="text-center"><input type="checkbox" value="${l.cid}"></td>` +
  388. `<td class=""><a href="/tender/${tenderId}/change/${l.cid}/information" target="_blank">${l.code}</a></td>` +
  389. '<td>' + setAuditList(l.auditList) +'</td>' +
  390. '</tr>';
  391. }
  392. $('#uncheck_list').html(html);
  393. if (res.uncheckList.length > 0) {
  394. $('#uncheck_list tr').eq(0).addClass('table-warning');
  395. this_cid = res.uncheckList[0].cid;
  396. makeSpList(res.uncheckList[0].auditList);
  397. } else {
  398. $('#uncheck_list tr').removeClass('table-warning');
  399. this_cid = null;
  400. makeSpList([]);
  401. }
  402. let showAuditSelectHtml = '';
  403. if (res.spGroupList && res.spGroupList.length > 0 && shenpi_status === shenpiConst.sp_status.gdspl) {
  404. let optionHtml = '';
  405. for (const g of res.spGroupList) { %>
  406. optionHtml += `<option value="${g.id}" ${res.uncheckList.length > 0 && g.id === res.uncheckList[0].sp_group ? 'selected' : ''}>${g.name}</option>`;
  407. }
  408. showAuditSelectHtml += '<div class="row">' +
  409. '<div class="col-7"></div>' +
  410. '<div class="col-5">' +
  411. '<select class="form-control form-control-sm change-sp-group">' + optionHtml + '</select>' +
  412. '</div></div>';
  413. } else {
  414. accountList = res.accountList;
  415. accountGroup = res.accountGroup;
  416. showAuditSelectHtml += getSelectAuditHtml('report');
  417. }
  418. $('#show-audit-select').html(showAuditSelectHtml);
  419. })
  420. });
  421. function setAuditList(auditList) {
  422. let html = [];
  423. // 去除原报
  424. if (auditList.length > 1) {
  425. for (const [i,a] of auditList.entries()) {
  426. if (i === 0) continue;
  427. const oneAuditNames = _.map(a, 'name');
  428. let names = oneAuditNames.join('、');
  429. if (oneAuditNames.length > 1) {
  430. names = (a[0].audit_type === auditType.key.and ? '(会)' : (a[0].audit_type === auditType.key.or ? '(或)' : '')) + names;
  431. }
  432. html.push(names);
  433. }
  434. }
  435. return html.join('-');
  436. }
  437. function getSelectAuditHtml(code) {
  438. let divhtml = '';
  439. accountGroup.forEach((group, idx) => {
  440. let didivhtml = '';
  441. if(group) {
  442. group.groupList.forEach(item => {
  443. didivhtml += '<dd class="border-bottom p-2 mb-0 " data-id="' + item.id + '" >\n' +
  444. '<p class="mb-0 d-flex"><span class="text-primary">' + item.name + '</span><span\n' +
  445. ' class="ml-auto">' + item.mobile + '</span></p>\n' +
  446. ' <span class="text-muted">' + item.role + '</span>\n' +
  447. ' </dd>\n';
  448. });
  449. divhtml += '<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="' + idx + '" data-type="hide"><i class="fa fa-plus-square"></i></a> ' + group.groupName + '</dt>\n' +
  450. ' <div class="dd-content" data-toggleid="' + idx + '">\n' + didivhtml +
  451. ' </div>\n';
  452. }
  453. });
  454. const html =
  455. ' <button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button" id="' + code + '_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">\n' +
  456. ' 添加审批流程\n' +
  457. ' </button>\n' +
  458. ' <div class="dropdown-menu dropdown-menu-right" id="' + code + '_dropdownMenu" aria-labelledby="' + code + '_dropdownMenuButton" style="width:220px">\n' +
  459. ' <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search"\n' +
  460. ' placeholder="姓名/手机 检索" autocomplete="off" data-code="' + code + '"></div>\n' +
  461. ' <dl class="list-unstyled book-list">\n' + divhtml +
  462. ' </dl>\n' +
  463. ' </div>\n';
  464. return html;
  465. }
  466. // uncheckList tr 切换
  467. $('#uncheck_list').on('click', 'tr', function () {
  468. $('#uncheck_list tr').removeClass('table-warning');
  469. $(this).addClass('table-warning');
  470. this_cid = $(this).find('a').attr('href').split('/')[4];
  471. makeSpList(uncheckList.find(l => l.cid === this_cid).auditList);
  472. });
  473. $('#uncheck_list').on('click', 'input[type="checkbox"]', function (e) {
  474. e.stopPropagation();
  475. });
  476. // uncheckList tr全选
  477. $('#select-all-uncheck').click(function () {
  478. $('#uncheck_list tr').find('input[type="checkbox"]').prop('checked', $(this).prop('checked'));
  479. });
  480. let timer = null;
  481. let oldSearchVal = null;
  482. $('body').on('input propertychange', 'div[id$="_dropdownMenu"] .gr-search', function(e) {
  483. oldSearchVal = e.target.value;
  484. timer && clearTimeout(timer);
  485. timer = setTimeout(() => {
  486. const newVal = $(this).val();
  487. const code = $(this).attr('data-code');
  488. let html = '';
  489. if (newVal && newVal === oldSearchVal) {
  490. accountList.filter(item => item && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
  491. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  492. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  493. class="ml-auto">${item.mobile || ''}</span></p>
  494. <span class="text-muted">${item.role || ''}</span>
  495. </dd>`;
  496. });
  497. $('#' + code + '_dropdownMenu .book-list').empty();
  498. $('#' + code + '_dropdownMenu .book-list').append(html);
  499. } else {
  500. if (!$('#' + code + '_dropdownMenu .acc-btn').length) {
  501. accountGroup.forEach((group, idx) => {
  502. if (!group) return;
  503. html += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>
  504. </a> ${group.groupName}</dt>
  505. <div class="dd-content" data-toggleid="${idx}">`;
  506. group.groupList.forEach(item => {
  507. // if (item.id !== changesUid) {
  508. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  509. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  510. class="ml-auto">${item.mobile || ''}</span></p>
  511. <span class="text-muted">${item.role || ''}</span>
  512. </dd>`;
  513. // }
  514. });
  515. html += '</div>';
  516. });
  517. $('#' + code + '_dropdownMenu .book-list').empty();
  518. $('#' + code + '_dropdownMenu .book-list').append(html);
  519. }
  520. }
  521. }, 400);
  522. });
  523. // 添加审批流程按钮逻辑
  524. $('body').on('click', 'div[id$="_dropdownMenu"] .book-list dt', function () {
  525. const idx = $(this).find('.acc-btn').attr('data-groupid');
  526. const type = $(this).find('.acc-btn').attr('data-type');
  527. if (type === 'hide') {
  528. $(this).parent().find(`div[data-toggleid="${idx}"]`).show(() => {
  529. $(this).children().find('i').removeClass('fa-plus-square').addClass('fa-minus-square-o');
  530. $(this).find('.acc-btn').attr('data-type', 'show');
  531. })
  532. } else {
  533. $(this).parent().find(`div[data-toggleid="${idx}"]`).hide(() => {
  534. $(this).children().find('i').removeClass('fa-minus-square-o').addClass('fa-plus-square');
  535. $(this).find('.acc-btn').attr('data-type', 'hide');
  536. })
  537. }
  538. return false;
  539. });
  540. // 添加到审批流程中
  541. $('body').on('click', 'div[id$="_dropdownMenu"] dl dd', function () {
  542. const id = parseInt($(this).data('id'));
  543. if (!this_cid) {
  544. toastr.error('请选择变更令');
  545. return false;
  546. }
  547. if (id !== 0) {
  548. postData('/tender/' + tenderId + '/change/' + this_cid + '/information/audit/add', { auditorId: id }, (datas) => {
  549. makeSpList(datas);
  550. const index = uncheckList.findIndex(item => item.cid === this_cid);
  551. if (index !== -1) {
  552. uncheckList[index].auditList = datas;
  553. $('#uncheck_list tr').eq(index).children('td').eq(2).html(setAuditList(datas));
  554. }
  555. });
  556. }
  557. });
  558. // 移除审批流程的审批人
  559. $('body').on('click', '#auditList li a', function () {
  560. const uid = $(this).parents('li').attr('data-auditid');
  561. const li = $(this).parents('li');
  562. const data = {
  563. auditorId: uid,
  564. };
  565. if (!this_cid) {
  566. toastr.error('请选择变更令');
  567. return false;
  568. }
  569. postData('/tender/' + tenderId + '/change/' + this_cid + '/information/audit/delete', data, (datas) => {
  570. li.remove();
  571. let liIndex = 1;
  572. $('#auditList li').each(function () {
  573. $(this).children('.col-auto').eq(0).text(liIndex);
  574. liIndex++;
  575. });
  576. const index = uncheckList.findIndex(item => item.cid === this_cid);
  577. if (index !== -1) {
  578. uncheckList[index].auditList = datas;
  579. $('#uncheck_list tr').eq(index).children('td').eq(2).html(setAuditList(datas));
  580. }
  581. });
  582. });
  583. // 切换审批组
  584. $('body').on('change', '.change-sp-group', function () {
  585. const data = {
  586. type: 'change_sp_group',
  587. sp_group: parseInt($(this).val()),
  588. }
  589. if (!this_cid) {
  590. toastr.error('请选择变更令');
  591. return false;
  592. }
  593. if (!data.sp_group) {
  594. toastr.error('请选择固定审批组');
  595. return false;
  596. }
  597. console.log(data);
  598. postData('/tender/' + tenderId + '/change/' + this_cid + '/information/audit/spgroup', data, (datas) => {
  599. makeSpList(datas);
  600. const index = uncheckList.findIndex(item => item.cid === this_cid);
  601. if (index !== -1) {
  602. uncheckList[index].auditList = datas;
  603. $('#uncheck_list tr').eq(index).children('td').eq(2).html(setAuditList(datas));
  604. }
  605. });
  606. });
  607. function makeSpList(datas) {
  608. const html = [];
  609. // 如果是重新上报,添加到重新上报列表中
  610. const auditorshtml = [];
  611. if (datas.length > 0) {
  612. for (const [index,data] of datas.entries()) {
  613. if (index !== 0) {
  614. html.push('<li class="list-group-item d-flex" data-auditid="'+ data[0].uid +'">');
  615. html.push(`<div class="col-auto">${index}</div>`);
  616. html.push('<div class="col">');
  617. for (const auditor of data) {
  618. html.push(`<div class="d-inline-block mx-1" auditorId="${auditor.uid}"><i class="fa fa-user text-muted"></i> ${auditor.name} <small class="text-muted">${auditor.role}</small></div>`);
  619. }
  620. html.push('</div>');
  621. html.push('<div class="col-auto">');
  622. // todo 添加会签或签时
  623. if (data[0].audit_type !== auditType.key.common) {
  624. html.push(`<span class="badge badge-pill badge-${auditType.info[data[0].audit_type].class} badge-bg-small"><small>${auditType.info[data[0].audit_type].long}</small></span>`);
  625. }
  626. if (shenpi_status === shenpiConst.sp_status.sqspr || (shenpi_status === shenpiConst.sp_status.gdzs && index+1 !== datas.length)) {
  627. html.push('<a href="javascript: void(0)" class="text-danger pull-right">移除</a>');
  628. }
  629. html.push('</div>');
  630. html.push('</li>');
  631. }
  632. }
  633. }
  634. $('#auditList').html(html.join(''));
  635. }
  636. $('#batch_uncheck_btn').click(function () {
  637. // 至少勾选一个
  638. if ($('#uncheck_list input:checked').length === 0) {
  639. toastr.error('请至少勾选一个变更令');
  640. return false;
  641. }
  642. const cids = [];
  643. $('#uncheck_list input:checked').each(function () {
  644. cids.push($(this).val());
  645. });
  646. $('#batch-sb').modal('hide');
  647. $('#batch-sb-progress').modal('show');
  648. $('#batch-sb-progress .progress-tz-bar').css('width', '0%');
  649. $('#batch-sb-progress .modal-footer').hide();
  650. setProgress($('#batch-sb-progress .progress-tz-bar'), 30, 'tz1');
  651. $('#batch-sb-progress .progress-tz-text').text('台账数据获取中...').removeClass('text-success');
  652. let changeListData;
  653. let gclGatherData;
  654. postData('/tender/' + tenderId + '/change/defaultBills', { form: 'batch' }, async function (result) {
  655. gclGatherModel.loadLedgerData(result.bills);
  656. gclGatherModel.loadPosData(result.pos);
  657. gclGatherData = gclGatherModel.gatherGclData();
  658. gclGatherData = _.filter(gclGatherData, function (item) {
  659. return item.leafXmjs && item.leafXmjs.length !== 0;
  660. });
  661. for (const ggd in gclGatherData) {
  662. if (gclGatherData[ggd].leafXmjs && gclGatherData[ggd].leafXmjs.length === 0) {
  663. gclGatherData.splice(ggd, 1);
  664. }
  665. gclGatherData[ggd].code = gclGatherData[ggd].b_code;
  666. let hadcid = 0;
  667. for (const xmj of gclGatherData[ggd].leafXmjs) {
  668. const changeLedger = _.find(result.changeLedgerList, { id: xmj.gcl_id });
  669. const changePos = _.find(result.changePosList, { id: xmj.mx_id, lid: xmj.gcl_id });
  670. if (changeLedger || changePos) {
  671. xmj.cid = 1;
  672. xmj.ccid = changeLedger ? changeLedger.ccid : changePos.ccid;
  673. hadcid = 1;
  674. }
  675. }
  676. if (hadcid !== 0) gclGatherData[ggd].cid = 1;
  677. }
  678. // console.log(gclGatherData);
  679. // 数组去重
  680. const dealBillList = result.dealBills;
  681. for (const db of gclGatherData) {
  682. const exist_index = dealBillList.findIndex(function (item) {
  683. return item.code === db.code && item.name === db.name && item.unit === db.unit && item.unit_price === db.unit_price;
  684. });
  685. if (exist_index !== -1) {
  686. dealBillList.splice(exist_index, 1);
  687. }
  688. }
  689. changeListData = gclGatherData.concat(dealBillList).sort(sortByCode);
  690. console.log(changeListData);
  691. stopProgress($('#batch-sb-progress .progress-tz-bar'), 'tz1');
  692. $('#batch-sb-progress .progress-tz-text').text('台账数据加载完成').addClass('text-success');
  693. $('#batch-sb-progress .change-progress').html('');
  694. for (const c of cids) {
  695. const cInfo = uncheckList.find(item => item.cid === c);
  696. if (cInfo) {
  697. $('#batch-sb-progress .change-progress').append(`<div id="change-${cInfo.cid}-progress"><div class="mt-3 progress">` +
  698. '<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 0%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>' +
  699. '</div>' +
  700. `<div class="mt-1">变更令 <b>${cInfo.code}</b> <span class="progress-change-text">上报处理中...</span></div></div>`);
  701. await checkAndChange(cInfo, changeListData, result.changeLedgerList);
  702. }
  703. }
  704. $('#batch-sb-progress .modal-footer').show();
  705. });
  706. });
  707. <% } %>
  708. let checkingList = [];
  709. $('#batch-sp').on('show.bs.modal', function () {
  710. postData(`/tender/${tenderId}/change/batch/fun`, { type: 'get_shenpi_list' }, function (res) {
  711. let html = '';
  712. $('#select-all-checking').prop('checked', false);
  713. checkingList = res.checkingList;
  714. for (const l of res.checkingList) {
  715. const finalHtml = l.is_finalAudit ? `<input type="text" class="form-control form-control-sm final_pcode_input" data-cid="${l.cid}" value="${l.p_code}" />` : '';
  716. html += '<tr>' +
  717. `<td class="text-center"><input type="checkbox" value="${l.cid}"></td>` +
  718. `<td class=""><a href="/tender/${tenderId}/change/${l.cid}/information" target="_blank">${l.code}</a></td>` +
  719. `<td>${l.name}</td>` +
  720. `<td>${finalHtml}</td>` +
  721. '</tr>';
  722. }
  723. $('#checking_list').html(html);
  724. });
  725. });
  726. $('body').on('change', '.final_pcode_input', function () {
  727. const cid = $(this).data('cid');
  728. const cInfo = checkingList.find(item => item.cid === cid);
  729. cInfo.p_code = $(this).val();
  730. });
  731. $('#checking_list').on('click', 'input[type="checkbox"]', function (e) {
  732. e.stopPropagation();
  733. });
  734. // uncheckList tr全选
  735. $('#select-all-checking').click(function () {
  736. $('#checking_list tr').find('input[type="checkbox"]').prop('checked', $(this).prop('checked'));
  737. });
  738. $('#batch_checking_btn').click(function () {
  739. // 至少勾选一个
  740. if ($('#checking_list input:checked').length === 0) {
  741. toastr.error('请至少勾选一个变更令');
  742. return false;
  743. }
  744. const cids = [];
  745. $('#checking_list input:checked').each(function () {
  746. cids.push($(this).val());
  747. });
  748. $('#batch-sp').modal('hide');
  749. $('#batch-sp-progress').modal('show');
  750. $('#batch-sp-progress .progress-tz-bar').css('width', '0%');
  751. $('#batch-sp-progress .modal-footer').hide();
  752. setProgress($('#batch-sp-progress .progress-tz-bar'), 30, 'tz2');
  753. $('#batch-sp-progress .progress-tz-text').text('台账数据获取中...').removeClass('text-success');
  754. let changeListData;
  755. let gclGatherData;
  756. postData('/tender/' + tenderId + '/change/defaultBills', { from: 'batch' }, async function (result) {
  757. gclGatherModel.loadLedgerData(result.bills);
  758. gclGatherModel.loadPosData(result.pos);
  759. gclGatherData = gclGatherModel.gatherGclData();
  760. gclGatherData = _.filter(gclGatherData, function (item) {
  761. return item.leafXmjs && item.leafXmjs.length !== 0;
  762. });
  763. for (const ggd in gclGatherData) {
  764. if (gclGatherData[ggd].leafXmjs && gclGatherData[ggd].leafXmjs.length === 0) {
  765. gclGatherData.splice(ggd, 1);
  766. }
  767. gclGatherData[ggd].code = gclGatherData[ggd].b_code;
  768. let hadcid = 0;
  769. for (const xmj of gclGatherData[ggd].leafXmjs) {
  770. const changeLedger = _.find(result.changeLedgerList, { id: xmj.gcl_id });
  771. const changePos = _.find(result.changePosList, { id: xmj.mx_id, lid: xmj.gcl_id });
  772. if (changeLedger || changePos) {
  773. xmj.cid = 1;
  774. xmj.ccid = changeLedger ? changeLedger.ccid : changePos.ccid;
  775. hadcid = 1;
  776. }
  777. }
  778. if (hadcid !== 0) gclGatherData[ggd].cid = 1;
  779. }
  780. // console.log(gclGatherData);
  781. // 数组去重
  782. const dealBillList = result.dealBills;
  783. for (const db of gclGatherData) {
  784. const exist_index = dealBillList.findIndex(function (item) {
  785. return item.code === db.code && item.name === db.name && item.unit === db.unit && item.unit_price === db.unit_price;
  786. });
  787. if (exist_index !== -1) {
  788. dealBillList.splice(exist_index, 1);
  789. }
  790. }
  791. changeListData = gclGatherData.concat(dealBillList).sort(sortByCode);
  792. console.log(changeListData);
  793. stopProgress($('#batch-sp-progress .progress-tz-bar'), 'tz2');
  794. $('#batch-sp-progress .progress-tz-text').text('台账数据加载完成').addClass('text-success');
  795. $('#batch-sp-progress .change-progress').html('');
  796. for (const c of cids) {
  797. const cInfo = checkingList.find(item => item.cid === c);
  798. if (cInfo) {
  799. $('#batch-sp-progress .change-progress').append(`<div class="mt-3" id="change-${cInfo.cid}-progress"><div>变更令 <a href="/tender/${cInfo.tid}/change/${cInfo.cid}/information" target="_blank"><b>${cInfo.code}</b></a> :</div><div class="progress">` +
  800. '<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" style="width: 0%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>' +
  801. '</div>' +
  802. `<div class="mt-1"><span class="progress-change-text">审批处理中...</span></div></div>`);
  803. await checkAndChange(cInfo, changeListData, result.changeLedgerList, 'checking');
  804. }
  805. }
  806. $('#batch-sp-progress .modal-footer').show();
  807. }, function (res) {
  808. }, false);
  809. });
  810. let value = 0;
  811. // let interval;
  812. let stop = false;
  813. function setProgress(_this, time = 50, name) {
  814. let intervalId = setInterval(function () {
  815. if (value < 100) {
  816. value = parseInt(value) + 1;
  817. _this.css("width", value + "%").text(value + "%");
  818. } else if (value === 100) {
  819. value = parseInt(value) + 1;
  820. value = 30;
  821. }
  822. }, time);
  823. intervalIds[name] = intervalId;
  824. }
  825. function resetProgress(_this) {
  826. _this.removeClass('bg-success');
  827. _this.css("width", "0%").text("0%").attr('aria-valuenow', '0');
  828. }
  829. function failProgress(_this, name) {
  830. if (intervalIds[name]) {
  831. _this.addClass('bg-danger');
  832. _this.css("width", "100%").text("失败");
  833. value = 0;
  834. stop = true;
  835. clearInterval(intervalIds[name]);
  836. intervalIds[name] = 0;
  837. }
  838. }
  839. function stopProgress(_this, name) {
  840. if (intervalIds[name]) {
  841. _this.addClass('bg-success');
  842. _this.css("width", "100%").text("100%");
  843. value = 0;
  844. stop = true;
  845. clearInterval(intervalIds[name]);
  846. intervalIds[name] = 0;
  847. }
  848. }
  849. async function checkAndChange(cInfo, changeListData, changeLedgerList, status = 'uncheck') {
  850. setProgress($(`#change-${cInfo.cid}-progress .progress-bar`), 30, `change-${cInfo.cid}`);
  851. // 根据已添加的清单显示
  852. if (cInfo.changeList.length > 0 && cInfo.changeList[0]) {
  853. const removeList = [];
  854. const updateList = [];
  855. const updateGclIdList = [];
  856. for (const [index,clinfo] of cInfo.changeList.entries()) {
  857. if (clinfo.lid != 0) {
  858. let listinfo = changeListData.find(function (item) {
  859. return (item.id !== undefined && item.id == clinfo.lid) || (item.id === undefined && item.leafXmjs !== undefined && item.leafXmjs.length !== 0 && item.leafXmjs[0].gcl_id == clinfo.lid);
  860. });
  861. if (listinfo === undefined || (clinfo.lid && clinfo.gcl_id && clinfo.lid !== clinfo.gcl_id)) {
  862. // 有可能这部分台账发生变化,此时要更新清单lid信息,防止数据丢失
  863. const newlistinfo = changeListData.find(function (item) {
  864. return (item.id !== undefined && item.id == clinfo.gcl_id) || (item.id === undefined && item.leafXmjs !== undefined && item.leafXmjs.length !== 0 && _.find(item.leafXmjs, {gcl_id: clinfo.gcl_id }));
  865. });
  866. if ((listinfo === undefined && newlistinfo) || (listinfo && newlistinfo && !isObjEqual(listinfo, newlistinfo))) {
  867. listinfo = newlistinfo;
  868. updateList.push({id: clinfo.id, lid: newlistinfo.leafXmjs[0].gcl_id});
  869. // 更新lid
  870. cInfo.changeList[index].lid = newlistinfo.leafXmjs[0].gcl_id;
  871. }
  872. }
  873. if (listinfo === undefined) {
  874. // 针对旧数据获取清单信息
  875. listinfo = changeListData[clinfo.lid - 1];
  876. if (listinfo === undefined) {
  877. removeList.push(clinfo);
  878. break;
  879. }
  880. }
  881. const [info, needUpdate] = makePushBwmx(clinfo, listinfo, removeList, updateList);
  882. if (needUpdate) break;
  883. if (_.findIndex(changeLedgerList, { id: clinfo.gcl_id }) !== -1) {
  884. // 可能因为升降级关系:细目,分部分项等会发生变化,更新清单
  885. const updateInfo = {};
  886. if (info.code !== clinfo.xmj_code) {
  887. updateInfo.xmj_code = info.code;
  888. // changeList[index].xmj_code = info.code;
  889. }
  890. if (info.jldy !== clinfo.xmj_jldy) {
  891. updateInfo.xmj_jldy = info.jldy;
  892. // changeList[index].xmj_jldy = info.jldy;
  893. }
  894. if (info.dwgc !== clinfo.xmj_dwgc) {
  895. updateInfo.xmj_dwgc = info.dwgc;
  896. // changeList[index].xmj_dwgc = info.dwgc;
  897. }
  898. if (info.fbgc !== clinfo.xmj_fbgc) {
  899. updateInfo.xmj_fbgc = info.fbgc;
  900. // changeList[index].xmj_fbgc = info.fbgc;
  901. }
  902. if (info.fxgc !== clinfo.xmj_fxgc) {
  903. updateInfo.xmj_fxgc = info.fxgc;
  904. // changeList[index].xmj_fxgc = info.fxgc;
  905. }
  906. if (!_.isEmpty(updateInfo) && _.indexOf(updateGclIdList, clinfo.gcl_id) === -1) {
  907. updateGclIdList.push(clinfo.gcl_id);
  908. // updateInfo.gcl_id = info.id;
  909. updateList.push({ row: updateInfo, where: { tid: tenderId, gcl_id: clinfo.gcl_id } });
  910. break;
  911. }
  912. }
  913. }
  914. }
  915. await sleep(2000);
  916. if (updateList.length > 0 || removeList.length > 0) {
  917. console.log(updateList, removeList);
  918. failProgress($('#change-' + cInfo.cid + '-progress .progress-bar'), `change-${cInfo.cid}`);
  919. $('#change-' + cInfo.cid + '-progress .mt-1').addClass('text-danger');
  920. $('#change-' + cInfo.cid + '-progress .progress-change-text').text('清单数据发生变化,需要进入到详情页处理');
  921. return;
  922. }
  923. // 上报或审批变更令
  924. let ss = true;
  925. if (status === 'uncheck') {
  926. postDataWithAsync('/tender/' + tenderId + '/change/' + cInfo.cid + '/information/audit/start', {}, function () {
  927. }, function (res) {
  928. ss = false;
  929. failProgress($('#change-' + cInfo.cid + '-progress .progress-bar'), `change-${cInfo.cid}`);
  930. $('#change-' + cInfo.cid + '-progress .mt-1').addClass('text-danger');
  931. $('#change-' + cInfo.cid + '-progress .progress-change-text').text(res);
  932. return;
  933. }, false);
  934. } else {
  935. const pData = {
  936. change_id: cInfo.cid,
  937. w_code: cInfo.code,
  938. status: auditConst.status.checked,
  939. sdesc: '同意',
  940. }
  941. if (cInfo.is_finalAudit) {
  942. if (cInfo.p_code) {
  943. pData.p_code = cInfo.p_code;
  944. const postData2 = {
  945. p_code: cInfo.p_code,
  946. };
  947. let returnflag = true;
  948. postDataWithAsync('/tender/' + tenderId + '/change/' + cInfo.cid + '/check/codeRepeat',postData2, function (result) {
  949. }, function (data) {
  950. returnflag = false;
  951. });
  952. if (!returnflag) {
  953. failProgress($('#change-' + cInfo.cid + '-progress .progress-bar'), `change-${cInfo.cid}`);
  954. $('#change-' + cInfo.cid + '-progress .mt-1').addClass('text-danger');
  955. $('#change-' + cInfo.cid + '-progress .progress-change-text').text('批复编号不能与其它变更令重复!');
  956. return;
  957. }
  958. } else {
  959. failProgress($('#change-' + cInfo.cid + '-progress .progress-bar'), `change-${cInfo.cid}`);
  960. $('#change-' + cInfo.cid + '-progress .mt-1').addClass('text-danger');
  961. $('#change-' + cInfo.cid + '-progress .progress-change-text').text('变更令号(批复编号)不能为空!');
  962. return;
  963. }
  964. }
  965. postDataWithAsync('/tender/' + tenderId + '/change/approval', pData, function (result) {
  966. }, function (res) {
  967. ss = false;
  968. failProgress($('#change-' + cInfo.cid + '-progress .progress-bar'), `change-${cInfo.cid}`);
  969. $('#change-' + cInfo.cid + '-progress .mt-1').addClass('text-danger');
  970. $('#change-' + cInfo.cid + '-progress .progress-change-text').text(res);
  971. return;
  972. }, false);
  973. }
  974. if (ss) {
  975. stopProgress($('#change-' + cInfo.cid + '-progress .progress-bar'), `change-${cInfo.cid}`);
  976. $('#change-' + cInfo.cid + '-progress .mt-1').addClass('text-success');
  977. $('#change-' + cInfo.cid + '-progress .progress-change-text').text((status === 'uncheck' ? '上报' : '审批') + '成功');
  978. }
  979. }
  980. }
  981. const postDataWithAsync = function (url, data, successCallback, errorCallBack, showWaiting = true) {
  982. if (showWaiting) showWaitingView();
  983. $.ajax({
  984. type:"POST",
  985. url: url,
  986. data: {'data': JSON.stringify(data)},
  987. dataType: 'json',
  988. cache: false,
  989. async: false,
  990. timeout: 60000,
  991. beforeSend: function(xhr) {
  992. let csrfToken = Cookies.get('csrfToken_j');
  993. xhr.setRequestHeader('x-csrf-token', csrfToken);
  994. },
  995. success: function(result){
  996. if (result.err === 0) {
  997. if (successCallback) {
  998. successCallback(result.data);
  999. }
  1000. } else {
  1001. toastr.error(result.msg);
  1002. if (errorCallBack) {
  1003. errorCallBack(result.msg);
  1004. }
  1005. }
  1006. if (showWaiting) closeWaitingView();
  1007. },
  1008. error: function(jqXHR, textStatus, errorThrown){
  1009. toastr.error('error: ' + textStatus + " " + errorThrown);
  1010. if (errorCallBack) {
  1011. errorCallBack();
  1012. }
  1013. if (showWaiting) closeWaitingView();
  1014. }
  1015. });
  1016. };
  1017. function sleep(millisecond) {
  1018. return new Promise(resolve => {
  1019. setTimeout(() => {
  1020. resolve()
  1021. }, millisecond)
  1022. })
  1023. }
  1024. function isObjEqual(o1,o2){
  1025. var props1 = Object.getOwnPropertyNames(o1);
  1026. var props2 = Object.getOwnPropertyNames(o2);
  1027. if (props1.length != props2.length) {
  1028. return false;
  1029. }
  1030. for (var i = 0,max = props1.length; i < max; i++) {
  1031. var propName = props1[i];
  1032. if (o1[propName] !== o2[propName]) {
  1033. return false;
  1034. }
  1035. }
  1036. return true;
  1037. }
  1038. function makePushBwmx(clinfo, listinfo, removeList, updateList) {
  1039. let info = '';
  1040. let needUpdate = false;
  1041. const checkKey = ['name', 'code', 'unit', 'unit_price'];
  1042. const checkLeafKey = ['oamount', 'bwmx', 'code', 'dwgc', 'fbgc', 'fxgc', 'jldy'];
  1043. if (listinfo.leafXmjs !== undefined) {
  1044. const leafInfo = listinfo.leafXmjs.find(function (item) {
  1045. // const flag = (item.bwmx === undefined || item.bwmx === clinfo.bwmx || item.jldy === clinfo.bwmx) && item.gcl_id === clinfo.gcl_id && (!clinfo.mx_id || (item.mx_id && clinfo.mx_id && item.mx_id === clinfo.mx_id)) && (item.quantity !== null ? item.quantity === parseFloat(clinfo.oamount) : 0 === parseFloat(clinfo.oamount));
  1046. const flag = item.gcl_id === clinfo.gcl_id && (!clinfo.mx_id || (item.mx_id && clinfo.mx_id && item.mx_id === clinfo.mx_id));
  1047. if (flag && item.code === clinfo.xmj_code) {
  1048. return flag && item.code === clinfo.xmj_code;
  1049. }
  1050. return flag;
  1051. });
  1052. if (leafInfo) {
  1053. const oneUpdate = { id: clinfo.id };
  1054. // 判断要不要更新名称,单位,原数量,单价
  1055. checkKey.forEach(function (key) {
  1056. if (listinfo[key] !== clinfo[key]) {
  1057. oneUpdate[key] = listinfo[key];
  1058. // clinfo[key] = listinfo[key];
  1059. if (key === 'unit') {
  1060. const changeKey = ['oamount', 'oamount2', 'camount'];
  1061. changeKey.forEach(function (key) {
  1062. const value = ZhCalc.round(clinfo[key], findDecimal(listinfo[key]));
  1063. if (value !== clinfo[key]) {
  1064. oneUpdate[key] = value;
  1065. // clinfo[key] = value;
  1066. }
  1067. });
  1068. }
  1069. needUpdate = true;
  1070. }
  1071. });
  1072. checkLeafKey.forEach(function (key) {
  1073. // 只有数量是对比leafInfo,其它对比listinfo,且有些值需要重新计算
  1074. if (key === 'oamount') {
  1075. if (leafInfo.quantity !== clinfo[key]) {
  1076. oneUpdate[key] = leafInfo.quantity;
  1077. // clinfo[key] = leafInfo.quantity;
  1078. needUpdate = true;
  1079. }
  1080. } else if (key === 'bwmx') {
  1081. if (leafInfo[key] !== undefined && leafInfo[key] !== clinfo[key]) {
  1082. oneUpdate[key] = leafInfo[key];
  1083. // clinfo[key] = leafInfo[key];
  1084. needUpdate = true;
  1085. } else if (leafInfo[key] === undefined && leafInfo.jldy !== clinfo[key]) {
  1086. oneUpdate[key] = leafInfo.jldy;
  1087. // clinfo[key] = leafInfo.jldy;
  1088. needUpdate = true;
  1089. }
  1090. } else {
  1091. if (leafInfo[key] !== clinfo['xmj_' + key]) {
  1092. oneUpdate['xmj_' + key] = leafInfo[key];
  1093. // clinfo['xmj_' + key] = leafInfo[key];
  1094. needUpdate = true;
  1095. }
  1096. }
  1097. });
  1098. if (needUpdate) {
  1099. updateList.push(oneUpdate);
  1100. }
  1101. info = leafInfo;
  1102. } else {
  1103. removeList.push(clinfo);
  1104. needUpdate = true;
  1105. }
  1106. }
  1107. return [info, needUpdate];
  1108. }
  1109. function findDecimal(unit) {
  1110. let value = precision.other.value;
  1111. const changeUnits = precision;
  1112. for (const d in changeUnits) {
  1113. if (changeUnits[d].unit !== undefined && changeUnits[d].unit === unit) {
  1114. value = changeUnits[d].value;
  1115. break;
  1116. }
  1117. }
  1118. return value;
  1119. }
  1120. // 编号排序,多重判断
  1121. function sortByCode(a, b) {
  1122. let code1 = a.code.split('-');
  1123. let code2 = b.code.split('-');
  1124. let code1length = code1.length;
  1125. let code2length = code2.length;
  1126. for (let i = 0; i < code1length; i ++) {
  1127. if (i+1 <= code2length) {
  1128. if (code1[i] != code2[i]) {
  1129. if (/^\d+$/.test(code1[i]) && /^\d+$/.test(code2[i])) {
  1130. return parseInt(code1[i]) - parseInt(code2[i]);
  1131. } else if (!/^\d+$/.test(code1[i]) && /^\d+$/.test(code2[i])) {
  1132. return 1;
  1133. } else if (/^\d+$/.test(code1[i]) && !/^\d+$/.test(code2[i])) {
  1134. return -1;
  1135. } else {
  1136. const str1length = code1[i].length;
  1137. const str2length = code2[i].length;
  1138. for (let j = 0; j < str1length; j++) {
  1139. if (j+1 <= str2length) {
  1140. if (code1[i].charAt(j) != code2[i].charAt(j)) {
  1141. return code1[i].charAt(j).charCodeAt() - code2[i].charAt(j).charCodeAt();
  1142. } else if (j+1 == str1length && code1[i].charAt(j) == code2[i].charAt(j)) {
  1143. if (str1length == str2length) {
  1144. return 0;
  1145. } else {
  1146. return str1length - str2length;
  1147. }
  1148. }
  1149. } else {
  1150. if (j+1 >= str1length) {
  1151. return 1;
  1152. } else {
  1153. return -1;
  1154. }
  1155. }
  1156. }
  1157. }
  1158. } else if (i+1 == code1length && code1[i] == code2[i]) {
  1159. if (code1length == code2length) {
  1160. return 0;
  1161. } else {
  1162. return code1length - code2length;
  1163. }
  1164. }
  1165. } else {
  1166. if (i+1 >= code1length) {
  1167. return 1;
  1168. } else {
  1169. return -1;
  1170. }
  1171. }
  1172. }
  1173. }
  1174. });
  1175. </script>