123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436 |
- var app = angular.module('app', ["angularUtils.directives.dirPagination"]);
-
- app.controller("indexCtrl", ["$scope", "$http", "$compile", "$timeout", function ($scope, $http, $compile, $timeout) {
- var self = this;
- var s4 = new SM4Util();
-
- self.userId = $.cookie("GlWorkPlatform-userid");
- self.userName = $.cookie("GlWorkPlatform-username");
- self.userCName = $.cookie("GlWorkPlatform-chineseName");
- self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
-
- $("#content-box").height($("body").height() - 80);
-
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- };
-
- //获取一级类别
- self.departList = [];
- self.getDepartData = function () {
- self.departList = [];
- var postData = {"pageno": "0", "pagesize": "0", "sectcode": ""}
- $http.post(apiurljs.login + "g2app/phonebook/querySectWithPage", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- res.data.forEach(function (item) {
- item.SECTIONNAME = item.SECTION + " (" + item.CHILDCOUNT + ") ";
- })
- self.departList = res.data;
- //console.log(self.departList);
- })
- .error(function (XMLHttpRequest, textStatus, errorThrown) {
- })
- }
-
-
- self.leftActive = "newF"; //默认newF oldF以及code\
- self.leftActiveName = "新的朋友";
- self.direction = ""; //user or depart
-
- //用于生成导航条的数组,只用与记录组织通讯录
- self.passArray = [];
- self.passIndex = "";
-
- self.changeActive = function (code, cname, item) {
- self.passArray = [];
- self.passIndex = "";
- self.leftActive = code;
- self.leftActiveName = cname;
- if (code == "newF" || code == "oldF") {
- self.direction = "";
- } else {
- if (parseInt(item.CHILDCOUNT) == 0) {
- self.direction = "user";
- self.passArray.push({
- level: 0,
- type: "user",
- code: code,
- cname: cname
- });
- self.passIndex = 0;
- } else {
- self.direction = "depart";
- self.passArray.push({
- level: 0,
- type: "depart",
- code: code,
- cname: cname
- });
- self.passIndex = 0;
- }
- }
- self.getData(1);
- // console.log(self.passArray);
- // console.log(self.passIndex);
- }
-
-
- self.noDataTip = 1;
- self.rows = [];
- self.pageno = 1;
- self.total_count = 0;
- self.itemsPerPage = 8;
- self.pageOptions = [8, 16, 24, 32];
-
- self.getUserAddress = function (pageno) {
- self.pageno = pageno;
- $scope.__default__currentPage = self.pageno;
- var postData = {
- "pageno": self.pageno,
- "pagesize": self.itemsPerPage,
- "userid": self.userId,
- "status": "",
- "order": "cdate"
- }
-
- if (self.leftActive == "newF") {
- postData.status = "0";
- } else if (self.leftActive == "oldF") {
- postData.status = "1";
- }
-
- $http.post(apiurljs.login + "g2app/phonebook/queryFriendWithPage", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- //console.log(res);
- // res.data.forEach(function (item) {
- // item.SECTIONNAME = item.SECTION + " (" + item.CHILDCOUNT + ") ";
- // })
- // self.departList = res.data;
- //console.log(res);
- if (sp.isval(res.data)) {
- self.noDataTip = 1;
- self.rows = res.data;
- self.total_count = res.totalCount;
- } else {
- self.rows = [];
- self.noDataTip = 0;
- }
- })
- .error(function (XMLHttpRequest, textStatus, errorThrown) {
- })
- }
-
- self.getDepartList = function (pageno) {
- self.pageno = pageno;
- $scope.__default__currentPage = self.pageno;
- let nowItem = self.passArray[self.passIndex];
-
- var postData = {
- "pageno": self.pageno,
- "pagesize": self.itemsPerPage,
- "sectcode": nowItem.code
- }
-
- $http.post(apiurljs.login + "g2app/phonebook/querySectUserinfoWithPage", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- console.log(res);
- if (sp.isval(res.data)) {
- self.noDataTip = 1;
- self.rows = res.data;
- self.total_count = res.totalCount;
- } else {
- self.rows = [];
- self.noDataTip = 0;
- }
- })
- .error(function (XMLHttpRequest, textStatus, errorThrown) {
- })
- }
-
- self.getUserList = function (pageno) {
- self.pageno = pageno;
- $scope.__default__currentPage = self.pageno;
- let nowItem = self.passArray[self.passIndex];
-
- var postData = {
- "pageno": self.pageno,
- "pagesize": self.itemsPerPage,
- "sectcode": nowItem.code,
- "userid":self.userId
- }
-
- $http.post(apiurljs.login + "g2app/phonebook/queryUserinfoWithPage", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- console.log(res);
- if (sp.isval(res.data)) {
- self.noDataTip = 1;
- self.rows = res.data;
- self.total_count = res.totalCount;
- } else {
- self.rows = [];
- self.noDataTip = 0;
- }
- })
- .error(function (XMLHttpRequest, textStatus, errorThrown) {
- })
- }
-
- self.getData = function (pageno) {
- if (self.leftActive == "newF" || self.leftActive == "oldF") {
- self.getUserAddress(pageno); //
- } else {
- let nowItem = self.passArray[self.passIndex];
- if (nowItem.type == "depart") {
- self.getDepartList(pageno);
- } else if (nowItem.type == "user") {
- self.direction = "user";
- self.getUserList(pageno);
- }
- }
- }
-
- self.extendDepart = function (item) {
- if (parseInt(item.CHILDDPCOUNT) <= 0) {
- self.passArray.push({
- level: 1,
- type: "user",
- code: item.CODE,
- cname: item.SECTION
- });
- self.passIndex++;
- } else {
- self.passArray.push({
- level: 1,
- type: "depart",
- code: item.CODE,
- cname: item.SECTION
- });
- self.passIndex++;
- }
- self.getData(1);
- }
-
-
- //返回
- self.goBack = function () {
- self.passIndex--;
- self.passArray = self.passArray.splice(0, self.passArray.length - 1);
- self.direction = "depart";
- self.getData(1);
- }
-
- self.getDepartData();
- self.getData(1);
-
- //删除朋友
- self.deleteFirend = function (code) {
- var getDelID = code;
- 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 data-id=" + getDelID + " 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 () {
- var getid = $(this).attr("data-id");
- sp.dialoghide();
- var data = {
- "userid": self.userId,
- "useridfriend": getid
- }
- //console.log(data);
- $http.post(apiurljs.login + "g2app/phonebook/deleteFriend", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- sp.dialog("删除成功");
- self.getData(self.pageno);
- } else {
- sp.dialog(res.message);
- }
- })
- .error(function (XMLHttpRequest, textStatus, errorThrown) {
- })
- });
- }
-
- //编辑部门弹出曾
- self.depart = {
- CODE: "",
- ADDR: "", //地址
- EMAIL: "", //邮件
- POSTCODE: "", //邮编
- SECTION: "", //部门名
- TELPHONE: "" //电话
- }
- self.openLayerEditDepart = function (item) {
- self.depart.CODE = item.CODE;
- self.depart.ADDR = item.ADDR;
- self.depart.EMAIL = item.EMAIL;
- self.depart.POSTCODE = item.POSTCODE;
- self.depart.SECTION = item.SECTION;
- self.depart.TELPHONE = item.TELPHONE;
- sp.layer("#layer_editDepart");
- };
-
-
- self.departCancel = function () {
- self.depart.CODE = "";
- self.depart.ADDR = "";
- self.depart.EMAIL = "";
- self.depart.POSTCODE = "";
- self.depart.SECTION = "";
- self.depart.TELPHONE = "";
- sp.layerhide();
- };
-
-
- self.departSave = function () {
- var data = {
- "sectcode": self.depart.CODE,
- "addr": self.depart.ADDR,
- "postcode": self.depart.POSTCODE,
- "telphone": self.depart.TELPHONE,
- "email": self.depart.EMAIL
- }
- console.log(data);
- $http.post(apiurljs.login + "g2app/phonebook/saveSectinfo", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
- .success(function (obj) {
- sp.layerhide();
- var res = strToJson(s4.decryptData_CBC(obj.data));
- console.log(res)
- if (res.success) {
- sp.dialog("编辑完成");
- self.getData(self.pageno);
- } else {
- sp.dialog(res.message);
- }
- })
- .error(function (XMLHttpRequest, textStatus, errorThrown) {
- })
- }
-
- self.updateFriend = function (item) {
- var data = {
- "userid":item.USERID,
- "useridfriend":item.USERIDFRIEND,
- "status":"1"
- }
- $http.post(apiurljs.login + "g2app/phonebook/updateFriend", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- //console.log(res)
- if (res.success) {
- sp.dialog("添加成功,请在好友列表中查看");
- self.getData(self.pageno);
- } else {
- sp.dialog(res.message);
- }
- })
- .error(function (XMLHttpRequest, textStatus, errorThrown) {
- })
- }
-
- self.updateFriend2 = function (item) {
- var data = {
- "userid":self.userId,
- "useridfriend":item.USERID,
- "status":"1"
- }
- console.log(data);
- $http.post(apiurljs.login + "g2app/phonebook/addFriend", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- console.log(res)
- if (res.success) {
- console.log(res);
- sp.dialog("添加成功,请在好友列表中查看");
- self.getData(self.pageno);
- } else {
- sp.dialog(res.message);
- }
- })
- .error(function (XMLHttpRequest, textStatus, errorThrown) {
- })
- }
-
- self.user = {
- USHOWNAME:"",
- USERID:"",
- DUTYNAME:"",
- TELPHONE:"",
- EMAIL: "",
- ROOM: "",
- CELLPHONE:""
- }
-
-
- self.openLayerEditUser = function (item) {
- self.user.USHOWNAME=item.USHOWNAME;
- self.user.USERID = item.USERID;
- self.user.DUTYNAME = item.DUTYNAME;
- self.user.TELPHONE = item.TELPHONE;
- self.user.EMAIL = item.EMAIL;
- self.user.ROOM = item.ROOM;
- self.user.CELLPHONE = item.CELLPHONE;
- sp.layer("#layer_editUser");
- };
- self.userCancel = function () {
- self.user.USHOWNAME="";
- self.user.USERID = "";
- self.user.DUTYNAME = "";
- self.user.TELPHONE = "";
- self.user.EMAIL = "";
- self.user.ROOM = "";
- self.user.CELLPHONE = "";
- sp.layerhide();
- };
- self.userSave = function () {
- var data ={
- "userid":self.user.USERID,
- "cellphone":self.user.CELLPHONE,
- "telphone":self.user.TELPHONE,
- "email": self.user.EMAIL,
- "room": self.user.ROOM
- }
- $http.post(apiurljs.login + "g2app/phonebook/saveUserinfoT", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
- .success(function (obj) {
- sp.layerhide();
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.success) {
- sp.dialog("编辑完成");
- self.getData(self.pageno);
- } else {
- sp.dialog(res.message);
- }
- })
- .error(function (XMLHttpRequest, textStatus, errorThrown) {
- })
- }
-
-
-
-
-
- }]);
|