formedit.js 50 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269
  1. 'use strict';
  2. var app = angular.module('app', []);
  3. //定义一个全局的截图插件变量
  4. var cropper;
  5. app.controller("formeditCtrl", ["$scope", "$http", "$timeout", '$sce', function ($scope, $http, $timeout, $sce) {
  6. var self = this;
  7. var s4 = new SM4Util();
  8. self.userId = $.cookie("GlWorkPlatform-userid");
  9. self.userName = $.cookie("GlWorkPlatform-chineseName");
  10. self.get_AccessToken = localStorage.getItem("GlWorkPlatform-AccessToken");
  11. self.routeid = sp.getUrlName("routeid");
  12. self.routeinfoid = sp.getUrlName("routeinfoid");
  13. self.copyrightid = sp.getUrlName("copyrightid");
  14. self.directionid = sp.getUrlName("directionid");
  15. self.formeditid = sp.getUrlName("formeditid");
  16. self.mbid = sp.getUrlName("mbid");
  17. self.fjid = sp.getUrlName("fjid");
  18. self.docmode = sp.getUrlName("docmode");
  19. self.dotype = sp.getUrlName("dotype");
  20. self.get_lastReturnPageno = sp.getUrlName("lastReturnPageno");
  21. self.get_lastReturnPage = sp.getUrlName("lastReturnPage");
  22. self.get_type = sp.getUrlName("type");
  23. self.return = "../list.html?lastReturnPageno=" + self.get_lastReturnPageno + "&type=" + self.get_type
  24. self.deviceType = localStorage.getItem("tjJxtGoldenlinkWork-deviceType");
  25. var base64 = new Base64(); //声明base解码和编码类
  26. var postCfg = {
  27. headers: {
  28. 'Content-Type': 'application/json',
  29. 'Authorization': "Bearer " + self.get_AccessToken
  30. }
  31. };
  32. self.FormTitle = $.cookie("GlWorkPlatform-SYSNAME");
  33. //初始化只读数组
  34. self.readonly = {
  35. BT: false,
  36. FBT: false,
  37. LM: false,
  38. SFSYLB: false,
  39. WJBT: false,
  40. FBR: false,
  41. FBBM: false,
  42. FBRQ: false,
  43. FBNR: false,
  44. IMAGESDATA: false,
  45. VIDEODATA: false,
  46. IMAGEDATA: false,
  47. YJ: false
  48. }
  49. //初始化右上角按钮
  50. self.buttonList = []
  51. var uploadformat = strToJson(s4.decryptData_CBC(apiurljs.uploadformat)).data.map(function (item) {
  52. return item.CNAME
  53. })
  54. //上传附件
  55. self.arrayFile1 = [];
  56. self.arrayFile2 = [];
  57. self.arrayFile3 = [];
  58. self.beforeUpload = function (n) {
  59. if (self.data.ID == 0) {
  60. if (spngvld.submit(".formedit")) {
  61. var getContent = editor2.html();
  62. var getContent_base64 = base64.encode(getContent);
  63. self.data.FBNR = getContent_base64;
  64. var dataArray = [];
  65. dataArray.push(self.data);
  66. var data = {
  67. ckey: "WJFB_TPXW",
  68. id: self.data.ID,
  69. routeid: self.routeid,
  70. routeinfoid: self.routeinfoid,
  71. routeinfotitle: self.data.BT,
  72. directionid: self.directionid,
  73. formeditid: self.formeditid,
  74. data: JSON.stringify(dataArray)
  75. }
  76. $http.post(apiurljs.login + "g2app/abase/saveData", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  77. .success(function (obj) {
  78. var res = strToJson(s4.decryptData_CBC(obj.data));
  79. if (res.code == 0) {
  80. self.data.ID = res.data.ID;
  81. self.routeid = res.data.ROUTEID;
  82. self.routeinfoid = res.data.ROUTEINFOID;
  83. self.getSwenList(1)
  84. self.upload(n)
  85. } else {
  86. sp.dialog(res.message)
  87. }
  88. })
  89. }
  90. } else {
  91. self.upload(n)
  92. }
  93. }
  94. self.upload = function (n) {
  95. var column = n == 1 ? "IMAGESDATA" : "VIDEODATA"
  96. var acceptFileTypes = n == 1 ? /(jpg|png)$/i : /(mp4)$/i
  97. $('#fileupload' + n).fileupload({
  98. url: apiurljs.login + 'g2app/abase/uploadFileWithForm',
  99. dataType: 'json',
  100. beforeSend: function (xhr, data) {
  101. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  102. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=FILE_ATTACH,routeinfoid=" + self.routeinfoid + ",ATTACHTYPE=" + column));
  103. },
  104. add: function (e, data) {
  105. var num = 0;
  106. var acceptFileTypes = eval('/(' + uploadformat.join("|") + ')$/i')
  107. //文件类型判断
  108. $.each(data.originalFiles, function (index, item) {
  109. if (item.size / 1024 > 500) {
  110. sp.dialog("图片不能超过500kb!")
  111. return
  112. }
  113. if (item['type'] != null && item['type'] != undefined && !acceptFileTypes.test(item['name'])) {
  114. if (n == 2) {
  115. sp.dialog("您好,请上传MP4格式的文件!");
  116. } else {
  117. sp.dialog("您好,请上传JPG、PNG格式的文件!");
  118. }
  119. return;
  120. } else {
  121. num++
  122. }
  123. })
  124. if (num == data.originalFiles.length) {
  125. data.submit();
  126. $scope.$apply();
  127. }
  128. },
  129. // 上传完成后的执行逻辑
  130. done: function (e, data) {
  131. n == 1 ? self.getFile1() : self.getFile2()
  132. }
  133. })
  134. $timeout(function () {
  135. $("#fileupload" + n).trigger("click")
  136. }, 1)
  137. }
  138. self.upload1 = function () {
  139. $('#fileupload').fileupload({
  140. url: apiurljs.login + 'g2app/abase/uploadFileWithForm',
  141. dataType: 'json',
  142. beforeSend: function (xhr, data) {
  143. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  144. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=FILE_ATTACH,routeinfoid=" + self.routeinfoid + ",ATTACHTYPE=图片新闻"));
  145. },
  146. add: function (e, data) {
  147. var num = 0;
  148. var acceptFileTypes = eval('/(' + uploadformat.join("|") + ')$/i')
  149. //文件类型判断
  150. $.each(data.originalFiles, function (index, item) {
  151. if (item['type'].length > 0 && !acceptFileTypes.test(item['name'])) {
  152. sp.dialog("您好,请上传" + uploadformat.join("/") + "格式的文件!");
  153. return;
  154. } else {
  155. num++
  156. }
  157. })
  158. if (num == data.originalFiles.length) {
  159. self.uploading = true;
  160. data.submit();
  161. $scope.$apply();
  162. }
  163. },
  164. // 上传完成后的执行逻辑
  165. done: function (e, data) {
  166. self.uploading = false;
  167. self.getOther()
  168. }
  169. })
  170. }
  171. self.downLoad = function (item) {
  172. window.open(apiurljs.login + "g2work/files/" + item.FILEURL.slice(7))
  173. }
  174. self.deleteFile = function (file) {
  175. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  176. var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
  177. 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>";
  178. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  179. sp.openCenter(".sp-dialog");
  180. ///取消按钮
  181. $('.sp-closeDialog').click(function (event) {
  182. sp.closeCenter(".sp-dialog");
  183. event.preventDefault();
  184. event.stopPropagation();
  185. });
  186. //post消息的id
  187. $("#delDataTrue").click(function () {
  188. var data = {
  189. tablename: "FILE_ATTACH",
  190. id: file.ID
  191. };
  192. $http.post(apiurljs.login + "g2app/dataabase/delDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  193. .success(function (obj) {
  194. var res = strToJson(s4.decryptData_CBC(obj.data));
  195. sp.dialoghide();
  196. if (res.success) {
  197. self.getOther();
  198. } else {
  199. sp.dialog("删除失败,请联系管理员!");
  200. }
  201. });
  202. });
  203. }
  204. self.goAttach = function (obj) {
  205. if (obj) {
  206. if (apiurljs.zhType.indexOf(obj.FILEEXT) == -1) {
  207. sp.dialog("文件暂不支持在线预览,请点击下载查看!")
  208. return
  209. }
  210. $("#attachlist")[0].contentWindow.openFile(obj)
  211. if ($(".fa-chevron-down").is(":hidden") == true) {
  212. showToggle(document.getElementById("toggleButton"))
  213. }
  214. } else {
  215. $("#attachlist").attr("src", "attachlist.html?page=formedit&routeinfoid=" + self.routeinfoid)
  216. }
  217. }
  218. self.getSwenList = function (n) {
  219. self.SwenList = [];
  220. var data = {
  221. directionid: self.directionid,
  222. userid: self.userId,
  223. routeinfoid: self.routeinfoid,
  224. routeid: self.routeid,
  225. formeditid: ""
  226. }
  227. $http.post(apiurljs.login + "g2app/abase/queryDataLink", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  228. .success(function (obj) {
  229. var res = strToJson(s4.decryptData_CBC(obj.data));
  230. if (self.copyrightid == "") {
  231. self.copyrightid = res.data.LINKS[0].COPYRIGHTID
  232. }
  233. $.each(res.data.LINKS, function (index, item) {
  234. if (item.TEMPFORM.indexOf("formedit.html") > -1) {
  235. self.Title = item.VNAME;
  236. }
  237. if (item.TEMPFORM.indexOf("?docmode") > 0) {
  238. if (item.TEMPFORM.indexOf("attachlist") > -1) {
  239. item.TEMPFORM = item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
  240. } else {
  241. item.TEMPFORM = "../" + item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
  242. }
  243. } else {
  244. item.TEMPFORM = "#";
  245. }
  246. self.SwenList.push(item)
  247. })
  248. self.SwenList.push({
  249. VNAME: "流程图",
  250. DIRECTIONID: self.SwenList[0].DIRECTIONID,
  251. TEMPFORM: "modeler_read.html?" + self.SwenList[0].TEMPFORM.split("?")[1]
  252. })
  253. if (n == 0) {
  254. self.getFLOW()
  255. } else {
  256. self.getData()
  257. }
  258. })
  259. }
  260. self.getSwenList(0)
  261. self.getFLOW = function () {
  262. var data = {
  263. copyrightid: self.copyrightid
  264. }
  265. $http.post(apiurljs.login + "g2work/flow/queryDataByCopyrightid", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  266. .success(function (obj) {
  267. var res = strToJson(s4.decryptData_CBC(obj.data));
  268. self.flowTitle = res.data.CNAME;
  269. self.getZRBM()
  270. })
  271. }
  272. self.getZRBM = function () {
  273. var data = {
  274. ckey: "CODE_ZRBM",
  275. routeinfoid: self.routeinfoid
  276. }
  277. $http.post(apiurljs.login + "g2app/abase/queryDataCode", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  278. .success(function (obj) {
  279. var res = strToJson(s4.decryptData_CBC(obj.data));
  280. self.ZRBM = res.data.CODE_ZRBM;
  281. self.getSFSYLB()
  282. })
  283. }
  284. self.getSFSYLB = function () {
  285. var data = {
  286. ckey: "CODE_SFSYLB",
  287. routeinfoid: self.routeinfoid
  288. }
  289. $http.post(apiurljs.login + "g2app/abase/queryDataCode", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  290. .success(function (obj) {
  291. var res = strToJson(s4.decryptData_CBC(obj.data));
  292. self.SFSYLB = res.data.CODE_SFSYLB;
  293. self.getLM()
  294. })
  295. }
  296. self.getLM = function () {
  297. var data = {
  298. ckey: "CODE_LM",
  299. routeinfoid: self.routeinfoid
  300. }
  301. $http.post(apiurljs.login + "g2app/abase/queryDataCode", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  302. .success(function (obj) {
  303. var res = strToJson(s4.decryptData_CBC(obj.data));
  304. self.LM = res.data.CODE_LM;
  305. self.getDP()
  306. })
  307. }
  308. self.getDP = function () {
  309. var data = {
  310. userid: self.userId
  311. }
  312. $http.post(apiurljs.login + "g2app/richang/queryDpInfo", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  313. .success(function (obj) {
  314. var res = strToJson(s4.decryptData_CBC(obj.data));
  315. self.userDp = res.data.length == 0 ? "" : res.data[0].CODE;
  316. self.getData()
  317. })
  318. }
  319. //获取数据
  320. self.getData = function () {
  321. var data = {
  322. ckey: "WJFB_TPXW",
  323. id: 0,
  324. directionid: self.directionid,
  325. formeditid: self.formeditid,
  326. routeid: self.routeid,
  327. routeinfoid: self.routeinfoid
  328. }
  329. $http.post(apiurljs.login + "g2app/abase/queryData", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  330. .success(function (obj) {
  331. var res = strToJson(s4.decryptData_CBC(obj.data));
  332. self.data = {
  333. ID: res.data.WJFB_TPXW.ID,
  334. BT: res.data.WJFB_TPXW.BT,
  335. FBT: res.data.WJFB_TPXW.FBT,
  336. LM: "",
  337. FBNR: res.data.WJFB_TPXW.FBNR == null ? "" : res.data.WJFB_TPXW.FBNR,
  338. SFSYLB: res.data.WJFB_TPXW.SFSYLB == "" ? self.SFSYLB[0].CODE : res.data.WJFB_TPXW.SFSYLB,
  339. WJBT: res.data.WJFB_TPXW.WJBT,
  340. FBR: res.data.WJFB_TPXW.FBR == "" ? self.userName : res.data.WJFB_TPXW.FBR,
  341. FBBM: res.data.WJFB_TPXW.FBBM == "" ? self.userDp : res.data.WJFB_TPXW.FBBM,
  342. FBRQ: res.data.WJFB_TPXW.FBRQ == "" ? sp.format(sp.getLocalDate()) : sp.format(res.data.WJFB_TPXW.FBRQ),
  343. YJ: res.data.WJFB_TPXW.YJ,
  344. IMAGEDATA: res.data.WJFB_TPXW.IMAGEDATA
  345. }
  346. console.log(res.data.WJFB_TPXW.IMAGEDATA)
  347. self.readonly = {
  348. BT: res.data.WJFB_TPXW["BT.EREADONLY"] == "true",
  349. FBT: res.data.WJFB_TPXW["FBT.EREADONLY"] == "true",
  350. LM: res.data.WJFB_TPXW["LM.EREADONLY"] == "true",
  351. SFSYLB: res.data.WJFB_TPXW["SFSYLB.EREADONLY"] == "true",
  352. WJBT: res.data.WJFB_TPXW["WJBT.EREADONLY"] == "true",
  353. FBR: res.data.WJFB_TPXW["FBR.EREADONLY"] == "true",
  354. FBBM: res.data.WJFB_TPXW["FBBM.EREADONLY"] == "true",
  355. FBRQ: res.data.WJFB_TPXW["FBRQ.EREADONLY"] == "true",
  356. FBNR: res.data.WJFB_TPXW["FBNR.EREADONLY"] == "true",
  357. IMAGESDATA: res.data.WJFB_TPXW["IMAGESDATA.EREADONLY"] == "true",
  358. VIDEODATA: res.data.WJFB_TPXW["VIDEODATA.EREADONLY"] == "true",
  359. IMAGEDATA: res.data.WJFB_TPXW["IMAGEDATA.EREADONLY"] == "true",
  360. YJ: res.data.WJFB_TPXW["YJ.EREADONLY"] == "true"
  361. }
  362. editor2.html(base64.decode(self.data.FBNR));
  363. if (self.data.FBBM == "") {
  364. self.ZRBM.forEach(function (item) {
  365. if (item.CNAME == self.userDp) {
  366. self.data.FBBM = item.CODE;
  367. }
  368. })
  369. }
  370. if (self.data.ID == 0) {
  371. self.filedChange = true;
  372. } else {
  373. self.filedChange = false;
  374. }
  375. if (res.data.WJFB_TPXW.IMAGESDATA && res.data.WJFB_TPXW.IMAGESDATA != "") {
  376. self.arrayFile1 = JSON.parse(res.data.WJFB_TPXW.IMAGESDATA);
  377. self.arrayFile1.forEach(function (item) {
  378. item.FILEURL1 = $sce.trustAsResourceUrl(apiurljs.login + "g2work" + item.FILEURL)
  379. })
  380. }
  381. if (res.data.WJFB_TPXW.VIDEODATA && res.data.WJFB_TPXW.VIDEODATA != "") {
  382. self.arrayFile2 = JSON.parse(res.data.WJFB_TPXW.VIDEODATA);
  383. self.arrayFile2.forEach(function (item) {
  384. item.FILEURL1 = $sce.trustAsResourceUrl(apiurljs.login + "g2work" + item.FILEURL)
  385. })
  386. }
  387. //if (res.data.WJFB_TPXW.IMAGEDATA && res.data.WJFB_TPXW.IMAGEDATA != "") {
  388. // self.arrayFile3 = JSON.parse(res.data.WJFB_TPXW.IMAGEDATA);
  389. // self.arrayFile3.forEach(function (item) {
  390. // item.FILEURL1 = $sce.trustAsResourceUrl(apiurljs.login + "g2work" + item.FILEURL)
  391. // })
  392. //}
  393. editor2.html(base64.decode(res.data.WJFB_TPXW.FBNR));
  394. self.buttonList = res.data["WJFB_TPXW.FUNCLIST"];
  395. self.getOpinion("YJ")
  396. self.getOther()
  397. self.getFile1()
  398. self.getFile2()
  399. self.getFile3()
  400. //watermark({
  401. // "watermarl_element": "app",
  402. // "watermark_txt": "测试水印内容",
  403. // "watermark_width": 150,
  404. // "watermark_height": 110,
  405. // "watermark_angle": 345
  406. //})
  407. })
  408. }
  409. //获取附件和插件
  410. self.getOther = function () {
  411. if (self.routeinfoid == 0) { return }
  412. var data = {
  413. tablename: "FILE_ATTACH",
  414. colums: "*",
  415. order: "ID desc",
  416. sqlwhere: { ROUTEINFOID: self.routeinfoid, ATTACHTYPE: "图片新闻" },
  417. sqlinwhere: "",
  418. sqllikewhere: ""
  419. }
  420. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  421. .success(function (obj) {
  422. var res = strToJson(s4.decryptData_CBC(obj.data));
  423. self.arrayFile = [];
  424. if (res.data.length > 0) {
  425. res.data.forEach(function (item) {
  426. self.arrayFile.push(item)
  427. })
  428. }
  429. })
  430. }
  431. self.getFile1 = function () {
  432. var data = {
  433. tablename: "FILE_ATTACH",
  434. colums: "*",
  435. order: "ID desc",
  436. sqlwhere: { ROUTEINFOID: self.routeinfoid, ATTACHTYPE: "IMAGESDATA" },
  437. sqlinwhere: "",
  438. sqllikewhere: ""
  439. }
  440. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  441. .success(function (obj) {
  442. var res = strToJson(s4.decryptData_CBC(obj.data));
  443. self.arrayFile1 = [];
  444. if (res.data.length > 0) {
  445. res.data.forEach(function (item) {
  446. item.FILEURL1 = $sce.trustAsResourceUrl(apiurljs.login + "g2work" + item.FILEURL)
  447. self.arrayFile1.push(item)
  448. })
  449. }
  450. })
  451. }
  452. self.getFile2 = function () {
  453. var data = {
  454. tablename: "FILE_ATTACH",
  455. colums: "*",
  456. order: "ID desc",
  457. sqlwhere: { ROUTEINFOID: self.routeinfoid, ATTACHTYPE: "VIDEODATA" },
  458. sqlinwhere: "",
  459. sqllikewhere: ""
  460. }
  461. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  462. .success(function (obj) {
  463. var res = strToJson(s4.decryptData_CBC(obj.data));
  464. self.arrayFile2 = [];
  465. if (res.data.length > 0) {
  466. res.data.forEach(function (item) {
  467. item.FILEURL1 = $sce.trustAsResourceUrl(apiurljs.login + "g2work" + item.FILEURL)
  468. self.arrayFile2.push(item)
  469. })
  470. }
  471. })
  472. }
  473. self.getFile3 = function () {
  474. var data = {
  475. tablename: "FILE_ATTACH",
  476. colums: "*",
  477. order: "ID desc",
  478. sqlwhere: { ROUTEINFOID: self.routeinfoid, ATTACHTYPE: "IMAGEDATA" },
  479. sqlinwhere: "",
  480. sqllikewhere: ""
  481. }
  482. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  483. .success(function (obj) {
  484. var res = strToJson(s4.decryptData_CBC(obj.data));
  485. self.arrayFile3 = [];
  486. if (res.data.length > 0) {
  487. res.data.forEach(function (item) {
  488. item.FILEURL1 = $sce.trustAsResourceUrl(apiurljs.login + "g2work" + item.FILEURL)
  489. self.arrayFile3.push(item)
  490. })
  491. }
  492. })
  493. }
  494. //获取意见
  495. self.getOpinion = function (str) {
  496. var data = {
  497. cmanid: self.userId,
  498. routeinfoid: self.routeinfoid,
  499. routeid: "",//self.routeid,
  500. tableid: "WJFB_TPXW",
  501. colid: str,
  502. opiniontype: 0,
  503. orderbycol: "CDATE desc"
  504. }
  505. $http.post(apiurljs.login + "g2app/abase/queryDataOpinionWithRouteAttach", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  506. .success(function (obj) {
  507. var res = strToJson(s4.decryptData_CBC(obj.data));
  508. if (res.success == true) {
  509. self.YJ[str] = res.data;
  510. self.YJ[str + "STATUS"] = false;
  511. self.YJ[str].forEach(function (item) {
  512. item.CDATE = sp.datefmt("yyyy-MM-dd", item.CDATE);
  513. if (item.ROUTEID == self.routeid) {
  514. self.YJ[str + "STATUS"] = true;
  515. }
  516. })
  517. } else {
  518. sp.dialog(res.message)
  519. }
  520. })
  521. }
  522. //判断页面字段是否只读readonly、是否隐藏show
  523. self.hide = function (type, field) {
  524. if (self.dotype == 0 && type == "readonly") {
  525. return true;
  526. } else {
  527. if (self[type][field] == true) {
  528. return true;
  529. } else {
  530. return false;
  531. }
  532. }
  533. }
  534. //右上角按钮调用方法
  535. self.btnEvent = function (item) {
  536. switch (item.CODE) {
  537. case "SAVEITEM":
  538. self.btnSave(0);
  539. break;
  540. case "PRINTITEM":
  541. self.btnPrint();
  542. break;
  543. case "MEETITEM":
  544. self.Meet();
  545. break;
  546. case "SENDLOG":
  547. self.RouteList();
  548. break;
  549. default:
  550. self.forward(item);
  551. break;
  552. }
  553. }
  554. //保存提交,0直接保存,1保存后转发,2保存后对多人转发,3保存后跳转浏览
  555. self.btnSave = function (n) {
  556. //if (self.data.ID != 0 && self.arrayFile2.length != 0 && self.arrayFile3.length == 0) {
  557. // self.screenshot();
  558. // return
  559. //}
  560. if (spngvld.submit(".formedit")) {
  561. var getContent = editor2.html();
  562. var getContent_base64 = base64.encode(getContent);
  563. self.data.FBNR = getContent_base64;
  564. var dataArray = [];
  565. self.data.YJ = "";
  566. dataArray.push(self.data);
  567. var data = {
  568. ckey: "WJFB_TPXW",
  569. id: self.data.ID,
  570. routeid: self.routeid,
  571. routeinfoid: self.routeinfoid,
  572. routeinfotitle: self.data.BT,
  573. directionid: self.directionid,
  574. formeditid: self.formeditid,
  575. data: JSON.stringify(dataArray)
  576. }
  577. $http.post(apiurljs.login + "g2app/abase/saveData", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  578. .success(function (obj) {
  579. var res = strToJson(s4.decryptData_CBC(obj.data));
  580. if (res.code == 0) {
  581. self.data.ID = res.data.ID;
  582. self.routeid = res.data.ROUTEID;
  583. self.routeinfoid = res.data.ROUTEINFOID;
  584. self.filedChange = false;
  585. if (n == 0) {
  586. sp.dialog("保存成功!");
  587. $timeout(function () {
  588. sp.dialoghide()
  589. }, 1500)
  590. self.getSwenList(1)
  591. } else if (n == 1) {
  592. self.forward(self.btnItem);
  593. } else if (n == 2) {
  594. self.sendAll();
  595. } else if (n == 3) {
  596. self.browse()
  597. }
  598. } else {
  599. sp.dialog(res.message)
  600. }
  601. })
  602. }
  603. }
  604. //图片详情
  605. self.seePic = function (obj) {
  606. self.seePicUrl = obj.FILEURL1
  607. $('.sp-bgMask').fadeIn(200);
  608. $(".sp-bgMask").bind("click", function () {
  609. $(this).fadeOut(200);
  610. if ($("#seePic").is(":visible")) { //若对话框显示则淡出
  611. $("#seePic").fadeOut(200);
  612. }
  613. });
  614. $timeout(function () {
  615. sp.setCenter("#seePic")
  616. }, 1)
  617. }
  618. //浏览
  619. self.browse = function () {
  620. sp.openNewWindow(window.location.pathname.replace("formedit", "detail") + "?id=" + self.data.ID + "&formPage=formedit", "预览")
  621. }
  622. //打印
  623. self.btnPrint = function () {
  624. // 创建隐藏的可下载链接
  625. var eleLink = document.createElement('a');
  626. eleLink.download = "";
  627. eleLink.style.display = 'none';
  628. eleLink.href = apiurljs.login + "g2app/shouwen/PrintWord?data=" + encodeURIComponent(s4.encryptData_CBC("templatefilename=XZYGQJ.ftl&tablename=WJFB_TPXW&outfilepath=/tmp/市住建委干部因公请假申请表.wps&prtdate=TBSJ,QJSJKS,QJSJJS&routeinfoid=" + self.routeinfoid));
  629. // 触发点击
  630. document.body.appendChild(eleLink);
  631. eleLink.click();
  632. // 然后移除
  633. document.body.removeChild(eleLink);
  634. //window.open(apiurljs.login + "g2app/shouwen/PrintWord?templatefilename=shouwen.ftl&tablename=WJFB_TPXW&outfilepath=" + apiurljs.print + "&routeinfoid=" + self.routeinfoid)
  635. }
  636. //下载附件
  637. self.download = function (item) {
  638. window.open(apiurljs.login + "g2work/files/" + item.FILEURL.slice(7))
  639. }
  640. //删除附件
  641. self.deleteFile1 = function (item, str) {
  642. var data = {
  643. tablename: "FILE_ATTACH",
  644. id: item.ID
  645. };
  646. $http.post(apiurljs.login + "g2app/dataabase/delDataById", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  647. .success(function (obj) {
  648. var res = strToJson(s4.decryptData_CBC(obj.data));
  649. if (res.success) {
  650. if (str == "IMAGESDATA") {
  651. self.getFile1()
  652. } else if (str == "VIDEODATA") {
  653. self.getFile2()
  654. } else {
  655. self.getFile3()
  656. }
  657. } else {
  658. sp.dialog(res.message)
  659. }
  660. });
  661. }
  662. //视频截图
  663. self.screenshot = function () {
  664. var data = {
  665. tablename: "WJFB_TPXW",
  666. routeinfoid: self.routeinfoid,
  667. fileid: self.arrayFile2[0].FILEID,
  668. filecdate: self.arrayFile2[0].FILECDATE,
  669. filepath: self.arrayFile2[0].FILEURL,
  670. imgcolumn: "IMAGEDATA",
  671. count: 1
  672. }
  673. $http.post(apiurljs.login + "g2app/filepublishing/randomGrabberFFmpegImage", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  674. .success(function (obj) {
  675. var res = strToJson(s4.decryptData_CBC(obj.data));
  676. if (res.success == true) {
  677. self.btnSave(0)
  678. }
  679. })
  680. }
  681. //签写意见编辑状态
  682. self.opinion = {
  683. YJ: false,
  684. YJImg: false,
  685. }
  686. self.YJ = {
  687. YJ: [],
  688. YJSTATUS: false,
  689. }
  690. //下载意见表附件
  691. self.downLoadOption = function (item) {
  692. window.open(apiurljs.login + "g2work/files/" + item.FILEPATH.slice(7))
  693. }
  694. //删除意见表附件
  695. self.deleteOptionFile = function (file, str) {
  696. var data = {
  697. routeid: file.ROUTEID,
  698. tableid: "WJFB_TPXW",
  699. colid: str,
  700. fileid: file.FILEID
  701. };
  702. $http.post(apiurljs.login + "g2app/abase/deleteDataOpinionWithRouteAttach", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  703. .success(function (obj) {
  704. var res = strToJson(s4.decryptData_CBC(obj.data));
  705. sp.dialoghide();
  706. if (res.success) {
  707. self.getOpinion(str);
  708. } else {
  709. sp.dialog("删除失败,请联系管理员!");
  710. }
  711. });
  712. }
  713. //意见附件(上表)
  714. self.upload2 = function (str) {
  715. $('#fileupload-' + str).fileupload({
  716. url: apiurljs.login + 'g2app/abase/UploadWholeFileWithRouteAttach',
  717. dataType: 'json',
  718. beforeSend: function (xhr, data) {
  719. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  720. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=SYS_ROUTE_ATTACHLIST,userid=" + self.userId + ",routeinfoid=" + self.routeinfoid
  721. + ",routeid=" + self.routeid + ",tableid=WJFB_TPXW,colid=" + str));
  722. },
  723. // 上传完成后的执行逻辑
  724. done: function (e, data) {
  725. self.uploading1 = false;
  726. self.getOpinion(str)
  727. }
  728. })
  729. }
  730. //签写意见
  731. self.openOpinion = function (str) {
  732. if (self.routeinfoid == 0 && self.routeid == 0) {
  733. sp.dialog("请先保存!")
  734. return;
  735. }
  736. self.opinion[str] = true;
  737. }
  738. //修改意见
  739. self.changeOpinion = function (str) {
  740. self.data[str] = self.YJ[str][0].OPINION;
  741. self.opinion[str] = true;
  742. }
  743. self.changeOpinionItem = function (str, item) {
  744. if (item.OPINIONIMAGE != "") {
  745. self.QianZi(str);
  746. self.opinion[str + "Img"] = true;
  747. }
  748. self.data[str] = item.OPINION;
  749. self.opinion[str] = true;
  750. }
  751. //提交意见
  752. self.Sopinion = function (str) {
  753. if (self.opinion[str + "Img"] == true) {
  754. self.data[str] = $("#" + str + "QZ").find("canvas")[0].toDataURL();
  755. } else {
  756. self.data[str] = $("#" + str).val();
  757. }
  758. var data = {
  759. cmanid: self.userId,
  760. routeinfoid: self.routeinfoid,
  761. routeid: self.routeid,
  762. tableid: "WJFB_TPXW",
  763. colid: str,
  764. opiniontype: 0,
  765. cresult: "",
  766. opinion: self.opinion[str + "Img"] == false ? self.data[str] : "",
  767. opinionimage: self.opinion[str + "Img"] == true ? self.data[str] : ""
  768. }
  769. $http.post(apiurljs.login + "g2app/abase/saveDataOpinion", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  770. .success(function (obj) {
  771. var res = strToJson(s4.decryptData_CBC(obj.data));
  772. if (res.success == true) {
  773. sp.dialog("保存成功!");
  774. self.getOpinion(str);
  775. self.opinion[str] = false;
  776. self.opinion[str + "Img"] = false;
  777. self.data[str] = "";
  778. self.changeFiled(str)
  779. } else {
  780. sp.dialog(res.message)
  781. }
  782. })
  783. }
  784. //删除意见
  785. self.Dopinion = function (str, item) {
  786. var data = {
  787. cmanid: self.userId,
  788. routeid: self.routeid,
  789. tableid: "WJFB_TPXW",
  790. colid: str,
  791. }
  792. $http.post(apiurljs.login + "g2app/abase/deleteDataOpinion", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  793. .success(function (obj) {
  794. var res = strToJson(s4.decryptData_CBC(obj.data));
  795. if (res.success == true) {
  796. self.getOpinion(str);
  797. self.changeFiled(str)
  798. } else {
  799. sp.dialog(res.message)
  800. }
  801. })
  802. }
  803. self.phraseText = "";//添加常用语
  804. self.phraseList = []//常用语列表
  805. //获取常用语库
  806. self.phrase = function (colid) {
  807. sp.layer("#phrase");
  808. self.colid = colid;
  809. self.getPhrase();
  810. }
  811. //添加常用语到常用语库
  812. self.Aphrase = function () {
  813. if (self.phraseText == "") {
  814. return;
  815. }
  816. var data = {
  817. cmanid: self.userId,
  818. tableid: "WJFB_TPXW",
  819. colid: self.colid,
  820. contents: self.phraseText
  821. }
  822. $http.post(apiurljs.login + "g2app/abase/insertDataPatterns", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  823. .success(function (obj) {
  824. var res = strToJson(s4.decryptData_CBC(obj.data));
  825. if (res.success == true) {
  826. self.phraseText = "";
  827. self.getPhrase();
  828. } else {
  829. sp.dialog(res.message)
  830. }
  831. })
  832. }
  833. //获取常用语库
  834. self.getPhrase = function () {
  835. var data = {
  836. cmanid: self.userId,
  837. tableid: "WJFB_TPXW",
  838. colid: self.colid
  839. }
  840. $http.post(apiurljs.login + "g2app/abase/queryDataPatterns", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  841. .success(function (obj) {
  842. var res = strToJson(s4.decryptData_CBC(obj.data));
  843. self.phraseList = res.data;
  844. self.phraseSelect = self.phraseList[0].CONTENTS;
  845. })
  846. }
  847. //从常用语库删除
  848. self.Dphrase = function () {
  849. var id = null;
  850. $.each(self.phraseList, function (index, item) {
  851. if (item.CONTENTS == self.phraseSelect) {
  852. id = item.ID;
  853. }
  854. })
  855. var data = {
  856. id: id
  857. }
  858. $http.post(apiurljs.login + "g2app/abase/deleteDataPatterns", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  859. .success(function (obj) {
  860. var res = strToJson(s4.decryptData_CBC(obj.data));
  861. self.getPhrase();
  862. })
  863. }
  864. //常用语确认为意见
  865. self.btnPhrase = function () {
  866. if (!self.colid) {
  867. self.nulla = self.phraseSelect;
  868. } else {
  869. self.data[self.colid] = self.phraseSelect;
  870. }
  871. sp.layerhide();
  872. }
  873. //签字—手写
  874. self.QianZi = function (str) {
  875. self.opinion[str + "Img"] = true;
  876. setTimeout(function () {
  877. new lineCanvas(str + "QZ")
  878. }, 1)
  879. }
  880. //清除手写
  881. self.canvasClear = function (str) {
  882. var cxt = $("#" + str + "QZ").find("canvas")[0].getContext("2d");
  883. cxt.clearRect(0, 0, $("#" + str + "QZ").find("canvas")[0].width, $("#" + str + "QZ").find("canvas")[0].height)
  884. }
  885. //发生修改
  886. self.changeFiled = function (str) {
  887. self.filedChange = true;
  888. }
  889. //转发
  890. self.forward = function (obj) {
  891. self.btnItem = obj;
  892. if (self.filedChange == true) {
  893. self.btnSave(1)
  894. } else {
  895. $("#forwardWin").attr("src", "../../forward/forward.html?routeid=" + self.routeid + "&routeinfoid=" + self.routeinfoid + "&copyrightid=" + self.copyrightid + "&directionid=" + self.directionid + "&formeditid=" + self.formeditid + "&codefuncbutton=" + obj.CODE + "&directionidtarget=" + obj.DIRECTIONIDTARGET + "&cookie=wenjianbg")
  896. sp.layer("#forward")
  897. }
  898. }
  899. //查看流转记录
  900. self.RouteList = function () {
  901. if (self.deviceType == "pad") {
  902. window.location.href = "../../forward/modeler_read.html?" + self.SwenList[0].TEMPFORM.split("?")[1]
  903. } else {
  904. sp.openNewWindow("../../forward/modeler_read.html?" + self.SwenList[0].TEMPFORM.split("?")[1], "流程图")
  905. }
  906. //var data = {
  907. // directionid: self.directionid,
  908. // userid: self.userId,
  909. // routeid: self.routeid,
  910. // routeinfoid: self.routeinfoid,
  911. //}
  912. //$http.post(apiurljs.login + "g2app/abase/queryDataRouteList", {data: s4.encryptData_CBC(JSON.stringify(data))}, postCfg)
  913. // .success(function (obj) {
  914. // var res = strToJson(s4.decryptData_CBC(obj.data));
  915. // self.routeList = res.data;
  916. // $.each(self.routeList, function (index, item) {
  917. // item.mainUser = [];
  918. // item.copyUsers = [];
  919. // $.each(item.USERS, function (index1, item1) {
  920. // if (item1.KIND == 0) {
  921. // item.mainUser.push(item1.USERNAME);
  922. // } else {
  923. // item.copyUsers.push(item1.USERNAME);
  924. // }
  925. // })
  926. // item.mainUser = item.mainUser.join(",");
  927. // item.copyUsers = item.copyUsers.join(",");
  928. // })
  929. // setTimeout(function (item) {
  930. // sp.layer("#RouteList");
  931. // }, 100);
  932. // })
  933. }
  934. self.reSizeRow = function () {
  935. var bodybox = document.getElementById("bodyDiv");
  936. var topbox = document.getElementById("topDiv");
  937. var bottombox = document.getElementById("bottomDiv");
  938. var line = document.getElementById("lineDiv");
  939. document.getElementById("lineDiv").addEventListener("mousedown", function (event) {
  940. $(".mousemove").show()
  941. var bodyboxH = bodybox.clientHeight;
  942. var topboxH = topbox.clientHeight;
  943. var bottomboxH = bottombox.clientHeight;
  944. //var y = event.pageY - line.offsetTop;
  945. var y = event.pageY - line.clientHeight;
  946. document.addEventListener("mousemove", boxMove)
  947. function boxMove(event) {
  948. if (topboxH * 1 + (event.pageY - y) * 1 - 36 <= 45) {
  949. //
  950. } else if (bottomboxH * 1 - (event.pageY - y) * 1 - 36 <= 45) {
  951. //
  952. } else {
  953. topbox.style.height = topboxH * 1 + (event.pageY - y) * 1 - 36 + "px";
  954. //topbox.getElementsByTagName("iframe")[0].style.height = topboxH * 1 + (event.pageY - y) * 1 - 45 + "px";
  955. bottombox.style.height = bodyboxH * 1 - topboxH * 1 - (event.pageY - y) * 1 + 36 + "px";
  956. bottombox.getElementsByTagName("iframe")[0].style.height = bodyboxH * 1 - topboxH * 1 - (event.pageY - y) * 1 - 25 + "px";
  957. }
  958. }
  959. document.addEventListener("mouseup", function () {
  960. $(".mousemove").hide()
  961. document.removeEventListener("mousemove", boxMove)
  962. })
  963. })
  964. }
  965. ////头部关键字搜索---20230905
  966. self.headBtnSearchKeyword = "";
  967. self.headSearchResult = [];
  968. self.headSearchResult_view = false;
  969. self.headBtnSearch = function () {
  970. if (sp.isval(self.headBtnSearchKeyword)) {
  971. self.headSearchResult = [];
  972. var data = {
  973. "url": "/basic/api/StatSelect/selectCodeList",
  974. "data": { "keyWord": self.headBtnSearchKeyword }
  975. }
  976. //console.log(JSON.stringify(data));
  977. $http.post(apiurljs.login + "g2app/yizhangtu/selectCodeList", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  978. .success(function (obj) {
  979. var res = strToJson(s4.decryptData_CBC(obj.data));
  980. //console.log(JSON.stringify(res.data));
  981. self.headSearchResult = res.data.build;
  982. if (sp.isval(self.headSearchResult)) {
  983. self.headSearchResult_view = true;
  984. } else {
  985. self.headSearchResult_view = false;
  986. }
  987. })
  988. } else {
  989. self.headSearchResult_view = false;
  990. }
  991. };
  992. self.headKeywordPage = function (itemdata) {
  993. var get_token = localStorage.getItem("main-token");
  994. var set_url = apiurljs.onePic + "wholeProcessPage/?token=" + get_token + "&name=" + itemdata.name + "&type=" + itemdata.type + "&id=" + itemdata.id;
  995. $('#attachlist')[0].contentWindow.openTool(set_url, '一张图');
  996. self.headSearchResult_view = false;
  997. };
  998. self.onePic = function () {
  999. $('#attachlist')[0].contentWindow.openTool(apiurljs.onePic + "wholeProcessPage/?token=" + localStorage.getItem("main-token"), "地图搜索")
  1000. }
  1001. //头部下滚冻结
  1002. $(function () {
  1003. $(".sp-page-center").eq(0).css("max-height", $("#topDiv").height()).css("height", $("#topDiv").height())
  1004. //$("body").bind("scroll", function () {
  1005. // var scrollTop = $("body").scrollTop();
  1006. // if (scrollTop == 0) {
  1007. // $(".FixTop").removeClass("FixTop");
  1008. // }
  1009. // if (scrollTop > 35) {
  1010. // $(".sp-page-title").parents(".sp-box").addClass("FixTop");
  1011. // }
  1012. //});
  1013. //页面高度撑满
  1014. setTimeout(function () {
  1015. if ($(".ibox-content").height() < $(window).height() - 31) {
  1016. $(".ibox-content").css("height", $(window).height() - 31)
  1017. }
  1018. $(".mousemove").css("top", 0).css("left", 0).css("width", $(window).width()).css("height", $(window).height() - 10)
  1019. }, 1)
  1020. })
  1021. var editor2;
  1022. self.setKindEditor2 = function () {
  1023. var options = {
  1024. uploadJson: apiurljs.login + "g2app/abase/uploadFileKindeditorImage/" + s4.encryptData_CBC(JSON.stringify("FILEKINDEDITOR_ATTACH")),
  1025. fileManagerJson: apiurljs.login + 'g2app/abase/uploadFileKindeditorImage/' + s4.encryptData_CBC(JSON.stringify("FILEKINDEDITOR_ATTACH")),
  1026. filterMode: true,//过滤HTML代码
  1027. allowImageUpload: true,
  1028. allowFlashUpload: false,
  1029. allowMediaUpload: false,
  1030. allowFileManager: false,
  1031. themeType: 'simple',
  1032. items: ['source', '|', 'undo', 'redo', '|', 'preview', 'template', '|',
  1033. 'cut', 'copy', 'paste', 'plainpaste', 'wordpaste', '|',
  1034. 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', '|',
  1035. 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', '|',
  1036. 'subscript', 'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
  1037. 'image', '|', 'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold', '|',
  1038. 'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|',
  1039. 'table', 'hr', 'emoticons', '|', 'pagebreak', 'anchor', '|', 'about',
  1040. 'table', 'insertfile', 'hr', 'emoticons', 'baidumap', '|',
  1041. 'pagebreak', 'anchor', 'link', 'unlink', '|', 'about'],
  1042. afterUpload: function (url, data, name) {
  1043. this.sync();
  1044. }, //图片上传后,将上传内容同步到textarea中
  1045. afterBlur: function () {
  1046. this.sync();
  1047. }, ////失去焦点时,将内容同步到textarea中
  1048. afterCreate: function () {
  1049. this.sync();
  1050. }
  1051. }
  1052. editor2 = KindEditor.create('#kindEditor_Content', options);
  1053. };
  1054. self.setKindEditor2();
  1055. //视频截图功能
  1056. //用来保存当前编辑图片的地址
  1057. self.nowImgUrl = "";
  1058. self.getVideoImg = function () {
  1059. self.nowImgUrl="";
  1060. var player = document.getElementById('videoBox'); //获取video的Dom节点
  1061. var canvas = document.createElement("canvas");
  1062. canvas.width = 1920;
  1063. canvas.height = 1080;
  1064. canvas.getContext("2d").drawImage(player, 0, 0, canvas.width, canvas.height);//截
  1065. var dataURL = canvas.toDataURL("image/png"); //将图片转成base64格式
  1066. self.nowImgUrl=dataURL;
  1067. self.openImgLayer();
  1068. }
  1069. //打开截图收藏框
  1070. self.cutType="type1";
  1071. self.openImgLayer = function () {
  1072. //每次打开截图层初始化截图窗口
  1073. self.cutType="type1";
  1074. var image = document.querySelector('#imageCut');
  1075. cropper = new Cropper(image, {
  1076. aspectRatio: 16 / 9,
  1077. viewMode: 1,
  1078. scalable: false,
  1079. minCropBoxWidth: 64,
  1080. minCropBoxHeight: 36,
  1081. autoCrop: true,
  1082. fillColor: "#fff",
  1083. responsive:false,
  1084. minContainerWidth:"640",//容器的最小宽度 默认:200;
  1085. minContainerHeight:"360",//容器的最小高度 默认:100;
  1086. });
  1087. cropper.replace(self.nowImgUrl, false);
  1088. sp.layer('#layer_fav',1);
  1089. }
  1090. self.closeImgLayer = function () {
  1091. self.nowImgUrl = "";
  1092. cropper.destroy();
  1093. sp.closeCenter('.sp-layer');
  1094. }
  1095. self.changeCutType=function(){
  1096. if(self.cutType=="type1"){
  1097. cropper.options= {
  1098. aspectRatio: 16 / 9,
  1099. viewMode: 1,
  1100. scalable: false,
  1101. minCropBoxWidth: 64,
  1102. minCropBoxHeight: 36,
  1103. autoCrop: true,
  1104. fillColor: "#fff",
  1105. responsive:false,
  1106. minContainerWidth:"640",//容器的最小宽度 默认:200;
  1107. minContainerHeight:"360",//容器的最小高度 默认:100;
  1108. };
  1109. }else if(self.cutType=="type2"){
  1110. cropper.options= {
  1111. viewMode: 1,
  1112. scalable: false,
  1113. minCropBoxWidth: 64,
  1114. minCropBoxHeight: 36,
  1115. autoCrop: true,
  1116. fillColor: "#fff",
  1117. responsive:false,
  1118. minContainerWidth:"640",//容器的最小宽度 默认:200;
  1119. minContainerHeight:"360",//容器的最小高度 默认:100;
  1120. };
  1121. }
  1122. }
  1123. self.saveData = function () {
  1124. var cas = cropper.getCroppedCanvas();
  1125. var base64url = cas.toDataURL('image/png');
  1126. var data = {
  1127. base64: base64url
  1128. }
  1129. $http.post(apiurljs.login + "g2app/richang/base64ToImageUrl", data, postCfg)
  1130. .success(function (obj) {
  1131. var res = strToJson(s4.decryptData_CBC(obj.data));
  1132. console.log(res);
  1133. self.data.IMAGEDATA = apiurljs.login + "g2work" + res.data[0].url;
  1134. //sp.closeCenter('.sp-layer');
  1135. self.closeImgLayer()
  1136. })
  1137. }
  1138. self.reset = function () {
  1139. if(self.nowImgUrl!=''){
  1140. cropper.reset();
  1141. }
  1142. }
  1143. self.zoomOut = function () {
  1144. if(self.nowImgUrl!=''){
  1145. cropper.zoom(0.1);
  1146. }
  1147. }
  1148. self.zoomIn = function () {
  1149. if(self.nowImgUrl!=''){
  1150. cropper.zoom(-0.1);
  1151. }
  1152. }
  1153. self.clear=function () {
  1154. if(self.nowImgUrl!=''){
  1155. self.nowImgUrl = "";
  1156. $("#imgUpload").blur();
  1157. $("#imgUpload").val("");
  1158. cropper.replace(" ",false);
  1159. }
  1160. }
  1161. }])
  1162. app.filter('trustHtml', function ($sce) {
  1163. return function (input) {
  1164. return $sce.trustAsHtml(input.replace(/\n/g, '<br/>').replace(/\s/g, '&nbsp;'));
  1165. };
  1166. });
  1167. //canvas画布签字
  1168. function lineCanvas(obj) {
  1169. var self = this;
  1170. self.linewidth = 1;
  1171. self.color = "#000000";
  1172. self.background = "#ffffff";
  1173. self.canvas = document.createElement("canvas");
  1174. document.getElementById(obj).appendChild(self.canvas);
  1175. self.cxt = self.canvas.getContext("2d");
  1176. self.canvas.width = document.getElementById(obj).clientWidth;
  1177. self.canvas.height = document.getElementById(obj).scrollHeight;
  1178. self.cxt.fillStyle = self.background;
  1179. self.cxt.fillRect(0, 0, self.canvas.width, self.canvas.width);
  1180. self.cxt.strokeStyle = self.color;
  1181. self.cxt.lineWidth = self.linewidth;
  1182. self.cxt.lineCap = "round";
  1183. //开始绘制
  1184. self.canvas.addEventListener("mousedown", function (e) {
  1185. self.cxt.beginPath();
  1186. self.cxt.lineTo(e.pageX - document.getElementById(obj).offsetLeft - 25, e.pageY - document.getElementById(obj).offsetTop + $(".sp-page-center").scrollTop() - 25);
  1187. self.canvas.addEventListener("mousemove", move)
  1188. }.bind(self), false);
  1189. //绘制中
  1190. function move() {
  1191. var e = window.event;
  1192. self.cxt.lineTo(e.pageX - document.getElementById(obj).offsetLeft - 25, e.pageY - document.getElementById(obj).offsetTop + $(".sp-page-center").scrollTop() - 25);
  1193. self.cxt.stroke();
  1194. }
  1195. //结束绘制
  1196. self.canvas.addEventListener("mouseup", up)
  1197. function up() {
  1198. self.cxt.closePath();
  1199. self.canvas.removeEventListener("mousemove", move)
  1200. }
  1201. };
  1202. var parentData = {}
  1203. function getData() {
  1204. parentData = angular.element(document.getElementById("app")).scope().data
  1205. return parentData
  1206. }
  1207. function showToggle(e) {
  1208. $(e).children().toggle()
  1209. $(e).next().toggle()
  1210. }
  1211. function toggleYJL(e) {
  1212. if ($(e).children(".fa-angle-double-down").is(":hidden") == true) {
  1213. $("#topDiv").css("height", 160)
  1214. $(e).parent().css("height", 450)
  1215. $("#attachlist").css("height", 200)
  1216. $("#bottomDiv").css("height", "")
  1217. } else {
  1218. $("#topDiv").css("height", 600)
  1219. $(e).parent().css("height", 10)
  1220. }
  1221. $(e).children().toggle()
  1222. }