123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- 'use strict';
- var app = angular.module('app', [
- ]);
- app.controller("UsersCtrl", ["$scope", "$http", "$interval", "$timeout", function ($scope, $http, $interval, $timeout) {
- var self = this;
- self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- }
- self.getStatus = function () {
- var data = {
- tablename: "SYS_DATAUSER",
- colums: "UINPUTNAME,UKIND",
- order: "UINPUTNAME",
- sqlwhere: { UINPUTNAME: "administrator" },
- sqlinwhere: "",
- sqllikewhere: ""
- }
- $http.post(apiurljs.login + "g2app/DangJian/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.usersFlag = res.data[0].UKIND == "禁用";//administrator禁用时表示三员开启
- })
- }
- self.getStatus()
- self.btnSubmit = function () {
- var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
- var dialogBody = "<div class=\"sp-dialog-body\">开启后将退出系统并启用三员管理,您确认要开启吗?</div>";
- 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>";
- $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
- sp.openCenter(".sp-dialog");
- ///取消按钮
- $('.sp-closeDialog').click(function (event) {
- sp.closeCenter(".sp-dialog");
- event.preventDefault();
- event.stopPropagation();
- $timeout(function () {
- self.usersFlag = !self.usersFlag;
- }, 1)
- });
- //post消息的id
- $("#DataTrue").click(function () {
- self.users = {
- username1: "administrator",
- UKIND1: UKIND(!self.usersFlag),
- username2: "sysadm",
- UKIND2: UKIND(self.usersFlag),
- username3: "secadm",
- UKIND3: UKIND(self.usersFlag),
- username4: "auditadm",
- UKIND4: UKIND(self.usersFlag)
- }
- var data = {
- entity: "SYS_DATAUSER",
- data: [{ UKIND: self.users.UKIND1 }, { UKIND: self.users.UKIND2 }, { UKIND: self.users.UKIND3 }, { UKIND: self.users.UKIND4 }],
- setwhere: [{ UINPUTNAME: self.users.username1 }, { UINPUTNAME: self.users.username2 }, { UINPUTNAME: self.users.username3 }, { UINPUTNAME: self.users.username4 }]
- }
- $http.post(apiurljs.login + "g2app/Data/UpdataByWhereList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- self.getStatus();
- var time = 3;
- dialog(time + "秒后将退出系统!")
- $interval(function () {
- if (time > 1) {
- time--;
- dialog(time + "秒后将退出系统!")
- } else {
- btnLoginOut()
- }
- }, 1000)
- }
- else {
- sp.dialog(res.message);
- }
- })
- })
- }
- }])
- function UKIND(str) {
- return str == true ? "正常" : "禁用";
- }
- function btnLoginOut() {
- $.ajax({
- url: apiurljs.login + "g2app/DangJian/insertFormData",
- type: "post",
- dataType: "json",
- contentType: "application/json",
- headers: { Authorization: "Bearer " + localStorage.getItem("GlWorkPlatform-AccessToken") }, ////请求头headers
- data: JSON.stringify({
- data: s4.encryptData_CBC(JSON.stringify({
- tablename: "LOGIN_STATISTICS_TAB",
- data: {
- USERID: $.cookie("GlWorkPlatform-userid"),
- USHOWNAME: decodeURI($.cookie("GlWorkPlatform-chineseName")),
- UINPUTNAME: $.cookie("GlWorkPlatform-username"),
- OPERATIONTIME: sp.getLocalDate(),
- ONLINEMARK: "out"
- }
- }))
- })
- })
- setTimeout(function () {
- window.parent.location.href = "../../login.html";
- $.cookie("GlWorkPlatform-userid", null, { path: '/', expires: -1 });
- $.cookie("GlWorkPlatform-username", null, { path: '/', expires: -1 });
- $.cookie("GlWorkPlatform-chineseName", null, { path: '/', expires: -1 });
- $.cookie("GlWorkPlatform-photo", null, { path: '/', expires: -1 });
- sessionStorage.removeItem("GlWorkPlatform-LoginFrom");
- localStorage.removeItem("GlWorkPlatform-openfileArray"); ////清空保存菜单文件的变量
- localStorage.removeItem("GlWorkPlatform-setLeftBarClickID");
- }, 500)
- };
- function dialog(str) {
- var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span></span>";
- var dialogBody = "<div class=\"sp-dialog-body\">" + str + "</div>";
- $('.sp-dialog').html(dialogHead + dialogBody)
- sp.openDLTX(".sp-dialog")
- }
|