list1.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  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. self.get_type = sp.getUrlName("type");
  13. var postCfg = {
  14. headers: {
  15. 'Content-Type': 'application/json',
  16. 'Authorization': "Bearer " + self.get_AccessToken
  17. }
  18. }
  19. self.getDpList = function () {
  20. $http.post(apiurljs.login + "g2app/dataabase/getDpList", { data: s4.encryptData_CBC("") }, postCfg)
  21. .success(function (obj) {
  22. var res = strToJson(s4.decryptData_CBC(obj.data));
  23. self.dpList = res.data;
  24. self.dpList.forEach(function (item) {
  25. item.checked = false;
  26. item.USER.forEach(function (item1) {
  27. item1.checked = false;
  28. item1.USHOWNAME1 = item1.USHOWNAME.length > 3 ? item1.USHOWNAME.slice(0, 3) + "..." : item1.USHOWNAME;
  29. item1.USHOWNAME2 = item1.USHOWNAME.length > 10 ? item1.USHOWNAME.slice(0, 10) + "..." : item1.USHOWNAME
  30. })
  31. })
  32. self.DpList = {
  33. SQBM: JSON.parse(JSON.stringify(self.dpList))
  34. }
  35. self.AllCheckedDp = {};
  36. self.DpLength = {};
  37. self.selectDpList = {};
  38. self.UserList = {
  39. PSLD: JSON.parse(JSON.stringify(self.dpList)),
  40. CYR: JSON.parse(JSON.stringify(self.dpList))
  41. };
  42. self.AllChecked = {};
  43. self.UserLength = {};
  44. self.selectList = {};
  45. self.getData()
  46. })
  47. }
  48. self.getData = function () {
  49. var data = {
  50. tablename: "HYQGC",
  51. colums: "*",
  52. order: "ID desc",
  53. sqlwhere: "",
  54. sqlorwhere: "",
  55. sqlinwhere: "",
  56. sqllikewhere: ""
  57. };
  58. $http.post(apiurljs.login + "g2app/richang/queryHYQGCDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  59. .success(function (obj) {
  60. var res = strToJson(s4.decryptData_CBC(obj.data));
  61. if (res.data == null || res.data == undefined || res.data == "") {
  62. self.noDataTip = 0;
  63. } else {
  64. self.noDataTip = 1;
  65. self.addFlag = false;
  66. self.editFlag = false;
  67. self.list = res.data;
  68. self.list.forEach(function (item) {
  69. item.checked = false;
  70. item.editFlag = false;
  71. for (var i in item) {
  72. isNull(item, i)
  73. }
  74. console.log(item.HYJYWJ)
  75. item.HYJYWJ1 = item.HYJYWJ == "" ? [] : JSON.parse(item.HYJYWJ)
  76. item.SQSJ= sp.datefmt("yyyy-MM-dd HH:mm",item.SQSJ)
  77. item.PSSJ = sp.datefmt("yyyy-MM-dd HH:mm", item.PSSJ)
  78. item.KSSJ = sp.datefmt("yyyy-MM-dd HH:mm", item.KSSJ)
  79. item.GDSJ = sp.datefmt("yyyy-MM-dd HH:mm", item.GDSJ)
  80. })
  81. }
  82. })
  83. }
  84. self.getDpList()
  85. self.goUrl = function (obj) {
  86. if (obj.FILEN != "") {
  87. window.top.sp.addTabNav("FZJ07", "会议室申请", "tpl/huiyishibg/" + obj.FILEN)
  88. }
  89. }
  90. self.init = function () {
  91. $http.post(apiurljs.login + "g2app/richang/initHYQGCData", { data: s4.encryptData_CBC(JSON.stringify({})) }, postCfg)
  92. .success(function (obj) {
  93. var res = strToJson(s4.decryptData_CBC(obj.data))
  94. if (res.success == true) {
  95. self.getData()
  96. }
  97. })
  98. }
  99. self.btnAdd = function () {
  100. self.addFlag = true;
  101. self.editFlag = false;
  102. self.list.forEach(function (item) {
  103. item.editFlag = false;
  104. })
  105. self.edit = {
  106. ID: 0,
  107. HYMC: "",
  108. SQSJ: "",
  109. SQBM: "",
  110. SQBM1: "",
  111. PSSJ: "",
  112. PSLD: "",
  113. PSLD1: "",
  114. PSLDID: "",
  115. HYS: "",
  116. KSSJ: "",
  117. CYR: "",
  118. CYR1: "",
  119. CYRID: "",
  120. }
  121. }
  122. self.btnEdit = function (obj) {
  123. self.editFlag = true;
  124. obj.editFlag = true;
  125. self.edit = {
  126. ID: obj.ID,
  127. HYMC: obj.HYMC,
  128. SQSJ: obj.SQSJ,
  129. SQBM: obj.SQBM,
  130. SQBM1: obj.SQBM,
  131. PSSJ: obj.PSSJ,
  132. PSLD: obj.PSLD,
  133. PSLD1: obj.PSLD,
  134. PSLDID: obj.PSLDID,
  135. HYS: obj.HYS,
  136. KSSJ: obj.KSSJ,
  137. CYR: obj.CYR,
  138. CYR1: obj.CYR,
  139. CYRID: obj.CYRID,
  140. }
  141. }
  142. self.btnDel = function (id) {
  143. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  144. var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
  145. var dialogFoot = "<div class=\"sp-dialog-foot\"><input id='delDataTrue' type='button' value='确 认' class='sp-dialog-btnTrue' /><input type='button' value='取 消' class='sp-dialog-btnCancle sp-closeDialog' /></div>";
  146. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  147. sp.openCenter(".sp-dialog");
  148. ///取消按钮
  149. $('.sp-closeDialog').click(function (event) {
  150. sp.closeCenter(".sp-dialog");
  151. event.preventDefault();
  152. event.stopPropagation();
  153. });
  154. //post消息的id
  155. $("#delDataTrue").click(function () {
  156. var data = {
  157. tablename: "HYQGC",
  158. id: id
  159. };
  160. $http.post(apiurljs.login + "g2app/dataabase/delDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  161. .success(function (obj) {
  162. var res = strToJson(s4.decryptData_CBC(obj.data));
  163. sp.dialoghide();
  164. if (res.success) {
  165. self.getData(self.pageno);
  166. } else {
  167. sp.dialog("删除失败,请联系管理员!");
  168. }
  169. });
  170. });
  171. }
  172. self.openDpList = function (str) {
  173. if (self.edit[str + "1"] != "") {
  174. return
  175. } else {
  176. var n = {}, all = {};
  177. for (var i in self.DpList) {
  178. self.AllCheckedDp[i] = false;
  179. self.DpLength[i] = 0;
  180. self.selectDpList[i] = []
  181. all[i] = 0;
  182. $.each(self.DpList[i], function (index, item) {
  183. self.DpLength[i]++
  184. if (self.data.SQBM.indexOf(item.SECTION) != -1 && i == "SQBM") {
  185. all[i]++;
  186. item.checked = true;
  187. self.selectDpList[i].push(item);
  188. }
  189. })
  190. if (all[i] == self.DpList[i].length) {
  191. self.AllCheckedDp[i] = true;
  192. } else {
  193. self.AllCheckedDp[i] = false;
  194. }
  195. }
  196. self.filed = str;
  197. sp.layer("#DpList")
  198. $("#DpList .sp-page").eq(0).scrollTop(0);
  199. }
  200. }
  201. self.checkAllDp = function () {
  202. self.AllCheckedDp[self.filed] = !self.AllCheckedDp[self.filed];
  203. $.each(self.DpList[self.filed], function (index, item) {
  204. item.checked = self.AllCheckedDp[self.filed];
  205. })
  206. self.submitDpList(1)
  207. }
  208. self.checkDpItem = function (item) {
  209. item.checked = !item.checked;
  210. var n = 0;
  211. $.each(self.DpList[self.filed], function (index, item) {
  212. if (item.checked == true) {
  213. n++
  214. }
  215. })
  216. if (n == self.DpList[self.filed].length) {
  217. self.AllCheckedDp[self.filed] = true;
  218. } else {
  219. self.AllCheckedDp[self.filed] = false;
  220. }
  221. self.submitDpList(1)
  222. }
  223. self.submitDpList = function (n) {
  224. var AllCheckedLength1 = 0;
  225. self.selectDpList[self.filed] = [];
  226. $.each(self.DpList[self.filed], function (index, item) {
  227. if (item.checked == true) {
  228. AllCheckedLength1++;
  229. self.selectDpList[self.filed].push(item)
  230. }
  231. })
  232. self.edit[self.filed] = self.selectDpList[self.filed].map(function (item) {
  233. return item.SECTION
  234. }).join(",")
  235. self.AllCheckedDp[self.filed] = AllCheckedLength1 == self.DpLength[self.filed];
  236. if (n == 0) {
  237. sp.layerhide();
  238. }
  239. }
  240. self.openUserList = function (str) {
  241. if (self.edit[str + "1"] != "") {
  242. return
  243. } else {
  244. var n = {}, all = {};
  245. for (var i in self.UserList) {
  246. self.AllChecked[i] = false;
  247. self.UserLength[i] = 0;
  248. self.selectList[i] = []
  249. n[i] = [];
  250. all[i] = 0;
  251. $.each(self.UserList[i], function (index, item) {
  252. n[i].push(0)
  253. item.checked = false;
  254. $.each(item.USER, function (index1, item1) {
  255. self.UserLength[i]++
  256. item1.checked = false;
  257. if (self.edit.PSLDID.indexOf(item1.USERID) != -1 && i == "PSLD") {
  258. n[i][index]++;
  259. item1.checked = true;
  260. self.selectList[i].push(item1);
  261. }
  262. if (self.edit.CYRID.indexOf(item1.USERID) != -1 && i == "CYR") {
  263. n[i][index]++;
  264. item1.checked = true;
  265. self.selectList[i].push(item1);
  266. }
  267. })
  268. if (n[i][index] == item.USER.length && n[i][index] != 0) {
  269. item.checked = true;
  270. all[i]++;
  271. }
  272. })
  273. if (all[i] == self.UserList[i].length) {
  274. self.AllChecked[i] = true;
  275. } else {
  276. self.AllChecked[i] = false;
  277. }
  278. }
  279. self.filed = str;
  280. sp.layer("#userList")
  281. $("#userList .sp-page").eq(0).scrollTop(0);
  282. }
  283. }
  284. self.checkAllUser = function () {
  285. self.AllChecked[self.filed] = !self.AllChecked[self.filed];
  286. $.each(self.UserList[self.filed], function (index, item) {
  287. item.checked = self.AllChecked[self.filed];
  288. $.each(item.USER, function (index1, item1) {
  289. item1.checked = self.AllChecked[self.filed];
  290. })
  291. })
  292. self.submitUserList(1)
  293. }
  294. self.checkUserItem = function (item) {
  295. item.checked = !item.checked;
  296. $.each(item.USER, function (index, item1) {
  297. item1.checked = item.checked;
  298. })
  299. var n = 0;
  300. $.each(self.UserList[self.filed], function (index, item) {
  301. if (item.checked == true) {
  302. n++
  303. }
  304. })
  305. if (n == self.UserList[self.filed].length) {
  306. self.AllChecked[self.filed] = true;
  307. } else {
  308. self.AllChecked[self.filed] = false;
  309. }
  310. self.submitUserList(1)
  311. }
  312. self.checkUser = function (item) {
  313. item.checked = !item.checked;
  314. var n = [], all = 0;
  315. $.each(self.UserList[self.filed], function (x, y) {
  316. n.push(0);
  317. $.each(y.USER, function (x1, y1) {
  318. if (y1.checked == true) {
  319. n[x]++
  320. }
  321. })
  322. if (n[x] == y.USER.length && n[x] != 0) {
  323. y.checked = true;
  324. all++
  325. } else {
  326. y.checked = false;
  327. }
  328. })
  329. if (all == self.UserList[self.filed].length) {
  330. self.AllChecked[self.filed] = true;
  331. } else {
  332. self.AllChecked[self.filed] = false;
  333. }
  334. self.submitUserList(1)
  335. }
  336. self.submitUserList = function (n) {
  337. var AllCheckedLength = 0;
  338. self.UserLength[self.filed] = 0;
  339. self.selectList[self.filed] = [];
  340. $.each(self.UserList[self.filed], function (index, item) {
  341. $.each(item.USER, function (index1, item1) {
  342. self.UserLength[self.filed]++;
  343. if (item1.checked == true) {
  344. AllCheckedLength++;
  345. self.selectList[self.filed].push(item1)
  346. }
  347. })
  348. })
  349. self.edit[self.filed] = self.selectList[self.filed].map(function (item) {
  350. return item.USHOWNAME
  351. }).join(",")
  352. if (self.edit[self.filed + "ID"] != undefined) {
  353. self.edit[self.filed + "ID"] = self.selectList[self.filed].map(function (item) {
  354. return item.USERID
  355. }).join(",")
  356. }
  357. self.AllChecked[self.filed] = AllCheckedLength == self.UserLength[self.filed];
  358. if (n == 0) {
  359. sp.layerhide();
  360. }
  361. }
  362. self.btnSubmit = function () {
  363. var data = {
  364. tablename: "HYQGC",
  365. data: {
  366. HYMC: self.edit.HYMC,
  367. SQSJ: self.edit.SQSJ,
  368. SQBM: self.edit.SQBM,
  369. PSSJ: self.edit.PSSJ,
  370. PSLD: self.edit.PSLD,
  371. PSLDID: self.edit.PSLDID,
  372. HYS: self.edit.HYS,
  373. KSSJ: self.edit.KSSJ,
  374. CYR: self.edit.CYR,
  375. CYRID: self.edit.CYRID
  376. }
  377. }
  378. $http.post(apiurljs.login + "g2app/dataabase/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  379. .success(function (obj) {
  380. var res = strToJson(s4.decryptData_CBC(obj.data));
  381. if (res.success) {
  382. sp.dialog("添加成功!");
  383. self.getData();
  384. $timeout(function () {
  385. sp.dialoghide();
  386. }, 1000)
  387. } else {
  388. sp.dialog(res.message);
  389. }
  390. })
  391. }
  392. self.btnSave = function () {
  393. var data = {
  394. id: self.edit.ID,
  395. tablename: "HYQGC",
  396. data: {
  397. HYMC: self.edit.HYMC,
  398. SQSJ: self.edit.SQSJ,
  399. SQBM: self.edit.SQBM,
  400. PSSJ: self.edit.PSSJ,
  401. PSLD: self.edit.PSLD,
  402. PSLDID: self.edit.PSLDID,
  403. HYS: self.edit.HYS,
  404. KSSJ: self.edit.KSSJ,
  405. CYR: self.edit.CYR,
  406. CYRID: self.edit.CYRID
  407. }
  408. }
  409. $http.post(apiurljs.login + "g2app/dataabase/upFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  410. .success(function (obj) {
  411. var res = strToJson(s4.decryptData_CBC(obj.data));
  412. if (res.success) {
  413. sp.dialog("保存成功!");
  414. self.getData();
  415. $timeout(function () {
  416. sp.dialoghide();
  417. }, 1000)
  418. } else {
  419. sp.dialog(res.message);
  420. }
  421. })
  422. }
  423. self.openFiles = function (obj) {
  424. self.filesTitle = obj.HYJYWJ1[0].DOCNAME;
  425. self.filesList = obj.HYJYWJ1;
  426. sp.layer("#files");
  427. }
  428. self.openFile = function (obj) {
  429. let postData = {
  430. convertType: 0,
  431. fileUrl: apiurljs.login.split("glwork/")[0] + "glworkweb/" + obj.FILEURL
  432. };
  433. var postCfg_transfer = {
  434. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  435. transformRequest: function (data) {
  436. return $.param(data);
  437. }
  438. };
  439. $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
  440. .success(function (res) {
  441. if (res.errorcode === 0) {
  442. let rst = res.data;
  443. window.open(rst.viewUrl)
  444. }
  445. });
  446. }
  447. }])
  448. function isNull(obj, str) {
  449. if (obj[str] == null) {
  450. obj[str] = "";
  451. }
  452. }