zhaoxiaoqiang1
2026-01-04 f1d30d03186c79ca2cbcfe60d6d2ce7d73fba97b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
var base_url = location.origin;
var usre_info = {};
 
layui.use(['layer','form'], function(){
    window.layer = layui.layer;
    window.form = layui.form;
});
 
layui.use('form', function(){
    var form = layui.form;
    form.verify({
        codeCheck:function(value, item){ //value:表单的值、item:表单的DOM对象
            if(!new RegExp("^\\w+$").test(value)){
                return "只能为数字英文与下划线";
            }
        },
        maxNumCheck:function(value, item){ //value:表单的值、item:表单的DOM对象
            if(value >= 10000){
                return "不能大于10000";
            }
        },
        positiveNumber:[
            /^[0-9]*[1-9][0-9]*$/,
            "只能为正整数"
        ],
        nonnegativeInteger:[
            /^[1-9]\d*|0$/,
            "必填且只能为非负整数"
        ],
        nonNegativeNumber: function(value, item){ //value:表单的值、item:表单的DOM对象
            if(value < 0){
                return '不能为负数';
            }
        },
        positive_decimal:[
            /^[+]{0,1}(\d+)$|^[+]{0,1}(\d+\.\d{1,2})$/,
            "只能为正数,小数点后最多两位"
        ],
        mobile_no_validate:[
            /^[1][0-9]{10}$/,
            "手机号格式不正确"
        ],
        is_url_validate:function(value, item){ //value:表单的值、item:表单的DOM对象
            var strRegex = '^((https|http)?://)'
                +'?(([0-9a-z_!~*().&=+$%-]+: )?[0-9a-z_!~*().&=+$%-]+@)?' //ftp的user@
                + '(([0-9]{1,3}.){3}[0-9]{1,3}' // IP形式的URL- 199.194.52.184
                + '|' // 允许IP和DOMAIN(域名)
                + '([0-9a-z_!~*()-]+.)*' // 域名- www.
                + '([0-9a-z][0-9a-z-]{0,61})?[0-9a-z].' // 二级域名
                + '[a-z]{2,6})' // first level domain- .com or .museum
                + '(:[0-9]{1,4})?' // 端口- :80
                + '((/?)|' // a slash isn't required if there is no file name
                + '(/[0-9a-z_!~*().;?:@&=+$,%#-]+)+/?)$';
            var re=new RegExp(strRegex);
            if (!re.test(value)){
                return "url地址格式不正确";
            }
        },
        identity_no_validate:function(value, item){ //value:表单的值、item:表单的DOM对象
            // 1 "验证通过!", 0 //校验不通过 // id为身份证号码
            var format = /^(([1][1-5])|([2][1-3])|([3][1-7])|([4][1-6])|([5][0-4])|([6][1-5])|([7][1])|([8][1-2]))\d{4}(([1][9]\d{2})|([2]\d{3}))(([0][1-9])|([1][0-2]))(([0][1-9])|([1-2][0-9])|([3][0-1]))\d{3}[0-9xX]$/;
            //号码规则校验
            if(!format.test(value)){
                return "身份证号码不合规";
            }
            //区位码校验
            //出生年月日校验  前正则限制起始年份为1900;
            var year = value.substr(6,4),//身份证年
                month = value.substr(10,2),//身份证月
                date = value.substr(12,2),//身份证日
                time = Date.parse(month+'-'+date+'-'+year),//身份证日期时间戳date
                now_time = Date.parse(new Date()),//当前时间戳
                dates = (new Date(year,month,0)).getDate();//身份证当月天数
            if(time>now_time||date>dates){
                return "出生日期不合规";
            }
            //校验码判断
            var c = new Array(7,9,10,5,8,4,2,1,6,3,7,9,10,5,8,4,2);  //系数
            var b = new Array('1','0','X','9','8','7','6','5','4','3','2'); //校验码对照表
            var id_array = value.split("");
            var sum = 0;
            for(var k=0;k<17;k++){
                sum+=parseInt(id_array[k])*parseInt(c[k]);
            }
            if(id_array[17].toUpperCase() != b[sum%11].toUpperCase()){
                return "身份证校验码不合规";
            }
        },
        user_name_validate:[
            /^[\u4e00-\u9fa5]{2,4}$/,
            "姓名格式不正确"
        ],
        amount_of_money_validate:[
            /^(([1-9][0-9]*)|(([0]\.\d{1,2}|[1-9][0-9]*\.\d{1,2})))$/,
            "格式不正确"
        ]
    });
});
//模拟post请求
function post(URL, PARAMS) {
    var temp = document.createElement("form");
    temp.action = URL;
    temp.method = "post";
    temp.style.display = "none";
//    temp.target = "_bank";
    for (var x in PARAMS) {
        var opt = document.createElement("textarea");
        opt.name = x;
        opt.value = PARAMS[x];
        // alert(opt.name)
        temp.appendChild(opt);
    }
    document.body.appendChild(temp);
    temp.submit();
    return temp;
}
 
 
// 设置全局ajax
$.ajaxSetup({
    xhrFields: {
        withCredentials: true
    },
    beforeSend: function(jqXHR, settings) {
        //在请求前给修改url(增加一个时间戳参数)
        settings.url += settings.url.match(/\?/) ? "&" : "?";
        settings.url += "menuId=" + window.g_menu_id;
    },
    cache: false, //关闭AJAX相应的缓存
    dataFilter : function(res, type){
        if(type == "json"){
            var res2 = JSON.parse(res);
            if(res2.errorCode == "003"){
                location.href = res2.data.loginUrl;
            }
        }
        return res;
    }
});
 
// 带常用搜索部门的部门多选
function trigger_auto_matchwrap_show2(that,event,url,type) {
    $(that).siblings(".auto_matchwrap").toggle();
    if($(that).siblings(".auto_matchwrap").is(':visible')){
        $(that).siblings(".auto_matchwrap").find(".auto_matchinput").val("").focus();
        $(that).parents(".layui-inline").siblings(".layui-inline").find(".auto_matchwrap").hide();
    }else{
 
    };
    $.ajax({
        type: 'POST',
        url: base_url+url,
        data:JSON.stringify({
            params:{
                "queryStr":"",
                "type":type
            }
        }),
        dataType: 'json',
        contentType: "application/json",
        success: function (res) {
            if(res.resultCode == 1){
                if(res.data.list){
                    $(that).siblings(".auto_matchwrap").find(".fuzzy_matching_wrap").show();
                    $(that).siblings(".auto_matchwrap").find(".fuzzy_matching_inner_wrap").html(template('fuzzy_matching_tpl', res.data));
                    $(that).siblings(".auto_matchwrap").find(".fuzzy_matching_inner_wrap").find(".fuzzy_matching_multi_select_input").each(function () {
                        if($.inArray($(this).val(), $(that).siblings(".auto_complateval").val().split(",")) == -1){
                            $(this).prop('checked',false);
                        }else{
                            $(this).prop('checked',true);
                        }
                    });
                    layui.use(['form'], function () {
                        var form = layui.form;
                        form.render();
                    });
                }else{
                    $(that).siblings(".auto_matchwrap").find(".fuzzy_matching_wrap").hide();
                }
            }else{
                layer.msg(res.errorDesc);
            }
        }
    });
    event.stopPropagation();
}
 
 
// 带常用搜索部门的部门多选
function trigger_auto_matchwrap_show(that,event,url) {
    $(that).siblings(".auto_matchwrap").toggle();
    if($(that).siblings(".auto_matchwrap").is(':visible')){
        $(that).siblings(".auto_matchwrap").find(".auto_matchinput").val("").focus();
        $(that).parents(".layui-inline").siblings(".layui-inline").find(".auto_matchwrap").hide();
    }else{
 
    };
    $.ajax({
        type: 'POST',
        url: base_url+url,
        data:JSON.stringify({
 
        }),
        dataType: 'json',
        contentType: "application/json",
        success: function (res) {
            if(res.resultCode == 1){
                if(res.data.list){
                    $(that).siblings(".auto_matchwrap").find(".fuzzy_matching_wrap").show();
                    $(that).siblings(".auto_matchwrap").find(".fuzzy_matching_inner_wrap").html(template('fuzzy_matching_tpl', res.data));
                    $(that).siblings(".auto_matchwrap").find(".fuzzy_matching_inner_wrap").find(".fuzzy_matching_multi_select_input").each(function () {
                        if($.inArray($(this).val(), $(that).siblings(".auto_complateval").val().split(",")) == -1){
                            $(this).prop('checked',false);
                        }else{
                            $(this).prop('checked',true);
                        }
                    });
                    layui.use(['form'], function () {
                        var form = layui.form;
                        form.render();
                    });
                }else{
                    $(that).siblings(".auto_matchwrap").find(".fuzzy_matching_wrap").hide();
                }
            }else{
                layer.msg(res.errorDesc);
            }
        }
    });
    event.stopPropagation();
}
 
function fuzzy_matching_multi_select_unit_click(that) {
    $(that).find(".fuzzy_matching_multi_select_input").trigger("click");
}
 
function fuzzy_matching_multi_select_input(that) {
    if($(that).parents(".auto_matchwrap").siblings(".auto_complateval").val()){
        var id_array = $(that).parents(".auto_matchwrap").siblings(".auto_complateval").val().split(",");
        var name_array = $(that).parents(".auto_matchwrap").siblings(".multi_select_department_wrap").val().split(",");
    }else{
        var id_array = [];
        var name_array = [];
    }
    if($(that).is(':checked') && $.inArray($(that).val(), id_array) == -1){
        id_array.push($(that).val());
        name_array.push($(that).siblings(".fuzzy_matching_multi_select_name").text());
    }else{
        id_array = $.grep(id_array, function(n,i){
            return n != $(that).val();
        });
        name_array = $.grep(name_array, function(n,i){
            return n != $(that).siblings(".fuzzy_matching_multi_select_name").text();
        });
    }
    $(that).parents(".auto_matchwrap").siblings(".auto_complateval").val(id_array.join(","));
    $(that).parents(".auto_matchwrap").siblings(".multi_select_department_wrap").val(name_array.join(","));
    $(that).parents(".auto_matchwrap").siblings(".multi_select_department_wrap").attr("title",name_array.join(","));
    $(that).parents(".auto_matchwrap").siblings(".empty_inputbtn2").show();
    $(that).parents(".auto_matchwrap").siblings(".drop_down_btn").hide();
}
 
function fuzzy_matching_multi_select_input_click(event) {
    event.stopPropagation();
}
 
 
function empty_inputfunc3(that,event){
    $(that).siblings(".multi_select_department_wrap").val("");
    $(that).siblings(".multi_select_department_wrap").removeAttr("title");
    $(that).siblings(".auto_complateval").val("");
    $(that).parents(".auto_matchwrap").find(".fuzzy_matching_inner_wrap").find(".fuzzy_matching_multi_select_input").each(function () {
        $(this).prop('checked',false);
    });
    $(that).hide();
    $(that).siblings(".drop_down_btn").show();
    event.stopPropagation();
}
 
function stop_close_event_propagation(event) {
    event.stopPropagation();
}
 
// 切换模糊匹配备选项(多选)
function change_list_item3(that) {
    var _that = $(that).parents(".auto_matchwrap");
    if(_that.is(":visible")){
        if(window.event.keyCode == 38 && _that.find(".fuzzy_matching_multi_select_unit").index(_that.find(".list_item_active")) != 0){
            _that.find(".list_item_active").removeClass("list_item_active").prev(".fuzzy_matching_multi_select_unit").addClass("list_item_active");
            _that.scrollTop(_that.find(".fuzzy_matching_multi_select_unit").index(_that.find(".list_item_active"))*38);
        }else if(window.event.keyCode == 40 && _that.find(".fuzzy_matching_multi_select_unit").index(_that.find(".list_item_active")) != _that.find(".fuzzy_matching_multi_select_unit").length - 1){
            _that.find(".list_item_active").removeClass("list_item_active").next(".fuzzy_matching_multi_select_unit").addClass("list_item_active");
            _that.scrollTop(_that.find(".fuzzy_matching_multi_select_unit").index(_that.find(".list_item_active"))*38);
        }else if(window.event.keyCode == 13){
            _that.find(".list_item_active").trigger("click");
            _that.hide();
        }
    }else{
 
    }
}
 
// 带常用搜索的模糊匹配多选组件
function input_match_multi_select_department(that,url) {
    //console.log($(that).val());
    var _insert_str = $.trim($(that).val());
    $.ajax({
        type: 'POST',
        url: base_url+url,
        data:JSON.stringify({
            params:{
                "queryStr":_insert_str
            }
        }),
        dataType: 'json',
        contentType: "application/json",
        success: function (res) {
            if(res.resultCode == 1) {
                if (res.data.list) {
                    $(that).parents(".auto_matchwrap").find(".fuzzy_matching_wrap").show();
                    $(that).parents(".auto_matchwrap").find(".fuzzy_matching_inner_wrap").html(template('fuzzy_matching_tpl', res.data));
                    $(that).parents(".auto_matchwrap").find(".fuzzy_matching_inner_wrap").find(".fuzzy_matching_multi_select_input").each(function () {
                        if ($.inArray($(this).val(), $(that).parents(".auto_matchwrap").siblings(".auto_complateval").val().split(",")) == -1) {
                            $(this).prop('checked', false);
                        } else {
                            $(this).prop('checked', true);
                        }
                    });
                    layui.use(['form'], function () {
                        var form = layui.form;
                        form.render();
                    });
                } else {
                    $(that).parents(".auto_matchwrap").find(".fuzzy_matching_wrap").hide();
                }
            }else{
                layer.msg(res.errorDesc);
            }
        }
    });
}
 
 
// 带常用搜索的模糊匹配多选组件
function input_match_multi_select_department2(that,url,type) {
    //console.log($(that).val());
    var _insert_str = $.trim($(that).val());
    $.ajax({
        type: 'POST',
        url: base_url+url,
        data:JSON.stringify({
            params:{
                "queryStr":_insert_str,
                "type":type
            }
        }),
        dataType: 'json',
        contentType: "application/json",
        success: function (res) {
            if(res.resultCode == 1) {
                if (res.data.list) {
                    $(that).parents(".auto_matchwrap").find(".fuzzy_matching_wrap").show();
                    $(that).parents(".auto_matchwrap").find(".fuzzy_matching_inner_wrap").html(template('fuzzy_matching_tpl', res.data));
                    $(that).parents(".auto_matchwrap").find(".fuzzy_matching_inner_wrap").find(".fuzzy_matching_multi_select_input").each(function () {
                        if ($.inArray($(this).val(), $(that).parents(".auto_matchwrap").siblings(".auto_complateval").val().split(",")) == -1) {
                            $(this).prop('checked', false);
                        } else {
                            $(this).prop('checked', true);
                        }
                    });
                    layui.use(['form'], function () {
                        var form = layui.form;
                        form.render();
                    });
                } else {
                    $(that).parents(".auto_matchwrap").find(".fuzzy_matching_wrap").hide();
                }
            }else{
                layer.msg(res.errorDesc);
            }
        }
    });
}
 
$("body").click(function () {
    $(".auto_matchwrap").hide();
});
 
// 表单字段三级判断并赋值
function g_form_field_3level_ctrl(id_str,data_field) {
    // 是否显示
    if(data_field.visible){
        // 是否可编辑
        if(data_field.writeAble){
            $('#'+id_str).attr("readOnly",false);
            // 字段是否必填
            if(data_field.required){
                $('#'+id_str).attr("lay-verify","required");
            }
        }
        $('#'+id_str).val(data_field.value);
    }else{
        $('#'+id_str).parents(".layui-inline").remove();
    }
}
 
 
//artTemplate模板内部取外部变量
template.defaults.imports.$window = window;