detail.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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. }
  220. $http.post(apiurljs.login + "g2app/dataabase/upFormData", { data: s4.encryptData_CBC(JSON.stringify(updata)) }, postCfg)
  221. .success(function (obj1) { })
  222. }
  223. })
  224. }
  225. //获取附件
  226. self.getAttachList = function () {
  227. if (self.data.WJLY == "WJ") {
  228. var data = {
  229. tablename: "WJFB_CB",
  230. colums: "*",
  231. order: "ID desc",
  232. sqlwhere: { ROUTEINFOID: self.data.FORMROUTEINFOID },
  233. sqlinwhere: "",
  234. sqllikewhere: ""
  235. }
  236. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  237. .success(function (obj) {
  238. var res = strToJson(s4.decryptData_CBC(obj.data));
  239. console.log(res)
  240. $(".sp-news-info").html(base64.decode(res.data[0].FBNR));
  241. self.arrayFile = res.data[0].FJ.length > 0 ? JSON.parse(res.data[0].FJ) : [];
  242. if (self.arrayFile.length > 0) {
  243. self.browse(self.arrayFile[0])
  244. }
  245. })
  246. } else {
  247. var data = {
  248. tablename: "FILE_ATTACH",
  249. colums: "*",
  250. order: "ID desc",
  251. sqlwhere: { ROUTEINFOID: self.data.FORMROUTEINFOID },
  252. sqlinwhere: "",
  253. sqllikewhere: ""
  254. }
  255. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  256. .success(function (obj) {
  257. var res = strToJson(s4.decryptData_CBC(obj.data));
  258. self.arrayFile = res.data;
  259. if (self.arrayFile.length > 0) {
  260. self.browse(self.arrayFile[0])
  261. }
  262. })
  263. }
  264. }
  265. self.browse = function (obj) {
  266. ///20230324---zyg ---永中转换-----start
  267. var set_convertType = 0;
  268. if (obj.FILEEXT == "doc") {
  269. set_convertType = 0;
  270. } else if (obj.FILEEXT == "pdf") {
  271. set_convertType = 20;
  272. } else if (obj.FILEEXT == "ofd") {
  273. set_convertType = 570;
  274. } else {
  275. set_convertType = 0;
  276. }
  277. let postData = {
  278. convertType: set_convertType,
  279. fileUrl: apiurljs.login + "g2work/files2/inline/" + obj.FILEURL.slice(7)
  280. };
  281. var postCfg_transfer = {
  282. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  283. transformRequest: function (data) {
  284. return $.param(data);
  285. }
  286. };
  287. $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
  288. .success(function (res) {
  289. //console.log(res);
  290. if (res.errorcode === 0) {
  291. let rst = res.data;
  292. self.attachUrl = $sce.trustAsResourceUrl(sp.ipChange(rst.viewUrl));
  293. } else {
  294. sp.dialog(res.message);
  295. }
  296. });
  297. }
  298. self.downLoad = function (item) {
  299. window.open(apiurljs.login + "g2work/files/" + item.FILEURL.slice(7))
  300. }
  301. //头部下滚冻结
  302. $(function () {
  303. $(".sp-page-center").eq(1).css("height", $(window).height() - 160)
  304. //$("body").bind("scroll", function () {
  305. // var scrollTop = $("body").scrollTop();
  306. // if (scrollTop == 0) {
  307. // $(".FixTop").removeClass("FixTop");
  308. // }
  309. // if (scrollTop > 35) {
  310. // $(".sp-page-title").parents(".sp-box").addClass("FixTop");
  311. // }
  312. //});
  313. //页面高度撑满
  314. setTimeout(function () {
  315. if ($(".ibox-content").height() < $(window).height() - 31) {
  316. $(".ibox-content").css("height", $(window).height() - 31)
  317. }
  318. }, 1)
  319. })
  320. var editor2;
  321. self.setKindEditor2 = function () {
  322. var options = {
  323. uploadJson: "",
  324. fileManagerJson: '',
  325. filterMode: true,//过滤HTML代码
  326. allowImageUpload: true,
  327. allowFlashUpload: false,
  328. allowMediaUpload: false,
  329. allowFileManager: false,
  330. themeType: 'simple',
  331. items: ['source', '|', 'undo', 'redo', '|', 'preview', 'template', '|',
  332. 'cut', 'copy', 'paste', 'plainpaste', 'wordpaste', '|',
  333. 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', '|',
  334. 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', '|',
  335. 'subscript', 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
  336. 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', '|',
  337. 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|',
  338. 'table', 'hr', 'emoticons', '|', 'pagebreak', 'anchor', '|', 'about'],
  339. //'table', 'image', 'insertfile', 'hr', 'emoticons', 'baidumap', '|',
  340. //'pagebreak', 'anchor', 'link', 'unlink', '|', 'about'],
  341. afterUpload: function (url, data, name) {
  342. this.sync();
  343. }, //图片上传后,将上传内容同步到textarea中
  344. afterBlur: function () {
  345. this.sync();
  346. }, ////失去焦点时,将内容同步到textarea中
  347. afterCreate: function () {
  348. this.sync();
  349. }
  350. }
  351. editor2 = KindEditor.create('#kindEditor_Content', options);
  352. };
  353. self.setKindEditor2();
  354. }])