formedt-1.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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.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?lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.type
  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: "formedt.html?routeinfoid=" + self.routeinfoid + "&lastReturn=" + self.get_lastReturn + "&lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.type
  25. }, {
  26. VNAME: "附件列表",
  27. TEMPFORM: "attachlist.html?routeinfoid=" + self.routeinfoid + "&lastReturn=" + self.get_lastReturn + "&lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.type
  28. }]
  29. self.Title = "文件详情";
  30. self.showReturn = false;
  31. self.getSelect = function () {
  32. self.select = { list: [] }
  33. var data = { tablename: "CODE_AGENCIES" }
  34. $http.post(apiurljs.login + "g2app/DangAn/queryCodeData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  35. .success(function (obj) {
  36. var res = strToJson(s4.decryptData_CBC(obj.data));
  37. self.select.list = res.data;
  38. self.getMIJI();
  39. })
  40. }
  41. self.getMIJI = function () {
  42. var data = { tablename: "CODE_SECRET" }
  43. $http.post(apiurljs.login + "g2app/DangAn/queryCodeData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  44. .success(function (obj) {
  45. var res = strToJson(s4.decryptData_CBC(obj.data));
  46. self.select.miji = res.data;
  47. self.getJINJI();
  48. })
  49. }
  50. self.getJINJI = function () {
  51. var data = { tablename: "CODE_EMERGENCY" }
  52. $http.post(apiurljs.login + "g2app/DangAn/queryCodeData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  53. .success(function (obj) {
  54. var res = strToJson(s4.decryptData_CBC(obj.data));
  55. self.select.jinji = res.data;
  56. self.getData(0);
  57. })
  58. }
  59. self.getData = function (n) {
  60. var data = {
  61. routeinfoid: self.routeinfoid,
  62. tablename: ""
  63. }
  64. if (self.get_lastReturn == "list") {
  65. if (self.type == 1) {
  66. data.tablename = "DOCELEMENT";
  67. } else {
  68. data.tablename = "DOCELEMENT_ZL";
  69. }
  70. }else{
  71. data.tablename = "DOCELEMENT_ZL"
  72. }
  73. $http.post(apiurljs.login + "g2app/DangAn/queryDataByTablename", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  74. .success(function (obj) {
  75. var res = strToJson(s4.decryptData_CBC(obj.data));
  76. self.data = {
  77. ID: res.data.ID ? res.data.ID : "",
  78. ARCHCODE: res.data.ARCHCODE ? res.data.ARCHCODE : "",
  79. ARCHYEAR: res.data.ARCHYEAR ? sp.currentYear() : sp.formatGetYear(res.data.DOCISSUEDDATE),
  80. ORGANIZATIONMA: res.data.ORGANIZATIONMA ? res.data.ORGANIZATIONMA : self.select.list[0].CODE,
  81. DOCUMENTID: res.data.DOCUMENTID ? res.data.DOCUMENTID : "",
  82. DOCUMENTTYPE: res.data.DOCUMENTTYPE ? res.data.DOCUMENTTYPE : "",
  83. SERIALNUM: res.data.SERIALNUM ? res.data.SERIALNUM : "",
  84. MIJIQIXIAN: res.data.MIJIQIXIAN ? res.data.MIJIQIXIAN : "",
  85. EMERGENCYDEGREE: res.data.EMERGENCYDEGREE ? res.data.EMERGENCYDEGREE : "",
  86. DOCISSUERID: res.data.DOCISSUERID ? res.data.DOCISSUERID : "",
  87. DOCISSUEDNUM: res.data.DOCISSUEDNUM ? res.data.DOCISSUEDNUM : "",
  88. SIGNER: res.data.SIGNER ? res.data.SIGNER : "",
  89. DOCTITLE: res.data.DOCTITLE ? res.data.DOCTITLE : "",
  90. MAINDPT: res.data.MAINDPT ? res.data.MAINDPT : "",
  91. DOCISSUEDDATE: res.data.DOCISSUEDDATE ? sp.format(res.data.DOCISSUEDDATE) : "",
  92. ATTACHMENT: res.data.ATTACHMENT ? res.data.ATTACHMENT : "",
  93. ISSUINGAGENCY: res.data.ISSUINGAGENCY ? res.data.ISSUINGAGENCY : "",
  94. ANNOTATION: res.data.ANNOTATION ? res.data.ANNOTATION : "",
  95. CCDPT: res.data.CCDPT ? res.data.CCDPT : "",
  96. PRINTSENDDPT: res.data.PRINTSENDDPT ? res.data.PRINTSENDDPT : "",
  97. PRINTDATE: res.data.PRINTDATE ? sp.format(res.data.PRINTDATE) : "",
  98. RELEASELEVEL: res.data.RELEASELEVEL ? res.data.RELEASELEVEL : "",
  99. }
  100. $.each(self.select.miji, function (index, item) {
  101. if (item.CODE == self.data.MIJIQIXIAN) {
  102. self.MIJIQIXIAN1 = item.CNAME;
  103. }
  104. })
  105. $.each(self.select.jinji, function (index, item) {
  106. if (item.CODE == self.data.EMERGENCYDEGREE) {
  107. self.EMERGENCYDEGREE1 = item.CNAME;
  108. }
  109. })
  110. self.getReturnList()
  111. })
  112. }
  113. self.getSelect();
  114. self.getReturnList = function () {
  115. var data = {
  116. routeinfoid: self.routeinfoid,
  117. tablename: "DOCELEMENT_01"
  118. }
  119. $http.post(apiurljs.login + "g2app/DangAn/GetDataListForPid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  120. .success(function (obj) {
  121. var res = strToJson(s4.decryptData_CBC(obj.data));
  122. self.returnList = res.data;
  123. self.returnListShow = false;
  124. self.selectReturn = self.returnList[0];
  125. $.each(self.returnList, function (index, item) {
  126. item.BACKDATE1 = sp.format(item.BACKDATE);
  127. item.BACKDATE = sp.formatMinute(item.BACKDATE);
  128. item.BACKOPINION1 = item.BACKOPINION.length > 12 ? item.BACKOPINION.slice(0, 12) + "..." : item.BACKOPINION;
  129. })
  130. })
  131. }
  132. self.btnSubmit = function (n) {
  133. if (n == 0) {
  134. self.btnSave(1)
  135. } else {
  136. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  137. var dialogBody = "<div class=\"sp-dialog-body\">您确认要提交这些内容吗?</div>";
  138. 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>";
  139. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  140. sp.openCenter(".sp-dialog");
  141. $('.sp-closeDialog').click(function (event) {
  142. sp.dialoghide();
  143. event.preventDefault();
  144. event.stopPropagation();
  145. });
  146. $("#upDataTrue").click(function () {
  147. sp.dialoghide();
  148. if (self.type == 1) {
  149. var data = {
  150. data: self.routeinfoid,
  151. userid: self.userId,
  152. username: self.userName
  153. }
  154. $http.post(apiurljs.login + "g2app/DangAn/SendData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  155. .success(function (obj) {
  156. var res = strToJson(s4.decryptData_CBC(obj.data));
  157. if (res.success) {
  158. sp.dialog("提交成功,即将跳转至文件收集!");
  159. $timeout(function () {
  160. window.location.href = self.return
  161. }, 1500)
  162. } else {
  163. sp.dialog(res.message)
  164. }
  165. })
  166. } else {
  167. var data = {
  168. data: self.routeinfoid,
  169. }
  170. $http.post(apiurljs.login + "g2app/DangAn/SendBackData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  171. .success(function (obj) {
  172. var res = strToJson(s4.decryptData_CBC(obj.data));
  173. if (res.success) {
  174. sp.dialog("提交成功,即将跳转至文件收集!");
  175. $timeout(function () {
  176. window.location.href = self.return
  177. }, 1500)
  178. } else {
  179. sp.dialog(res.message)
  180. }
  181. })
  182. }
  183. })
  184. }
  185. }
  186. self.btnSave = function (n) {
  187. var data = {
  188. routeinfoid: self.routeinfoid,
  189. data: JSON.stringify(self.data),
  190. tablename: ""
  191. }
  192. if (self.get_lastReturn == "list") {
  193. if (self.type == 1) {
  194. data.tablename = "DOCELEMENT";
  195. } else {
  196. data.tablename = "DOCELEMENT_ZL";
  197. }
  198. } else {
  199. data.tablename = "DOCELEMENT_ZL"
  200. }
  201. $http.post(apiurljs.login + "g2app/abase/saveFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  202. .success(function (obj) {
  203. var res = strToJson(s4.decryptData_CBC(obj.data));
  204. if (res.code == 0) {
  205. self.routeinfoid = res.data.id;
  206. if (n == 0) {
  207. self.getData(1);
  208. sp.dialog("保存成功!");
  209. $timeout(function () {
  210. sp.dialoghide()
  211. }, 1500)
  212. } else {
  213. self.btnSubmit(1)
  214. }
  215. } else {
  216. sp.dialog(res.message)
  217. }
  218. })
  219. }
  220. }])
  221. app.filter('trustHtml', function ($sce) {
  222. return function (input) {
  223. return $sce.trustAsHtml(input.replace(/\n/g, '<br/>').replace(/\s/g, '&nbsp;'));
  224. };
  225. });