attachlist.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. 'use strict';
  2. var app = angular.module('app', [
  3. ]);
  4. //定义一个全局的截图插件变量
  5. var cropper;
  6. app.controller("formeditCtrl", ["$scope", "$http", "$timeout", "$sce", function ($scope, $http, $timeout, $sce) {
  7. var self = this;
  8. var s4 = new SM4Util();
  9. self.userId = $.cookie("GlWorkPlatform-userid");
  10. self.userName = $.cookie("GlWorkPlatform-chineseName");
  11. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  12. self.routeid = sp.getUrlName("routeid");
  13. self.routeinfoid = sp.getUrlName("routeinfoid");
  14. self.directionid = sp.getUrlName("directionid");
  15. self.formeditid = sp.getUrlName("formeditid");
  16. self.docmode = sp.getUrlName("docmode");
  17. self.dotype = sp.getUrlName("dotype");
  18. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  19. self.get_lastReturnPage = sp.getUrlName("lastReturnPage");
  20. self.get_type = sp.getUrlName("type");
  21. if (self.get_lastReturnPage != "") {
  22. self.return = "../../../" + self.get_lastReturnPage + "?lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.get_type
  23. } else {
  24. self.return = "../list.html?lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.get_type
  25. }
  26. var postCfg = {
  27. headers: {
  28. 'Content-Type': 'application/json',
  29. 'Authorization': "Bearer " + self.get_AccessToken
  30. }
  31. };
  32. self.video = false;
  33. self.QianPi = false;
  34. self.watchNum = 0;
  35. //初始化右上角按钮
  36. self.buttonList = []
  37. var uploadformat = window.top.uploadformat.map(function (item) {
  38. return item.CNAME
  39. })
  40. self.getSwenList = function () {
  41. self.SwenList = [];
  42. var data = {
  43. directionid: self.directionid,
  44. userid: self.userId,
  45. routeinfoid: self.routeinfoid,
  46. routeid: self.routeid,
  47. formeditid: ""
  48. }
  49. $http.post(apiurljs.login + "g2app/abase/queryDataLink", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  50. .success(function (obj) {
  51. var res = strToJson(s4.decryptData_CBC(obj.data));
  52. $.each(res.data.LINKS, function (index, item) {
  53. if (item.TEMPFORM.indexOf("attachlist.html") > -1) {
  54. self.Title = item.VNAME;
  55. }
  56. if (item.TEMPFORM.indexOf("?docmode") > 0) {
  57. if (item.TEMPFORM.indexOf("attachlist") > -1) {
  58. item.TEMPFORM = item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
  59. } else {
  60. item.TEMPFORM = "../" + item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
  61. }
  62. } else {
  63. item.TEMPFORM = "#";
  64. }
  65. self.SwenList.push(item)
  66. })
  67. self.SwenList.push({
  68. VNAME: "流程图",
  69. DIRECTIONID: self.SwenList[0].DIRECTIONID,
  70. TEMPFORM: "modeler_read.html?" + self.SwenList[0].TEMPFORM.split("?")[1]
  71. })
  72. self.getSelect()
  73. })
  74. }
  75. self.getSwenList(0)
  76. self.iframeFlag = false;
  77. self.zhengwen = []
  78. self.fujian = [];
  79. self.wendan = [];
  80. self.liuzhuan = [];
  81. self.getSelect = function () {
  82. var data = {
  83. tablename: "SYS_SECT",
  84. colums: "*",
  85. order: "SORTID",
  86. sqlwhere: "",
  87. sqlorwhere: "",
  88. sqlinwhere: "",
  89. sqllikewhere: ""
  90. }
  91. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  92. .success(function (obj) {
  93. var res = strToJson(s4.decryptData_CBC(obj.data));
  94. self.ORGANIZATIONMA = res.data;
  95. self.getData();
  96. })
  97. }
  98. self.getData = function () {
  99. var data = {
  100. tablename: "DA_DASP",
  101. colums: "*",
  102. order: "ID",
  103. sqlwhere: { ROUTEINFOID: self.routeinfoid },
  104. sqlorwhere: "",
  105. sqlinwhere: "",
  106. sqllikewhere: ""
  107. };
  108. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  109. .success(function (obj) {
  110. var res = strToJson(s4.decryptData_CBC(obj.data));
  111. self.data = res.data[0];
  112. self.ORGANIZATIONMA.forEach(function (item) {
  113. if (self.data.ORGANIZATIONMA == item.CODE) {
  114. self.data.ORGANIZATIONMA1 = item.SECTION;
  115. }
  116. })
  117. self.getZhengWen();
  118. })
  119. }
  120. self.getZhengWen = function () {
  121. var ATTACHTYPE;
  122. if ((self.type == 2 || self.get_lastReturn == "list3") && self.data.TABLENAME.indexOf("FW_") > -1) {
  123. ATTACHTYPE = "GDZ_PDF"
  124. } else {
  125. ATTACHTYPE = "CWG_PDF"
  126. }
  127. var data = {
  128. tablename: "DANGANATTACHFILE",
  129. colums: "*",
  130. order: "ID",
  131. sqlwhere: { ROUTEINFOID: self.data.DAROUTEINFOID, ATTACHTYPE: ATTACHTYPE },
  132. sqlorwhere: "",
  133. sqlinwhere: "",
  134. sqllikewhere: ""
  135. };
  136. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  137. .success(function (obj) {
  138. var res = strToJson(s4.decryptData_CBC(obj.data));
  139. self.zhengwen = res.data;
  140. $.each(self.zhengwen, function (index, item) {
  141. item.url = item.FILEURL
  142. item.FILEURL = apiurljs.login.split("glwork")[0] + "glworkweb/" + item.FILEURL
  143. })
  144. if (self.zhengwen.length > 0) {
  145. self.browse1(self.zhengwen[0]);
  146. self.iframeFlag = true;
  147. }
  148. self.getWenDan()
  149. })
  150. };
  151. self.getWenDan = function () {
  152. var ATTACHTYPE;
  153. if ((self.type == 2 || self.get_lastReturn == "list3") && self.data.TABLENAME.indexOf("SW_") > -1) {
  154. ATTACHTYPE = "GDZ_PDF"
  155. } else {
  156. ATTACHTYPE = "FORM_PDF"
  157. }
  158. var data1 = {
  159. tablename: "DANGANATTACHFILE",
  160. colums: "*",
  161. order: "ID",
  162. sqlwhere: { ROUTEINFOID: self.data.DAROUTEINFOID, ATTACHTYPE: ATTACHTYPE },
  163. sqlorwhere: "",
  164. sqlinwhere: "",
  165. sqllikewhere: ""
  166. }
  167. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data1)) }, postCfg)
  168. .success(function (obj) {
  169. var res = strToJson(s4.decryptData_CBC(obj.data));
  170. $.each(res.data, function (index, item) {
  171. if (item.FILEEXT == "pdf") {
  172. item.url = item.FILEURL
  173. item.FILEURL = apiurljs.login + "g2work/files2/inline/" + item.FILEURL.slice(7)
  174. //item.FILEURL = apiurljs.login + "g2work/files2/inline/" + res.data[0].FILEURL.slice(7)
  175. self.wendan.push(item)
  176. }
  177. })
  178. //self.wendan.push(res.data[0])
  179. if (self.zhengwen.length == 0 && self.wendan.length > 0) {
  180. self.browse1(self.wendan[0]);
  181. self.iframeFlag = true;
  182. }
  183. self.getFuJian(0);
  184. })
  185. }
  186. self.getFuJian = function (n) {
  187. var data = {
  188. routeinfoid: self.routeinfoid,
  189. sqlwhere: "",
  190. attachtype: ['FORM_PDF', 'CWG_PDF', 'GDZ_PDF', 'FLOWCONVERTFILE']
  191. }
  192. $http.post(apiurljs.login + "g2app/DangAn/getAttachListNotAttachTypeByYJYGD", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  193. .success(function (obj) {
  194. var res = strToJson(s4.decryptData_CBC(obj.data));
  195. self.fujian = res.data;
  196. $.each(self.fujian, function (index, item) {
  197. item.SIZE = item.FILESIZE >= 104857.6 ? (item.FILESIZE / 1048576).toFixed(2) + "MB" : (item.FILESIZE / 1024).toFixed(2) + "KB";
  198. item.FILEURL = apiurljs.login + "g2work/files2/inline/" + item.FILEURL.slice(7)
  199. })
  200. if (self.zhengwen.length == 0 && self.wendan.length == 0 && self.fujian.length > 0) {
  201. self.browse1(self.fujian[0]);
  202. self.iframeFlag = true;
  203. }
  204. if (n == 0) {
  205. self.getRecord()
  206. }
  207. })
  208. }
  209. self.getRecord = function () {
  210. var data = {
  211. tablename: "DANGANATTACHFILE",
  212. colums: "*",
  213. order: "ID",
  214. sqlwhere: { ROUTEINFOID: self.data.DAROUTEINFOID, ATTACHTYPE: "FLOWRECORD_PDF" },
  215. sqlorwhere: "",
  216. sqlinwhere: "",
  217. sqllikewhere: ""
  218. };
  219. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  220. .success(function (obj) {
  221. var res = strToJson(s4.decryptData_CBC(obj.data));
  222. self.liuzhuan = res.data;
  223. $.each(self.liuzhuan, function (index, item) {
  224. item.url = item.FILEURL
  225. if (item.FILEEXT == "pdf") {
  226. item.FILEURL = apiurljs.login + "g2work/files2/inline/" + item.FILEURL.slice(7)
  227. } else {
  228. item.FILEURL = apiurljs.login.split("glwork")[0] + "glworkweb/" + item.FILEURL
  229. }
  230. })
  231. if (self.zhengwen.length == 0 && self.wendan.length == 0 && self.fujian.length == 0 && self.liuzhuan.length > 0) {
  232. self.browse1(self.liuzhuan[0]);
  233. self.iframeFlag = true;
  234. }
  235. })
  236. }
  237. self.uploading = false;
  238. self.upload = function () {
  239. $('#fileupload').fileupload({
  240. url: apiurljs.login + 'g2app/abase/uploadFileWithFormBackid',
  241. dataType: 'json',
  242. beforeSend: function (xhr, data) {
  243. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  244. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=FILE_ATTACH,routeinfoid=" + self.routeinfoid + ",ATTACHTYPE=归档审批"));
  245. },
  246. add: function (e, data) {
  247. var num = 0;
  248. //var acceptFileTypes = eval('/(' + uploadformat.join("|") + ')$/i')
  249. //文件类型判断
  250. $.each(data.originalFiles, function (index, item) {
  251. //if (item['type'].length > 0 && !acceptFileTypes.test(item['name'])) {
  252. // sp.dialog("您好,请上传" + uploadformat.join("/") + "格式的文件!");
  253. // return;
  254. //} else {
  255. num++
  256. //}
  257. })
  258. if (num == data.originalFiles.length) {
  259. self.uploading = true;
  260. data.submit(); $scope.$apply();
  261. }
  262. },
  263. // 上传完成后的执行逻辑
  264. done: function (e, data) {
  265. self.uploading = false;
  266. console.log(strToJson(s4.decryptData_CBC(data.result.data)).data.currentid)
  267. var postData = {
  268. id: strToJson(s4.decryptData_CBC(data.result.data)).data.currentid,
  269. routeinfoid: self.routeinfoid
  270. }
  271. $http.post(apiurljs.login + "g2app/DangAn/convertPdfAndUpPage", { data: s4.encryptData_CBC(JSON.stringify(postData)) }, postCfg)
  272. .success(function (obj) {
  273. self.getFuJian(1)
  274. })
  275. }
  276. })
  277. }
  278. self.downLoad = function (item) {
  279. window.open(apiurljs.login + "g2work/files/" + item.FILEURL.slice(7))
  280. }
  281. self.btnDelete = function (ID) {
  282. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  283. var dialogBody = "<div class=\"sp-dialog-body\">您确认要删除此附件吗?</div>";
  284. var dialogFoot = "<div class=\"sp-dialog-foot\"><input id='upDataTrue' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
  285. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  286. sp.openCenter(".sp-dialog");
  287. $('.sp-closeDialog').click(function (event) {
  288. sp.dialoghide();
  289. event.preventDefault(); event.stopPropagation();
  290. });
  291. $("#upDataTrue").click(function () {
  292. var data = {
  293. id: ID
  294. };
  295. $http.post(apiurljs.login + "g2app/DangAn/delAttachByidWithYJYGD", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  296. .success(function (obj) {
  297. var res = strToJson(s4.decryptData_CBC(obj.data));
  298. sp.dialoghide();
  299. if (res.success) {
  300. self.getFuJian(1);
  301. } else {
  302. sp.dialog("删除失败,请联系管理员!");
  303. }
  304. });
  305. })
  306. }
  307. self.browse1 = function (obj) {
  308. ///20230324---zyg ---永中转换-----start
  309. var set_convertType = 0;
  310. if (obj.FILEEXT == "doc") {
  311. set_convertType = 0;
  312. } else if (obj.FILEEXT == "pdf") {
  313. set_convertType = 20;
  314. } else if (obj.FILEEXT == "ofd") {
  315. set_convertType = 570;
  316. } else {
  317. set_convertType = 0;
  318. }
  319. let postData = {
  320. convertType: set_convertType,
  321. fileUrl: obj.FILEURL
  322. };
  323. var postCfg_transfer = {
  324. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  325. transformRequest: function (data) {
  326. return $.param(data);
  327. }
  328. };
  329. $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
  330. .success(function (res) {
  331. if (res.errorcode === 0) {
  332. let rst = res.data;
  333. $("#iframe").css("width", $(".col-md-10").width() - 10).css("height", 715);
  334. $("#iframe").attr("src", rst.viewUrl)
  335. } else {
  336. sp.dialog(res.message);
  337. }
  338. });
  339. ///20230324---zyg ---永中转换-----end
  340. }
  341. //头部下滚冻结
  342. $(function () {
  343. //页面高度撑满
  344. setTimeout(function () {
  345. if ($(".wrapper-content").height() < $(window).height() - 11) {
  346. $(".wrapper-content").css("height", $(window).height() - 11)
  347. }
  348. $(".sp-line-gray").next("div").css("height", $(".wrapper-content").height() - 119)
  349. }, 1)
  350. })
  351. }])