123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313 |
- '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: "WJFB_CB",
- 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];
- $(".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])
- }
- self.getTotalFavNum();
- })
- }
- 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(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();
- }])
|