'use strict'; var app = angular.module('app', [ ]); app.controller("formeditCtrl", ["$scope", "$http", "$timeout", '$sce', function ($scope, $http, $timeout, $sce) { var self = this; var s4 = new SM4Util(); self.userId = $.cookie("GlWorkPlatform-userid"); self.userName = $.cookie("GlWorkPlatform-chineseName"); self.userCName = $.cookie("GlWorkPlatform-chineseName"); self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken"); self.routeinfoid = sp.getUrlName("routeinfoid"); self.type = sp.getUrlName("type"); self.get_lastReturn = sp.getUrlName("lastReturn"); self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno"); self.return = self.get_lastReturn + ".html?type=" + self.type + "&lastReturnPageno=" + self.get_lastReturnPageno var postCfg = { headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + self.get_AccessToken } }; self.select = {}; self.getLeft = function () { self.selectActive = ""; var data = { routeinfoid: self.routeinfoid, tablename: "PAGELEMENT" } $http.post(apiurljs.login + "g2app/DangAn/queryDataByTablename", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.detail = { PACKAGEID: res.data.PACKAGEID ? res.data.PACKAGEID : "", PACKAGETYPE: res.data.PACKAGETYPE ? res.data.PACKAGETYPE : "", CREATOR: res.data.CREATOR ? res.data.CREATOR : "", CREATDATE: res.data.CREATDATE ? sp.format(res.data.CREATDATE) : "", CREATENVIR: res.data.CREATENVIR ? res.data.CREATENVIR : "", STORAGELOC: res.data.STORAGELOC ? res.data.STORAGELOC : "", PACKAGEDES: res.data.PACKAGEDES ? res.data.PACKAGEDES : "" }; var data = { tablename: "DOCELEMENT_ZL", routeinfoid: res.data.ROUTEINFOIDLIST, columns: "ROUTEINFOID,DOCTITLE" } $http.post(apiurljs.login + "g2app/DangAn/queryColumnByRouteinfoid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); if (res.success == true) { self.leftList = res.data; self.getData(self.leftList[0].ROUTEINFOID, 0, 0) } else { sp.dialog(res.message) } }) }) } self.getData = function (routeinfoid, num, n) { var time1 = sp.getLocalDate1(); self.selectActive = num; var data = { routeinfoid: routeinfoid, tablename: "DOCELEMENT_ZL" } $http.post(apiurljs.login + "g2app/DangAn/queryDataByTablename", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.data = { ARCHCODE: res.data.ARCHCODE ? res.data.ARCHCODE : "", ARCHYEAR: res.data.ARCHYEAR ? res.data.ARCHYEAR : "", ORGANIZATIONMA: res.data.ORGANIZATIONMA ? res.data.ORGANIZATIONMA : "", DOCUMENTID: res.data.DOCUMENTID ? res.data.DOCUMENTID : "", DANGANML: res.data.DANGANML ? res.data.DANGANML : "", DOCUMENTTYPE: res.data.DOCUMENTTYPE ? res.data.DOCUMENTTYPE : "", SERIALNUM: res.data.SERIALNUM ? res.data.SERIALNUM : "", MIJIQIXIAN: res.data.MIJIQIXIAN ? res.data.MIJIQIXIAN : "", EMERGENCYDEGREE: res.data.EMERGENCYDEGREE ? res.data.EMERGENCYDEGREE : "", DOCISSUERID: res.data.DOCISSUERID ? res.data.DOCISSUERID : "", DOCISSUEDNUM: res.data.DOCISSUEDNUM ? res.data.DOCISSUEDNUM : "", SIGNER: res.data.SIGNER ? res.data.SIGNER : "", DOCTITLE: res.data.DOCTITLE ? res.data.DOCTITLE : "", MAINDPT: res.data.MAINDPT ? res.data.MAINDPT : "", DOCISSUEDDATE: res.data.DOCISSUEDDATE ? sp.format(res.data.DOCISSUEDDATE) : "", ATTACHMENT: res.data.ATTACHMENT ? res.data.ATTACHMENT : "", ISSUINGAGENCY: res.data.ISSUINGAGENCY ? res.data.ISSUINGAGENCY : "", ANNOTATION: res.data.ANNOTATION ? res.data.ANNOTATION : "", CCDPT: res.data.CCDPT ? res.data.CCDPT : "", PRINTSENDDPT: res.data.PRINTSENDDPT ? res.data.PRINTSENDDPT : "", PRINTDATE: res.data.PRINTDATE ? sp.format(res.data.PRINTDATE) : "", RELEASELEVEL: res.data.RELEASELEVEL ? res.data.RELEASELEVEL : "", } }) self.getAttachList(routeinfoid) } self.getAttachList = function (routeinfoid) { var data = { routeinfoid: routeinfoid } $http.post(apiurljs.login + "g2app/DangAn/getAttachList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.list = res.data; $.each(self.list, function (index, item) { item.SIZE = item.FILESIZE >= 104857.6 ? (item.FILESIZE / 1048576).toFixed(2) + "MB" : (item.FILESIZE / 1024).toFixed(2) + "KB"; }) }) } self.getLeft() self.download = function () { var data = { tablename: "FILETRANSFER", routeinfoid: self.routeinfoid, columns: "FILEURL" } $http.post(apiurljs.login + "g2app/DangAn/queryColumnByRouteinfoid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); if (res.success == true) { window.open(apiurljs.login + "g2app/DangAn/downloadZipFile" + res.data[0].FILEURL) } else { sp.dialog(res.message) } }) } }])