'use strict'; /** * * * @author lanjianrong * @date 2020/8/12 * @version */ $(document).ready(function () { // if (!advancePayTotal) { // $('#erro').modal('show'); // } // $('#advance_add').click(function() { // postData(`${window.location.pathname}/${type}/create`, {}, res => { // const html = ` // 第${res.order}期 // ${res.pay_ratio || 0}% // ${formatMoney((res.cur_amount || 0), ',', decimal)} // ${formatMoney((res.prev_amount || 0), ',', decimal)} // ${formatMoney((res.prev_total_amount || 0),',', decimal)} // 3 // ${auditConst.statusString[res.status]} // 编辑 // ` // $('#advanceList').prepend(html) // $('#advance_add').remove() // window.location.href = `${window.location.pathname}/${res.id}/detail` // }) // return false // }) $.subMenu({ menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list', toMenu: '#to-menu', toMiniMenu: '#to-mini-menu', key: 'menu.1.0.0', miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1', callback: function (info) { if (info.mini) { $('.panel-title').addClass('fluid'); $('#sub-menu').removeClass('panel-sidebar'); } else { $('.panel-title').removeClass('fluid'); $('#sub-menu').addClass('panel-sidebar'); } autoFlashHeight(); } }); $('.ml-auto').submit(function () { if (!advancePayTotal) { $('#erro').modal('show'); return false; } return true; }) $('#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) }) $('a[data-target="#sp-list" ]').on('click', function () { const id = $(this).data('vid') postData(`${window.location.pathname}/${id}/auditors`, {}, (res) => { const { auditHistory, auditors, user } = res let auditorsHTML = '' let historyHTML = '' auditors.forEach((auditor, idx) => { if (idx === 0) { auditorsHTML += `
  • ${auditor.name} ${auditor.role} 原报
  • ` } else if(idx === auditors.length -1 && idx !== 0) { auditorsHTML += `
  • ${auditor.name} ${auditor.role} 终审
  • ` } else { auditorsHTML += `
  • ${auditor.name} ${auditor.role} ${transFormToChinese(idx)}审
  • ` } }) $('#auditor-list').empty() $('#auditor-list').append(auditorsHTML) auditHistory.forEach((auditors, idx) => { if(idx === auditHistory.length - 1 && auditHistory.length !== 1) { historyHTML += `
    展开历史审批流程
    ` } historyHTML += `
    ${idx+1}#
    ' }) $('#audit-list').empty() $('#audit-list').append(historyHTML) }) }) $('a[data-target="#del-qi"').on('click', function () { const id = $(this).data('id') const order = $(this).data('order') //期数 $('#del-qi').find('.modal-body').children()[0].innerText = `确认删除「第${order}期」?` $('#del-qi #del-confirm').click(function() { postData(`${window.location.pathname}/delete`, {id}, (res) => { console.log(res); window.location.reload() }) }) }) function formatMoney(s, dot = ',', decimal = 2) { if (!s) { s = 0; return s.toFixed(decimal); } s = parseFloat((s + '').replace(/[^\d\.-]/g, '')).toFixed(decimal) + ''; if (!decimal) { s += '.'; } const 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 : ''); } const num = t.split('').reverse().join('') + (decimal === 0 ? '' : '.' + r); return num.replace('-,', '-'); } function transFormToChinese(num) { const changeNum = ['零', '一', '二', '三', '四', '五', '六', '七', '八', '九']; const unit = ['', '十', '百', '千', '万']; num = parseInt(num); const getWan = temp => { const strArr = temp.toString().split('').reverse(); let newNum = ''; for (let i = 0; i < strArr.length; i++) { newNum = (i == 0 && strArr[i] == 0 ? '' : (i > 0 && strArr[i] == 0 && strArr[i - 1] == 0 ? '' : changeNum[strArr[i]] + (strArr[i] == 0 ? unit[0] : unit[i]))) + newNum; } return strArr.length === 2 && newNum.indexOf('一十') !== -1 ? newNum.replace('一十', '十') : newNum; }; const overWan = Math.floor(num / 10000); let noWan = num % 10000; if (noWan.toString().length < 4) noWan = '0' + noWan; return overWan ? getWan(overWan) + '万' + getWan(noWan) : getWan(num); } function formatDate(date) { if (!date) return ''; date = new Date(date) const year = date.getFullYear(); let mon = date.getMonth() + 1; let day = date.getDate(); let hour = date.getHours(); let minute = date.getMinutes(); let scond = date.getSeconds(); if (mon < 10) { mon = '0' + mon.toString(); } if (day < 10) { day = '0' + day.toString(); } if (hour < 10) { hour = '0' + hour.toString(); } if (minute < 10) { minute = '0' + minute.toString(); } if (scond < 10) { scond = '0' + scond.toString(); } return `${year}${mon}-${day}${hour}:${minute}:${scond}`; } })