'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.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken"); self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno"); self.code = sp.getUrlName("code"); self.code1 = sp.getUrlName("code1"); self.id = sp.getUrlName("id"); self.leaf = sp.getUrlName("leaf"); self.return = function () { window.location.href = "list1.html?code=" + self.code + "&code1=" + self.code1 + "&lastReturnPageno=" + self.get_lastReturnPageno + (self.leaf ? "&leaf=1" : "") } var base64 = new Base64(); //声明base解码和编码类 var postCfg = { headers: { 'Content-Type': 'application/json', 'Authorization': "Bearer " + self.get_AccessToken } } self.userDp=""; self.userDpName=""; self.getDP = function () { var data = { userid: self.userId } $http.post(apiurljs.login + "g2app/richang/queryDpInfo", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.userDp = res.data.length == 0 ? "" : res.data[0].CODE; self.userDpName = res.data.length == 0 ? "" : res.data[0].SECTION; self.getZRBM(); self.initReadRecord(); }) } //插入阅读记录 //SX_GGYDJLB 公告阅读记录表 //SX_SCJLB 收藏记录表 self.initReadRecord=function(){ var postData = { "tablename": "SX_GGYDJLB", "data": [] } postData.data.push({ WZMK: "文件发布", //文章模块 WZID: self.id, //文章ID YHID: self.userId, //用户id YHMC: self.userName, //用户名称 YHDWMC: self.userDpName, //用户单位名称 YHDWID: self.userDp, //用户单位ID YDSJ: sp.dateFtt("yyyy-MM-dd hh:mm:ss", new Date()), WZZMK: self.code //文章子模块 }); $http.post(apiurljs.login + "g2app/dataabase/insertDataList", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.getTotalReadNum(); }) .error(function (XMLHttpRequest, textStatus, errorThrown) { }) } //获取阅读量 self.totalReadNum = 0; self.getTotalReadNum=function(){ self.totalReadNum = 0; let postData = { tablename: "SX_GGYDJLB", pagesize: 10, pageno: 1, colums: "ID,SORTID", order: "ID", sqlwhere: {}, sqlorwhere: "", sqlinwhere: "", sqllikewhere: { WZID: self.id, WZMK: "文件发布" } } $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg) .success(function (res) { var res = strToJson(s4.decryptData_CBC(res.data)); self.totalReadNum=res.totalCount; }).error(function (err) { sp.dialog(JSON.stringify(err)); }); } //判断下是否可以点击收藏 self.canFav=false; self.itemFavID=""; self.getTotalFavNum=function(){ let postData = { tablename: "SX_SCJLB", pagesize: 10, pageno: 1, colums: "ID,SORTID", order: "ID", sqlwhere: {}, sqlorwhere: "", sqlinwhere: "", sqllikewhere: { WZID: self.id, YHID: self.userId, //用户id WZMK: "文件发布" } } $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg) .success(function (res) { var res = strToJson(s4.decryptData_CBC(res.data)); if(res.totalCount>0){ self.canFav=false; self.itemFavID=res.data[0].ID; }else{ self.canFav=true; self.itemFavID=""; } }).error(function (err) { sp.dialog(JSON.stringify(err)); }); } //收藏 self.addFav=function(){ var postData = { "tablename": "SX_SCJLB", "data": [] } postData.data.push({ WZMK:"文件发布", //文章模块 WZID:self.id, //文章ID YHID:self.userId, //用户id YHMC:self.userName, //用户名称 YHDWMC:self.userDpName, //用户单位名称 YHDWID:self.userDp, //用户单位ID YDSJ:sp.dateFtt("yyyy-MM-dd hh:mm:ss",new Date()), WZZMK:"" , //文章子模块 WZBT: self.data.WJBT }); $http.post(apiurljs.login + "g2app/dataabase/insertDataList", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.getTotalFavNum(); }) .error(function (XMLHttpRequest, textStatus, errorThrown) { }) } //取消收藏 self.deleteFav=function(){ var data = {"id":self.itemFavID, "tablename": "SX_SCJLB"} //console.log(data); $http.post(apiurljs.login + "g2app/richang/delDataById", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.getTotalFavNum(); }) .error(function (XMLHttpRequest, textStatus, errorThrown) { }) } self.getDP(); self.getZRBM = function () { var data = { ckey: "CODE_ZRBM", routeinfoid: self.routeinfoid } $http.post(apiurljs.login + "g2app/abase/queryDataCode", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg) .success(function (obj) { var res = strToJson(s4.decryptData_CBC(obj.data)); self.ZRBM = res.data.CODE_ZRBM; self.getData() }) } //获取数据 self.getData = function () { var data = { tablename: "SX_FBLIST", colums: "*", order: "ID", sqlwhere: {ID: self.id}, 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.data = res.data[0]; self.ZRBM.forEach(function (item) { if (self.data.FBBM == item.CODE) { self.data.FBBM1 = item.CNAME; } }) console.log(self.data) self.getAttachList() self.getTotalFavNum(); self.getFBLIST2() }) } self.getFBLIST2 = function () { var data = { tablename: "SX_FBLIST_02", colums: "*", order: "ID", sqlwhere: { PID: self.id, USERID: self.userId }, 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)); if (res.data.length > 0) { var updata = { tablename: "SX_FBLIST_02", id: res.data[0].ID, data: { READSTATUS: 1, READTIME: sp.getLocalDate() }, lm: self.code1 } $http.post(apiurljs.login + "g2app/filepublishing/upReadStatusWithfpRedis", { data: s4.encryptData_CBC(JSON.stringify(updata)) }, postCfg) .success(function (obj1) { }) } }) } //获取附件 self.getAttachList = function () { if (self.data.WJLY == "WJ") { var data = { tablename: "WJFB_CB", colums: "*", order: "ID desc", sqlwhere: { ROUTEINFOID: self.data.FORMROUTEINFOID }, 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)); console.log(res) $(".sp-news-info").html(base64.decode(res.data[0].FBNR)); self.arrayFile = res.data[0].FJ.length > 0 ? JSON.parse(res.data[0].FJ) : []; if (self.arrayFile.length > 0) { self.browse(self.arrayFile[0]) } }) } else { var data = { tablename: "FILE_ATTACH", colums: "*", order: "ID desc", sqlwhere: { ROUTEINFOID: self.data.FORMROUTEINFOID }, 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; if (self.arrayFile.length > 0) { self.browse(self.arrayFile[0]) } }) } } self.browse = function (obj) { ///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 { set_convertType = 0; } let postData = { convertType: set_convertType, fileUrl: apiurljs.login + "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) { //console.log(res); if (res.errorcode === 0) { let rst = res.data; self.attachUrl = $sce.trustAsResourceUrl(sp.ipChange(rst.viewUrl)); } else { sp.dialog(res.message); } }); } self.downLoad = function (item) { window.open(apiurljs.login + "g2work/files/" + item.FILEURL.slice(7)) } //头部下滚冻结 $(function () { $(".sp-page-center").eq(1).css("height", $(window).height() - 160) //$("body").bind("scroll", function () { // var scrollTop = $("body").scrollTop(); // if (scrollTop == 0) { // $(".FixTop").removeClass("FixTop"); // } // if (scrollTop > 35) { // $(".sp-page-title").parents(".sp-box").addClass("FixTop"); // } //}); //页面高度撑满 setTimeout(function () { if ($(".ibox-content").height() < $(window).height() - 31) { $(".ibox-content").css("height", $(window).height() - 31) } }, 1) }) var editor2; self.setKindEditor2 = function () { var options = { uploadJson: "", fileManagerJson: '', filterMode: true,//过滤HTML代码 allowImageUpload: true, allowFlashUpload: false, allowMediaUpload: false, allowFileManager: false, themeType: 'simple', items: ['source', '|', 'undo', 'redo', '|', 'preview', 'template', '|', 'cut', 'copy', 'paste', 'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', '|', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', '|', 'subscript', 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/', 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', '|', 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'table', 'hr', 'emoticons', '|', 'pagebreak', 'anchor', '|', 'about'], //'table', 'image', 'insertfile', 'hr', 'emoticons', 'baidumap', '|', //'pagebreak', 'anchor', 'link', 'unlink', '|', 'about'], afterUpload: function (url, data, name) { this.sync(); }, //图片上传后,将上传内容同步到textarea中 afterBlur: function () { this.sync(); }, ////失去焦点时,将内容同步到textarea中 afterCreate: function () { this.sync(); } } editor2 = KindEditor.create('#kindEditor_Content', options); }; self.setKindEditor2(); }])