|  | @@ -59,7 +59,7 @@ $(document).ready(function () {
 | 
	
		
			
				|  |  |      })
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      // 添加审批流程按钮逻辑
 | 
	
		
			
				|  |  | -    $('.book-list').on('click', 'dt', function () {
 | 
	
		
			
				|  |  | +    $('body').on('click', '.book-list dt', function () {
 | 
	
		
			
				|  |  |          const idx = $(this).find('.acc-btn').attr('data-groupid')
 | 
	
		
			
				|  |  |          const type = $(this).find('.acc-btn').attr('data-type')
 | 
	
		
			
				|  |  |          if (type === 'hide') {
 | 
	
	
		
			
				|  | @@ -126,7 +126,7 @@ $(document).ready(function () {
 | 
	
		
			
				|  |  |      //     $('#account_list').html(account_html);
 | 
	
		
			
				|  |  |      // });
 | 
	
		
			
				|  |  |      // 添加到审批流程中
 | 
	
		
			
				|  |  | -    $('dl').on('click', 'dd', function () {
 | 
	
		
			
				|  |  | +    $('#book-list').on('click', 'dd', function () {
 | 
	
		
			
				|  |  |          const id = parseInt($(this).data('id'));
 | 
	
		
			
				|  |  |          if (id !== 0) {
 | 
	
		
			
				|  |  |              postData(getUrlPre() + '/audit/add', { auditorId: id }, (datas) => {
 | 
	
	
		
			
				|  | @@ -242,6 +242,226 @@ $(document).ready(function () {
 | 
	
		
			
				|  |  |      });
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    // 管理员更改审批流程js部分
 | 
	
		
			
				|  |  | +    let timer2 = null;
 | 
	
		
			
				|  |  | +    let oldSearchVal2 = null;
 | 
	
		
			
				|  |  | +    $('body').on('input propertychange', '.gr-search', function(e) {
 | 
	
		
			
				|  |  | +        oldSearchVal2 = e.target.value;
 | 
	
		
			
				|  |  | +        timer2 && clearTimeout(timer2);
 | 
	
		
			
				|  |  | +        timer2 = setTimeout(() => {
 | 
	
		
			
				|  |  | +            const newVal = $(this).val();
 | 
	
		
			
				|  |  | +            const code = $(this).attr('data-code');
 | 
	
		
			
				|  |  | +            let html = '';
 | 
	
		
			
				|  |  | +            if (newVal && newVal === oldSearchVal2) {
 | 
	
		
			
				|  |  | +                accountList.filter(item => item && item.id !== stage_uid && (item.name.indexOf(newVal) !== -1 || (item.mobile && item.mobile.indexOf(newVal) !== -1))).forEach(item => {
 | 
	
		
			
				|  |  | +                    html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
 | 
	
		
			
				|  |  | +                        <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
 | 
	
		
			
				|  |  | +                                class="ml-auto">${item.mobile || ''}</span></p>
 | 
	
		
			
				|  |  | +                        <span class="text-muted">${item.role || ''}</span>
 | 
	
		
			
				|  |  | +                    </dd>`
 | 
	
		
			
				|  |  | +                });
 | 
	
		
			
				|  |  | +                $('#' + code + '_dropdownMenu .book-list').empty();
 | 
	
		
			
				|  |  | +                $('#' + code + '_dropdownMenu .book-list').append(html);
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                if (!$('#' + code + '_dropdownMenu .acc-btn').length) {
 | 
	
		
			
				|  |  | +                    accountGroup.forEach((group, idx) => {
 | 
	
		
			
				|  |  | +                        if (!group) return;
 | 
	
		
			
				|  |  | +                        html += `<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="${idx}" data-type="hide"><i class="fa fa-plus-square"></i>
 | 
	
		
			
				|  |  | +                        </a> ${group.groupName}</dt>
 | 
	
		
			
				|  |  | +                        <div class="dd-content" data-toggleid="${idx}">`;
 | 
	
		
			
				|  |  | +                        group.groupList.forEach(item => {
 | 
	
		
			
				|  |  | +                            if (item.id !== stage_uid) {
 | 
	
		
			
				|  |  | +                                html += `<dd class="border-bottom p-2 mb-0 " data-id="${item.id}" >
 | 
	
		
			
				|  |  | +                                    <p class="mb-0 d-flex"><span class="text-primary">${item.name}</span><span
 | 
	
		
			
				|  |  | +                                            class="ml-auto">${item.mobile || ''}</span></p>
 | 
	
		
			
				|  |  | +                                    <span class="text-muted">${item.role || ''}</span>
 | 
	
		
			
				|  |  | +                                </dd>`;
 | 
	
		
			
				|  |  | +                            }
 | 
	
		
			
				|  |  | +                        });
 | 
	
		
			
				|  |  | +                        html += '</div>';
 | 
	
		
			
				|  |  | +                    });
 | 
	
		
			
				|  |  | +                    $('#' + code + '_dropdownMenu .book-list').empty();
 | 
	
		
			
				|  |  | +                    $('#' + code + '_dropdownMenu .book-list').append(html);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }, 400);
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    $('body').on('click', '#admin-edit-shenpi dl dd', function () {
 | 
	
		
			
				|  |  | +        const id = parseInt($(this).attr('data-id'));
 | 
	
		
			
				|  |  | +        if (!id) return;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        let this_aid = parseInt($(this).parents('.book-list').attr('data-aid'));
 | 
	
		
			
				|  |  | +        let this_operate = $(this).parents('.book-list').attr('data-operate');
 | 
	
		
			
				|  |  | +        const user = _.find(accountList, function (item) {
 | 
	
		
			
				|  |  | +            return item.id === id;
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        const auditorIndex = _.findIndex(auditorList, { aid: id });
 | 
	
		
			
				|  |  | +        if (auditorIndex !== -1) {
 | 
	
		
			
				|  |  | +            toastr.warning('该审核人已存在,请勿重复添加');
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        const order = parseInt($(this).parents('tr').find('.shenpi-order').text());
 | 
	
		
			
				|  |  | +        const curAuditorIndex = _.findIndex(auditorList, { aid: this_aid });
 | 
	
		
			
				|  |  | +        const prop = {
 | 
	
		
			
				|  |  | +            operate: this_operate,
 | 
	
		
			
				|  |  | +            old_aid: this_aid,
 | 
	
		
			
				|  |  | +            new_aid: user.id,
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +        postData(getUrlPre() + '/audit/save', prop, (datas) => {
 | 
	
		
			
				|  |  | +            if (this_operate === 'add') {
 | 
	
		
			
				|  |  | +                const addhtml = '<tr>\n' +
 | 
	
		
			
				|  |  | +                    `                                <td><span class="shenpi-order">${order+1}</span> ${user.name} <small class="text-muted">${user.role}</small></td>\n` +
 | 
	
		
			
				|  |  | +                    `                                <td style="text-align: center"><span class="">待审批</span></td>\n` +
 | 
	
		
			
				|  |  | +                    '                                <td style="text-align: center">\n' +
 | 
	
		
			
				|  |  | +                    '                                    <span class="dropdown mr-2">\n' +
 | 
	
		
			
				|  |  | +                    `                                    <a href="javascript: void(0)" class="add-audit" id="${user.id}_add_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">增加</a>\n` +
 | 
	
		
			
				|  |  | +                    makeSelectAudit(user.id+'_add', user.id, 'add') +
 | 
	
		
			
				|  |  | +                    '                                        </div>\n' +
 | 
	
		
			
				|  |  | +                    '                                    </span>\n' +
 | 
	
		
			
				|  |  | +                    '                                    <span class="dropdown mr-2">\n' +
 | 
	
		
			
				|  |  | +                    `                                        <a href="javascript: void(0)" class="change-audit" id="${user.id}_change_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">更换</a>\n` +
 | 
	
		
			
				|  |  | +                    makeSelectAudit(user.id+'_change', user.id, 'change') +
 | 
	
		
			
				|  |  | +                    '                                    </span>\n' +
 | 
	
		
			
				|  |  | +                    '                                    <span class="dropdown">\n' +
 | 
	
		
			
				|  |  | +                    '                                    <a href="javascript: void(0)" class="text-danger" title="移除" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">移除</a>\n' +
 | 
	
		
			
				|  |  | +                    '                                    <div class="dropdown-menu">\n' +
 | 
	
		
			
				|  |  | +                    '                                        <span class="dropdown-item">确认移除审批人?</span>\n' +
 | 
	
		
			
				|  |  | +                    '                                        <div class="dropdown-divider"></div>\n' +
 | 
	
		
			
				|  |  | +                    '                                        <div class="px-2 py-1 text-center">\n' +
 | 
	
		
			
				|  |  | +                    `                                            <button class="remove-audit btn btn-sm btn-danger" data-id="${user.id}">移除</button>\n` +
 | 
	
		
			
				|  |  | +                    '                                            <button class="btn btn-sm btn-secondary">取消</button>\n' +
 | 
	
		
			
				|  |  | +                    '                                        </div>\n' +
 | 
	
		
			
				|  |  | +                    '                                    </div>\n' +
 | 
	
		
			
				|  |  | +                    '                                    </span>\n' +
 | 
	
		
			
				|  |  | +                    '                                </td>\n' +
 | 
	
		
			
				|  |  | +                    '                            </tr>';
 | 
	
		
			
				|  |  | +                $(this).parents('tr').after(addhtml);
 | 
	
		
			
				|  |  | +                auditorList.splice(curAuditorIndex+1, 0, { aid: user.id, company: user.company, name: user.name, role: user.role });
 | 
	
		
			
				|  |  | +                updateOrder(user.id);
 | 
	
		
			
				|  |  | +            } else if (this_operate === 'change') {
 | 
	
		
			
				|  |  | +                const this_user = _.find(auditorList, { aid: this_aid });
 | 
	
		
			
				|  |  | +                this_user.aid = user.id;
 | 
	
		
			
				|  |  | +                this_user.company = user.company;
 | 
	
		
			
				|  |  | +                this_user.role = user.role;
 | 
	
		
			
				|  |  | +                this_user.name = user.name;
 | 
	
		
			
				|  |  | +                auditorList.splice(curAuditorIndex, 1, this_user);
 | 
	
		
			
				|  |  | +                $(this).parents('tr').children('td').eq(0).html(`<span class="shenpi-order">${order}</span> ${user.name} <small class="text-muted">${user.role}</small>`);
 | 
	
		
			
				|  |  | +                // 替换所有aid
 | 
	
		
			
				|  |  | +                $(this).parents('.book-list').attr('data-aid', user.id);
 | 
	
		
			
				|  |  | +                $(this).parents('.dropdown-menu').attr('id', user.id +'_change_dropdownMenu').attr('aria-labelledby', user.id +'_change_dropdownMenuButton');
 | 
	
		
			
				|  |  | +                $(this).parents('.dropdown-menu').children('mb-2').children('input').attr('data-code', user.id +'_change');
 | 
	
		
			
				|  |  | +                $(this).parents('.dropdown-menu').siblings('.change-audit').attr('id', user.id +'_change_dropdownMenuButton');
 | 
	
		
			
				|  |  | +                $(this).parents('td').children('span').eq(0).find('.add-audit').attr('id', user.id +'_add_dropdownMenuButton');
 | 
	
		
			
				|  |  | +                $(this).parents('td').children('span').eq(0).find('.dropdown-menu').attr('id', user.id +'_add_dropdownMenu').attr('aria-labelledby', user.id +'_add_dropdownMenuButton');
 | 
	
		
			
				|  |  | +                $(this).parents('td').children('span').eq(0).find('.dropdown-menu').children('mb-2').children('input').attr('data-code', user.id +'_add');
 | 
	
		
			
				|  |  | +                $(this).parents('td').children('span').eq(0).find('.dropdown-menu').children('.book-list').attr('data-aid', user.id);
 | 
	
		
			
				|  |  | +                $(this).parents('td').children('span').eq(2).find('.remove-audit').attr('data-id', user.id);
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            changeLiucheng(datas);
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // 移除审批人
 | 
	
		
			
				|  |  | +    $('body').on('click', '.remove-audit', function () {
 | 
	
		
			
				|  |  | +        const id = parseInt($(this).attr('data-id'));
 | 
	
		
			
				|  |  | +        const prop = {
 | 
	
		
			
				|  |  | +            operate: 'del',
 | 
	
		
			
				|  |  | +            old_aid: id,
 | 
	
		
			
				|  |  | +        };
 | 
	
		
			
				|  |  | +        postData(getUrlPre() + '/audit/save', prop, (datas) => {
 | 
	
		
			
				|  |  | +            updateOrder(id, 0);
 | 
	
		
			
				|  |  | +            const curAuditorIndex = _.findIndex(auditorList, { aid: id });
 | 
	
		
			
				|  |  | +            auditorList.splice(curAuditorIndex, 1);
 | 
	
		
			
				|  |  | +            $(this).parents('tr').remove();
 | 
	
		
			
				|  |  | +            changeLiucheng(datas);
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +    });
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // 比uid大的序号进行调整
 | 
	
		
			
				|  |  | +    function updateOrder(aid, num = 1) {
 | 
	
		
			
				|  |  | +        console.log('hello');
 | 
	
		
			
				|  |  | +        const index = _.findIndex(auditorList, { aid });
 | 
	
		
			
				|  |  | +        console.log(index, auditorList.length);
 | 
	
		
			
				|  |  | +        for (let i = index;i < auditorList.length; i++) {
 | 
	
		
			
				|  |  | +            console.log(i,i+num, auditorList.length);
 | 
	
		
			
				|  |  | +            $('#admin-edit-shenpi tbody').children('tr').eq(i).find('.shenpi-order').text(i+num);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    function changeLiucheng(datas) {
 | 
	
		
			
				|  |  | +        const auditorshtml = [];
 | 
	
		
			
				|  |  | +        for (const [index,data] of datas.entries()) {
 | 
	
		
			
				|  |  | +            auditorshtml.push('<li class="list-group-item" data-auditorid="' + data.aid + '">');
 | 
	
		
			
				|  |  | +            auditorshtml.push('<i class="fa ' + (index+1 === datas.length ? 'fa-stop-circle' : 'fa-chevron-circle-down') + '"></i> ');
 | 
	
		
			
				|  |  | +            auditorshtml.push(data.name + ' <small class="text-muted">' + data.role + '</small>');
 | 
	
		
			
				|  |  | +            if (index === 0) {
 | 
	
		
			
				|  |  | +                auditorshtml.push('<span class="pull-right">原报</span>');
 | 
	
		
			
				|  |  | +            } else if (index+1 === datas.length) {
 | 
	
		
			
				|  |  | +                auditorshtml.push('<span class="pull-right">终审</span>');
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                auditorshtml.push('<span class="pull-right">'+ transFormToChinese(index) +'审</span>');
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +            auditorshtml.push('</li>');
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        let html = '<li class="timeline-list-item pb-2">\n' +
 | 
	
		
			
				|  |  | +            '                                            <div class="timeline-item-date">\n' +
 | 
	
		
			
				|  |  | +            '                                                \n' +
 | 
	
		
			
				|  |  | +            '                                            </div>\n' +
 | 
	
		
			
				|  |  | +            '                                            <div class="timeline-item-icon bg-secondary text-light">\n' +
 | 
	
		
			
				|  |  | +            '                                            </div>\n' +
 | 
	
		
			
				|  |  | +            '                                            <div class="timeline-item-content">\n' +
 | 
	
		
			
				|  |  | +            '                                                <div class="card">\n' +
 | 
	
		
			
				|  |  | +            '                                                    <div class="card-body p-3">\n' +
 | 
	
		
			
				|  |  | +            '                                                        <div class="card-text">\n' +
 | 
	
		
			
				|  |  | +            `                                                            <p class="mb-1"><span class="h5">fuqingqing</span>\n` +
 | 
	
		
			
				|  |  | +            '                                                                <span class="pull-right ">\n' +
 | 
	
		
			
				|  |  | +            '                                                                    \n' +
 | 
	
		
			
				|  |  | +            '                                                                    \n' +
 | 
	
		
			
				|  |  | +            '                                                                    \n' +
 | 
	
		
			
				|  |  | +            '                                                                </span>\n' +
 | 
	
		
			
				|  |  | +            '                                                            </p>\n' +
 | 
	
		
			
				|  |  | +            `                                                            <p class="text-muted mb-0">测试角色</p>\n` +
 | 
	
		
			
				|  |  | +            '                                                        </div>\n' +
 | 
	
		
			
				|  |  | +            '                                                    </div>\n' +
 | 
	
		
			
				|  |  | +            '                                                </div>\n' +
 | 
	
		
			
				|  |  | +            '                                            </div>\n' +
 | 
	
		
			
				|  |  | +            '                                        </li>';
 | 
	
		
			
				|  |  | +        $('.auditors-list').html(auditorshtml.join(''));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    // 审批流程-选择审批人html 生成
 | 
	
		
			
				|  |  | +    function makeSelectAudit(code, aid, status) {
 | 
	
		
			
				|  |  | +        let divhtml = '';
 | 
	
		
			
				|  |  | +        accountGroup.forEach((group, idx) => {
 | 
	
		
			
				|  |  | +            let didivhtml = '';
 | 
	
		
			
				|  |  | +            if(group) {
 | 
	
		
			
				|  |  | +                group.groupList.forEach(item => {
 | 
	
		
			
				|  |  | +                    didivhtml += item.id !== stage_uid ? '<dd class="border-bottom p-2 mb-0 " data-id="' + item.id + '" >\n' +
 | 
	
		
			
				|  |  | +                        '<p class="mb-0 d-flex"><span class="text-primary">' + item.name + '</span><span\n' +
 | 
	
		
			
				|  |  | +                        '                                                                                class="ml-auto">' + item.mobile + '</span></p>\n' +
 | 
	
		
			
				|  |  | +                        '                                                                    <span class="text-muted">' + item.role + '</span>\n' +
 | 
	
		
			
				|  |  | +                        '                                                                    </dd>\n' : '';
 | 
	
		
			
				|  |  | +                });
 | 
	
		
			
				|  |  | +                divhtml += '<dt><a href="javascript: void(0);" class="acc-btn" data-groupid="' + idx + '" data-type="hide"><i class="fa fa-plus-square"></i></a> ' + group.groupName + '</dt>\n' +
 | 
	
		
			
				|  |  | +                    '                                                                <div class="dd-content" data-toggleid="' + idx + '">\n' + didivhtml +
 | 
	
		
			
				|  |  | +                    '                                                                </div>\n';
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        });
 | 
	
		
			
				|  |  | +        let html = '<div class="dropdown-menu dropdown-menu-right" id="' + code + '_dropdownMenu" aria-labelledby="' + code + '_dropdownMenuButton" style="width:220px">\n' +
 | 
	
		
			
				|  |  | +            '                                                        <div class="mb-2 p-2"><input class="form-control form-control-sm gr-search"\n' +
 | 
	
		
			
				|  |  | +            '                                                                                     placeholder="姓名/手机 检索" autocomplete="off" data-code="' + code + '"></div>\n' +
 | 
	
		
			
				|  |  | +            '                                                        <dl class="list-unstyled book-list" data-aid="'+ aid +'" data-operate="'+ status +'">\n' + divhtml +
 | 
	
		
			
				|  |  | +            '                                                        </dl>\n' +
 | 
	
		
			
				|  |  | +            '                                                    </div>\n' +
 | 
	
		
			
				|  |  | +            '                                                </div>\n' +
 | 
	
		
			
				|  |  | +            '                                            </span>\n' +
 | 
	
		
			
				|  |  | +            '                                        </span>\n' +
 | 
	
		
			
				|  |  | +            '                                        </li>';
 | 
	
		
			
				|  |  | +        return html;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  });
 | 
	
		
			
				|  |  |  // 检查上报情况
 | 
	
		
			
				|  |  |  function checkAuditorFrom () {
 |