'use strict'; var app = angular.module('app', [ 'angularUtils.directives.dirPagination' ]); app.controller("GLJCtrl", ["$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"); self.routeid = sp.getUrlName("routeid"); self.routeinfoid = sp.getUrlName("routeinfoid"); self.copyrightid = sp.getUrlName("copyrightid"); self.directionid = sp.getUrlName("directionid"); self.formeditid = sp.getUrlName("formeditid"); self.flowid = sp.getUrlName("flowid"); var postCfg = { headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + self.get_AccessToken } }; //var uploadformat = strToJson(s4.decryptData_CBC(apiurljs.uploadformat)).data.map(function (item) { // return item.CNAME //}) self.getGLJ = function () { var data = { userid: self.userid, routeinfoid: self.routeinfoid } $http.post(apiurljs.login + "g2work/routeinfo/queryDataRelatedFlow", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.FLOWIN = res.data.FLOWIN; self.FLOWIN.forEach(function (item) { if (!item.LASTROUTEINFOID) { item.FILEN.split("&").forEach(function (item1) { if (item1.indexOf("lastrouteinfoid") > -1) { item.LASTROUTEINFOID = item1.split("=")[1] } }) } }) self.FLOWOUT = res.data.FLOWOUT; self.FLOWOUT.forEach(function (item) { if (!item.LASTROUTEINFOID) { item.FILEN.split("&").forEach(function (item1) { if (item1.indexOf("lastrouteinfoid") > -1) { item.LASTROUTEINFOID = item1.split("=")[1] } }) } }) }) } self.getGLJ() //AA16、AA18收文 //AA65签报 //AA20、AA03、AA10、AA55、AA56、AA57、AA08、AA23、AA77、AA06行政发文 //AA88、AA89、AA46、AA22、AA54党委发文 //AA98、AA0A、AA99、AA0E、AA0P机关党建 //n等于1为上关联,n等于2为下关联 self.type = 0; self.CREATFLOW = function (n, pageno) { self.type = n; var flowid = "AA16|AA18|AA65|AA20|AA03|AA10|AA55|AA56|AA57|AA08|AA23|AA77|AA06|AA88|AA89|AA46|AA22|AA54|AA98|AA0A|AA99|AA0E|AA0P"; //if (self.flowid == "AA65") { // if (self.type == 1) { // flowid = "AA16|AA18" // } else { // flowid = "AA20|AA03|AA10|AA55|AA56|AA57|AA08|AA23|AA77|AA06|AA88|AA89|AA46|AA22|AA54|AA98|AA0A|AA99|AA0E|AA0P" // } //} //else if ("AA20|AA03|AA10|AA55|AA56|AA57|AA08|AA23|AA77|AA06|AA88|AA89|AA46|AA22|AA54|AA98|AA0A|AA99|AA0E|AA0P".indexOf(self.flowid) > -1) { // if (self.type == 1) { // flowid = "AA65" // } else { // flowid = "AA20|AA03|AA10|AA55|AA56|AA57|AA08|AA23|AA77|AA06|AA88|AA89|AA46|AA22|AA54|AA98|AA0A|AA99|AA0E|AA0P" // } //} //else if ("AA16|AA18".indexOf(self.flowid) > -1) { // flowid = "AA65" //} var data = { flowid: flowid, userid: self.userId, infostatus: "START|DEAL|STOP", pagesize: 10, pageno: pageno } $http.post(apiurljs.login + "g2work/routeinfo/queryDataRelateFlowWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.gljList = res.data; self.total_count = res.totalCount }) } self.subFLOW = function (item) { var data = { routeinfoid: self.type == 1 ? self.routeinfoid : item.ROUTEINFOID, lastrouteinfoid: self.type == 1 ? item.ROUTEINFOID : self.routeinfoid } $http.post(apiurljs.login + "g2work/routeinfo/updateRelateWithRouteinfoid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)) if (res.success) { self.type = 0; self.getGLJ() } else { sp.dialog(res.message) } }) } self.delFLOW = function (item) { var data = { routeinfoid: self.type == 1 ? item.ROUTEINFOID : item.LASTROUTEINFOID, lastrouteinfoid: self.type == 1 ? item.LASTROUTEINFOID : item.ROUTEINFOID } $http.post(apiurljs.login + "g2work/routeinfo/cancelRelateWithRouteinfoid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res=strToJson(s4.decryptData_CBC(obj.data)) if (res.success) { self.type = 0; self.getGLJ() } else { sp.dialog(res.message) } }) } }])