'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"); self.getflowids = sp.getUrlName("flowids") 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); self.CrossPage = window.parent.CrossPage; self.loading = false; self.search = null//JSON.parse($.cookie("GlWorkPlatform-fawendw")); self.noDataTip = 1;//没有数据时赋变量为0,先默认为1 self.pageno = 1; self.total_count = 0; self.itemsPerPage = 20; self.pageOptions = [20, 40, 60]; self.getGWZL = function () { var data = { tablename: "CODE_GWTYPE", colums: "ID,CODE,CNAME,FLOWID", order: "ID desc", sqlwhere: { USEMARK: 1 }, sqlinwhere: { FLOWID: self.flowids.map(function (item) { return "'" + item.ID + "'" }).join(",") }, sqllikewhere: "" } $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.GWZL = res.data; self.getJJLB() }) } self.getJJLB = function () { var data = { ckey: "CODE_JJLB", 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.JJLB = res.data.CODE_JJLB; self.load() }) } self.ordercondition = [] self.flowids = [{ ID: "AA88", NAME: "党委正式文上行文", checked: false }, { ID: "AA89", NAME: "党委正式文下行文", checked: false }, { ID: "AA46", NAME: "党委会议纪要", checked: false }, { ID: "AA22", NAME: "党委其他文件", checked: false }, { ID: "AA54", NAME: "党委督查专报", checked: false }] if (self.getflowids != "") { self.flowids = self.flowids.filter(function (item) { if (self.getflowids.indexOf(item.ID) > -1) { return true } }) } self.getData = function (pageno) { if (self.search == null) { self.search = { FLOW: [], JJLB: [], GWZL: [], TITLE: "", DATE1: "", DATE2: "", NGRBM: '', NGR: '' } } var urlflowids = self.flowids.map(function (item) { return item.ID }).join("|"); var flowids = self.search.FLOW.join("|"); var querycondition = []; var columnscondition = [ { COLID: "JJLB", COLUMNS: "FW_DWDCZB.JJLB|FW_DWHYJY.JJLB|FW_DWQTWJ.JJLB|FW_DWZSWSXW.JJLB|FW_DWZSWXXW.JJLB" }, { COLID: "GWZL", COLUMNS: "FW_DWDCZB.GWZL|FW_DWHYJY.GWZL|FW_DWQTWJ.GWZL|FW_DWZSWSXW.GWZL|FW_DWZSWXXW.GWZL" }, { COLID: "NGRBM", COLUMNS: "FW_DWDCZB.NGRBM|FW_DWHYJY.NGRBM|FW_DWQTWJ.NGRBM|FW_DWZSWSXW.NGRBM|FW_DWZSWXXW.NGRBM" }, { COLID: "NGR", COLUMNS: "FW_DWDCZB.NGR|FW_DWHYJY.NGR|FW_DWQTWJ.NGR|FW_DWZSWSXW.NGR|FW_DWZSWXXW.NGR" } ] if (self.search.JJLB != "") { querycondition.push({ "CKIND": "VARLIST", "TABLEID": "CODETABLE", "COLID": "TITLE", "VALUEA": self.search.JJLB.join(","), "VALUEB": "" }) } if (self.search.GWZL != "") { querycondition.push({ "CKIND": "VARLIST", "TABLEID": "CODETABLE", "COLID": "GWZL", "VALUEA": self.search.GWZL.join(","), "VALUEB": "" }) } if (self.search.TITLE != "") { querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "TITLE", "VALUEA": self.search.TITLE, "VALUEB": "" }) } if (self.search.NGRBM != "") { querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "CODETABLE", "COLID": "NGRBM", "VALUEA": self.search.NGRBM, "VALUEB": "" }) } if (self.search.NGR != "") { querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "CODETABLE", "COLID": "NGR", "VALUEA": self.search.NGR, "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": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": self.search.DATE1, "VALUEB": self.search.DATE2 }) } else if (self.search.DATE1 != "" && self.search.DATE2 == "") { querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": self.search.DATE1, "VALUEB": "" }) } else if (self.search.DATE1 == "" && self.search.DATE2 != "") { querycondition.push({ "CKIND": "DATETIME", "TABLEID": "SYS_ROUTE_VIEW", "COLID": "RECEIVEDATE", "VALUEA": "", "VALUEB": self.search.DATE2 }) } self.list = []; self.loading = true; self.pageno = pageno; $scope.__default__currentPage = self.pageno; //设置页面样式在第几页 var data = { //flowid: "AA05|AA22|AA44|AA45|AA46|AA47|AA48|AA54|AA58|AA59|AA60|AA61|AA62", //"AA88|AA89|AA46|AA22|AA54|AA58|AA98|AA99|AA0E" flowid: flowids != "" ? flowids : urlflowids != "" ? urlflowids : "AA88|AA89|AA46|AA22|AA54", userid: self.userId, pageno: self.pageno, pagesize: self.itemsPerPage, columnscondition: JSON.stringify(columnscondition), querycondition: JSON.stringify(querycondition), 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) { self.JJLB.forEach(function (item1) { if (item.JJLB == item1.CODE) item.JJLB = item1.CNAME }) self.GWZL.forEach(function (item1) { if (item.GWZL == item1.CODE) item.GWZL = item1.CNAME }) 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 + "&flowid=" + item.FLOWID : item.FILEN + "&dotype=" + getDoType(self.type) + "&type=" + self.type + "&lastReturnPageno=" + self.pageno + "&flowid=" + item.FLOWID; } else { item.FILEN = "#"; } if (item.TODOLIST) { item.TODOLIST.forEach(function (item1) { if (item1.FILEN != "") { item1.FILEN = item1.FILEN.indexOf("dotype") > -1 ? item1.FILEN.replace("dotype=1", "dotype=" + getDoType(self.type)) + "&type=" + self.type + "&lastReturnPageno=" + self.pageno + "&flowid=" + item.FLOWID : item1.FILEN + "&dotype=" + getDoType(self.type) + "&type=" + self.type + "&lastReturnPageno=" + self.pageno + "&flowid=" + item.FLOWID; } else { item1.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.getGWZL(); self.openLayer = function () { self.params = ""; if (self.search == null) { self.search = { FLOW: [], JJLB: [], GWZL: [], TITLE: "", DATE1: "", DATE2: "", NGRBM: '', NGR: '' } } else { self.flowids.forEach(function (item) { item.checked = false; if (self.search.FLOW.indexOf(item.ID) > -1) { item.checked = true; } }) self.JJLB.forEach(function (item) { item.checked = false; if (self.search.JJLB.indexOf(item.CODE) > -1) { item.checked = true; } }) self.GWZL.forEach(function (item) { item.checked = false; if (self.search.GWZL.indexOf(item.CODE) > -1) { item.checked = true; } }) } sp.layer("#Search") } self.doSearch = function () { self.search.FLOW = []; self.flowids.forEach(function (item) { if (item.checked == true) { self.search.FLOW.push(item.ID) } }) self.search.JJLB = []; self.JJLB.forEach(function (item) { if (item.checked == true) { self.search.JJLB.push(item.CODE) } }) self.search.GWZL = []; self.GWZL.forEach(function (item) { if (item.checked == true) { self.search.GWZL.push(item.CODE) } }) $.cookie("GlWorkPlatform-fawendw", JSON.stringify(self.search), { path: '/', expires: 1 }); self.getData(self.pageno) sp.layerhide() } self.cancal = function () { self.search = { FLOW: [], JJLB: [], GWZL: [], TITLE: "", DATE1: "", DATE2: "", NGRBM: '', NGR: '' } $.cookie("GlWorkPlatform-fawendw", null, { path: '/', expires: 1 }); 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.deviceType == "pad") { window.location.href = item.FILEN + "&dotype=" + getDoType(self.type) } else { sp.openNewWindow(item.FILEN + "&dotype=" + getDoType(self.type), 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 = "