group.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. var _my_channal = null;
  2. var get_channel_list_callback = null;
  3. channal_list();
  4. function group_list_init() {
  5. if (typeof gGroupId == "undefined") {
  6. my_group_list();
  7. group_add_dlg_init("group_add_div");
  8. $("#button_new_group").show();
  9. } else {
  10. group_list(gGroupId, gList);
  11. team_add_dlg_init("sub_group_add_div");
  12. $("#member_list_shell").css("visibility", "visible");
  13. member_list(gGroupId);
  14. //初始化用户选择对话框
  15. user_select_dlg_init("user_select_div");
  16. }
  17. }
  18. function channal_list() {
  19. $.post("../channal/get.php", {}, function (data) {
  20. try {
  21. _my_channal = JSON.parse(data);
  22. if (get_channel_list_callback) {
  23. get_channel_list_callback();
  24. }
  25. } catch (e) {
  26. console.error(e);
  27. }
  28. });
  29. }
  30. function channal_getById(id) {
  31. for (const iterator of _my_channal) {
  32. if (iterator.id == id) {
  33. return iterator;
  34. }
  35. }
  36. return false;
  37. }
  38. function my_group_list() {
  39. $.get("../group/list.php", {}, function (data, status) {
  40. if (status == "success") {
  41. try {
  42. let html = "";
  43. let result = JSON.parse(data);
  44. let key = 1;
  45. if (result.length > 0) {
  46. for (const iterator of result) {
  47. html += '<div class="file_list_row" style="padding:5px;">';
  48. html += "<div style='flex:1;'>" + key++ + "</div>";
  49. html += "<div style='flex:2;'>" + iterator.group_name + "</div>";
  50. html += "<div style='flex:2;'>";
  51. switch (parseInt(iterator.power)) {
  52. case 0:
  53. html += gLocal.gui.owner;
  54. break;
  55. case 1:
  56. html += gLocal.gui.manager;
  57. break;
  58. case 2:
  59. html += gLocal.gui.member;
  60. break;
  61. default:
  62. break;
  63. }
  64. html += "</div>";
  65. html +=
  66. "<div style='flex:1;'><a href='../group/index.php?id=" +
  67. iterator.group_id +
  68. "'>" +
  69. gLocal.gui.enter +
  70. "</a></div>";
  71. html += "<div style='flex:1;'><div class='hover_button'>";
  72. if (parseInt(iterator.power) == 0) {
  73. //管理员可以删除group
  74. html +=
  75. "<button onclick=\"group_del('" +
  76. iterator.group_id +
  77. "')\">" +
  78. gLocal.gui.delete +
  79. "</button>";
  80. }
  81. html += "</div></div>";
  82. html += "</div>";
  83. }
  84. } else {
  85. html += "你没有加入任何工作组 现在 创建 你的工作组。";
  86. }
  87. $("#my_group_list").html(html);
  88. } catch (e) {
  89. console.error(e);
  90. }
  91. } else {
  92. console.error("ajex error");
  93. }
  94. });
  95. }
  96. function group_list(id, list) {
  97. $.get(
  98. "../group/get.php",
  99. {
  100. id: id,
  101. list: list,
  102. },
  103. function (data, status) {
  104. if (status == "success") {
  105. try {
  106. let html = "";
  107. let result = JSON.parse(data);
  108. let key = 1;
  109. html += "<div class='info_block'>";
  110. html += "<h2>" + gLocal.gui.introduction + "</h2>";
  111. html += result.info.description;
  112. html += "</div>";
  113. $("#curr_group").html("/" + result.info.name);
  114. if (result.parent) {
  115. //如果是project 显示 group名词
  116. $("#parent_group").html(
  117. " / <a href='../group/index.php?id=" +
  118. result.parent.id +
  119. "'>" +
  120. result.parent.name +
  121. "</a> "
  122. );
  123. } else {
  124. if (result.info.creator == getCookie("userid")) {
  125. $("#button_new_sub_group").show();
  126. }
  127. //子小组列表
  128. html += "<div class='info_block'>";
  129. html += "<h2>" + gLocal.gui.sub_group + "</h2>";
  130. if (result.children && result.children.length > 0) {
  131. for (const iterator of result.children) {
  132. html += '<div class="file_list_row" style="padding:5px;">';
  133. html += "<div style='flex:1;'>" + key++ + "</div>";
  134. html += "<div style='flex:2;'>" + iterator.name + "</div>";
  135. html += "<div style='flex:2;'>";
  136. if (iterator.creator == getCookie("userid")) {
  137. html += gLocal.gui.owner;
  138. }
  139. html += "</div>";
  140. html +=
  141. "<div style='flex:1;'><a href='../group/index.php?id=" +
  142. iterator.id +
  143. "&list=file'>" +
  144. gLocal.gui.enter +
  145. "</a></div>";
  146. html += "<div style='flex:1;'><div class='hover_button'>";
  147. if (iterator.creator == getCookie("userid")) {
  148. html +=
  149. "<button onclick=\"group_del('" +
  150. iterator.id +
  151. "')\">" +
  152. gLocal.gui.delete +
  153. "</button>";
  154. }
  155. html += "</div></div>";
  156. html += "</div>";
  157. }
  158. } else {
  159. html += "尚未设置小组";
  160. }
  161. html += "</div>";
  162. }
  163. //共享文件列表
  164. key = 1;
  165. html += "<div class='info_block'>";
  166. html += "<h2>" + gLocal.gui.collaborate + "</h2>";
  167. if (result.file && result.file.length > 0) {
  168. for (const iterator of result.file) {
  169. html += '<div class="file_list_row" style="padding:5px;">';
  170. html += "<div style='flex:1;'>" + key++ + "</div>";
  171. html += "<div style='flex:2;'>" + iterator.title + "</div>";
  172. html += "<div style='flex:2;'>";
  173. switch (iterator.power) {
  174. case 10:
  175. html += gLocal.gui.read_only;
  176. break;
  177. case 20:
  178. break;
  179. case 30:
  180. html += gLocal.gui.write;
  181. break;
  182. default:
  183. break;
  184. }
  185. html += "</div>";
  186. html +=
  187. "<div style='flex:1;'><a href='../studio/project.php?op=open&doc_id=" +
  188. iterator.doc_id +
  189. "'>打开</a></div>";
  190. html += "</div>";
  191. }
  192. } else {
  193. html += "没有共享文档 在译经楼中添加";
  194. }
  195. html += "</div>";
  196. $("#my_group_list").html(html);
  197. } catch (e) {
  198. console.error(e);
  199. }
  200. } else {
  201. console.error("ajex error");
  202. }
  203. }
  204. );
  205. }
  206. function member_list(id) {
  207. $.get(
  208. "../group/list_member.php",
  209. {
  210. id: id,
  211. },
  212. function (data, status) {
  213. if (status == "success") {
  214. try {
  215. let html = "";
  216. let result = JSON.parse(data);
  217. $("#member_number").html("(" + result.length + ")");
  218. //人员
  219. html += "<div class='info_block'>";
  220. if (result && result.length > 0) {
  221. for (const iterator of result) {
  222. html += '<div class="file_list_row" style="padding:5px;">';
  223. html += "<div style='flex:2;'>" + iterator.user_info.nickname + "</div>";
  224. html += "<div style='flex:2;'>";
  225. if (iterator.power == 1) {
  226. html += "拥有者";
  227. }
  228. html += "</div>";
  229. html += "<div style='flex:1;'><div class='hover_button'>";
  230. //if (iterator.creator == getCookie("userid"))
  231. {
  232. html +=
  233. "<button onclick=\"member_del('" +
  234. id +
  235. "','" +
  236. iterator.user_id +
  237. "')\">" +
  238. gLocal.gui.delete +
  239. "</button>";
  240. }
  241. html += "</div></div>";
  242. html += "</div>";
  243. }
  244. } else {
  245. html += "这是一个安静的地方";
  246. }
  247. html += "</div>";
  248. $("#member_list").html(html);
  249. } catch (e) {
  250. console.error(e);
  251. }
  252. } else {
  253. console.error("ajex error");
  254. }
  255. }
  256. );
  257. }
  258. function user_selected(id) {
  259. $.post(
  260. "../group/member_put.php",
  261. {
  262. userid: id,
  263. groupid: gGroupId,
  264. },
  265. function (data) {
  266. let error = JSON.parse(data);
  267. if (error.status == 0) {
  268. user_select_cancel();
  269. alert("ok");
  270. location.reload();
  271. } else {
  272. user_select_cancel();
  273. alert(error.message);
  274. }
  275. }
  276. );
  277. }
  278. function user_select_new() {
  279. $.post(
  280. "../group/my_group_put.php",
  281. {
  282. name: $("#user_select_title").val(),
  283. parent: parentid,
  284. },
  285. function (data) {
  286. let error = JSON.parse(data);
  287. if (error.status == 0) {
  288. alert("ok");
  289. user_select_cancel();
  290. location.reload();
  291. } else {
  292. alert(error.message);
  293. }
  294. }
  295. );
  296. }
  297. function group_del(group_id) {
  298. if (
  299. confirm(
  300. "此操作将删除组/项目。\n以及切断分享到此组/项目文件的链接。\n但是不会删除该文件。\n此操作不能恢复。仍然要删除吗!"
  301. )
  302. ) {
  303. $.post(
  304. "../group/group_del.php",
  305. {
  306. groupid: group_id,
  307. },
  308. function (data) {
  309. let error = JSON.parse(data);
  310. if (error.status == 0) {
  311. alert("ok");
  312. location.reload();
  313. } else {
  314. alert(error.message);
  315. }
  316. }
  317. );
  318. }
  319. }
  320. function member_del(group_id, user_id) {
  321. if (confirm("此操作将移除成员。\n此操作不能恢复。仍然要移除吗!")) {
  322. $.post(
  323. "../group/member_del.php",
  324. {
  325. groupid: group_id,
  326. userid: user_id,
  327. },
  328. function (data) {
  329. let error = JSON.parse(data);
  330. if (error.status == 0) {
  331. alert("ok");
  332. location.reload();
  333. } else {
  334. alert(error.message);
  335. }
  336. }
  337. );
  338. }
  339. }