feedback.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  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. //初始化右上角按钮
  33. self.buttonList = []
  34. self.getSwenList = function () {
  35. self.SwenList = [];
  36. var data = {
  37. directionid: self.directionid,
  38. userid: self.userId,
  39. routeinfoid: self.routeinfoid,
  40. routeid: self.routeid,
  41. formeditid: ""
  42. }
  43. $http.post(apiurljs.login + "g2app/abase/queryDataLink", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  44. .success(function (obj) {
  45. var res = strToJson(s4.decryptData_CBC(obj.data));
  46. $.each(res.data.LINKS, function (index, item) {
  47. if (item.TEMPFORM.indexOf("feedback.html") > -1) {
  48. self.Title = item.VNAME;
  49. }
  50. if (item.TEMPFORM.indexOf("?docmode") > 0) {
  51. if (item.TEMPFORM.indexOf("attachlist") > -1 || item.TEMPFORM.indexOf("feedback") > -1) {
  52. item.TEMPFORM = item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
  53. } else {
  54. item.TEMPFORM = "../" + item.TEMPFORM + "&dotype=" + self.dotype + "&type=" + self.get_type + "&lastReturnPageno=" + self.get_lastReturnPageno + "&lastReturnPage=" + self.get_lastReturnPage;
  55. }
  56. } else {
  57. item.TEMPFORM = "#";
  58. }
  59. self.SwenList.push(item)
  60. })
  61. self.SwenList.push({
  62. VNAME: "流程图",
  63. DIRECTIONID: self.SwenList[0].DIRECTIONID,
  64. TEMPFORM: "modeler_read.html?" + self.SwenList[0].TEMPFORM.split("?")[1]
  65. })
  66. self.getFuncList()
  67. })
  68. }
  69. self.getSwenList(0)
  70. self.getFuncList = function () {
  71. var data = {
  72. formeditid: self.formeditid,
  73. billkey: "FILE_ATTACH"
  74. }
  75. $http.post(apiurljs.login + "g2work/formedit/queryDataFormEditFunc", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  76. .success(function (obj) {
  77. var res = strToJson(s4.decryptData_CBC(obj.data));
  78. self.buttonList = res.data
  79. self.getData()
  80. })
  81. }
  82. self.getData = function () {
  83. var data = {
  84. tablename: "SX_XF",
  85. colums: "*",
  86. order: "ID desc",
  87. sqlwhere: { ROUTEINFOID: self.routeinfoid },
  88. sqlinwhere: "",
  89. sqllikewhere: ""
  90. }
  91. $http.post(apiurljs.login + "g2app/dataabase/queryDataByCol", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  92. .success(function (obj) {
  93. var res = strToJson(s4.decryptData_CBC(obj.data));
  94. var FJ = res.data[0].FJ != "" && res.data[0].FJ != null ? JSON.parse(res.data[0].FJ) : [];
  95. var JGFJ = res.data[0].JGFJ != "" && res.data[0].JGFJ != null ? JSON.parse(res.data[0].JGFJ) : [];
  96. FJ.forEach(function (item) {
  97. item.COLID = "FJ"
  98. })
  99. JGFJ.forEach(function (item) {
  100. item.COLID = "JGFJ"
  101. })
  102. self.arrayFile = FJ.concat(JGFJ);
  103. console.log(self.arrayFile)
  104. self.getData1()
  105. })
  106. }
  107. self.getData1 = function () {
  108. var data = {
  109. routeinfoid: self.routeinfoid,
  110. routeid: "",
  111. tableid: "SX_XF",
  112. colid: "",
  113. }
  114. $http.post(apiurljs.login + "g2app/abase/queryFileWithRouteAttach", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  115. .success(function (obj) {
  116. var res = strToJson(s4.decryptData_CBC(obj.data));
  117. self.arrayFile1 = res.data;
  118. console.log(self.arrayFile1)
  119. })
  120. }
  121. self.uploading = false;
  122. self.upload = function () {
  123. $('#fileupload').fileupload({
  124. url: apiurljs.login + 'g2app/abase/saveUploadFileName',
  125. dataType: 'json',
  126. beforeSend: function (xhr, data) {
  127. xhr.setRequestHeader("Authorization", "Bearer " + self.get_AccessToken);
  128. xhr.setRequestHeader("File-Argument", s4.encryptData_CBC("tablename=SX_XF,column=FJ,routeinfoid=" + self.routeinfoid + ",loaded=" + data.loaded + ",total=" + data.total));
  129. },
  130. // 上传完成后的执行逻辑
  131. done: function (e, data) {
  132. self.uploading = false;
  133. self.getData()
  134. }
  135. })
  136. }
  137. self.downLoad = function (item,n) {
  138. window.open(apiurljs.login + "g2work/files/" + (n == 1 ? item.FILEURL.slice(7) : item.FILEPATH.slice(7)))
  139. }
  140. self.deleteFile = function (file) {
  141. var dialogHead = "<span class=\"sp-dialog-head\"><span class=\"sp-dialog-tip\">温馨提示</span><span class=\"sp-dialog-close sp-closeDialog\" title=\"关闭\">×</span></span>";
  142. var dialogBody = "<div class=\"sp-dialog-body\">删除后不可恢复,您确认要删除吗?</div>";
  143. 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>";
  144. $('.sp-dialog').html(dialogHead + dialogBody + dialogFoot);
  145. sp.openCenter(".sp-dialog");
  146. ///取消按钮
  147. $('.sp-closeDialog').click(function (event) {
  148. sp.closeCenter(".sp-dialog");
  149. event.preventDefault();
  150. event.stopPropagation();
  151. });
  152. //post消息的id
  153. $("#delDataTrue").click(function () {
  154. var data = {
  155. tablename: "SX_XF",
  156. column: file.COLID,
  157. routeinfoid: self.routeinfoid,
  158. fileid: file.FILEID,
  159. filenames: file.FILENAMES
  160. }
  161. $http.post(apiurljs.login + "g2app/abase/deleteUploadFileName", { data: s4.encryptData_CBC(JSON.stringify(data)) }, postCfg)
  162. .success(function (obj) {
  163. var res = strToJson(s4.decryptData_CBC(obj.data));
  164. sp.dialoghide();
  165. if (res.success == true) {
  166. self.getData();
  167. } else {
  168. sp.dialog("删除失败,请联系管理员!");
  169. }
  170. })
  171. });
  172. }
  173. self.browseItem = null;
  174. self.browse = function (item, n) {
  175. self.browseItem = item;
  176. var set_convertType = 0;
  177. if (item.FILEEXT == "doc") {
  178. set_convertType = 0;
  179. } else if (item.FILEEXT == "pdf") {
  180. set_convertType = 20;
  181. } else if (item.FILEEXT == "ofd") {
  182. set_convertType = 570;
  183. } else {
  184. set_convertType = 0;
  185. }
  186. let postData = {
  187. convertType: set_convertType,
  188. fileUrl: apiurljs.login + "g2work/files2/inline/" + (n == 1 ? item.FILEURL.slice(7) : item.FILEPATH.slice(7))
  189. };
  190. console.log("路径:" + postData.fileUrl)
  191. var postCfg_transfer = {
  192. headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  193. transformRequest: function (data) {
  194. return $.param(data);
  195. }
  196. };
  197. $http.post(apiurljs.login.split("glwork/")[0] + "fcscloud/composite/httpfile", postData, postCfg_transfer)
  198. .success(function (res) {
  199. if (res.errorcode === 0) {
  200. $("#iframe_browse").attr("src", res.data.viewUrl);
  201. } else {
  202. sp.dialog(res.message);
  203. }
  204. });
  205. }
  206. self.editItem = null;
  207. self.Edit = function (item) {
  208. self.editItem = item;
  209. var data = {
  210. method: 1,
  211. params: {
  212. userId: self.userName,
  213. fileId: item.FILEID,
  214. fileName: item.FILENAME,
  215. filePath: apiurljs.login + "g2work" + item.FILEPATH,
  216. userRight: 0, // 用户权限 编辑:UserRightEdit = 0; 只读:UserRightReadonly = 1; 临时只读:UserRightTempReadonly = 2;此时页面上编辑—临时只读按钮,打开只能临时只读,不打开可以进行编辑
  217. saveFlag: false, /// true:自动保存文档 false:不自动保存文档 (默认为true)
  218. callbackUrl: apiurljs.login + "g2app/xinfang/uploadFile?fileId=" + item.FILEID + "&fileUrl=" + item.FILEPATH
  219. }
  220. };
  221. console.log("路径:" + data.params.filePath)
  222. console.log("参数:" + JSON.stringify(data.params))
  223. $.ajax({
  224. url: apiurljs.yzFileWo + "api.do",
  225. data: {
  226. jsonParams: encodeURIComponent(JSON.stringify(data))
  227. },
  228. type: "POST",
  229. dataType: "json",
  230. general: false,
  231. async: false,
  232. success: function (data) {
  233. console.log(data);
  234. if (data) {
  235. if (data.errorCode === "0") {
  236. let rst = data.result;
  237. console.log(rst.urls);
  238. if (rst && rst.urls) {
  239. var get_urls = rst.urls;
  240. console.log(get_urls);
  241. if (typeof (get_urls) === "string") {
  242. $timeout(function () {
  243. $("#iframe_edit").attr("src", get_urls);
  244. //window.open(get_urls)
  245. })
  246. } else {
  247. console.warn("无效的urls:" + get_urls);
  248. }
  249. } else {
  250. console.warn("ajax响应内容data.result有问题:" + rst);
  251. }
  252. } else {
  253. alert(data.errorMessage);
  254. }
  255. } else {
  256. console.warn("ajax响应内容为空!");
  257. }
  258. },
  259. });
  260. }
  261. self.btnSave = function () {
  262. var data = {
  263. method: 2,
  264. params: {
  265. fileId: self.editItem.FILEID
  266. }
  267. };
  268. $.ajax({
  269. url: apiurljs.yzFileWo + "api.do",
  270. data: {
  271. jsonParams: encodeURIComponent(JSON.stringify(data))
  272. },
  273. type: "POST",
  274. dataType: "json",
  275. general: false,
  276. async: false,
  277. success: function (data) {
  278. console.log(data);
  279. if (data && data.errorCode === "0") {
  280. sp.dialog("保存成功");
  281. }
  282. },
  283. });
  284. }
  285. self.editFlag = function (str) {
  286. if (str == "wps" || str == "doc" || str == "docx" || str == "xls" || str == "xlsx" || str == "et") {
  287. return true
  288. } else {
  289. return false
  290. }
  291. }
  292. //右上角按钮调用方法
  293. self.btnEvent = function (item) {
  294. switch (item.CODE) {
  295. case "SENDLOG": self.RouteList(); break;
  296. case "PRINTITEM": self.btnPrint(); break;
  297. case "MEETITEM": self.Meet(); break;
  298. case "SAVESIGN": self.Qian(); break;
  299. default: self.forward(item); break;
  300. }
  301. }
  302. //头部下滚冻结
  303. $(function () {
  304. //页面高度撑满
  305. setTimeout(function () {
  306. if ($(".ibox-content").height() < $(window).height() - 31) {
  307. $(".ibox-content").css("height", $(window).height() - 31)
  308. }
  309. $("#iframe_browse").css("height", $(".ibox-content").height() - 48)
  310. $("#iframe_edit").css("height", $(".ibox-content").height() - 48)
  311. }, 1)
  312. })
  313. }])