common.js
6.02 KB
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
/**
* 通用方法封装处理
* Copyright (c) 2018 huaheng
*/
$(function(){
// 复选框事件绑定
if ($.fn.select2 !== undefined) {
$("select.form-control:not(.noselect2)").each(function () {
$(this).select2().on("change", function () {
$(this).valid();
})
})
}
if ($(".i-checks").length > 0) {
$(".i-checks").iCheck({
checkboxClass: "icheckbox_square-green",
radioClass: "iradio_square-green",
})
}
if ($(".time").length > 0) {
layui.use('laydate', function() {
var laydate = layui.laydate;
var day1 = new Date();
day1.setTime(day1.getTime()-24*60*60*1000*7);
var endDay = new Date();
endDay.setTime(endDay.getTime()+24*60*60*1000);
laydate.render({ elem: '#startTime', theme: 'molv',value: new Date(day1), isInitValue: true});
laydate.render({ elem: '#endTime', theme: 'molv',value: new Date(endDay), isInitValue: true });
});
}
if ($(".time2").length > 0) {
layui.use('laydate', function() {
var laydate = layui.laydate;
var day1 = new Date();
day1.setTime(day1.getTime()-24*60*60*1000*7);
var endDay = new Date();
endDay.setTime(endDay.getTime()+24*60*60*1000);
laydate.render({ elem: '#startTime', theme: 'molv'});
laydate.render({ elem: '#endTime', theme: 'molv'});
});
}
if ($(".select-time").length > 0) {
layui.use('laydate', function() {
var laydate = layui.laydate;
var day1 = new Date();
day1.setTime(day1.getTime()-24*60*60*1000*7);
var endDay = new Date();
endDay.setTime(endDay.getTime()+24*60*60*1000);
laydate.render({ elem: '#startTime', theme: 'molv'});
laydate.render({ elem: '#endTime', theme: 'molv'});
});
}
if ($(".select-time2").length > 0) {
layui.use('laydate', function() {
var laydate = layui.laydate;
var day1 = new Date();
day1.setTime(day1.getTime()-24*60*60*1000*7);
var endDay = new Date();
endDay.setTime(endDay.getTime()+24*60*60*1000);
laydate.render({ elem: '#startTime', theme: 'molv'});
laydate.render({ elem: '#endTime', theme: 'molv'});
});
}
});
/** 创建选项卡 */
function createMenuItem(dataUrl, menuName) {
dataIndex = $.common.random(1,100),
flag = true;
if (dataUrl == undefined || $.trim(dataUrl).length == 0) return false;
var topWindow = $(window.parent.document);
// 选项卡菜单已存在
$('.menuTab', topWindow).each(function() {
//todo 增加判断 如果是detail 则需去掉后面的/id 再判断
if ($(this).data('id') == dataUrl) {
if (!$(this).hasClass('active')) {
$(this).addClass('active').siblings('.menuTab').removeClass('active');
$('.page-tabs-content').animate({ marginLeft: ""}, "fast");
// 显示tab对应的内容区
$('.mainContent .huaheng_iframe', topWindow).each(function() {
if ($(this).data('id') == dataUrl) {
$(this).show().siblings('.huaheng_iframe').hide();
return false;
}
});
}
flag = false;
return false;
}
});
// 选项卡菜单不存在
if (flag) {
var str = '<a href="javascript:;" class="active menuTab" data-id="' + dataUrl + '">' + menuName + ' <i class="fa fa-times-circle"></i></a>';
$('.menuTab', topWindow).removeClass('active');
// 添加选项卡对应的iframe
var str1 = '<iframe class="huaheng_iframe" name="iframe' + dataIndex + '" width="100%" height="100%" src="' + dataUrl + '" frameborder="0" data-id="' + dataUrl + '" seamless></iframe>';
$('.mainContent', topWindow).find('iframe.huaheng_iframe').hide().parents('.mainContent').append(str1);
// 添加选项卡
$('.menuTabs .page-tabs-content', topWindow).append(str);
}
return false;
}
/** 设置全局ajax超时处理 */
$.ajaxSetup({
complete: function(XMLHttpRequest, textStatus) {
if (textStatus == "parsererror") {
$.modal.confirm("登陆超时!请重新登陆!", function() {
window.location.href = ctx + "login";
})
}
}
});
function getUrlParms(){
var args = new Object();
//获取查询串
var query = location.search.substring(1);
//在&处断开
var pairs = query.split("&");
for(var i=0; i<pairs.length; i++) {
//查找name=value
var pos = pairs[i].indexOf('=');
//如果没有找到就跳过
if(pos == -1) continue;
//提取name
var argname = pairs[i].substring(0,pos);
//提取value
var value = pairs[i].substring(pos+1);
//存为属性
args[argname] = decodeURI(value);
}
return args;
}
/** 拓展方法,替换字符串中字段的值 */
function formValueReplace (formData, replaceField, replaceValue) {
var beginIndex = formData.indexOf("&"+replaceField);
if (beginIndex > -1) {
var endIndex = formData.indexOf("&", beginIndex+1);
if (endIndex > -1) {
formData = formData.substring(0, beginIndex) + formData.substring(endIndex, formData.length);
}
else {
formData = formData.substring(0, beginIndex);
}
}
return formData + "&" + replaceField + "=" + replaceValue;
};
// function formValueReplace(formData, replaceField, replaceValue) {
// var beginIndex = formData.indexOf("&"+replaceField);
// if (beginIndex > -1) {
// var endIndex = formData.indexOf("&", beginIndex+1);
// if (endIndex > -1) {
// formData = formData.substring(0, beginIndex) + formData.substring(endIndex, tableValue.length);
// }
// else {
// formData = formData.substring(0, beginIndex);
// }
// formData = formData + "&" + replaceField + "=" + replaceValue;
// }
// }