yuguidang1.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470
  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.routeinfoid = sp.getUrlName("routeinfoid");
  11. self.id = sp.getUrlName("id");
  12. self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
  13. self.lastReturn = sp.getUrlName("lastReturn")
  14. self.info = JSON.parse($.cookie("GlWorkPlatform-gdsp"))
  15. self.guidangList = []
  16. self.show = 1;
  17. var postCfg = {
  18. headers: {
  19. 'Content-Type': 'application/json',
  20. 'Authorization': "Bearer " + self.get_AccessToken
  21. }
  22. };
  23. self.goBack = function () {
  24. window.location.href = "ygdlist.html?lastReturnPageno=" + sp.getUrlName("lastReturnPageno")
  25. }
  26. //初始化右上角按钮
  27. self.buttonList = []
  28. self.readonly = {
  29. LC: false,
  30. BT: false,
  31. WH: false,
  32. GDCS: false,
  33. GDRY: false,
  34. CSYJ: false,
  35. BZ: false
  36. }
  37. self.getDP = function () {
  38. var data = {
  39. userid: self.userId
  40. }
  41. $http.post(apiurljs.login + "g2app/richang/queryDpInfo", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  42. .success(function (obj) {
  43. var res = strToJson(s4.decryptData_CBC(obj.data));
  44. self.userDpName = res.data.length == 0 ? "" : res.data[0].SECTION;
  45. self.userDpCode = res.data.length == 0 ? "" : res.data[0].CODE;
  46. self.getGDBM();
  47. })
  48. }
  49. self.getDP()
  50. self.getGDBM = function () {
  51. var data = {
  52. unitid: "AA"
  53. }
  54. $http.post(apiurljs.login + "g2app/dataabase/queryDanganSectByCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  55. .success(function (obj) {
  56. var res = strToJson(s4.decryptData_CBC(obj.data));
  57. self.GDBM = res.data;
  58. if (self.routeinfoid == 0) {
  59. self.getWENHAO();
  60. } else {
  61. self.getWENHAO();
  62. }
  63. })
  64. }
  65. self.getWENHAO = function () {
  66. var data = {
  67. routeinfoid: self.routeinfoid,
  68. flowid:self.info.FLOWID
  69. }
  70. $http.post(apiurljs.login + "g2app/DangAn/queryDataByRouteinfoid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  71. .success(function (obj) {
  72. var res = strToJson(s4.decryptData_CBC(obj.data));
  73. if (res.data.length > 0) {
  74. self.WENHAO = res.data[0].WENHAO;
  75. } else {
  76. self.WENHAO = "";
  77. }
  78. self.getData();
  79. })
  80. }
  81. //获取数据
  82. self.getData = function () {
  83. var data = {
  84. tablename: "DA_YGD",
  85. colums: "*",
  86. order: "ID",
  87. sqlwhere: { GLROUTEINFOID: self.routeinfoid },
  88. sqlinwhere: "",
  89. sqllikewhere: ""
  90. }
  91. if (self.lastReturn == "list") {
  92. data.sqlwhere = { ID: sp.getUrlName("ID") }
  93. }
  94. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  95. .success(function (obj) {
  96. var res = strToJson(s4.decryptData_CBC(obj.data));
  97. console.log(res.data)
  98. if (res.data[0]) {
  99. self.data = {
  100. ID: res.data[0].ID,
  101. FONDS_CODE: res.data[0].FONDS_CODE,
  102. SERIES_CODE: res.data[0].SERIES_CODE,
  103. FILE_CODE: res.data[0].FILE_CODE,
  104. TITLE_PROPER: res.data[0].TITLE_PROPER,
  105. DATE_OF_CREATION: sp.format(res.data[0].DATE_OF_CREATION),
  106. OA_ID: res.data[0].OA_ID,
  107. OFFICE_ARCHIVAL_CODE: res.data[0].OFFICE_ARCHIVAL_CODE,
  108. AUTHOR: res.data[0].AUTHOR,
  109. AMOUNT_OF_PAGES: res.data[0].AMOUNT_OF_PAGES,
  110. YEAR_CODE: res.data[0].YEAR_CODE,
  111. ITEM_NO: res.data[0].ITEM_NO,
  112. ITEM_COUNT: res.data[0].ITEM_COUNT,
  113. RETENTION_PERIOD: res.data[0].RETENTION_PERIOD,
  114. FILING_DEPT: res.data[0].FILING_DEPT,
  115. FILENAME: res.data[0].FILENAME,
  116. ZHANGTOP: res.data[0].ZHANGTOP,
  117. ZHANGLEFT: res.data[0].ZHANGLEFT
  118. }
  119. } else {
  120. self.data = {
  121. ID: 0,
  122. FONDS_CODE: "X154",
  123. SERIES_CODE: "WS",
  124. FILE_CODE: self.WENHAO,
  125. TITLE_PROPER: self.info.TITLE,
  126. DATE_OF_CREATION: "",
  127. OA_ID: "",
  128. OFFICE_ARCHIVAL_CODE:"",
  129. AUTHOR:"",
  130. AMOUNT_OF_PAGES:"",
  131. YEAR_CODE: sp.currentYear(),
  132. ITEM_NO: "",
  133. ITEM_COUNT:"",
  134. RETENTION_PERIOD:"D10",
  135. FILING_DEPT: self.userDpName,
  136. FILENAME:"",
  137. ZHANGTOP: "",
  138. ZHANGLEFT: "",
  139. GLROUTEINFOID: self.routeinfoid,
  140. CDATE: sp.getLocalDate(),
  141. STATUS:0
  142. }
  143. }
  144. self.getYGD()
  145. })
  146. }
  147. self.getYGD = function () {
  148. var data = {
  149. routeinfoid: self.routeinfoid,
  150. converttype: "3"
  151. }
  152. $http.post(apiurljs.login + "g2app/DangAn/queryYJYGDWenJianList",{ data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  153. .success(function (obj) {
  154. var res = strToJson(s4.decryptData_CBC(obj.data));
  155. self.fileList = res.data[0].DATA;
  156. self.getGDFile();
  157. })
  158. }
  159. self.getGDFile = function () {
  160. var data = {
  161. tablename: "DA_YJYGDFILEATTACH",
  162. colums: "*",
  163. order: "SORTID",
  164. sqlwhere: { ROUTEINFOID: self.data.ID },
  165. sqlinwhere: "",
  166. sqllikewhere: ""
  167. }
  168. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  169. .success(function (obj) {
  170. var res = strToJson(s4.decryptData_CBC(obj.data));
  171. self.guidangList = res.data.filter(function (item) { return item.ATTACHTYPE == "" });
  172. self.fileList.forEach(function (item) {
  173. var n = 0;
  174. self.guidangList.forEach(function (item1) {
  175. if (item.WENJIANMING == item1.FILENAMES) {
  176. item.show = false;
  177. n++
  178. }
  179. })
  180. if (n == 0) {
  181. item.show = true;
  182. }
  183. })
  184. $("#table_tbody").sortable({
  185. cursor: "move",
  186. stop: function (event, ui) {
  187. var index = 1;
  188. $("#table_tbody").children().each(function (x) {
  189. $(this).attr("index", index)
  190. $(this).children().eq(0).html(index)
  191. index++
  192. })
  193. }
  194. }).disableSelection();
  195. })
  196. }
  197. //保存提交
  198. self.btnSave = function () {
  199. if (spngvld.submit(".formedit")) {
  200. var data = {
  201. tablename: "DA_YGD",
  202. id: self.data.ID,
  203. data: {
  204. FONDS_CODE: self.data.FONDS_CODE,
  205. SERIES_CODE: self.data.SERIES_CODE,
  206. FILE_CODE: self.data.FILE_CODE,
  207. TITLE_PROPER: self.data.TITLE_PROPER,
  208. DATE_OF_CREATION: self.data.DATE_OF_CREATION,
  209. OA_ID: self.data.OA_ID,
  210. OFFICE_ARCHIVAL_CODE: self.data.OFFICE_ARCHIVAL_CODE,
  211. AUTHOR: self.data.AUTHOR,
  212. AMOUNT_OF_PAGES: self.data.AMOUNT_OF_PAGES,
  213. YEAR_CODE: self.data.YEAR_CODE,
  214. ITEM_NO: self.data.ITEM_NO,
  215. ITEM_COUNT: self.data.ITEM_COUNT,
  216. RETENTION_PERIOD: self.data.RETENTION_PERIOD,
  217. FILING_DEPT: self.data.FILING_DEPT,
  218. FILENAME: self.data.FILENAME,
  219. ZHANGTOP: self.data.ZHANGTOP,
  220. ZHANGLEFT: self.data.ZHANGLEFT,
  221. GLROUTEINFOID: self.data.GLROUTEINFOID,
  222. CDATE: self.data.CDATE,
  223. STATUS: self.data.STATUS
  224. }
  225. }
  226. $http.post(apiurljs.login + "g2app/dataabase/saveChildData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  227. .success(function (obj) {
  228. var res = strToJson(s4.decryptData_CBC(obj.data));
  229. if (res.code == 0) {
  230. self.id = res.data.ID;
  231. self.getData()
  232. self.show = 2;
  233. } else {
  234. sp.dialog(res.message)
  235. }
  236. })
  237. }
  238. }
  239. self.addFile = function (obj) {
  240. var data = {
  241. tablename: "DA_YJYGDFILEATTACH",
  242. data: {
  243. FILENAMES: obj.WENJIANMING,
  244. FILEOLDNAME: obj.WENJIANMING,
  245. FILEEXT: obj.PREFIX,
  246. FILESIZE: "",
  247. FILEDATE: obj.RIQI,
  248. FILEID: "",
  249. FILEURL: obj.URL,
  250. FILETBURL: "",
  251. ATTACHTYPE: "",
  252. FILECDATE: "",
  253. CONVERTID: "",
  254. FILEPAGE: obj.YESHU,
  255. ROUTEINFOID: self.data.ID
  256. }
  257. }
  258. $http.post(apiurljs.login + "g2app/dataabase/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  259. .success(function (obj) {
  260. var res = strToJson(s4.decryptData_CBC(obj.data));
  261. if (res.success) {
  262. self.getYGD();
  263. } else {
  264. sp.dialog(res.message);
  265. }
  266. })
  267. }
  268. self.delFile = function (obj) {
  269. var data = {
  270. tablename: "DA_YJYGDFILEATTACH",
  271. id: obj.ID
  272. };
  273. $http.post(apiurljs.login + "g2app/dataabase/delDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  274. .success(function (obj) {
  275. var res = strToJson(s4.decryptData_CBC(obj.data));
  276. if (res.success) {
  277. self.getYGD();
  278. } else {
  279. sp.dialog(res.message);
  280. }
  281. });
  282. }
  283. self.sortUp = function (num) {
  284. var IDS = [{ ID: self.guidangList[num].ID }, { ID: self.guidangList[num - 1].ID }]
  285. var SORTIDS = [{ SORTID: self.guidangList[num - 1].SORTID }, { SORTID: self.guidangList[num].SORTID }]
  286. var data = {
  287. entity: "DA_YJYGDFILEATTACH",
  288. data: SORTIDS,
  289. setwhere: IDS
  290. }
  291. $http.post(apiurljs.login + "g2app/Data/UpdataByWhereList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  292. .success(function (obj) {
  293. var res = strToJson(s4.decryptData_CBC(obj.data));
  294. if (res.success) {
  295. self.getGDFile();
  296. } else {
  297. sp.dialog(res.message);
  298. }
  299. })
  300. }
  301. self.sortDown = function (num) {
  302. var IDS = [{ ID: self.guidangList[num].ID }, { ID: self.guidangList[num + 1].ID }]
  303. var SORTIDS = [{ SORTID: self.guidangList[num + 1].SORTID }, { SORTID: self.guidangList[num].SORTID }]
  304. var data = {
  305. entity: "DA_YJYGDFILEATTACH",
  306. data: SORTIDS,
  307. setwhere: IDS
  308. }
  309. $http.post(apiurljs.login + "g2app/Data/UpdataByWhereList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  310. .success(function (obj) {
  311. var res = strToJson(s4.decryptData_CBC(obj.data));
  312. if (res.success) {
  313. self.getGDFile();
  314. } else {
  315. sp.dialog(res.message);
  316. }
  317. })
  318. }
  319. self.uploading = false;
  320. self.upload = function () {
  321. //var uploadformat = strToJson(s4.decryptData_CBC(apiurljs.uploadformat)).data.map(function (item) {
  322. // return item.CNAME
  323. //})
  324. $('#fileupload').fileupload({
  325. url: apiurljs.login + 'g2app/abase/uploadFileWithForm',
  326. dataType: 'json',
  327. beforeSend: function (xhr, data) {
  328. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  329. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=DA_YJYGDFILEATTACH,routeinfoid=" + self.data.ID));
  330. },
  331. add: function (e, data) {
  332. var num = 0;
  333. //var acceptFileTypes = eval('/(' + uploadformat.join("|") + ')$/i')
  334. var acceptFileTypes = eval('/(pdf)$/i')
  335. //文件类型判断
  336. $.each(data.originalFiles, function (index, item) {
  337. if (item['type'].length > 0 && !acceptFileTypes.test(item['name'])) {
  338. //sp.dialog("您好,请上传" + uploadformat.join("/") + "格式的文件!");
  339. sp.dialog("您好,请上传pdf格式的文件!");
  340. return;
  341. } else {
  342. num++
  343. }
  344. })
  345. if (num == data.originalFiles.length) {
  346. self.uploading = true;
  347. data.submit();
  348. $scope.$apply();
  349. }
  350. },
  351. // 上传完成后的执行逻辑
  352. done: function (e, data) {
  353. self.uploading = false;
  354. self.getGDFile()
  355. }
  356. })
  357. }
  358. self.btnSaveFiles = function () {
  359. var IDS = [], SORTIDS = [];
  360. self.guidangList.forEach(function (item) {
  361. $("#table_tbody").children().each(function (index) {
  362. if ($(this).attr("data-col") == item.ID) {
  363. IDS.push({ ID: item.ID })
  364. SORTIDS.push({ SORTID: self.guidangList[$(this).attr("index") - 1].SORTID })
  365. }
  366. })
  367. })
  368. var data = {
  369. entity: "DA_YJYGDFILEATTACH",
  370. data: SORTIDS,
  371. setwhere: IDS
  372. }
  373. $http.post(apiurljs.login + "g2app/Data/UpdataByWhereList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  374. .success(function (obj) {
  375. var res = strToJson(s4.decryptData_CBC(obj.data));
  376. if (res.success) {
  377. self.getGDFile();
  378. } else {
  379. sp.dialog(res.message);
  380. }
  381. })
  382. }
  383. self.MergeByFile = function () {
  384. var data = {
  385. files: [],
  386. converttype: 3,
  387. routeinfoid: self.data.ID,
  388. gdzdata: ['全宗号', '年度', '件号', "X154", self.data.YEAR_CODE, self.data.ITEM_NO, '机构', '保管期限', '页数', self.data.FILING_DEPT, self.data.RETENTION_PERIOD, self.data.AMOUNT_OF_PAGES],
  389. marginLeft: 755,//self.data.ZHANGLEFT,
  390. marginBottom: 440//self.data.ZHANGTOP
  391. }
  392. self.guidangList.forEach(function (item) {
  393. data.files.push({ fileurl: item.FILEURL })
  394. })
  395. $http.post(apiurljs.login + "g2app/DangAn/queryYJYGDMergeByFile", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  396. .success(function (obj) {
  397. var res = strToJson(s4.decryptData_CBC(obj.data));
  398. self.seeFiles(res.data.DATA,1)
  399. self.show = 3;
  400. })
  401. }
  402. // 查看文件
  403. self.seeFiles = function (obj,n) {
  404. var set_convertType = 0;
  405. if (n == 3) {
  406. obj.FILEURL = obj.URL;
  407. obj.FILEEXT = obj.PREFIX;
  408. }
  409. if (obj.FILEEXT == "doc") {
  410. set_convertType = 0;
  411. } else if (obj.FILEEXT == "pdf") {
  412. set_convertType = 20;
  413. } else if (obj.FILEEXT == "ofd") {
  414. set_convertType = 570;
  415. } else {
  416. set_convertType = 0;
  417. }
  418. let postData = {
  419. convertType: set_convertType,
  420. isSignature: 1,
  421. fileUrl: apiurljs.login + "g2work/files2/inline/" + obj.FILEURL.slice(7)
  422. };
  423. var postCfg_transfer = {
  424. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  425. transformRequest: function (data) {
  426. return $.param(data);
  427. }
  428. };
  429. $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
  430. .success(function (res) {
  431. if (res.errorcode === 0) {
  432. if (n == 1) {
  433. $("#filesId").attr("src", res.data.viewUrl)
  434. } else {
  435. window.open(res.data.viewUrl)
  436. }
  437. } else {
  438. sp.dialog(res.message);
  439. }
  440. });
  441. }
  442. //头部下滚冻结
  443. $(function () {
  444. $(".sp-page-center").css("max-height", $(window).height() - 58).css("height", $(window).height() - 58)
  445. //页面高度撑满
  446. setTimeout(function () {
  447. if ($(".ibox-content").height() < $(window).height() - 31) {
  448. $(".ibox-content").css("height", $(window).height() - 31)
  449. }
  450. }, 1)
  451. })
  452. }])