danghao.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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.userCName = $.cookie("GlWorkPlatform-chineseName");
  10. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  11. self.routeinfoid = sp.getUrlName("routeinfoid");
  12. self.get_lastReturn = sp.getUrlName("lastReturn");
  13. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  14. self.return = self.get_lastReturn + ".html?type=2&lastReturnPageno=" + self.get_lastReturnPageno
  15. var postCfg = {
  16. headers: {
  17. 'Content-Type': 'application/json',
  18. 'Authorization': "Bearer " + self.get_AccessToken
  19. }
  20. };
  21. self.show = false;
  22. self.select = {
  23. list1: [],
  24. list2: [],
  25. list3: [],
  26. miji: []
  27. }
  28. self.getSelect1 = function () {
  29. var data = { tablename: "CODE_PERIOD" }
  30. $http.post(apiurljs.login + "g2app/DangAn/queryCodeData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  31. .success(function (obj) {
  32. var res = strToJson(s4.decryptData_CBC(obj.data));
  33. self.select.list1 = res.data;
  34. self.getSelect2();
  35. })
  36. }
  37. self.getSelect2 = function () {
  38. var data = { tablename: "CODE_AGENCIES" }
  39. $http.post(apiurljs.login + "g2app/DangAn/queryCodeData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  40. .success(function (obj) {
  41. var res = strToJson(s4.decryptData_CBC(obj.data));
  42. self.select.list2 = res.data;
  43. self.getSelect3();
  44. })
  45. }
  46. self.getSelect3 = function () {
  47. var data = { tablename: "CODE_DISTYPE" }
  48. $http.post(apiurljs.login + "g2app/DangAn/queryCodeData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  49. .success(function (obj) {
  50. var res = strToJson(s4.decryptData_CBC(obj.data));
  51. self.select.list3 = res.data;
  52. self.getMIJI();
  53. })
  54. }
  55. self.getMIJI = function () {
  56. var data = { tablename: "CODE_SECRET" }
  57. $http.post(apiurljs.login + "g2app/DangAn/queryCodeData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  58. .success(function (obj) {
  59. var res = strToJson(s4.decryptData_CBC(obj.data));
  60. self.select.miji = res.data;
  61. self.getData(0);
  62. })
  63. }
  64. self.getData = function (n) {
  65. var data = {
  66. routeinfoid: self.routeinfoid,
  67. tablename: "DOCELEMENT_ZL"
  68. }
  69. $http.post(apiurljs.login + "g2app/DangAn/queryDataByDangHao", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  70. .success(function (obj) {
  71. var res = strToJson(s4.decryptData_CBC(obj.data));
  72. self.data = {
  73. DOCUMENTID: res.data.DOCUMENTID ? res.data.DOCUMENTID : "",
  74. DOCUMENTTYPE: res.data.DOCUMENTTYPE ? res.data.DOCUMENTTYPE : "",
  75. FLOWCODE: res.data.FLOWCODE ? res.data.FLOWCODE : "",
  76. SERIALNUM: res.data.SERIALNUM ? res.data.SERIALNUM : "",
  77. MIJIQIXIAN: res.data.MIJIQIXIAN ? res.data.MIJIQIXIAN : "",
  78. EMERGENCYDEGREE: res.data.EMERGENCYDEGREE ? res.data.EMERGENCYDEGREE : "",
  79. DOCISSUERID: res.data.DOCISSUERID ? res.data.DOCISSUERID : "",
  80. DOCISSUEDNUM: res.data.DOCISSUEDNUM ? res.data.DOCISSUEDNUM : "",
  81. SIGNER: res.data.SIGNER ? res.data.SIGNER : "",
  82. DOCTITLE: res.data.DOCTITLE ? res.data.DOCTITLE : "",
  83. MAINDPT: res.data.MAINDPT ? res.data.MAINDPT : "",
  84. DOCISSUEDDATE: res.data.DOCISSUEDDATE ? sp.format(res.data.DOCISSUEDDATE) : "",
  85. ATTACHMENT: res.data.ATTACHMENT ? res.data.ATTACHMENT : "",
  86. ISSUINGAGENCY: res.data.ISSUINGAGENCY ? res.data.ISSUINGAGENCY : "",
  87. ANNOTATION: res.data.ANNOTATION ? res.data.ANNOTATION : "",
  88. CCDPT: res.data.CCDPT ? res.data.CCDPT : "",
  89. PRINTSENDDPT: res.data.PRINTSENDDPT ? res.data.PRINTSENDDPT : "",
  90. PRINTDATE: res.data.PRINTDATE ? sp.format(res.data.PRINTDATE) : "",
  91. RELEASELEVEL: res.data.RELEASELEVEL ? res.data.RELEASELEVEL : ""
  92. }
  93. self.edit = {
  94. ARCHYEAR: res.data.ARCHYEAR ? res.data.ARCHYEAR : sp.currentYear(),
  95. RETENTPERIOD: res.data.RETENTPERIOD ? res.data.RETENTPERIOD : self.select.list1[0].CODE,
  96. ORGANIZATIONMA: res.data.ORGANIZATIONMA ? res.data.ORGANIZATIONMA : self.select.list2[0].CODE,
  97. ITEMNUM: res.data.ITEMNUM ? res.data.ITEMNUM : "",
  98. SOFTWENVIRON: res.data.SOFTWENVIRON ? res.data.SOFTWENVIRON : "",
  99. HARDWENVIRON: res.data.HARDWENVIRON ? res.data.HARDWENVIRON : "",
  100. DISTYPE: res.data.DISTYPE ? res.data.DISTYPE : self.select.list3[0].CODE,
  101. DISACTOR: res.data.DISACTOR ? res.data.DISACTOR : "",
  102. DISDPT: res.data.DISDPT ? res.data.DISDPT : "",
  103. DISTIME: res.data.DISTIME ? sp.minsToDate("yyyy-MM-dd", res.data.DISTIME) : "",
  104. DISLRESULT: res.data.DISLRESULT ? res.data.DISLRESULT : ""
  105. }
  106. self.edit.ARCHCODE = res.data.ARCHCODE ? res.data.ARCHCODE : "TJJH-" + res.data.FLOWCODE + "-" + self.edit.ARCHYEAR + "-" + self.edit.RETENTPERIOD + "-" + self.edit.ORGANIZATIONMA;
  107. var a = "", b = "";
  108. $.each(self.select.miji, function (index, item) {
  109. if (item.CODE == self.data.MIJIQIXIAN.split(",")[0]) {
  110. a = item.CNAME;
  111. }
  112. })
  113. $.each(self.select.list1, function (index, item) {
  114. if (item.CODE == self.edit.RETENTPERIOD) {
  115. b = item.CNAME;
  116. }
  117. })
  118. self.data.MIJIQIXIAN1 = a + "," + b;
  119. })
  120. }
  121. self.getSelect1();
  122. self.toggle = function () {
  123. var trList = $(".sp-table").find("tr");
  124. console.log(1)
  125. if (!$(".sp-table").hasClass("hidepart")) {
  126. self.show = false;
  127. $(".sp-table").addClass("hidepart")
  128. $.each(trList, function (index, item) {
  129. if (index <= 10) {
  130. item.style.display = "none"
  131. }
  132. })
  133. } else {
  134. self.show = true;
  135. $(".sp-table").removeClass("hidepart")
  136. $.each(trList, function (index, item) {
  137. if (index <= 10) {
  138. item.style.display = ""
  139. }
  140. })
  141. }
  142. }
  143. self.btnSave = function () {
  144. if (self.edit.ARCHYEAR == "" || self.edit.RETENTPERIOD == "" || self.edit.ORGANIZATIONMA == "") {
  145. sp.dialog("年度、保管期限、机构或问题不可为空,请填写完整!");
  146. return;
  147. }
  148. self.edit.MIJIQIXIAN = self.data.MIJIQIXIAN;
  149. var data = {
  150. tablename: "DOCELEMENT_ZL",
  151. routeinfoid: self.routeinfoid,
  152. data: JSON.stringify(self.edit)
  153. }
  154. $http.post(apiurljs.login + "g2app/abase/saveFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  155. .success(function (obj) {
  156. var res = strToJson(s4.decryptData_CBC(obj.data));
  157. if (res.code == 0) {
  158. self.routeinfoid = res.data.id;
  159. sp.dialog("保存成功!");
  160. $timeout(function () {
  161. sp.dialoghide()
  162. }, 1500)
  163. self.getData(1);
  164. } else {
  165. sp.dialog(res.message)
  166. }
  167. })
  168. }
  169. self.getDangHao = function () {
  170. self.edit.ARCHCODE = "TJJH-" + self.data.FLOWCODE + "-" + self.edit.ARCHYEAR + "-" + self.edit.RETENTPERIOD + "-" + self.edit.ORGANIZATIONMA;
  171. self.data.MIJIQIXIAN = self.data.MIJIQIXIAN.split(",")[0] + "," + self.edit.RETENTPERIOD;
  172. var a = "", b = "";
  173. $.each(self.select.miji, function (index, item) {
  174. if (item.CODE == self.data.MIJIQIXIAN.split(",")[0]) {
  175. a = item.CNAME;
  176. }
  177. })
  178. $.each(self.select.list1, function (index, item) {
  179. if (item.CODE == self.edit.RETENTPERIOD) {
  180. b = item.CNAME;
  181. }
  182. })
  183. self.data.MIJIQIXIAN1 = a + "," + b;
  184. }
  185. }])