attachlist.js 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862
  1. 'use strict';
  2. var app = angular.module('app', [
  3. ]);
  4. //定义一个全局的截图插件变量
  5. var cropper;
  6. app.controller("formeditCtrl", ["$scope", "$http", "$timeout", "$interval", "$sce", function ($scope, $http, $timeout, $interval, $sce) {
  7. var self = this;
  8. var s4 = new SM4Util();
  9. self.userId = $.cookie("GlWorkPlatform-userid");
  10. self.userName = $.cookie("GlWorkPlatform-chineseName");
  11. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  12. self.routeid = sp.getUrlName("routeid");
  13. self.routeinfoid = sp.getUrlName("routeinfoid");
  14. self.directionid = sp.getUrlName("directionid");
  15. self.formeditid = sp.getUrlName("formeditid");
  16. self.docmode = sp.getUrlName("docmode");
  17. self.dotype = sp.getUrlName("dotype");
  18. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  19. self.get_lastReturnPage = sp.getUrlName("lastReturnPage");
  20. self.get_type = sp.getUrlName("type");
  21. if (self.get_lastReturnPage != "") {
  22. self.return = "../../../" + self.get_lastReturnPage + "?lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.get_type
  23. } else {
  24. self.return = "../list.html?lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.get_type
  25. }
  26. var postCfg = {
  27. headers: {
  28. 'Content-Type': 'application/json',
  29. 'Authorization': "Bearer " + self.get_AccessToken
  30. }
  31. };
  32. self.video = false;
  33. self.QianPi = false;
  34. self.watchNum = 0;
  35. //初始化右上角按钮
  36. self.buttonList = []
  37. var uploadformat = window.top.uploadformat.map(function (item) {
  38. return item.CNAME
  39. })
  40. self.getSwenList = function () {
  41. self.SwenList = [];
  42. var data = {
  43. directionid: self.directionid,
  44. userid: self.userId,
  45. routeinfoid: self.routeinfoid,
  46. routeid: self.routeid,
  47. formeditid: ""
  48. }
  49. $http.post(apiurljs.login + "g2app/abase/queryDataLink", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  50. .success(function (obj) {
  51. var res = strToJson(s4.decryptData_CBC(obj.data));
  52. $.each(res.data.LINKS, function (index, item) {
  53. item.TEMPFORM = item.TEMPFORM + "&flowid=" + sp.getUrlName("flowid")
  54. if (item.TEMPFORM.indexOf("attachlist.html") > -1) {
  55. self.Title = item.VNAME;
  56. }
  57. if (item.TEMPFORM.indexOf("?docmode") > 0) {
  58. if (item.TEMPFORM.indexOf("attachlist") > -1 || item.TEMPFORM.indexOf("fawenfile") > -1) {
  59. item.TEMPFORM = item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
  60. } else {
  61. item.TEMPFORM = "../" + item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
  62. }
  63. } else {
  64. item.TEMPFORM = "#";
  65. }
  66. self.SwenList.push(item)
  67. })
  68. self.SwenList.push({
  69. VNAME: "流程图",
  70. DIRECTIONID: self.SwenList[0].DIRECTIONID,
  71. TEMPFORM: "modeler_read.html?" + self.SwenList[0].TEMPFORM.split("?")[1]
  72. })
  73. self.getFuncList()
  74. })
  75. }
  76. self.getSwenList(0)
  77. self.getFuncList = function () {
  78. var data = {
  79. formeditid: self.formeditid,
  80. billkey: "FILE_ATTACH"
  81. }
  82. $http.post(apiurljs.login + "g2work/formedit/queryDataFormEditFunc", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  83. .success(function (obj) {
  84. var res = strToJson(s4.decryptData_CBC(obj.data));
  85. self.buttonList = res.data
  86. self.getData()
  87. })
  88. }
  89. self.getData = function () {
  90. var data = {
  91. tablename: "FILE_ATTACH",
  92. colums: "*",
  93. order: "ID desc",
  94. sqlwhere: { ROUTEINFOID: self.routeinfoid },
  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.arrayFile = res.data;
  102. self.getCJ()
  103. self.getMeetMsg()
  104. if (self.arrayFile.length > 0) {
  105. if (sp.getUrlName("FileNum") != "") {
  106. self.browse(self.arrayFile[sp.getUrlName("FileNum")])
  107. } else {
  108. self.browse(self.arrayFile[0])
  109. }
  110. }
  111. })
  112. }
  113. self.getCJ = function () {
  114. var data = {
  115. routeinfoid: self.routeinfoid
  116. }
  117. //$http.post(apiurljs.login + "g2app/plugin/queryPluginRouteDataList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  118. $http.post(apiurljs.login + "g2app/plugin/queryPluginRouteDataList", data, postCfg)
  119. .success(function (res) {
  120. //var res = strToJson(s4.decryptData_CBC(obj.data));
  121. self.cjList = res.data.reverse();
  122. self.getNumCJ()
  123. if (sp.getUrlName("CjNum") != "") {
  124. self.openCJ(self.cjList[sp.getUrlName("CjNum")])
  125. }
  126. if (sp.getUrlName("addSC") != "") {
  127. self.scLoadFirst = true;
  128. self.searchCj(1)
  129. }
  130. })
  131. }
  132. self.getNumCJ = function () {
  133. var data = {
  134. routeinfoid: self.routeinfoid
  135. }
  136. $http.post(apiurljs.login + "g2app/plugin/queryPluginRouteDataListCount", data, postCfg)
  137. .success(function (res) {
  138. if (res.data != self.cjList.length) {
  139. self.getCJ()
  140. }
  141. })
  142. }
  143. self.getMeetMsg = function () {
  144. var data = {
  145. routeid: self.routeid,
  146. routeinfoid: self.routeinfoid
  147. }
  148. $http.post(apiurljs.login + "g2work/meetcoop/queryDataList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  149. .success(function (obj) {
  150. var res = strToJson(s4.decryptData_CBC(obj.data));
  151. self.meetList = res.data;
  152. self.meetNum = 0;
  153. self.meetList.forEach(function (item) {
  154. self.meetNum++
  155. item.FILES.forEach(function (item1) {
  156. self.meetNum++
  157. item1.WATCHLIMIT = sp.format(item1.WATCHLIMIT);
  158. })
  159. })
  160. self.getNumMeet()
  161. })
  162. }
  163. self.getNumMeet = function () {
  164. var data = {
  165. routeinfoid: self.routeinfoid
  166. }
  167. $http.post(apiurljs.login + "g2work/meetcoop/queryDataListCount", data, postCfg)
  168. .success(function (obj) {
  169. var res = strToJson(s4.decryptData_CBC(obj.data));
  170. if (res.data != self.meetNum) {
  171. self.getMeetMsg()
  172. }
  173. })
  174. }
  175. $interval(function () {
  176. self.getNumCJ()
  177. self.getNumMeet()
  178. }, 2000)
  179. //右上角按钮调用方法
  180. self.btnEvent = function (item) {
  181. switch (item.CODE) {
  182. case "SENDLOG": self.RouteList(); break;
  183. case "PRINTITEM": self.btnPrint(); break;
  184. case "MEETITEM": self.Meet(); break;
  185. case "SAVESIGN": self.Qian(); break;
  186. default: self.forward(item); break;
  187. }
  188. }
  189. self.uploading = false;
  190. self.upload = function () {
  191. $('#fileupload').fileupload({
  192. url: apiurljs.login + 'g2app/abase/uploadFileWithForm',
  193. dataType: 'json',
  194. beforeSend: function (xhr, data) {
  195. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  196. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=FILE_ATTACH,routeinfoid=" + self.routeinfoid + ",ATTACHTYPE=机关党委非正式文"));
  197. },
  198. add: function (e, data) {
  199. var num = 0;
  200. var acceptFileTypes = eval('/(' + uploadformat.join("|") + ')$/i')
  201. //文件类型判断
  202. $.each(data.originalFiles, function (index, item) {
  203. if (item['type'].length > 0 && !acceptFileTypes.test(item['name'])) {
  204. sp.dialog("您好,请上传" + uploadformat.join("/") + "格式的文件!");
  205. return;
  206. } else {
  207. num++
  208. }
  209. })
  210. if (num == data.originalFiles.length) {
  211. self.uploading = true;
  212. data.submit(); $scope.$apply();
  213. }
  214. },
  215. // 上传完成后的执行逻辑
  216. done: function (e, data) {
  217. self.uploading = false;
  218. self.getData()
  219. }
  220. })
  221. }
  222. self.downLoad = function (item) {
  223. window.open(apiurljs.login + "g2work/files/" + item.FILEURL.slice(7))
  224. }
  225. self.deleteFile = function (file) {
  226. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  227. var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
  228. 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>";
  229. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  230. sp.openCenter(".sp-dialog");
  231. ///取消按钮
  232. $('.sp-closeDialog').click(function (event) {
  233. sp.closeCenter(".sp-dialog");
  234. event.preventDefault();
  235. event.stopPropagation();
  236. });
  237. //post消息的id
  238. $("#delDataTrue").click(function () {
  239. var data = {
  240. tablename: "FILE_ATTACH",
  241. id: file.ID
  242. };
  243. $http.post(apiurljs.login + "g2app/dataabase/delDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  244. .success(function (obj) {
  245. var res = strToJson(s4.decryptData_CBC(obj.data));
  246. sp.dialoghide();
  247. if (res.success) {
  248. $.each(self.iframeList, function (index, item) {
  249. if (item.title == file.FILENAMES && item.source == apiurljs.login + "g2work/files2/inline/" + file.FILEURL.slice(7)) {
  250. self.closeItem(index);
  251. return false;
  252. }
  253. })
  254. self.getData();
  255. } else {
  256. sp.dialog("删除失败,请联系管理员!");
  257. }
  258. });
  259. });
  260. }
  261. self.searchCj = function (n) {
  262. var data1 = {
  263. ckey: "CODE_PLUGINKINDS",
  264. routeinfoid: self.routeinfoid
  265. }
  266. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data1)) }, postCfg)
  267. .success(function (obj1) {
  268. var res1 = strToJson(s4.decryptData_CBC(obj1.data));
  269. self.KINDS = res1.data.CODE_PLUGINKINDS;
  270. var data2 = {
  271. ckey: "CODE_PLUGINDTYPE",
  272. routeinfoid: self.routeinfoid
  273. }
  274. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data2)) }, postCfg)
  275. .success(function (obj2) {
  276. var res2 = strToJson(s4.decryptData_CBC(obj2.data));
  277. self.DTYPE = res2.data.CODE_PLUGINDTYPE;
  278. var data3 = {
  279. ckey: "CODE_PLUGINAUTHMAN",
  280. routeinfoid: self.routeinfoid
  281. }
  282. $http.post(apiurljs.login + "g2app/abase/queryDataCode", { data: s4.encryptData_CBC(JSON.stringify(data3)) }, postCfg)
  283. .success(function (obj3) {
  284. var res3 = strToJson(s4.decryptData_CBC(obj3.data));
  285. self.AUTHMAN = res3.data.CODE_PLUGINAUTHMAN;
  286. self.search = {
  287. KINDS: "",
  288. DTYPE: ""
  289. }
  290. self.addSC = {};
  291. self.getCJlist(n)
  292. })
  293. })
  294. })
  295. }
  296. self.getCJlist = function (n) {
  297. var data = {
  298. kinds: self.search.KINDS,
  299. dtype: self.search.DTYPE,
  300. ctype: "C02"
  301. }
  302. $http.post(apiurljs.login + "g2app/plugin/queryDataList", data, postCfg)
  303. //$http.post(apiurljs.login + "g2app/plugin/queryDataList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  304. .success(function (res) {
  305. //var res = strToJson(s4.decryptData_CBC(obj.data));
  306. self.CJlist = res.data;
  307. self.CJlist.forEach(function (item) {
  308. self.AUTHMAN.forEach(function (item1) {
  309. if (item.AUTHMAN == item1.CODE) {
  310. item.AUTHMAN1 = item1.CNAME;
  311. }
  312. })
  313. if (sp.getUrlName("addSC") != "" && item.ID == sp.getUrlName("addSC") && self.scLoadFirst == true) {
  314. self.addSC = item;
  315. self.AddSC()
  316. self.scLoadFirst = false;
  317. }
  318. })
  319. if (n == 0) {
  320. sp.layer("#addCJ")
  321. }
  322. })
  323. }
  324. self.AddSC = function () {
  325. var n = 0;
  326. self.iframeList.forEach(function (item) {
  327. if (item.title == self.addSC.CNAME && item.source == self.addSC.URL) {
  328. n++
  329. }
  330. })
  331. if (n == 0) {
  332. self.iframeList.push({ id: self.iframeList.length + 1, title: self.addSC.CNAME, url: $sce.trustAsResourceUrl(addToken(self.addSC.URL)), source: self.addSC.URL, pgcode: self.addSC.PGCODE })
  333. self.add()
  334. }
  335. sp.layerhide();
  336. }
  337. self.Meeting = function () {
  338. $http.post(apiurljs.login + "g2app/dataabase/getDpList", { data: s4.encryptData_CBC("") }, postCfg)
  339. .success(function (obj) {
  340. var res = strToJson(s4.decryptData_CBC(obj.data));
  341. self.dpList = res.data;
  342. self.dpList1 = [];
  343. self.dpList.forEach(function (item) {
  344. self.dpList1.push(item)
  345. item.USER.forEach(function (item1) {
  346. item1.show = true;
  347. })
  348. })
  349. self.activeDep = 0;
  350. self.userList = self.dpList1[0].USER;
  351. self.meetUser = [];
  352. sp.layer("#meet")
  353. })
  354. }
  355. self.searchName = "";
  356. self.searchPerson = function () {
  357. self.dpList1 = [];
  358. self.dpList.forEach(function (item) {
  359. if (item.DEP.indexOf(self.searchName) > -1) {
  360. self.dpList1.push(item)
  361. }
  362. })
  363. self.activeDep = 0;
  364. self.userList = self.dpList1[0].USER;
  365. }
  366. self.addmeet = function () {
  367. self.dpList.forEach(function (item) {
  368. item.USER.forEach(function (item1) {
  369. if (item1.checked == true && item1.show == true) {
  370. self.meetUser.push(item1);
  371. item1.checked = false;
  372. item1.show = false;
  373. }
  374. })
  375. })
  376. }
  377. self.delmeet = function () {
  378. self.meetUser.forEach(function (item) {
  379. if (item.checked == true) {
  380. item.checked = false;
  381. item.show = true;
  382. }
  383. })
  384. self.meetUser = self.meetUser.filter(function (item) {
  385. return item.show == false;
  386. })
  387. }
  388. self.joinMeet = function () {
  389. var data = {
  390. tablename: "FW_JGDWFZSW",
  391. colums: "*",
  392. order: "ID desc",
  393. sqlwhere: { ROUTEINFOID: self.routeinfoid },
  394. sqlinwhere: "",
  395. sqllikewhere: ""
  396. }
  397. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  398. .success(function (obj) {
  399. var res = strToJson(s4.decryptData_CBC(obj.data));
  400. var data1 = {
  401. routeid: self.routeid,
  402. routeinfoid: self.routeinfoid,
  403. cman: self.userId,
  404. cname: res.data[0].BT + "—共享沟通",
  405. userids: self.meetUser.map(function (item) {
  406. return item.USERID
  407. }).join(",")
  408. }
  409. $http.post(apiurljs.login + "g2work/meetcoop/createMeetcoop", data1, postCfg)
  410. .success(function (res1) {
  411. sp.layerhide()
  412. if (res1.success == true) {
  413. self.getMeetMsg()
  414. } else {
  415. sp.dialog(res1.message)
  416. }
  417. })
  418. })
  419. }
  420. self.browse = function (obj) {
  421. var n = 0;
  422. self.iframeList.forEach(function (item) {
  423. if (item.title == obj.FILENAMES && item.source == apiurljs.login + "g2work/files2/inline/" + obj.FILEURL.slice(7)) {
  424. n++
  425. }
  426. })
  427. if (n == 0) {
  428. //console.log(obj);
  429. ///20230324---zyg ---永中转换-----start
  430. var set_convertType = 0;
  431. if (obj.FILEEXT == "doc") {
  432. set_convertType = 0;
  433. } else if (obj.FILEEXT == "pdf") {
  434. set_convertType = 20;
  435. } else if (obj.FILEEXT == "ofd") {
  436. set_convertType = 570;
  437. } else if (/(png|jpg|jpeg|gif|bmp|jfif|svg|tif|tiff)$/i.test(obj.FILEEXT) == true) {
  438. set_convertType = 23;
  439. } else {
  440. set_convertType = 0;
  441. }
  442. let postData = {
  443. convertType: set_convertType,
  444. fileUrl: apiurljs.login + "g2work/files2/inline/" + obj.FILEURL.slice(7)
  445. };
  446. var postCfg_transfer = {
  447. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  448. transformRequest: function (data) {
  449. return $.param(data);
  450. }
  451. };
  452. $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
  453. .success(function (res) {
  454. //console.log(res);
  455. if (res.errorcode === 0) {
  456. let rst = res.data;
  457. //console.log(rst.viewUrl);
  458. self.iframeList.push({ id: self.iframeList.length + 1, title: obj.FILENAMES, url: $sce.trustAsResourceUrl(rst.viewUrl), source: apiurljs.login + "g2work/files2/inline/" + obj.FILEURL.slice(7) })
  459. self.add()
  460. } else {
  461. sp.dialog(res.message);
  462. }
  463. });
  464. ///20230324---zyg ---永中转换-----end
  465. }
  466. }
  467. self.openCJ = function (obj) {
  468. var n = 0;
  469. self.iframeList.forEach(function (item) {
  470. if (item.title == obj.CNAME && item.source == obj.URL) {
  471. n++
  472. }
  473. })
  474. if (n == 0) {
  475. self.iframeList.push({ id: self.iframeList.length + 1, title: obj.CNAME, url: $sce.trustAsResourceUrl(addToken(obj.URL) + "&routeinfoid=" + self.routeinfoid + "&pgcode=" + obj.PGCODE + "&bookmarkid=" + obj.ID), source: obj.URL, pgcode: obj.PGCODE })
  476. self.add()
  477. }
  478. }
  479. self.deleteCJ = function (CJ) {
  480. var data = {
  481. id: CJ.ID
  482. }
  483. $http.post(apiurljs.login + "g2app/plugin/deletePluginRouteByID", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  484. .success(function (obj) {
  485. var res = strToJson(s4.decryptData_CBC(obj.data));
  486. if (res.success == true) {
  487. $.each(self.iframeList, function (index, item) {
  488. if (item.title == CJ.CNAME && item.source == CJ.URL) {
  489. self.closeItem(index)
  490. }
  491. })
  492. self.getCJ()
  493. } else {
  494. sp.dialog(res.message)
  495. }
  496. })
  497. }
  498. self.playItem = function (obj) {
  499. var n = 0;
  500. self.iframeList.forEach(function (item) {
  501. if (item.title == obj.WATCHLIMIT && item.source == obj.URL) {
  502. n++
  503. }
  504. })
  505. if (n == 0) {
  506. self.iframeList.push({ id: self.iframeList.length + 1, title: obj.WATCHLIMIT, url: $sce.trustAsResourceUrl(obj.FILEURL), source: obj.FILEURL })
  507. self.add()
  508. }
  509. }
  510. self.updateCname = function (item) {
  511. self.meeting = {
  512. type: 1,
  513. updateTitle: "修改会议标题",
  514. meetid: item.MEETID,
  515. cname: item.CNAME
  516. }
  517. sp.layer("#meetUpdate")
  518. }
  519. self.deleteMeet = function (meet) {
  520. var data = {
  521. meetid: meet.MEETID
  522. }
  523. $http.post(apiurljs.login + "g2work/meetcoop/deleteDataByID", data, postCfg)
  524. .success(function (res) {
  525. if (res.success == true) {
  526. $.each(self.iframeList, function (index, item) {
  527. $.each(meet.FILES, function (index1, item1) {
  528. if (item.title == item1.WATCHLIMIT && item.source == item1.FILEURL) {
  529. self.closeItem(index1)
  530. }
  531. })
  532. })
  533. self.getMeetMsg()
  534. } else {
  535. sp.dialog(res.message)
  536. }
  537. })
  538. }
  539. self.updateWatchlimit = function (item) {
  540. self.meeting = {
  541. type: 2,
  542. updateTitle: "修改查看时限",
  543. fileid: item.FILEID,
  544. watchlimit: item.WATCHLIMIT
  545. }
  546. sp.layer("#meetUpdate")
  547. }
  548. self.deleteMFile = function (mfile) {
  549. var data = {
  550. fileid: mfile.MEETID
  551. }
  552. $http.post(apiurljs.login + "g2work/meetcoop/deleteDataFilesByFileID", data, postCfg)
  553. .success(function (res) {
  554. if (res.success == true) {
  555. $.each(self.iframeList, function (index, item) {
  556. if (item.title == mfile.WATCHLIMIT && item.source == mfile.FILEURL) {
  557. self.closeItem(index)
  558. }
  559. })
  560. self.getMeetMsg()
  561. } else {
  562. sp.dialog(res.message)
  563. }
  564. })
  565. }
  566. self.meetUpdate = function () {
  567. if (self.meeting.type == 1) {
  568. var data = {
  569. meetid: self.meeting.meetid,
  570. cname: self.meeting.cname
  571. }
  572. $http.post(apiurljs.login + "g2work/meetcoop/updateCnameByID", data, postCfg)
  573. .success(function (res) {
  574. sp.layerhide()
  575. if (res.success == true) {
  576. self.getMeetMsg()
  577. } else {
  578. sp.dialog(res.message)
  579. }
  580. })
  581. } else {
  582. var data = {
  583. fileid: self.meeting.fileid,
  584. watchlimit: self.meeting.watchlimit
  585. }
  586. $http.post(apiurljs.login + "g2work/meetcoop/updateWatchlimitByFileID", data, postCfg)
  587. .success(function (res) {
  588. sp.layerhide()
  589. if (res.success == true) {
  590. self.getMeetMsg()
  591. } else {
  592. sp.dialog(res.message)
  593. }
  594. })
  595. }
  596. }
  597. self.iframeList = []//[{ id: 1, url: "../../index/img-new/background3.png", source: "../../index/img-new/background3.png", boxWidth: { width: 1200 }, iframeWidth: { width: 1190 } }]
  598. self.add = function () {
  599. if (self.iframeList.length == 1) {
  600. self.iframeList[0].boxWidth = { width: $(".col-md-10").width() }
  601. self.iframeList[0].iframeWidth = { width: $(".col-md-10").width() - 10 }
  602. } else {
  603. self.iframeList.forEach(function (item) {
  604. item.boxWidth = { width: Math.trunc($(".col-md-10").width() / 4 * 2 / (self.iframeList.length - 1)) - 10 }
  605. item.iframeWidth = { width: item.boxWidth.width - 10 }
  606. })
  607. self.iframeList[self.iframeList.length - 1].boxWidth = { width: Math.trunc($(".col-md-10").width() / 4 * 2) - 10 }
  608. self.iframeList[self.iframeList.length - 1].iframeWidth = { width: self.iframeList[self.iframeList.length - 1].boxWidth.width - 10 }
  609. }
  610. }
  611. self.openItem = function (obj) {
  612. window.open(obj.url)
  613. }
  614. self.closeItem = function (n) {
  615. self.iframeList.splice(n, 1)
  616. if (self.iframeList.length == 0) {
  617. } else if (self.iframeList.length == 1) {
  618. self.iframeList[0].boxWidth = { width: $(".col-md-10").width() }
  619. self.iframeList[0].iframeWidth = { width: $(".col-md-10").width() - 10 }
  620. } else {
  621. self.iframeList.forEach(function (item) {
  622. item.boxWidth = { width: Math.trunc($(".col-md-10").width() / 4 * 2 / (self.iframeList.length - 1)) - 10 }
  623. item.iframeWidth = { width: item.boxWidth.width - 10 }
  624. })
  625. self.iframeList[self.iframeList.length - 1].boxWidth = { width: Math.trunc($(".col-md-10").width() / 4 * 2) - 10 }
  626. self.iframeList[self.iframeList.length - 1].iframeWidth = { width: self.iframeList[self.iframeList.length - 1].boxWidth.width - 10 }
  627. }
  628. }
  629. self.reSize = function (n) {
  630. var leftbox = document.getElementsByClassName("iframe-item")[n - 1];
  631. var rightbox = document.getElementsByClassName("iframe-item")[n];
  632. var line = document.getElementsByClassName("iframe-border-right")[n - 1];
  633. document.getElementsByClassName("iframe-border-right")[n - 1].addEventListener("mousedown", function (event) {
  634. $(".mousemove").show()
  635. var leftboxW = leftbox.style.width.slice(0, leftbox.style.width.length - 2);
  636. var rightboxW = rightbox.style.width.slice(0, rightbox.style.width.length - 2);
  637. var x = event.pageX - line.offsetLeft;
  638. document.addEventListener("mousemove", boxMove)
  639. function boxMove(event) {
  640. if (leftboxW * 1 + (event.pageX - x) * 1 <= 200) {
  641. //document.removeEventListener("mousemove", boxMove)
  642. } else if (rightboxW * 1 - (event.pageX - x) * 1 <= 200) {
  643. //document.removeEventListener("mousemove", boxMove)
  644. } else {
  645. leftbox.style.width = leftboxW * 1 + (event.pageX - x) * 1 + "px";
  646. //leftbox.getElementsByClassName("iframe-title")[0].style.width = leftboxW * 1 + (event.pageX - x) * 1 - 10 + "px";
  647. leftbox.getElementsByTagName("iframe")[0].style.width = leftboxW * 1 + (event.pageX - x) * 1 - 10 + "px";
  648. self.iframeList[n - 1].boxWidth.width = leftboxW * 1 + (event.pageX - x) * 1;
  649. self.iframeList[n - 1].iframeWidth.width = leftboxW * 1 + (event.pageX - x) * 1 - 10;
  650. rightbox.style.width = rightboxW * 1 - (event.pageX - x) * 1 + "px";
  651. //rightbox.getElementsByClassName("iframe-title")[0].style.width = rightboxW * 1 - (event.pageX - x) * 1 - 10 + "px";
  652. rightbox.getElementsByTagName("iframe")[0].style.width = rightboxW * 1 - (event.pageX - x) * 1 - 10 + "px";
  653. self.iframeList[n].boxWidth.width = rightboxW * 1 - (event.pageX - x) * 1;
  654. self.iframeList[n].iframeWidth.width = rightboxW * 1 - (event.pageX - x) * 1 - 10;
  655. }
  656. }
  657. document.addEventListener("mouseup", function () {
  658. $(".mousemove").hide()
  659. document.removeEventListener("mousemove", boxMove)
  660. })
  661. })
  662. }
  663. //头部下滚冻结
  664. $(function () {
  665. //页面高度撑满
  666. setTimeout(function () {
  667. if ($(".ibox-content").height() < $(window).height() - 31) {
  668. $(".ibox-content").css("height", $(window).height() - 31)
  669. }
  670. $(".meeting").css("height", $(".ibox-content").height() - 636)
  671. }, 1)
  672. })
  673. //用来保存当前编辑图片的地址
  674. self.nowImgUrl = "";
  675. //打开截图收藏框
  676. self.joinItem = function (obj) {
  677. self.SCobj = {
  678. id: 0,
  679. routeinfoid: self.routeinfoid,
  680. pgcode: obj.pgcode,
  681. cname: "",
  682. url: obj.source,
  683. imagesmall: "",
  684. remark: ""
  685. }
  686. sp.layer('#layer_fav', 1);
  687. $("#imgUpload").blur();
  688. $("#imgUpload").val("");
  689. self.nowImgUrl = "";
  690. //每次打开截图层初始化截图窗口
  691. var image = document.querySelector('#image');
  692. cropper = new Cropper(image, {
  693. aspectRatio: 16 / 9,
  694. viewMode: 1,
  695. scalable: false,
  696. minCropBoxWidth: 64,
  697. minCropBoxHeight: 36,
  698. autoCrop: true,
  699. fillColor: "#fff",
  700. });
  701. }
  702. self.closeImgLayer = function () {
  703. self.nowImgUrl = "";
  704. $("#imgUpload").blur();
  705. $("#imgUpload").val("");
  706. cropper.destroy();
  707. sp.closeCenter('.sp-layer')
  708. }
  709. self.saveData = function () {
  710. var cas = cropper.getCroppedCanvas();
  711. var base64url = cas.toDataURL('image/png');
  712. console.log(base64url); //生成base64图片的格式
  713. self.SCobj.imagesmall = base64url;
  714. self.SCobj.cdate = sp.getLocalDate();
  715. self.SCobj.cman = self.userName;
  716. //$http.post(apiurljs.login + "g2app/plugin/savePluginRouteData", { data: s4.encryptData_CBC(JSON.stringify(self.SCobj)) }, postCfg)
  717. $http.post(apiurljs.login + "g2app/plugin/savePluginRouteData", self.SCobj, postCfg)
  718. .success(function (res) {
  719. //var res = strToJson(s4.decryptData_CBC(obj.data));
  720. self.closeImgLayer()
  721. if (res.success == true) {
  722. self.getCJ()
  723. } else {
  724. sp.dialog(res.message)
  725. }
  726. })
  727. }
  728. self.reset = function () {
  729. if (self.nowImgUrl != '') {
  730. cropper.reset();
  731. }
  732. }
  733. self.zoomOut = function () {
  734. if (self.nowImgUrl != '') {
  735. cropper.zoom(0.1);
  736. }
  737. }
  738. self.zoomIn = function () {
  739. if (self.nowImgUrl != '') {
  740. cropper.zoom(-0.1);
  741. }
  742. }
  743. self.clear = function () {
  744. if (self.nowImgUrl != '') {
  745. self.nowImgUrl = "";
  746. $("#imgUpload").blur();
  747. $("#imgUpload").val("");
  748. cropper.replace(" ", false);
  749. }
  750. }
  751. }])
  752. app.directive("repeatFinish", function () {
  753. return {
  754. link: function (scope) {
  755. if (scope.$last == true) {
  756. $("#iframeList").css("height", $(window).height() - 110)
  757. $(".mousemove").css("top", $("#iframeList").offset().top).css("left", $("#iframeList").offset().left).css("width", $("#iframeList").width()).css("height", $(window).height() - 110)
  758. }
  759. }
  760. };
  761. });
  762. //插件路径添加token
  763. function addToken(url) {
  764. var newUrl = "";
  765. if (url.indexOf("?") > -1) {
  766. newUrl = url + "&token=" + localStorage.getItem("main-token")
  767. } else {
  768. newUrl = url + "?token=" + localStorage.getItem("main-token")
  769. }
  770. return newUrl
  771. }
  772. function imgChange(e) {
  773. var files = document.getElementById('imgUpload').files;
  774. if (files[0].size > 3 * 1024 * 1024) {
  775. alert("上传文件不得超过3MB");
  776. return;
  777. }
  778. var reader = new FileReader();
  779. reader.onload = (function (file) {
  780. return function (e) {
  781. // //把图片路径复制到angular控件中
  782. angular.element(document.getElementById('app')).scope().ctl.nowImgUrl = this.result;
  783. angular.element(document.getElementById('app')).scope().$apply();
  784. $("#image").prop("src", this.result);
  785. cropper.replace(this.result, false);
  786. };
  787. })(e.target.files[0]);
  788. reader.readAsDataURL(e.target.files[0]);
  789. }
  790. document.body.addEventListener('paste', function (event) {
  791. if (!$("#layer_fav").is(":hidden")) {
  792. var items = (event.clipboardData || window.clipboardData).items;
  793. var file = null;
  794. var fileSize = 0;
  795. if (items && items.length) {
  796. //搜索剪切板items 只取第一个
  797. let first = items[0];
  798. if (first.type.indexOf('image') !== -1) {
  799. file = items[0].getAsFile();
  800. fileSize = file.size;
  801. }
  802. } else {
  803. alert('当前浏览器不支持');
  804. return;
  805. }
  806. if (!file) {
  807. //alert('粘贴内容非图片');
  808. return;
  809. }
  810. if (fileSize > 3 * 1024 * 1024) {
  811. alert('粘贴图片大小不得超过3MB');
  812. return;
  813. }
  814. // 此时file就是我们的剪切板中的图片对象
  815. // 如果需要预览,可以执行下面代码
  816. var reader = new FileReader()
  817. reader.onload = function (event) {
  818. // //把图片路径复制到angular控件中
  819. angular.element(document.getElementById('app')).scope().ctl.nowImgUrl = this.result;
  820. angular.element(document.getElementById('app')).scope().$apply();
  821. $("#image").prop("src", this.result);
  822. cropper.replace(this.result, false);
  823. }
  824. reader.readAsDataURL(file);
  825. } else {
  826. }
  827. });