Users.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. 'use strict';
  2. var app = angular.module('app', [
  3. ]);
  4. app.controller("UsersCtrl", ["$scope", "$http", "$interval", "$timeout", function ($scope, $http, $interval, $timeout) {
  5. var self = this;
  6. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  7. var postCfg = {
  8. headers: {
  9. 'Content-Type': 'application/json',
  10. 'Authorization': "Bearer " + self.get_AccessToken
  11. }
  12. }
  13. self.getStatus = function () {
  14. var data = {
  15. tablename: "SYS_DATAUSER",
  16. colums: "UINPUTNAME,UKIND",
  17. order: "UINPUTNAME",
  18. sqlwhere: { UINPUTNAME: "administrator" },
  19. sqlinwhere: "",
  20. sqllikewhere: ""
  21. }
  22. $http.post(apiurljs.login + "g2app/DangJian/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  23. .success(function (obj) {
  24. var res = strToJson(s4.decryptData_CBC(obj.data));
  25. self.usersFlag = res.data[0].UKIND == "禁用";//administrator禁用时表示三员开启
  26. })
  27. }
  28. self.getStatus()
  29. self.btnSubmit = function () {
  30. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  31. var dialogBody = "<div class=\"sp-dialog-body\">开启后将退出系统并启用三员管理,您确认要开启吗?</div>";
  32. var dialogFoot = "<div class=\"sp-dialog-foot\"><input id='DataTrue' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
  33. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  34. sp.openCenter(".sp-dialog");
  35. ///取消按钮
  36. $('.sp-closeDialog').click(function (event) {
  37. sp.closeCenter(".sp-dialog");
  38. event.preventDefault();
  39. event.stopPropagation();
  40. $timeout(function () {
  41. self.usersFlag = !self.usersFlag;
  42. }, 1)
  43. });
  44. //post消息的id
  45. $("#DataTrue").click(function () {
  46. self.users = {
  47. username1: "administrator",
  48. UKIND1: UKIND(!self.usersFlag),
  49. username2: "sysadm",
  50. UKIND2: UKIND(self.usersFlag),
  51. username3: "secadm",
  52. UKIND3: UKIND(self.usersFlag),
  53. username4: "auditadm",
  54. UKIND4: UKIND(self.usersFlag)
  55. }
  56. var data = {
  57. entity: "SYS_DATAUSER",
  58. data: [{ UKIND: self.users.UKIND1 }, { UKIND: self.users.UKIND2 }, { UKIND: self.users.UKIND3 }, { UKIND: self.users.UKIND4 }],
  59. setwhere: [{ UINPUTNAME: self.users.username1 }, { UINPUTNAME: self.users.username2 }, { UINPUTNAME: self.users.username3 }, { UINPUTNAME: self.users.username4 }]
  60. }
  61. $http.post(apiurljs.login + "g2app/Data/UpdataByWhereList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  62. .success(function (obj) {
  63. var res = strToJson(s4.decryptData_CBC(obj.data));
  64. if (res.success) {
  65. self.getStatus();
  66. var time = 3;
  67. dialog(time + "秒后将退出系统!")
  68. $interval(function () {
  69. if (time > 1) {
  70. time--;
  71. dialog(time + "秒后将退出系统!")
  72. } else {
  73. btnLoginOut()
  74. }
  75. }, 1000)
  76. }
  77. else {
  78. sp.dialog(res.message);
  79. }
  80. })
  81. })
  82. }
  83. }])
  84. function UKIND(str) {
  85. return str == true ? "正常" : "禁用";
  86. }
  87. function btnLoginOut() {
  88. $.ajax({
  89. url: apiurljs.login + "g2app/DangJian/insertFormData",
  90. type: "post",
  91. dataType: "json",
  92. contentType: "application/json",
  93. headers: { Authorization: "Bearer " + localStorage.getItem("GlWorkPlatform-AccessToken") }, ////请求头headers
  94. data: JSON.stringify({
  95. data: s4.encryptData_CBC(JSON.stringify({
  96. tablename: "LOGIN_STATISTICS_TAB",
  97. data: {
  98. USERID: $.cookie("GlWorkPlatform-userid"),
  99. USHOWNAME: decodeURI($.cookie("GlWorkPlatform-chineseName")),
  100. UINPUTNAME: $.cookie("GlWorkPlatform-username"),
  101. OPERATIONTIME: sp.getLocalDate(),
  102. ONLINEMARK: "out"
  103. }
  104. }))
  105. })
  106. })
  107. setTimeout(function () {
  108. window.parent.location.href = "../../login.html";
  109. $.cookie("GlWorkPlatform-userid", null, { path: '/', expires: -1 });
  110. $.cookie("GlWorkPlatform-username", null, { path: '/', expires: -1 });
  111. $.cookie("GlWorkPlatform-chineseName", null, { path: '/', expires: -1 });
  112. $.cookie("GlWorkPlatform-photo", null, { path: '/', expires: -1 });
  113. sessionStorage.removeItem("GlWorkPlatform-LoginFrom");
  114. localStorage.removeItem("GlWorkPlatform-openfileArray"); ////清空保存菜单文件的变量
  115. localStorage.removeItem("GlWorkPlatform-setLeftBarClickID");
  116. }, 500)
  117. };
  118. function dialog(str) {
  119. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span></span>";
  120. var dialogBody = "<div class=\"sp-dialog-body\">" + str + "</div>";
  121. $('.sp-dialog').html(dialogHead + dialogBody)
  122. sp.openDLTX(".sp-dialog")
  123. }