advance.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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. function formatMoney(s, dot = ',') {
  29. if (!s) return '0.00';
  30. s = parseFloat((s + '').replace(/[^\d\.-]/g, '')).toFixed(2) + '';
  31. let l = s.split('.')[0].split('').reverse(),
  32. r = s.split('.')[1];
  33. let t = '';
  34. for (let i = 0; i < l.length; i++) {
  35. t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? dot : '');
  36. }
  37. return t.split('').reverse().join('') + '.' + r;
  38. }
  39. })