eliminate.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. var app = angular.module('app', ["angularUtils.directives.dirPagination"]);
  2. app.controller("formlistCtrl", ["$scope", "$http", "$compile", "$timeout", function ($scope, $http, $compile, $timeout) {
  3. var self = this;
  4. var s4 = new SM4Util();
  5. self.userId = $.cookie("GlWorkPlatform-userid");
  6. self.userName = $.cookie("GlWorkPlatform-username");
  7. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  8. self.get_leftActive = sp.getUrlName("leftActive");
  9. self.get_leftActiveType = sp.getUrlName("leftActiveType");
  10. $("#contentBox").height($("body").height() - 75);
  11. self.loading = false;
  12. self.btnGoBack = function () {
  13. ///返回上一级
  14. window.location.href = "formlist.html?leftActive=" + self.get_leftActive + "&leftActiveType=" + self.get_leftActiveType;
  15. };
  16. var postCfg = {
  17. headers: {
  18. 'Content-Type': 'application/json',
  19. 'Authorization': "Bearer " + self.get_AccessToken
  20. }
  21. };
  22. self.Eliminate = function () {
  23. self.loading = true;
  24. var time1 = sp.getLocalDate1();
  25. var data = {
  26. tablename: "SYS_FORM",
  27. sqlwhere: {
  28. CTYPE: "NORMAL"
  29. },
  30. sqlorwhere: {},
  31. sqlinwhere: {},
  32. sqllikewhere: {},
  33. colums: "*",
  34. order: "SORTID"
  35. };
  36. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  37. .success(function (obj) {
  38. self.loading = false;
  39. var res = strToJson(s4.decryptData_CBC(obj.data));
  40. self.eliminateList = res.data;
  41. self.EliminateAllChecked = false;
  42. self.eliminateList.forEach(function (item) {
  43. item.checked = false;
  44. })
  45. })
  46. }
  47. self.Eliminate()
  48. self.changeEliminate1 = function () {
  49. //self.EliminateAllChecked = !self.EliminateAllChecked;
  50. $.each(self.eliminateList, function (index, item) {
  51. item.checked = self.EliminateAllChecked
  52. })
  53. }
  54. self.changeEliminate2 = function (item) {
  55. item.checked = !item.checked;
  56. }
  57. self.btnEliminateTrue = function () {
  58. var ckeys = [];
  59. self.eliminateList.forEach(function (item) {
  60. if (item.checked == true) {
  61. ckeys.push(item.CKEY)
  62. }
  63. })
  64. if (ckeys.length == 0) {
  65. sp.dialog("请勾选需要清除的表单!");
  66. return;
  67. }
  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='delDataTrue' 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. ///取消按钮
  74. $('.sp-closeDialog').click(function (event) {
  75. sp.closeCenter(".sp-dialog");
  76. event.preventDefault();
  77. event.stopPropagation();
  78. });
  79. //post消息的id
  80. $("#delDataTrue").click(function () {
  81. sp.dialoghide();
  82. var data = {
  83. tablename: ckeys.join(",")
  84. }
  85. $http.post(apiurljs.login + "g2app/abase/deleteTabeData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  86. .success(function (obj) {
  87. var res = strToJson(s4.decryptData_CBC(obj.data));
  88. if (res.success) {
  89. self.Eliminate()
  90. } else {
  91. sp.dialog("删除失败,请联系管理员!")
  92. }
  93. })
  94. });
  95. }
  96. }])