detail.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385
  1. 'use strict';
  2. var app = angular.module('app', []);
  3. app.controller("formeditCtrl", ["$scope", "$http", "$timeout", '$sce', function ($scope, $http, $timeout, $sce) {
  4. var self = this;
  5. var s4 = new SM4Util();
  6. self.userId = $.cookie("GlWorkPlatform-userid");
  7. self.userName = $.cookie("GlWorkPlatform-chineseName");
  8. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  9. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  10. self.code = sp.getUrlName("code");
  11. self.code1 = sp.getUrlName("code1");
  12. self.id = sp.getUrlName("id");
  13. self.leaf = sp.getUrlName("leaf");
  14. self.return = function () {
  15. window.location.href = "list1.html?code=" + self.code + "&code1=" + self.code1 + "&lastReturnPageno=" + self.get_lastReturnPageno + (self.leaf ? "&leaf=1" : "")
  16. }
  17. var base64 = new Base64(); //声明base解码和编码类
  18. var postCfg = {
  19. headers: {
  20. 'Content-Type': 'application/json',
  21. 'Authorization': "Bearer " + self.get_AccessToken
  22. }
  23. }
  24. self.userDp="";
  25. self.userDpName="";
  26. self.getDP = function () {
  27. var data = {
  28. userid: self.userId
  29. }
  30. $http.post(apiurljs.login + "g2app/richang/queryDpInfo", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  31. .success(function (obj) {
  32. var res = strToJson(s4.decryptData_CBC(obj.data));
  33. self.userDp = res.data.length == 0 ? "" : res.data[0].CODE;
  34. self.userDpName = res.data.length == 0 ? "" : res.data[0].SECTION;
  35. self.getZRBM();
  36. self.initReadRecord();
  37. })
  38. }
  39. //插入阅读记录
  40. //SX_GGYDJLB 公告阅读记录表
  41. //SX_SCJLB 收藏记录表
  42. self.initReadRecord=function(){
  43. var postData = {
  44. "tablename": "SX_GGYDJLB",
  45. "data": []
  46. }
  47. postData.data.push({
  48. WZMK: "文件发布", //文章模块
  49. WZID: self.id, //文章ID
  50. YHID: self.userId, //用户id
  51. YHMC: self.userName, //用户名称
  52. YHDWMC: self.userDpName, //用户单位名称
  53. YHDWID: self.userDp, //用户单位ID
  54. YDSJ: sp.dateFtt("yyyy-MM-dd hh:mm:ss", new Date()),
  55. WZZMK: self.code //文章子模块
  56. });
  57. $http.post(apiurljs.login + "g2app/dataabase/insertDataList", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg)
  58. .success(function (obj) {
  59. var res = strToJson(s4.decryptData_CBC(obj.data));
  60. self.getTotalReadNum();
  61. })
  62. .error(function (XMLHttpRequest, textStatus, errorThrown) {
  63. })
  64. }
  65. //获取阅读量
  66. self.totalReadNum = 0;
  67. self.getTotalReadNum=function(){
  68. self.totalReadNum = 0;
  69. let postData = {
  70. tablename: "SX_GGYDJLB",
  71. pagesize: 10,
  72. pageno: 1,
  73. colums: "ID,SORTID",
  74. order: "ID",
  75. sqlwhere: {},
  76. sqlorwhere: "",
  77. sqlinwhere: "",
  78. sqllikewhere: {
  79. WZID: self.id,
  80. WZMK: "文件发布"
  81. }
  82. }
  83. $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg)
  84. .success(function (res) {
  85. var res = strToJson(s4.decryptData_CBC(res.data));
  86. self.totalReadNum=res.totalCount;
  87. }).error(function (err) {
  88. sp.dialog(JSON.stringify(err));
  89. });
  90. }
  91. //判断下是否可以点击收藏
  92. self.canFav=false;
  93. self.itemFavID="";
  94. self.getTotalFavNum=function(){
  95. let postData = {
  96. tablename: "SX_SCJLB",
  97. pagesize: 10,
  98. pageno: 1,
  99. colums: "ID,SORTID",
  100. order: "ID",
  101. sqlwhere: {},
  102. sqlorwhere: "",
  103. sqlinwhere: "",
  104. sqllikewhere: {
  105. WZID: self.id,
  106. YHID: self.userId, //用户id
  107. WZMK: "文件发布"
  108. }
  109. }
  110. $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg)
  111. .success(function (res) {
  112. var res = strToJson(s4.decryptData_CBC(res.data));
  113. if(res.totalCount>0){
  114. self.canFav=false;
  115. self.itemFavID=res.data[0].ID;
  116. }else{
  117. self.canFav=true;
  118. self.itemFavID="";
  119. }
  120. }).error(function (err) {
  121. sp.dialog(JSON.stringify(err));
  122. });
  123. }
  124. //收藏
  125. self.addFav=function(){
  126. var postData = {
  127. "tablename": "SX_SCJLB",
  128. "data": []
  129. }
  130. postData.data.push({
  131. WZMK:"文件发布", //文章模块
  132. WZID:self.id, //文章ID
  133. YHID:self.userId, //用户id
  134. YHMC:self.userName, //用户名称
  135. YHDWMC:self.userDpName, //用户单位名称
  136. YHDWID:self.userDp, //用户单位ID
  137. YDSJ:sp.dateFtt("yyyy-MM-dd hh:mm:ss",new Date()),
  138. WZZMK:"" , //文章子模块
  139. WZBT: self.data.WJBT
  140. });
  141. $http.post(apiurljs.login + "g2app/dataabase/insertDataList", {data: s4.encryptData_CBC(JSON.stringify(postData))}, postCfg)
  142. .success(function (obj) {
  143. var res = strToJson(s4.decryptData_CBC(obj.data));
  144. self.getTotalFavNum();
  145. })
  146. .error(function (XMLHttpRequest, textStatus, errorThrown) {
  147. })
  148. }
  149. //取消收藏
  150. self.deleteFav=function(){
  151. var data = {"id":self.itemFavID, "tablename": "SX_SCJLB"}
  152. //console.log(data);
  153. $http.post(apiurljs.login + "g2app/richang/delDataById", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  154. .success(function (obj) {
  155. var res = strToJson(s4.decryptData_CBC(obj.data));
  156. self.getTotalFavNum();
  157. })
  158. .error(function (XMLHttpRequest, textStatus, errorThrown) {
  159. })
  160. }
  161. self.getDP();
  162. self.getZRBM = function () {
  163. var data = {
  164. ckey: "CODE_ZRBM",
  165. routeinfoid: self.routeinfoid
  166. }
  167. $http.post(apiurljs.login + "g2app/abase/queryDataCode", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  168. .success(function (obj) {
  169. var res = strToJson(s4.decryptData_CBC(obj.data));
  170. self.ZRBM = res.data.CODE_ZRBM;
  171. self.getData()
  172. })
  173. }
  174. //获取数据
  175. self.getData = function () {
  176. var data = {
  177. tablename: "SX_FBLIST",
  178. colums: "*",
  179. order: "ID",
  180. sqlwhere: {ID: self.id},
  181. sqlinwhere: "",
  182. sqllikewhere: ""
  183. }
  184. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  185. .success(function (obj) {
  186. var res = strToJson(s4.decryptData_CBC(obj.data));
  187. self.data = res.data[0];
  188. self.ZRBM.forEach(function (item) {
  189. if (self.data.FBBM == item.CODE) {
  190. self.data.FBBM1 = item.CNAME;
  191. }
  192. })
  193. console.log(self.data)
  194. self.getAttachList()
  195. self.getTotalFavNum();
  196. self.getFBLIST2()
  197. })
  198. }
  199. self.getFBLIST2 = function () {
  200. var data = {
  201. tablename: "SX_FBLIST_02",
  202. colums: "*",
  203. order: "ID",
  204. sqlwhere: { PID: self.id, USERID: self.userId },
  205. sqlinwhere: "",
  206. sqllikewhere: ""
  207. }
  208. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  209. .success(function (obj) {
  210. var res = strToJson(s4.decryptData_CBC(obj.data));
  211. if (res.data.length > 0) {
  212. var updata = {
  213. tablename: "SX_FBLIST_02",
  214. id: res.data[0].ID,
  215. data: {
  216. READSTATUS: 1,
  217. READTIME: sp.getLocalDate()
  218. },
  219. lm: self.code1
  220. }
  221. $http.post(apiurljs.login + "g2app/filepublishing/upReadStatusWithfpRedis", { data: s4.encryptData_CBC(JSON.stringify(updata)) }, postCfg)
  222. .success(function (obj1) { })
  223. }
  224. })
  225. }
  226. //获取附件
  227. self.getAttachList = function () {
  228. if (self.data.WJLY == "WJ") {
  229. var data = {
  230. tablename: "WJFB_CB",
  231. colums: "*",
  232. order: "ID desc",
  233. sqlwhere: { ROUTEINFOID: self.data.FORMROUTEINFOID },
  234. sqlinwhere: "",
  235. sqllikewhere: ""
  236. }
  237. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  238. .success(function (obj) {
  239. var res = strToJson(s4.decryptData_CBC(obj.data));
  240. console.log(res)
  241. $(".sp-news-info").html(base64.decode(res.data[0].FBNR));
  242. self.arrayFile = res.data[0].FJ.length > 0 ? JSON.parse(res.data[0].FJ) : [];
  243. if (self.arrayFile.length > 0) {
  244. self.browse(self.arrayFile[0])
  245. }
  246. })
  247. } else {
  248. var data = {
  249. tablename: "FILE_ATTACH",
  250. colums: "*",
  251. order: "ID desc",
  252. sqlwhere: { ROUTEINFOID: self.data.FORMROUTEINFOID },
  253. sqlinwhere: "",
  254. sqllikewhere: ""
  255. }
  256. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  257. .success(function (obj) {
  258. var res = strToJson(s4.decryptData_CBC(obj.data));
  259. self.arrayFile = res.data;
  260. if (self.arrayFile.length > 0) {
  261. self.browse(self.arrayFile[0])
  262. }
  263. })
  264. }
  265. }
  266. self.browse = function (obj) {
  267. ///20230324---zyg ---永中转换-----start
  268. var set_convertType = 0;
  269. if (obj.FILEEXT == "doc") {
  270. set_convertType = 0;
  271. } else if (obj.FILEEXT == "pdf") {
  272. set_convertType = 20;
  273. } else if (obj.FILEEXT == "ofd") {
  274. set_convertType = 570;
  275. } else {
  276. set_convertType = 0;
  277. }
  278. let postData = {
  279. convertType: set_convertType,
  280. fileUrl: apiurljs.login + "g2work/files2/inline/" + obj.FILEURL.slice(7)
  281. };
  282. var postCfg_transfer = {
  283. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  284. transformRequest: function (data) {
  285. return $.param(data);
  286. }
  287. };
  288. $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
  289. .success(function (res) {
  290. //console.log(res);
  291. if (res.errorcode === 0) {
  292. let rst = res.data;
  293. self.attachUrl = $sce.trustAsResourceUrl(sp.ipChange(rst.viewUrl));
  294. } else {
  295. sp.dialog(res.message);
  296. }
  297. });
  298. }
  299. self.downLoad = function (item) {
  300. window.open(apiurljs.login + "g2work/files/" + item.FILEURL.slice(7))
  301. }
  302. //头部下滚冻结
  303. $(function () {
  304. $(".sp-page-center").eq(1).css("height", $(window).height() - 160)
  305. //$("body").bind("scroll", function () {
  306. // var scrollTop = $("body").scrollTop();
  307. // if (scrollTop == 0) {
  308. // $(".FixTop").removeClass("FixTop");
  309. // }
  310. // if (scrollTop > 35) {
  311. // $(".sp-page-title").parents(".sp-box").addClass("FixTop");
  312. // }
  313. //});
  314. //页面高度撑满
  315. setTimeout(function () {
  316. if ($(".ibox-content").height() < $(window).height() - 31) {
  317. $(".ibox-content").css("height", $(window).height() - 31)
  318. }
  319. }, 1)
  320. })
  321. var editor2;
  322. self.setKindEditor2 = function () {
  323. var options = {
  324. uploadJson: "",
  325. fileManagerJson: '',
  326. filterMode: true,//过滤HTML代码
  327. allowImageUpload: true,
  328. allowFlashUpload: false,
  329. allowMediaUpload: false,
  330. allowFileManager: false,
  331. themeType: 'simple',
  332. items: ['source', '|', 'undo', 'redo', '|', 'preview', 'template', '|',
  333. 'cut', 'copy', 'paste', 'plainpaste', 'wordpaste', '|',
  334. 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', '|',
  335. 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', '|',
  336. 'subscript', 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
  337. 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', '|',
  338. 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|',
  339. 'table', 'hr', 'emoticons', '|', 'pagebreak', 'anchor', '|', 'about'],
  340. //'table', 'image', 'insertfile', 'hr', 'emoticons', 'baidumap', '|',
  341. //'pagebreak', 'anchor', 'link', 'unlink', '|', 'about'],
  342. afterUpload: function (url, data, name) {
  343. this.sync();
  344. }, //图片上传后,将上传内容同步到textarea中
  345. afterBlur: function () {
  346. this.sync();
  347. }, ////失去焦点时,将内容同步到textarea中
  348. afterCreate: function () {
  349. this.sync();
  350. }
  351. }
  352. editor2 = KindEditor.create('#kindEditor_Content', options);
  353. };
  354. self.setKindEditor2();
  355. }])