'use strict'; /** * 期计量 - 期列表页面 js * * @author Mai * @date 2018/12/7 * @version */ $(function () { // 获取审批流程 $('a[data-target="#sp-list" ]').on('click', function () { const data = { order: $(this).attr('m-order'), }; postData('/tender/' + tenderId + '/measure/material/auditors', data, function (result) { const { auditHistory, auditors, user } = result 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) const leftAuditors = auditors; auditHistory.forEach((auditors, idx) => { if(idx === auditHistory.length - 1 && auditHistory.length !== 1) { historyHTML += `
    展开历史审批流程
    ` } historyHTML += `
    ${idx + 1}#
    ' }) $('#audit-list').empty() $('#audit-list').append(historyHTML) }); }); // 展开/收起历史审核记录 $('#audit-list').on('click', 'a', function() { const type = $(this).data('target') const auditCard = $(this).parent().parent() console.log('auditCard', auditCard) if (type === 'show') { $(this).data('target', 'hide') auditCard.find('.fold-card').slideDown('swing', () => { auditCard.find('#end-target').text($(this).data('idx') + '#') auditCard.find('#fold-btn').text('收起历史审核记录') }) } else { $(this).data('target', 'show') auditCard.find('.fold-card').slideUp('swing', () => { auditCard.find('#end-target').text('1#') auditCard.find('#fold-btn').text('展开历史审核记录') }) } }); 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}`; }; // 计量期选中 $('.select-stage-order').on('click', function () { const stageList = $('.select-stage-order:checked'); if (stageList.length === 0) { $('#show_order').hide(); $('#s_order').val(''); } else { const order_array = []; for (let s = 0; s < stageList.length; s++) { order_array.push(stageList.eq(s).data('order')); // console.log(stageList.eq(s)); } $('#show_order').html('第' + order_array.join(',') + '期'); $('#show_order').show(); $('#s_order').val(order_array.join(',')); } }); // 提交表单判断 $('#addMaterial').click(function () { $(this).attr('disabled', true); if ($('#s_order').val() == '') { toastr.error('请选择计量期'); $(this).removeAttr('disabled'); return false; } $(this).text('正在生成新一期数据中,请勿刷新本页!...'); $(this).parents('form').submit(); }); let editPeriod = null; $('.edit-material').on('click', function () { const order = parseInt($(this).data('order')); const mid = parseInt($(this).data('mid')); $('#edit-period').val(''); $('#edit-name').val('第 ' + order + ' 期'); $('#edit-mid').val(mid); const m_period = $(this).data('period'); const period = []; for (const p of m_period.split('~')) { if (p && p !== '') { period.push(new Date(p)); } } $('#edit-period').val(m_period); editPeriod = !editPeriod ? $('#edit-period').datepicker().data('datepicker') : editPeriod; editPeriod.clear(); if (period.length > 0) { editPeriod.selectDate(period); } }); }); function checkForm () { if ($('#edit-period').val() == '') { toastr.error('请选择调差周期'); return false; } // const date = $('#edit-date').val(); // const period = $('#edit-period').val(); // const startDate = period.split('~')[0]; // const endDate = period.split('~')[1]; // if (startDate.indexOf(date) === -1 && endDate.indexOf(date) === -1) { // toastr.error('所选日期与当前月份不匹配,请重新选择'); // $('#edit-period').parents('.form-group').find('.text-danger').remove(); // $('#edit-period').parents('.form-group').append('所选日期与当前月份不匹配,请重新选择'); // return false; // } };