123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328 |
- 'use strict';
- /**
- *
- *
- * @author Mai
- * @date 2019/2/27
- * @version
- */
- $(document).ready(function () {
- let timer = null
- let oldSearchVal = null
- let timer2 = null
- let oldSearchVal2 = null
- $('#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 && cur_uid !== item.id && (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>`
- })
- $('.search-user-list').empty()
- $('.search-user-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 !== cur_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>'
- })
- $('.search-user-list').empty()
- $('.search-user-list').append(html)
- }
- }
- }, 400);
- })
- // 添加审批流程按钮逻辑
- $('.search-user-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
- })
- // 添加到审批流程中
- $('.search-user-list').on('click', 'dd', function () {
- const id = parseInt($(this).data('id'));
- if (id) {
- postData(preUrl + '/audit/add', { auditorId: id }, (datas) => {
- const html = [];
- // 如果是重新上报,添加到重新上报列表中
- const auditorshtml = [];
- for (const [index,data] of datas.entries()) {
- if (index !== 0) {
- html.push('<li class="list-group-item" auditorId="'+ data.aid +'">');
- html.push('<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>');
- }
- // 添加新审批人流程修改
- 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>');
- }
- $('#auditors').html(html.join(''));
- // 重新上报时。令其它的审批人流程图标转换
- // $('#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) + '审');
- // }
- $('#auditors-list').html(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(preUrl + '/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-auditorid="' + 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 === 0 ? '原报' : (i+1 === $('#auditors-list li').length ? '终' : transFormToChinese(i)) + '审');
- // $('#auditors-list2').eq(i).find('.pull-right').text((i+1 === $('#auditors-list2').length ? '终' : transFormToChinese(i+1)) + '审');
- }
- });
- });
- // 协审人搜索
- $('#gr-search2').bind('input propertychange', function(e) {
- oldSearchVal2 = e.target.value;
- timer2 && clearTimeout(timer2);
- timer2 = setTimeout(() => {
- const newVal = $('#gr-search2').val();
- let html = '';
- if (newVal && newVal === oldSearchVal2) {
- 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>`
- })
- $('.search-user-list2').empty();
- $('.search-user-list2').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 => {
- 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>'
- })
- $('.search-user-list2').empty();
- $('.search-user-list2').append(html);
- }
- }
- }, 400);
- })
- // 添加审批流程按钮逻辑
- $('.search-user-list2').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
- });
- // 添加到审批流程中
- $('.search-user-list2').on('click', 'dd', function () {
- const id = parseInt($(this).data('id'));
- if (id) {
- console.log(id);
- postData(preUrl + '/xsaudit/add', { auditorId: id }, (data) => {
- const html = [];
- html.push('<span class="d-inline-block">\n' +
- ' <span class="badge badge-light">\n' +
- ' ' + data.name + '\n' +
- ' <span class="dropdown">\n' +
- ' <a href="javascript:void(0)" class="btn-sm text-danger px-1" title="移除" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-remove"></i></a>\n' +
- ' <div class="dropdown-menu">\n' +
- ' <a class="dropdown-item" href="javascript:void(0);">确认移除审批人?</a>\n' +
- ' <div class="dropdown-divider"></div>\n' +
- ' <div class="px-2 py-1 text-center">\n' +
- ' <button class="btn btn-sm btn-danger" aid="'+ data.aid +'">移除</button>\n' +
- ' <button class="btn btn-sm btn-secondary">取消</button>\n' +
- ' </div>\n' +
- ' </div>\n' +
- ' </span>\n' +
- ' </span>\n' +
- ' </span> ');
- $('#xs-list').append(html.join(''));
- });
- }
- });
- // 删除审批人
- $('body').on('click', '#xs-list .btn-danger', function () {
- const li = $(this).parents('.d-inline-block');
- const data = {
- auditorId: parseInt($(this).attr('aid')),
- };
- postData(preUrl + '/xsaudit/delete', data, (result) => {
- li.remove();
- });
- });
- // 退回选择修改审批人流程
- $('#hideSp').click(function () {
- $('#sp-list').modal('hide');
- });
- $('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 checkAuditorFrom () {
- if ($('#auditors li').length === 0) {
- // if(shenpi_status === shenpiConst.sp_status.gdspl) {
- // toastr.error('请联系管理员添加审批人');
- // } else {
- toastr.error('请先选择审批人,再上报数据');
- // }
- return false;
- }
- let flag = false;
- if (change.code === '') {
- toastr.error('立项书编号不能为空');
- flag = true;
- }
- if (change.name === '') {
- toastr.error('工程名称不能为空');
- flag = true;
- }
- if (!change.reason) {
- toastr.error('变更原因不能为空');
- flag = true;
- }
- if (flag) {
- return false;
- }
- $('#hide-all').show();
- }
- // 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 === 2) {
- if ($('textarea[name="opinion"]').eq(i).val() === '') {
- toastr.error('请输入终止原因');
- return false;
- }
- }
- // 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;
- }
|