list-set.js 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  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.loading = false;
  19. self.noDataTip = 1;//没有数据时赋变量为0,先默认为1
  20. self.list = [];
  21. self.pageno = 1;
  22. self.total_count = 0;
  23. self.itemsPerPage = 10;
  24. self.pageOptions = [10, 20, 30, 40];
  25. self.search = JSON.parse($.cookie("GlWorkPlatform-danganSet"));
  26. self.getDP = function () {
  27. var data = {
  28. userid: self.userId
  29. }
  30. $http.post(apiurljs.login + "g2app/richang/queryDpInfo", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  31. .success(function (obj) {
  32. var res = strToJson(s4.decryptData_CBC(obj.data));
  33. self.userDpName = res.data.length == 0 ? "" : res.data[0].SECTION;
  34. self.userDpCode = res.data.length == 0 ? "" : res.data[0].CODE;
  35. self.load();
  36. })
  37. }
  38. self.getDP()
  39. self.getData = function (pageno) {
  40. if (self.search == null) {
  41. self.search = {
  42. DOCUMENTTYPE: "",
  43. FLOWNAME: ""
  44. }
  45. }
  46. var sqlwhere = ["and DPCODE='" + self.userDpCode + "'"];
  47. self.loading = true;
  48. self.pageno = pageno;
  49. $scope.__default__currentPage = self.pageno; //设置页面样式在第几页
  50. if (self.search.FLOWNAME != "") {
  51. sqlwhere.push("and FLOWNAME='" + self.search.FLOWNAME + "'")
  52. }
  53. if (self.search.DOCUMENTTYPE != "") {
  54. sqlwhere.push("and DOCUMENTTYPE='" + self.search.DOCUMENTTYPE + "'")
  55. }
  56. self.list = [];
  57. var data = {
  58. tablename: "DANGANFLOW AS A",
  59. pagesize: self.itemsPerPage,
  60. pageno: self.pageno,
  61. colums: "*,(SELECT count('WENHAO') FROM DATACOMPER AS B WHERE A.FLOWID=B.FLOWID ) AS COUNTS",
  62. order: "ID",
  63. sqlwhere: sqlwhere.join(" "),
  64. sqlorwhere: "",
  65. sqlinwhere: "",
  66. sqllikewhere: ""
  67. };
  68. $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage3", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  69. .success(function (obj) {
  70. var res = strToJson(s4.decryptData_CBC(obj.data));
  71. self.loading = false;
  72. if (res.data == null || res.data == undefined || res.data == "") {
  73. self.noDataTip = 0;
  74. } else {
  75. self.noDataTip = 1;
  76. self.list = res.data;
  77. self.total_count = res.totalCount;
  78. self.list.forEach(function (item) {
  79. item.STATUS1 = item.STATUS ? item.STATUS : "禁用";
  80. item.DOCUMENTTYPE1 = item.DOCUMENTTYPE != "" && item.DOCUMENTTYPE != null ? item.DOCUMENTTYPE : item.TABLENAME.indexOf("SW_") > -1 ? "收文" : item.TABLENAME.indexOf("FW_") > -1 ? "发文" : "";
  81. })
  82. }
  83. })
  84. }
  85. self.load = function () {
  86. if (self.get_lastReturnPageno == undefined || self.get_lastReturnPageno == null || self.get_lastReturnPageno == "") {
  87. self.getData(self.pageno);
  88. } else {
  89. $timeout(function () {
  90. self.getData(parseInt(self.get_lastReturnPageno));
  91. }, 1)
  92. }
  93. }
  94. ///查询-打开弹出层
  95. self.openSearchLayer = function () {
  96. if (self.search == null) {
  97. self.search = {
  98. DOCUMENTTYPE: "",
  99. FLOWNAME: ""
  100. }
  101. }
  102. sp.layer("#search");
  103. }
  104. self.btnSearch = function () {
  105. self.getData(1);
  106. $.cookie("GlWorkPlatform-danganSet", JSON.stringify(self.search), { path: '/', expires: 1 });
  107. sp.layerhide()
  108. }
  109. self.closeSeach = function () {
  110. self.search = {
  111. DOCUMENTTYPE: "",
  112. FLOWNAME: ""
  113. }
  114. sp.layerhide();
  115. $.cookie("GlWorkPlatform-danganSet", null, { path: '/', expires: 1 });
  116. self.getData(1);
  117. };
  118. self.openAddLayer = function (n) {
  119. var data = {
  120. tablename: "DANGANFLOWMANAGE",
  121. colums: "*",
  122. order: "ID",
  123. sqlwhere: {
  124. STATUS: "启用"
  125. },
  126. sqlorwhere: "",
  127. sqlinwhere: "",
  128. sqllikewhere: ""
  129. };
  130. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  131. .success(function (obj) {
  132. var res = strToJson(s4.decryptData_CBC(obj.data));
  133. var data1 = {
  134. tablename: "DANGANFLOW",
  135. colums: "*",
  136. order: "ID",
  137. sqlwhere: {
  138. DPCODE: self.userDpCode
  139. },
  140. sqlorwhere: "",
  141. sqlinwhere: "",
  142. sqllikewhere: ""
  143. };
  144. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data1)) }, postCfg)
  145. .success(function (obj1) {
  146. var res1 = strToJson(s4.decryptData_CBC(obj1.data));
  147. self.flowList = res.data;
  148. self.list1 = JSON.parse(JSON.stringify(res1.data));//当前部门现有的所有流程
  149. self.list2 = JSON.parse(JSON.stringify(res1.data));//对比数据是否发生变化
  150. self.flowList.forEach(function (item) {
  151. item.checked = false;
  152. item.show = true;
  153. self.list1.forEach(function (item1) {
  154. item1.checked = false;
  155. item1.show = true
  156. if (item.FLOWID == item1.FLOWID) {
  157. item.show = false;
  158. }
  159. })
  160. })
  161. if (n == 0) {
  162. sp.layer("#Add")
  163. }
  164. })
  165. })
  166. }
  167. self.num = 0;
  168. self.clickInit = function () {
  169. self.num++
  170. if (self.num == 5) {
  171. window.location.href="init.html"
  172. //var data = {
  173. // unitid: "AA",
  174. // arry: ['AA01', 'AA02']
  175. //}
  176. //$http.post(apiurljs.login + "g2app/DangAn/initFlowDataToDangAnManage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  177. //.success(function (obj) {
  178. // var res = strToJson(s4.decryptData_CBC(obj.data));
  179. // if (res.success == true) {
  180. // self.openAddLayer(1)
  181. // self.num = 0;
  182. // }
  183. //})
  184. }
  185. }
  186. self.setWENHAO = function (item) {
  187. console.log(item)
  188. var data = {
  189. tablename: item.TABLENAME,
  190. order: "sortid"
  191. }
  192. $http.post(apiurljs.login + "g2app/richang/queryColumnsData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  193. .success(function (obj) {
  194. var res = strToJson(s4.decryptData_CBC(obj.data));
  195. self.thead = [];
  196. $.each(res.data, function (index, item) {
  197. if (item.code != "ID" && item.code != "ROUTEINFOID" && item.code != "SORTID" && item.code != "APPCODE" && item.code != "CDATE") {
  198. self.thead.push({ code: item.code, cname: item.cname })
  199. }
  200. })
  201. self.setObjWH = {
  202. TABLECOLUMN: "",
  203. FLOWID: item.FLOWID,
  204. FLOWNAME: item.FLOWNAME,
  205. TABLENAME: item.TABLENAME,
  206. COMPCOLUMN: "WENHAO"
  207. };
  208. sp.layer("#setWH")
  209. });
  210. }
  211. self.btnSetWH = function () {
  212. var data = {
  213. tablename: "DATACOMPER",
  214. data: self.setObjWH
  215. }
  216. $http.post(apiurljs.login + "g2app/dataabase/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  217. .success(function (obj) {
  218. var res = strToJson(s4.decryptData_CBC(obj.data));
  219. if (res.success) {
  220. sp.dialog("设置成功!");
  221. self.getData(self.pageno);
  222. $timeout(function () {
  223. sp.dialoghide();
  224. }, 1000)
  225. } else {
  226. sp.dialog(res.message);
  227. }
  228. })
  229. }
  230. self.checkItem = function (item) {
  231. if (item.STATUS != "启用") {
  232. item.checked = !item.checked
  233. } else {
  234. return
  235. }
  236. }
  237. self.addFlag = true;
  238. self.addflow = function () {
  239. self.addFlag = true;
  240. var n = 0;
  241. self.flowList.forEach(function (item) {
  242. if (item.checked == true && item.show == true) {
  243. self.list1.push(item);
  244. item.checked = false;
  245. item.show = false;
  246. }
  247. if (item.show == false) {
  248. n++
  249. }
  250. })
  251. if (n == self.flowList.length) {
  252. self.addFlag = false;
  253. }
  254. }
  255. self.delflow = function () {
  256. var array = [];
  257. self.list1.forEach(function (item) {
  258. if (item.checked == true) {
  259. self.flowList.forEach(function (item1) {
  260. if (item.FLOWID == item1.FLOWID) {
  261. item1.checked = false;
  262. item1.show = true;
  263. }
  264. })
  265. } else {
  266. array.push(item)
  267. }
  268. })
  269. var n = 0;
  270. self.flowList.forEach(function (item) {
  271. if (item.show == true) {
  272. n++
  273. }
  274. })
  275. self.list1 = array;
  276. if (n > 0) {
  277. self.addFlag = true;
  278. }
  279. }
  280. self.addflowAll = function () {
  281. self.addFlag = true;
  282. self.flowList.forEach(function (item) {
  283. if (item.show == true) {
  284. self.list1.push(item);
  285. item.checked = false;
  286. item.show = false;
  287. }
  288. })
  289. self.addFlag = false;
  290. }
  291. self.delflowAll = function () {
  292. self.list1.forEach(function (item) {
  293. item.checked = false;
  294. item.show = true;
  295. })
  296. self.flowList.forEach(function (item) {
  297. item.checked = false;
  298. item.show = true;
  299. })
  300. self.list1 = [];
  301. self.addFlag = true;
  302. }
  303. self.btnSubmit = function () {
  304. var n = 0;
  305. self.list1.forEach(function (item) {
  306. self.list2.forEach(function (item1) {
  307. if (item.FLOWID == item1.FLOWID) {
  308. n++
  309. }
  310. })
  311. })
  312. if (n == self.list1.length) {
  313. sp.layerhide()
  314. sp.dialog("操作成功!")
  315. $timeout(function () {
  316. sp.dialoghide()
  317. }, 2000)
  318. return
  319. }
  320. var list = self.list1.map(function (item) {
  321. return {
  322. FLOWID: item.FLOWID,
  323. TABLENAME: item.TABLENAME,
  324. FLOWNAME: item.FLOWNAME,
  325. FLOWCODE: item.FLOWCODE,
  326. MOBANNAME: item.MOBANNAME,
  327. DOCUMENTTYPE: item.TABLENAME.indexOf("SW_") > -1 ? "收文" : "发文",
  328. STATUS: "启用",
  329. OUTFILEPATH: "/tmp",
  330. PRINTTYPE: 1,
  331. DPNAME: self.userDpName,
  332. DPCODE: self.userDpCode
  333. }
  334. })
  335. self.list.forEach(function (item) {
  336. list.forEach(function (item1) {
  337. if (item1.FLOWID == item.FLOWID) {
  338. item1.STATUS = item.STATUS;
  339. }
  340. })
  341. })
  342. var data = {
  343. tablename: "DANGANFLOW",
  344. delwhere: " dpcode='" + self.userDpCode + "'",
  345. data: list
  346. }
  347. $http.post(apiurljs.login + "g2app/DangAn/DangAnflowAddAndDel", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  348. .success(function (obj) {
  349. var res = strToJson(s4.decryptData_CBC(obj.data));
  350. sp.layerhide()
  351. self.getData(1)
  352. if (res.success) {
  353. sp.dialog("操作成功!")
  354. $timeout(function () {
  355. sp.dialoghide()
  356. }, 2000)
  357. } else {
  358. sp.dialog(res.message)
  359. }
  360. })
  361. }
  362. //1更新为启用,2更新为禁用
  363. self.upDataStatus = function (item, n) {
  364. var data = {
  365. id: item.ID,
  366. tablename: "DANGANFLOW",
  367. data: { STATUS: "" }
  368. }
  369. if (n == 1) {
  370. data.data.STATUS = "启用"
  371. } else {
  372. data.data.STATUS = "禁用"
  373. }
  374. $http.post(apiurljs.login + "g2app/dataabase/upFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  375. .success(function (obj) {
  376. var res = strToJson(s4.decryptData_CBC(obj.data));
  377. if (res.success) {
  378. self.getData(self.pageno)
  379. sp.dialog("已" + data.data.STATUS + "!");
  380. $timeout(function () {
  381. sp.dialoghide();
  382. }, 1000)
  383. } else {
  384. sp.dialog(res.message);
  385. }
  386. })
  387. }
  388. self.btnDel = function (item) {
  389. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  390. var dialogBody = "<div class=\"sp-dialog-body\">您确认要删除此记录吗?</div>";
  391. 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>";
  392. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  393. sp.openCenter(".sp-dialog");
  394. $('.sp-closeDialog').click(function (event) {
  395. sp.dialoghide();
  396. event.preventDefault();
  397. event.stopPropagation();
  398. });
  399. $("#upDataTrue").click(function () {
  400. sp.dialoghide();
  401. var data = {
  402. tablename: "DANGANFLOW",
  403. id: item.ID
  404. };
  405. $http.post(apiurljs.login + "g2app/dataabase/delDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  406. .success(function (obj) {
  407. var res = strToJson(s4.decryptData_CBC(obj.data));
  408. sp.dialoghide();
  409. if (res.success) {
  410. self.getData(self.pageno);
  411. } else {
  412. sp.dialog("删除失败,请联系管理员!");
  413. }
  414. });
  415. })
  416. }
  417. //头部下滚冻结
  418. $(function () {
  419. //页面高度撑满
  420. setTimeout(function () {
  421. if ($(".ibox-content").height() < $(window).height() - 31) {
  422. $(".ibox-content").css("height", $(window).height() - 31)
  423. }
  424. }, 1)
  425. })
  426. }])