formedt.js 9.7 KB

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