list.js 16 KB

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