setting.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571
  1. 'use strict';
  2. /**
  3. * 项目信息js
  4. *
  5. * @author EllisRan.
  6. * @date 2019/3/19
  7. * @version
  8. */
  9. $(document).ready(() => {
  10. // 启用和停用账号
  11. $('.account-switch-btn').on('click', function () {
  12. const data = {
  13. enable: $(this).hasClass('btn-outline-success') ? 1 : 0,
  14. id: $(this).data('account'),
  15. };
  16. postData('/setting/user/switch', data, function () {
  17. window.location.href = '/setting/user';
  18. });
  19. });
  20. // 编辑账号
  21. $('a[data-target="#edit-user"]').on('click', function () {
  22. const account = $(this).data('account');
  23. $('#edit-user input[name="account"]').val(account.account);
  24. $('#edit-user input[name="name"]').val(account.name);
  25. $('#edit-user select[name="company"]').val(account.company);
  26. $('#edit-user input[name="role"]').val(account.role);
  27. $('#edit-user input[name="mobile"]').val(account.mobile);
  28. $('#edit-user input[name="telephone"]').val(account.telephone);
  29. $('#edit-user input[name="id"]').val(account.id);
  30. $('#edit-user input[name="account_group"]').val(account.account_group);
  31. $('#edit-user input[class="account-check"]').val(account.account);
  32. $('#edit-user input[data-mobile="auth-mobile"]').val(account.auth_mobile);
  33. $('#edit-user input[name="mobile"]').attr('readOnly', account.bind === 1);
  34. if (account.bind === 1) {
  35. $('#edit-user input[name="mobile"]').siblings('small').show();
  36. } else {
  37. $('#edit-user input[name="mobile"]').siblings('small').hide();
  38. }
  39. $('#edit-password input[name="account"]').val(account.account);
  40. $('#edit-password input[class="account-check"]').val(account.account);
  41. $('#edit-password input[name="id"]').val(account.id);
  42. $('#edit-password input[name="reset_password"]').val('');
  43. });
  44. // 选择单位自动配置账号组
  45. $('select[name="company"]').change(function () {
  46. const company = $(this).val();
  47. const oneUnit = _.find(unitList, { name: company });
  48. $(this).siblings('input[name="account_group"]').val(oneUnit ? oneUnit.type : 7);
  49. });
  50. // 分配随机密码
  51. $("#rand-password").click(function() {
  52. const password = randPassword();
  53. $(this).parent().parent().find('input').val(password);
  54. });
  55. // 分配随机密码
  56. $("#rand-password2").click(function() {
  57. const password = randPassword();
  58. $(this).parent().parent().find('input').val(password);
  59. });
  60. // 重置密码
  61. let isChange = false;
  62. $("#reset-password-btn").click(function() {
  63. try {
  64. if (isChange) {
  65. throw '稍后再操作';
  66. }
  67. const resetPassword = $("#reset-password").val();
  68. const id = $("#user-id").val();
  69. if (resetPassword.length < 6) {
  70. throw '密码长度不能小于6';
  71. }
  72. if (!/^[0-9a-zA-Z*~!@&%$^\\(\\)#_\[\]\-\+={}|?'":,<>.`]+$/.test(resetPassword)) {
  73. throw '密码只支持英文数字及符号';
  74. }
  75. // 判断新密码的强度
  76. const reg = /^(?![0-9]+$)(?![a-zA-Z]+$).{6,16}$/;
  77. if (!reg.test(resetPassword)) {
  78. throw '请设置至少包含数字和字母的密码';
  79. }
  80. const btn = $(this);
  81. $.ajax({
  82. url: '/setting/user/reset/password',
  83. type: 'post',
  84. data: { id: id, reset_password: resetPassword },
  85. dataType: 'json',
  86. error: function() {
  87. isChange = false;
  88. btn.html('重置密码');
  89. throw '网络错误!';
  90. },
  91. beforeSend: function(xhr) {
  92. let csrfToken = Cookies.get('csrfToken_j');
  93. xhr.setRequestHeader('x-csrf-token', csrfToken);
  94. isChange = true;
  95. btn.html('<i class="fa fa-spinner fa-pulse"></i>');
  96. },
  97. success: function(response) {
  98. isChange = false;
  99. btn.html('重置密码');
  100. if (response.err !== 0) {
  101. throw response.msg;
  102. }
  103. $("#reset-password").val('');
  104. toastr.success('重置成功');
  105. }
  106. });
  107. } catch (error) {
  108. toastr.error(error);
  109. console.log(error);
  110. }
  111. });
  112. // 账号查重
  113. $('input[name="account"]').on('blur', function () {
  114. const self = $(this);
  115. if (self.val() !== self.siblings('input').val()) {
  116. const data = {account: $(this).val()};
  117. postData('/setting/user/exist', data, function (data) {
  118. if (data === null) {
  119. self.removeClass('is-invalid');
  120. } else {
  121. self.addClass('is-invalid');
  122. }
  123. })
  124. } else {
  125. self.removeClass('is-invalid');
  126. }
  127. });
  128. // 选中创建标段才可以选择协作办公
  129. $('a[aria-controls="edit-user2"]').on('click', function () {
  130. $('#edit-user2 input:radio').prop('checked', false);
  131. $('#edit-user2 input:checkbox').prop('checked', false);
  132. const account = $(this).data('account');
  133. $('#edit-user2 input[name="id"]').val(account.id);
  134. // 权限赋值
  135. if (account.permission !== '') {
  136. const permission = JSON.parse(account.permission);
  137. for (const pm in permission) {
  138. if (pm === 'tender' && permission[pm].indexOf('1') !== -1) {
  139. $('#edit-user2 input[name="cooperation"]').attr('disabled', false);
  140. } else {
  141. $('#edit-user2 input[name="cooperation"]').attr('disabled', true);
  142. }
  143. if (pm === 'tender' && permission[pm].indexOf('5') !== -1) {
  144. $('#edit-user2 input:checkbox[id="change_1"]').prop('checked', true);
  145. }
  146. if (pm === 'tender' && permission[pm].indexOf('4') !== -1) {
  147. $('#edit-user2 input:checkbox[id="material_1"]').prop('checked', true);
  148. }
  149. if (allPermission[pm].type === 'checkbox') {
  150. for (const index of permission[pm]) {
  151. $('#edit-user2 input:checkbox[id="' + pm + '_' + index + '"]').prop('checked', true);
  152. }
  153. } else if (allPermission[pm].type === 'radio') {
  154. $('#edit-user2 input:radio[id="' + pm + '_' + permission[pm] + '"]').prop('checked', true);
  155. }
  156. }
  157. }
  158. // 协作赋值
  159. $('#edit-user2 input:radio[name="cooperation"][value="' + account.cooperation + '"]').prop('checked', true);
  160. // 微信通知赋值
  161. if (account.notice_again) {
  162. const noticeAgain = JSON.parse(account.notice_again);
  163. $('#again_all').prop('checked', noticeAgain.checked);
  164. for (const sp in noticeAgainConst.sp) {
  165. $('#again_' + sp).prop('checked', noticeAgain.sp[sp] !== undefined ? noticeAgain.sp[sp] : false);
  166. }
  167. }
  168. });
  169. // 选择创建标段功能后可选协作办公
  170. $('#edit-user2 input:checkbox').click(function () {
  171. if ($(this).attr('id') === 'tender_1') {
  172. if ($(this).is(':checked')) {
  173. $('#edit-user2 input[name="cooperation"]').attr('disabled', false);
  174. } else {
  175. $('#edit-user2 input[name="cooperation"]').attr('disabled', true);
  176. }
  177. }
  178. });
  179. // 解绑第三方平台
  180. $('.unlink-user').on('click', function () {
  181. const id = $(this).data('account');
  182. const accountData = _.find(accountList, { id });
  183. console.log(accountData);
  184. $('#bind_account').text(accountData.name + ' ' + accountData.mobile);
  185. $('#account_id').val(id);
  186. })
  187. // 设置显示默认
  188. $('body').on('click', '#set-default', function () {
  189. const attid = $(this).data('attid');
  190. const data = {id: attid};
  191. postData('/setting/show/update', data, function (result) {
  192. let html = ''
  193. result.forEach((item, idx) => {
  194. html += `<li class="list-group-item">${item.label_name}`
  195. 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>`
  196. })
  197. // <li class="list-group-item">
  198. // 标段列表<a href="#" class="btn btn-primary btn-sm pull-right">设为默认</a>
  199. // </li>
  200. // <li class="list-group-item">金额概况<span class="pull-right">默认</span></li>
  201. // <li class="list-group-item">
  202. // 计量进度<a href="#" class="btn btn-primary btn-sm pull-right">设为默认</a>
  203. // </li>
  204. $('.list-group').empty()
  205. $('.list-group').append(html)
  206. const item = result.find((i, idx) => idx=== attid)
  207. $('#nav_tender').attr('href', item.path)
  208. });
  209. });
  210. // 设置页显示数目
  211. $('.nav-tabs .nav-link').each(function () {
  212. const pageSize = getLocalCache('account-pageSize') ? getLocalCache('account-pageSize') : '';
  213. if (getLocalCache('account-pageSize') && $(this).attr('href').indexOf('pageSize') === -1 && $(this).attr('href').indexOf('unit') === -1) {
  214. $(this).attr('href', $(this).attr('href') + '?pageSize=' + getLocalCache('account-pageSize'));
  215. }
  216. });
  217. // 设置页显示数目
  218. $('#user-list .list-group-item').each(function (k,v) {
  219. const pageSize = getLocalCache('account-pageSize') ? getLocalCache('account-pageSize') : '';
  220. if (pageSize) {
  221. $(this).attr('href', $(this).attr('href') + '&pageSize=' + pageSize);
  222. }
  223. })
  224. // 参建单位页切换单位右侧显示
  225. $('body').on('click', '#unit_list tr', function () {
  226. const id = parseInt($(this).data('id'));
  227. $(this).siblings('tr').removeClass('table-warning');
  228. $(this).addClass('table-warning');
  229. setUnitRightHtml(id);
  230. });
  231. // 参建单位编辑
  232. // 回车提交
  233. $('#one_unit input').on('keypress', function () {
  234. if(window.event.keyCode === 13) {
  235. $(this).blur();
  236. }
  237. });
  238. $('#one_unit input').blur(function () {
  239. console.log('hello');
  240. const val_name = $(this).data('name');
  241. let val = _.trim($(this).val()) !== '' ? _.trim($(this).val()) : null;
  242. if (!oneUnit) {
  243. toastr.error('所选单位有误,请重新选择');
  244. return false;
  245. }
  246. switch(val_name) {
  247. case 'name':
  248. if(val && val.length > 100) {
  249. toastr.error('单位名称超过100个字,请缩减名称');
  250. $(this).val(oneUnit[val_name]);
  251. return false;
  252. }
  253. const tongming = _.find(unitList, { name: val });
  254. if (tongming && tongming.id !== oneUnit.id) {
  255. toastr.error('单位名称不能重复');
  256. $(this).val(oneUnit[val_name]);
  257. return false;
  258. }
  259. break;
  260. default:
  261. if(val && val.length > 255) {
  262. toastr.error('超出字段范围,请缩减');
  263. $(this).val(oneUnit[val_name]);
  264. return false;
  265. }
  266. break;
  267. }
  268. if(oneUnit[val_name] !== val) {
  269. const _self = $(this);
  270. postData('/setting/user/unit/save', { type: 'update', id: oneUnit.id, val_name, val}, function (result) {
  271. oneUnit[val_name] = val;
  272. _self.val(oneUnit[val_name]);
  273. if (val_name === 'name') {
  274. oneUnit.account_num = result.account_num;
  275. $('#unit_list tr[class="table-warning"]').find('a').text(oneUnit[val_name]);
  276. $('#unit_list tr[class="table-warning"]').children('td').eq(2).text(result.account_num);
  277. }
  278. }, function () {
  279. _self.val(oneUnit[val_name]);
  280. })
  281. } else {
  282. $(this).val(oneUnit[val_name]);
  283. }
  284. });
  285. $('#one_unit textarea').blur(function () {
  286. const val_name = $(this).data('name');
  287. let val = _.trim($(this).val()) !== '' ? _.trim($(this).val()) : null;
  288. if (!oneUnit) {
  289. toastr.error('所选单位有误,请重新选择');
  290. return false;
  291. }
  292. if(oneUnit[val_name] !== val) {
  293. const _self = $(this);
  294. postData('/setting/user/unit/save', { type: 'update', id: oneUnit.id, val_name, val}, function (result) {
  295. oneUnit[val_name] = val;
  296. _self.val(oneUnit[val_name]);
  297. $('#unit_list tr[class="table-warning"]').children('td').eq(4).text(oneUnit[val_name]);
  298. }, function () {
  299. _self.val(oneUnit[val_name]);
  300. })
  301. } else {
  302. $(this).val(oneUnit[val_name]);
  303. }
  304. });
  305. $('#one_unit select').change(function () {
  306. const val_name = $(this).attr('data-name');
  307. let val = _.trim($(this).val()) !== '' ? _.trim($(this).val()) : null;
  308. if (!oneUnit) {
  309. toastr.error('所选单位有误,请重新选择');
  310. return false;
  311. }
  312. if(oneUnit[val_name] !== val) {
  313. const _self = $(this);
  314. postData('/setting/user/unit/save', { type: 'update', id: oneUnit.id, name: oneUnit.name, val_name, val}, function (result) {
  315. oneUnit[val_name] = val;
  316. _self.val(oneUnit[val_name]);
  317. $('#unit_list tr[class="table-warning"]').children('td').eq(3).text(accountGroup[parseInt(oneUnit[val_name])]);
  318. }, function () {
  319. _self.val(oneUnit[val_name]);
  320. })
  321. } else {
  322. $(this).val(oneUnit[val_name]);
  323. }
  324. });
  325. // 删除单位弹窗
  326. $('#del-modal-btn').click(function () {
  327. if (!oneUnit) {
  328. toastr.error('所选单位有误,请重新选择');
  329. return false;
  330. }
  331. if (oneUnit.account_num === 0) {
  332. $('.del-btn').show();
  333. $('.not-del-btn').hide();
  334. } else {
  335. $('.del-btn').hide();
  336. $('.not-del-btn').show();
  337. }
  338. });
  339. // 删除单位
  340. $('#delete-unit').click(function () {
  341. if (!oneUnit) {
  342. toastr.error('所选单位有误,请重新选择');
  343. return false;
  344. }
  345. postData('/setting/user/unit/save', { type: 'delete', name: oneUnit.name, id: oneUnit.id }, function (result) {
  346. window.location.href = '/setting/user/unit';
  347. })
  348. });
  349. // 上传签章
  350. $('#sign-upload').change(function () {
  351. if (!oneUnit) {
  352. toastr.error('所选单位有误,请重新选择');
  353. return false;
  354. }
  355. const file = this.files[0];
  356. const ext = file.name.toLowerCase().split('.').splice(-1)[0];
  357. const imgStr = /(jpg|jpeg|png|bmp|BMP|JPG|PNG|JPEG)$/;
  358. if (!imgStr.test(ext)) {
  359. toastr.error('请上传正确的图片格式文件');
  360. return
  361. }
  362. if ($(this).val()) {
  363. const formData = new FormData();
  364. formData.append('file', this.files[0]);
  365. formData.append('id', oneUnit.id);
  366. postDataWithFile('/setting/user/unit/upload', formData, function (result) {
  367. const html = '<img src="'+ fujianOssPath + result.sign_path +'" width="120">';
  368. $('#sign-show').html(html);
  369. $('#sign-upload').val('');
  370. oneUnit.sign_path = result.sign_path;
  371. $('#upload-sign').hide();
  372. $('#delete-sign').show();
  373. toastr.success('上传成功');
  374. });
  375. }
  376. });
  377. // 移除签章
  378. $('#delete-sign').click(function () {
  379. if (!oneUnit) {
  380. toastr.error('所选单位有误,请重新选择');
  381. return false;
  382. }
  383. postData('/setting/user/unit/save', { type: 'del-sign', id: oneUnit.id }, function (result) {
  384. $('#sign-show').html('');
  385. toastr.warning('已移除');
  386. oneUnit.sign_path = null;
  387. $('#upload-sign').show();
  388. $('#delete-sign').hide();
  389. })
  390. });
  391. });
  392. function checkPasswordForm() {
  393. try {
  394. if ($('#edit-password input[name="account"]').val() == '' || $('#edit-password input[name="account"]').hasClass('is-invalid')) {
  395. throw '账号不能为空或已存在';
  396. }
  397. const resetPassword = $('#edit-password input[name="reset_password"]').val();
  398. if (resetPassword.length < 6) {
  399. throw '密码长度不能小于6';
  400. }
  401. if (!/^[0-9a-zA-Z*~!@&%$^\\(\\)#_\[\]\-\+={}|?'":,<>.`]+$/.test(resetPassword)) {
  402. throw '密码只支持英文数字及符号';
  403. }
  404. // 判断新密码的强度
  405. const reg = /^(?![0-9]+$)(?![a-zA-Z]+$).{6,16}$/;
  406. if (!reg.test(resetPassword)) {
  407. throw '请设置至少包含数字和字母的密码';
  408. }
  409. } catch (err) {
  410. toastr.error(err);
  411. return false;
  412. }
  413. }
  414. function setUnitRightHtml(id) {
  415. const one = _.find(unitList, { id });
  416. if (one) {
  417. $('#unit_name').val(one.name);
  418. $('#unit_corporation').val(one.corporation);
  419. $('#unit_credit_code').val(one.credit_code);
  420. $('#unit_tel').val(one.tel);
  421. $('#unit_website').val(one.website);
  422. $('#unit_region').val(one.region);
  423. $('#unit_address').val(one.address);
  424. $('#unit_basic').val(one.basic);
  425. $('#unit_type').val(one.type);
  426. if(one.sign_path) {
  427. $('#sign-show').html('<img src="' + fujianOssPath + one.sign_path + '" width="120">');
  428. $('#delete-sign').show();
  429. $('#upload-sign').hide();
  430. } else {
  431. $('#sign-show').html('');
  432. $('#delete-sign').hide();
  433. $('#upload-sign').show();
  434. }
  435. oneUnit = one;
  436. $('#add_user_company').val(one.name);
  437. }
  438. }
  439. /**
  440. * 表单检测
  441. */
  442. function checkUserForm(status) {
  443. try {
  444. if (status === 'add') {
  445. if ($('#add-user input[name="account_group"]').val() == 0) {
  446. throw '请选择账号组';
  447. }
  448. if ($('#add-user input[name="account"]').val() == '' || $('#add-user input[name="account"]').hasClass('is-invalid')) {
  449. throw '账号不能为空或已存在';
  450. }
  451. if ($('#add-user input[name="password"]').val() == '' || $('#add-user input[name="password"]').val().length < 6) {
  452. throw '密码不能为空或不能小于6位';
  453. }
  454. if (!/^[0-9a-zA-Z*~!@&%$^\\(\\)#_\[\]\-\+={}|?'":,<>.`]+$/.test($('#add-user input[name="password"]').val())) {
  455. throw '密码只支持英文数字及符号';
  456. }
  457. // 判断新密码的强度
  458. const reg = /^(?![0-9]+$)(?![a-zA-Z]+$).{6,16}$/;
  459. if (!reg.test($('#add-user input[name="password"]').val())) {
  460. throw '请设置至少包含数字和字母的密码';
  461. }
  462. if ($('#add-user input[name="name"]').val() == '') {
  463. throw '姓名不能为空';
  464. }
  465. if (_.findIndex(unitList, { name: $('#add-user select[name="company"]').val() }) === -1) {
  466. throw '请选择单位名称';
  467. }
  468. if ($('#add-user input[name="role"]').val() == '') {
  469. throw '职位名称不能为空';
  470. }
  471. $('#add-user input[name="account"]').val(trimInvalidChar($('#add-user input[name="account"]').val()));
  472. $('#add-user input[name="name"]').val(trimInvalidChar($('#add-user input[name="name"]').val()));
  473. // $('#add-user input[name="company"]').val(trimInvalidChar($('#add-user input[name="company"]').val()));
  474. $('#add-user input[name="role"]').val(trimInvalidChar($('#add-user input[name="role"]').val()));
  475. $('#add-user input[name="telephone"]').val(trimInvalidChar($('#add-user input[name="telephone"]').val()));
  476. } else {
  477. if ($('#edit-user input[name="account_group"]').val() == 0) {
  478. throw '请选择账号组';
  479. }
  480. if ($('#edit-user input[name="account"]').val() == '' || $('#add-user input[name="account"]').hasClass('is-invalid')) {
  481. throw '账号不能为空或已存在';
  482. }
  483. if ($('#edit-user input[name="name"]').val() == '') {
  484. throw '姓名不能为空';
  485. }
  486. if (_.findIndex(unitList, { name: $('#edit-user select[name="company"]').val() }) === -1) {
  487. throw '请选择单位名称';
  488. }
  489. if ($('#edit-user input[name="role"]').val() == '') {
  490. throw '职位名称不能为空';
  491. }
  492. $('#edit-user input[name="account"]').val(trimInvalidChar($('#edit-user input[name="account"]').val()));
  493. $('#edit-user input[name="name"]').val(trimInvalidChar($('#edit-user input[name="name"]').val()));
  494. // $('#edit-user input[name="company"]').val(trimInvalidChar($('#edit-user input[name="company"]').val()));
  495. $('#edit-user input[name="role"]').val(trimInvalidChar($('#edit-user input[name="role"]').val()));
  496. $('#edit-user input[name="telephone"]').val(trimInvalidChar($('#edit-user input[name="telephone"]').val()));
  497. }
  498. } catch (err) {
  499. toastr.error(err);
  500. return false;
  501. }
  502. }
  503. /**
  504. * 表单检测
  505. */
  506. function checkUnitForm() {
  507. try {
  508. if ($('#add-company input[name="name"]').val() == '') {
  509. throw '单位名称不能为空';
  510. }
  511. if ($('#add-company select[name="type"]').val() == 0) {
  512. throw '请选择类型';
  513. }
  514. // 检测同名
  515. if (_.findIndex(unitList, { name: $('#add-company input[name="name"]').val() }) !== -1) {
  516. throw '已存在对应的单位名称';
  517. }
  518. } catch (err) {
  519. toastr.error(err);
  520. return false;
  521. }
  522. }
  523. /**
  524. * 随机密码(必须包含数字和字母)
  525. */
  526. function randPassword() {
  527. const result = [];
  528. // 随机6-10位
  529. const length = Math.ceil(Math.random() * 2 + 6);
  530. let numberSeed = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
  531. let stringSeed = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
  532. 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
  533. 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
  534. const numRan = numberSeed[Math.floor((Math.random() * numberSeed.length))];
  535. const strRan = stringSeed[Math.floor((Math.random() * stringSeed.length))];
  536. const randSeed = stringSeed.concat(numberSeed);
  537. const seedLength = randSeed.length - 1;
  538. for (let i = 0; i < length; i++) {
  539. const index = Math.ceil(Math.random() * seedLength);
  540. result.push(randSeed[index]);
  541. }
  542. result.splice(Math.floor((Math.random() * result.length)), 0, numRan);
  543. result.splice(Math.floor((Math.random() * result.length)), 0, strRan);
  544. return result.join('');
  545. }