advance.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author lanjianrong
  6. * @date 2020/8/12
  7. * @version
  8. */
  9. $(document).ready(function () {
  10. $('#advance_add').click(function() {
  11. postData(`${window.location.pathname}/${type}/create`, {}, res => {
  12. const html = `<tr>
  13. <td><a href="/tender/${res.tid}/advance/${res.id}/detail" data-id="${res.id}">第${res.order}期</a></td>
  14. <td>${res.pay_ratio || 0}%</td>
  15. <td class="text-right">${formatMoney(res.cur_amount || 0)}</td>
  16. <td class="text-right">${formatMoney(res.prev_amount || 0)}</td>
  17. <td class="text-right">${formatMoney(res.prev_total_amount || 0)}</td>
  18. <td><a class="btn btn-sm" href="#file" data-toggle="modal" data-target="#file"><i class="fa fa-paperclip "></i> 3</a></td>
  19. <td>${auditConst.statusString[res.status]}</td>
  20. <td><a href="/tender/${res.tid}/advance/${res.id}/detail" class="btn btn-primary btn-sm">编辑</a></td>
  21. </tr>`
  22. $('#advanceList').prepend(html)
  23. $('#advance_add').remove()
  24. window.location.href = `${window.location.pathname}/${res.id}/detail`
  25. })
  26. return false
  27. })
  28. $('#advanceList').on('click', `a[href="#file"]`, function() {
  29. const { fileList = [] } = advanceList.find(item => item.id === parseInt($(this).data('id')))
  30. $('#file-content').empty()
  31. let html = `<thead>
  32. <tr>
  33. <th>文件名</th>
  34. <th>上传时间</th>
  35. <th>操作</th>
  36. </tr>
  37. </thead>`
  38. fileList.forEach(file => {
  39. html+= `<tr>
  40. <td>${file.filename}</td>
  41. <td>${new Date(file.create_time).toLocaleDateString()}</td>
  42. <td>
  43. <a href="/${file.filepath}" target="_blank" title="下载"><i class="fa fa-download"></i></a>
  44. </td>
  45. </tr>`
  46. })
  47. $('#file-content').append(html)
  48. })
  49. function formatMoney(s, dot = ',') {
  50. if (!s) return '0.00';
  51. s = parseFloat((s + '').replace(/[^\d\.-]/g, '')).toFixed(2) + '';
  52. let l = s.split('.')[0].split('').reverse(),
  53. r = s.split('.')[1];
  54. let t = '';
  55. for (let i = 0; i < l.length; i++) {
  56. t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? dot : '');
  57. }
  58. return t.split('').reverse().join('') + '.' + r;
  59. }
  60. })