123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310 |
- 'use strict';
- var app = angular.module('app', [
- ]);
- app.controller("formeditCtrl", ["$scope", "$http", "$sce", function ($scope, $http, $sce) {
- var self = this;
- var s4 = new SM4Util();
- self.userName = $.cookie("GlWorkPlatform-chineseName");
- self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
- self.routeinfoid = sp.getUrlName("routeinfoid");
- self.dotype = window.top.sp.getUrlName("dotype");
- var width = window.outerWidth;
- var height = window.outerHeight;
- var postCfg = {
- headers: {
- 'Content-Type': 'application/json',
- 'Authorization': "Bearer " + self.get_AccessToken
- }
- };
- self.getData = function () {
- var data = {
- tablename: "FILE_ATTACH",
- colums: "*",
- order: "ID asc",
- 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));
- self.arrayFile = [];
- res.data.forEach(function (item) {
- self.arrayFile.push(item)
- })
- if (sp.getUrlName("page") != "formedit") {
- self.browse(self.arrayFile[0])
- } else {
- self.getGCG()
- }
- })
- }
- self.getGCG = function () {
- var data = {
- dockind: "D01",
- routeinfoid: self.routeinfoid
- }
- $http.post(apiurljs.login + "g2app/fawenfiles/queryDataList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
- .success(function (obj) {
- var res = strToJson(s4.decryptData_CBC(obj.data));
- if (res.data[0].FILENAMES.split(".").length == 1) {
- res.data[0].FILENAMES = res.data[0].FILENAMES + "." + res.data[0].FILEEXT
- }
- if (res.data[0].FILEURL.indexOf("files") > -1) {
- var set_filepath = apiurljs.yzFcscloud + "g2work/files/" + res.data[0].FILEURL.slice(7);
- } else {
- var set_filepath = apiurljs.yzFcscloud.split("glwork/")[0] + "glworkweb/" + res.data[0].FILEURL;
- }
- self.getFileWo(res.data[0].ID, res.data[0].FILENAMES, set_filepath);
- })
- }
- self.getData()
- $scope.browse = function (obj) {
- if (obj.DOCKIND == "D01") {
- if (obj.FILEURL.indexOf("files") > -1) {
- var set_filepath = apiurljs.yzFcscloud + "g2work/files/" + obj.FILEURL.slice(7);
- } else {
- var set_filepath = apiurljs.yzFcscloud.split("glwork/")[0] + "glworkweb/" + obj.FILEURL;
- }
- self.getFileWo(obj.ID, obj.FILENAMES, set_filepath);
- } else {
- self.browse(obj);
- }
- }
- self.browse = function (obj) {
- var n = 0;
- self.iframeList.forEach(function (item) {
- if (item.title == obj.FILENAMES && item.source == apiurljs.login + "g2work/files2/inline/" + obj.FILEURL.slice(7)) {
- n++
- }
- })
- if (n == 0) {;
- ///20230324---zyg ---永中转换-----start
- var set_convertType = 0;
- if (obj.FILEEXT == "doc") {
- set_convertType = 0;
- } else if (obj.FILEEXT == "pdf") {
- set_convertType = 20;
- } else if (obj.FILEEXT == "ofd") {
- set_convertType = 570;
- } else if (/(png|jpg|jpeg|gif|bmp|jfif|svg|tif|tiff)$/i.test(obj.FILEEXT) == true) {
- set_convertType = 23;
- } else {
- set_convertType = 0;
- }
- let postData = {
- convertType: set_convertType,
- fileUrl: apiurljs.yzFcscloud + "g2work/files2/inline/" + obj.FILEURL.slice(7)
- };
- 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) {
- let rst = res.data;
- self.iframeList.push({ id: self.iframeList.length + 1, title: obj.FILENAMES, url: $sce.trustAsResourceUrl(sp.ipChange(rst.viewUrl)), source: apiurljs.login + "g2work/files2/inline/" + obj.FILEURL.slice(7) })
- self.add()
- } else {
- sp.dialog(res.message);
- }
- });
- ///20230324---zyg ---永中转换-----end
- }
- }
- self.getFileWo = function (fileid, filename, filepath) {
- var n = 0;
- self.iframeList.forEach(function (item) {
- if (item.title == filename && item.source == filepath) {
- n++
- }
- })
- if (n == 0) {
- if (filepath.indexOf("files") > -1) {
- fileid = filepath.split("/")[6];
- }
- var data = {
- method: 1,
- params: {
- userId: self.userName,
- fileId: fileid,
- fileName: filename,
- filePath: filepath,
- userRight: self.dotype == 1 ? 0 : 1,// 用户权限 编辑:UserRightEdit = 0; 只读:UserRightReadonly = 1; 临时只读:UserRightTempReadonly = 2;此时页面上编辑—临时只读按钮,打开只能临时只读,不打开可以进行编辑
- //saveFlag: true, /// true:自动保存文档 false:不自动保存文档 (默认为true)
- callbackUrl: filepath.indexOf("files") > -1 ? apiurljs.login + "g2app/attachfiles/uploadFileAttach" : apiurljs.login + "g2app/fawenfiles/uploadFile"
- }
- };
- $.ajax({
- url: apiurljs.yzFileWo + "api.do",
- data: {
- jsonParams: encodeURIComponent(JSON.stringify(data))
- },
- type: "POST",
- dataType: "json",
- general: false,
- async: false,
- success: function (data) {
- if (data) {
- if (data.errorCode === "0") {
- let rst = data.result;
- if (rst && rst.urls) {
- var get_urls = rst.urls;
- if (typeof (get_urls) === "string") {
- self.iframeList.push({ id: self.iframeList.length + 1, title: filename, url: $sce.trustAsResourceUrl(sp.ipChange(get_urls)), source: filepath, wo: true })
- self.add()
- $scope.$apply();
- } else {
- console.warn("无效的urls:" + get_urls);
- }
- } else {
- console.warn("ajax响应内容data.result有问题:" + rst);
- }
- } else {
- alert(data.errorMessage);
- }
- } else {
- console.warn("ajax响应内容为空!");
- }
- },
- });
- }
- }
- $scope.addGJL = function (name, url) {
- self.addGJL(name, url);
- }
- self.addGJL = function (name, url) {
- var n = 0;
- self.iframeList.forEach(function (item) {
- if (item.title == name && item.source == url) {
- n++
- }
- })
- if (n == 0) {
- self.iframeList.push({ id: self.iframeList.length + 1, title: name, url: $sce.trustAsResourceUrl(url), source: url })
- self.add()
- $scope.$apply();
- }
- }
- self.iframeList = []//[{ id: 1, url: "../../index/img-new/background3.png", source: "../../index/img-new/background3.png", boxWidth: { width: 1200 }, iframeWidth: { width: 1190 } }]
- self.add = function () {
- if (self.iframeList.length == 1) {
- self.iframeList[0].boxWidth = { width: $(".col-md-12").width() }
- self.iframeList[0].iframeWidth = { width: $(".col-md-12").width() - 10 }
- } else {
- self.iframeList.forEach(function (item) {
- item.boxWidth = { width: Math.trunc($(".col-md-12").width() / 4 * 2 / (self.iframeList.length - 1)) - 10 }
- item.iframeWidth = { width: item.boxWidth.width - 10 }
- })
- self.iframeList[self.iframeList.length - 1].boxWidth = { width: Math.trunc($(".col-md-12").width() / 4 * 2) - 10 }
- self.iframeList[self.iframeList.length - 1].iframeWidth = { width: self.iframeList[self.iframeList.length - 1].boxWidth.width - 10 }
- }
- }
- self.openItem = function (obj) {
- window.open(obj.url, obj.title, 'width=' + width + ',height=' + height + ',toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no')
- }
- self.closeItem = function (n) {
- self.iframeList.splice(n, 1)
- if (self.iframeList.length == 0) {
- } else if (self.iframeList.length == 1) {
- self.iframeList[0].boxWidth = { width: $(".col-md-12").width() }
- self.iframeList[0].iframeWidth = { width: $(".col-md-12").width() - 10 }
- } else {
- self.iframeList.forEach(function (item) {
- item.boxWidth = { width: Math.trunc($(".col-md-12").width() / 4 * 2 / (self.iframeList.length - 1)) - 10 }
- item.iframeWidth = { width: item.boxWidth.width - 10 }
- })
- self.iframeList[self.iframeList.length - 1].boxWidth = { width: Math.trunc($(".col-md-12").width() / 4 * 2) - 10 }
- self.iframeList[self.iframeList.length - 1].iframeWidth = { width: self.iframeList[self.iframeList.length - 1].boxWidth.width - 10 }
- }
- }
- self.reSize = function (n) {
- var leftbox = document.getElementsByClassName("iframe-item")[n - 1];
- var rightbox = document.getElementsByClassName("iframe-item")[n];
- var line = document.getElementsByClassName("iframe-border-right")[n - 1];
- document.getElementsByClassName("iframe-border-right")[n - 1].addEventListener("mousedown", function (event) {
- $(".mousemove").show()
- var leftboxW = leftbox.style.width.slice(0, leftbox.style.width.length - 2);
- var rightboxW = rightbox.style.width.slice(0, rightbox.style.width.length - 2);
- var x = event.pageX - line.offsetLeft;
- document.addEventListener("mousemove", boxMove)
- function boxMove(event) {
- if (leftboxW * 1 + (event.pageX - x) * 1 <= 200) {
- //document.removeEventListener("mousemove", boxMove)
- } else if (rightboxW * 1 - (event.pageX - x) * 1 <= 200) {
- //document.removeEventListener("mousemove", boxMove)
- } else {
- leftbox.style.width = leftboxW * 1 + (event.pageX - x) * 1 + "px";
- //leftbox.getElementsByClassName("iframe-title")[0].style.width = leftboxW * 1 + (event.pageX - x) * 1 - 10 + "px";
- leftbox.getElementsByTagName("iframe")[0].style.width = leftboxW * 1 + (event.pageX - x) * 1 - 10 + "px";
- self.iframeList[n - 1].boxWidth.width = leftboxW * 1 + (event.pageX - x) * 1;
- self.iframeList[n - 1].iframeWidth.width = leftboxW * 1 + (event.pageX - x) * 1 - 10;
- rightbox.style.width = rightboxW * 1 - (event.pageX - x) * 1 + "px";
- //rightbox.getElementsByClassName("iframe-title")[0].style.width = rightboxW * 1 - (event.pageX - x) * 1 - 10 + "px";
- rightbox.getElementsByTagName("iframe")[0].style.width = rightboxW * 1 - (event.pageX - x) * 1 - 10 + "px";
- self.iframeList[n].boxWidth.width = rightboxW * 1 - (event.pageX - x) * 1;
- self.iframeList[n].iframeWidth.width = rightboxW * 1 - (event.pageX - x) * 1 - 10;
- }
- }
- document.addEventListener("mouseup", function () {
- $(".mousemove").hide()
- document.removeEventListener("mousemove", boxMove)
- })
- })
- }
- $(function () {
- $(window).resize(function () {
- if (self.iframeList.length > 0) {
- $("#iframeList").css("height", $(window).height())
- $(".mousemove").css("top", $("#iframeList").offset().top).css("left", $("#iframeList").offset().left).css("width", $("#iframeList").width()).css("height", $(window).height())
- if (self.iframeList.length == 1) {
- self.iframeList[0].boxWidth = { width: $(".col-md-12").width() }
- self.iframeList[0].iframeWidth = { width: $(".col-md-12").width() - 10 }
- } else {
- self.iframeList.forEach(function (item) {
- item.boxWidth = { width: Math.trunc($(".col-md-12").width() / 4 * 2 / (self.iframeList.length - 1)) - 10 }
- item.iframeWidth = { width: item.boxWidth.width - 10 }
- })
- self.iframeList[self.iframeList.length - 1].boxWidth = { width: Math.trunc($(".col-md-12").width() / 4 * 2) - 10 }
- self.iframeList[self.iframeList.length - 1].iframeWidth = { width: self.iframeList[self.iframeList.length - 1].boxWidth.width - 10 }
- }
- $scope.$apply();
- }
- })
- })
- }])
- app.directive("repeatFinish", function () {
- return {
- link: function (scope) {
- if (scope.$last == true) {
- $("#iframeList").css("height", $(window).height())
- $(".mousemove").css("top", $("#iframeList").offset().top).css("left", $("#iframeList").offset().left).css("width", $("#iframeList").width()).css("height", $(window).height())
- }
- }
- };
- });
- function openFile(obj) {
- angular.element(document.getElementById('app')).scope().browse(obj);
- }
- function openTool(url, name) {
- angular.element(document.getElementById('app')).scope().addGJL(name, url);
- }
|