structure.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. 
  2. /// <reference path="jquery-1.8.3.min.js" />
  3. function loadScript(url, callback) {
  4. var script = document.createElement_x("script");
  5. script.type = "text/javascript";
  6. if (script.readyState) { //IE
  7. script.onreadystatechange = function() {
  8. if (script.readyState == "loaded" ||
  9. script.readyState == "complete") {
  10. script.onreadystatechange = null;
  11. callback();
  12. }
  13. };
  14. } else { //Others: Firefox, Safari, Chrome, and Opera
  15. script.onload = function() {
  16. callback();
  17. };
  18. }
  19. script.src = url;
  20. document.body.appendChild(script);
  21. }
  22. function Structure(strJson, appElement) {
  23. this.keyWord = "";
  24. this.strJson = strJson;
  25. this.appElement = appElement;
  26. this.tarClientId = "";
  27. this.topic_id = "";
  28. this.cName = "";
  29. this.id = "";
  30. this.photoUri = "";
  31. this.sex = "";
  32. this.isGroup = false;
  33. }
  34. Structure.prototype.showUI = function (keyWord) {
  35. var _this = this;
  36. _this.keyWord = keyWord;
  37. if (keyWord && _this.keyWord.length) {
  38. } else {
  39. }
  40. var json = _this.strJson;
  41. if (json.Code == 10000) {
  42. _this.appElement.html("");
  43. if (json.Depart.length||json.Emp.length) {
  44. var parent = $('<ul class="im-user-tree"></ul>');
  45. showwall(json, parent, 0);
  46. _this.appElement.append(parent);
  47. //loadErrorImg();
  48. }
  49. }
  50. };
  51. function showwall(json, parent,index) {
  52. parent.html("");
  53. var ind=parseInt(index)+1;
  54. for (var menu = 0; menu < json.Depart.length; menu++) {
  55. var li = $("<li></li>");
  56. if (json.Depart[menu].OrgID) {
  57. li.html("<div class=\"tree-hd\"><a href=\"javascript:;\" title=\"" + json.Depart[menu].OrgName + "(" + json.Depart[menu].UserCount + ")" +"\" onclick=\"getTree('"+json.Depart[menu].OrgID+"',"+ind+");\"><i class=\"iconfont\">&#xe609;</i><span class=\"c-f14\">" + json.Depart[menu].OrgName + '(' + json.Depart[menu].UserCount + ')</span></a></div>').attr(
  58. {
  59. "data-id": json.Depart[menu].OrgID,
  60. "data-name": json.Depart[menu].OrgName,
  61. "data-type": "1"
  62. }).append("<ul id=SubDepart"+json.Depart[menu].OrgID+"></ul>").appendTo(parent);
  63. //showwall(structure_list[menu].structure_list, $(li).find("ul")[0], index + 1);
  64. }
  65. }
  66. for (var i = 0; i < json.Emp.length; i++) {
  67. var li = $("<li></li>");
  68. var photoUri = json.Emp[i].PhotoUri;
  69. var sex = json.Emp[i].Sex;
  70. if (photoUri && photoUri != "") {
  71. } else if (sex == 1) {
  72. photoUri = "images/face.png";
  73. } else if (sex == 0) {
  74. photoUri = "images/face.png";
  75. } else {
  76. photoUri = "images/face.png";
  77. }
  78. if(json.Emp[i].ImClientId&&json.Emp[i].ImClientId!=''){
  79. li.html("<div class=\"tree-bd\"><a href=\"javascript:;\" onclick=\"showMember('"+json.Emp[i].ImClientId+"');\"><div class=\"tree-bd-box c-position-r\" style=\"padding-left:"+ind*15+"px;\"><div class=\"tree-bd-face\"><img class=\"c-images-block\" src=\"" + photoUri + "\"/></div>"
  80. + '<div class=\"tree-bd-name c-nowrap c-f14 c-333\">' + json.Emp[i].CName + '</div></div></a>'
  81. + '</div>').attr({
  82. "data-id": json.Emp[i].ImClientId,
  83. "data-type": "2"
  84. }).appendTo(parent);
  85. memberInfos[json.Emp[i].ImClientId] = {
  86. "data-id": json.Emp[i].UserID,
  87. "data-name": json.Emp[i].CName,
  88. "data-clientId": json.Emp[i].ImClientId,
  89. "data-photoUri": json.Emp[i].PhotoUri,
  90. "data-sex": json.Emp[i].Sex
  91. };
  92. }
  93. }
  94. }
  95. function showMember(ImClientId) {
  96. if(clientId&&clientId!=''){
  97. showChat(ImClientId);
  98. }
  99. }
  100. function getTree(orgId,index) {
  101. $.ajax({
  102. url: "SubDepartAction/getSubDepart",
  103. dataType: "json",
  104. type: 'POST',
  105. data: { orgId: orgId },
  106. success: function(orgData) {
  107. if (orgData) {
  108. showwall(orgData, $("#SubDepart"+orgId),index);
  109. //$("#showLoading").hide();
  110. }
  111. },
  112. error: function(errorData) {
  113. }
  114. });
  115. }
  116. function showMsgChat(clientId, isGroup) {
  117. if(clientId&&clientId!=''){
  118. if (clientId == myInfo.clientId) {
  119. showMsg("不能和自己聊天!!!");
  120. $(".loading_box").hide();
  121. return false;
  122. }
  123. $("#talking_box").show();
  124. $('#iframe-im').show();
  125. $('#text_msg').focus();
  126. if (clientId != Structure.tarClientId) {
  127. var clickMsgCount = parseInt($("#newMsg_" + clientId).html());
  128. var memberInfo = memberInfos[clientId];
  129. Structure.tarClientId = memberInfo["data-clientId"];
  130. Structure.cName = memberInfo["data-name"];
  131. Structure.id = memberInfo["data-id"];
  132. Structure.isGroup = isGroup;
  133. Structure.photoUri = memberInfo["data-photoUri"];
  134. Structure.photoUri = Structure.photoUri == "" ? "images/face.png" : Structure.photoUri;
  135. Structure.sex = memberInfo["data-sex"];
  136. $(".section-header.clearfix > h4").html(Structure.cName);
  137. $("#talkingID").val(Structure.id);
  138. //$("#iframe-im").show();
  139. $(".sec-main-con").html("");
  140. $("#text_msg").val("");
  141. $("#clientId").val(Structure.tarClientId);
  142. if (clickMsgCount > 0) {
  143. $("#newMsg_" + clientId).html('0').hide();
  144. newMsgBodyCount -= 1;
  145. }
  146. sumUnreadCount();
  147. if (newMsgBodyCount <= 0) {
  148. newMsgBodyCount = 0;
  149. $("#im_count").hide();
  150. //$(".boss-user-number.c-position-a").remove();
  151. }
  152. if (isGroup) {
  153. $("#isGroup").val(1);
  154. anImClass.getTopicHistory(Structure.tarClientId, 10, "", myInfo.clientId);
  155. } else{
  156. $("#isGroup").val(0);
  157. anImClass.getHistory(Structure.tarClientId, myInfo.clientId, 10, "");
  158. }
  159. }
  160. }
  161. }