modal.ejs 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246
  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="height:521px;overflow-y:auto;">
  221. <table class="table table-hover table-bordered">
  222. <thead>
  223. <tr>
  224. <th width="10%" class="text-center"><div class="align-middle"><input id="select-all-uncheck" type="checkbox"></div></th>
  225. <th width="7%">序号</th>
  226. <th width="40%">变更令编号</th>
  227. <th width="">原审批流程</th>
  228. </tr>
  229. </thead>
  230. <tbody id="uncheck_list">
  231. </tbody>
  232. </table>
  233. </div>
  234. </div>
  235. <!-- 右侧新审批流程 -->
  236. <div class="col-6">
  237. <div class="ml-auto">
  238. <div class="dropdown row">
  239. <span class="col-7"><button class="btn btn-sm btn-primary" id="synchronize_shenpi_btn">同步流程至其它已勾选变更令</button></span>
  240. <span class="col-5 text-right" id="show-audit-select"></span>
  241. </div>
  242. <div class="card mt-1">
  243. <div class="card-header">
  244. 审批流程
  245. </div>
  246. <div class="modal-height-500" style="overflow-y:auto;">
  247. <ul class="list-group list-group-flush" id="auditList">
  248. </ul>
  249. </div>
  250. </div>
  251. </div>
  252. </div>
  253. </div>
  254. <div class="alert alert-warning mt-2 mb-0">没有设置审批流的变更令将无法上报,请先设置审批流。</div>
  255. </div>
  256. <div class="modal-footer">
  257. <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
  258. <button class="btn btn-sm btn-primary" id="batch_uncheck_btn">确定上报</button>
  259. </div>
  260. </div>
  261. </div>
  262. </div>
  263. <!--批量上报变更令进度条modal-->
  264. <div class="modal fade" id="batch-sb-progress" data-backdrop="static" style="">
  265. <div class="modal-dialog" role="document">
  266. <div class="modal-content">
  267. <div class="modal-header">
  268. <h5 class="modal-title">批量上报变更令</h5>
  269. </div>
  270. <div class="modal-body">
  271. <div class="progress">
  272. <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>
  273. </div>
  274. <div class="mt-1 progress-tz-text">台账获取并处理中...</div>
  275. <div class="change-progress modal-height-500" style="overflow-y:auto;">
  276. </div>
  277. </div>
  278. <div class="modal-footer" style="display: none">
  279. <button class="btn btn-sm btn-primary" onclick="window.location.reload();">刷新页面</button>
  280. </div>
  281. </div>
  282. </div>
  283. </div>
  284. <% } %>
  285. <!--批量审批变更令-->
  286. <div class="modal fade" id="batch-sp" data-backdrop="static" style="">
  287. <div class="modal-dialog modal-lg" role="document">
  288. <div class="modal-content">
  289. <div class="modal-header">
  290. <h5 class="modal-title">批量审批变更令</h5>
  291. <button type="button" class="close" data-dismiss="modal" aria-label="Close">
  292. <span aria-hidden="true">&times;</span>
  293. </button>
  294. </div>
  295. <div class="modal-body">
  296. <div class="modal-height-500" style="overflow-y:auto;">
  297. <table class="table table-hover table-bordered">
  298. <thead>
  299. <tr>
  300. <th width="5%"><div class="align-middle text-center"><input type="checkbox" id="select-all-checking"></div></th>
  301. <th width="7%">序号</th>
  302. <th width="25%">变更令编号</th>
  303. <th width="">变更令名称</th>
  304. <th width="25%">批复编号</th>
  305. </tr>
  306. </thead>
  307. <tbody id="checking_list">
  308. </tbody>
  309. </table>
  310. </div>
  311. </div>
  312. <div class="modal-footer">
  313. <button type="button" class="btn btn-sm btn-secondary" data-dismiss="modal">取消</button>
  314. <button type="button" class="btn btn-sm btn-primary" id="batch_checking_btn">确定</button>
  315. </div>
  316. </div>
  317. </div>
  318. </div>
  319. <!--批量审批变更令进度条modal-->
  320. <div class="modal fade" id="batch-sp-progress" data-backdrop="static" style="">
  321. <div class="modal-dialog" role="document">
  322. <div class="modal-content">
  323. <div class="modal-header">
  324. <h5 class="modal-title">批量审批变更令</h5>
  325. </div>
  326. <div class="modal-body">
  327. <div class="progress">
  328. <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>
  329. </div>
  330. <div class="mt-1 progress-tz-text">台账获取并处理中...</div>
  331. <div class="change-progress modal-height-500" style="overflow-y:auto;">
  332. </div>
  333. </div>
  334. <div class="modal-footer" style="display: none">
  335. <button class="btn btn-sm btn-primary" onclick="window.location.reload();">刷新页面</button>
  336. </div>
  337. </div>
  338. </div>
  339. </div>
  340. <script>
  341. const ruleType = <%- ruleType %>;
  342. const ruleConst = JSON.parse('<%- JSON.stringify(ruleConst) %>');
  343. let codeRule = JSON.parse('<%- JSON.stringify(codeRule) %>');
  344. let connectorRule = '<%- tender.c_connector %>';
  345. let cRuleFirst = '<%- tender.c_rule_first %>';
  346. const tenderId = '<%- ctx.tender.id %>';
  347. const auditConst = JSON.parse(unescape('<%- escape(JSON.stringify(auditConst)) %>'));
  348. const auditType = JSON.parse('<%- JSON.stringify(auditType) %>');
  349. $('#audit-list').on('click', 'a', function() {
  350. const type = $(this).data('target')
  351. const auditCard = $(this).parent().parent()
  352. if (type === 'show') {
  353. $(this).data('target', 'hide')
  354. auditCard.find('.fold-card').slideDown('swing', () => {
  355. auditCard.find('#end-target').text($(this).data('idx') + '#')
  356. auditCard.find('#fold-btn').text('收起历史审核记录')
  357. })
  358. } else {
  359. $(this).data('target', 'show')
  360. auditCard.find('.fold-card').slideUp('swing', () => {
  361. auditCard.find('#end-target').text('1#')
  362. auditCard.find('#fold-btn').text('展开历史审核记录')
  363. })
  364. }
  365. });
  366. </script>
  367. <script src="/public/js/moment/moment.min.js"></script>
  368. <script src="/public/js/decimal.min.js"></script>
  369. <script src="/public/js/zh_calc.js"></script>
  370. <script src="/public/js/path_tree.js"></script>
  371. <script src="/public/js/gcl_gather.js"></script>
  372. <script>
  373. const shenpiConst = JSON.parse(unescape('<%- escape(JSON.stringify(shenpiConst)) %>'));
  374. const precision = JSON.parse('<%- JSON.stringify(precision) %>');
  375. $(function () {
  376. const intervalIds = {};
  377. <% if (tender.user_id === ctx.session.sessionUser.accountId) { %>
  378. let this_cid = null;
  379. let shenpi_status = shenpiConst.sp_status.sqspr;
  380. let accountList, accountGroup;
  381. let uncheckList = [];
  382. // 批量上报变更令部分
  383. $('#batch-sb').on('show.bs.modal', function () {
  384. postData(`/tender/${tenderId}/change/batch/fun`, { type: 'get_report_list' }, function (res) {
  385. let html = '';
  386. $('#select-all-uncheck').prop('checked', false);
  387. shenpi_status = res.shenpi_status;
  388. uncheckList = res.uncheckList;
  389. if (res.uncheckList.length > 0) {
  390. for (const [i, l] of res.uncheckList.entries()) {
  391. html += '<tr>' +
  392. `<td class="text-center"><input type="checkbox" value="${l.cid}"></td><td>${i + 1}</td>` +
  393. `<td class=""><a href="/tender/${tenderId}/change/${l.cid}/information" target="_blank">${l.code}</a></td>` +
  394. '<td>' + setAuditList(l.auditList) +'</td>' +
  395. '</tr>';
  396. }
  397. }
  398. $('#uncheck_list').html(html);
  399. if (res.uncheckList.length > 0) {
  400. $('#uncheck_list tr').eq(0).addClass('table-warning');
  401. this_cid = res.uncheckList[0].cid;
  402. makeSpList(res.uncheckList[0].auditList);
  403. } else {
  404. $('#uncheck_list tr').removeClass('table-warning');
  405. this_cid = null;
  406. makeSpList([]);
  407. }
  408. let showAuditSelectHtml = '';
  409. if (res.spGroupList && res.spGroupList.length > 0 && shenpi_status === shenpiConst.sp_status.gdspl) {
  410. let optionHtml = '';
  411. for (const g of res.spGroupList) { %>
  412. optionHtml += `<option value="${g.id}" ${res.uncheckList.length > 0 && g.id === res.uncheckList[0].sp_group ? 'selected' : ''}>${g.name}</option>`;
  413. }
  414. showAuditSelectHtml += '<select class="form-control form-control-sm change-sp-group">' + optionHtml + '</select>';
  415. $('#synchronize_shenpi_btn').css('margin-top', '5px');
  416. } else {
  417. accountList = res.accountList;
  418. accountGroup = res.accountGroup;
  419. showAuditSelectHtml += getSelectAuditHtml('report');
  420. }
  421. $('#show-audit-select').html(showAuditSelectHtml);
  422. })
  423. });
  424. function setAuditList(auditList) {
  425. let html = [];
  426. // 去除原报
  427. if (auditList.length > 1) {
  428. for (const [i,a] of auditList.entries()) {
  429. if (i === 0) continue;
  430. const oneAuditNames = _.map(a, 'name');
  431. let names = oneAuditNames.join('、');
  432. if (oneAuditNames.length > 1) {
  433. names = (a[0].audit_type === auditType.key.and ? '(会)' : (a[0].audit_type === auditType.key.or ? '(或)' : '')) + names;
  434. }
  435. html.push(names);
  436. }
  437. }
  438. return html.join('-');
  439. }
  440. function getSelectAuditHtml(code) {
  441. let divhtml = '';
  442. accountGroup.forEach((group, idx) => {
  443. let didivhtml = '';
  444. if(group) {
  445. group.groupList.forEach(item => {
  446. didivhtml += '<dd class="border-bottom p-2 mb-0 " data-id="' + item.id + '" >\n' +
  447. '<p class="mb-0 d-flex"><span class="text-primary">' + item.name + '</span><span\n' +
  448. ' class="ml-auto">' + item.mobile + '</span></p>\n' +
  449. ' <span class="text-muted">' + item.role + '</span>\n' +
  450. ' </dd>\n';
  451. });
  452. 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' +
  453. ' <div class="dd-content" data-toggleid="' + idx + '">\n' + didivhtml +
  454. ' </div>\n';
  455. }
  456. });
  457. const html =
  458. ' <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' +
  459. ' 添加审批流程\n' +
  460. ' </button>\n' +
  461. ' <div class="dropdown-menu dropdown-menu-right" id="' + code + '_dropdownMenu" aria-labelledby="' + code + '_dropdownMenuButton" style="width:220px">\n' +
  462. ' <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search"\n' +
  463. ' placeholder="姓名/手机 检索" autocomplete="off" data-code="' + code + '"></div>\n' +
  464. ' <dl class="list-unstyled book-list">\n' + divhtml +
  465. ' </dl>\n' +
  466. ' </div>\n';
  467. return html;
  468. }
  469. // uncheckList tr 切换
  470. $('#uncheck_list').on('click', 'tr', function () {
  471. $('#uncheck_list tr').removeClass('table-warning');
  472. $(this).addClass('table-warning');
  473. this_cid = $(this).find('a').attr('href').split('/')[4];
  474. makeSpList(uncheckList.find(l => l.cid === this_cid).auditList);
  475. });
  476. $('#uncheck_list').on('click', 'input[type="checkbox"]', function (e) {
  477. e.stopPropagation();
  478. });
  479. // uncheckList tr全选
  480. $('#select-all-uncheck').click(function () {
  481. $('#uncheck_list tr').find('input[type="checkbox"]').prop('checked', $(this).prop('checked'));
  482. });
  483. $('#synchronize_shenpi_btn').click(function () {
  484. const this_cid = $('#uncheck_list tr[class="table-warning"]').find('a').attr('href').split('/')[4];
  485. const info = uncheckList.find(l => l.cid === this_cid);
  486. if (!this_cid || !info) {
  487. toastr.error('请先选择一个变更令');
  488. return false;
  489. }
  490. if ($('#uncheck_list input:checked').length === 0) {
  491. toastr.error('请至少勾选一个变更令');
  492. return false;
  493. }
  494. const cids = [];
  495. $('#uncheck_list input:checked').each(function () {
  496. cids.push($(this).val());
  497. });
  498. if (cids.length === 1 && cids[0] === this_cid) {
  499. toastr.error('请至少勾选一个其它变更令');
  500. return false;
  501. }
  502. if (cids.indexOf(this_cid) !== -1) cids.splice(cids.indexOf(this_cid), 1);
  503. console.log(cids, info);
  504. postData(`/tender/${tenderId}/change/batch/fun`, { type: 'set_shenpi_list', cids, from_cid: this_cid }, function (res) {
  505. toastr.success('同步流程成功');
  506. uncheckList = res.uncheckList;
  507. for (const index in res.uncheckList) {
  508. $('#uncheck_list tr').eq(index).children('td').eq(3).html(setAuditList(res.uncheckList[index].auditList));
  509. }
  510. });
  511. });
  512. let timer = null;
  513. let oldSearchVal = null;
  514. $('body').on('input propertychange', 'div[id$="_dropdownMenu"] .gr-search', function(e) {
  515. oldSearchVal = e.target.value;
  516. timer && clearTimeout(timer);
  517. timer = setTimeout(() => {
  518. const newVal = $(this).val();
  519. const code = $(this).attr('data-code');
  520. let html = '';
  521. if (newVal && newVal === oldSearchVal) {
  522. accountList.filter(item => item && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
  523. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  524. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  525. class="ml-auto">${item.mobile || ''}</span></p>
  526. <span class="text-muted">${item.role || ''}</span>
  527. </dd>`;
  528. });
  529. $('#' + code + '_dropdownMenu .book-list').empty();
  530. $('#' + code + '_dropdownMenu .book-list').append(html);
  531. } else {
  532. if (!$('#' + code + '_dropdownMenu .acc-btn').length) {
  533. accountGroup.forEach((group, idx) => {
  534. if (!group) return;
  535. html += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>
  536. </a> ${group.groupName}</dt>
  537. <div class="dd-content" data-toggleid="${idx}">`;
  538. group.groupList.forEach(item => {
  539. // if (item.id !== changesUid) {
  540. html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
  541. <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
  542. class="ml-auto">${item.mobile || ''}</span></p>
  543. <span class="text-muted">${item.role || ''}</span>
  544. </dd>`;
  545. // }
  546. });
  547. html += '</div>';
  548. });
  549. $('#' + code + '_dropdownMenu .book-list').empty();
  550. $('#' + code + '_dropdownMenu .book-list').append(html);
  551. }
  552. }
  553. }, 400);
  554. });
  555. // 添加审批流程按钮逻辑
  556. $('body').on('click', 'div[id$="_dropdownMenu"] .book-list dt', function () {
  557. const idx = $(this).find('.acc-btn').attr('data-groupid');
  558. const type = $(this).find('.acc-btn').attr('data-type');
  559. if (type === 'hide') {
  560. $(this).parent().find(`div[data-toggleid="${idx}"]`).show(() => {
  561. $(this).children().find('i').removeClass('fa-plus-square').addClass('fa-minus-square-o');
  562. $(this).find('.acc-btn').attr('data-type', 'show');
  563. })
  564. } else {
  565. $(this).parent().find(`div[data-toggleid="${idx}"]`).hide(() => {
  566. $(this).children().find('i').removeClass('fa-minus-square-o').addClass('fa-plus-square');
  567. $(this).find('.acc-btn').attr('data-type', 'hide');
  568. })
  569. }
  570. return false;
  571. });
  572. // 添加到审批流程中
  573. $('body').on('click', 'div[id$="_dropdownMenu"] dl dd', function () {
  574. const id = parseInt($(this).data('id'));
  575. if (!this_cid) {
  576. toastr.error('请选择变更令');
  577. return false;
  578. }
  579. if (id !== 0) {
  580. postData('/tender/' + tenderId + '/change/' + this_cid + '/information/audit/add', { auditorId: id }, (datas) => {
  581. makeSpList(datas);
  582. const index = uncheckList.findIndex(item => item.cid === this_cid);
  583. if (index !== -1) {
  584. uncheckList[index].auditList = datas;
  585. $('#uncheck_list tr').eq(index).children('td').eq(3).html(setAuditList(datas));
  586. }
  587. });
  588. }
  589. });
  590. // 移除审批流程的审批人
  591. $('body').on('click', '#auditList li a', function () {
  592. const uid = $(this).parents('li').attr('data-auditid');
  593. const li = $(this).parents('li');
  594. const data = {
  595. auditorId: uid,
  596. };
  597. if (!this_cid) {
  598. toastr.error('请选择变更令');
  599. return false;
  600. }
  601. postData('/tender/' + tenderId + '/change/' + this_cid + '/information/audit/delete', data, (datas) => {
  602. li.remove();
  603. let liIndex = 1;
  604. $('#auditList li').each(function () {
  605. $(this).children('.col-auto').eq(0).text(liIndex);
  606. liIndex++;
  607. });
  608. const index = uncheckList.findIndex(item => item.cid === this_cid);
  609. if (index !== -1) {
  610. uncheckList[index].auditList = datas;
  611. $('#uncheck_list tr').eq(index).children('td').eq(3).html(setAuditList(datas));
  612. }
  613. });
  614. });
  615. // 切换审批组
  616. $('body').on('change', '.change-sp-group', function () {
  617. const data = {
  618. type: 'change_sp_group',
  619. sp_group: parseInt($(this).val()),
  620. }
  621. if (!this_cid) {
  622. toastr.error('请选择变更令');
  623. return false;
  624. }
  625. if (!data.sp_group) {
  626. toastr.error('请选择固定审批组');
  627. return false;
  628. }
  629. console.log(data);
  630. postData('/tender/' + tenderId + '/change/' + this_cid + '/information/audit/spgroup', data, (datas) => {
  631. makeSpList(datas);
  632. const index = uncheckList.findIndex(item => item.cid === this_cid);
  633. if (index !== -1) {
  634. uncheckList[index].auditList = datas;
  635. $('#uncheck_list tr').eq(index).children('td').eq(3).html(setAuditList(datas));
  636. }
  637. });
  638. });
  639. function makeSpList(datas) {
  640. const html = [];
  641. // 如果是重新上报,添加到重新上报列表中
  642. const auditorshtml = [];
  643. if (datas.length > 0) {
  644. for (const [index,data] of datas.entries()) {
  645. if (index !== 0) {
  646. html.push('<li class="list-group-item d-flex" data-auditid="'+ data[0].uid +'">');
  647. html.push(`<div class="col-auto">${index}</div>`);
  648. html.push('<div class="col">');
  649. for (const auditor of data) {
  650. 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>`);
  651. }
  652. html.push('</div>');
  653. html.push('<div class="col-auto">');
  654. // todo 添加会签或签时
  655. if (data[0].audit_type !== auditType.key.common) {
  656. 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>`);
  657. }
  658. if (shenpi_status === shenpiConst.sp_status.sqspr || (shenpi_status === shenpiConst.sp_status.gdzs && index+1 !== datas.length)) {
  659. html.push('<a href="javascript: void(0)" class="text-danger pull-right">移除</a>');
  660. }
  661. html.push('</div>');
  662. html.push('</li>');
  663. }
  664. }
  665. }
  666. $('#auditList').html(html.join(''));
  667. }
  668. $('#batch_uncheck_btn').click(function () {
  669. // 至少勾选一个
  670. if ($('#uncheck_list input:checked').length === 0) {
  671. toastr.error('请至少勾选一个变更令');
  672. return false;
  673. }
  674. const cids = [];
  675. $('#uncheck_list input:checked').each(function () {
  676. cids.push($(this).val());
  677. });
  678. $('#batch-sb').modal('hide');
  679. $('#batch-sb-progress').modal('show');
  680. $('#batch-sb-progress .progress-tz-bar').css('width', '0%');
  681. $('#batch-sb-progress .modal-footer').hide();
  682. setProgress($('#batch-sb-progress .progress-tz-bar'), 30, 'tz1');
  683. $('#batch-sb-progress .progress-tz-text').text('台账数据获取中...').removeClass('text-success');
  684. let changeListData;
  685. let gclGatherData;
  686. postData('/tender/' + tenderId + '/change/defaultBills', { form: 'batch' }, async function (result) {
  687. gclGatherModel.loadLedgerData(result.bills);
  688. gclGatherModel.loadPosData(result.pos);
  689. gclGatherData = gclGatherModel.gatherGclData();
  690. gclGatherData = _.filter(gclGatherData, function (item) {
  691. return item.leafXmjs && item.leafXmjs.length !== 0;
  692. });
  693. for (const ggd in gclGatherData) {
  694. if (gclGatherData[ggd].leafXmjs && gclGatherData[ggd].leafXmjs.length === 0) {
  695. gclGatherData.splice(ggd, 1);
  696. }
  697. gclGatherData[ggd].code = gclGatherData[ggd].b_code;
  698. let hadcid = 0;
  699. for (const xmj of gclGatherData[ggd].leafXmjs) {
  700. const changeLedger = _.find(result.changeLedgerList, { id: xmj.gcl_id });
  701. const changePos = _.find(result.changePosList, { id: xmj.mx_id, lid: xmj.gcl_id });
  702. if (changeLedger || changePos) {
  703. xmj.cid = 1;
  704. xmj.ccid = changeLedger ? changeLedger.ccid : changePos.ccid;
  705. hadcid = 1;
  706. }
  707. }
  708. if (hadcid !== 0) gclGatherData[ggd].cid = 1;
  709. }
  710. // console.log(gclGatherData);
  711. // 数组去重
  712. const dealBillList = result.dealBills;
  713. for (const db of gclGatherData) {
  714. const exist_index = dealBillList.findIndex(function (item) {
  715. return item.code === db.code && item.name === db.name && item.unit === db.unit && item.unit_price === db.unit_price;
  716. });
  717. if (exist_index !== -1) {
  718. dealBillList.splice(exist_index, 1);
  719. }
  720. }
  721. changeListData = gclGatherData.concat(dealBillList).sort(sortByCode);
  722. console.log(changeListData);
  723. stopProgress($('#batch-sb-progress .progress-tz-bar'), 'tz1');
  724. $('#batch-sb-progress .progress-tz-text').text('台账数据加载完成').addClass('text-success');
  725. $('#batch-sb-progress .change-progress').html('');
  726. for (const c of cids) {
  727. const cInfo = uncheckList.find(item => item.cid === c);
  728. if (cInfo) {
  729. $('#batch-sb-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">` +
  730. '<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>' +
  731. '</div>' +
  732. `<div class="mt-1"><span class="progress-change-text">上报处理中...</span></div></div>`);
  733. await checkAndChange(cInfo, changeListData, result.changeLedgerList);
  734. }
  735. }
  736. $('#batch-sb-progress .modal-footer').show();
  737. });
  738. });
  739. <% } %>
  740. let checkingList = [];
  741. $('#batch-sp').on('show.bs.modal', function () {
  742. postData(`/tender/${tenderId}/change/batch/fun`, { type: 'get_shenpi_list' }, function (res) {
  743. let html = '';
  744. $('#select-all-checking').prop('checked', false);
  745. checkingList = res.checkingList;
  746. if (checkingList.length > 0) {
  747. for (const [i, l] of res.checkingList.entries()) {
  748. 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}" />` : '';
  749. html += '<tr>' +
  750. `<td class="text-center"><input type="checkbox" value="${l.cid}"></td>` +
  751. `<td>${i+1}</td>` +
  752. `<td class=""><a href="/tender/${tenderId}/change/${l.cid}/information" target="_blank">${l.code}</a></td>` +
  753. `<td>${l.name}</td>` +
  754. `<td>${finalHtml}</td>` +
  755. '</tr>';
  756. }
  757. }
  758. $('#checking_list').html(html);
  759. });
  760. });
  761. $('body').on('change', '.final_pcode_input', function () {
  762. const cid = $(this).data('cid');
  763. const cInfo = checkingList.find(item => item.cid === cid);
  764. cInfo.p_code = $(this).val();
  765. });
  766. $('#checking_list').on('click', 'input[type="checkbox"]', function (e) {
  767. e.stopPropagation();
  768. });
  769. // uncheckList tr全选
  770. $('#select-all-checking').click(function () {
  771. $('#checking_list tr').find('input[type="checkbox"]').prop('checked', $(this).prop('checked'));
  772. });
  773. $('#batch_checking_btn').click(function () {
  774. // 至少勾选一个
  775. if ($('#checking_list input:checked').length === 0) {
  776. toastr.error('请至少勾选一个变更令');
  777. return false;
  778. }
  779. const cids = [];
  780. $('#checking_list input:checked').each(function () {
  781. cids.push($(this).val());
  782. });
  783. $('#batch-sp').modal('hide');
  784. $('#batch-sp-progress').modal('show');
  785. $('#batch-sp-progress .progress-tz-bar').css('width', '0%');
  786. $('#batch-sp-progress .modal-footer').hide();
  787. setProgress($('#batch-sp-progress .progress-tz-bar'), 30, 'tz2');
  788. $('#batch-sp-progress .progress-tz-text').text('台账数据获取中...').removeClass('text-success');
  789. let changeListData;
  790. let gclGatherData;
  791. postData('/tender/' + tenderId + '/change/defaultBills', { from: 'batch' }, async function (result) {
  792. gclGatherModel.loadLedgerData(result.bills);
  793. gclGatherModel.loadPosData(result.pos);
  794. gclGatherData = gclGatherModel.gatherGclData();
  795. gclGatherData = _.filter(gclGatherData, function (item) {
  796. return item.leafXmjs && item.leafXmjs.length !== 0;
  797. });
  798. for (const ggd in gclGatherData) {
  799. if (gclGatherData[ggd].leafXmjs && gclGatherData[ggd].leafXmjs.length === 0) {
  800. gclGatherData.splice(ggd, 1);
  801. }
  802. gclGatherData[ggd].code = gclGatherData[ggd].b_code;
  803. let hadcid = 0;
  804. for (const xmj of gclGatherData[ggd].leafXmjs) {
  805. const changeLedger = _.find(result.changeLedgerList, { id: xmj.gcl_id });
  806. const changePos = _.find(result.changePosList, { id: xmj.mx_id, lid: xmj.gcl_id });
  807. if (changeLedger || changePos) {
  808. xmj.cid = 1;
  809. xmj.ccid = changeLedger ? changeLedger.ccid : changePos.ccid;
  810. hadcid = 1;
  811. }
  812. }
  813. if (hadcid !== 0) gclGatherData[ggd].cid = 1;
  814. }
  815. // console.log(gclGatherData);
  816. // 数组去重
  817. const dealBillList = result.dealBills;
  818. for (const db of gclGatherData) {
  819. const exist_index = dealBillList.findIndex(function (item) {
  820. return item.code === db.code && item.name === db.name && item.unit === db.unit && item.unit_price === db.unit_price;
  821. });
  822. if (exist_index !== -1) {
  823. dealBillList.splice(exist_index, 1);
  824. }
  825. }
  826. changeListData = gclGatherData.concat(dealBillList).sort(sortByCode);
  827. console.log(changeListData);
  828. stopProgress($('#batch-sp-progress .progress-tz-bar'), 'tz2');
  829. $('#batch-sp-progress .progress-tz-text').text('台账数据加载完成').addClass('text-success');
  830. $('#batch-sp-progress .change-progress').html('');
  831. for (const c of cids) {
  832. const cInfo = checkingList.find(item => item.cid === c);
  833. if (cInfo) {
  834. $('#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">` +
  835. '<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>' +
  836. '</div>' +
  837. `<div class="mt-1"><span class="progress-change-text">审批处理中...</span></div></div>`);
  838. await checkAndChange(cInfo, changeListData, result.changeLedgerList, 'checking');
  839. }
  840. }
  841. $('#batch-sp-progress .modal-footer').show();
  842. }, function (res) {
  843. }, false);
  844. });
  845. let value = 0;
  846. // let interval;
  847. let stop = false;
  848. function setProgress(_this, time = 50, name) {
  849. let intervalId = setInterval(function () {
  850. if (value < 100) {
  851. value = parseInt(value) + 1;
  852. _this.css("width", value + "%").text(value + "%");
  853. } else if (value === 100) {
  854. value = parseInt(value) + 1;
  855. value = 30;
  856. }
  857. }, time);
  858. intervalIds[name] = intervalId;
  859. }
  860. function resetProgress(_this) {
  861. _this.removeClass('bg-success');
  862. _this.css("width", "0%").text("0%").attr('aria-valuenow', '0');
  863. }
  864. function failProgress(_this, name) {
  865. if (intervalIds[name]) {
  866. _this.addClass('bg-danger');
  867. _this.css("width", "100%").text("失败");
  868. value = 0;
  869. stop = true;
  870. clearInterval(intervalIds[name]);
  871. intervalIds[name] = 0;
  872. }
  873. }
  874. function stopProgress(_this, name) {
  875. if (intervalIds[name]) {
  876. _this.addClass('bg-success');
  877. _this.css("width", "100%").text("100%");
  878. value = 0;
  879. stop = true;
  880. clearInterval(intervalIds[name]);
  881. intervalIds[name] = 0;
  882. }
  883. }
  884. async function checkAndChange(cInfo, changeListData, changeLedgerList, status = 'uncheck') {
  885. setProgress($(`#change-${cInfo.cid}-progress .progress-bar`), 30, `change-${cInfo.cid}`);
  886. // 根据已添加的清单显示
  887. if (cInfo.changeList.length > 0 && cInfo.changeList[0]) {
  888. const removeList = [];
  889. const updateList = [];
  890. const updateGclIdList = [];
  891. for (const [index,clinfo] of cInfo.changeList.entries()) {
  892. if (clinfo.lid != 0) {
  893. let listinfo = changeListData.find(function (item) {
  894. 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);
  895. });
  896. if (listinfo === undefined || (clinfo.lid && clinfo.gcl_id && clinfo.lid !== clinfo.gcl_id)) {
  897. // 有可能这部分台账发生变化,此时要更新清单lid信息,防止数据丢失
  898. const newlistinfo = changeListData.find(function (item) {
  899. 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 }));
  900. });
  901. if ((listinfo === undefined && newlistinfo) || (listinfo && newlistinfo && !isObjEqual(listinfo, newlistinfo))) {
  902. listinfo = newlistinfo;
  903. updateList.push({id: clinfo.id, lid: newlistinfo.leafXmjs[0].gcl_id});
  904. // 更新lid
  905. cInfo.changeList[index].lid = newlistinfo.leafXmjs[0].gcl_id;
  906. }
  907. }
  908. if (listinfo === undefined) {
  909. // 针对旧数据获取清单信息
  910. listinfo = changeListData[clinfo.lid - 1];
  911. if (listinfo === undefined) {
  912. removeList.push(clinfo);
  913. break;
  914. }
  915. }
  916. const [info, needUpdate] = makePushBwmx(clinfo, listinfo, removeList, updateList);
  917. if (needUpdate) break;
  918. if (_.findIndex(changeLedgerList, { id: clinfo.gcl_id }) !== -1) {
  919. // 可能因为升降级关系:细目,分部分项等会发生变化,更新清单
  920. const updateInfo = {};
  921. if (info.code !== clinfo.xmj_code) {
  922. updateInfo.xmj_code = info.code;
  923. // changeList[index].xmj_code = info.code;
  924. }
  925. if (info.jldy !== clinfo.xmj_jldy) {
  926. updateInfo.xmj_jldy = info.jldy;
  927. // changeList[index].xmj_jldy = info.jldy;
  928. }
  929. if (info.dwgc !== clinfo.xmj_dwgc) {
  930. updateInfo.xmj_dwgc = info.dwgc;
  931. // changeList[index].xmj_dwgc = info.dwgc;
  932. }
  933. if (info.fbgc !== clinfo.xmj_fbgc) {
  934. updateInfo.xmj_fbgc = info.fbgc;
  935. // changeList[index].xmj_fbgc = info.fbgc;
  936. }
  937. if (info.fxgc !== clinfo.xmj_fxgc) {
  938. updateInfo.xmj_fxgc = info.fxgc;
  939. // changeList[index].xmj_fxgc = info.fxgc;
  940. }
  941. if (!_.isEmpty(updateInfo) && _.indexOf(updateGclIdList, clinfo.gcl_id) === -1) {
  942. updateGclIdList.push(clinfo.gcl_id);
  943. // updateInfo.gcl_id = info.id;
  944. updateList.push({ row: updateInfo, where: { tid: tenderId, gcl_id: clinfo.gcl_id } });
  945. break;
  946. }
  947. }
  948. }
  949. }
  950. await sleep(2000);
  951. if (updateList.length > 0 || removeList.length > 0) {
  952. console.log(updateList, removeList);
  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. // 上报或审批变更令
  959. let ss = true;
  960. if (status === 'uncheck') {
  961. postDataWithAsync('/tender/' + tenderId + '/change/' + cInfo.cid + '/information/audit/start', {}, function () {
  962. }, function (res) {
  963. ss = false;
  964. failProgress($('#change-' + cInfo.cid + '-progress .progress-bar'), `change-${cInfo.cid}`);
  965. $('#change-' + cInfo.cid + '-progress .mt-1').addClass('text-danger');
  966. $('#change-' + cInfo.cid + '-progress .progress-change-text').text(res);
  967. return;
  968. }, false);
  969. } else {
  970. const pData = {
  971. change_id: cInfo.cid,
  972. w_code: cInfo.code,
  973. status: auditConst.status.checked,
  974. sdesc: '同意',
  975. }
  976. if (cInfo.is_finalAudit) {
  977. if (cInfo.p_code) {
  978. pData.p_code = cInfo.p_code;
  979. const postData2 = {
  980. p_code: cInfo.p_code,
  981. };
  982. let returnflag = true;
  983. postDataWithAsync('/tender/' + tenderId + '/change/' + cInfo.cid + '/check/codeRepeat',postData2, function (result) {
  984. }, function (data) {
  985. returnflag = false;
  986. });
  987. if (!returnflag) {
  988. failProgress($('#change-' + cInfo.cid + '-progress .progress-bar'), `change-${cInfo.cid}`);
  989. $('#change-' + cInfo.cid + '-progress .mt-1').addClass('text-danger');
  990. $('#change-' + cInfo.cid + '-progress .progress-change-text').text('批复编号不能与其它变更令重复!');
  991. return;
  992. }
  993. } else {
  994. failProgress($('#change-' + cInfo.cid + '-progress .progress-bar'), `change-${cInfo.cid}`);
  995. $('#change-' + cInfo.cid + '-progress .mt-1').addClass('text-danger');
  996. $('#change-' + cInfo.cid + '-progress .progress-change-text').text('变更令号(批复编号)不能为空!');
  997. return;
  998. }
  999. }
  1000. postDataWithAsync('/tender/' + tenderId + '/change/approval', pData, function (result) {
  1001. }, function (res) {
  1002. ss = false;
  1003. failProgress($('#change-' + cInfo.cid + '-progress .progress-bar'), `change-${cInfo.cid}`);
  1004. $('#change-' + cInfo.cid + '-progress .mt-1').addClass('text-danger');
  1005. $('#change-' + cInfo.cid + '-progress .progress-change-text').text(res);
  1006. return;
  1007. }, false);
  1008. }
  1009. if (ss) {
  1010. stopProgress($('#change-' + cInfo.cid + '-progress .progress-bar'), `change-${cInfo.cid}`);
  1011. $('#change-' + cInfo.cid + '-progress .mt-1').addClass('text-success');
  1012. $('#change-' + cInfo.cid + '-progress .progress-change-text').text((status === 'uncheck' ? '上报' : '审批') + '成功');
  1013. }
  1014. }
  1015. }
  1016. const postDataWithAsync = function (url, data, successCallback, errorCallBack, showWaiting = true) {
  1017. if (showWaiting) showWaitingView();
  1018. $.ajax({
  1019. type:"POST",
  1020. url: url,
  1021. data: {'data': JSON.stringify(data)},
  1022. dataType: 'json',
  1023. cache: false,
  1024. async: false,
  1025. timeout: 60000,
  1026. beforeSend: function(xhr) {
  1027. let csrfToken = Cookies.get('csrfToken_j');
  1028. xhr.setRequestHeader('x-csrf-token', csrfToken);
  1029. },
  1030. success: function(result){
  1031. if (result.err === 0) {
  1032. if (successCallback) {
  1033. successCallback(result.data);
  1034. }
  1035. } else {
  1036. toastr.error(result.msg);
  1037. if (errorCallBack) {
  1038. errorCallBack(result.msg);
  1039. }
  1040. }
  1041. if (showWaiting) closeWaitingView();
  1042. },
  1043. error: function(jqXHR, textStatus, errorThrown){
  1044. toastr.error('error: ' + textStatus + " " + errorThrown);
  1045. if (errorCallBack) {
  1046. errorCallBack();
  1047. }
  1048. if (showWaiting) closeWaitingView();
  1049. }
  1050. });
  1051. };
  1052. function sleep(millisecond) {
  1053. return new Promise(resolve => {
  1054. setTimeout(() => {
  1055. resolve()
  1056. }, millisecond)
  1057. })
  1058. }
  1059. function isObjEqual(o1,o2){
  1060. var props1 = Object.getOwnPropertyNames(o1);
  1061. var props2 = Object.getOwnPropertyNames(o2);
  1062. if (props1.length != props2.length) {
  1063. return false;
  1064. }
  1065. for (var i = 0,max = props1.length; i < max; i++) {
  1066. var propName = props1[i];
  1067. if (o1[propName] !== o2[propName]) {
  1068. return false;
  1069. }
  1070. }
  1071. return true;
  1072. }
  1073. function makePushBwmx(clinfo, listinfo, removeList, updateList) {
  1074. let info = '';
  1075. let needUpdate = false;
  1076. const checkKey = ['name', 'code', 'unit', 'unit_price'];
  1077. const checkLeafKey = ['oamount', 'bwmx', 'code', 'dwgc', 'fbgc', 'fxgc', 'jldy'];
  1078. if (listinfo.leafXmjs !== undefined) {
  1079. const leafInfo = listinfo.leafXmjs.find(function (item) {
  1080. // 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));
  1081. const flag = item.gcl_id === clinfo.gcl_id && (!clinfo.mx_id || (item.mx_id && clinfo.mx_id && item.mx_id === clinfo.mx_id));
  1082. if (flag && item.code === clinfo.xmj_code) {
  1083. return flag && item.code === clinfo.xmj_code;
  1084. }
  1085. return flag;
  1086. });
  1087. if (leafInfo) {
  1088. const oneUpdate = { id: clinfo.id };
  1089. // 判断要不要更新名称,单位,原数量,单价
  1090. checkKey.forEach(function (key) {
  1091. if ((key === 'name' || key === 'unit') && listinfo[key] === null) {
  1092. listinfo[key] = '';
  1093. }
  1094. if (listinfo[key] !== clinfo[key]) {
  1095. oneUpdate[key] = listinfo[key];
  1096. // clinfo[key] = listinfo[key];
  1097. if (key === 'unit') {
  1098. const changeKey = ['oamount', 'oamount2', 'camount'];
  1099. changeKey.forEach(function (key) {
  1100. const value = ZhCalc.round(clinfo[key], findDecimal(listinfo[key]));
  1101. if (value !== clinfo[key]) {
  1102. oneUpdate[key] = value;
  1103. // clinfo[key] = value;
  1104. }
  1105. });
  1106. }
  1107. needUpdate = true;
  1108. }
  1109. });
  1110. checkLeafKey.forEach(function (key) {
  1111. // 只有数量是对比leafInfo,其它对比listinfo,且有些值需要重新计算
  1112. if (key === 'oamount') {
  1113. if (leafInfo.quantity !== clinfo[key]) {
  1114. oneUpdate[key] = leafInfo.quantity;
  1115. // clinfo[key] = leafInfo.quantity;
  1116. needUpdate = true;
  1117. }
  1118. } else if (key === 'bwmx') {
  1119. if (leafInfo[key] !== undefined && leafInfo[key] !== clinfo[key]) {
  1120. oneUpdate[key] = leafInfo[key];
  1121. // clinfo[key] = leafInfo[key];
  1122. needUpdate = true;
  1123. } else if (leafInfo[key] === undefined && leafInfo.jldy !== clinfo[key]) {
  1124. oneUpdate[key] = leafInfo.jldy;
  1125. // clinfo[key] = leafInfo.jldy;
  1126. needUpdate = true;
  1127. }
  1128. } else {
  1129. if (leafInfo[key] !== clinfo['xmj_' + key]) {
  1130. oneUpdate['xmj_' + key] = leafInfo[key];
  1131. // clinfo['xmj_' + key] = leafInfo[key];
  1132. needUpdate = true;
  1133. }
  1134. }
  1135. });
  1136. if (needUpdate) {
  1137. updateList.push(oneUpdate);
  1138. }
  1139. info = leafInfo;
  1140. } else {
  1141. removeList.push(clinfo);
  1142. needUpdate = true;
  1143. }
  1144. }
  1145. return [info, needUpdate];
  1146. }
  1147. function findDecimal(unit) {
  1148. let value = precision.other.value;
  1149. const changeUnits = precision;
  1150. for (const d in changeUnits) {
  1151. if (changeUnits[d].unit !== undefined && changeUnits[d].unit === unit) {
  1152. value = changeUnits[d].value;
  1153. break;
  1154. }
  1155. }
  1156. return value;
  1157. }
  1158. // 编号排序,多重判断
  1159. function sortByCode(a, b) {
  1160. let code1 = a.code.split('-');
  1161. let code2 = b.code.split('-');
  1162. let code1length = code1.length;
  1163. let code2length = code2.length;
  1164. for (let i = 0; i < code1length; i ++) {
  1165. if (i+1 <= code2length) {
  1166. if (code1[i] != code2[i]) {
  1167. if (/^\d+$/.test(code1[i]) && /^\d+$/.test(code2[i])) {
  1168. return parseInt(code1[i]) - parseInt(code2[i]);
  1169. } else if (!/^\d+$/.test(code1[i]) && /^\d+$/.test(code2[i])) {
  1170. return 1;
  1171. } else if (/^\d+$/.test(code1[i]) && !/^\d+$/.test(code2[i])) {
  1172. return -1;
  1173. } else {
  1174. const str1length = code1[i].length;
  1175. const str2length = code2[i].length;
  1176. for (let j = 0; j < str1length; j++) {
  1177. if (j+1 <= str2length) {
  1178. if (code1[i].charAt(j) != code2[i].charAt(j)) {
  1179. return code1[i].charAt(j).charCodeAt() - code2[i].charAt(j).charCodeAt();
  1180. } else if (j+1 == str1length && code1[i].charAt(j) == code2[i].charAt(j)) {
  1181. if (str1length == str2length) {
  1182. return 0;
  1183. } else {
  1184. return str1length - str2length;
  1185. }
  1186. }
  1187. } else {
  1188. if (j+1 >= str1length) {
  1189. return 1;
  1190. } else {
  1191. return -1;
  1192. }
  1193. }
  1194. }
  1195. }
  1196. } else if (i+1 == code1length && code1[i] == code2[i]) {
  1197. if (code1length == code2length) {
  1198. return 0;
  1199. } else {
  1200. return code1length - code2length;
  1201. }
  1202. }
  1203. } else {
  1204. if (i+1 >= code1length) {
  1205. return 1;
  1206. } else {
  1207. return -1;
  1208. }
  1209. }
  1210. }
  1211. }
  1212. });
  1213. </script>