123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216 |
- 'use strict';
- /**
- *
- *
- * @author Mai
- * @date 2019/2/27
- * @version
- */
- $(document).ready(function () {
- let timer = null;
- let oldSearchVal = null;
- // 获取审核相关url
- function getUrlPre () {
- const path = window.location.pathname.split('/');
- return _.take(path, 6).join('/');
- }
- $('#gr-search').bind('input propertychange', function(e) {
- oldSearchVal = e.target.value;
- timer && clearTimeout(timer);
- timer = setTimeout(() => {
- const newVal = $('#gr-search').val();
- let html = '';
- if (newVal && newVal === oldSearchVal) {
- accountList.filter(item => item && (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>`;
- });
- $('.book-list').empty();
- $('.book-list').append(html);
- } else {
- if (!$('.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 !== changesUid) {
- 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>';
- });
- $('.book-list').empty();
- $('.book-list').append(html);
- }
- }
- }, 400);
- });
- // 添加审批流程按钮逻辑
- $('.book-list').on('click', 'dt', function () {
- const idx = $(this).find('.acc-btn').attr('data-groupid');
- const type = $(this).find('.acc-btn').attr('data-type');
- if (type === 'hide') {
- $(this).parent().find(`div[data-toggleid="${idx}"]`).show(() => {
- $(this).children().find('i').removeClass('fa-plus-square').addClass('fa-minus-square-o')
- $(this).find('.acc-btn').attr('data-type', 'show')
- })
- } else {
- $(this).parent().find(`div[data-toggleid="${idx}"]`).hide(() => {
- $(this).children().find('i').removeClass('fa-minus-square-o').addClass('fa-plus-square')
- $(this).find('.acc-btn').attr('data-type', 'hide')
- })
- }
- return false
- });
- $('#hideSp').click(function () {
- $('#sub-sp2').modal('hide');
- });
- // 添加到审批流程中
- $('dl').on('click', 'dd', function () {
- const id = parseInt($(this).data('id'));
- if (id !== 0) {
- postData(getUrlPre() + '/audit/add', { auditorId: id }, (datas) => {
- makeSpList(datas);
- });
- }
- });
- // 移除审批流程的审批人
- $('body').on('click', '#auditList li a', function () {
- const uid = $(this).parents('li').attr('data-auditid');
- const li = $(this).parents('li');
- const data = {
- auditorId: uid,
- };
- postData(getUrlPre() + '/audit/delete', data, (result) => {
- li.remove();
- let index = 1;
- $('#auditList li').each(function () {
- $(this).children('.col-auto').eq(0).text(index);
- index++;
- });
- // if (index === 1) {
- // $('#account_list').val(0);
- // }
- // 重新上报时。移除审批流程
- // 令最后一个图标转换
- $('#auditors-list li[data-auditid="' + uid + '"]').remove();
- if ($('#auditors-list li').length !== 0 && !$('#auditors-list li').find('i').hasClass('fa-stop-circle')) {
- $('#auditors-list li').eq($('#auditors-list li').length-1).find('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('.badge-pill').children('small').text(i === 0 ? '原报' : (i+1 === $('#auditors-list li').length ? '终' : transFormToChinese(i)) + '审');
- }
- // $('#auditors-list li').eq(0).find('i').removeClass('fa-chevron-circle-down').addClass('fa-play-circle fa-rotate-90');
- });
- });
- // 切换审批组
- $('#change-sp-group').change(function () {
- const data = {
- type: 'change_sp_group',
- sp_group: parseInt($(this).val()),
- }
- if (!data.sp_group) {
- toastr.error('请选择固定审批组');
- return false;
- }
- console.log(data);
- postData(getUrlPre() + '/audit/spgroup', data, (datas) => {
- makeSpList(datas)
- });
- });
- $('a[f-target]').click(function () {
- $($(this).attr('f-target')).modal('show');
- });
- // 多层modal关闭后的滚动bug修复
- $('#sp-list').on('hidden.bs.modal', function (e) {
- $(document.body).addClass('modal-open');
- });
- function makeSpList(datas) {
- const html = [];
- // 如果是重新上报,添加到重新上报列表中
- const auditorshtml = [];
- for (const [index,data] of datas.entries()) {
- if (index !== 0) {
- html.push('<li class="list-group-item d-flex" data-auditid="'+ data[0].uid +'">');
- html.push(`<div class="col-auto">${index}</div>`);
- html.push('<div class="col">');
- for (const auditor of data) {
- html.push(`<div class="d-inline-block mx-1" auditorId="${auditor.uid}"><i class="fa fa-user text-muted"></i> ${auditor.name} <small class="text-muted">${auditor.role}</small></div>`);
- }
- html.push('</div>');
- html.push('<div class="col-auto">');
- // todo 添加会签或签时
- if (data[0].audit_type !== auditType.key.common) {
- html.push(`<span class="badge badge-pill badge-${auditType.info[data[0].audit_type].class} badge-bg-small"><small>${auditType.info[data[0].audit_type].long}</small></span>`);
- }
- if (shenpi_status === shenpiConst.sp_status.sqspr || (shenpi_status === shenpiConst.sp_status.gdzs && index+1 !== datas.length)) {
- html.push('<a href="javascript: void(0)" class="text-danger pull-right">移除</a>');
- }
- html.push('</div>');
- html.push('</li>');
- }
- auditorshtml.push(`<li class="list-group-item d-flex justify-content-between align-items-center" data-auditid="${index !== 0 ? data[0].uid : ''}">`);
- auditorshtml.push('<span class="mr-1"><i class="fa ' + (index === 0 ? 'fa-play-circle fa-rotate-90' : index+1 === datas.length ? 'fa-stop-circle' : 'fa-chevron-circle-down') + '"></i></span>');
- auditorshtml.push('<span class="text-muted">');
- for (const auditor of data) {
- auditorshtml.push(`<small class="d-inline-block text-dark mx-1" title="${auditor.role}" data-auditorId="${auditor.uid}">${auditor.name}</small>`);
- }
- auditorshtml.push('</span>');
- auditorshtml.push('<div class="d-flex ml-auto">');
- if (data[0].audit_type !== auditType.key.common) {
- auditorshtml.push(`<span class="badge badge-pill badge-${auditType.info[data[0].audit_type].class} p-1"><small>${auditType.info[data[0].audit_type].short}</small></span>`);
- }
- if (index === 0) {
- auditorshtml.push('<span class="badge badge-light badge-pill ml-auto"><small>原报</small></span>');
- } else if (index+1 === datas.length) {
- auditorshtml.push('<span class="badge badge-light badge-pill"><small>终审</small></span>');
- } else {
- auditorshtml.push('<span class="badge badge-light badge-pill"><small>'+ transFormToChinese(index) +'审</small></span>');
- }
- auditorshtml.push('</div>');
- auditorshtml.push('</li>');
- }
- $('#auditList').html(html.join(''));
- $('#auditors-list').html(auditorshtml.join(''));
- }
- });
- // texterea换行
- function auditCheck(i) {
- const inlineRadio1 = $('#inlineRadio1:checked').val()
- const inlineRadio2 = $('#inlineRadio2:checked').val()
- 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);
- if (i === 1) {
- if (!inlineRadio1 && !inlineRadio2) {
- if (!$('#warning-text').length) {
- $('#reject-process').prepend('<p id="warning-text" style="color: red; margin: 0;">请选择退回流程</p>');
- }
- return false;
- }
- if ($('#warning-text').length) $('#warning-text').remove()
- }
- return true;
- }
|