PageSourceSearch

https://everdrawing.com/js/common.js?v4

js everdrawing.com collected 2026-10-02 15:26:37 UTC 30,726 bytes, 825 lines download raw bytes

1/**********************参数校验*********************/
2/**
3 * 校验输入,包括是否为空、长度限制;如果校验有误,通过dialog进行错误提示
4 * @param value 待校验的输入值
5 * @param inputNameForMessage 输入值的名称,用于错误提示
6 * @param checkEmpty 是否校验为空
7 * @param minLength 最小长度值,大于0时进行校验
8 * @param maxLength 最大长度值,大于0时进行校验
9 * @returns {boolean} 校验结果
10 */
11function checkInput(value, inputNameForMessage, checkEmpty, minLength, maxLength) {
12    if(checkEmpty && isStrEmpty(value)){
13        alertDialog(inputNameForMessage + "不能为空");
14        return false;
15    }
16    if((minLength > 0 && value.length < minLength)
17        || maxLength > 0 && value.length > maxLength){
18        alertDialog(inputNameForMessage + "长度不符合要求");
19        return false;
20    }
21    return true;
22}
23//判断字符串是否为空
24function isStrEmpty(str){
25	if(str == null || str == undefined || str == ""){
26		return true;
27	}
28	return false;
29}
30//判断字符串是否是正整数
31function validatePositiveInteger(str){
32	var re = /^[1-9]\d*$/;
33	if (!re.test(str)) {
34		return false;
35	}
36	return true;
37}
38//判断字符串是否是非负数
39function validatePositiveNumber(str){
40	return !isNaN(parseFloat(str)) && isFinite(str) && !str.startsWith("-");
41}
42//校验手机号格式
43function validateMobile(mobile){
44	if(isStrEmpty(mobile)){
45		return false;
46	}
47	if(!(/^1[0-9]{10}$/.test(mobile))){
48		return false;
49	}
50	return true;
51}
52//检查字符串是否为邮件地址
53function validateEmail(email) {
54	var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
55	return re.test(String(email).toLowerCase());
56}
57// 转义html特殊字符
58function escapeHtml(input) {
59    if (typeof input !== 'string') return input;
60
61    return input.replace(/[&<>"'/]/g, function(match) {
62        switch (match) {
63            case '&':
64                return '&amp;';
65            case '<':
66                return '&lt;';
67            case '>':
68                return '&gt;';
69            case '"':
70                return '&quot;';
71            case "'":
72                return '&#39;';
73            case "/":
74                return '&#47;';
75            default:
76                return match;
77        }
78    });
79}
80//获取当前deviceType
81function getDeviceType() {
82    return isMacOS() ? "18" : "15";
83}
84
85// 获取操作系统类型是否Mac
86function isMacOS(){
87    var p = navigator.platform;
88    if(p != undefined && p.indexOf("Mac") == 0){
89        return true;
90    }
91    return false;
92}
93function isStrongPassword(str) {
94    /* 长度校验 */
95    if (str.length < 8 || str.length > 16) {
96        return false;
97    }
98    // 字符 字母 数字三选二(正则来自用户中心)
99    var reg = new RegExp(/(?!^(\d+|[a-zA-Z]+|[`,~,!,@,#,$,%,^,&,*,(,),\-,_,=,+,\[,{,\],},;,:,',\\,|,\,,<,.,>,/,?]+)$)^[\w,`,~,!,@,#,$,%,^,&,*,(,),\-,_,=,+,\[,{,\],},;,:,',\\,|,\,,<,.,>,/,?]+$/);
100    return reg.test(str);
101}
102function getWebDeviceType() {
103    return isMacOS() ? "18" : "15";
104}
105
106/**
107 * 格式化时间,目前支持以下格式:
108 * yyyy-MM-dd
109 */
110function formatTime(date, format) {
111    if(format != "yyyy-MM-dd"){
112        return "";
113    }
114    var year = date.getFullYear().toString().padStart(4, '0');
115    var month = (date.getMonth() + 1).toString().padStart(2, '0');
116    var day = date.getDate().toString().padStart(2, '0');
117    var hour = date.getHours().toString().padStart(2, '0');
118    var minute = date.getMinutes().toString().padStart(2, '0');
119    var second = date.getSeconds().toString().padStart(2, '0');
120    if(format == "yyyy-MM-dd"){
121        return year + "-" + month + "-" + day;
122    }
123    return "";
124}
125
126/**********************按钮处理*********************/
127function disableBtn($btn) {
128	$btn.attr("disabled", true);
129    $btn.addClass("ent-p-disabled");
130}
131function waitBtn($btn) {
132    $btn.attr("disabled", true);
133    $btn.addClass("pdf-p-waiting");
134}
135// 启动btn
136function enableBtn($btn) {
137    $btn.removeAttr("disabled");
138    $btn.removeClass("ent-p-disabled");
139    $btn.removeClass("ent-p-waiting");
140}
141
142// 为按钮添加禁用定时器,倒计时为60s
143function addTimerForBtn($btn) {
144    $btn = $($btn);
145    var wait = 60;
146    !function timer() {
147        if (wait === 0) {
148            enableBtn($btn);
149            $btn.text("获取验证码");
150            wait = 60;
151        } else {
152            disableBtn($btn)
153            $btn.text(wait + "秒后重试");
154            wait--;
155            setTimeout(timer, 1000);
156        }
157    }();
158}
159
160/**********************根据input显示图片*********************/
161function showImg(input, id) {
162	var file = input.files[0];
163	var url = window.URL.createObjectURL(file);
164	document.getElementById(id).src = url;
165}
166
167/**********************图片点击放大*********************/
168//使得图片能够点击放大
169function initModalImage(imgDomStr){
170  // 移动端禁用该操作
171  if(isMobilePage()){
172    return ;
173  }
174
175  var $imgDomList = $(imgDomStr);
176
177  $imgDomList.each(function(index){
178    var $imgDom = $(this);
179    $imgDom.css("cursor", "pointer");
180
181    $imgDom.click(function(){
182      var $modalImgContainer = $('<div class="ent-modal-img"></div>');
183      var $modalClose = $('<span class="ent-close">&times;</span>');
184      var $clonedImg = $imgDom.clone();
185      $clonedImg.css("cursor", "auto");
186      $modalImgContainer.append($modalClose);
187      $modalImgContainer.append($clonedImg);
188      $("body").append($modalImgContainer);
189      crShow($modalImgContainer);
190
191      $modalClose.click(function(){
192        crHide($modalImgContainer, true);
193      });
194    });
195  });
196}
197
198//检查当前页面是否为移动页面
199function isMobilePage(){
200  return $(window).width() <= 700;
201}
202
203function crShow($dom){
204  $dom.show();
205}
206function crHide($dom, remove){
207  setTimeout(function() {
208    $dom.hide();
209    if(remove){
210      $dom.remove();
211    }
212  }, 10);
213}
214
215/**********************引入分页*********************/
216/**
217 * 引入分页
218 * @param paginationWrap 分页Wrap
219 * @param callback 分页内回调方法
220 * @param currentPage 当前页
221 * @param maxPageNum 最大页数
222 */
223function loadPagination(paginationWrap, callback, currentPage, maxPageNum) {
224    var htmlPagination = "";
225    $paginationWrap = $(paginationWrap);
226    if(maxPageNum < 2){
227        $paginationWrap.html(htmlPagination);
228        return;
229    }
230    if(currentPage > 1){
231        htmlPagination = htmlPagination +
232            '<li><a href="javascript:void(0);" data-pageNum="' + (currentPage - 1) + '">«</a></li>' +
233            '<li><a href="javascript:void(0);" data-pageNum="1">1</a></li>';
234    }
235    if(currentPage > 2){
236        htmlPagination = htmlPagination + '<li><a href="javascript:void(0);">...</a></li>';
237    }
238    htmlPagination = htmlPagination + '<li class="active"><a href="javascript:void(0);">' + currentPage + '</a></li>';
239    if((currentPage + 1) < maxPageNum){
240        htmlPagination = htmlPagination + '<li><a href="javascript:void(0);">...</a></li>'
241    }
242    if(currentPage < maxPageNum){
243        htmlPagination = htmlPagination +
244            '<li><a href="javascript:void(0);" data-pageNum="' + (maxPageNum) + '">' + maxPageNum + '</a></li>' +
245            '<li><a href="javascript:void(0);" data-pageNum="' + (currentPage + 1) + '">»</a></li>';
246    }
247    $paginationWrap.html(htmlPagination);
248    $paginationWrap.find("li a").click(function () {
249        var pageNum = $(this).attr("data-pageNum");
250        callback(pageNum);
251    });
252}
253
254/**********************发送ajax请求*********************/
255// 获取到需要带有重定向的登录页面 url
256function loginUrlWithRedirect(){
257    var srcUrl = location.pathname + location.search;
258    return "/account/login?referrer=" + encodeURIComponent(srcUrl);
259}
260
261function ajaxRequest(type, url, data, callback, timeout, callbackForTimeout){
262	if(typeof(data) == 'string'){
263		if(data.indexOf("requestType") === -1){
264			data += "&requestType=asyn";
265		}
266	}else if(data instanceof FormData){
267		if(!data.has("requestType")){
268			data.append("requestType", "asyn");
269		}
270    }else {
271		if (!('requestType' in data)) {
272			data['requestType'] = 'asyn';
273		}
274	}
275	//根据data形式选择ajax
276    if(data instanceof FormData){
277        $.ajax({
278            type: type,
279            url: url,
280            data: data,
281            processData: false,
282            contentType: false,
283            statusCode: {
284                200: callback,
285                401: function(){
286                    location.href = loginUrlWithRedirect();
287                },
288                402: function(){
289                    window.location.reload();
290                },
291                403: function () {
292                    location.href = "/enterprise/overview";
293                },
294                504: callbackForTimeout
295            }
296        });
297    }else {
298        $.ajax({
299            type: type,
300            url: url,
301            data: data,
302            traditional : true,
303            statusCode: {
304                200: callback,
305                401: function(){
306                    location.href = loginUrlWithRedirect();
307                },
308                402: function(){
309                    window.location.reload();
310                },
311                403: function () {
312                    location.href = "/enterprise/overview";
313                },
314                504: callbackForTimeout
315            }
316        });
317    }
318}
319
320// 封装 ajaxRequest 的 post 请求
321function httpPost(url, data, callback){
322    ajaxRequest( 'post', url, data, callback);
323}
324
325// 封装 ajaxRequest 的 get 请求
326function httpGet(url, data, callback){
327    if(arguments.length === 2){
328        callback = data;
329        data = {};
330    }
331    ajaxRequest('get', url, data, callback);
332}
333
334/**********************模态对话框相关*********************/
335// 对话框相关函数
336// 对话框部分开始
337var $dialogTemplate = $('<div id="ent-dialog-dom">' +
338    '  <div class="ent-modal"></div>' +
339    '  <div class="ent-dialog full-screen">' +
340    '    <div class="ent-dialog-header">' +
341    '      <h3 class="ent-title">标题</h3><a class="ent-dialog-close ent-close-dialog">✕</a>' +
342
343    '    </div>' +
344    '    <div class="ent-dialog-content">' +
345    '      <p class="ent-content">' +
346    '        内容' +
347    '      </p>' +
348    '    </div>' +
349    '    <div class="ent-dialog-footer">' +
350    '      <button class="ent-close-dialog confirm">确认</button>' +
351    '      <button class="ent-line-light ent-close-dialog cancel reversed">取消</button>' +
352    '    </div>' +
353    '  </div>' +
354    '</div>');
355
356function setDialog($dialogDom, content, title, callback, contentType){
357    $dialogDom.find('.ent-title').text(title);
358    contentType !== 'html' ? $dialogDom.find('.ent-content').text(content) : $dialogDom.find('.ent-dialog-content').html(content);
359    $dialogDom.find('form').on('submit', function (e) {
360        e.preventDefault();
361    });
362    var $firstInput = $dialogDom.find('input[type=text]:visible,input[type=number]:visible').first();
363    $firstInput.length > 0 && $firstInput.focus();
364    callback && $dialogDom.find('.confirm').click(function (e) {
365        disableBtn($(this));
366        callback(e, $dialogDom);
367    });
368}
369
370function showDialog($dialogDom){
371    var $body = $('body');
372    if ($body.find('.ent-modal').length > 1) {
373        window.dialogZIndexDelta = window.dialogZIndexDelta ? window.dialogZIndexDelta + 2 : 2;
374        var $dialog = $dialogDom.find('.ent-dialog');
375        var currentDialogZIndex = parseInt($dialog.css('z-index'));
376        $dialog.css("z-index", currentDialogZIndex + window.dialogZIndexDelta);
377        var $dialogModal = $dialogDom.find('.ent-modal');
378        var currentDialogModalZIndex = parseInt($dialogModal.css('z-index'));
379        $dialogModal.css("z-index", currentDialogModalZIndex + window.dialogZIndexDelta);
380    }
381    $dialogDom.show().find('.ent-modal').show();
382    $dialogDom.find('.ent-close-dialog').click(function(){
383        closeDialog($dialogDom);
384    });
385}
386
387function closeDialog($dialogDom){
388    $dialogDom.hide();
389}
390
391// 绑定当前确认对话框的内容,并打开
392function confirmDialog(title, content, callback, contentType, customSet){
393    $('#ent-confirm-dialog').remove();
394    var $dialogDom = $dialogTemplate.clone().attr('id', 'ent-confirm-dialog').appendTo($('body'));
395    customSet && customSet($dialogDom);
396    setDialog($dialogDom, content, title, callback, contentType);
397    showDialog($dialogDom);
398}
399
400function alertDialog(content, title, callback, contentType, customSet){
401    $('#ent-alert-dialog').remove();
402    title = title || '云图企业账号';
403    var $dialogDom = $dialogTemplate.clone().attr('id', 'ent-alert-dialog').find('.cancel').remove().end();
404    customSet && customSet($dialogDom);
405    $dialogDom.appendTo($('body'));
406    setDialog($dialogDom, content, title, callback, contentType);
407    showDialog($dialogDom);
408}
409// 对话框部分结束
410
411
412// 登录相关函数开始
413function formError($form, msg){
414    $form.prepend('<div class="ent-alert ent-p-danger">' + msg + '</div>')
415}
416
417function clearError($form){
418    $form.find(".ent-alert").remove();
419}
420/**
421 * 初始化第三方智能验证码,验证成功时调用发短信接口
422 */
423function init3rdCaptcha() {
424    initNECaptcha({
425        element: '#captcha-ne',
426        captchaId: '162e2ddf42044a27847d38e237130176',
427        mode: 'bind',
428        width: '320px',
429        onVerify: function (err, data) {
430            if (data) {
431                // 密码登录使用验证码
432                if ($("#password-tab.ent-selected").length > 0) {
433                    $("#password-login .ent-img-captcha-key").val(data.validate);
434                    loginByPasswordAfterCheck();
435                    return;
436                }
437                // 发短信使用验证码
438                sendSmsCodeAfterCheck(data.validate);
439            }
440        }
441    }, function (instance) {
442        window.neCaptchaIns = instance;
443    }, function (err) {
444        alertDialog("初始化失败,请刷新重试");
445        console.log(err);
446    });
447}
448
449//获取短信验证码
450function sendSmsCode(){
451    // 判断按钮是否已禁用,禁用则返回
452    if($("#ent-send-sms-btn").attr("disabled") === "disabled"){
453        return;
454    }
455    //参数校验
456    var $form = $('.ent-login-form > .ent-container');
457    clearError($form);
458    var mobile = $('input[name=mobile]').val();
459    if(!validateMobile(mobile)){
460        formError($form, "请输入正确的手机号码");
461        return;
462    }
463    var imgCaptchaValue = $('input[name=imgCaptchaValue]').val();
464    var imgCaptchaType = $("#img-captcha-type").val();
465    if(imgCaptchaType !== "GLODON_3RD_NE" && isStrEmpty(imgCaptchaValue)){
466        formError($form, "图片验证码不能为空");
467        return;
468    }
469    window.neCaptchaIns ? window.neCaptchaIns.verify() : sendSmsCodeAfterCheck($('input[name=imgCaptchaKey]').val());
470}
471
472/**
473 * 发送短信验证码
474 * @param captchaKey 图形验证码 key,第三方验证码时为 validate 内容
475 */
476function sendSmsCodeAfterCheck(captchaKey) {
477    var $form = $('.ent-login-form > .ent-container');
478    var captchaType = $("#captchaType").val();
479    //构造请求参数
480    var data = {
481        mobile: $('input[name=mobile]').val(),
482        captchaKey: captchaKey,
483        captchaValue: $("input[name='imgCaptchaValue']").val(),
484        timestamp: $("input[name='imgCaptchaTimestamp']").val(),
485        sign: $("input[name='imgCaptchaSign']").val(),
486        captchaType: captchaType
487    };
488    httpPost('/account/send_verification_code/oyRm521ZdQ', data, function(ret){
489        if(ret.code === 0){
490            addTimerForBtn($('#ent-send-sms-btn'));
491        }else{
492            formError($form, ret.msg);
493        }
494        refreshCaptcha('.' + captchaType + ' .ent-input-with-img-captcha');
495    });
496}
497
498// 密码登录
499function loginByPasswordAfterCheck() {
500    var $form = $("#password-login");
501    httpPost('/account/passwd_login', $form.serialize(), function (ret) {
502        if (ret.code === 0) {
503            location.reload();
504        } else {
505            loginByPasswordRequireCaptcha = true;
506            if (!isCaptchaNe) {
507                $("#password-login .ent-input-with-img-captcha").show();
508            }
509            refreshCaptcha("#password-login .ent-input-with-img-captcha");
510            formError($form, ret.msg);
511            enableBtn($form.find("input[type='submit']"));
512        }
513    });
514}
515
516/**
517 * 获取图片验证码,成功时设置 CaptchaKey 和验证码图片
518 */
519//获取图片验证码
520function refreshCaptcha(selector){
521    httpGet('/account/get_image_captcha/sgj65dh7ae', function(ret){
522        if(ret.data.captchaNe === 1) {
523            // 第三方智能验证码初始化
524            init3rdCaptcha();
525            $("#img-captcha-type").val("GLODON_3RD_NE");
526            return;
527        }
528
529        var data = ret.data;
530        $(selector).children(".ent-img-captcha-key").val(data.captchaKey);
531        $(selector).children(".ent-img-captcha-timestamp").val(data.timestamp);
532        $(selector).children(".ent-img-captcha-sign").val(data.sign);
533        $(selector).children(".ent-img-captcha-value").attr('placeholder', data.placeholder);
534        var imgHtml = '<img onclick="refreshCaptcha(\'' + selector + '\')" src="data:image/png;base64,' + data.imageContent + '" />';
535        $(selector).children(".ent-img-captcha-container").html(imgHtml);
536        $(selector).show();
537        var $prev = $(selector).prev();
538        if ($prev.length > 0 && $prev.text() === '图片验证码') {
539            $prev.show();
540        }
541    });
542}
543
544function chooseStaffAccount(staffId) {
545    httpPost("/account/choose", {"staffId": staffId}, function (ret) {
546        if (ret.code === 0) {
547            (typeof referrer === 'undefined' || !referrer) ?
548              (location.pathname.indexOf('/account/login') === -1 ? location.reload() : location.href = '/enterprise/overview')
549              : location.href = referrer;
550        } else {
551            alertDialog(ret.msg);
552        }
553    })
554}
555
556// 登录相关函数结束
557// 切换账号
558function switchAccount() {
559    httpPost("/account/list", {}, function (ret) {
560        if (ret.code !== 0) {
561            alertDialog(ret.msg);
562            return;
563        }
564        // 企业账号列表为空,则跳转至创建
565        var accounts = ret.data.accounts;
566        if ($.isEmptyObject(accounts)) {
567            location.href = "/enterprise/createEnterprise/index";
568            return;
569        }
570        var $switchAccountDialog = $('<div id="ent-switch-account-dialog">' +
571            '  <div class="ent-modal"></div>' +
572            '  <div class="ent-dialog full-screen">' +
573            '    <div class="ent-login-form">' +
574            '      <a class="ent-close ent-close-dialog">✕</a>' +
575            '      <div class="ent-ent-chooser">' +
576            '        <div class="chooser-header">选择企业进入</div>' +
577            '        <div class="chooser-body"></div>' +
578            '      </div>' +
579            '    </div>' +
580            '  </div>' +
581            '</div>');
582        var $chooserBody = $switchAccountDialog.find(".chooser-body");
583        accounts.forEach(function (account) {
584            var itemPrefixHtml = (account.staffId !== ret.data.current)
585                ? '<a class="chooser-item" href="javascript:void(0)" onclick="chooseStaffAccount(\'' + account.staffId + '\')">'
586                : '<a class="chooser-item selected" href="javascript:void(0)">';
587            itemPrefixHtml +=
588                '  <div class="item-header"><i class="ent-icon icon-avatar-chooser"></i></div>' +
589                '  <div class="item-body">' +
590                '    <div class="ent-name">' + escapeHtml(account.enterpriseName) + '</div>';
591            if (account.licenseProductList) {
592                itemPrefixHtml +=
593                    '<div class="ent-Info">' +
594                        '<div>' +
595                            '<span>授权产品:</span>';
596                account.licenseProductNameList.forEach(licenseProductName => {
597                    itemPrefixHtml += `<span>${licenseProductName}&nbsp;</span>`;
598                });
599                itemPrefixHtml += '</div><div>';
600                itemPrefixHtml += `<span>授权点数:${account.allocatedLicensePointCount}/${account.licensePointCount}</span>`;
601                itemPrefixHtml += account.gmtEnd.substring(0, 4) < 2200 ?
602                    `<span>&nbsp;&nbsp;授权到期时间:${account.gmtEnd.substring(0, 10)}</span>` : '<span>&nbsp;&nbsp;授权期限:永久</span>';
603                itemPrefixHtml += '</div></div>';
604            } else {
605                itemPrefixHtml += '<span>企业尚未购买授权</span>';
606            }
607            itemPrefixHtml +=
608                '  </div>' +
609                '</a>';
610            $chooserBody.append(itemPrefixHtml);
611        });
612        $('#ent-switch-account-dialog').remove();
613        $switchAccountDialog.appendTo($('body'));
614        showDialog($switchAccountDialog);
615    })
616}
617
618function showTooltips(content, colorClass) {
619    $tooltips = $('<div id="ent-tooltips" class="ent-tooltips ' + colorClass + '">' +
620      escapeHtml(content) + '</div>');
621    $tooltips.css({"margin-left": -$tooltips.width()/2});
622    var wait = 2;
623    $tooltips.appendTo($('body'));
624    !function timer() {
625        if (wait === 0) {
626            $('.ent-tooltips').remove();
627        } else {
628            wait--;
629            setTimeout(timer, 1000);
630        }
631    }();
632}
633
634/**
635 * 校验员工相关输入,未校验手机号
636 * @param $form 添加员工的 form jquery 对象
637 * @param $submitButton 提交按钮的 jquery 对象
638 * @returns {boolean} 校验是否通过
639 */
640function checkStaffInputs($form, $submitButton) {
641    var name = $("input[name='name']").val();
642    var departmentName = $("input[name='departmentName']").val();
643    var position = $("input[name='position']").val();
644    var remark = $("input[name='remark']").val();
645    if(isStrEmpty(name) || name.length > 30){
646        formError($form, "姓名输入不符合要求");
647        enableBtn($submitButton);
648        return false;
649    }
650    if(departmentName && departmentName.length > 100){
651        formError($form, "部门输入不符合要求");
652        enableBtn($submitButton);
653        return false;
654    }
655    if(position && position.length > 20){
656        formError($form, "岗位输入不符合要求");
657        enableBtn($submitButton);
658        return false;
659    }
660    if(remark && remark.length > 100){
661        formError($form, "备注输入不符合要求");
662        enableBtn($submitButton);
663        return false;
664    }
665    return true;
666}
667
668/**
669 * 校验手机号输入
670 */
671function checkMobileInput($form, $submitButton) {
672    var mobile = $("input[name='mobile']").val();
673    if (!validateMobile(mobile)) {
674        formError($form, "手机号不符合要求");
675        enableBtn($submitButton);
676        return false;
677    }
678    return true;
679}
680
681/**
682 * 去除form表单中input前导和尾随空格
683 */
684function trimInput($form) {
685    $form.find('input').each(function (index, ele) {
686        $(ele).val($(ele).val().trim());
687    })
688}
689
690/**
691 * 显示 form 中的错误信息,兼容 spring validation 错误信息,目前只支持 
691input 标签的错误信息,需要使用 ent-error 样式容器配合输出错误信息
692 * @param errors 错误信息列表 [{field: "name", defaultMessage: "错误信息"},{...}]
693 */
694function displayFormErrors(errors) {
695    // 清除 form 中的各种错误显示
696    var inputErrorSelector = ":input ~ .ent-error";
697    $(inputErrorSelector).html("");
698    $(inputErrorSelector).hide();
699
700    // 将错误信息绑定在 form 中(需要 html 配合)
701    for (var errorIndex in errors) {
702        var error = errors[errorIndex];
703        $(":input[name='" + error.field + "'] ~ .ent-error").html(error.defaultMessage);
704        $(inputErrorSelector).show();
705    }
706}
707
708// 数据资产交接使用
709function handoverDataAsset(id, name, mobile) {
710    confirmDialog('数据资产交接', '<form id="ent-handover-staff-form">' +
711      '  <div class="ent-section">' +
712      '    <div class="section-header">待交接员工信息</div>' +
713      '    <div class="section-body">' +
714      '      <div class="bg-gray">' +
715      '        <p>姓名:<b>' + escapeHtml(name) + '</b></p>' +
716      '        <p>手机号:<b>' + mobile + '</b></p>' +
717      '      </div>' +
718      '    </div>' +
719      '  </div>' +
720      '  <div class="ent-section">' +
721      '    <div class="section-header">数据资产交接方式</div>' +
722      '    <div class="section-body">' +
723      '      <div class="asset-disposal">' +
724      '        <div class="disposal-method">' +
725      '          <label class="ent-radio">' +
726      '            <input type="radio" name="assetDisposalMethod" value="1" checked="checked" onclick="cho
726oseAssetsDisposalMethod(this)" />' +
727      '            <span>转移给其他员工</span>' +
728      '          </label>' +
729      '          <label class="ent-radio">' +
730      '            <input type="radio" name="assetDisposalMethod" value="2" onclick="chooseAssetsDisposalMethod(this)" />' +
731      '            <span>删除</span>' +
732      '          </label>' +
733      '        </div>' +
734      '        <div class="disposal-alert"><div class="ent-alert ent-p-warning">系统将转移该员工的数据资产和图纸容量至您设置的接收员工账号。</div></div>' +
735      '      </div>' +
736      '    </div>' +
737      '  </div>' +
738      '  <div class="ent-section" id="asset-receiver">' +
739      '    <div class="section-header">设置数据资产接收员工账号</div>' +
740      '    <div class="section-body">' +
741      '      <div class="ent-labeled-input2">' +
742      '        <span class="ent-label"><span class="ent-red">*</span>接收员工账号</span>' +
743      '        <input class="ent-input" type="text" name="mobile" placeholder="请输入接收员工登录的手机号"/>' +
744      '      </div>' +
745      '    </div>' +
746      '  </div>' +
747      '  <input type="hidden" name="id" value="' + id + '" />' +
748      '  <input class="ent-hidden" type="submit"/>' +
749      '</form>', function (e, $confirmDialog) {
750        e.preventDefault();
751        var $form = $('#ent-handover-staff-form');
752        trimInput($form);
753        var $confirmBtn = $confirmDialog.find(".confirm");
754        var assetDisposalMethod = $('input[name="assetDisposalMethod"]:checked').val();
755        var receiverMobile = $("input[name='mobile']").val();
756        clearError($form);
757        if(assetDisposalMethod === '1' && !checkMobileInput($form, $confirmBtn)){
758            return;
759        }
760        if (assetDisposalMethod === '1' && mobile === receiverMobile) {
761            formError($form, "接收人手机号与待交接员工手机号相同");
762            enableBtn($confirmBtn);
763            return;
764        }
765        var assetDisposalHtmlTip = assetDisposalMethod === '1' ? ('将转移给<b>' + receiverMobile + '</b></p>') : ('将<b>全部删除</b>。</p>');
766        alertDialog('<p>账号<b>' + mobile + '</b>的数据资产' + assetDisposalHtmlTip +
767          '<p>确认交接数据资产吗?</p>', "数据资产交接确认", function () {
768            var data = $form.serialize();
769            httpPost("/staff/delete", data, function (ret) {
770                if (ret.code === 0) {
771                    closeDialog($confirmDialog);
772                    alertDialog(ret.data, "数据资产交接", function () {
773                        location.reload();
774                    }, "html", function ($alertDialogDom) {
775                        $alertDialogDom.find(".ent-dialog-content").css("max-height", "400px");
776                    });
777                } else {
778                    formError($form, ret.msg);
779                    enableBtn($confirmBtn);
780                }
781            });
782        }, 'html', function ($dialogDom) {
783            $dialogDom.find(".ent-close-dialog").click(function () {
784                $(this).hasClass("confirm") || enableBtn($confirmBtn);
785            });
786        });
787    }, 'html', function ($dialogDom) {
788        $dialogDom.find('.confirm').removeClass('ent-close-dialog');
789    });
790}
791function chooseAssetsDisposalMethod(radioInput) {
792    var $radioInput = $(radioInput);
793    var method = $radioInput.val();
794    var $assetDisposal = $radioInput.closest('.asset-disposal');
795    var $assetAlert = $assetDisposal.find('.disposal-alert');
796    var $assetReceiver = $('#asset-receiver');
797    switch (method) {
798        case '1':
799            $assetAlert.html('<div class="ent-alert ent-p-warning">系统将转移该员工的数据资产和图纸容量至您设置的接收员工账号。</div>');
800            $assetReceiver.html('<div class="section-header">设置数据资产接收员工账号</div>' +
801              '<div class="section-body">' +
802              '  <div class="ent-labeled-input2">' +
803              '    <span class="ent-label"><span class="ent-red">*</span>接收员工手机号</span>' +
804              '    <input class="ent-input" type="text" name="mobile" placeholder="请输入接收员工登录的手机号"/>' +
805              '  </div></div>');
806            return;
807        case '2':
808            $assetAlert.html('<div class="ent-alert ent-p-danger">系统将删除该员工的所有数据资产。</div>');
809            $assetReceiver.html('');
810            return;
811        case '3':
812            $assetAlert.html('<div class="ent-alert ent-p-warning">系统暂不处理该员工的数据资产转移,管理员可在”已删除员工“中管理员工资产转移。</div>');
813            $assetReceiver.html('');
814            return;
815        default:
816    }
817}
818// 未定义和null转为空字符串,其他转为字符串修剪两端空白
819function nonToEmptyElseTrim(str) {
820    if (str === undefined || str === null) {
821        return '';
822    } else {
823        return String(str).trim();
824    }
825}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.