| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571 | 
							- 'use strict';
 
- /**
 
-  * 项目信息js
 
-  *
 
-  * @author EllisRan.
 
-  * @date 2019/3/19
 
-  * @version
 
-  */
 
- $(document).ready(() => {
 
-     // 启用和停用账号
 
-     $('.account-switch-btn').on('click', function () {
 
-         const data = {
 
-             enable: $(this).hasClass('btn-outline-success') ? 1 : 0,
 
-             id: $(this).data('account'),
 
-         };
 
-         postData('/setting/user/switch', data, function () {
 
-             window.location.href = '/setting/user';
 
-         });
 
-     });
 
-     // 编辑账号
 
-     $('a[data-target="#edit-user"]').on('click', function () {
 
-         const account = $(this).data('account');
 
-         $('#edit-user input[name="account"]').val(account.account);
 
-         $('#edit-user input[name="name"]').val(account.name);
 
-         $('#edit-user select[name="company"]').val(account.company);
 
-         $('#edit-user input[name="role"]').val(account.role);
 
-         $('#edit-user input[name="mobile"]').val(account.mobile);
 
-         $('#edit-user input[name="telephone"]').val(account.telephone);
 
-         $('#edit-user input[name="id"]').val(account.id);
 
-         $('#edit-user input[name="account_group"]').val(account.account_group);
 
-         $('#edit-user input[class="account-check"]').val(account.account);
 
-         $('#edit-user input[data-mobile="auth-mobile"]').val(account.auth_mobile);
 
-         $('#edit-user input[name="mobile"]').attr('readOnly', account.bind === 1);
 
-         if (account.bind === 1) {
 
-             $('#edit-user input[name="mobile"]').siblings('small').show();
 
-         } else {
 
-             $('#edit-user input[name="mobile"]').siblings('small').hide();
 
-         }
 
-         $('#edit-password input[name="account"]').val(account.account);
 
-         $('#edit-password input[class="account-check"]').val(account.account);
 
-         $('#edit-password input[name="id"]').val(account.id);
 
-         $('#edit-password input[name="reset_password"]').val('');
 
-     });
 
-     // 选择单位自动配置账号组
 
-     $('select[name="company"]').change(function () {
 
-         const company = $(this).val();
 
-         const oneUnit = _.find(unitList, { name: company });
 
-         $(this).siblings('input[name="account_group"]').val(oneUnit ? oneUnit.type : 7);
 
-     });
 
-     // 分配随机密码
 
-     $("#rand-password").click(function() {
 
-         const password = randPassword();
 
-         $(this).parent().parent().find('input').val(password);
 
-     });
 
-     // 分配随机密码
 
-     $("#rand-password2").click(function() {
 
-         const password = randPassword();
 
-         $(this).parent().parent().find('input').val(password);
 
-     });
 
-     // 重置密码
 
-     let isChange = false;
 
-     $("#reset-password-btn").click(function() {
 
-         try {
 
-             if (isChange) {
 
-                 throw '稍后再操作';
 
-             }
 
-             const resetPassword = $("#reset-password").val();
 
-             const id = $("#user-id").val();
 
-             if (resetPassword.length < 6) {
 
-                 throw '密码长度不能小于6';
 
-             }
 
-             if (!/^[0-9a-zA-Z*~!@&%$^\\(\\)#_\[\]\-\+={}|?'":,<>.`]+$/.test(resetPassword)) {
 
-                 throw '密码只支持英文数字及符号';
 
-             }
 
-             // 判断新密码的强度
 
-             const reg = /^(?![0-9]+$)(?![a-zA-Z]+$).{6,16}$/;
 
-             if (!reg.test(resetPassword)) {
 
-                 throw '请设置至少包含数字和字母的密码';
 
-             }
 
-             const btn = $(this);
 
-             $.ajax({
 
-                 url: '/setting/user/reset/password',
 
-                 type: 'post',
 
-                 data: { id: id, reset_password: resetPassword },
 
-                 dataType: 'json',
 
-                 error: function() {
 
-                     isChange = false;
 
-                     btn.html('重置密码');
 
-                     throw '网络错误!';
 
-                 },
 
-                 beforeSend: function(xhr) {
 
-                     let csrfToken = Cookies.get('csrfToken_j');
 
-                     xhr.setRequestHeader('x-csrf-token', csrfToken);
 
-                     isChange = true;
 
-                     btn.html('<i class="fa fa-spinner fa-pulse"></i>');
 
-                 },
 
-                 success: function(response) {
 
-                     isChange = false;
 
-                     btn.html('重置密码');
 
-                     if (response.err !== 0) {
 
-                         throw response.msg;
 
-                     }
 
-                     $("#reset-password").val('');
 
-                     toastr.success('重置成功');
 
-                 }
 
-             });
 
-         } catch (error) {
 
-             toastr.error(error);
 
-             console.log(error);
 
-         }
 
-     });
 
-     // 账号查重
 
-     $('input[name="account"]').on('blur', function () {
 
-         const self = $(this);
 
-         if (self.val() !== self.siblings('input').val()) {
 
-             const data = {account: $(this).val()};
 
-             postData('/setting/user/exist', data, function (data) {
 
-                 if (data === null) {
 
-                     self.removeClass('is-invalid');
 
-                 } else {
 
-                     self.addClass('is-invalid');
 
-                 }
 
-             })
 
-         } else {
 
-             self.removeClass('is-invalid');
 
-         }
 
-     });
 
-     // 选中创建标段才可以选择协作办公
 
-     $('a[aria-controls="edit-user2"]').on('click', function () {
 
-         $('#edit-user2 input:radio').prop('checked', false);
 
-         $('#edit-user2 input:checkbox').prop('checked', false);
 
-         const account = $(this).data('account');
 
-         $('#edit-user2 input[name="id"]').val(account.id);
 
-         // 权限赋值
 
-         if (account.permission !== '') {
 
-             const permission = JSON.parse(account.permission);
 
-             for (const pm in permission) {
 
-                 if (pm === 'tender' && permission[pm].indexOf('1') !== -1) {
 
-                     $('#edit-user2 input[name="cooperation"]').attr('disabled', false);
 
-                 } else {
 
-                     $('#edit-user2 input[name="cooperation"]').attr('disabled', true);
 
-                 }
 
-                 if (pm === 'tender' && permission[pm].indexOf('5') !== -1) {
 
-                     $('#edit-user2 input:checkbox[id="change_1"]').prop('checked', true);
 
-                 }
 
-                 if (pm === 'tender' && permission[pm].indexOf('4') !== -1) {
 
-                     $('#edit-user2 input:checkbox[id="material_1"]').prop('checked', true);
 
-                 }
 
-                 if (allPermission[pm].type === 'checkbox') {
 
-                     for (const index of permission[pm]) {
 
-                         $('#edit-user2 input:checkbox[id="' + pm + '_' + index + '"]').prop('checked', true);
 
-                     }
 
-                 } else if (allPermission[pm].type === 'radio') {
 
-                     $('#edit-user2 input:radio[id="' + pm + '_' + permission[pm] + '"]').prop('checked', true);
 
-                 }
 
-             }
 
-         }
 
-         // 协作赋值
 
-         $('#edit-user2 input:radio[name="cooperation"][value="' + account.cooperation + '"]').prop('checked', true);
 
-         // 微信通知赋值
 
-         if (account.notice_again) {
 
-             const noticeAgain = JSON.parse(account.notice_again);
 
-             $('#again_all').prop('checked', noticeAgain.checked);
 
-             for (const sp in noticeAgainConst.sp) {
 
-                 $('#again_' + sp).prop('checked', noticeAgain.sp[sp] !== undefined ? noticeAgain.sp[sp] : false);
 
-             }
 
-         }
 
-     });
 
-     // 选择创建标段功能后可选协作办公
 
-     $('#edit-user2 input:checkbox').click(function () {
 
-         if ($(this).attr('id') === 'tender_1') {
 
-             if ($(this).is(':checked')) {
 
-                 $('#edit-user2 input[name="cooperation"]').attr('disabled', false);
 
-             } else {
 
-                 $('#edit-user2 input[name="cooperation"]').attr('disabled', true);
 
-             }
 
-         }
 
-     });
 
-     // 解绑第三方平台
 
-     $('.unlink-user').on('click', function () {
 
-         const id = $(this).data('account');
 
-         const accountData = _.find(accountList, { id });
 
-         console.log(accountData);
 
-         $('#bind_account').text(accountData.name + ' ' + accountData.mobile);
 
-         $('#account_id').val(id);
 
-     })
 
-     // 设置显示默认
 
-     $('body').on('click', '#set-default', function () {
 
-         const attid = $(this).data('attid');
 
-         const data = {id: attid};
 
-         postData('/setting/show/update', data, function (result) {
 
-            let html = ''
 
-             result.forEach((item, idx) => {
 
-                 html += `<li class="list-group-item">${item.label_name}`
 
-                 html+= item.is_default ? `<span class="pull-right">默认</span></li>`:`<a href="javascript:void(0)" id="set-default" class="btn btn-primary btn-sm pull-right" data-attid="${idx}">设为默认</a></li>`
 
-             })
 
-             // <li class="list-group-item">
 
-             // 标段列表<a href="#" class="btn btn-primary btn-sm pull-right">设为默认</a>
 
-             // </li>
 
-             // <li class="list-group-item">金额概况<span class="pull-right">默认</span></li>
 
-             // <li class="list-group-item">
 
-             //     计量进度<a href="#" class="btn btn-primary btn-sm pull-right">设为默认</a>
 
-             // </li>
 
-             $('.list-group').empty()
 
-             $('.list-group').append(html)
 
-             const item = result.find((i, idx) => idx=== attid)
 
-             $('#nav_tender').attr('href', item.path)
 
-         });
 
-     });
 
-     // 设置页显示数目
 
-     $('.nav-tabs .nav-link').each(function () {
 
-         const pageSize = getLocalCache('account-pageSize') ? getLocalCache('account-pageSize') : '';
 
-         if (getLocalCache('account-pageSize') && $(this).attr('href').indexOf('pageSize') === -1 && $(this).attr('href').indexOf('unit') === -1) {
 
-             $(this).attr('href', $(this).attr('href') + '?pageSize=' + getLocalCache('account-pageSize'));
 
-         }
 
-     });
 
-     // 设置页显示数目
 
-     $('#user-list .list-group-item').each(function (k,v) {
 
-         const pageSize = getLocalCache('account-pageSize') ? getLocalCache('account-pageSize') : '';
 
-         if (pageSize) {
 
-             $(this).attr('href', $(this).attr('href') + '&pageSize=' + pageSize);
 
-         }
 
-     })
 
-     // 参建单位页切换单位右侧显示
 
-     $('body').on('click', '#unit_list tr', function () {
 
-         const id = parseInt($(this).data('id'));
 
-         $(this).siblings('tr').removeClass('table-warning');
 
-         $(this).addClass('table-warning');
 
-         setUnitRightHtml(id);
 
-     });
 
-     // 参建单位编辑
 
-     // 回车提交
 
-     $('#one_unit input').on('keypress', function () {
 
-         if(window.event.keyCode === 13) {
 
-             $(this).blur();
 
-         }
 
-     });
 
-     $('#one_unit input').blur(function () {
 
-         console.log('hello');
 
-         const val_name = $(this).data('name');
 
-         let val = _.trim($(this).val()) !== '' ? _.trim($(this).val()) : null;
 
-         if (!oneUnit) {
 
-             toastr.error('所选单位有误,请重新选择');
 
-             return false;
 
-         }
 
-         switch(val_name) {
 
-             case 'name':
 
-                 if(val && val.length > 100) {
 
-                     toastr.error('单位名称超过100个字,请缩减名称');
 
-                     $(this).val(oneUnit[val_name]);
 
-                     return false;
 
-                 }
 
-                 const tongming = _.find(unitList, { name: val });
 
-                 if (tongming && tongming.id !== oneUnit.id) {
 
-                     toastr.error('单位名称不能重复');
 
-                     $(this).val(oneUnit[val_name]);
 
-                     return false;
 
-                 }
 
-                 break;
 
-             default:
 
-                 if(val && val.length > 255) {
 
-                     toastr.error('超出字段范围,请缩减');
 
-                     $(this).val(oneUnit[val_name]);
 
-                     return false;
 
-                 }
 
-                 break;
 
-         }
 
-         if(oneUnit[val_name] !== val) {
 
-             const _self = $(this);
 
-             postData('/setting/user/unit/save', { type: 'update', id: oneUnit.id, val_name, val}, function (result) {
 
-                 oneUnit[val_name] = val;
 
-                 _self.val(oneUnit[val_name]);
 
-                 if (val_name === 'name') {
 
-                     oneUnit.account_num = result.account_num;
 
-                     $('#unit_list tr[class="table-warning"]').find('a').text(oneUnit[val_name]);
 
-                     $('#unit_list tr[class="table-warning"]').children('td').eq(2).text(result.account_num);
 
-                 }
 
-             }, function () {
 
-                 _self.val(oneUnit[val_name]);
 
-             })
 
-         } else {
 
-             $(this).val(oneUnit[val_name]);
 
-         }
 
-     });
 
-     $('#one_unit textarea').blur(function () {
 
-         const val_name = $(this).data('name');
 
-         let val = _.trim($(this).val()) !== '' ? _.trim($(this).val()) : null;
 
-         if (!oneUnit) {
 
-             toastr.error('所选单位有误,请重新选择');
 
-             return false;
 
-         }
 
-         if(oneUnit[val_name] !== val) {
 
-             const _self = $(this);
 
-             postData('/setting/user/unit/save', { type: 'update', id: oneUnit.id, val_name, val}, function (result) {
 
-                 oneUnit[val_name] = val;
 
-                 _self.val(oneUnit[val_name]);
 
-                 $('#unit_list tr[class="table-warning"]').children('td').eq(4).text(oneUnit[val_name]);
 
-             }, function () {
 
-                 _self.val(oneUnit[val_name]);
 
-             })
 
-         } else {
 
-             $(this).val(oneUnit[val_name]);
 
-         }
 
-     });
 
-     $('#one_unit select').change(function () {
 
-         const val_name = $(this).attr('data-name');
 
-         let val = _.trim($(this).val()) !== '' ? _.trim($(this).val()) : null;
 
-         if (!oneUnit) {
 
-             toastr.error('所选单位有误,请重新选择');
 
-             return false;
 
-         }
 
-         if(oneUnit[val_name] !== val) {
 
-             const _self = $(this);
 
-             postData('/setting/user/unit/save', { type: 'update', id: oneUnit.id, name: oneUnit.name, val_name, val}, function (result) {
 
-                 oneUnit[val_name] = val;
 
-                 _self.val(oneUnit[val_name]);
 
-                 $('#unit_list tr[class="table-warning"]').children('td').eq(3).text(accountGroup[parseInt(oneUnit[val_name])]);
 
-             }, function () {
 
-                 _self.val(oneUnit[val_name]);
 
-             })
 
-         } else {
 
-             $(this).val(oneUnit[val_name]);
 
-         }
 
-     });
 
-     // 删除单位弹窗
 
-     $('#del-modal-btn').click(function () {
 
-         if (!oneUnit) {
 
-             toastr.error('所选单位有误,请重新选择');
 
-             return false;
 
-         }
 
-         if (oneUnit.account_num === 0) {
 
-             $('.del-btn').show();
 
-             $('.not-del-btn').hide();
 
-         } else {
 
-             $('.del-btn').hide();
 
-             $('.not-del-btn').show();
 
-         }
 
-     });
 
-     // 删除单位
 
-     $('#delete-unit').click(function () {
 
-         if (!oneUnit) {
 
-             toastr.error('所选单位有误,请重新选择');
 
-             return false;
 
-         }
 
-         postData('/setting/user/unit/save', { type: 'delete', name: oneUnit.name, id: oneUnit.id }, function (result) {
 
-             window.location.href = '/setting/user/unit';
 
-         })
 
-     });
 
-     // 上传签章
 
-     $('#sign-upload').change(function () {
 
-         if (!oneUnit) {
 
-             toastr.error('所选单位有误,请重新选择');
 
-             return false;
 
-         }
 
-         const file = this.files[0];
 
-         const ext = file.name.toLowerCase().split('.').splice(-1)[0];
 
-         const imgStr = /(jpg|jpeg|png|bmp|BMP|JPG|PNG|JPEG)$/;
 
-         if (!imgStr.test(ext)) {
 
-             toastr.error('请上传正确的图片格式文件');
 
-             return
 
-         }
 
-         if ($(this).val()) {
 
-             const formData = new FormData();
 
-             formData.append('file', this.files[0]);
 
-             formData.append('id', oneUnit.id);
 
-             postDataWithFile('/setting/user/unit/upload', formData, function (result) {
 
-                 const html = '<img src="'+ fujianOssPath + result.sign_path +'" width="120">';
 
-                 $('#sign-show').html(html);
 
-                 $('#sign-upload').val('');
 
-                 oneUnit.sign_path = result.sign_path;
 
-                 $('#upload-sign').hide();
 
-                 $('#delete-sign').show();
 
-                 toastr.success('上传成功');
 
-             });
 
-         }
 
-     });
 
-     // 移除签章
 
-     $('#delete-sign').click(function () {
 
-         if (!oneUnit) {
 
-             toastr.error('所选单位有误,请重新选择');
 
-             return false;
 
-         }
 
-         postData('/setting/user/unit/save', { type: 'del-sign', id: oneUnit.id }, function (result) {
 
-             $('#sign-show').html('');
 
-             toastr.warning('已移除');
 
-             oneUnit.sign_path = null;
 
-             $('#upload-sign').show();
 
-             $('#delete-sign').hide();
 
-         })
 
-     });
 
- });
 
- function checkPasswordForm() {
 
-     try {
 
-         if ($('#edit-password input[name="account"]').val() == '' || $('#edit-password input[name="account"]').hasClass('is-invalid')) {
 
-             throw '账号不能为空或已存在';
 
-         }
 
-         const resetPassword = $('#edit-password input[name="reset_password"]').val();
 
-         if (resetPassword.length < 6) {
 
-             throw '密码长度不能小于6';
 
-         }
 
-         if (!/^[0-9a-zA-Z*~!@&%$^\\(\\)#_\[\]\-\+={}|?'":,<>.`]+$/.test(resetPassword)) {
 
-             throw '密码只支持英文数字及符号';
 
-         }
 
-         // 判断新密码的强度
 
-         const reg = /^(?![0-9]+$)(?![a-zA-Z]+$).{6,16}$/;
 
-         if (!reg.test(resetPassword)) {
 
-             throw '请设置至少包含数字和字母的密码';
 
-         }
 
-     } catch (err) {
 
-         toastr.error(err);
 
-         return false;
 
-     }
 
- }
 
- function setUnitRightHtml(id) {
 
-     const one = _.find(unitList, { id });
 
-     if (one) {
 
-         $('#unit_name').val(one.name);
 
-         $('#unit_corporation').val(one.corporation);
 
-         $('#unit_credit_code').val(one.credit_code);
 
-         $('#unit_tel').val(one.tel);
 
-         $('#unit_website').val(one.website);
 
-         $('#unit_region').val(one.region);
 
-         $('#unit_address').val(one.address);
 
-         $('#unit_basic').val(one.basic);
 
-         $('#unit_type').val(one.type);
 
-         if(one.sign_path) {
 
-             $('#sign-show').html('<img src="' + fujianOssPath + one.sign_path + '" width="120">');
 
-             $('#delete-sign').show();
 
-             $('#upload-sign').hide();
 
-         } else {
 
-             $('#sign-show').html('');
 
-             $('#delete-sign').hide();
 
-             $('#upload-sign').show();
 
-         }
 
-         oneUnit = one;
 
-         $('#add_user_company').val(one.name);
 
-     }
 
- }
 
- /**
 
-  * 表单检测
 
-  */
 
- function checkUserForm(status) {
 
-     try {
 
-         if (status === 'add') {
 
-             if ($('#add-user input[name="account_group"]').val() == 0) {
 
-                 throw '请选择账号组';
 
-             }
 
-             if ($('#add-user input[name="account"]').val() == '' || $('#add-user input[name="account"]').hasClass('is-invalid')) {
 
-                 throw '账号不能为空或已存在';
 
-             }
 
-             if ($('#add-user input[name="password"]').val() == '' || $('#add-user input[name="password"]').val().length < 6) {
 
-                 throw '密码不能为空或不能小于6位';
 
-             }
 
-             if (!/^[0-9a-zA-Z*~!@&%$^\\(\\)#_\[\]\-\+={}|?'":,<>.`]+$/.test($('#add-user input[name="password"]').val())) {
 
-                 throw '密码只支持英文数字及符号';
 
-             }
 
-             // 判断新密码的强度
 
-             const reg = /^(?![0-9]+$)(?![a-zA-Z]+$).{6,16}$/;
 
-             if (!reg.test($('#add-user input[name="password"]').val())) {
 
-                 throw '请设置至少包含数字和字母的密码';
 
-             }
 
-             if ($('#add-user input[name="name"]').val() == '') {
 
-                 throw '姓名不能为空';
 
-             }
 
-             if (_.findIndex(unitList, { name: $('#add-user select[name="company"]').val() }) === -1) {
 
-                 throw '请选择单位名称';
 
-             }
 
-             if ($('#add-user input[name="role"]').val() == '') {
 
-                 throw '职位名称不能为空';
 
-             }
 
-             $('#add-user input[name="account"]').val(trimInvalidChar($('#add-user input[name="account"]').val()));
 
-             $('#add-user input[name="name"]').val(trimInvalidChar($('#add-user input[name="name"]').val()));
 
-             // $('#add-user input[name="company"]').val(trimInvalidChar($('#add-user input[name="company"]').val()));
 
-             $('#add-user input[name="role"]').val(trimInvalidChar($('#add-user input[name="role"]').val()));
 
-             $('#add-user input[name="telephone"]').val(trimInvalidChar($('#add-user input[name="telephone"]').val()));
 
-         } else {
 
-             if ($('#edit-user input[name="account_group"]').val() == 0) {
 
-                 throw '请选择账号组';
 
-             }
 
-             if ($('#edit-user input[name="account"]').val() == '' || $('#add-user input[name="account"]').hasClass('is-invalid')) {
 
-                 throw '账号不能为空或已存在';
 
-             }
 
-             if ($('#edit-user input[name="name"]').val() == '') {
 
-                 throw '姓名不能为空';
 
-             }
 
-             if (_.findIndex(unitList, { name: $('#edit-user select[name="company"]').val() }) === -1) {
 
-                 throw '请选择单位名称';
 
-             }
 
-             if ($('#edit-user input[name="role"]').val() == '') {
 
-                 throw '职位名称不能为空';
 
-             }
 
-             $('#edit-user input[name="account"]').val(trimInvalidChar($('#edit-user input[name="account"]').val()));
 
-             $('#edit-user input[name="name"]').val(trimInvalidChar($('#edit-user input[name="name"]').val()));
 
-             // $('#edit-user input[name="company"]').val(trimInvalidChar($('#edit-user input[name="company"]').val()));
 
-             $('#edit-user input[name="role"]').val(trimInvalidChar($('#edit-user input[name="role"]').val()));
 
-             $('#edit-user input[name="telephone"]').val(trimInvalidChar($('#edit-user input[name="telephone"]').val()));
 
-         }
 
-     } catch (err) {
 
-         toastr.error(err);
 
-         return false;
 
-     }
 
- }
 
- /**
 
-  * 表单检测
 
-  */
 
- function checkUnitForm() {
 
-     try {
 
-         if ($('#add-company input[name="name"]').val() == '') {
 
-             throw '单位名称不能为空';
 
-         }
 
-         if ($('#add-company select[name="type"]').val() == 0) {
 
-             throw '请选择类型';
 
-         }
 
-         // 检测同名
 
-         if (_.findIndex(unitList, { name: $('#add-company input[name="name"]').val() }) !== -1) {
 
-             throw '已存在对应的单位名称';
 
-         }
 
-     } catch (err) {
 
-         toastr.error(err);
 
-         return false;
 
-     }
 
- }
 
- /**
 
-  * 随机密码(必须包含数字和字母)
 
-  */
 
- function randPassword() {
 
-     const result = [];
 
-     // 随机6-10位
 
-     const length = Math.ceil(Math.random() * 2 + 6);
 
-     let numberSeed = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
 
-     let stringSeed = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
 
-         'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
 
-         'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
 
-     const numRan = numberSeed[Math.floor((Math.random() * numberSeed.length))];
 
-     const strRan = stringSeed[Math.floor((Math.random() * stringSeed.length))];
 
-     const randSeed = stringSeed.concat(numberSeed);
 
-     const seedLength = randSeed.length - 1;
 
-     for (let i = 0; i < length; i++) {
 
-         const index = Math.ceil(Math.random() * seedLength);
 
-         result.push(randSeed[index]);
 
-     }
 
-     result.splice(Math.floor((Math.random() * result.length)), 0, numRan);
 
-     result.splice(Math.floor((Math.random() * result.length)), 0, strRan);
 
-     return result.join('');
 
- }
 
 
  |