submitdetail.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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.get_id = sp.getUrlName("id")
  11. self.routeinfoid = sp.getUrlName("routeinfoid");
  12. self.type = sp.getUrlName("type");
  13. self.get_lastReturn = sp.getUrlName("lastReturn");
  14. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  15. self.return = self.get_lastReturn + ".html?type=" + self.type + "&lastReturnPageno=" + self.get_lastReturnPageno
  16. var postCfg = {
  17. headers: {
  18. 'Content-Type': 'application/json',
  19. 'Authorization': "Bearer " + self.get_AccessToken
  20. }
  21. };
  22. self.SwenList = [{
  23. VNAME: "文件详情",
  24. TEMPFORM: "submitdetail.html?id=" + self.get_id + "&routeinfoid=" + self.routeinfoid + "&lastReturn=" + self.get_lastReturn + "&lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.type
  25. }, {
  26. VNAME: "附件列表",
  27. TEMPFORM: "attachlist.html?id=" + self.get_id + "&routeinfoid=" + self.routeinfoid + "&lastReturn=" + self.get_lastReturn + "&lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.type
  28. }]
  29. self.Title = "文件详情";
  30. self.select = {};
  31. self.getJIGOU = function () {
  32. var data = { tablename: "CODE_AGENCIES" }
  33. $http.post(apiurljs.login + "g2app/DangAn/queryCodeData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  34. .success(function (obj) {
  35. var res = strToJson(s4.decryptData_CBC(obj.data));
  36. self.select.list = res.data;
  37. self.getData();
  38. })
  39. }
  40. self.getData = function () {
  41. var data = {
  42. routeinfoid: self.routeinfoid,
  43. tablename: "DOCELEMENT_ZL"
  44. }
  45. $http.post(apiurljs.login + "g2app/DangAn/queryDataByTablename", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  46. .success(function (obj) {
  47. var res = strToJson(s4.decryptData_CBC(obj.data));
  48. self.data = {
  49. ARCHCODE: res.data.ARCHCODE ? res.data.ARCHCODE : "",
  50. ARCHYEAR: res.data.ARCHYEAR ? res.data.ARCHYEAR : "",
  51. ORGANIZATIONMA: res.data.ORGANIZATIONMA ? res.data.ORGANIZATIONMA : "",
  52. DOCUMENTID: res.data.DOCUMENTID ? res.data.DOCUMENTID : "",
  53. DANGANML: res.data.DANGANML ? res.data.DANGANML : "",
  54. DOCUMENTTYPE: res.data.DOCUMENTTYPE ? res.data.DOCUMENTTYPE : "",
  55. SERIALNUM: res.data.SERIALNUM ? res.data.SERIALNUM : "",
  56. MIJIQIXIAN: res.data.MIJIQIXIAN ? res.data.MIJIQIXIAN : "",
  57. EMERGENCYDEGREE: res.data.EMERGENCYDEGREE ? res.data.EMERGENCYDEGREE : "",
  58. DOCISSUERID: res.data.DOCISSUERID ? res.data.DOCISSUERID : "",
  59. DOCISSUEDNUM: res.data.DOCISSUEDNUM ? res.data.DOCISSUEDNUM : "",
  60. SIGNER: res.data.SIGNER ? res.data.SIGNER : "",
  61. DOCTITLE: res.data.DOCTITLE ? res.data.DOCTITLE : "",
  62. MAINDPT: res.data.MAINDPT ? res.data.MAINDPT : "",
  63. DOCISSUEDDATE: res.data.DOCISSUEDDATE ? sp.format(res.data.DOCISSUEDDATE) : "",
  64. ATTACHMENT: res.data.ATTACHMENT ? res.data.ATTACHMENT : "",
  65. ISSUINGAGENCY: res.data.ISSUINGAGENCY ? res.data.ISSUINGAGENCY : "",
  66. ANNOTATION: res.data.ANNOTATION ? res.data.ANNOTATION : "",
  67. CCDPT: res.data.CCDPT ? res.data.CCDPT : "",
  68. PRINTSENDDPT: res.data.PRINTSENDDPT ? res.data.PRINTSENDDPT : "",
  69. PRINTDATE: res.data.PRINTDATE ? sp.format(res.data.PRINTDATE) : "",
  70. RELEASELEVEL: res.data.RELEASELEVEL ? res.data.RELEASELEVEL : "",
  71. }
  72. console.log(res.data)
  73. $.each(self.select.list, function (index, item) {
  74. if (item.CODE == self.data.ORGANIZATIONMA) {
  75. self.data.ORGANIZATIONMA = item.CNAME;
  76. }
  77. })
  78. })
  79. self.getAttachList()
  80. }
  81. self.getAttachList = function () {
  82. var data = {
  83. routeinfoid: self.routeinfoid
  84. }
  85. $http.post(apiurljs.login + "g2app/DangAn/getAttachList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  86. .success(function (obj) {
  87. var res = strToJson(s4.decryptData_CBC(obj.data));
  88. self.list = res.data;
  89. $.each(self.list, function (index, item) {
  90. item.SIZE = item.FILESIZE >= 104857.6 ? (item.FILESIZE / 1048576).toFixed(2) + "MB" : (item.FILESIZE / 1024).toFixed(2) + "KB";
  91. })
  92. })
  93. }
  94. self.btnSave = function () {
  95. var data = {
  96. routeinfoid: self.routeinfoid,
  97. data: JSON.stringify(self.data),
  98. tablename: "DOCELEMENT_ZL"
  99. }
  100. $http.post(apiurljs.login + "g2app/abase/saveFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  101. .success(function (obj) {
  102. var res = strToJson(s4.decryptData_CBC(obj.data));
  103. if (res.code == 0) {
  104. self.routeinfoid = res.data.id;
  105. self.getData();
  106. sp.dialog("保存成功!");
  107. $timeout(function () {
  108. sp.dialoghide()
  109. }, 1500)
  110. } else {
  111. sp.dialog(res.message)
  112. }
  113. })
  114. }
  115. self.getJIGOU();
  116. }])