|
@@ -0,0 +1,209 @@
|
|
|
+'use strict';
|
|
|
+
|
|
|
+/**
|
|
|
+ *
|
|
|
+ *
|
|
|
+ * @author Ellisran
|
|
|
+ * @date 2020/10/09
|
|
|
+ * @version
|
|
|
+ */
|
|
|
+
|
|
|
+$(document).ready(function () {
|
|
|
+ let timer = null
|
|
|
+ let oldSearchVal = null
|
|
|
+ $('body').bind('input propertychange', '.gr-search', function(e) {
|
|
|
+ oldSearchVal = e.target.value;
|
|
|
+ timer && clearTimeout(timer);
|
|
|
+ timer = setTimeout(() => {
|
|
|
+ const newVal = $(this).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>`
|
|
|
+ })
|
|
|
+ $('.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 !== 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>'
|
|
|
+ });
|
|
|
+ $('.book-list').empty();
|
|
|
+ $('.book-list').append(html);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 400);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 添加审批流程按钮逻辑
|
|
|
+ $('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') {
|
|
|
+ $(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;
|
|
|
+ });
|
|
|
+
|
|
|
+ // 更改审批流程状态
|
|
|
+ $('.form-check input').on('change', function () {
|
|
|
+ // 获取所有审批的checked值并更新
|
|
|
+ const this_status = parseInt($(this).val());
|
|
|
+ const this_code = $(this).data('code');
|
|
|
+ const spt = sp_status_list[this_status];
|
|
|
+ $(this).parents('.form-group').siblings('.alert-warning').text(spt.name + ':' + spt.msg);
|
|
|
+ if (this_status === sp_status.sqspr) {
|
|
|
+ $(this).parents('.form-group').siblings('.lc-show').html('');
|
|
|
+ } else if (this_status === sp_status.gdspl) {
|
|
|
+ let addhtml = '<ul class="list-unstyled">\n';
|
|
|
+ addhtml += makeSelectAudit(this_code, '一');
|
|
|
+ addhtml += '</ul>\n';
|
|
|
+ $(this).parents('.form-group').siblings('.lc-show').html(addhtml);
|
|
|
+ } else if (this_status === sp_status.gdzs) {
|
|
|
+ let addhtml = '<ul class="list-unstyled">\n' +
|
|
|
+ ' <li class="d-flex justify-content-start mb-3">\n' +
|
|
|
+ ' <span class="col-auto">授权审批人</span>\n' +
|
|
|
+ ' <span class="col-7">\n' +
|
|
|
+ ' <span class="d-inline-block"></span>\n' +
|
|
|
+ ' </span>\n' +
|
|
|
+ ' </li>\n';
|
|
|
+ addhtml += makeSelectAudit(this_code);
|
|
|
+ addhtml += '</ul>\n';
|
|
|
+ $(this).parents('.form-group').siblings('.lc-show').html(addhtml);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 选中审批人
|
|
|
+ $('body').on('click', 'dl dd', function () {
|
|
|
+ const id = parseInt($(this).data('id'));
|
|
|
+ if (id) {
|
|
|
+ const user = _.find(accountList, function (item) {
|
|
|
+ return item.id === id;
|
|
|
+ });
|
|
|
+
|
|
|
+ const this_status = parseInt($(this).parents('.lc-show').siblings('.form-group').find('input:checked').val());
|
|
|
+ if (this_status === sp_status.gdspl) {
|
|
|
+ // 判断是否已存在审批人
|
|
|
+ const aid_num = $(this).parents('ul').find('.remove-audit').length;
|
|
|
+ for (let i = 0; i < aid_num; i++) {
|
|
|
+ const aid = parseInt($(this).parents('ul').find('.remove-audit').eq(i).data('id'));
|
|
|
+ if (aid === id) {
|
|
|
+ toastr.warning('该审核人已存在,请勿重复添加');
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $(this).parents('ul').append('<li class="pl-3"><a href="javascript:void(0);" class="add-audit"><i class="fa fa-plus"></i> 添加流程</a></li>');
|
|
|
+ }
|
|
|
+ $(this).parents('.spr-span').html('<span class="d-inline-block"></span>\n' +
|
|
|
+ '<span class="d-inline-block"><span class="badge badge-light">'+ user.name +' <a href="javascript:void(0);" class="remove-audit btn-sm text-danger px-1" title="移除" data-id="'+ user.id +'"><i class="fa fa-remove"></i></a></span> </span>');
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 移除审批人
|
|
|
+ $('body').on('click', '.remove-audit', function () {
|
|
|
+ const id = parseInt($(this).data('id'));
|
|
|
+ const this_status = parseInt($(this).parents('.lc-show').siblings('.form-group').find('input:checked').val());
|
|
|
+ const this_code = $(this).parents('.lc-show').siblings('.form-group').find('input:checked').data('code');
|
|
|
+ if (this_status === sp_status.gdspl) {
|
|
|
+ const _self = $(this).parents('.lc-show');
|
|
|
+ $(this).parents('li').remove();
|
|
|
+ const aid_num = parseInt(_self.children('ul').find('li.d-flex').length);
|
|
|
+ if (aid_num === 0) {
|
|
|
+ let addhtml = '<ul class="list-unstyled">\n';
|
|
|
+ addhtml += makeSelectAudit(this_code, '一');
|
|
|
+ addhtml += '</ul>\n';
|
|
|
+ _self.html(addhtml);
|
|
|
+ } else {
|
|
|
+ for (let i = 0; i < aid_num; i++) {
|
|
|
+ _self.find('li.d-flex').eq(i).find('.col-auto').text(transFormToChinese(i+1) + '审');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (this_status === sp_status.gdzs) {
|
|
|
+ let addhtml = '<ul class="list-unstyled">\n' +
|
|
|
+ ' <li class="d-flex justify-content-start mb-3">\n' +
|
|
|
+ ' <span class="col-auto">授权审批人</span>\n' +
|
|
|
+ ' <span class="col-7">\n' +
|
|
|
+ ' <span class="d-inline-block"></span>\n' +
|
|
|
+ ' </span>\n' +
|
|
|
+ ' </li>\n';
|
|
|
+ addhtml += makeSelectAudit(this_code);
|
|
|
+ addhtml += '</ul>\n';
|
|
|
+ $(this).parents('.lc-show').html(addhtml);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ // 固定审批流-添加流程
|
|
|
+ $('body').on('click', '.add-audit', function () {
|
|
|
+ const num = $(this).parents('ul').children('li').length;
|
|
|
+ const this_code = $(this).parents('.lc-show').siblings('.form-group').find('input:checked').data('code');
|
|
|
+ const addhtml = makeSelectAudit(this_code, transFormToChinese(num));
|
|
|
+ $(this).parents('ul').append(addhtml);
|
|
|
+ $(this).parents('li').remove();
|
|
|
+ });
|
|
|
+
|
|
|
+ // 审批流程-选择审批人html 生成
|
|
|
+ function makeSelectAudit(code, i = '终') {
|
|
|
+ let divhtml = '';
|
|
|
+ accountGroup.forEach((group, idx) => {
|
|
|
+ let didivhtml = '';
|
|
|
+ if(group) {
|
|
|
+ group.groupList.forEach(item => {
|
|
|
+ didivhtml += item.id !== cur_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 = '<li class="d-flex justify-content-start mb-3">\n' +
|
|
|
+ ' <span class="col-auto">' + i + '审</span>\n' +
|
|
|
+ ' <span class="col-7 spr-span">\n' +
|
|
|
+ ' <span class="d-inline-block">\n' +
|
|
|
+ ' <div class="dropdown text-right">\n' +
|
|
|
+ ' <button class="btn btn-outline-primary btn-sm dropdown-toggle" type="button" id="' + code + '_dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">\n' +
|
|
|
+ ' 选择审批人\n' +
|
|
|
+ ' </button>\n' +
|
|
|
+ ' <div class="dropdown-menu dropdown-menu-right" 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"></div>\n' +
|
|
|
+ ' <dl class="list-unstyled book-list">\n' + divhtml +
|
|
|
+ ' </dl>\n' +
|
|
|
+ ' </div>\n' +
|
|
|
+ ' </div>\n' +
|
|
|
+ ' </span>\n' +
|
|
|
+ ' </span>\n' +
|
|
|
+ ' </li>';
|
|
|
+ return html;
|
|
|
+ }
|
|
|
+});
|