modal.ejs 60 KB

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