modal.ejs 65 KB

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