officeedit.js 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. let s4 = new SM4Util();
  2. let detailVue = new Vue({
  3. el: "#detailBox",
  4. data: {
  5. apiurl: apiurl,
  6. userId: "", //用户id
  7. userName: "", //用户中文名
  8. token: "",
  9. info: "",
  10. yzWeb: ""
  11. },
  12. methods: {
  13. dateFtt: (fmt, date) => {
  14. var o = {
  15. "M+": date.getMonth() + 1, //月份
  16. "d+": date.getDate(), //日
  17. "h+": date.getHours(), //小时
  18. "m+": date.getMinutes(), //分
  19. "s+": date.getSeconds(), //秒
  20. "q+": Math.floor((date.getMonth() + 3) / 3), //季度
  21. "S": date.getMilliseconds() //毫秒
  22. };
  23. if (/(y+)/.test(fmt))
  24. fmt = fmt.replace(RegExp.$1, (date.getFullYear() + "").substr(4 - RegExp.$1.length));
  25. for (var k in o)
  26. if (new RegExp("(" + k + ")").test(fmt))
  27. fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
  28. return fmt;
  29. },
  30. backBtn: () => {
  31. history.back();
  32. },
  33. //只读模式打开附件
  34. openReadonlyFile: (obj) => {
  35. let set_convertType = 0;
  36. if (obj.FILEEXT == "doc") {
  37. set_convertType = 0;
  38. } else if (obj.FILEEXT == "pdf") {
  39. set_convertType = 20;
  40. } else if (obj.FILEEXT == "ofd") {
  41. set_convertType = 570;
  42. } else {
  43. set_convertType = 0;
  44. }
  45. let postData = {
  46. convertType: set_convertType,
  47. fileUrl: _this.apiurl + "/g2work/files2/inline/" + obj.FILEURL.slice(7)
  48. };
  49. let post_url = _this.apiurl.split("glwork")[0] + "fcscloud/composite/httpfile";
  50. $http({
  51. method: 'post',
  52. url: post_url,
  53. data: postData,
  54. headers: {'Content-Type': 'application/x-www-form-urlencoded'},
  55. transformRequest: function (data) {
  56. return _this.utils.param(data);
  57. }
  58. }).then(res => {
  59. if (res.data.errorcode === 0) {
  60. _this.yzWeb = res.data.data.viewUrl
  61. } else {
  62. $.alert("打开失败,请联系管理员!", "温馨提示");
  63. }
  64. })
  65. },
  66. //只读模式打开稿件
  67. openReadonlyRecord: (obj) => {
  68. let postData = {
  69. convertType: 570,
  70. fileUrl: _this.apiurl.split("glwork")[0] + "glworkweb/" + obj.FILEURL
  71. };
  72. let post_url = _this.apiurl.split("glwork")[0] + "fcscloud/composite/httpfile";
  73. $http({
  74. method: 'post',
  75. url: post_url,
  76. data: postData,
  77. headers: {'Content-Type': 'application/x-www-form-urlencoded'},
  78. transformRequest: function (data) {
  79. return _this.utils.param(data);
  80. }
  81. }).then(res => {
  82. if (res.data.errorcode === 0) {
  83. _this.yzWeb = res.data.data.viewUrl
  84. } else {
  85. $.alert("打开失败,请联系管理员!", "温馨提示");
  86. }
  87. })
  88. },
  89. //编辑模式打开稿件
  90. openEditRecord: (obj) => {
  91. let set_filepath = _this.apiurl.split("glwork")[0] + "glworkweb/" + obj.FILEURL;
  92. let postData = {
  93. method: 1,
  94. params: {
  95. userId: _this.userId,
  96. fileId: obj.ID,
  97. fileName: obj.FILENAMES,
  98. filePath: set_filepath,
  99. mobileFlag: true,
  100. //userRight: 0, // 用户权限 编辑:UserRightEdit = 0; 只读:UserRightReadonly = 1; 临时只读:UserRightTempReadonly = 2;此时页面上编辑—临时只读按钮,打开只能临时只读,不打开可以进行编辑
  101. //saveFlag: true, /// true:自动保存文档 false:不自动保存文档 (默认为true)
  102. callbackUrl: _this.apiurl + "/g2app/fawenfiles/uploadFile"
  103. }
  104. };
  105. $.ajax({
  106. url: "http://10.233.22.204:18080/api.do",
  107. data: {
  108. jsonParams: encodeURIComponent(JSON.stringify(postData))
  109. },
  110. type: "POST",
  111. dataType: "json",
  112. general: false,
  113. async: false,
  114. success: function (data) {
  115. if (data) {
  116. if (data.errorCode === "0") {
  117. let rst = data.result;
  118. if (rst && rst.urls) {
  119. let get_urls = rst.urls;
  120. if (typeof (get_urls) === "string") {
  121. _this.yzWeb = get_urls;
  122. } else {
  123. $.alert("打开失败,请联系管理员!", "温馨提示");
  124. }
  125. } else {
  126. $.alert("打开失败,请联系管理员!", "温馨提示");
  127. }
  128. } else {
  129. $.alert("打开失败,请联系管理员!", "温馨提示");
  130. }
  131. } else {
  132. $.alert("打开失败,请联系管理员!", "温馨提示");
  133. }
  134. },
  135. });
  136. },
  137. },
  138. created: function () {
  139. _this = this;
  140. let token = localStorage.getItem("mobile-token", _this.token);
  141. let userName = localStorage.getItem("mobile-userName", _this.userName);
  142. let userId = localStorage.getItem("mobile-userId", _this.userId);
  143. _this.userId = userId;
  144. _this.token = token;
  145. _this.userName = userName;
  146. _this.dataString = _this.utils.getUrlName("dataString");
  147. _this.info = _this.utils.strToJson(s4.decryptData_CBC(_this.dataString));
  148. console.log(_this.info);
  149. if (_this.info.type == "type1") {
  150. _this.openReadonlyFile(_this.info.obj);
  151. } else if (_this.info.type == "type2") {
  152. _this.openEditRecord(_this.info.obj);
  153. } else if (_this.info.type == "type3") {
  154. _this.openReadonlyRecord(_this.info.obj);
  155. }
  156. },
  157. mounted: function () {
  158. }
  159. })