'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); self.CrossPage = window.parent.CrossPage; self.loading = false; self.search = null//JSON.parse($.cookie("GlWorkPlatform-GWJDBXPZ")); self.noDataTip = 1;//没有数据时赋变量为0,先默认为1 self.pageno = 1; self.total_count = 0; self.itemsPerPage = 20; self.pageOptions = [20, 40, 60]; self.ordercondition = []; self.getData = function (pageno) { if (self.search == null) { self.search = { JDBM: "", JDFY: "", JFYS: "", DATE1: "", DATE2: "" } } var querycondition = []; var columnscondition = [ { COLID: "JDBM", COLUMNS: "SX_GWJD.JDBM" }, { COLID: "JFYS", COLUMNS: "SX_GWJD.JFYS" }, { COLID: "BKRS", COLUMNS: "SX_GWJD.BKRS" }, { COLID: "PKRS", COLUMNS: "SX_GWJD.PKRS" }, { COLID: "JDFY", COLUMNS: "SX_GWJD.JDFY" }, { COLID: "BGMC", COLUMNS: "SX_GWJD.BGMC" }, { COLID: "JDSJ", COLUMNS: "SX_GWJD.JDSJ" } ] if (self.search.JDBM != "") { querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "CODETABLE", "COLID": "JDBM", "VALUEA": self.search.JDBM, "VALUEB": "" }) } if (self.search.JDFY != "") { querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "CODETABLE", "COLID": "JDFY", "VALUEA": self.search.JDFY, "VALUEB": "" }) } if (self.search.JFYS != "") { querycondition.push({ "CKIND": "VARCHAR", "TABLEID": "CODETABLE", "COLID": "JFYS", "VALUEA": self.search.JFYS, "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": "JDSJ", "VALUEA": self.search.DATE1, "VALUEB": self.search.DATE2 }) } else if (self.search.DATE1 != "" && self.search.DATE2 == "") { querycondition.push({ "CKIND": "DATETIME", "TABLEID": "CODETABLE", "COLID": "JDSJ", "VALUEA": self.search.DATE1, "VALUEB": "" }) } else if (self.search.DATE1 == "" && self.search.DATE2 != "") { querycondition.push({ "CKIND": "DATETIME", "TABLEID": "CODETABLE", "COLID": "JDSJ", "VALUEA": "", "VALUEB": self.search.DATE2 }) } self.list = []; self.loading = true ; self.pageno = pageno; $scope.__default__currentPage = self.pageno; //设置页面样式在第几页 var data = { flowid: "AA0W", 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; } else { self.noDataTip = 1; self.list = res.data; self.total_count = res.totalCount; $.each(self.list, function (index, item) { item.JDSJ = sp.format(item.JDSJ); 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.load(); self.openLayer = function () { self.params = ""; if (self.search == null) { self.search = { JDBM: "", JDFY: "", JFYS: "", DATE1: "", DATE2: "" } } sp.layer("#Search") } self.doSearch = function () { $.cookie("GlWorkPlatform-GWJDBXPZ", JSON.stringify(self.search), { path: '/', expires: 1 }); self.getData(self.pageno) sp.layerhide() } self.cancal = function () { self.search = { JDBM: "", JDFY: "", JFYS: "", DATE1: "", DATE2: "" } $.cookie("GlWorkPlatform-GWJDBXPZ", 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 = "
" + res.data.REMARK + "
"; var dialogFoot = "
"; $('.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 () { $http.post(apiurljs.login + "g2work/routeinfo/recallDoneByRouteid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); sp.dialoghide() if (res.success == true) { self.getData(self.pageno) } else { sp.dialog(res.message) } }) }); }) } self.changeType = function (str) { if (self.type == str) { return; } else { var time1 = sp.getLocalDate1(); self.journalRecord(time1, sp.getLocalDate1(), "查询", "查询日志", "/g2work/routeinfo/" + self.Url) self.type = str; self.Url = getUrl(self.type); self.getData(1) } } self.getAddFlag = function () { var data = { userid: self.userId, ntops: 0 } $http.post(apiurljs.login + "g2work/desktop/queryWorkflowCando", data, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.lcList = []; self.activeLC = {}; res.data.forEach(function (item) { if ("AA0W".indexOf(item.FLOWID) > -1) { self.lcList.push(item); } }) }) } self.getAddFlag() self.addLC = function () { if (self.lcList.length == 0) { sp.dialog("暂无权限!") } else if (self.lcList.length == 1) { sp.openNewWindow(self.lcList[0].FILEN + "&dotype=1&flowid=" + self.lcList[0].FLOWID, self.lcList[0].FLOWNAME) } else { sp.layer("#addLC"); } //var data = { // userid: self.userId, // ntops: 0 //} //$http.post(apiurljs.login + "g2work/desktop/queryWorkflowCandoGwtype", data, postCfg) //.success(function (obj) { // var res = strToJson(s4.decryptData_CBC(obj.data)); // self.lcList = []; // self.activeLC = {}; // res.data.forEach(function (item) { // if ("AA0W".indexOf(item.FLOWID) > -1) { // self.lcList.push(item); // } // }) // if (self.lcList.length == 0) { // sp.dialog("暂无权限!") // } else if (self.lcList.length == 1) { // window.location.href = self.lcList[0].FILEN + "&dotype=1" // //var data = { // // gwtypecode: self.lcList[0].GWCODE, // // copyrightid: self.lcList[0].COPYRIGHTID, // // userid: self.userId // //} // //$http.post(apiurljs.login + "g2app/fawenfiles/createNewWorkFlowWithGwtype", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) // //.success(function (obj) { // // var res = strToJson(s4.decryptData_CBC(obj.data)); // // var url = self.lcList[0].FILEN + "&dotype=1&GWCODE=" + self.lcList[0].GWCODE; // // var url1 = url.replace("routeid=0", "routeid=" + res.data.ROUTEID).replace("routeinfoid=0", "routeinfoid=" + res.data.ROUTEINFOID) // // console.log(url1) // // window.location.href = url1; // //}) // } else { // sp.layer("#addLC"); // } //}) } self.seeLCT = function (item,event) { event.preventDefault(); event.stopPropagation(); } self.goAddUrl = function () { if (!self.activeLC.FILEN) { return } sp.openNewWindow(obj.FILEN + "&dotype=1&flowid=" + obj.FLOWID, obj.FLOWNAME) //var data = { // gwtypecode: self.activeLC.GWCODE, // copyrightid: self.activeLC.COPYRIGHTID, // userid: self.userId //} //$http.post(apiurljs.login + "g2app/fawenfiles/createNewWorkFlowWithGwtype",{ data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) //.success(function (obj) { // var res = strToJson(s4.decryptData_CBC(obj.data)); // var url = self.activeLC.FILEN + "&dotype=1&GWCODE=" + self.activeLC.GWCODE; // var url1 = url.replace("routeid=0", "routeid=" + res.data.ROUTEID).replace("routeinfoid=0", "routeinfoid=" + res.data.ROUTEINFOID) // console.log(url1) // window.location.href = url1; //}) } //记录日志 self.journalRecord = function (time1, time2, title, func, url) { if (!self.CrossPage || !self.CrossPage.cname) { return; } var data = { tablename: "SYS_CLICKLOG", data: { CTIME: time1 == null ? sp.getLocalDate1() : time1, TITLE: (title != "" ? self.CrossPage.cname + "/" + title : self.CrossPage.cname), REQUESTURL: url, REQUESTHEADERURL: window.location.origin, LOGTYPE: func, USERTYPE: $.cookie("GlWorkPlatform-userType"), ADMIN: $.cookie("GlWorkPlatform-userTypeEng"), CLIENTIP: sp.myIP(), PCNAME: sp.detectOS(), BROWSERNAME: sp.browser(), RESPONSETIME: time2 == null ? sp.getLocalDate1() : time2, USERID: self.userId, USERNAME: self.userName } } $http.post(apiurljs.login + "g2app/DangJian/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (res) { self.CrossPage.type = 1; }) } $interval(function () { if (localStorage.getItem("GlWorkPlatform-GWJDBXPZ-refresh") == 1) { localStorage.removeItem("GlWorkPlatform-GWJDBXPZ-refresh") self.refresh() } }, 1000) //头部下滚冻结 $(function () { //页面高度撑满 setTimeout(function () { if ($(".ibox-content").height() < $(window).height() - 31) { $(".ibox-content").css("height", $(window).height() - 31) } }, 1) }) }]) function getUrl(str) { switch (str) { case "todo": return "queryDataTodoWithPage"; break; case "done": return "queryDataDoneWithPage"; break; case "finish": return "queryDataFinishWithPage"; break; } } function getDoType(str) { switch (str) { case "todo": return 1; break; default: return 0; break; } }