modal.ejs 65 KB

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