detail.js 16 KB

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