modal.ejs 66 KB

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