UserAvatar_wev8.js
7.71 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
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
if(typeof(MEC_NS) == 'undefined'){
MEC_NS = {};
}
MEC_NS.UserAvatar = function(type, id, mecJson){
this.type = type;
if(!id){
id = new UUID().toString();
}
this.id = id;
if(!mecJson){
mecJson = this.getDefaultMecJson();
}
this.mecJson = mecJson;
}
/*获取id。 必需的方法*/
MEC_NS.UserAvatar.prototype.getID = function(){
return this.id;
};
/*获取设计的html, 页面上怎么显示控件完全依赖于此方法。 必需的方法*/
MEC_NS.UserAvatar.prototype.getDesignHtml = function(){
var theId = this.id;
var htmTemplate = getPluginContentTemplateById(this.type);
htmTemplate = htmTemplate.replace("${theId}", theId);
var userStyle = Mec_FiexdUndefinedVal(this.mecJson["userStyle"]);
var className = "";
if(userStyle == "2"){
className = "userAvatarContainer2";
}
htmTemplate = htmTemplate.replace("${class2}", className);
return htmTemplate;
};
/*页面上显示控件完成后调用此方法,主要用于一些必须要使用js对页面进行后置操作时,无需要此方法可至空。 不必需的方法,有此方法系统自动调用*/
MEC_NS.UserAvatar.prototype.afterDesignHtmlBuild = function(){
var theId = this.id;
var p = this.mecJson;
var userType = p["userType"];
var userParam = Mec_FiexdUndefinedVal(p["userParam"]);
var url = jionActionUrl("com.weaver.formmodel.mobile.mec.servlet.MECAdminAction", "action=getUserAvatar&userType="+userType+"&userParam="+userParam);
$.post(url, null, function(responseText){
var jObj = $.parseJSON(responseText);
var status = jObj["status"];
if(status == "1"){
var data = jObj["data"];
var userName = data["userName"];
var deptName = data["deptName"];
var jobTitlesName = data["jobTitlesName"];
var messagerUrls = data["messagerUrls"];
var $userAvatar = $("#NMEC_" + theId);
$(".avatarInfo > img", $userAvatar).attr("src", messagerUrls);
$(".userName", $userAvatar).html(userName);
$(".deptName", $userAvatar).html(deptName);
$(".jobtitleName", $userAvatar).html(jobTitlesName);
}else{
alert(SystemEnv.getHtmlNoteName(4364)); //系统异常,获取用户信息失败
}
});
};
/*获取构建属性编辑窗体的html,添加和单击控件后会调用此方法,由此方法去构建属性编辑窗体。 必需的方法*/
MEC_NS.UserAvatar.prototype.getAttrDlgHtml = function(){
var styleL = "_style" + _userLanguage;
var theId = this.id;
var htm = "<div id=\"MADUA_"+theId+"\">"
htm += "<div class=\"MADUA_Title\">"+SystemEnv.getHtmlNoteName(4365)+"</div>"; //用户头像
htm += "<div class=\"MADUA_Content\">" +
"<div class=\"MADUA_BaseInfo_Entry\">"
+ "<span class=\"MADUA_BaseInfo_Entry_Label\">"+SystemEnv.getHtmlNoteName(4366)+"</span>" //用户来源:
+ "<span class=\"MADUA_BaseInfo_Entry_Content\">"
+ "<span class=\"cbboxEntry cbboxEntry1 cbboxEntry1"+styleL+"\">"
+ "<input type=\"checkbox\" name=\"userType_"+theId+"\" value=\"1\" onclick=\"MADUA_ChangeUserType(this, '"+theId+"');\"/><span class=\"cbboxLabel\">"+SystemEnv.getHtmlNoteName(4367)+"</span>" //当前用户
+ "</span>"
+ "<span class=\"cbboxEntry cbboxEntry2 cbboxEntry2"+styleL+"\">"
+ "<input type=\"checkbox\" name=\"userType_"+theId+"\" value=\"2\" onclick=\"MADUA_ChangeUserType(this, '"+theId+"');\"/><span class=\"cbboxLabel\">"+SystemEnv.getHtmlNoteName(4281)+"</span>" //获取参数
+ "<span style=\"margin-left: 8px;position: absolute;top:-3px;\"><input type=\"text\" id=\"userParam_"+theId+"\" class=\"MADUA_Text\" placeholder=\""+SystemEnv.getHtmlNoteName(4593)+"\"/></span>" //参数名称,如:userid
+ "</span>"
+ "</span>"
+ "</div>"
+ "<div class=\"MADUA_BaseInfo_Entry\">"
+ "<span class=\"MADUA_BaseInfo_Entry_Label\">"+SystemEnv.getHtmlNoteName(4369)+"</span>" //样式:
+ "</div>"
+ "<div class=\"MADUA_BaseInfo_Entry\">"
+ "<span class=\"MADUA_BaseInfo_Entry_Content\">"
+"<div width=\"300px;\">"
+"<div class=\"userAvatarContainers\" onclick=\"MADUA_ChangeUserStyle('"+theId+"',1);\">"
+"<img src=\"/mobilemode/images/template/userAvatar1_wev8.png\">"
+"<div class=\"selectUserStyle\"></div>"
+"</div>"
+"<div class=\"userAvatarContainers userAvatarContainers2\" onclick=\"MADUA_ChangeUserStyle('"+theId+"',2);\">"
+"<img src=\"/mobilemode/images/template/userAvatar2_wev8.png\">"
+"<div class=\"selectUserStyle\"></div>"
+"</div>"
+"<input type=\"hidden\" id=\"userStyle_"+theId+"\" value=\"\" />"
+"</div>"
+ "</span>"
+ "</div>"
+"</div>";
htm += "<div style=\"clear:both;\"></div>";
htm += "<div class=\"MADUA_Bottom\"><div class=\"MADUA_SaveBtn\" onclick=\"refreshMecDesign('"+theId+"');\">"+SystemEnv.getHtmlNoteName(3451)+"</div></div>"; //确定
htm += "</div>";
htm += "<div class=\"MAD_Alert\">"+SystemEnv.getHtmlNoteName(4115)+"</div>"; //已生成到布局
return htm;
};
/*构建属性编辑窗体完成后调用此方法,主要用于一些必须要使用js对页面进行后置操作时,无需要此方法可至空。 不必需的方法,有此方法系统自动调用*/
MEC_NS.UserAvatar.prototype.afterAttrDlgBuild = function(){
var theId = this.id;
var userTypeV = this.mecJson["userType"];
var $userType = $("input[type='checkbox'][name='userType_"+theId+"'][value='"+userTypeV+"']");
if($userType.length > 0){
$userType.attr("checked", "checked");
$userType.triggerHandler("click");
}
var $userStyle = Mec_FiexdUndefinedVal(this.mecJson["userStyle"]);
MADUA_ChangeUserStyle(theId,$userStyle);
$("#userParam_"+theId).val(Mec_FiexdUndefinedVal(this.mecJson["userParam"]));
$("#MADUA_"+theId).jNice();
};
/*获取JSON*/
MEC_NS.UserAvatar.prototype.getMecJson = function(){
var theId = this.id;
this.mecJson["id"] = theId;
this.mecJson["mectype"] = this.type;
var $attrContainer = $("#MAD_"+theId);
if($attrContainer.length > 0){
this.mecJson["userType"] = $("input[type='checkbox'][name='userType_"+theId+"']:checked").val();
this.mecJson["userParam"] = $("#userParam_"+theId).val();
this.mecJson["userStyle"] = $("#userStyle_"+theId).val();
}
return this.mecJson;
};
MEC_NS.UserAvatar.prototype.getDefaultMecJson = function(){
var theId = this.id;
var defMecJson = {};
defMecJson["id"] = theId;
defMecJson["mectype"] = this.type;
defMecJson["userType"] = "1"; //用户来源
defMecJson["userStyle"] = "1"; //用户样式
return defMecJson;
};
function MADUA_ChangeUserType(cbObj, mec_id){
setTimeout(function(){ //checkbox用了插件,不延时checkbox的checked状态获取不准确
var objV = cbObj.value;
if(!cbObj.checked){
changeCheckboxStatus(cbObj, true);
return;
}else{
$("input[type='checkbox'][name='userType_"+mec_id+"']").each(function(){
if(this.value != objV){
changeCheckboxStatus(this, false);
}
});
}
if(objV == "2"){
$("#userParam_" + mec_id).show();
}else{
$("#userParam_" + mec_id).hide();
}
},100);
}
function MADUA_ChangeUserStyle(mec_id,userStyleVal){
if(userStyleVal == ""){
userStyleVal = "1";
}
$("#userStyle_"+mec_id).val(userStyleVal);
var $attrContainer = $("#MAD_"+mec_id);
if(userStyleVal == "1"){
$(".selectUserStyle", $attrContainer).eq(0).removeClass("controlUserStyle");
$(".userAvatarContainers", $attrContainer).eq(0).addClass("selectUserStyle2");
$(".selectUserStyle", $attrContainer).eq(1).addClass("controlUserStyle");
$(".userAvatarContainers", $attrContainer).eq(1).removeClass("selectUserStyle2");
}else{
$(".selectUserStyle", $attrContainer).eq(0).addClass("controlUserStyle");
$(".userAvatarContainers", $attrContainer).eq(0).removeClass("selectUserStyle2");
$(".userAvatarContainers", $attrContainer).eq(1).addClass("selectUserStyle2");
$(".selectUserStyle", $attrContainer).eq(1).removeClass("controlUserStyle");
}
}