financial_transfer_tender.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date 2018/10/11
  7. * @version
  8. */
  9. const tenderListSpec = (function(){
  10. function getTenderNodeHtml(node, arr, pid) {
  11. const html = [];
  12. html.push('<tr pid="' + pid + '">');
  13. // 名称
  14. html.push('<td width="30%" style="min-width: 300px;" class="in-' + node.level + '">');
  15. if (node.cid) {
  16. html.push('<span onselectstart="return false" style="{-moz-user-select:none}" class="fold-switch mr-1" title="收起" cid="'+ node.sort_id +'"><i class="fa fa-minus-square-o"></i></span> <i class="fa fa-folder-o"></i> ');
  17. html.push((node.level === 1 ? '<b>' : ''), node.name, (node.level === 1 ? '</b>' : ''));
  18. } else {
  19. html.push('<span class="text-muted mr-2">');
  20. html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├');
  21. html.push('</span>');
  22. html.push(node.name);
  23. }
  24. html.push('</td>');
  25. // 计量进度
  26. html.push('<td style="width: 130px" class="text-center">');
  27. if (!node.cid && node.cur_flow) {
  28. if (node.progress) {
  29. html.push(node.progress.title + ' (' + '<span class="' + node.progress.status_class + '">' + node.progress.status + '</span>' + ')');
  30. } else {
  31. html.push(node.cur_flow.title + ' (' + '<span class="' + node.cur_flow.status_class + '">' + node.cur_flow.status + '</span>' + ')');
  32. }
  33. }
  34. html.push('</td>');
  35. // 资金来源
  36. html.push('<td style="width: 200px" class="text-center">');
  37. if (!node.cid) {
  38. html.push(transferInfo.uid === user_id && !transferInfo.is_lock ? '<input type="text" data-key="source" class="form-control form-control-sm" placeholder="" data-ftid="' + node.id + '" value="'+ node.source +'" />' : node.source);
  39. }
  40. html.push('</td>');
  41. // 合同金额
  42. html.push('<td style="width: 100px" class="text-right">');
  43. html.push(node.total_price || '');
  44. html.push('</td>');
  45. // 截止本期合同
  46. html.push('<td style="width: 100px" class="text-right">');
  47. html.push(node.end_contract_tp || '');
  48. html.push('</td>');
  49. // 截止本期变更
  50. html.push('<td style="width: 100px" class="text-right">');
  51. html.push(node.end_qc_tp || '');
  52. html.push('</td>');
  53. // 截止本期完成
  54. html.push('<td style="width: 100px" class="text-right">');
  55. html.push(node.end_gather_tp || '');
  56. html.push('</td>');
  57. // 截止本期实付
  58. html.push('<td style="width: 100px" class="text-right">');
  59. html.push(node.end_sf_tp || '');
  60. html.push('</td>');
  61. // 本次划拨
  62. html.push('<td style="width: 100px" class="text-right">');
  63. if (!node.cid) {
  64. html.push(transferInfo.uid === user_id && !transferInfo.is_lock ? '<input type="text" data-key="hb_tp" class="form-control form-control-sm text-right" placeholder="默认等于本期实付" data-ftid="' + node.id + '" value="' + node.hb_tp + '" />' : node.hb_tp);
  65. } else {
  66. html.push(node.hb_tp || '');
  67. }
  68. html.push('</td>');
  69. // 截止上次划拨
  70. html.push('<td style="width: 100px" class="text-right">');
  71. html.push(node.pre_hb_tp || '');
  72. html.push('</td>');
  73. // 截止本次划拨
  74. html.push('<td style="width: 100px" class="text-right">');
  75. html.push(node.end_hb_tp || '');
  76. html.push('</td>');
  77. // 附件
  78. html.push('<td style="width: 80px" class="text-center">');
  79. if (!node.cid) {
  80. html.push('<a href="javascript:void(0);" class="text-primary open-tender-files" data-ftid="' + node.id + '"><i class="fa fa-paperclip fa-rotate-90"></i></a> <span class="file-num">'+ (node.files.length > 0 ? node.files.length : '') +'</span>');
  81. }
  82. html.push('</td>');
  83. // 操作
  84. if (transferInfo.uid === user_id) {
  85. html.push('<td style="width: 80px" class="text-center">');
  86. html.push(!node.cid && !transferInfo.is_lock ? '<a class="text-danger del-tender-btn" href="javascript:void(0);" data-id="'+ node.id +'">移除</a>' : '');
  87. html.push('</td>');
  88. }
  89. html.push('</tr>');
  90. return html.join('');
  91. }
  92. function getTenderTreeHeaderHtml() {
  93. const html = [];
  94. const left = $('#sub-menu').css('display') === 'none' ? 56 : 176;
  95. html.push('<table class="table table-hover table-bordered" id="progress-table">')
  96. html.push('<thead style="position: sticky;left:'+ left +'px;top: 0;">', '<tr>');
  97. html.push('<th style="width: 30%;min-width: 300px" class="text-center">', '标段名称', '</th>');
  98. html.push('<th class="text-center" style="width: 130px">', '计量进度', '</th>');
  99. html.push('<th class="text-center" style="width: 200px">', '资金来源', '</th>');
  100. html.push('<th class="text-center" style="width: 100px">', '合同金额', '</th>');
  101. html.push('<th style="width: 100px" class="text-center">', '截止本期合同', '</th>');
  102. html.push('<th style="width: 100px" class="text-center">', '截止本期变更', '</th>');
  103. html.push('<th style="width: 100px" class="text-center">', '截止本期完成', '</th>');
  104. html.push('<th style="width: 100px" class="text-center">', '截止本期实付', '</th>');
  105. html.push('<th style="width: 100px" class="text-center">', '本次划拨', '</th>');
  106. html.push('<th style="width: 100px" class="text-center">', '截止上次划拨', '</th>');
  107. html.push('<th style="width: 100px" class="text-center">', '截止本次划拨', '</th>');
  108. html.push('<th style="width: 80px" class="text-center">', '附件', '</th>');
  109. if (transferInfo.uid === user_id) {
  110. html.push('<th style="width: 80px" class="text-center">', '操作', '</th>');
  111. }
  112. html.push('</tr>', '</thead>');
  113. return html.join('');
  114. }
  115. function calculateTender(tender) {
  116. if (tender.stage_tp) {
  117. tender.gather_tp = ZhCalc.sum([tender.stage_tp.contract_tp, tender.stage_tp.qc_tp, tender.stage_tp.pc_tp]);
  118. tender.end_contract_tp = ZhCalc.sum([tender.stage_tp.pre_contract_tp, tender.stage_tp.contract_tp, tender.stage_tp.contract_pc_tp]);
  119. tender.end_qc_tp = ZhCalc.sum([tender.stage_tp.pre_qc_tp, tender.stage_tp.qc_tp, tender.stage_tp.qc_pc_tp]);
  120. tender.end_gather_tp = ZhCalc.add(tender.end_contract_tp, tender.end_qc_tp);
  121. tender.pre_gather_tp = ZhCalc.add(tender.stage_tp.pre_contract_tp, tender.stage_tp.pre_qc_tp);
  122. tender.yf_tp = ZhCalc.add(tender.stage_tp.yf_tp);
  123. tender.end_yf_tp = ZhCalc.add(tender.stage_tp.pre_yf_tp, tender.yf_tp);
  124. tender.sf_tp = ZhCalc.add(tender.stage_tp.sf_tp);
  125. tender.end_sf_tp = ZhCalc.add(tender.stage_tp.pre_sf_tp, tender.sf_tp);
  126. tender.wf_tp = ZhCalc.sub(tender.end_yf_tp, tender.end_sf_tp);
  127. } else if (tender.lastStage) {
  128. tender.gather_tp = ZhCalc.sum([tender.lastStage.contract_tp, tender.lastStage.qc_tp, tender.lastStage.pc_tp]);
  129. tender.end_contract_tp = ZhCalc.sum([tender.lastStage.pre_contract_tp, tender.lastStage.contract_tp, tender.lastStage.contract_pc_tp]);
  130. tender.end_qc_tp = ZhCalc.sum([tender.lastStage.pre_qc_tp, tender.lastStage.qc_tp, tender.lastStage.qc_pc_tp]);
  131. tender.end_gather_tp = ZhCalc.add(tender.end_contract_tp, tender.end_qc_tp);
  132. tender.pre_gather_tp = ZhCalc.add(tender.lastStage.pre_contract_tp, tender.lastStage.pre_qc_tp);
  133. tender.yf_tp = ZhCalc.add(tender.lastStage.yf_tp);
  134. tender.end_yf_tp = ZhCalc.add(tender.lastStage.pre_yf_tp, tender.yf_tp);
  135. tender.sf_tp = ZhCalc.add(tender.lastStage.sf_tp);
  136. tender.end_sf_tp = ZhCalc.add(tender.lastStage.pre_sf_tp, tender.sf_tp);
  137. tender.wf_tp = ZhCalc.sub(tender.end_yf_tp, tender.end_sf_tp);
  138. }
  139. tender.end_hb_tp = ZhCalc.add(tender.pre_hb_tp, tender.hb_tp);
  140. }
  141. function calculateParent(node) {
  142. if (node.children && node.cid) {
  143. node.total_price = 0;
  144. node.gather_tp = 0;
  145. node.end_contract_tp = 0;
  146. node.end_qc_tp = 0;
  147. node.end_gather_tp = 0;
  148. node.pre_gather_tp = 0;
  149. node.yf_tp = 0;
  150. node.end_yf_tp = 0;
  151. node.advance_tp = 0;
  152. node.contract_price = 0;
  153. node.sf_tp = 0;
  154. node.end_sf_tp = 0;
  155. node.wf_tp = 0;
  156. node.hb_tp = 0;
  157. node.pre_hb_tp = 0;
  158. node.end_hb_tp = 0;
  159. for (const c of node.children) {
  160. calculateParent(c);
  161. node.total_price = ZhCalc.add(node.total_price, c.total_price);
  162. node.gather_tp = ZhCalc.add(node.gather_tp, c.gather_tp);
  163. node.end_contract_tp = ZhCalc.add(node.end_contract_tp, c.end_contract_tp);
  164. node.end_qc_tp = ZhCalc.add(node.end_qc_tp, c.end_qc_tp);
  165. node.end_gather_tp = ZhCalc.add(node.end_gather_tp, c.end_gather_tp);
  166. node.pre_gather_tp = ZhCalc.add(node.pre_gather_tp, c.pre_gather_tp);
  167. node.yf_tp = ZhCalc.add(node.yf_tp, c.yf_tp);
  168. node.end_yf_tp = ZhCalc.add(node.end_yf_tp, c.end_yf_tp);
  169. node.advance_tp = ZhCalc.add(node.advance_tp, c.advance_tp);
  170. node.contract_price = ZhCalc.add(node.contract_price, c.contract_price);
  171. node.sf_tp = ZhCalc.add(node.sf_tp, c.sf_tp);
  172. node.end_sf_tp = ZhCalc.add(node.end_sf_tp, c.end_sf_tp);
  173. node.wf_tp = ZhCalc.add(node.wf_tp, c.wf_tp);
  174. node.hb_tp = ZhCalc.add(node.hb_tp, c.hb_tp);
  175. node.pre_hb_tp = ZhCalc.add(node.pre_hb_tp, c.pre_hb_tp);
  176. node.end_hb_tp = ZhCalc.add(node.end_hb_tp, c.end_hb_tp);
  177. }
  178. }
  179. }
  180. return { getTenderNodeHtml, getTenderTreeHeaderHtml, calculateTender, calculateParent }
  181. })();
  182. $(function () {
  183. autoFlashHeight();
  184. $('#add-tender-btn').click(function () {
  185. const addTenders = [];
  186. $('input[name="tender_id[]"]:checked:not(:disabled)').each(function () {
  187. const tenderId = $(this).val();
  188. if (tenderId) {
  189. addTenders.push(parseInt(tenderId));
  190. }
  191. });
  192. if (addTenders.length === 0) {
  193. toastr.warning('请选择添加标段');
  194. return false;
  195. }
  196. console.log(addTenders);
  197. postData(window.location.pathname + '/update', {postType: 'add-tender', postData: { tenders: addTenders }}, function (result) {
  198. window.location.reload();
  199. });
  200. });
  201. $('body').on('click', '#tender-list .del-tender-btn', function () {
  202. const ftid = $(this).data('id');
  203. deleteAfterHint(function () {
  204. postData(window.location.pathname + '/update', {postType: 'del-tender', postData: { node: ftid }}, function (result) {
  205. window.location.reload();
  206. })
  207. }, '确认删除该标段并移除所有附件?');
  208. });
  209. $('#lock-transfer-btn').click(function () {
  210. postData(`/sp/${spid}/financial/transfer/update`, {postType: 'lock-transfer', postData: { node: trid, lock: 1 }}, function (result) {
  211. window.location.reload();
  212. });
  213. });
  214. $('#unlock-transfer-btn').click(function () {
  215. postData(`/sp/${spid}/financial/transfer/update`, {postType: 'lock-transfer', postData: { node: trid, lock: 0 }}, function (result) {
  216. window.location.reload();
  217. });
  218. });
  219. $('body').on('change', '#tender-list input[type="text"]', function () {
  220. const ftid = $(this).data('ftid');
  221. if (!ftid) {
  222. toastr.error('获取资金划拨标段信息失败');
  223. return;
  224. }
  225. const ftInfo = _.find(tenders, { id: parseInt(ftid) });
  226. if (!ftInfo) {
  227. toastr.error('获取资金划拨信息失败');
  228. return;
  229. }
  230. const key = $(this).data('key');
  231. if (key === 'hb_tp') {
  232. const value = $(this).val() || 0;
  233. // 判断只能输入数字,支持负数和小数
  234. if (!/^-?\d+(\.\d+)?$/.test(value)) {
  235. toastr.error('请输入正确的金额');
  236. $(this).val(ftInfo.hb_tp);
  237. return;
  238. }
  239. postData(window.location.pathname + '/update', {postType: 'update-hb_tp', postData: { node: ftid, hb_tp: parseFloat(value) }}, function (result) {
  240. // window.location.reload();
  241. ftInfo.hb_tp = parseFloat(value);
  242. // 更新并汇总父节点和截止本次划拨汇总
  243. ftInfo.end_hb_tp = ZhCalc.add(ftInfo.pre_hb_tp, ftInfo.hb_tp);
  244. for (const t of tenderTree) {
  245. tenderListSpec.calculateParent(t);
  246. }
  247. $('.c-body').html(getTenderTreeHtml());
  248. });
  249. } else {
  250. const value = $(this).val() || '';
  251. if (value.length > 255) {
  252. toastr.error('输入内容过长,不能超过255个字符');
  253. $(this).val(ftInfo[key]);
  254. return;
  255. }
  256. postData(window.location.pathname + '/update', {postType: 'update-tender', postData: { node: ftInfo.id, key: key, value: value }}, function (result) {
  257. // window.location.reload();
  258. ftInfo[key] = value;
  259. });
  260. }
  261. });
  262. $('body').on('click', '.open-tender-files', function () {
  263. const ftid = $(this).attr('data-ftid');
  264. if (!ftid) {
  265. toastr.error('获取资金划拨标段信息失败');
  266. return;
  267. }
  268. const ftInfo = _.find(tenders, { id: parseInt(ftid) });
  269. if (!ftInfo) {
  270. toastr.error('获取资金划拨信息失败');
  271. return;
  272. }
  273. if (ftInfo.uid === user_id || financialPermission.transfer_file) {
  274. $('#tender-file .upload-permission').show();
  275. } else {
  276. $('#tender-file .upload-permission').hide();
  277. }
  278. $('#tender-file').modal('show');
  279. $('#tender-file input[name="ftid"]').val(ftid);
  280. openFinancialTransferTenderFiles(ftInfo);
  281. });
  282. // 上传附件
  283. $('#tender-file input[type="file"]').change(function () {
  284. const files = Array.from(this.files);
  285. const valiData = files.map(v => {
  286. const ext = v.name.substring(v.name.lastIndexOf('.') + 1)
  287. return {
  288. size: v.size,
  289. ext
  290. }
  291. });
  292. const ftid = $('#tender-file input[name="ftid"]').val();
  293. const ftInfo = _.find(tenders, { id: parseInt(ftid) });
  294. if (!ftInfo) {
  295. toastr.warning('不存在该资金划拨标段');
  296. $('#tender-file input[type="file"]').val('');
  297. return;
  298. }
  299. if (validateFiles(valiData)) {
  300. if (files.length) {
  301. const formData = new FormData()
  302. files.forEach(file => {
  303. formData.append('name', file.name)
  304. formData.append('size', file.size)
  305. formData.append('file', file)
  306. })
  307. postDataWithFile(`/sp/${spid}/financial/transfer/${trid}/tender/${ftInfo.id}/file/upload`, formData, function (result) {
  308. ftInfo.files = result;
  309. openFinancialTransferTenderFiles(ftInfo);
  310. $('#tender-list tr[data-id="' + ftInfo.id + '"] .file-num').text(ftInfo.files.length ? ftInfo.files.length : '');
  311. });
  312. }
  313. }
  314. $('#tender-file input[type="file"]').val('');
  315. });
  316. $('body').on('click', '#tender-file .file-del', function () {
  317. const ftid = $('#tender-file input[name="ftid"]').val();
  318. const ftInfo = _.find(tenders, { id: parseInt(ftid) });
  319. if (!ftInfo) {
  320. toastr.warning('不存在该资金划拨标段');
  321. return;
  322. }
  323. const fid = $(this).data('id');
  324. deleteAfterHint(function () {
  325. postData(`/sp/${spid}/financial/transfer/${trid}/tender/${ftInfo.id}/file/delete`, { id: fid }, function (result) {
  326. ftInfo.files = result;
  327. openFinancialTransferTenderFiles(ftInfo);
  328. $('#tender-list tr[data-id="' + ftInfo.id + '"] .file-num').text(ftInfo.files.length ? ftInfo.files.length : '');
  329. });
  330. }, '确认删除该文件?');
  331. });
  332. function openFinancialTransferTenderFiles(ftInfo, _this = '#tender-file table tbody') {
  333. const files = ftInfo.files;
  334. let filesHtml = '';
  335. const newFiles = files.map(file => {
  336. let showDel = false;
  337. if (file.uid === user_id) {
  338. showDel = true
  339. }
  340. return {...file, showDel}
  341. })
  342. newFiles.forEach((file, idx) => {
  343. filesHtml += `<tr class="text-center">
  344. <td>${idx + 1}</td><td class="text-left"><a href="${file.filepath}" target="_blank">${file.filename}</a></td><td>${file.username}</td><td>${moment(file.upload_time).format('YYYY-MM-DD HH:mm:ss')}</td>
  345. <td>
  346. <div class="btn-group-table">
  347. ${file.viewpath ? `<a href="${file.viewpath}" target="_blank" class="mr-1"><i class="fa fa-eye fa-fw"></i></a>` : ''}
  348. <a href="/sp/${spid}/financial/transfer/${trid}/tender/${ftInfo.id}/file/${file.id}/download" class="mr-1"><i class="fa fa-download fa-fw"></i></a>
  349. ${file.showDel ? `<a href="javascript: void(0);" class="text-danger file-del mr-1" data-id="${file.id}"><i class="fa fa-trash-o fa-fw text-danger"></i></a>` : ''}
  350. </div>
  351. </td>
  352. </tr>`;
  353. });
  354. $(_this).html(filesHtml);
  355. }
  356. $.subMenu({
  357. menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',
  358. toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',
  359. key: 'menu.1.0.0',
  360. miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',
  361. callback: function (info) {
  362. if (info.mini) {
  363. $('.panel-title').addClass('fluid');
  364. $('#sub-menu').removeClass('panel-sidebar');
  365. } else {
  366. $('.panel-title').removeClass('fluid');
  367. $('#sub-menu').addClass('panel-sidebar');
  368. }
  369. autoFlashHeight();
  370. }
  371. });
  372. // 添加标段树结构加载
  373. const EmptyTenderListHtml = [
  374. '<div class="jumbotron">',
  375. '<h3 class="display-6">还没有标段数据</h3>',
  376. '</div>'
  377. ];
  378. const tenderListTree = [];
  379. let tenderListParentId = 0;
  380. function initTenderListTree () {
  381. const levelCategory = category.filter(function (c) {
  382. return c.show_level && c.show_level > 0;
  383. });
  384. function findCategoryNode(cid, value, array) {
  385. for (const a of array) {
  386. if (a.cid === cid && a.vid === value) {
  387. return a;
  388. }
  389. }
  390. }
  391. function getCategoryNode(category, value, parent, i = null) {
  392. const array = parent ? parent.children : tenderListTree;
  393. let cate = findCategoryNode(category.id, value, array);
  394. if (!cate) {
  395. const cateValue = findNode('id', value, category.value);
  396. if (!cateValue) return null;
  397. cate = {
  398. cid: category.id,
  399. vid: value,
  400. name: cateValue.value,
  401. children: [],
  402. level: i ? i : category.show_level,
  403. sort_id: ++tenderListParentId,
  404. sort: cateValue.sort,
  405. };
  406. array.push(cate);
  407. }
  408. return cate;
  409. }
  410. function loadTenderCategory (tender) {
  411. let tenderCategory = null;
  412. for (const [index, lc] of levelCategory.entries()) {
  413. const tenderCate = findNode('cid', lc.id, tender.category);
  414. if (tenderCate) {
  415. tenderCategory = getCategoryNode(lc, tenderCate.value, tenderCategory);
  416. } else {
  417. if (index === 0 && tender.category) {
  418. for (const [i,c] of tender.category.entries()) {
  419. const cate = findNode('id', c.cid, category);
  420. if (cate) {
  421. tenderCategory = getCategoryNode(cate, c.value, tenderCategory, i+1);
  422. }
  423. }
  424. }
  425. return tenderCategory;
  426. }
  427. }
  428. return tenderCategory;
  429. }
  430. tenderListTree.splice(0, tenderListTree.length);
  431. for (const t of tenderList) {
  432. t.valid = true;
  433. delete t.level;
  434. if (t.category && levelCategory.length > 0) {
  435. const parent = loadTenderCategory(t);
  436. if (parent) {
  437. t.level = parent.level + 1;
  438. parent.children.push(t);
  439. } else {
  440. tenderListTree.push(t);
  441. }
  442. } else {
  443. tenderListTree.push(t);
  444. }
  445. }
  446. sortTenderTree(tenderListTree);
  447. }
  448. function recursiveGetTenderListNodeHtml (node, arr, pid) {
  449. const html = [];
  450. html.push('<tr pid="' + pid + '">');
  451. html.push('<td style="width: 60px" class="text-center">');
  452. if (!node.cid) {
  453. html.push(`<input type="checkbox" class="tender-check" name="tender_id[]" value="${node.id}" ${_.findIndex(tenders, { tid: node.id }) !== -1 ? 'checked disabled' : ''} />`);
  454. }
  455. html.push('</td>');
  456. // 名称
  457. html.push('<td style="width: 65%" class="in-' + node.level + '">');
  458. if (node.cid) {
  459. html.push('<i class="fa fa-folder-o"></i> ', node.name);
  460. } else {
  461. html.push('<span class="text-muted mr-2">');
  462. html.push(arr.indexOf(node) === arr.length - 1 ? '└' : '├');
  463. html.push('</span>');
  464. html.push(node.name);
  465. }
  466. html.push('</td>');
  467. // 计量进度
  468. html.push('<td style="width: 25%">');
  469. if (!node.cid && node.cur_flow) {
  470. if (node.progress) {
  471. html.push(node.progress.title + ' (' + '<span class="' + node.progress.status_class + '">' + node.progress.status + '</span>' + ')');
  472. } else {
  473. html.push(node.cur_flow.title + ' (' + '<span class="' + node.cur_flow.status_class + '">' + node.cur_flow.status + '</span>' + ')');
  474. }
  475. }
  476. html.push('</td>');
  477. html.push('</tr>');
  478. if (node.children) {
  479. for (const c of node.children) {
  480. html.push(recursiveGetTenderListNodeHtml(c, node.children, node.sort_id));
  481. }
  482. }
  483. return html.join('');
  484. }
  485. // 根据TenderTree数据获取Html代码
  486. function getTenderListTreeHtml () {
  487. if (tenderListTree.length > 0) {
  488. const html = [];
  489. html.push('<table class="table table-hover table-bordered">');
  490. html.push('<thead style="position: sticky;left:56px;top: 0px;">', '<tr>');
  491. html.push('<th class="text-center" style="width: 60px;">', '选择', '</th>');
  492. html.push('<th class="text-center" style="width: 65%">', '标段名称', '</th>');
  493. html.push('<th class="text-center" style="width: 25%">', '计量进度', '</th>');
  494. html.push('</tr>', '</thead>');
  495. tenderListParentId = 0;
  496. for (const t of tenderListTree) {
  497. html.push(recursiveGetTenderListNodeHtml(t, tenderListTree, ''));
  498. }
  499. html.push('</table>');
  500. return html.join('');
  501. } else {
  502. return EmptyTenderListHtml.join('');
  503. }
  504. }
  505. $('#add-ftt').on('shown.bs.modal', function () {
  506. tenderListOrder.reOrderTenders('', '#copyModalContent', false, tenderList);
  507. initTenderListTree();
  508. $('#add-tender-list').html(getTenderListTreeHtml());
  509. });
  510. })
  511. /**
  512. * 校验文件大小、格式
  513. * @param {Array} files 文件数组
  514. */
  515. function validateFiles(files) {
  516. if (files.length > 10) {
  517. toastr.error('至多同时上传10个文件');
  518. return false
  519. }
  520. return files.every(file => {
  521. if (file.size > 1024 * 1024 * 50) {
  522. toastr.error('文件大小限制为50MB');
  523. return false
  524. }
  525. if (whiteList.indexOf('.' + file.ext.toLowerCase()) === -1) {
  526. toastr.error('请上传正确的格式文件');
  527. return false
  528. }
  529. return true
  530. })
  531. }