workList.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination'
  4. ]);
  5. app.controller("listCtrl", ["$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. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  12. self.get_type = sp.getUrlName("type");
  13. var postCfg = {
  14. headers: {
  15. 'Content-Type': 'application/json',
  16. 'Authorization': "Bearer " + self.get_AccessToken
  17. }
  18. }
  19. self.type = self.get_type != "" ? self.get_type : "1";
  20. self.loading = false;
  21. self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
  22. self.pageno = 1;
  23. self.total_count = 0;
  24. self.itemsPerPage = 10;
  25. self.pageOptions = [10, 20, 30, 40];
  26. self.getData = function (pageno) {
  27. self.list = [];
  28. self.loading = false;
  29. self.pageno = pageno;
  30. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  31. var data = {
  32. tablename: "SX_ZHIBANGZRZ",
  33. pagesize: self.itemsPerPage,
  34. pageno: self.pageno,
  35. colums: "*,TO_CHAR(GLRQ,'yyyy-mm-dd')as GLRQ1",
  36. order: "ID",
  37. sqlwhere: "",
  38. sqlorwhere: "",
  39. sqlinwhere: "",
  40. sqllikewhere: ""
  41. };
  42. $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  43. .success(function (obj) {
  44. var res = strToJson(s4.decryptData_CBC(obj.data));
  45. self.loading = false;
  46. if (res.data == null || res.data == undefined || res.data == "") {
  47. self.noDataTip = 0;
  48. } else {
  49. self.noDataTip = 1;
  50. self.list = res.data;
  51. self.total_count = res.totalCount;
  52. }
  53. })
  54. }
  55. self.load = function () {
  56. if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
  57. self.getData(self.pageno);
  58. } else {
  59. $timeout(function () {
  60. self.getData(self.get_lastReturnPageno);
  61. }, 1)
  62. }
  63. }
  64. self.load()
  65. self.btnAdd = function () {
  66. sp.openNewWindow("workRecord.html?id=0&lastReturnPageno=1")
  67. }
  68. self.btnEdit = function (id) {
  69. sp.openNewWindow("workRecord.html?id=" + id + "&lastReturnPageno=" + self.pageno)
  70. //window.location.href = "workRecord.html?id=" + id + "&lastReturnPageno=" + self.pageno;
  71. }
  72. self.btnRead = function (id) {
  73. sp.openNewWindow("workRecord.html?id=" + id + "&read=1&lastReturnPageno=" + self.pageno)
  74. //window.location.href = "workRecord.html?id=" + id + "&read=1&lastReturnPageno=" + self.pageno;
  75. }
  76. self.btnDel = function (id) {
  77. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  78. var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
  79. 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>";
  80. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  81. sp.openCenter(".sp-dialog");
  82. ///取消按钮
  83. $('.sp-closeDialog').click(function (event) {
  84. sp.closeCenter(".sp-dialog");
  85. event.preventDefault();
  86. event.stopPropagation();
  87. });
  88. //post消息的id
  89. $("#delDataTrue").click(function () {
  90. var data = {
  91. tablename: "SX_ZHIBANGZRZ",
  92. id: id
  93. };
  94. $http.post(apiurljs.login + "g2app/dataabase/delDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  95. .success(function (obj) {
  96. var res = strToJson(s4.decryptData_CBC(obj.data));
  97. sp.dialoghide();
  98. if (res.success) {
  99. self.getData(self.pageno);
  100. } else {
  101. sp.dialog("删除失败,请联系管理员!");
  102. }
  103. });
  104. });
  105. }
  106. }])