|
@@ -0,0 +1,212 @@
|
|
|
+'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) {
|
|
|
+ const auditListIdData = [];
|
|
|
+ $('#auditList li').each(function () {
|
|
|
+ const aid = $(this).data('auditid');
|
|
|
+ auditListIdData.push(aid);
|
|
|
+ });
|
|
|
+ if (!in_array(auditListIdData, id)) {
|
|
|
+ postData(getUrlPre() + '/audit/add', { auditorId: id }, (datas) => {
|
|
|
+ if (shenpi_status === shenpiConst.sp_status.gdzs) {
|
|
|
+ auditListIdData.splice(-1,0,id);
|
|
|
+ } else {
|
|
|
+ auditListIdData.push(id);
|
|
|
+ }
|
|
|
+ const html = [];
|
|
|
+ const auditorshtml = [];
|
|
|
+ auditListIdData.unshift(changesUid);
|
|
|
+ for (const [index,ids] of auditListIdData.entries()) {
|
|
|
+ const accountInfo = _.find(accountList, { 'id': ids });
|
|
|
+ if (index !== 0) {
|
|
|
+ const user = accountInfo.id + '/%/' + accountInfo.name + '/%/' + accountInfo.role + '/%/' + accountInfo.company;
|
|
|
+ html.push('<li class="list-group-item" data-auditmsg="' + user + '" data-auditid="'+ ids +'">');
|
|
|
+ if (shenpi_status === shenpiConst.sp_status.sqspr || (shenpi_status === shenpiConst.sp_status.gdzs && index+1 !== auditListIdData.length)) {
|
|
|
+ html.push('<a href="javascript:void(0);" class="text-danger pull-right remove_audit_btn">移除</a>');
|
|
|
+ }
|
|
|
+ html.push('<span>');
|
|
|
+ html.push(index + ' ');
|
|
|
+ html.push('</span> ');
|
|
|
+ html.push(accountInfo.name + ' ');
|
|
|
+ html.push('<small class="text-muted">');
|
|
|
+ html.push(accountInfo.role);
|
|
|
+ html.push('</small>');
|
|
|
+ html.push('<p class="m-0 ml-2"><small class="text-muted">' + accountInfo.company + '</small></p>');
|
|
|
+ html.push('</li>');
|
|
|
+ }
|
|
|
+ // 添加新审批人流程修改
|
|
|
+ auditorshtml.push('<li class="list-group-item" ' + (index !== 0 ? 'data-auditid="' + accountInfo.id + '"' : '') + '>');
|
|
|
+ auditorshtml.push('<i class="fa ' + (index+1 === auditListIdData.length ? 'fa-stop-circle' : 'fa-chevron-circle-down') + '"></i> ');
|
|
|
+ auditorshtml.push(accountInfo.name + ' <small class="text-muted">' + accountInfo.role + '</small>');
|
|
|
+ if (index === 0) {
|
|
|
+ auditorshtml.push('<span class="pull-right">原报</span>');
|
|
|
+ } else if (index+1 === auditListIdData.length) {
|
|
|
+ auditorshtml.push('<span class="pull-right">终审</span>');
|
|
|
+ } else {
|
|
|
+ auditorshtml.push('<span class="pull-right">'+ transFormToChinese(index) +'审</span>');
|
|
|
+ }
|
|
|
+ auditorshtml.push('</li>');
|
|
|
+ }
|
|
|
+ $('#auditList').html(html.join(''));
|
|
|
+ $('#shenpi-audit-list').html(auditorshtml.join(''));
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ toastr.error('审批流程中已存在该用户!');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 移除审批流程的审批人
|
|
|
+ $('body').on('click', '.remove_audit_btn', function () {
|
|
|
+ const uid = $(this).parents('li').attr('data-auditid');
|
|
|
+ const li = $(this).parent();
|
|
|
+ const data = {
|
|
|
+ auditorId: uid,
|
|
|
+ };
|
|
|
+ postData(getUrlPre() + '/audit/delete', data, (result) => {
|
|
|
+ li.remove();
|
|
|
+ let index = 1;
|
|
|
+ $('#auditList li').each(function () {
|
|
|
+ $(this).children('span').text(index);
|
|
|
+ index++;
|
|
|
+ });
|
|
|
+ if (index === 1) {
|
|
|
+ $('#account_list').val(0);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 重新上报时。移除审批流程
|
|
|
+ // 令最后一个图标转换
|
|
|
+ $('#shenpi-audit-list li[data-auditid="' + uid + '"]').remove();
|
|
|
+ if ($('#shenpi-audit-list li').length !== 0 && !$('#shenpi-audit-list li i').hasClass('fa-stop-circle')) {
|
|
|
+ $('#shenpi-audit-list li').eq($('#shenpi-audit-list li').length-1).children('i')
|
|
|
+ .removeClass('fa-chevron-circle-down').addClass('fa-stop-circle');
|
|
|
+ }
|
|
|
+ for (let i = 0; i < $('#shenpi-audit-list li').length; i++) {
|
|
|
+ $('#shenpi-audit-list li').eq(i).find('.pull-right').text(i === 0 ? '原报' : (i+1 === $('#shenpi-audit-list li').length ? '终' : transFormToChinese(i)) + '审');
|
|
|
+ }
|
|
|
+ $('#shenpi-audit-list li i').eq(0).removeClass('fa-chevron-circle-down').addClass('fa-play-circle');
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
+ $('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;
|
|
|
+ }
|
|
|
+ $('#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 === 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;
|
|
|
+}
|