attachlist.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination'
  4. ]);
  5. app.controller("formeditCtrl", ["$scope", "$http", "$timeout", '$sce', function ($scope, $http, $timeout, $sce) {
  6. var self = this;
  7. var s4 = new SM4Util();
  8. self.userId = $.cookie("GlWorkPlatform-userid");
  9. self.userName = $.cookie("GlWorkPlatform-chineseName");
  10. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  11. self.get_id = sp.getUrlName("id")
  12. self.routeinfoid = sp.getUrlName("routeinfoid");
  13. self.type = sp.getUrlName("type");
  14. self.get_lastReturn = sp.getUrlName("lastReturn");
  15. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  16. self.return = self.get_lastReturn + ".html?lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.type
  17. var postCfg = {
  18. headers: {
  19. 'Content-Type': 'application/json',
  20. 'Authorization': "Bearer " + self.get_AccessToken
  21. }
  22. };
  23. self.SwenList = [{
  24. VNAME: "文件详情",
  25. TYPE: 1,
  26. PAGE: "list2",
  27. TEMPFORM: "formedt.html?id=" + self.get_id + "&routeinfoid=" + self.routeinfoid + "&lastReturn=" + self.get_lastReturn + "&lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.type
  28. }, {
  29. VNAME: "文件详情",
  30. TYPE: 1,
  31. PAGE: "list3",
  32. TEMPFORM: "submitdetail.html?id=" + self.get_id + "&routeinfoid=" + self.routeinfoid + "&lastReturn=" + self.get_lastReturn + "&lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.type
  33. }, {
  34. VNAME: "文件详情",
  35. TYPE: 2,
  36. TEMPFORM: "submitdetail.html?id=" + self.get_id + "&routeinfoid=" + self.routeinfoid + "&lastReturn=" + self.get_lastReturn + "&lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.type
  37. }, {
  38. VNAME: "附件列表",
  39. TYPE: self.type,
  40. TEMPFORM: "attachlist.html?id=" + self.get_id + "&routeinfoid=" + self.routeinfoid + "&lastReturn=" + self.get_lastReturn + "&lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.type
  41. }]
  42. self.Title = "附件列表"
  43. self.iframeFlag = false;
  44. self.zhengwen = []
  45. self.fujian = [];
  46. self.wendan = [];
  47. self.liuzhuan = [];
  48. self.getSelect = function () {
  49. self.select = { list: [] }
  50. var data = {
  51. tablename: "SYS_SECT",
  52. colums: "*",
  53. order: "SORTID",
  54. sqlwhere: "",
  55. sqlorwhere: "",
  56. sqlinwhere: "",
  57. sqllikewhere: ""
  58. }
  59. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  60. .success(function (obj) {
  61. var res = strToJson(s4.decryptData_CBC(obj.data));
  62. self.select.list = res.data;
  63. self.getData();
  64. })
  65. }
  66. self.getSelect()
  67. self.getData = function () {
  68. var data = {
  69. tablename: "DOCELEMENT_ZL",
  70. colums: "*",
  71. order: "ID",
  72. sqlwhere: { ROUTEINFOID: self.routeinfoid },
  73. sqlorwhere: "",
  74. sqlinwhere: "",
  75. sqllikewhere: ""
  76. };
  77. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  78. .success(function (obj) {
  79. var res = strToJson(s4.decryptData_CBC(obj.data));
  80. self.data = res.data[0];
  81. self.select.list.forEach(function (item) {
  82. if (self.data.ORGANIZATIONMA == item.CODE) {
  83. self.data.ORGANIZATIONMA1 = item.SECTION;
  84. }
  85. })
  86. self.getZhengWen();
  87. })
  88. }
  89. self.getZhengWen = function () {
  90. var ATTACHTYPE;
  91. if ((self.type == 2 || self.get_lastReturn == "list3") && self.data.TABLENAME.indexOf("FW_") > -1) {
  92. ATTACHTYPE = "GDZ_PDF"
  93. } else {
  94. ATTACHTYPE = "CWG_PDF"
  95. }
  96. var data = {
  97. tablename: "DANGANATTACHFILE",
  98. colums: "*",
  99. order: "ID",
  100. sqlwhere: { ROUTEINFOID: self.routeinfoid, ATTACHTYPE: ATTACHTYPE },
  101. sqlorwhere: "",
  102. sqlinwhere: "",
  103. sqllikewhere: ""
  104. };
  105. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  106. .success(function (obj) {
  107. var res = strToJson(s4.decryptData_CBC(obj.data));
  108. self.zhengwen = res.data;
  109. $.each(self.zhengwen, function (index, item) {
  110. item.url = item.FILEURL
  111. item.FILEURL = apiurljs.login.split("glwork")[0] + "glworkweb/" + item.FILEURL
  112. })
  113. if (self.zhengwen.length > 0) {
  114. self.browse1(self.zhengwen[0]);
  115. self.iframeFlag = true;
  116. }
  117. self.getWenDan()
  118. })
  119. //var data = {
  120. // dockind: "D02",
  121. // routeinfoid: self.routeinfoid
  122. //}
  123. //$http.post(apiurljs.login + "g2app/fawenfiles/queryDataList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  124. //.success(function (obj) {
  125. // var res = strToJson(s4.decryptData_CBC(obj.data));
  126. // self.zhengwen = res.data;
  127. // $.each(self.zhengwen, function (index, item) {
  128. // item.url = item.FILEURL
  129. // item.FILEURL = apiurljs.login.split("glwork")[0] + "glworkweb/" + item.FILEURL
  130. // })
  131. // if (self.zhengwen.length > 0) {
  132. // if (self.type == 1 && self.get_lastReturn == "list2") {
  133. // self.browse1(self.zhengwen[0]);
  134. // } else {
  135. // self.browse2(self.zhengwen[0]);
  136. // }
  137. // self.iframeFlag = true;
  138. // }
  139. // self.getWenDan()
  140. //})
  141. };
  142. self.getWenDan = function () {
  143. var ATTACHTYPE;
  144. if ((self.type == 2 || self.get_lastReturn == "list3") && self.data.TABLENAME.indexOf("SW_") > -1) {
  145. ATTACHTYPE = "GDZ_PDF"
  146. } else {
  147. ATTACHTYPE = "FORM_PDF"
  148. }
  149. var data1 = {
  150. tablename: "DANGANATTACHFILE",
  151. colums: "*",
  152. order: "ID",
  153. sqlwhere: { ROUTEINFOID: self.routeinfoid, ATTACHTYPE: ATTACHTYPE },
  154. sqlorwhere: "",
  155. sqlinwhere: "",
  156. sqllikewhere: ""
  157. }
  158. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data1)) }, postCfg)
  159. .success(function (obj) {
  160. var res = strToJson(s4.decryptData_CBC(obj.data));
  161. console.log(res)
  162. $.each(res.data, function (index, item) {
  163. if (item.FILEEXT == "pdf") {
  164. item.url = item.FILEURL
  165. item.FILEURL = apiurljs.login + "g2work/files2/inline/" + item.FILEURL.slice(7)
  166. //item.FILEURL = apiurljs.login + "g2work/files2/inline/" + res.data[0].FILEURL.slice(7)
  167. self.wendan.push(item)
  168. }
  169. })
  170. //self.wendan.push(res.data[0])
  171. if (self.zhengwen.length == 0 && self.wendan.length > 0) {
  172. self.browse1(self.wendan[0]);
  173. self.iframeFlag = true;
  174. }
  175. self.getFuJian();
  176. })
  177. }
  178. self.getFuJian = function () {
  179. var data = {
  180. routeinfoid: self.routeinfoid,
  181. sqlwhere: " and fileext='pdf'",
  182. attachtype: ['FORM_PDF', 'CWG_PDF', 'GDZ_PDF', 'FLOWRECORD_PDF']//['FORM_PDF', 'CWG_PDF', 'GDZ_PDF', 'ZLFILE_PDF']
  183. }
  184. $http.post(apiurljs.login + "g2app/DangAn/getAttachListNotAttachType", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  185. .success(function (obj) {
  186. var res = strToJson(s4.decryptData_CBC(obj.data));
  187. self.fujian = res.data;
  188. $.each(self.fujian, function (index, item) {
  189. item.SIZE = item.FILESIZE >= 104857.6 ? (item.FILESIZE / 1048576).toFixed(2) + "MB" : (item.FILESIZE / 1024).toFixed(2) + "KB";
  190. item.FILEURL = apiurljs.login + "g2work/files2/inline/" + item.FILEURL.slice(7)
  191. })
  192. if (self.zhengwen.length == 0 && self.wendan.length == 0 && self.fujian.length > 0) {
  193. self.browse1(self.fujian[0]);
  194. self.iframeFlag = true;
  195. }
  196. self.getRecord()
  197. })
  198. }
  199. self.getRecord = function () {
  200. var data = {
  201. tablename: "DANGANATTACHFILE",
  202. colums: "*",
  203. order: "ID",
  204. sqlwhere: { ROUTEINFOID: self.routeinfoid, ATTACHTYPE: "FLOWRECORD_PDF" },
  205. sqlorwhere: "",
  206. sqlinwhere: "",
  207. sqllikewhere: ""
  208. };
  209. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  210. .success(function (obj) {
  211. var res = strToJson(s4.decryptData_CBC(obj.data));
  212. self.liuzhuan = res.data;
  213. $.each(self.liuzhuan, function (index, item) {
  214. item.url = item.FILEURL
  215. if (item.FILEEXT == "pdf") {
  216. item.FILEURL = apiurljs.login + "g2work/files2/inline/" + item.FILEURL.slice(7)
  217. } else {
  218. item.FILEURL = apiurljs.login.split("glwork")[0] + "glworkweb/" + item.FILEURL
  219. }
  220. })
  221. console.log(self.liuzhuan)
  222. if (self.zhengwen.length == 0 && self.wendan.length == 0 && self.fujian.length == 0 && self.liuzhuan.length > 0) {
  223. self.browse1(self.liuzhuan[0]);
  224. self.iframeFlag = true;
  225. }
  226. })
  227. }
  228. self.btnDelete = function (ID) {
  229. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  230. var dialogBody = "<div class=\"sp-dialog-body\">您确认要删除此附件吗?</div>";
  231. 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>";
  232. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  233. sp.openCenter(".sp-dialog");
  234. $('.sp-closeDialog').click(function (event) {
  235. sp.dialoghide();
  236. event.preventDefault(); event.stopPropagation();
  237. });
  238. $("#upDataTrue").click(function () {
  239. var data = {
  240. id:ID
  241. }
  242. $http.post(apiurljs.login + "g2app/DangAn/deleteAttach", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  243. .success(function (obj) {
  244. var res = strToJson(s4.decryptData_CBC(obj.data));
  245. if (res.success) {
  246. sp.dialoghide();
  247. self.getFuJian();
  248. }
  249. })
  250. })
  251. }
  252. self.browse1 = function (obj) {
  253. ///20230324---zyg ---永中转换-----start
  254. var set_convertType = 0;
  255. if (obj.FILEEXT == "doc") {
  256. set_convertType = 0;
  257. } else if (obj.FILEEXT == "pdf") {
  258. set_convertType = 20;
  259. } else if (obj.FILEEXT == "ofd") {
  260. set_convertType = 570;
  261. } else {
  262. set_convertType = 0;
  263. }
  264. let postData = {
  265. convertType: set_convertType,
  266. fileUrl: obj.FILEURL
  267. };
  268. var postCfg_transfer = {
  269. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  270. transformRequest: function (data) {
  271. return $.param(data);
  272. }
  273. };
  274. $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
  275. .success(function (res) {
  276. if (res.errorcode === 0) {
  277. let rst = res.data;
  278. $("#iframe").css("width", $(".col-md-10").width() - 10).css("height", 654);
  279. $("#iframe").attr("src", rst.viewUrl)
  280. } else {
  281. sp.dialog(res.message);
  282. }
  283. });
  284. ///20230324---zyg ---永中转换-----end
  285. }
  286. self.btnGui = function () {
  287. if (self.data.ARCHCODE == "" || self.data.ARCHCODE == null || self.data.ARCHCODE == undefined) {
  288. sp.dialog("请先生成档号!");
  289. return
  290. }
  291. var array = ["全宗号", "年度", "件号", "X154", self.data.ARCHYEAR, self.data.JIANHAO, "机构(问题)", "保管期限", "页数", self.data.ORGANIZATIONMA1, self.data.MIJIQIXIAN, self.data.YESHU]
  292. if (self.data.TABLENAME.indexOf("SW") > -1) {
  293. var data = {
  294. data: array,
  295. sourcepath: self.wendan[0].url.slice(6),
  296. routeinfoid: self.routeinfoid,
  297. marginLeft: 430,
  298. marginBottom: 749
  299. }
  300. $http.post(apiurljs.login + "g2app/DangAn/PdfInPng", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  301. .success(function (obj) {
  302. var res = strToJson(s4.decryptData_CBC(obj.data));
  303. //$("#GuiDangZ").attr("src", apiurljs.login + "g2work/files2/inline/" + res.data.slice(6))
  304. var dataStatus = {
  305. tablename: "DOCELEMENT_ZL",
  306. id: self.get_id,
  307. data: {
  308. SENDSTATUS: 3,
  309. MODELMARK: 1
  310. }
  311. }
  312. $http.post(apiurljs.login + "g2app/dataabase/upFormData", { data: s4.encryptData_CBC(JSON.stringify(dataStatus)) }, postCfg)
  313. .success(function (obj1) {
  314. let postData = {
  315. convertType: 20,
  316. fileUrl: apiurljs.login + "g2work/files2/inline/" + res.data.slice(6)
  317. };
  318. var postCfg_transfer = {
  319. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  320. transformRequest: function (data) {
  321. return $.param(data);
  322. }
  323. };
  324. $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
  325. .success(function (res) {
  326. if (res.errorcode === 0) {
  327. let rst = res.data;
  328. //$("#GuiDangZ").attr("src", apiurljs.login + "g2work/files2/inline/" + res.data.slice(6))
  329. $("#GuiDangZ").attr("src", rst.viewUrl)
  330. } else {
  331. sp.dialog(res.message);
  332. }
  333. });
  334. })
  335. })
  336. } else {
  337. var data = {
  338. data: array,
  339. sourcepath: self.zhengwen[0].url,
  340. routeinfoid: self.routeinfoid,
  341. marginLeft: 430,
  342. marginBottom: 749
  343. }
  344. $http.post(apiurljs.login + "g2app/DangAn/PdfInPng", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  345. .success(function (obj) {
  346. var res = strToJson(s4.decryptData_CBC(obj.data));
  347. var dataStatus = {
  348. tablename: "DOCELEMENT_ZL",
  349. id: self.get_id,
  350. data: {
  351. SENDSTATUS: 3
  352. }
  353. }
  354. $http.post(apiurljs.login + "g2app/dataabase/upFormData", { data: s4.encryptData_CBC(JSON.stringify(dataStatus)) }, postCfg)
  355. .success(function (obj1) {
  356. //$("#GuiDangZ").attr("src", apiurljs.login + "g2work/files2/inline//" + res.data.slice(7))
  357. let postData = {
  358. convertType: 20,
  359. fileUrl: apiurljs.login + "g2work/files2/inline/" + res.data.slice(7)
  360. };
  361. var postCfg_transfer = {
  362. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  363. transformRequest: function (data) {
  364. return $.param(data);
  365. }
  366. };
  367. $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
  368. .success(function (res) {
  369. if (res.errorcode === 0) {
  370. let rst = res.data;
  371. $("#GuiDangZ").attr("src", apiurljs.login + "g2work/files2/inline/" + res.data.slice(7))
  372. } else {
  373. sp.dialog(res.message);
  374. }
  375. });
  376. })
  377. })
  378. }
  379. sp.layer("#GDZ")
  380. }
  381. }])