personalData_tabletop.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. var app = angular.module('app', [
  2. ]);
  3. app.controller("personalDataTabletop", ["$scope", "$http", "$interval", "$timeout", function ($scope, $http, $interval, $timeout) {
  4. var self = this;
  5. var s4 = new SM4Util();
  6. self.userId = $.cookie("GlWorkPlatform-userid");
  7. self.userName = $.cookie("GlWorkPlatform-username");
  8. self.userCName = $.cookie("GlWorkPlatform-chineseName");
  9. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  10. self.userTypeEng = $.cookie("GlWorkPlatform-userTypeEng");
  11. var postCfg = {
  12. headers: {
  13. 'Content-Type': 'application/json',
  14. 'Authorization': "Bearer " + self.get_AccessToken
  15. }
  16. };
  17. self.CrossPage = window.parent.CrossPage;
  18. self.loading = false;
  19. ////加载用户的框架列表*******************************************************************************************
  20. self.imgColActive_code = "";
  21. self.frameArray = [];
  22. self.frameArray_active = {};
  23. self.ifHasDefault_frame = 0;
  24. self.getData_frame = function () {
  25. self.loading = true;
  26. var postData = { "userid": self.userId };
  27. //console.log(postData);
  28. //console.log(postData); s4.encryptData_CBC(JSON.stringify(postData))
  29. $http.post(apiurljs.login + "g2work/frame/queryDataUserByUserid", JSON.stringify(postData), postCfg)
  30. .success(function (obj) {
  31. //var res = strToJson(s4.decryptData_CBC(obj.data));
  32. var res = obj;
  33. //console.log(JSON.stringify(res));
  34. if (res.success) {
  35. self.loading = false;
  36. self.frameArray = res.data;
  37. angular.forEach(self.frameArray, function (item) {
  38. if (item.ISDEFAULT == "1") {
  39. self.ifHasDefault_frame = 1;
  40. self.imgColActive_code = item.CODE;
  41. self.frameArray_active = item;
  42. }
  43. });
  44. $timeout(function () {
  45. if (self.ifHasDefault_frame == 0) {
  46. self.frameArray_active = self.frameArray[0];
  47. self.imgColActive_code = self.frameArray[0].CODE;
  48. }
  49. },10)
  50. } else {
  51. self.loading = false;
  52. self.frameArray = [];
  53. }
  54. })
  55. .error(function (XMLHttpRequest, textStatus, errorThrown) {
  56. if (textStatus != 200) {
  57. self.loading = false;
  58. }
  59. })
  60. };
  61. self.getData_frame();
  62. self.btnModify_frame = function () {
  63. sp.layer("#layer_frame", 1);
  64. };
  65. self.submit_frame = function () {
  66. var postData = {
  67. "userid": self.userId,
  68. "code": self.imgColActive_code
  69. };
  70. //console.log(postData);
  71. //console.log(postData); s4.encryptData_CBC(JSON.stringify(postData))
  72. $http.post(apiurljs.login + "g2work/frame/updateDataUserDefault", JSON.stringify(postData), postCfg)
  73. .success(function (obj) {
  74. //var res = strToJson(s4.decryptData_CBC(obj.data));
  75. var res = obj;
  76. //console.log(JSON.stringify(res));
  77. if (res.success) {
  78. sp.closeCenter('.sp-layer');
  79. self.getData_frame();
  80. sp.dialog("框架修改成功,请重新登陆!");
  81. $timeout(function () {
  82. //top.window.location.reload();
  83. top.location.href = "../../login.html";
  84. $.cookie("GlWorkPlatform-userid", null, { path: '/', expires: -1 });
  85. $.cookie("GlWorkPlatform-chineseName", null, { path: '/', expires: -1 });
  86. $.cookie("GlWorkPlatform-username", null, { path: '/', expires: -1 });
  87. sessionStorage.removeItem("GlWorkPlatform-LoginFrom");
  88. localStorage.removeItem("GlWorkPlatform-openfileArray"); ////清空保存菜单文件的变量
  89. localStorage.removeItem("GlWorkPlatform-setLeftBarClickID");
  90. localStorage.removeItem("GlWorkPlatform-AccessToken");
  91. localStorage.removeItem("GlWorkPlatform-userInfoJsonStr");
  92. }, 1000);
  93. } else {
  94. sp.closeCenter('.sp-layer');
  95. sp.dialog(res.message);
  96. }
  97. })
  98. .error(function (XMLHttpRequest, textStatus, errorThrown) {
  99. if (textStatus != 200) {
  100. self.loading = false;
  101. }
  102. })
  103. }
  104. self.cancel_frame = function () {
  105. sp.closeCenter('#layer_frame');
  106. }
  107. self.frame_imgColClick = function (itemdata) {
  108. self.imgColActive_code = itemdata.CODE;
  109. }
  110. ////加载用户的框架列表*******************************************************************************************
  111. ////加载用户的桌面列表*******************************************************************************************
  112. self.imgColActive_code_desktop = "";
  113. self.desktopArray = [];
  114. self.desktopArray_active = {};
  115. self.ifHasDefault_desktop = 0;
  116. self.getData_desktop = function () {
  117. self.loading = true;
  118. var postData = { "userid": self.userId };
  119. //console.log(postData);
  120. //console.log(postData); s4.encryptData_CBC(JSON.stringify(postData))
  121. $http.post(apiurljs.login + "g2work/desktop/queryDataUserByUserid", JSON.stringify(postData), postCfg)
  122. .success(function (obj) {
  123. //var res = strToJson(s4.decryptData_CBC(obj.data));
  124. var res = obj;
  125. //console.log(JSON.stringify(res));
  126. if (res.success) {
  127. self.loading = false;
  128. self.desktopArray = res.data;
  129. angular.forEach(self.desktopArray, function (item) {
  130. if (item.ISDEFAULT == "1") {
  131. self.ifHasDefault_desktop = 1;
  132. self.imgColActive_code_desktop = item.CODE;
  133. self.desktopArray_active = item;
  134. }
  135. });
  136. $timeout(function () {
  137. if (self.ifHasDefault_desktop == 0) {
  138. self.desktopArray_active = self.desktopArray[0];
  139. self.imgColActive_code_desktop = self.desktopArray[0].CODE;
  140. }
  141. }, 10)
  142. } else {
  143. self.loading = false;
  144. self.desktopArray = [];
  145. self.desktopArray_active = {};
  146. }
  147. })
  148. .error(function (XMLHttpRequest, textStatus, errorThrown) {
  149. if (textStatus != 200) {
  150. self.loading = false;
  151. }
  152. })
  153. };
  154. self.getData_desktop();
  155. self.btnModify_desktop = function () {
  156. sp.layer("#layer_desktop", 1);
  157. };
  158. self.submit_desktop = function () {
  159. var postData = {
  160. "userid": self.userId,
  161. "code": self.imgColActive_code_desktop
  162. };
  163. //console.log(postData);
  164. //console.log(postData); s4.encryptData_CBC(JSON.stringify(postData))
  165. $http.post(apiurljs.login + "g2work/desktop/updateDataUserDefault", JSON.stringify(postData), postCfg)
  166. .success(function (obj) {
  167. //var res = strToJson(s4.decryptData_CBC(obj.data));
  168. var res = obj;
  169. //console.log(JSON.stringify(res));
  170. if (res.success) {
  171. sp.closeCenter('.sp-layer');
  172. self.getData_desktop();
  173. //sp.dialog("桌面修改成功!");
  174. $timeout(function () {
  175. top.window.location.reload();
  176. //top.location.href = "../../login.html";
  177. //$.cookie("GlWorkPlatform-userid", null, { path: '/', expires: -1 });
  178. //$.cookie("GlWorkPlatform-chineseName", null, { path: '/', expires: -1 });
  179. //$.cookie("GlWorkPlatform-username", null, { path: '/', expires: -1 });
  180. //sessionStorage.removeItem("GlWorkPlatform-LoginFrom");
  181. //localStorage.removeItem("GlWorkPlatform-openfileArray"); ////清空保存菜单文件的变量
  182. //localStorage.removeItem("GlWorkPlatform-setLeftBarClickID");
  183. //localStorage.removeItem("GlWorkPlatform-AccessToken");
  184. //localStorage.removeItem("GlWorkPlatform-userInfoJsonStr");
  185. }, 10);
  186. } else {
  187. sp.closeCenter('.sp-layer');
  188. sp.dialog(res.message);
  189. }
  190. })
  191. .error(function (XMLHttpRequest, textStatus, errorThrown) {
  192. if (textStatus != 200) {
  193. self.loading = false;
  194. }
  195. })
  196. };
  197. self.cancel_desktop = function () {
  198. sp.closeCenter('#layer_desktop');
  199. };
  200. self.desktop_imgColClick = function (itemdata) {
  201. self.imgColActive_code_desktop = itemdata.CODE;
  202. }
  203. ////加载用户的桌面列表*******************************************************************************************
  204. ////加载背景图片*******************************************************************************************
  205. self.imgColActive_code_bkimage = "";
  206. self.bkimageArray = [];
  207. self.bkimageArray_active = {};
  208. self.ifHasDefault_bkimage = 0;
  209. self.getData_bkimage = function () {
  210. self.loading = true;
  211. var postData = { "userid": self.userId };
  212. //console.log(postData);
  213. //console.log(postData); s4.encryptData_CBC(JSON.stringify(postData))
  214. $http.post(apiurljs.login + "g2work/bkimage/queryDataUserByUserid", JSON.stringify(postData), postCfg)
  215. .success(function (obj) {
  216. //var res = strToJson(s4.decryptData_CBC(obj.data));
  217. var res = obj;
  218. //console.log(JSON.stringify(res));
  219. if (res.success) {
  220. self.loading = false;
  221. self.bkimageArray = res.data;
  222. angular.forEach(self.bkimageArray, function (item) {
  223. if (item.ISDEFAULT == "1") {
  224. self.ifHasDefault_bkimage = 1;
  225. self.imgColActive_code_bkimage = item.CODE;
  226. self.bkimageArray_active = item;
  227. }
  228. });
  229. $timeout(function () {
  230. if (self.ifHasDefault_bkimage == 0) {
  231. self.bkimageArray_active = self.bkimageArray[0];
  232. self.imgColActive_code_bkimage = self.bkimageArray[0].CODE;
  233. }
  234. }, 10);
  235. } else {
  236. self.loading = false;
  237. self.bkimageArray = [];
  238. self.bkimageArray_active = {};
  239. }
  240. })
  241. .error(function (XMLHttpRequest, textStatus, errorThrown) {
  242. if (textStatus != 200) {
  243. self.loading = false;
  244. }
  245. })
  246. };
  247. self.getData_bkimage();
  248. self.btnModify_bkimage = function () {
  249. sp.layer("#layer_bkimage", 1);
  250. }
  251. self.submit_bkimage = function () {
  252. var postData = {
  253. "userid": self.userId,
  254. "code": self.imgColActive_code_bkimage
  255. };
  256. //console.log(postData);
  257. //console.log(postData); s4.encryptData_CBC(JSON.stringify(postData))
  258. $http.post(apiurljs.login + "g2work/bkimage/updateDataUserDefault", JSON.stringify(postData), postCfg)
  259. .success(function (obj) {
  260. //var res = strToJson(s4.decryptData_CBC(obj.data));
  261. var res = obj;
  262. //console.log(JSON.stringify(res));
  263. if (res.success) {
  264. sp.closeCenter('.sp-layer');
  265. self.getData_bkimage();
  266. //sp.dialog("背景图片修改成功!");
  267. $timeout(function () {
  268. top.window.location.reload();
  269. //top.location.href = "../../login.html";
  270. //$.cookie("GlWorkPlatform-userid", null, { path: '/', expires: -1 });
  271. //$.cookie("GlWorkPlatform-chineseName", null, { path: '/', expires: -1 });
  272. //$.cookie("GlWorkPlatform-username", null, { path: '/', expires: -1 });
  273. //sessionStorage.removeItem("GlWorkPlatform-LoginFrom");
  274. //localStorage.removeItem("GlWorkPlatform-openfileArray"); ////清空保存菜单文件的变量
  275. //localStorage.removeItem("GlWorkPlatform-setLeftBarClickID");
  276. //localStorage.removeItem("GlWorkPlatform-AccessToken");
  277. //localStorage.removeItem("GlWorkPlatform-userInfoJsonStr");
  278. }, 10);
  279. } else {
  280. sp.closeCenter('.sp-layer');
  281. sp.dialog(res.message);
  282. }
  283. })
  284. .error(function (XMLHttpRequest, textStatus, errorThrown) {
  285. if (textStatus != 200) {
  286. self.loading = false;
  287. }
  288. })
  289. }
  290. self.cancel_bkimage = function () {
  291. sp.closeCenter('#layer_bkimage');
  292. }
  293. self.bkimage_imgColClick = function (itemdata) {
  294. self.imgColActive_code_bkimage = itemdata.CODE;
  295. }
  296. ////加载背景图片*******************************************************************************************
  297. }]);