'use strict'; var app = angular.module('app', [ ]); //定义一个全局的截图插件变量 var cropper; app.controller("formeditCtrl", ["$scope", "$http", "$timeout", "$interval", "$sce", function ($scope, $http, $timeout, $interval, $sce) { 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.directionid = sp.getUrlName("directionid"); self.formeditid = sp.getUrlName("formeditid"); self.docmode = sp.getUrlName("docmode"); self.dotype = sp.getUrlName("dotype"); self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno"); self.get_lastReturnPage = sp.getUrlName("lastReturnPage"); self.get_type = sp.getUrlName("type"); if (self.get_lastReturnPage != "") { self.return = "../../../" + self.get_lastReturnPage + "?lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.get_type } else { self.return = "../list.html?lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.get_type } var postCfg = { headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + self.get_AccessToken } }; //初始化右上角按钮 self.buttonList = [] self.getSwenList = function () { self.SwenList = []; var data = { directionid: self.directionid, userid: self.userId, routeinfoid: self.routeinfoid, routeid: self.routeid, formeditid: "" } $http.post(apiurljs.login + "g2app/abase/queryDataLink", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); $.each(res.data.LINKS, function (index, item) { if (item.TEMPFORM.indexOf("feedback.html") > -1) { self.Title = item.VNAME; } if (item.TEMPFORM.indexOf("?docmode") > 0) { if (item.TEMPFORM.indexOf("attachlist") > -1 || item.TEMPFORM.indexOf("feedback") > -1) { item.TEMPFORM = item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage; } else { item.TEMPFORM = "../" + item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage; } } else { item.TEMPFORM = "#"; } self.SwenList.push(item) }) self.SwenList.push({ VNAME: "流程图", DIRECTIONID: self.SwenList[0].DIRECTIONID, TEMPFORM: "modeler_read.html?" + self.SwenList[0].TEMPFORM.split("?")[1] }) self.getFuncList() }) } self.getSwenList(0) self.getFuncList = function () { var data = { formeditid: self.formeditid, billkey: "FILE_ATTACH" } $http.post(apiurljs.login + "g2work/formedit/queryDataFormEditFunc", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.buttonList = res.data self.getData() }) } self.getData = function () { var data = { tablename: "SX_XF", colums: "*", order: "ID desc", sqlwhere: { ROUTEINFOID: self.routeinfoid }, sqlinwhere: "", 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)); var FJ = res.data[0].FJ != "" && res.data[0].FJ != null ? JSON.parse(res.data[0].FJ) : []; var JGFJ = res.data[0].JGFJ != "" && res.data[0].JGFJ != null ? JSON.parse(res.data[0].JGFJ) : []; FJ.forEach(function (item) { item.COLID = "FJ" }) JGFJ.forEach(function (item) { item.COLID = "JGFJ" }) self.arrayFile = FJ.concat(JGFJ); console.log(self.arrayFile) self.getData1() }) } self.getData1 = function () { var data = { routeinfoid: self.routeinfoid, routeid: "", tableid: "SX_XF", colid: "", } $http.post(apiurljs.login + "g2app/abase/queryFileWithRouteAttach", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.arrayFile1 = res.data; console.log(self.arrayFile1) }) } self.uploading = false; self.upload = function () { $('#fileupload').fileupload({ url: apiurljs.login + 'g2app/abase/saveUploadFileName', dataType: 'json', beforeSend: function (xhr, data) { xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken); xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=SX_XF,column=FJ,routeinfoid=" + self.routeinfoid + ",loaded=" + data.loaded + ",total=" + data.total)); }, // 上传完成后的执行逻辑 done: function (e, data) { self.uploading = false; self.getData() } }) } self.downLoad = function (item,n) { window.open(apiurljs.login + "g2work/files/" + (n == 1 ? item.FILEURL.slice(7) : item.FILEPATH.slice(7))) } self.deleteFile = function (file) { var dialogHead = "温馨提示×"; var dialogBody = "