'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.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType"); self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno"); self.get_type = sp.getUrlName("type"); self.params = sp.getUrlName("params"); var postCfg = { headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + self.get_AccessToken } } self.type = self.get_type != "" ? self.get_type : "todo"; self.Url = getUrl(self.type); var weeks = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"] self.CrossPage = window.parent.CrossPage; self.loading = false; self.search = null//JSON.parse($.cookie("GlWorkPlatform-PH")); self.noDataTip = 1;//没有数据时赋变量为0,先默认为1 self.pageno = 1; self.total_count = 0; self.itemsPerPage = 10; self.pageOptions = [10, 20, 30, 40]; self.ordercondition = []; self.getData = function (pageno) { if (self.search == null) { self.search = { HYMC: "", HYZZDW: "", DATE1: "", DATE2: "" } } var querycondition = []; var columnscondition = [ { COLID: "HYZZDW", COLUMNS: "SX_PHD.HYZZDW" }, { COLID: "HYRQ", COLUMNS: "SX_PHD.TO_CHAR(HYRQ)" }, { COLID: "HYMC", COLUMNS: "SX_PHD.HYMC" }, { COLID: "CHLD", COLUMNS: "SX_PHD.CHLD" }, { COLID: "CHWLD", COLUMNS: "SX_PHD.CHWLD" }, { COLID: "CHFW", COLUMNS: "SX_PHD.CHFW" }, { COLID: "HYDD", COLUMNS: "SX_PHD.HYDD" }, { COLID: "BZ", COLUMNS: "SX_PHD.BZ" } ] if (self.search.HYMC != "") { querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "CODETABLE", "COLID": "HYMC", "VALUEA": self.search.HYMC, "VALUEB": "" }) } if (self.search.HYZZDW != "") { querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "CODETABLE", "COLID": "HYZZDW", "VALUEA": self.search.HYZZDW, "VALUEB": "" }) } if (self.params != "") { querycondition.push({ "CKIND": "VARLIST", "TABLEID": "SYS_ROUTE", "COLID": "ROUTEID", "VALUEA": self.params, "VALUEB": "" }) } if (self.search.DATE1 != "" && self.search.DATE2 != "") { querycondition.push({ "CKIND": "DATETIME", "TABLEID": "CODETABLE", "COLID": "HYRQ", "VALUEA": self.search.DATE1, "VALUEB": self.search.DATE2 }) } else if (self.search.DATE1 != "" && self.search.DATE2 == "") { querycondition.push({ "CKIND": "DATETIME", "TABLEID": "CODETABLE", "COLID": "HYRQ", "VALUEA": self.search.DATE1, "VALUEB": "" }) } else if (self.search.DATE1 == "" && self.search.DATE2 != "") { querycondition.push({ "CKIND": "DATETIME", "TABLEID": "CODETABLE", "COLID": "HYRQ", "VALUEA": "", "VALUEB": self.search.DATE2 }) } self.list = []; self.loading = false; self.pageno = pageno; $scope.__default__currentPage = self.pageno; //设置页面样式在第几页 var data = { flowid: "AA0B", userid: self.userId, pageno: self.pageno, pagesize: self.itemsPerPage, querycondition: JSON.stringify(querycondition), columnscondition: JSON.stringify(columnscondition), ordercondition: self.ordercondition.length == 0 ? "" : JSON.stringify(self.ordercondition) } //$http.post(apiurljs.login + "g2work/routeinfo/" + self.Url, { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) $http.post(apiurljs.login + "g2work/routeinfo/" + self.Url, data, postCfg) .success(function (obj) { var res = obj; //var res = strToJson(s4.decryptData_CBC(obj.data)); self.loading = false; if (res.data == null || res.data == undefined || res.data == "") { self.noDataTip = 0; if (self.params != "") { self.params = ""; self.getData(1) } } else { self.noDataTip = 1; self.list = res.data; self.total_count = res.totalCount; $.each(self.list, function (index, item) { item.WEEK = weeks[new Date(item.HYRQ).getDay()] item.WCSX = sp.format(item.WCSX); if (item.FILEN != "") { item.FILEN = item.FILEN.indexOf("dotype") > -1 ? item.FILEN.replace("dotype=1", "dotype=" + getDoType(self.type)) + "&type=" + self.type + "&lastReturnPageno=" + self.pageno : item.FILEN + "&dotype=" + getDoType(self.type) + "&type=" + self.type + "&lastReturnPageno=" + self.pageno; } else { item.FILEN = "#"; } if (self.type == "finish") { item.RECEIVEDATE = item.FINISHEDDATE; } }) } if (self.CrossPage.type == 0) { self.journalRecord(self.CrossPage.ctime, sp.getLocalDate1(), "", "接入日志", window.location.pathname) } }) } 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.sortFiled = function (str) { var n = 0, obj, x = -1; self.ordercondition.forEach(function (item, index) { if (item.COLID == str) { n++ item.SORTTYPE = item.SORTTYPE == "" || item.SORTTYPE == "asc" ? "desc" : "asc" obj = item; x = index } }) if (n == 0) { self.ordercondition.unshift({ COLID: str, SORTTYPE: "desc" }) } if (x != -1) { self.ordercondition.splice(x, 1) self.ordercondition.unshift(obj) } self.getData(1); } self.getUserRole = function () { self.editFlag = false; var data = { userid: self.userId }; $http.post(apiurljs.login + "g2work/datazu/queryDataUserAuth", data, postCfg) .success(function (res) { for (var i = 0; i < res.data[0].auths.length; i++) { if (res.data[0].auths[i].ZID == "AA95" && res.data[0].auths[i].AUTH == "1") { self.editFlag = true; } } self.load(); }); } self.getUserRole(); self.openLayer = function () { self.params = ""; if (self.search == null) { self.search = { HYMC: "", HYZZDW: "", DATE1: "", DATE2: "" } } sp.layer("#Search") } self.doSearch = function () { self.getData(self.pageno) sp.layerhide() } self.cancal = function () { self.search = { HYMC: "", HYZZDW: "", DATE1: "", DATE2: "" } self.getData(1) sp.layerhide() } self.refresh = function () { self.CrossPage.type = null; self.getData(self.pageno); } self.goUrl = function (item) { if (item.TODOLIST && item.TODOLIST.length > 1) { self.todoTitle = item.TITLE; self.todoList = item.TODOLIST; sp.layer("#todolist") } else { if (self.editFlag == true) { var FILEN = item.FILEN.replace(/dotype=0/g, "dotype=1") } else { var FILEN = item.FILEN } if (self.deviceType == "pad") { window.location.href = item.FILEN } else { sp.openNewWindow(FILEN, item.TITLE) } sp.layerhide(); } } self.btnDel = function (item) { var data = { routeinfoid: item.ROUTEINFOID, userid: self.userId } $http.post(apiurljs.login + "g2work/routeinfo/deleteDraftByRouteinfoid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); if (res.success == true) { self.getData(self.pageno) } else { sp.dialog(res.message) } }) } self.btnRecall = function (routeid, kind) { var data = { routeid: routeid, kind: kind, userid: self.userId } $http.post(apiurljs.login + "g2work/routeinfo/queryDataRecallDoneByRouteid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); var dialogHead = "温馨提示×"; var dialogBody = "