123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333 |
- '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 = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
- var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
- var dialogFoot = "<div class=\"sp-dialog-foot\"><input id='delDataTrue' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
- $('.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 () {
- var data = {
- tablename: "SX_XF",
- column: file.COLID,
- routeinfoid: self.routeinfoid,
- fileid: file.FILEID,
- filenames: file.FILENAMES
- }
- $http.post(apiurljs.login + "g2app/abase/deleteUploadFileName", { 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();
- } else {
- sp.dialog("删除失败,请联系管理员!");
- }
- })
- });
- }
- self.browseItem = null;
- self.browse = function (item, n) {
- self.browseItem = item;
- var set_convertType = 0;
- if (item.FILEEXT == "doc") {
- set_convertType = 0;
- } else if (item.FILEEXT == "pdf") {
- set_convertType = 20;
- } else if (item.FILEEXT == "ofd") {
- set_convertType = 570;
- } else {
- set_convertType = 0;
- }
- let postData = {
- convertType: set_convertType,
- fileUrl: apiurljs.login + "g2work/files2/inline/" + (n == 1 ? item.FILEURL.slice(7) : item.FILEPATH.slice(7))
- };
- console.log("路径:" + postData.fileUrl)
- var postCfg_transfer = {
- headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
- transformRequest: function (data) {
- return $.param(data);
- }
- };
- $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
- .success(function (res) {
- if (res.errorcode === 0) {
- $("#iframe_browse").attr("src", res.data.viewUrl);
- } else {
- sp.dialog(res.message);
- }
- });
- }
- self.editItem = null;
- self.Edit = function (item) {
- self.editItem = item;
- var data = {
- method: 1,
- params: {
- userId: self.userName,
- fileId: item.FILEID,
- fileName: item.FILENAME,
- filePath: apiurljs.login + "g2work" + item.FILEPATH,
- userRight: 0, // 用户权限 编辑:UserRightEdit = 0; 只读:UserRightReadonly = 1; 临时只读:UserRightTempReadonly = 2;此时页面上编辑—临时只读按钮,打开只能临时只读,不打开可以进行编辑
- saveFlag: false, /// true:自动保存文档 false:不自动保存文档 (默认为true)
- callbackUrl: apiurljs.login + "g2app/xinfang/uploadFile?fileId=" + item.FILEID + "&fileUrl=" + item.FILEPATH
- }
- };
- console.log("路径:" + data.params.filePath)
- console.log("参数:" + JSON.stringify(data.params))
- $.ajax({
- url: apiurljs.yzFileWo + "api.do",
- data: {
- jsonParams: encodeURIComponent(JSON.stringify(data))
- },
- type: "POST",
- dataType: "json",
- general: false,
- async: false,
- success: function (data) {
- console.log(data);
- if (data) {
- if (data.errorCode === "0") {
- let rst = data.result;
- console.log(rst.urls);
- if (rst && rst.urls) {
- var get_urls = rst.urls;
- console.log(get_urls);
- if (typeof (get_urls) === "string") {
- $timeout(function () {
- $("#iframe_edit").attr("src", get_urls);
- //window.open(get_urls)
- })
- } else {
- console.warn("无效的urls:" + get_urls);
- }
- } else {
- console.warn("ajax响应内容data.result有问题:" + rst);
- }
- } else {
- alert(data.errorMessage);
- }
- } else {
- console.warn("ajax响应内容为空!");
- }
- },
- });
- }
- self.btnSave = function () {
- var data = {
- method: 2,
- params: {
- fileId: self.editItem.FILEID
- }
- };
- $.ajax({
- url: apiurljs.yzFileWo + "api.do",
- data: {
- jsonParams: encodeURIComponent(JSON.stringify(data))
- },
- type: "POST",
- dataType: "json",
- general: false,
- async: false,
- success: function (data) {
- console.log(data);
- if (data && data.errorCode === "0") {
- sp.dialog("保存成功");
- }
- },
- });
- }
- self.editFlag = function (str) {
- if (str == "wps" || str == "doc" || str == "docx" || str == "xls" || str == "xlsx" || str == "et") {
- return true
- } else {
- return false
- }
- }
- //右上角按钮调用方法
- self.btnEvent = function (item) {
- switch (item.CODE) {
- case "SENDLOG": self.RouteList(); break;
- case "PRINTITEM": self.btnPrint(); break;
- case "MEETITEM": self.Meet(); break;
- case "SAVESIGN": self.Qian(); break;
- default: self.forward(item); break;
- }
- }
- //头部下滚冻结
- $(function () {
- //页面高度撑满
- setTimeout(function () {
- if ($(".ibox-content").height() < $(window).height() - 31) {
- $(".ibox-content").css("height", $(window).height() - 31)
- }
- $("#iframe_browse").css("height", $(".ibox-content").height() - 48)
- $("#iframe_edit").css("height", $(".ibox-content").height() - 48)
- }, 1)
- })
- }])
|