detail.js 13 KB

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