list.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination'
  4. ]);
  5. app.controller("listCtrl", ["$scope", "$http", "$timeout", "$sce", function ($scope, $http, $timeout, $sce) {
  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.dateParam = sp.getUrlName("date");
  12. var postCfg = {
  13. headers: {
  14. 'Content-Type': 'application/json',
  15. 'Authorization': "Bearer " + self.get_AccessToken
  16. }
  17. }
  18. self.leftTree = [{ CNAME: "政策文件", CODE: "ZCWJ" },
  19. { CNAME: "两清单", CHILDREN: [{ CNAME: "委党委", show: false, TYPE: 0 }, { CNAME: "班子成员", show: false, CHILDREN: [], TYPE: 2 }, { CNAME: "市管单位", show: false, CHILDREN: [], TYPE: 3 }, { CNAME: "直属单位", show: false, CHILDREN: [], TYPE: 4 }] },
  20. { CNAME: "报告", CHILDREN: [{ CNAME: "委党委", show: false, CHILDREN: [], TYPE: 1 }, { CNAME: "班子成员", show: false, CHILDREN: [], TYPE: 2 }, { CNAME: "市管单位", show: false, CHILDREN: [], TYPE: 3 }, { CNAME: "直属单位", show: false, CHILDREN: [], TYPE: 4 }] }
  21. ]
  22. self.checkNode = function (NODE) {
  23. NODE.show = !NODE.show;
  24. self.activeNode = NODE;
  25. if (self.activeNode.TYPE > 0) {
  26. if (self.activeNode.TYPE == 1 && NODE.CHILDREN.length == 0) {
  27. var data = {
  28. unitid: "AA01"
  29. }
  30. $http.post(apiurljs.login + "g2app/dataabase/querySectByCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  31. .success(function (obj) {
  32. var res = strToJson(s4.decryptData_CBC(obj.data));
  33. res.data.forEach(function (item) {
  34. if (item.CODE != "AA0136") {
  35. NODE.CHILDREN.push({ CNAME: item.SECTION, CODE: item.CODE })
  36. }
  37. })
  38. })
  39. } else if (self.activeNode.TYPE == 2 && NODE.CHILDREN.length == 0) {
  40. var data = {
  41. zid: "AA19",
  42. levels: "0"
  43. }
  44. $http.post(apiurljs.login + "g2work/datazu/queryDataUser", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  45. .success(function (obj) {
  46. var res = strToJson(s4.decryptData_CBC(obj.data));
  47. res.data.forEach(function (item) {
  48. item.users.forEach(function (item1) {
  49. if (item1.auth == 1) {
  50. NODE.CHILDREN.push({ CNAME: item1.ushowname, CODE: item1.userid })
  51. }
  52. })
  53. })
  54. })
  55. } else if (self.activeNode.TYPE == 3 && NODE.CHILDREN.length == 0) {
  56. var data = {
  57. unitid: "AA02"
  58. }
  59. $http.post(apiurljs.login + "g2app/dataabase/querySectByCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  60. .success(function (obj) {
  61. var res = strToJson(s4.decryptData_CBC(obj.data));
  62. res.data.forEach(function (item) {
  63. if (item.CODE == "AA0216" || item.CODE == "AA0201") {
  64. NODE.CHILDREN.push({ CNAME: item.SECTION, CODE: item.CODE })
  65. }
  66. })
  67. })
  68. } else if (self.activeNode.TYPE == 4 && NODE.CHILDREN.length == 0) {
  69. var data = {
  70. unitid: "AA02"
  71. }
  72. $http.post(apiurljs.login + "g2app/dataabase/querySectByCode", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  73. .success(function (obj) {
  74. var res = strToJson(s4.decryptData_CBC(obj.data));
  75. res.data.forEach(function (item) {
  76. if (item.CODE != "AA0216" && item.CODE != "AA0201") {
  77. NODE.CHILDREN.push({ CNAME: item.SECTION, CODE: item.CODE })
  78. }
  79. })
  80. })
  81. }
  82. } else {
  83. if (!self.activeNode.CHILDREN) {
  84. //self.getFiles(self.activeNode)
  85. //self.getType()
  86. }
  87. }
  88. }
  89. self.filesList = [];
  90. self.getFiles = function (obj) {
  91. var data = {
  92. tablename: "FILE_ATTACH",
  93. colums: "*",
  94. order: "ID asc",
  95. sqlwhere: { ATTACHTYPE: obj.CODE },
  96. sqlinwhere: "",
  97. sqllikewhere: ""
  98. }
  99. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  100. .success(function (obj) {
  101. var res = strToJson(s4.decryptData_CBC(obj.data));
  102. self.filesList = res.data
  103. })
  104. }
  105. self.type = 2;
  106. self.searchDWMC = "";
  107. self.searchYear = sp.currentYear() * 1;
  108. self.years = [sp.currentYear() * 1 - 2, sp.currentYear() * 1 - 1, sp.currentYear() * 1, sp.currentYear() * 1 + 1, sp.currentYear() * 1 + 2]
  109. self.getType = function () {
  110. var data = {
  111. userid: self.userId
  112. }
  113. $http.post(apiurljs.login + "g2app/dataabase/queryDPParentName", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  114. .success(function (obj) {
  115. var res = strToJson(s4.decryptData_CBC(obj.data));
  116. for (var i in res.data[0]) {
  117. if (res.data[0][i][0].PARENT_DATA.length > 0) {
  118. self.type = res.data[0][i][0].PARENT_DATA[0].SECTION != "直属单位" ? 1 : 2;
  119. } else {
  120. self.type = 1;
  121. }
  122. }
  123. self.getDP()
  124. })
  125. }
  126. self.getDP = function () {
  127. var data = {
  128. userid: self.userId
  129. }
  130. $http.post(apiurljs.login + "g2app/richang/queryDpInfo", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  131. .success(function (obj) {
  132. var res = strToJson(s4.decryptData_CBC(obj.data));
  133. self.userDpCode = res.data.length == 0 ? "" : res.data[0].CODE;
  134. self.userDpName = res.data.length == 0 ? "" : res.data[0].SECTION;
  135. self.getData();
  136. })
  137. }
  138. self.getData = function () {
  139. var sqlwhere = ["AND NF='" + self.searchYear + "' and GLBMCODE='" + self.userDpCode + "'"]
  140. if (self.searchDWMC != "") {
  141. sqlwhere.push("and DWMC like '%" + self.searchDWMC + "%'")
  142. }
  143. var data = {
  144. pageno: 0,
  145. pagesize: 0,
  146. tztablename: "SX_CYZDXMTZ",
  147. tzcolums: "ID,XMMC,WCSX",
  148. colums: "ID",
  149. order: "ID",
  150. sqlwhere: sqlwhere.join(" "),
  151. childtopnum: "",
  152. childcolumns: "ID,BH,WCQK,SJWCSJ",
  153. childorder: "sortid"
  154. }
  155. $http.post(apiurljs.login + "g2app/xinxifabu/queryXXFBDataWithChildAndAttach", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  156. .success(function (obj) {
  157. var res = strToJson(s4.decryptData_CBC(obj.data));
  158. self.list = res.data;
  159. console.log(self.list)
  160. })
  161. }
  162. self.getType()
  163. self.openLayer = function () {
  164. self.searchDWMC = "";
  165. self.searchYear = sp.currentYear() * 1;
  166. sp.layer("#Search")
  167. }
  168. self.doSearch = function () {
  169. self.getData()
  170. sp.layerhide()
  171. }
  172. self.initSearch = function () {
  173. self.searchYear = sp.currentYear() * 1;
  174. self.searchDWMC = "";
  175. self.getData()
  176. sp.layerhide()
  177. }
  178. self.Detail = function (obj,n) {
  179. self.detail = obj;
  180. var data = {
  181. pageno: 1,
  182. pagesize: 1,
  183. tztablename: "SX_CYZDXMTZ",
  184. tzcolums: "ID,XMMC,WCSX",
  185. colums: "ID",
  186. order: "ID",
  187. sqlwhere: "AND ID='" + obj.ID + "'",
  188. childtopnum: "",
  189. childcolumns: "ID,BH,WCQK,SJWCSJ",
  190. childorder: " sortid"
  191. }
  192. $http.post(apiurljs.login + "g2app/xinxifabu/queryXXFBDataWithChildAndAttach", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  193. .success(function (obj) {
  194. var res = strToJson(s4.decryptData_CBC(obj.data));
  195. //self.rwList = res.data[0].CHILD;
  196. if (res.data[0].data.length > 0) {
  197. self.rwList_CHILD = true;
  198. self.rwList = res.data[0].data[0].CHILD;
  199. } else {
  200. self.rwList_CHILD = false;
  201. self.rwList = res.data[0].data;
  202. }
  203. self.addFlag = false;
  204. self.editFlag = false;
  205. self.rwList.forEach(function (item) {
  206. item.SJWCSJ = sp.format(item.SJWCSJ)
  207. item.editFlag = false;
  208. })
  209. if (n == 0) {
  210. sp.layer("#Detail")
  211. }
  212. })
  213. }
  214. self.addItem = function () {
  215. if (self.editFlag == true || self.addFlag == true) {
  216. return
  217. }
  218. self.addFlag = true;
  219. self.add = {
  220. ID: 0,
  221. BH: self.rwList.length == 0 ? 1 : self.rwList[self.rwList.length - 1].BH * 1 + 1,
  222. WCQK: "",
  223. SJWCSJ: ""
  224. }
  225. }
  226. self.editItem = function (obj) {
  227. if (self.addFlag == true) {
  228. return
  229. }
  230. self.editFlag = true;
  231. obj.editFlag = true;
  232. self.edit = {
  233. ID: obj.ID,
  234. WCQK: obj.WCQK,
  235. SJWCSJ: obj.SJWCSJ
  236. }
  237. }
  238. self.saveItem = function (object) {
  239. if (object.ID == 0) {
  240. if (self.rwList_CHILD == false) {
  241. var data = {
  242. id: 0,
  243. tablename: "SX_CYZD",
  244. data: {
  245. PID: self.detail.ID
  246. },
  247. childtablename: "SX_CYZD_01",
  248. childdata: [{
  249. BH: object.BH,
  250. WCQK: object.WCQK,
  251. SJWCSJ: object.SJWCSJ
  252. }]
  253. }
  254. $http.post(apiurljs.login + "g2app/dataabase/SaveDataAndChildData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  255. .success(function (obj) {
  256. var res = strToJson(s4.decryptData_CBC(obj.data));
  257. if (res.success) {
  258. self.Detail(self.detail, 1);
  259. self.getData()
  260. } else {
  261. sp.dialog(res.message)
  262. }
  263. })
  264. } else {
  265. var data = {
  266. tablename: "SX_CYZD",
  267. colums: "ID,PID",
  268. order: "ID desc",
  269. sqlwhere: {
  270. PID: self.detail.ID
  271. },
  272. sqlinwhere: "",
  273. sqllikewhere: ""
  274. }
  275. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  276. .success(function (obj) {
  277. var res = strToJson(s4.decryptData_CBC(obj.data));
  278. var data1 = {
  279. tablename: "SX_CYZD_01",
  280. id: 0,
  281. data: JSON.stringify({
  282. PID: res.data[0].ID,
  283. BH: object.BH,
  284. WCQK: object.WCQK,
  285. SJWCSJ: object.SJWCSJ
  286. })
  287. }
  288. $http.post(apiurljs.login + "g2app/dataabase/saveChildData", { data: s4.encryptData_CBC(JSON.stringify(data1)) }, postCfg)
  289. .success(function (obj1) {
  290. var res1 = strToJson(s4.decryptData_CBC(obj1.data));
  291. if (res1.success) {
  292. self.Detail(self.detail, 1);
  293. self.getData()
  294. } else {
  295. sp.dialog(res1.message)
  296. }
  297. })
  298. })
  299. }
  300. } else {
  301. var data = {
  302. tablename: "SX_CYZD_01",
  303. id: object.ID,
  304. data: JSON.stringify({
  305. WCQK: object.WCQK,
  306. SJWCSJ: object.SJWCSJ
  307. })
  308. }
  309. $http.post(apiurljs.login + "g2app/dataabase/upFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  310. .success(function (obj) {
  311. var res = strToJson(s4.decryptData_CBC(obj.data));
  312. if (res.success) {
  313. self.Detail(self.detail, 1);
  314. self.getData()
  315. } else {
  316. sp.dialog(res.message)
  317. }
  318. })
  319. }
  320. }
  321. self.deleteItem = function (obj) {
  322. var data = {
  323. tablename: "SX_CYZD_01",
  324. id: obj.ID
  325. };
  326. $http.post(apiurljs.login + "g2app/dataabase/delDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  327. .success(function (obj) {
  328. var res = strToJson(s4.decryptData_CBC(obj.data));
  329. sp.dialoghide();
  330. if (res.success) {
  331. self.Detail(self.detail, 1);
  332. self.getData()
  333. } else {
  334. sp.dialog("删除失败,请联系管理员!");
  335. }
  336. });
  337. }
  338. self.upload = function (obj, n) {
  339. $('#fileupload' + n).fileupload({
  340. url: apiurljs.login + 'g2app/abase/uploadFileWithForm',
  341. dataType: 'json',
  342. beforeSend: function (xhr, data) {
  343. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  344. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=FILE_ATTACH,routeinfoid=" + obj.ID + ",ATTACHTYPE=" + self.detail.XMMC));
  345. },
  346. add: function (e, data) {
  347. self.uploading = true;
  348. data.submit();
  349. },
  350. // 上传完成后的执行逻辑
  351. done: function (e, data) {
  352. self.uploading = false;
  353. self.Detail(self.detail, 1);
  354. self.getData()
  355. }
  356. })
  357. }
  358. self.download = function (obj) {
  359. window.open(apiurljs.login + "g2work/files/" + obj.FILEURL.slice(7))
  360. }
  361. self.deleteFile = function (obj) {
  362. var data = {
  363. tablename: "FILE_ATTACH",
  364. id: obj.ID
  365. };
  366. $http.post(apiurljs.login + "g2app/dataabase/delDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  367. .success(function (obj) {
  368. var res = strToJson(s4.decryptData_CBC(obj.data));
  369. sp.dialoghide();
  370. if (res.success) {
  371. self.Detail(self.detail, 1);
  372. self.getData()
  373. } else {
  374. sp.dialog("删除失败,请联系管理员!");
  375. }
  376. });
  377. }
  378. self.upload1 = function () {
  379. $('#fileupload_1').fileupload({
  380. url: apiurljs.login + 'g2app/abase/uploadFileWithForm',
  381. dataType: 'json',
  382. beforeSend: function (xhr, data) {
  383. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  384. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=FILE_ATTACH,routeinfoid=" + self.activeNode.CODE + ",ATTACHTYPE=" + self.activeNode.CODE));
  385. },
  386. add: function (e, data) {
  387. self.uploading = true;
  388. data.submit();
  389. },
  390. // 上传完成后的执行逻辑
  391. done: function (e, data) {
  392. self.getFiles(self.activeNode)
  393. }
  394. })
  395. }
  396. self.deleteFile1 = function (obj) {
  397. var data = {
  398. tablename: "FILE_ATTACH",
  399. id: obj.ID
  400. };
  401. $http.post(apiurljs.login + "g2app/dataabase/delDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  402. .success(function (obj) {
  403. var res = strToJson(s4.decryptData_CBC(obj.data));
  404. sp.dialoghide();
  405. if (res.success) {
  406. self.getFiles(self.activeNode)
  407. } else {
  408. sp.dialog("删除失败,请联系管理员!");
  409. }
  410. });
  411. }
  412. }])