'use strict'; /** * * * @author lanjianrong * @date 2020/8/12 * @version */ $(document).ready(function () { $('#advance_add').click(function() { postData(`${window.location.pathname}/${type}/create`, {}, res => { const html = ` 第${res.order}期 ${res.pay_ratio || 0}% ${formatMoney(res.cur_amount || 0)} ${formatMoney(res.prev_amount || 0)} ${formatMoney(res.prev_total_amount || 0)} 3 ${auditConst.statusString[res.status]} 编辑 ` $('#advanceList').prepend(html) $('#advance_add').remove() window.location.href = `${window.location.pathname}/${res.id}/detail` }) return false }) $('#advanceList').on('click', `a[href="#file"]`, function() { const { fileList = [] } = advanceList.find(item => item.id === parseInt($(this).data('id'))) $('#file-content').empty() let html = ` 文件名 上传时间 操作 ` fileList.forEach(file => { html+= ` ${file.filename} ${new Date(file.create_time).toLocaleDateString()} ` }) $('#file-content').append(html) }) function formatMoney(s, dot = ',') { if (!s) return '0.00'; s = parseFloat((s + '').replace(/[^\d\.-]/g, '')).toFixed(2) + ''; let l = s.split('.')[0].split('').reverse(), r = s.split('.')[1]; let t = ''; for (let i = 0; i < l.length; i++) { t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? dot : ''); } return t.split('').reverse().join('') + '.' + r; } })