list3.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination'
  4. ]);
  5. app.controller("listCtrl", ["$scope", "$http", "$timeout", function ($scope, $http, $timeout) {
  6. var self = this;
  7. var s4 = new SM4Util();
  8. self.userId = $.cookie("GlWorkPlatform-userid");
  9. self.userName = $.cookie("GlWorkPlatform-chineseName");
  10. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  11. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  12. var postCfg = {
  13. headers: {
  14. 'Content-Type': 'application/json',
  15. 'Authorization': "Bearer " + self.get_AccessToken
  16. }
  17. }
  18. self.type = sp.getUrlName("type") == "" ? 1 : sp.getUrlName("type");
  19. self.changeType = function (n) {
  20. if (self.type == n) {
  21. return;
  22. } else {
  23. self.type = n;
  24. self.search = {
  25. PACKAGEID: "",
  26. ARCHCODE: ""
  27. }
  28. self.getData(1, self.type)
  29. }
  30. }
  31. self.CrossPage = window.parent.CrossPage;
  32. self.loading = false;
  33. self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
  34. self.listTotal1 = [];
  35. self.listTotal2 = [];
  36. self.list = [];
  37. self.pageno = 1;
  38. self.total_count = 0;
  39. self.itemsPerPage = 10;
  40. self.pageOptions = [10, 20, 30, 40];
  41. self.search = {
  42. PACKAGEID: $.cookie("danganList3-search") && self.type == 2 ? $.cookie("danganList3-search") : "",
  43. ARCHCODE: $.cookie("danganList3-search") && self.type == 1 ? $.cookie("danganList3-search") : ""
  44. }
  45. self.getData = function (pageno, type) {
  46. self.loading = true;
  47. self.pageno = pageno;
  48. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  49. self.list = [];
  50. var functionName = type == 1 ? "queryZLDataWithPage" : "queryDataWithPageByYJ";
  51. var data = type == 1 ? {
  52. tablename: "DOCELEMENT_ZL",
  53. sqlwhere: {
  54. MODELMARK: "1",
  55. DPCODE: self.userDpCode
  56. },
  57. sqlinwhere: {
  58. sendstatus: "6"
  59. },
  60. sqllikewhere: {
  61. ARCHCODE: self.search.ARCHCODE
  62. },
  63. title: "",
  64. order: "SORTID desc",
  65. pageno: self.pageno,
  66. pagesize: self.itemsPerPage
  67. } : {
  68. tablename: "FILETRANSFER",
  69. sqlwhere: {
  70. DPCODE: self.userDpCode
  71. },
  72. sqlinwhere: {},
  73. sqllikewhere: {
  74. PACKAGEID: self.search.PACKAGEID
  75. },
  76. order: "SORTID desc",
  77. pageno: self.pageno,
  78. pagesize: self.itemsPerPage
  79. }
  80. $http.post(apiurljs.login + "g2app/DangAn/" + functionName, { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  81. .success(function (obj) {
  82. var res = strToJson(s4.decryptData_CBC(obj.data));
  83. self.loading = false;
  84. if (res.data == null || res.data == undefined || res.data == "") {
  85. self.noDataTip = 0;
  86. } else {
  87. self.noDataTip = 1;
  88. self.list = res.data;
  89. console.log(self.list)
  90. self.listChecked = false;
  91. self.total_count = res.totalCount;
  92. if (QCHB(self.list, self["listTotal" + self.type], "ID").length > 0) {
  93. self["listTotal" + self.type] = self["listTotal" + self.type].concat(QCHB(self.list, self["listTotal" + self.type], "ID"))
  94. }
  95. var checkedNum = 0;
  96. $.each(self.list, function (index, item) {
  97. item.checked = false;
  98. item.CREATDATE = sp.format(item.CREATDATE);
  99. $.each(self["listTotal" + self.type], function (index1, item1) {
  100. if (item.ID == item1.ID) {
  101. item.checked = item1.checked;
  102. }
  103. })
  104. if (item.checked == true) {
  105. checkedNum++
  106. }
  107. })
  108. if (checkedNum == self.list.length) {
  109. self.listChecked = true;
  110. }
  111. }
  112. })
  113. }
  114. self.changeListCheck = function () {
  115. $.each(self.list, function (index, item) {
  116. item.checked = self.listChecked;
  117. $.each(self["listTotal" + self.type], function (index1, item1) {
  118. if (item1.ID == item.ID) {
  119. item1.checked = item.checked;
  120. }
  121. })
  122. })
  123. }
  124. self.changeCheck = function (item, n) {
  125. item.checked = n == 1 ? item.checked : !item.checked
  126. $.each(self["listTotal" + self.type], function (index1, item1) {
  127. if (item1.ID == item.ID) {
  128. item1.checked = item.checked;
  129. }
  130. })
  131. event.stopPropagation()
  132. }
  133. self.load = function () {
  134. if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
  135. self.getData(self.pageno, self.type);
  136. } else {
  137. $timeout(function () {
  138. self.getData(parseInt(self.get_lastReturnPageno), self.type);
  139. }, 1)
  140. }
  141. }
  142. self.getDP = function () {
  143. var data = {
  144. userid: self.userId
  145. }
  146. $http.post(apiurljs.login + "g2app/richang/queryDpInfo", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  147. .success(function (obj) {
  148. var res = strToJson(s4.decryptData_CBC(obj.data));
  149. self.userDpName = res.data.length == 0 ? "" : res.data[0].SECTION;
  150. self.userDpCode = res.data.length == 0 ? "" : res.data[0].CODE;
  151. self.load();
  152. })
  153. }
  154. self.getDP();
  155. self.refresh = function () {
  156. self.CrossPage.type = null;
  157. self.getData(self.pageno, self.type);
  158. }
  159. ///查询-打开弹出层
  160. self.openSearchLayer = function () {
  161. sp.layer("#search");
  162. }
  163. self.btnSearch = function () {
  164. self.getData(1, self.type)
  165. if (self.type == 1) {
  166. $.cookie("danganList3-search", self.search.ARCHCODE, { path: '/', expires: 1 });
  167. } else {
  168. $.cookie("danganList3-search", self.search.PACKAGEID, { path: '/', expires: 1 });
  169. }
  170. sp.layerhide()
  171. }
  172. self.closeSeach = function () {
  173. self.search = {
  174. PACKAGEID: "",
  175. ARCHCODE: ""
  176. }
  177. sp.layerhide();
  178. $.cookie("danganList3-search", null, { path: '/', expires: -1 });
  179. self.getData(1, self.type)
  180. };
  181. self.fengzhuang = function () {
  182. var itemlist = [], flag = true;
  183. self["listTotal" + self.type].forEach(function (item) {
  184. if (item.checked == true) {
  185. itemlist.push(item.ROUTEINFOID);
  186. }
  187. })
  188. if (itemlist.length == 0) {
  189. sp.dialog("请勾选需要封装的案件!");
  190. return;
  191. }
  192. self.fz = {
  193. PACKAGEID: "",
  194. PACKAGETYPE: "",
  195. CREATOR: self.userName,
  196. CREATORUSERID: self.userId,
  197. CREATDATE: sp.format(sp.getLocalDate()),
  198. CREATENVIR: "",
  199. STORAGELOC: "",
  200. PACKAGEDES: "",
  201. ROUTEINFOIDLIST: itemlist.join(","),
  202. DPCODE: self.userDpCode,
  203. DPNAME: self.userDpName
  204. }
  205. sp.layer("#FZ")
  206. }
  207. self.btnFZ = function () {
  208. if (self.fz.PACKAGEID == "") {
  209. sp.dialog("信息包不可为空!");
  210. return;
  211. }
  212. var data = {
  213. id: 0,
  214. tablename: "PAGELEMENT",
  215. routeinfoidlist: self.fz.ROUTEINFOIDLIST,
  216. data: JSON.stringify(self.fz)
  217. }
  218. $http.post(apiurljs.login + "g2app/DangAn/SaveFengZhuang", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  219. .success(function (obj) {
  220. var res = strToJson(s4.decryptData_CBC(obj.data));
  221. sp.layerhide();
  222. if (res.code == 0) {
  223. sp.dialog("封装成功!");
  224. self.getData(self.pageno, self.type);
  225. self["listTotal" + self.type] = self["listTotal" + self.type].filter(function (item) {
  226. return self.fz.ROUTEINFOIDLIST.split(",").every(function (item1) {
  227. return item.ROUTEINFOID != item1;
  228. })
  229. })
  230. $timeout(function () {
  231. sp.dialoghide();
  232. }, 1500)
  233. } else {
  234. sp.dialog(res.message)
  235. }
  236. })
  237. }
  238. self.btnDJ = function (ID, n) {
  239. if (n == 1) {
  240. var data = {
  241. id: ID,
  242. tablename: "FILETRANSFER"
  243. }
  244. $http.post(apiurljs.login + "g2app/DangAn/queryDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  245. .success(function (obj) {
  246. var res = strToJson(s4.decryptData_CBC(obj.data));
  247. self.dj = {
  248. ID: ID,
  249. type: 1,
  250. FILENAME: res.data.FILENAME,
  251. FILENUMBER: res.data.FILENUMBER,
  252. TRANSFERUNIT: res.data.TRANSFERUNIT,
  253. TRANSFERDATE: sp.format(res.data.TRANSFERDATE),
  254. ARCHIVEDATE: res.data.ARCHIVEDATE,
  255. ACCEPTUNIT: res.data.ACCEPTUNIT
  256. }
  257. })
  258. }
  259. if (n == 2) {
  260. self.dj = {
  261. ID: ID,
  262. type: 2,
  263. FILENAME: "",
  264. FILENUMBER: null,
  265. TRANSFERUNIT: "区委办",
  266. TRANSFERDATE: sp.format(sp.getLocalDate()),
  267. ARCHIVEDATE: "",
  268. ACCEPTUNIT: "档案馆"
  269. }
  270. }
  271. sp.layer("#DJ")
  272. }
  273. self.btnDJsubmit = function () {
  274. var data = {
  275. id: self.dj.ID,
  276. tablename: "FILETRANSFER",
  277. data: {
  278. FILENAME: self.dj.FILENAME,
  279. FILENUMBER: self.dj.FILENUMBER,
  280. TRANSFERUNIT: self.dj.TRANSFERUNIT,
  281. TRANSFERDATE: self.dj.TRANSFERDATE,
  282. ARCHIVEDATE: self.dj.ARCHIVEDATE,
  283. ACCEPTUNIT: self.dj.ACCEPTUNIT,
  284. REGISTATUS: "是"
  285. }
  286. }
  287. $http.post(apiurljs.login + "g2app/DangAn/SaveDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  288. .success(function (obj) {
  289. var res = strToJson(s4.decryptData_CBC(obj.data));
  290. sp.layerhide();
  291. if (res.code == 0) {
  292. sp.dialog("登记成功!");
  293. $timeout(function () {
  294. sp.dialoghide();
  295. self.getData(self.pageno, self.type)
  296. }, 1500)
  297. } else {
  298. sp.dialog(res.message)
  299. }
  300. })
  301. }
  302. self.toHref = function (html, item, type) {
  303. window.location.href = html + ".html?id=" + item.ID + "&routeinfoid=" + item.ROUTEINFOID + "&lastReturn=list3&lastReturnPageno=" + self.pageno + "&type=" + type;
  304. event.stopPropagation()
  305. }
  306. //头部下滚冻结
  307. $(function () {
  308. //页面高度撑满
  309. setTimeout(function () {
  310. if ($(".ibox-content").height() < $(window).height() - 31) {
  311. $(".ibox-content").css("height", $(window).height() - 31)
  312. }
  313. }, 1)
  314. })
  315. }])
  316. function QCHB(arr1, arr2, filed) {
  317. return arr1.filter(function (item) {
  318. return arr2.every(function (item1) {
  319. return item[filed] != item1[filed];
  320. })
  321. })
  322. }