| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 | 
							- 'use strict';
 
- /**
 
-  *
 
-  *
 
-  * @author Mai
 
-  * @date 2019/2/27
 
-  * @version
 
-  */
 
- $(document).ready(function () {
 
-     // 获取审核相关url
 
-     function getUrlPre () {
 
-         const path = window.location.pathname.split('/');
 
-         return _.take(path, 6).join('/');
 
-     }
 
-     // 搜索审批人
 
-     $('#searchAccount').click(() => {
 
-         const data = {
 
-             keyword: $('#searchName').val(),
 
-         };
 
-         postData('/search/user', data, (data) => {
 
-             const resultDiv = $('#searchResult');
 
-             if (data) {
 
-                 $('h5>span', resultDiv).text(data.name);
 
-                 $('#addAuditor').attr('auditorId', data.id);
 
-                 $('h6', resultDiv).text(data.role);
 
-                 $('p', resultDiv).text(data.company);
 
-                 resultDiv.show();
 
-             } else {
 
-                 toast('未查询到该审核人', 'info');
 
-                 resultDiv.hide();
 
-             }
 
-         }, () => {
 
-             $('#searchResult').hide();
 
-         });
 
-     });
 
-     // 添加审批人
 
-     $('#addAuditor').click(() => {
 
-         postData(getUrlPre() + '/audit/add', { auditorId: $('#addAuditor').attr('auditorId') }, (data) => {
 
-             const html = [];
 
-             html.push('<li class="list-group-item" auditorId="'+ data.aid +'"><a href="javascript: void(0)" class="text-danger pull-right">移除</a>');
 
-             html.push('<span>');
 
-             html.push(data.order + ' ');
 
-             html.push(data.name + ' ');
 
-             html.push('</span>');
 
-             html.push('<small class="text-muted">');
 
-             html.push(data.role);
 
-             html.push('</small></li>');
 
-             $('#auditors').append(html.join(''));
 
-         });
 
-     });
 
-     // 审批人分组选择
 
-     $('#account_group').change(function () {
 
-         let account_html = '<option value="0">选择审批人</option>';
 
-         for (const account of accountList) {
 
-             if (parseInt($(this).val()) === 0 || parseInt($(this).val()) === account.account_group) {
 
-                 const role = account.role !== '' ? '(' + account.role + ')' : '';
 
-                 const company = account.company !== '' ? ' -' + account.company : '';
 
-                 account_html += '<option value="' + account.id + '">' + account.name + role + company + '</option>';
 
-             }
 
-         }
 
-         $('#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('<li class="list-group-item" auditorId="'+ data.aid +'"><a href="javascript: void(0)" class="text-danger pull-right">移除</a>');
 
-                 html.push('<span>');
 
-                 html.push(data.order + ' ');
 
-                 html.push(data.name + ' ');
 
-                 html.push('</span>');
 
-                 html.push('<small class="text-muted">');
 
-                 html.push(data.role);
 
-                 html.push('</small></li>');
 
-                 $('#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('<li class="list-group-item" data-auditid="' + data.aid + '">');
 
-                 auditorshtml.push('<i class="fa fa-stop-circle"></i> ');
 
-                 auditorshtml.push(data.name + ' <small class="text-muted">' + data.role + '</small>');
 
-                 auditorshtml.push('<span class="pull-right">终审</span>');
 
-                 auditorshtml.push('</li>');
 
-                 $('#auditors-list').append(auditorshtml.join(''));
 
-                 const auditorshtml2 = [];
 
-                 // 重新上报时。令其它的审批人流程图标转换
 
-                 $('#auditors-list2 li i').removeClass('fa-stop-circle').addClass('fa-chevron-circle-down');
 
-                 // 添加新审批人
 
-                 auditorshtml2.push('<li class="list-group-item" data-auditid="' + data.aid + '">');
 
-                 auditorshtml2.push('<h5 class="card-title"><i class="fa fa-stop-circle"></i> ');
 
-                 auditorshtml2.push(data.name + ' <small class="text-muted">' + data.role + '</small>');
 
-                 auditorshtml2.push('<span class="pull-right">终审</span>');
 
-                 auditorshtml2.push('</h5></li>');
 
-                 $('#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').length; i++) {
 
-                 $('#auditors-list').eq(i).find('.pull-right').text((i+1 === $('#auditors-list').length ? '终' : transFormToChinese(i+1)) + '审');
 
-                 $('#auditors-list2').eq(i).find('.pull-right').text((i+1 === $('#auditors-list2').length ? '终' : transFormToChinese(i+1)) + '审');
 
-             }
 
-         });
 
-     });
 
-     // 退回选择修改审批人流程
 
-     $('#hideSp').click(function () {
 
-         $('#sp-list2').modal('hide');
 
-     });
 
-     $('a[f-target]').click(function () {
 
-         $($(this).attr('f-target')).modal('show');
 
-     })
 
- });
 
- // 检查上报情况
 
- function checkAuditorFrom () {
 
-     if ($('#auditors li').length === 0) {
 
-         toast('请先选择审批人,再上报数据', 'error', 'exclamation-circle');
 
-         return false;
 
-     }
 
-     $('#hide-all').show();
 
- }
 
- // texterea换行
 
- function auditCheck(i) {
 
-     const opinion = $('textarea[name="opinion"]').eq(i).val().replace(/\r\n/g, '<br/>').replace(/\n/g, '<br/>').replace(/\s/g, ' ');
 
-     $('textarea[name="opinion"]').eq(i).val(opinion);
 
-     return true;
 
- }
 
 
  |