indexManage.js 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination',
  4. ]);
  5. app.controller("indexCtrl", ["$scope", "$http", "$timeout", function ($scope, $http, $timeout) {
  6. var self = this;
  7. var s4 = new SM4Util();
  8. self.userId = $.cookie("GlWorkPlatform-userid");
  9. self.userName = $.cookie("GlWorkPlatform-chineseName");
  10. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  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.getLeftTree = function () {
  19. var data = {
  20. tablename: "CODE_XXML"
  21. }
  22. $http.post(apiurljs.login + "g2app/dataabase/getTreeListAllByTablename", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  23. .success(function (obj) {
  24. var res = strToJson(s4.decryptData_CBC(obj.data));
  25. self.leftTree = res.data;
  26. })
  27. }
  28. self.getLeftTree();
  29. self.addNode = function () {
  30. self.add = {
  31. "tablename": "CODE_XXML",
  32. "PARENT_CNAME": "中心组",
  33. "code": "P01",
  34. "levels": "1",
  35. "cname": "",
  36. "userid": self.userId
  37. }
  38. sp.layer('#layer_box_add')
  39. }
  40. ///修改菜单
  41. self.editNode = function (obj) {
  42. self.edit = {
  43. "id": obj.ID,
  44. "tablename": "CODE_XXML",
  45. "cname": obj.CNAME,
  46. "userid": self.userId
  47. }
  48. sp.layer('#layer_box_edit');
  49. };
  50. self.btnSaveNode = function (n) {
  51. if (n == 1) {
  52. var data = {
  53. "tablename": self.add.tablename,
  54. "code": self.add.code,
  55. "levels": self.add.levels,
  56. "cname": self.add.cname,
  57. "userid": self.add.userid
  58. }
  59. $http.post(apiurljs.login + "g2app/dataabase/TreeAdd", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  60. .success(function (obj) {
  61. var res = strToJson(s4.decryptData_CBC(obj.data));
  62. if (res.success) {
  63. sp.layerhide();
  64. self.getLeftTree();
  65. } else {
  66. sp.layerhide();
  67. sp.dialog(res.message);
  68. }
  69. })
  70. } else {
  71. var data = {
  72. "id": self.edit.id,
  73. "tablename": self.edit.tablename,
  74. "setwhere": {
  75. "CNAME": self.edit.cname
  76. }
  77. }
  78. $http.post(apiurljs.login + "g2app/dataabase/setColumnsById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  79. .success(function (obj) {
  80. var res = strToJson(s4.decryptData_CBC(obj.data));
  81. if (res.success) {
  82. sp.layerhide();
  83. self.getLeftTree();
  84. } else {
  85. sp.layerhide();
  86. sp.dialog(res.message);
  87. }
  88. })
  89. }
  90. }
  91. self.deleteNode = function (obj) {
  92. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  93. var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
  94. var dialogFoot = "<div class=\"sp-dialog-foot\"><input id='delDataTrue' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
  95. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  96. sp.openCenter(".sp-dialog");
  97. ///取消按钮
  98. $('.sp-closeDialog').click(function (event) {
  99. sp.closeCenter(".sp-dialog");
  100. event.preventDefault(); event.stopPropagation();
  101. });
  102. //post消息的id
  103. $("#delDataTrue").click(function () {
  104. sp.dialoghide();
  105. //var postData = {
  106. // id: obj.ID,
  107. // tablename: "CODE_XXML",
  108. // parentid: obj.PARENTID
  109. //}
  110. //$http.post(apiurljs.login + "g2app/dataabase/delNode", { data: s4.encryptData_CBC(JSON.stringify(postData)) }, postCfg)
  111. var postData = {
  112. id: obj.ID,
  113. tablename: "CODE_XXML",
  114. data: {
  115. USEMARK: 0
  116. }
  117. }
  118. $http.post(apiurljs.login + "g2app/dataabase/upFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  119. .success(function (obj) {
  120. var res = strToJson(s4.decryptData_CBC(obj.data));
  121. if (res.success) {
  122. self.getLeftTree();
  123. } else {
  124. sp.dialog(res.message);
  125. }
  126. });
  127. });
  128. }
  129. self.repeatNode = function (obj) {
  130. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  131. var dialogBody = "<div class=\"sp-dialog-body\">您确认要恢复吗?</div>";
  132. var dialogFoot = "<div class=\"sp-dialog-foot\"><input id='delDataTrue' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
  133. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  134. sp.openCenter(".sp-dialog");
  135. ///取消按钮
  136. $('.sp-closeDialog').click(function (event) {
  137. sp.closeCenter(".sp-dialog");
  138. event.preventDefault(); event.stopPropagation();
  139. });
  140. //post消息的id
  141. $("#delDataTrue").click(function () {
  142. sp.dialoghide();
  143. var postData = {
  144. id: obj.ID,
  145. tablename: "CODE_XXML",
  146. data: {
  147. USEMARK: 1
  148. }
  149. }
  150. $http.post(apiurljs.login + "g2app/dataabase/upFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  151. .success(function (obj) {
  152. var res = strToJson(s4.decryptData_CBC(obj.data));
  153. if (res.success) {
  154. self.getLeftTree();
  155. } else {
  156. sp.dialog(res.message);
  157. }
  158. });
  159. });
  160. }
  161. self.checkNode = function (obj) {
  162. obj.show = !obj.show;
  163. console.log(obj)
  164. }
  165. self.moveUp = function (obj,arr) {
  166. var x = obj, y;
  167. for (var i = 0; i < arr.length; i++) {
  168. if (arr[i].NODE == obj.NODE) {
  169. y = arr[i - 1];
  170. }
  171. } var data = {
  172. entity: "CODE_XXML",
  173. data: [{ SORTID: y.SORTID }, { SORTID: x.SORTID }],
  174. setwhere: [{ ID: x.ID }, { ID: y.ID }]
  175. }
  176. $http.post(apiurljs.login + "g2app/Data/UpdataByWhereList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  177. .success(function (obj) {
  178. var res = strToJson(s4.decryptData_CBC(obj.data));
  179. if (res.success == true) {
  180. self.getLeftTree();
  181. } else {
  182. sp.dialog(res.message);
  183. }
  184. })
  185. }
  186. }])