index.js 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983
  1. 'use strict';
  2. var app = angular.module('app', [
  3. 'angularUtils.directives.dirPagination',
  4. ]);
  5. app.controller("indexCtrl", ["$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. var postCfg = {
  12. headers: {
  13. 'Content-Type': 'application/json',
  14. 'Authorization': "Bearer " + self.get_AccessToken
  15. }
  16. };
  17. self.CrossPage = window.parent.CrossPage;
  18. $(".filelist").css("height", $(".sp-wrapper-left").height() - 70)
  19. self.getLeftTree = function () {
  20. var data = {
  21. tablename: "KNOWLEDGETREE",
  22. cuserid: self.userId
  23. }
  24. $http.post(apiurljs.login + "g2app/dataabase/getTreeListByTablename2", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  25. .success(function (obj) {
  26. var res = strToJson(s4.decryptData_CBC(obj.data));
  27. self.leftTree = res.data;
  28. self.checkNode(self.leftTree[0].C_H_I_L_D_DATA[0])
  29. })
  30. }
  31. self.getLeftTree();
  32. self.addNode = function () {
  33. self.add = {
  34. "tablename": "KNOWLEDGETREE",
  35. "PARENT_CNAME": "知识库",
  36. "code": "P01",
  37. "levels": "1",
  38. "cname": "",
  39. "userid": self.userId
  40. }
  41. sp.layer('#layer_box_add')
  42. }
  43. ///修改菜单
  44. self.editNode = function (obj) {
  45. self.edit = {
  46. "id": obj.ID,
  47. "tablename": "KNOWLEDGETREE",
  48. "cname": obj.CNAME,
  49. "userid": self.userId
  50. }
  51. sp.layer('#layer_box_edit');
  52. };
  53. self.btnSaveNode = function (n) {
  54. if (n == 1) {
  55. var data = {
  56. "tablename": self.add.tablename,
  57. "code": self.add.code,
  58. "levels": self.add.levels,
  59. "cname": self.add.cname,
  60. "userid": self.add.userid
  61. }
  62. $http.post(apiurljs.login + "g2app/dataabase/TreeAdd", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  63. .success(function (obj) {
  64. var res = strToJson(s4.decryptData_CBC(obj.data));
  65. if (res.success) {
  66. sp.layerhide();
  67. self.getLeftTree();
  68. } else {
  69. sp.layerhide();
  70. sp.dialog(res.message);
  71. }
  72. })
  73. } else {
  74. var data = {
  75. "id": self.edit.id,
  76. "tablename": self.edit.tablename,
  77. "setwhere": {
  78. "CNAME": self.edit.cname
  79. }
  80. }
  81. $http.post(apiurljs.login + "g2app/dataabase/setColumnsById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  82. .success(function (obj) {
  83. var res = strToJson(s4.decryptData_CBC(obj.data));
  84. if (res.success) {
  85. sp.layerhide();
  86. self.getLeftTree();
  87. } else {
  88. sp.layerhide();
  89. sp.dialog(res.message);
  90. }
  91. })
  92. }
  93. }
  94. self.deleteNode = function (obj) {
  95. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  96. var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
  97. 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>";
  98. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  99. sp.openCenter(".sp-dialog");
  100. ///取消按钮
  101. $('.sp-closeDialog').click(function (event) {
  102. sp.closeCenter(".sp-dialog");
  103. event.preventDefault(); event.stopPropagation();
  104. });
  105. //post消息的id
  106. $("#delDataTrue").click(function () {
  107. sp.dialoghide();
  108. var postData = {
  109. id: obj.ID,
  110. tablename: "KNOWLEDGETREE",
  111. parentid: obj.PARENTID
  112. }
  113. $http.post(apiurljs.login + "g2app/dataabase/delNode", { data: s4.encryptData_CBC(JSON.stringify(postData)) }, postCfg)
  114. .success(function (obj) {
  115. var res = strToJson(s4.decryptData_CBC(obj.data));
  116. if (res.success) {
  117. self.getLeftTree();
  118. } else {
  119. sp.dialog(res.message);
  120. }
  121. });
  122. });
  123. }
  124. self.checkNode = function (obj) {
  125. self.active = obj;
  126. self.getRightData();
  127. }
  128. self.search = {
  129. type: "",
  130. name: ""
  131. }
  132. //关闭wps刷新
  133. $scope.WpsClose = function () {
  134. self.getRightData();
  135. }
  136. self.listType = 1;
  137. self.getRightData = function () {
  138. switch (self.active.CODE) {
  139. case "P0101": self.getGG(); break;
  140. case "P0102": self.getGR(); break;
  141. case "P0103": self.getFX(); break;
  142. case "P0104": self.getBFX(); break;
  143. default: self.getSelfData(); break
  144. }
  145. }
  146. self.getFileType = function (str) {
  147. var img = /(jpg|png|gif|tif|ico|bmp|tga|pic)$/i;
  148. var audio = /(mp3|wma|ape|flac|dts|m4a|aac|ac3|mmf|amr|m4r|ogg)$/i;
  149. var video = /(mp4|mkv|avi|flv|mov|wmv|3gp|3g2|mpg|vob|swf)$/i;
  150. var text = /(doc|docx|wps|ppt|pptx|xls|xlsx|ofd|pdf|txt|rar|zip)$/i;
  151. if (img.test(str) == true) {
  152. return "img"
  153. } else if (audio.test(str) == true) {
  154. return "audio"
  155. } else if (video.test(str) == true) {
  156. return "video"
  157. } else if (text.test(str) == true) {
  158. return "text"
  159. } else {
  160. return "other"
  161. }
  162. }
  163. self.getGG = function () {
  164. self.list = [];
  165. var data = {
  166. tablename: "KNOWLEDGEATTACHLIST",
  167. pageno: 0,
  168. pagesize: 0,
  169. colums: "ID,ATTACHTYPE,CODE,FILEEXT,FILEID,FILENAMES,FILEOLDNAME,FILESIZE,FILEURL,USERID,ROUTEINFOID,TO_CHAR(FILEDATE,'YYYY-mm-dd') AS FILEDATE1",
  170. order: "ID",
  171. sqlwhere: {
  172. ROUTEINFOID: self.active.ID
  173. },
  174. sqlorwhere: "",
  175. sqlinwhere: "",
  176. sqllikewhere: {
  177. FILEOLDNAME: self.search.name
  178. }
  179. }
  180. if (data.sqlwhere.ATTACHTYPE && self.search.type == "") {
  181. delete data.sqlwhere.ATTACHTYPE
  182. } else {
  183. data.sqlwhere.ATTACHTYPE = self.search.type
  184. }
  185. $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  186. .success(function (obj) {
  187. var res = strToJson(s4.decryptData_CBC(obj.data));
  188. self.list = res.data;
  189. $.each(self.list, function (index, item) {
  190. item.FILESIZE = item.FILESIZE >= 1048576 ? (item.FILESIZE / 1048576).toFixed(2) + "MB" : (item.FILESIZE / 1024).toFixed(2) + "KB";
  191. if (item.FILEEXT == "doc" || item.FILEEXT == "docx") {
  192. item.img = "css/doc.png";
  193. } else if (item.FILEEXT == "ppt" || item.FILEEXT == "pptx") {
  194. item.img = "css/ppt.png";
  195. } else if (item.FILEEXT == "xls" || item.FILEEXT == "xlsx") {
  196. item.img = "css/xls.png";
  197. } else if (item.FILEEXT == "ofd" || item.FILEEXT == "pdf") {
  198. item.img = "css/ofd.png";
  199. } else {
  200. item.img = "css/" + self.getFileType(item.FILEOLDNAME) + ".png";
  201. }
  202. })
  203. })
  204. }
  205. self.getGR = function () {
  206. self.list = [];
  207. var data = {
  208. tablename: "KNOWLEDGEATTACHLIST",
  209. pageno: 0,
  210. pagesize: 0,
  211. colums: "ID,ATTACHTYPE,CODE,FILEEXT,FILEID,FILENAMES,FILEOLDNAME,FILESIZE,FILEURL,USERID,ROUTEINFOID,TO_CHAR(FILEDATE,'YYYY-mm-dd') AS FILEDATE1",
  212. order: "ID",
  213. sqlwhere: {
  214. ROUTEINFOID: self.active.ID,
  215. USERID: self.userId
  216. },
  217. sqlorwhere: "",
  218. sqlinwhere: "",
  219. sqllikewhere: {
  220. FILEOLDNAME: self.search.name
  221. }
  222. }
  223. if (data.sqlwhere.ATTACHTYPE && self.search.type == "") {
  224. delete data.sqlwhere.ATTACHTYPE
  225. } else {
  226. data.sqlwhere.ATTACHTYPE = self.search.type
  227. }
  228. $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  229. .success(function (obj) {
  230. var res = strToJson(s4.decryptData_CBC(obj.data));
  231. self.list = res.data;
  232. $.each(self.list, function (index, item) {
  233. item.FILESIZE = item.FILESIZE >= 1048576 ? (item.FILESIZE / 1048576).toFixed(2) + "MB" : (item.FILESIZE / 1024).toFixed(2) + "KB";
  234. if (item.FILEEXT == "doc" || item.FILEEXT == "docx") {
  235. item.img = "css/doc.png";
  236. } else if (item.FILEEXT == "ppt" || item.FILEEXT == "pptx") {
  237. item.img = "css/ppt.png";
  238. } else if (item.FILEEXT == "xls" || item.FILEEXT == "xlsx") {
  239. item.img = "css/xls.png";
  240. } else if (item.FILEEXT == "ofd" || item.FILEEXT == "pdf") {
  241. item.img = "css/ofd.png";
  242. } else {
  243. item.img = "css/" + self.getFileType(item.FILEOLDNAME) + ".png";
  244. }
  245. })
  246. })
  247. }
  248. self.getFX = function () {
  249. self.list = [];
  250. var data = {
  251. tablename: "KNOWLEDGEATTACHLIST",
  252. pageno: 0,
  253. pagesize: 0,
  254. colums: "ID,ATTACHTYPE,CODE,FILEEXT,FILEID,FILENAMES,FILEOLDNAME,FILESIZE,FILEURL,USERID,ROUTEINFOID,TO_CHAR(FILEDATE,'YYYY-mm-dd') AS FILEDATE1",
  255. order: "ID",
  256. sqlwhere: {
  257. USERID: self.userId,
  258. SHAREMARK: 1
  259. },
  260. sqlorwhere: "",
  261. sqlinwhere: "",
  262. sqllikewhere: {
  263. FILEOLDNAME: self.search.name
  264. }
  265. }
  266. if (data.sqlwhere.ATTACHTYPE && self.search.type == "") {
  267. delete data.sqlwhere.ATTACHTYPE
  268. } else {
  269. data.sqlwhere.ATTACHTYPE = self.search.type
  270. }
  271. $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  272. .success(function (obj) {
  273. var res = strToJson(s4.decryptData_CBC(obj.data));
  274. self.list = res.data;
  275. $.each(self.list, function (index, item) {
  276. item.FILESIZE = item.FILESIZE >= 1048576 ? (item.FILESIZE / 1048576).toFixed(2) + "MB" : (item.FILESIZE / 1024).toFixed(2) + "KB";
  277. if (item.FILEEXT == "doc" || item.FILEEXT == "docx") {
  278. item.img = "css/doc.png";
  279. } else if (item.FILEEXT == "ppt" || item.FILEEXT == "pptx") {
  280. item.img = "css/ppt.png";
  281. } else if (item.FILEEXT == "xls" || item.FILEEXT == "xlsx") {
  282. item.img = "css/xls.png";
  283. } else if (item.FILEEXT == "ofd" || item.FILEEXT == "pdf") {
  284. item.img = "css/ofd.png";
  285. } else {
  286. item.img = "css/" + self.getFileType(item.FILEOLDNAME) + ".png";
  287. }
  288. })
  289. })
  290. }
  291. self.getBFX = function () {
  292. self.list = [];
  293. var data = {
  294. tablename: "KNOWLEDGEATTACHLIST",
  295. pageno: 0,
  296. pagesize: 0,
  297. colums: "ID,ATTACHTYPE,CODE,FILEEXT,FILEID,FILENAMES,FILEOLDNAME,FILESIZE,FILEURL,USERID,ROUTEINFOID,TO_CHAR(FILEDATE,'YYYY-mm-dd') AS FILEDATE1",
  298. order: "ID",
  299. sqlwhere: {},
  300. sqlorwhere: "",
  301. sqlinwhere: "",
  302. sqllikewhere: {
  303. FILEOLDNAME: self.search.name,
  304. TOSHAREUSERID: self.userId
  305. }
  306. }
  307. if (data.sqlwhere.ATTACHTYPE && self.search.type == "") {
  308. delete data.sqlwhere.ATTACHTYPE
  309. } else {
  310. data.sqlwhere.ATTACHTYPE = self.search.type
  311. }
  312. $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  313. .success(function (obj) {
  314. var res = strToJson(s4.decryptData_CBC(obj.data));
  315. self.list = res.data;
  316. $.each(self.list, function (index, item) {
  317. item.FILESIZE = item.FILESIZE >= 1048576 ? (item.FILESIZE / 1048576).toFixed(2) + "MB" : (item.FILESIZE / 1024).toFixed(2) + "KB";
  318. if (item.FILEEXT == "doc" || item.FILEEXT == "docx") {
  319. item.img = "css/doc.png";
  320. } else if (item.FILEEXT == "ppt" || item.FILEEXT == "pptx") {
  321. item.img = "css/ppt.png";
  322. } else if (item.FILEEXT == "xls" || item.FILEEXT == "xlsx") {
  323. item.img = "css/xls.png";
  324. } else if (item.FILEEXT == "ofd" || item.FILEEXT == "pdf") {
  325. item.img = "css/ofd.png";
  326. } else {
  327. item.img = "css/" + self.getFileType(item.FILEOLDNAME) + ".png";
  328. }
  329. })
  330. })
  331. }
  332. self.getSelfData = function () {
  333. self.list = [];
  334. var data = {
  335. tablename: "KNOWLEDGEATTACHLIST",
  336. pageno: 0,
  337. pagesize: 0,
  338. colums: "ID,ATTACHTYPE,CODE,FILEEXT,FILEID,FILENAMES,FILEOLDNAME,FILESIZE,FILEURL,USERID,ROUTEINFOID,TO_CHAR(FILEDATE,'YYYY-mm-dd') AS FILEDATE1",
  339. order: "ID",
  340. sqlwhere: {
  341. ROUTEINFOID: self.active.ID
  342. },
  343. sqlorwhere: "",
  344. sqlinwhere: "",
  345. sqllikewhere: {
  346. FILEOLDNAME: self.search.name
  347. }
  348. }
  349. if (data.sqlwhere.ATTACHTYPE && self.search.type == "") {
  350. delete data.sqlwhere.ATTACHTYPE
  351. } else {
  352. data.sqlwhere.ATTACHTYPE = self.search.type
  353. }
  354. $http.post(apiurljs.login + "g2app/dataabase/queryDataByColWithPage", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  355. .success(function (obj) {
  356. var res = strToJson(s4.decryptData_CBC(obj.data));
  357. self.list = res.data;
  358. $.each(self.list, function (index, item) {
  359. item.FILESIZE = item.FILESIZE >= 1048576 ? (item.FILESIZE / 1048576).toFixed(2) + "MB" : (item.FILESIZE / 1024).toFixed(2) + "KB";
  360. if (item.FILEEXT == "doc" || item.FILEEXT == "docx") {
  361. item.img = "css/doc.png";
  362. } else if (item.FILEEXT == "ppt" || item.FILEEXT == "pptx") {
  363. item.img = "css/ppt.png";
  364. } else if (item.FILEEXT == "xls" || item.FILEEXT == "xlsx") {
  365. item.img = "css/xls.png";
  366. } else if (item.FILEEXT == "ofd" || item.FILEEXT == "pdf") {
  367. item.img = "css/ofd.png";
  368. } else {
  369. item.img = "css/" + self.getFileType(item.FILEOLDNAME) + ".png";
  370. }
  371. })
  372. })
  373. }
  374. self.changeListType = function (n) {
  375. if (n == self.listType) {
  376. return;
  377. } else {
  378. self.listType = n;
  379. }
  380. }
  381. self.uploading = false;
  382. self.upload = function () {
  383. $('#fileupload').fileupload({
  384. url: apiurljs.login + 'g2app/abase/uploadFileWithForm',
  385. dataType: 'json',
  386. beforeSend: function (xhr, data) {
  387. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  388. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=KNOWLEDGEATTACHLIST,routeinfoid=" + self.active.ID + ",code=" + self.active.CODE + ",ATTACHTYPE=" + self.Filetype + ",userid=" + self.userId));
  389. },
  390. add: function (e, data) {
  391. self.Filetype = self.getFileType(data.files[0].name);
  392. //文件类型判断
  393. //if (!self.Filetype) {
  394. // sp.dialog(data.files[0].name + "文件类型不对");
  395. // return;
  396. //} else {
  397. self.uploading = true;
  398. data.submit(); $scope.$apply();
  399. //}
  400. },
  401. // 上传完成后的执行逻辑
  402. done: function (e, data) {
  403. self.uploading = false;
  404. var arrayFile = strToJson(s4.decryptData_CBC(data.result.data))
  405. //sp.transmit2("FILEMANAGER_SHENQING", "行政", "", arrayFile.data, self.active.ID, "KNOWLEDGEATTACHLIST")
  406. //sp.transmit1("FILEMANAGER_SHENQING", "行政", "", arrayFile.data[0].FILENAMES, arrayFile.data[0].FILEEXT, arrayFile.data[0].FILESIZE, arrayFile.data[0].FILEURL, arrayFile.data[0].FILEID, self.active.ID, "KNOWLEDGEATTACHLIST")
  407. self.getRightData();
  408. sp.dialog("上传成功!")
  409. $timeout(function () {
  410. sp.dialoghide()
  411. },1500)
  412. }
  413. })
  414. }
  415. self.downloadFile = function (item) {
  416. window.open(apiurljs.login + "g2work/files/" + item.FILEURL.slice(7))
  417. }
  418. self.fxFile = function (obj) {
  419. self.fxFileID = obj.ID;
  420. self.fxFileName = obj.FILEOLDNAME;
  421. self.fxFileName1 = obj.FILEOLDNAME.slice(0, 20) + "...";
  422. if (obj.TOSHAREUSERID) {
  423. self.personList.forEach(function (item) {
  424. item.C_H_I_L_D_DATA.forEach(function (item2) {
  425. item2.isChecked = obj.TOSHAREUSERID.indexOf(item2.userid) > -1 ? true : false;
  426. })
  427. item.C_H_I_L_D.forEach(function (item3) {
  428. item3.isChecked = false;
  429. item3.C_H_I_L_D_DATA.forEach(function (item4) {
  430. item4.isChecked = obj.TOSHAREUSERID.indexOf(item4.userid) > -1 ? true : false;
  431. })
  432. item3.C_H_I_L_D.forEach(function (item5) {
  433. item5.isChecked = false;
  434. item5.C_H_I_L_D_DATA.forEach(function (item6) {
  435. item6.isChecked = obj.TOSHAREUSERID.indexOf(item6.userid) > -1 ? true : false;
  436. })
  437. })
  438. })
  439. })
  440. }
  441. sp.layer("#layer_fenxiang")
  442. }
  443. self.btnFX = function () {
  444. var TOSHAREUSERID = []
  445. self.personList.forEach(function (item) {
  446. item.C_H_I_L_D_DATA.forEach(function (item2) {
  447. if (item2.isChecked) {
  448. TOSHAREUSERID.push(item2.userid);
  449. }
  450. })
  451. item.C_H_I_L_D.forEach(function (item3) {
  452. item3.C_H_I_L_D_DATA.forEach(function (item4) {
  453. if (item4.isChecked) {
  454. TOSHAREUSERID.push(item4.userid);
  455. }
  456. })
  457. item3.C_H_I_L_D.forEach(function (item5) {
  458. item5.C_H_I_L_D_DATA.forEach(function (item6) {
  459. if (item6.isChecked) {
  460. TOSHAREUSERID.push(item6.userid);
  461. }
  462. })
  463. })
  464. })
  465. })
  466. sp.layerhide();
  467. var data = {
  468. id: self.fxFileID,
  469. tablename: "KNOWLEDGEATTACHLIST",
  470. data: {
  471. TOSHAREUSERID: TOSHAREUSERID.join(","),
  472. SHAREMARK: 1
  473. }
  474. }
  475. $http.post(apiurljs.login + "g2app/dataabase/upFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  476. .success(function (obj) {
  477. var res = strToJson(s4.decryptData_CBC(obj.data));
  478. if (res.success) {
  479. self.getRightData();
  480. } else {
  481. sp.dialog(res.message)
  482. }
  483. })
  484. }
  485. //参会人员
  486. self.getPeople = function () {
  487. var data = {
  488. code: "AA"
  489. }
  490. $http.post(apiurljs.login + "g2app/calendar/querySect", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  491. .success(function (obj) {
  492. var res = strToJson(s4.decryptData_CBC(obj.data));
  493. $.each(res.data[0].C_H_I_L_D, function (index, item) {
  494. item.isChecked = false;
  495. $.each(item.C_H_I_L_D_DATA, function (index2, item2) {
  496. item2.isChecked = false;
  497. })
  498. $.each(item.C_H_I_L_D, function (index3, item3) {
  499. item3.isChecked = false;
  500. $.each(item3.C_H_I_L_D_DATA, function (index4, item4) {
  501. item4.isChecked = false;
  502. })
  503. $.each(item3.C_H_I_L_D, function (index5, item5) {
  504. item5.isChecked = false;
  505. $.each(item5.C_H_I_L_D_DATA, function (index6, item6) {
  506. item6.isChecked = false;
  507. })
  508. })
  509. })
  510. })
  511. self.personList = res.data[0].C_H_I_L_D;
  512. })
  513. }
  514. self.getPeople()
  515. //一级部门的勾选
  516. self.firstDepartSelect = function (index) {
  517. var flag = self.personList[index].isChecked;
  518. self.personList[index].C_H_I_L_D_DATA.forEach(function (item) {
  519. item.isChecked = flag;
  520. })
  521. self.personList[index].C_H_I_L_D.forEach(function (item2) {
  522. item2.isChecked = flag;
  523. item2.C_H_I_L_D_DATA.forEach(function (item3) {
  524. item3.isChecked = flag;
  525. });
  526. item2.C_H_I_L_D.forEach(function (item4) {
  527. item4.isChecked = flag;
  528. item4.C_H_I_L_D_DATA.forEach(function (item5) {
  529. item5.isChecked = flag;
  530. });
  531. })
  532. })
  533. var itemTotal = self.personList.length;
  534. var itemSelect = 0;
  535. self.personList.forEach(function (item) {
  536. if (item.isChecked) {
  537. itemSelect++
  538. }
  539. })
  540. if (itemTotal == itemSelect) {
  541. self.isSelectedAll = true;
  542. } else {
  543. self.isSelectedAll = false;
  544. }
  545. }
  546. //二级部门的勾选
  547. self.secondDepartSelect = function (index, index2) {
  548. var flag = self.personList[index].C_H_I_L_D[index2].isChecked;
  549. self.personList[index].C_H_I_L_D[index2].C_H_I_L_D_DATA.forEach(function (item) {
  550. item.isChecked = flag;
  551. })
  552. self.personList[index].C_H_I_L_D[index2].C_H_I_L_D.forEach(function (item2) {
  553. item2.isChecked = flag;
  554. item2.C_H_I_L_D_DATA.forEach(function (item3) {
  555. item3.isChecked = flag;
  556. });
  557. })
  558. var totalDepat = self.personList[index].C_H_I_L_D.length;
  559. var selectDepart = 0
  560. self.personList[index].C_H_I_L_D.forEach(function (item) {
  561. if (item.isChecked) {
  562. selectDepart++
  563. }
  564. })
  565. if (totalDepat == selectDepart) {
  566. var childTotal = self.personList[index].C_H_I_L_D_DATA.length;
  567. var childSelect = 0;
  568. self.personList[index].C_H_I_L_D_DATA.forEach(function (item) {
  569. if (item.isChecked) {
  570. childSelect++;
  571. }
  572. })
  573. if (childSelect == childTotal) {
  574. self.personList[index].isChecked = true;
  575. } else {
  576. self.personList[index].isChecked = false;
  577. }
  578. } else {
  579. self.personList[index].isChecked = false;
  580. }
  581. var itemTotal = self.personList.length;
  582. var itemSelect = 0;
  583. self.personList.forEach(function (item) {
  584. if (item.isChecked) {
  585. itemSelect++
  586. }
  587. })
  588. if (itemTotal == itemSelect) {
  589. self.isSelectedAll = true;
  590. } else {
  591. self.isSelectedAll = false;
  592. }
  593. }
  594. //三级部门点击
  595. self.thirdDepartSelect = function (index, index2, index3) {
  596. var flag = self.personList[index].C_H_I_L_D[index2].C_H_I_L_D[index3].isChecked;
  597. self.personList[index].C_H_I_L_D[index2].C_H_I_L_D[index3].C_H_I_L_D_DATA.forEach(function (item) {
  598. item.isChecked = flag;
  599. })
  600. var thirdDepat = self.personList[index].C_H_I_L_D[index2].C_H_I_L_D.length;
  601. var thirdDepart = 0;
  602. self.personList[index].C_H_I_L_D[index2].C_H_I_L_D.forEach(function (item) {
  603. if (item.isChecked) {
  604. thirdDepart++
  605. }
  606. })
  607. if (thirdDepat == thirdDepart) {
  608. var thirdTotal = self.personList[index].C_H_I_L_D[index2].C_H_I_L_D_DATA.length;
  609. var thirdSelect = 0;
  610. self.personList[index].C_H_I_L_D[index2].C_H_I_L_D_DATA.forEach(function (item) {
  611. if (item.isChecked) {
  612. thirdSelect++;
  613. }
  614. })
  615. if (thirdSelect == thirdTotal) {
  616. self.personList[index].C_H_I_L_D[index2].isChecked = true;
  617. } else {
  618. self.personList[index].C_H_I_L_D[index2].isChecked = false;
  619. }
  620. } else {
  621. self.personList[index].C_H_I_L_D[index2].isChecked = false;
  622. }
  623. var totalDepat = self.personList[index].C_H_I_L_D.length;
  624. var selectDepart = 0
  625. self.personList[index].C_H_I_L_D.forEach(function (item) {
  626. if (item.isChecked) {
  627. selectDepart++
  628. }
  629. })
  630. if (totalDepat == selectDepart) {
  631. var childTotal = self.personList[index].C_H_I_L_D_DATA.length;
  632. var childSelect = 0;
  633. self.personList[index].C_H_I_L_D_DATA.forEach(function (item) {
  634. if (item.isChecked) {
  635. childSelect++;
  636. }
  637. })
  638. if (childSelect == childTotal) {
  639. self.personList[index].isChecked = true;
  640. } else {
  641. self.personList[index].isChecked = false;
  642. }
  643. } else {
  644. self.personList[index].isChecked = false;
  645. }
  646. var itemTotal = self.personList.length;
  647. var itemSelect = 0;
  648. self.personList.forEach(function (item) {
  649. if (item.isChecked) {
  650. itemSelect++
  651. }
  652. })
  653. if (itemTotal == itemSelect) {
  654. self.isSelectedAll = true;
  655. } else {
  656. self.isSelectedAll = false;
  657. }
  658. }
  659. //三级部门人员点击
  660. self.thirdUserSelect = function (index, index2, index3) {
  661. var totalNum = self.personList[index].C_H_I_L_D[index2].C_H_I_L_D[index3].C_H_I_L_D_DATA.length;
  662. var selectNum = 0;
  663. self.personList[index].C_H_I_L_D[index2].C_H_I_L_D[index3].C_H_I_L_D_DATA.forEach(function (item) {
  664. if (item.isChecked) {
  665. selectNum++;
  666. }
  667. })
  668. if (totalNum == selectNum) {
  669. self.personList[index].C_H_I_L_D[index2].C_H_I_L_D[index3].isChecked = true;
  670. } else {
  671. self.personList[index].C_H_I_L_D[index2].C_H_I_L_D[index3].isChecked = false;
  672. }
  673. var thirdDepat = self.personList[index].C_H_I_L_D[index2].C_H_I_L_D.length;
  674. var thirdDepart = 0;
  675. self.personList[index].C_H_I_L_D[index2].C_H_I_L_D.forEach(function (item) {
  676. if (item.isChecked) {
  677. thirdDepart++
  678. }
  679. })
  680. if (thirdDepat == thirdDepart) {
  681. var thirdTotal = self.personList[index].C_H_I_L_D[index2].C_H_I_L_D_DATA.length;
  682. var thirdSelect = 0;
  683. self.personList[index].C_H_I_L_D[index2].C_H_I_L_D_DATA.forEach(function (item) {
  684. if (item.isChecked) {
  685. thirdSelect++;
  686. }
  687. })
  688. if (thirdSelect == thirdTotal) {
  689. self.personList[index].C_H_I_L_D[index2].isChecked = true;
  690. } else {
  691. self.personList[index].C_H_I_L_D[index2].isChecked = false;
  692. }
  693. } else {
  694. self.personList[index].C_H_I_L_D[index2].isChecked = false;
  695. }
  696. var totalDepat = self.personList[index].C_H_I_L_D.length;
  697. var selectDepart = 0
  698. self.personList[index].C_H_I_L_D.forEach(function (item) {
  699. if (item.isChecked) {
  700. selectDepart++
  701. }
  702. })
  703. if (totalDepat == selectDepart) {
  704. var childTotal = self.personList[index].C_H_I_L_D_DATA.length;
  705. var childSelect = 0;
  706. self.personList[index].C_H_I_L_D_DATA.forEach(function (item) {
  707. if (item.isChecked) {
  708. childSelect++;
  709. }
  710. })
  711. if (childSelect == childTotal) {
  712. self.personList[index].isChecked = true;
  713. } else {
  714. self.personList[index].isChecked = false;
  715. }
  716. } else {
  717. self.personList[index].isChecked = false;
  718. }
  719. var itemTotal = self.personList.length;
  720. var itemSelect = 0;
  721. self.personList.forEach(function (item) {
  722. if (item.isChecked) {
  723. itemSelect++
  724. }
  725. })
  726. if (itemTotal == itemSelect) {
  727. self.isSelectedAll = true;
  728. } else {
  729. self.isSelectedAll = false;
  730. }
  731. }
  732. //二级部门人员点击
  733. self.secondUserSelect = function (index, index2) {
  734. var totalNum = self.personList[index].C_H_I_L_D[index2].C_H_I_L_D_DATA.length;
  735. var selectNum = 0;
  736. self.personList[index].C_H_I_L_D[index2].C_H_I_L_D_DATA.forEach(function (item) {
  737. if (item.isChecked) {
  738. selectNum++;
  739. }
  740. })
  741. if (totalNum == selectNum) {
  742. self.personList[index].C_H_I_L_D[index2].isChecked = true;
  743. } else {
  744. self.personList[index].C_H_I_L_D[index2].isChecked = false;
  745. }
  746. var totalDepat = self.personList[index].C_H_I_L_D.length;
  747. var selectDepart = 0
  748. self.personList[index].C_H_I_L_D.forEach(function (item) {
  749. if (item.isChecked) {
  750. selectDepart++
  751. }
  752. })
  753. if (totalDepat == selectDepart) {
  754. var childTotal = self.personList[index].C_H_I_L_D_DATA.length;
  755. var childSelect = 0;
  756. self.personList[index].C_H_I_L_D_DATA.forEach(function (item) {
  757. if (item.isChecked) {
  758. childSelect++;
  759. }
  760. })
  761. if (childSelect == childTotal) {
  762. self.personList[index].isChecked = true;
  763. } else {
  764. self.personList[index].isChecked = false;
  765. }
  766. } else {
  767. self.personList[index].isChecked = false;
  768. }
  769. var itemTotal = self.personList.length;
  770. var itemSelect = 0;
  771. self.personList.forEach(function (item) {
  772. if (item.isChecked) {
  773. itemSelect++
  774. }
  775. })
  776. if (itemTotal == itemSelect) {
  777. self.isSelectedAll = true;
  778. } else {
  779. self.isSelectedAll = false;
  780. }
  781. }
  782. //一级部门人员点击
  783. self.firstUserSelect = function (index) {
  784. var totalDepat = self.personList[index].C_H_I_L_D.length;
  785. var selectDepart = 0
  786. self.personList[index].C_H_I_L_D.forEach(function (item) {
  787. if (item.isChecked) {
  788. selectDepart++
  789. }
  790. })
  791. if (totalDepat == selectDepart) {
  792. var childTotal = self.personList[index].C_H_I_L_D_DATA.length;
  793. var childSelect = 0;
  794. self.personList[index].C_H_I_L_D_DATA.forEach(function (item) {
  795. if (item.isChecked) {
  796. childSelect++;
  797. }
  798. })
  799. if (childSelect == childTotal) {
  800. self.personList[index].isChecked = true;
  801. } else {
  802. self.personList[index].isChecked = false;
  803. }
  804. } else {
  805. self.personList[index].isChecked = false;
  806. }
  807. var itemTotal = self.personList.length;
  808. var itemSelect = 0;
  809. self.personList.forEach(function (item) {
  810. if (item.isChecked) {
  811. itemSelect++
  812. }
  813. })
  814. if (itemTotal == itemSelect) {
  815. self.isSelectedAll = true;
  816. } else {
  817. self.isSelectedAll = false;
  818. }
  819. }
  820. //全选函数
  821. self.isSelectedAll = false;
  822. self.selectAll = function () {
  823. var flag = self.isSelectedAll;
  824. self.personList.forEach(function (item) {
  825. item.isChecked = flag;
  826. item.C_H_I_L_D_DATA.forEach(function (item2) {
  827. item2.isChecked = flag;
  828. })
  829. item.C_H_I_L_D.forEach(function (item3) {
  830. item3.isChecked = flag;
  831. item3.C_H_I_L_D_DATA.forEach(function (item4) {
  832. item4.isChecked = flag;
  833. })
  834. item3.C_H_I_L_D.forEach(function (item5) {
  835. item5.isChecked = flag;
  836. item5.C_H_I_L_D_DATA.forEach(function (item6) {
  837. item6.isChecked = flag;
  838. })
  839. })
  840. })
  841. })
  842. }
  843. self.deleteFile = function (item) {
  844. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  845. var dialogBody = "<div class=\"sp-dialog-body\">您确认要删除此文件吗?</div>";
  846. 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>";
  847. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  848. sp.openCenter(".sp-dialog");
  849. $('.sp-closeDialog').click(function (event) {
  850. sp.dialoghide();
  851. event.preventDefault();
  852. event.stopPropagation();
  853. });
  854. $("#upDataTrue").click(function () {
  855. sp.dialoghide();
  856. var data = {
  857. id: item.ID,
  858. tablename: "KNOWLEDGEATTACHLIST"
  859. }
  860. $http.post(apiurljs.login + "g2app/dataabase/delDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  861. .success(function (obj) {
  862. var res = strToJson(s4.decryptData_CBC(obj.data));
  863. if (res.success) {
  864. self.getRightData();
  865. //sp.deltransmit(item.FILEID)
  866. } else {
  867. sp.dialog(res.message)
  868. }
  869. })
  870. });
  871. }
  872. self.openAddFile = function () {
  873. self.add = {
  874. FILESNAME: "",
  875. }
  876. sp.layer("#layer_addwps")
  877. }
  878. self.btnAddWps = function () {
  879. var data = {
  880. tablename: "KNOWLEDGEATTACHLIST",
  881. data: {
  882. FILENAMES: self.add.FILESNAME + ".wps",
  883. FILEEXT: "",
  884. ATTACHTYPE: "text",
  885. CODE: self.active.CODE,
  886. USERID: self.userId,
  887. ROUTEINFOID: self.active.ID
  888. }
  889. }
  890. $http.post(apiurljs.login + "g2app/dataabase/insertFormData", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  891. .success(function (obj) {
  892. var res = strToJson(s4.decryptData_CBC(obj.data));
  893. sp.layerhide()
  894. if (res.success == true) {
  895. self.getRightData()
  896. } else {
  897. sp.dialeg(res.message)
  898. }
  899. })
  900. }
  901. self.goUrl = function (obj) {
  902. var set_convertType = 0;
  903. if (obj.FILEEXT == "pdf") {
  904. set_convertType = 20;
  905. } else if (obj.FILEEXT == "ofd") {
  906. set_convertType = 570;
  907. } else if (/(jpg|png|gif|bmp)$/i.test(obj.FILEEXT) == true) {
  908. set_convertType = 23;
  909. } else {
  910. set_convertType = 0;
  911. }
  912. let postData = {
  913. convertType: set_convertType,
  914. fileUrl: apiurljs.login + "g2work/files2/inline/" + obj.FILEURL.slice(7)
  915. };
  916. var postCfg_transfer = {
  917. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  918. transformRequest: function (data) {
  919. return $.param(data);
  920. }
  921. };
  922. $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
  923. .success(function (res) {
  924. //console.log(res);
  925. if (res.errorcode === 0) {
  926. let rst = res.data;
  927. window.open(rst.viewUrl)
  928. } else {
  929. sp.dialog(res.message);
  930. }
  931. });
  932. }
  933. }])