123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- 'use strict';
- var app = angular.module('app', [
- 'angularUtils.directives.dirPagination',
- ]);
- app.controller("indexCtrl", ["$scope", "$http", "$timeout", function ($scope, $http, $timeout) {
- var self = this;
- var s4 = new SM4Util();
- self.userId = $.cookie("GlWorkPlatform-userid");
- self.userName = $.cookie("GlWorkPlatform-chineseName");
- self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- };
- self.CrossPage = window.parent.CrossPage;
- self.getLeftTree = function () {
- var data = {
- tablename: "CODE_XXML"
- }
- $http.post(apiurljs.login + "g2app/dataabase/getTreeListAllByTablename", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- self.leftTree = res.data;
- })
- }
- self.getLeftTree();
- self.addNode = function () {
- self.add = {
- "tablename": "CODE_XXML",
- "PARENT_CNAME": "中心组",
- "code": "P01",
- "levels": "1",
- "cname": "",
- "userid": self.userId
- }
- sp.layer('#layer_box_add')
- }
- ///修改菜单
- self.editNode = function (obj) {
- self.edit = {
- "id": obj.ID,
- "tablename": "CODE_XXML",
- "cname": obj.CNAME,
- "userid": self.userId
- }
- sp.layer('#layer_box_edit');
- };
- self.btnSaveNode = function (n) {
- if (n == 1) {
- var data = {
- "tablename": self.add.tablename,
- "code": self.add.code,
- "levels": self.add.levels,
- "cname": self.add.cname,
- "userid": self.add.userid
- }
- $http.post(apiurljs.login + "g2app/dataabase/TreeAdd", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- sp.layerhide();
- self.getLeftTree();
- } else {
- sp.layerhide();
- sp.dialog(res.message);
- }
- })
- } else {
- var data = {
- "id": self.edit.id,
- "tablename": self.edit.tablename,
- "setwhere": {
- "CNAME": self.edit.cname
- }
- }
- $http.post(apiurljs.login + "g2app/dataabase/setColumnsById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- sp.layerhide();
- self.getLeftTree();
- } else {
- sp.layerhide();
- sp.dialog(res.message);
- }
- })
- }
- }
- self.deleteNode = function (obj) {
- 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='delDataTrue' 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();
- });
- //post消息的id
- $("#delDataTrue").click(function () {
- sp.dialoghide();
- //var postData = {
- // id: obj.ID,
- // tablename: "CODE_XXML",
- // parentid: obj.PARENTID
- //}
- //$http.post(apiurljs.login + "g2app/dataabase/delNode", { data: s4.encryptData_CBC(JSON.stringify(postData)) }, postCfg)
- var postData = {
- id: obj.ID,
- tablename: "CODE_XXML",
- data: {
- USEMARK: 0
- }
- }
- $http.post(apiurljs.login + "g2app/dataabase/upFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- self.getLeftTree();
- } else {
- sp.dialog(res.message);
- }
- });
- });
- }
- self.repeatNode = function (obj) {
- 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='delDataTrue' 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();
- });
- //post消息的id
- $("#delDataTrue").click(function () {
- sp.dialoghide();
- var postData = {
- id: obj.ID,
- tablename: "CODE_XXML",
- data: {
- USEMARK: 1
- }
- }
- $http.post(apiurljs.login + "g2app/dataabase/upFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- self.getLeftTree();
- } else {
- sp.dialog(res.message);
- }
- });
- });
- }
- self.checkNode = function (obj) {
- obj.show = !obj.show;
- console.log(obj)
- }
- self.moveUp = function (obj,arr) {
- var x = obj, y;
- for (var i = 0; i < arr.length; i++) {
- if (arr[i].NODE == obj.NODE) {
- y = arr[i - 1];
- }
- } var data = {
- entity: "CODE_XXML",
- data: [{ SORTID: y.SORTID }, { SORTID: x.SORTID }],
- setwhere: [{ ID: x.ID }, { ID: y.ID }]
- }
- $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 == true) {
- self.getLeftTree();
- } else {
- sp.dialog(res.message);
- }
- })
- }
- }])
|