init.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. 'use strict';
  2. var app = angular.module('app', []);
  3. app.controller("listCtrl", ["$scope", "$http", "$timeout", function ($scope, $http, $timeout) {
  4. var self = this;
  5. var s4 = new SM4Util();
  6. self.userId = $.cookie("GlWorkPlatform-userid");
  7. self.userName = $.cookie("GlWorkPlatform-chineseName");
  8. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  9. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  10. var postCfg = {
  11. headers: {
  12. 'Content-Type': 'application/json',
  13. 'Authorization': "Bearer " + self.get_AccessToken
  14. }
  15. }
  16. self.search = {
  17. FLOWNAME: ""
  18. }
  19. self.getData = function () {
  20. self.list = [];
  21. var data = {
  22. tablename: "DANGANFLOWMANAGE",
  23. colums: "*",
  24. order: "ID",
  25. sqlwhere:"",
  26. sqlorwhere: "",
  27. sqlinwhere: "",
  28. sqllikewhere: {
  29. FLOWNAME: self.search.FLOWNAME,
  30. }
  31. };
  32. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  33. .success(function (obj) {
  34. var res = strToJson(s4.decryptData_CBC(obj.data));
  35. self.list = res.data;
  36. })
  37. }
  38. self.getData()
  39. self.Edit = function (item) {
  40. self.edit = item;
  41. sp.layer("#Edit")
  42. }
  43. self.btnSave = function () {
  44. var data = {
  45. id: self.edit.ID,
  46. tablename: "DANGANFLOWMANAGE",
  47. data: {
  48. MOBANNAME: self.edit.MOBANNAME,
  49. PRINTTYPE: self.edit.PRINTTYPE
  50. }
  51. }
  52. $http.post(apiurljs.login + "g2app/DangJian/upFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  53. .success(function (obj) {
  54. var res = strToJson(s4.decryptData_CBC(obj.data));
  55. sp.layerhide()
  56. if (res.success) {
  57. self.getData()
  58. sp.dialog("保存成功!");
  59. $timeout(function () {
  60. sp.dialoghide()
  61. },1500)
  62. } else {
  63. sp.dialog(res.message)
  64. }
  65. });
  66. }
  67. self.Del = function (item) {
  68. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  69. var dialogBody = "<div class=\"sp-dialog-body\">您确认要删除此记录吗?</div>";
  70. var dialogFoot = "<div class=\"sp-dialog-foot\"><input id='upDataTrue' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
  71. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  72. sp.openCenter(".sp-dialog");
  73. $('.sp-closeDialog').click(function (event) {
  74. sp.dialoghide();
  75. event.preventDefault();
  76. event.stopPropagation();
  77. });
  78. $("#upDataTrue").click(function () {
  79. sp.dialoghide();
  80. var data = {
  81. tablename: "DANGANFLOWMANAGE",
  82. id: item.ID
  83. };
  84. $http.post(apiurljs.login + "g2app/dataabase/delDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  85. .success(function (obj) {
  86. var res = strToJson(s4.decryptData_CBC(obj.data));
  87. sp.dialoghide();
  88. if (res.success) {
  89. self.getData(self.pageno);
  90. } else {
  91. sp.dialog("删除失败,请联系管理员!");
  92. }
  93. });
  94. })
  95. }
  96. ///查询-打开弹出层
  97. self.openSearchLayer = function () {
  98. self.search = {
  99. FLOWNAME: ""
  100. }
  101. sp.layer("#search");
  102. }
  103. self.btnSearch = function () {
  104. self.getData(1);
  105. sp.layerhide()
  106. }
  107. self.closeSeach = function () {
  108. self.search = {
  109. DOCUMENTTYPE: "",
  110. FLOWNAME: ""
  111. }
  112. sp.layerhide();
  113. self.getData(1);
  114. };
  115. self.init = function () {
  116. var data = {
  117. unitid: "AA",
  118. arry: ['AA01', 'AA02']
  119. }
  120. $http.post(apiurljs.login + "g2app/DangAn/initFlowDataToDangAnManage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  121. .success(function (obj) {
  122. var res = strToJson(s4.decryptData_CBC(obj.data));
  123. if (res.success == true) {
  124. self.getData()
  125. } else {
  126. sp.dialog(res.message)
  127. }
  128. })
  129. }
  130. //头部下滚冻结
  131. $(function () {
  132. //页面高度撑满
  133. setTimeout(function () {
  134. if ($(".ibox-content").height() < $(window).height() - 31) {
  135. $(".ibox-content").css("height", $(window).height() - 31)
  136. }
  137. }, 1)
  138. })
  139. }])