'use strict'; var app = angular.module('app', [ 'angularUtils.directives.dirPagination' ]); app.controller("listCtrl", ["$scope", "$http", "$timeout", "$interval", function ($scope, $http, $timeout, $interval) { var self = this; var s4 = new SM4Util(); self.userId = $.cookie("GlWorkPlatform-userid"); self.userName = $.cookie("GlWorkPlatform-chineseName"); self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken"); self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno"); self.code = sp.getUrlName("code"); self.code1 = sp.getUrlName("code1"); self.leaf = sp.getUrlName("leaf") | 0; self.returnHtml = "list1.html?code=" + self.code1 + "&lastReturnPageno=" + self.get_lastReturnPageno + (self.leaf ? "&leaf=" + (self.leaf - 1) : "") var postCfg = { headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + self.get_AccessToken } } self.CrossPage = window.parent.CrossPage; self.loading = false; self.noDataTip = 1;//没有数据时赋变量为0,先默认为1 self.pageno = 1; self.total_count = 0; self.itemsPerPage = 10; self.pageOptions = [10, 20, 30, 40]; self.getLM = function () { var data = { tablename: "CODE_LM" } $http.post(apiurljs.login + "g2app/filepublishing/getTreeListByTablename", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.LM = res.data[0].C_H_I_L_D_DATA; self.ZD = [];//置顶专栏 self.ZT = [];//普通专栏 self.PT = [];//普通栏目 self.LM.forEach(function (item) { if (self.leaf == 0) { if (item.CODE == self.code) { self.Title = item.CNAME; item.C_H_I_L_D_DATA.forEach(function (item1) { item1.IMGURL = item1.IMGURL != null && item1.IMGURL != undefined ? sp.ipChange(item1.IMGURL) : "" if (item1.COLUMNTYPE == 0) { self.ZD.push(item1) } else if (item1.COLUMNTYPE == 1) { self.ZT.push(item1) } else { self.PT.push(item1) } }) } } else { item.C_H_I_L_D_DATA.forEach(function (item1) { item1.IMGURL = item1.IMGURL != null && item1.IMGURL != undefined ? sp.ipChange(item1.IMGURL) : "" if (item1.CODE == self.code) { self.Title = item1.CNAME; item1.C_H_I_L_D_DATA.forEach(function (item2) { if (item2.COLUMNTYPE == 0) { self.ZD.push(item2) }else if (item2.COLUMNTYPE == 1) { self.ZT.push(item2) } else { self.PT.push(item2) } }) } }) } }) self.getZRBM() }) } self.getLM(); self.getZRBM = function () { var data = { ckey: "CODE_ZRBM", routeinfoid: self.routeinfoid } $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.ZRBM = res.data.CODE_ZRBM; self.load() }) } self.today = sp.format(sp.getLocalDate()); self.getData = function (pageno) { var CODE = ["'" + self.code + "'"]; self.PT.forEach(function (item) { CODE.push("'" + item.CODE + "'") }) self.list = []; self.loading = false; self.pageno = pageno; $scope.__default__currentPage = self.pageno; //设置页面样式在第几页 var sqlwhere = { FBZT: "1" }; var data = { tablename: "SX_FBLIST", pagesize: self.itemsPerPage, pageno: self.pageno, childtablename: "SX_FBLIST_02", colums: "ID,WJBT,FBBM,LM ,GKFW,FBRQ", childcolums: "TOP 1 ID,USERID,READSTATUS", order: "FBRQ desc", sqlwhere: "and LM in(" + CODE.join(",") + ") and ( GKFW ISNULL OR GKFW LIKE '" + self.userId + "') " }; $http.post(apiurljs.login + "g2app/dataabase/queryMainDataAndChildDataWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.loading = false; if (res.data == null || res.data == undefined || res.data == "") { self.noDataTip = 0; } else { self.noDataTip = 1; self.list = res.data; self.total_count = res.totalCount; self.list.forEach(function (item) { self.ZRBM.forEach(function (item1) { if (item.FBBM == item1.CODE) { item.FBBM1 = item1.CNAME; } }) }) } }) } self.load = function () { if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") { self.getData(self.pageno); } else { $timeout(function () { self.getData(self.get_lastReturnPageno); }, 1) } } self.goUrl = function (item) { //if (self.tablename == "WJFB_CB") { // window.location.href = "../../tpl/wenjianbg/WJFBB/detail.html?id=" + item.ID + "&formPage=wenjianshow&&tablename=" + self.tablename + "&code=" + self.code + "&val=" + self.val //} else { // window.location.href = "../../tpl/tongzhibg/TZGG/detail.html?id=" + item.ID + "&formPage=wenjianshow&&tablename=" + self.tablename + "&code=" + self.code + "&val=" + self.val //} sp.openNewWindow("detail.html?id=" + item.ID + "&code=" + self.code + "&code1=" + self.code1 + "&lastReturnPageno=" + self.pageno + (self.leaf ? "&leaf=1" : ""), item.WJBT) //window.location.href = "detail.html?id=" + item.ID + "&code=" + self.code + "&code1=" + self.code1 + "&lastReturnPageno=" + self.pageno + (self.leaf ? "&leaf=1" : ""); } self.goZL = function (item) { window.location.href = "list1.html?code=" + item.CODE + "&leaf=" + (self.leaf + 1) + "&code1=" + self.code; } $interval(function () { if (localStorage.getItem("GlWorkPlatform-list1-refresh") == 1) { localStorage.removeItem("GlWorkPlatform-list1-refresh") self.getData(self.pageno); } }, 1000) //头部下滚冻结 $(function () { //页面高度撑满 setTimeout(function () { if ($(".ibox-content").height() < $(window).height() - 31) { $(".ibox-content").css("height", $(window).height() - 31) } }, 1) }) }])