'use strict'; /** * * * @author lanjianrong * @date 2020/8/7 * @version */ $(document).ready(function () { // 获取审核相关url function getUrlPre () { const path = window.location.pathname.split('/'); return _.take(path, 3).join('/'); } // 审批人分组选择 $('#account_group').change(function () { let account_html = '' for (const account of accountList) { if ((parseInt($(this).val()) === 0 || parseInt($(this).val()) === account.account_group) && account.id !== parseInt(userID)) { const role = account.role !== '' ? '(' + account.role + ')' : '' const company = account.company !== '' ? ' -' + account.company : '' account_html += '' } } $('#account_list').html(account_html) }); // 添加到审批流程中 $('body').on('change', '#account_list', function () { let id = $(this).val() id = parseInt(id) if (id !== 0) { postData(getUrlPre() + '/audit/add', { auditorId: id }, (data) => { const html = [] html.push('
  • 移除') html.push('') html.push(data.order + ' ') html.push(data.name + ' ') html.push('') html.push('') html.push(data.role) html.push('
  • ') $('#auditors').append(html.join('')) // 如果是重新上报,添加到重新上报列表中 const auditorshtml = [] // 重新上报时。令其它的审批人流程图标转换 $('#auditors-list li i').removeClass('fa-stop-circle').addClass('fa-chevron-circle-down') for (let i = 0; i < $('#auditors-list li').length; i++) { $('#auditors-list li').eq(i).find('.pull-right').text(transFormToChinese(i+1) + '审') $('#auditors-list2 li').eq(i).find('.pull-right').text(transFormToChinese(i+1) + '审') } // 添加新审批人 auditorshtml.push('
  • ') auditorshtml.push(' ') auditorshtml.push(data.name + ' ' + data.role + '') auditorshtml.push('终审') auditorshtml.push('
  • ') $('#auditors-list').append(auditorshtml.join('')) const auditorshtml2 = []; // 重新上报时。令其它的审批人流程图标转换 $('#auditors-list2 li i').removeClass('fa-stop-circle').addClass('fa-chevron-circle-down') // 添加新审批人 auditorshtml2.push('
  • ') auditorshtml2.push('
    ') auditorshtml2.push(data.name + ' ' + data.role + '') auditorshtml2.push('终审') auditorshtml2.push('
  • '); $('#auditors-list2').append(auditorshtml2.join('')) }); } }); // 删除审批人 $('body').on('click', '#auditors li>a', function () { const li = $(this).parent() const data = { auditorId: parseInt(li.attr('auditorId')), }; postData(getUrlPre() + '/audit/delete', data, (result) => { li.remove(); for (const rst of result) { const aLi = $('li[auditorId=' + rst.aid + ']'); $('span', aLi).text(rst.order + ' ' + rst.name + ' ') } // 如果是重新上报 // 令最后一个图标转换 $('#auditors-list li[data-auditid="' + data.auditorId + '"]').remove() if ($('#auditors-list li').length !== 0 && !$('#auditors-list li i').hasClass('fa-stop-circle')) { $('#auditors-list li').eq($('#auditors-list li').length-1).children('i') .removeClass('fa-chevron-circle-down').addClass('fa-stop-circle') } $('#auditors-list2 li[data-auditid="' + data.auditorId + '"]').remove(); if ($('#auditors-list2 li').length !== 0 && !$('#auditors-list2 li i').hasClass('fa-stop-circle')) { $('#auditors-list2 li').eq($('#auditors-list2 li').length-1).children('i') .removeClass('fa-chevron-circle-down').addClass('fa-stop-circle') } for (let i = 0; i < $('#auditors-list li').length; i++) { $('#auditors-list li').eq(i).find('.pull-right').text((i+1 === $('#auditors-list li').length ? '终' : transFormToChinese(i+1)) + '审') $('#auditors-list2 li').eq(i).find('.pull-right').text((i+1 === $('#auditors-list2 li').length ? '终' : transFormToChinese(i+1)) + '审') } }) }) })