Built files from Bizgaze WebServer
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

documents.js 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. var Unibase;
  2. (function (Unibase) {
  3. let Apps;
  4. (function (Apps) {
  5. let Collaboration;
  6. (function (Collaboration) {
  7. let Components;
  8. (function (Components) {
  9. class Documents extends Unibase.Platform.Core.BaseComponent {
  10. constructor() {
  11. super(...arguments);
  12. this.ej2Source = {
  13. Excel: ['libs/syncfusion/excel/ej2-excel.min.js'],
  14. Pdf: ['libs/syncfusion/pdf/ej2-pdf.min.js'],
  15. Word: ['libs/syncfusion/word/ej2-word.min.js'],
  16. };
  17. }
  18. jsFiles() {
  19. return ["apps/collaboration/managers/documentmanager.js"];
  20. }
  21. cssFiles() {
  22. return [];
  23. }
  24. loadForm(FormId, Pk_Value, AppConfigurationId, Callback, ElementId) {
  25. var instance = this;
  26. instance.navigationHelper.popup(Pk_Value, '', Unibase.Apps.Collaboration.Components.Documents.Instance(), function (container) {
  27. var documentGroup = ElementId;
  28. if (Callback != null) {
  29. Callback();
  30. }
  31. }, Unibase.Platform.Helpers.Size.ExtraLarge);
  32. }
  33. html(id, containerid) {
  34. var html = `<div><div id="DocumentViewer" style="width: 100%;height: 100%" class="DocumentViewer"></div></div>
  35. <div id="dialog-container">
  36. <div id="dialog"></div>
  37. <div id="see-document-status"></div>
  38. <div id="dlgContent" class="dialogContent"></div>
  39. </div><div id="importfile-container"></div>
  40. <div id="copydocument-container"> </div><div id="spreadsheettrim-container">
  41. <div id="removeduplicates"></div><div id="biz-ss-menubar-fullscreendialog"></div><div id="biz-ss-resizetofit-dialog"></div></div>`;
  42. return html;
  43. }
  44. load(formId, containerid, callback) {
  45. var instance = this;
  46. instance._containerid = containerid;
  47. }
  48. convertDocsToPdfDownload(documentFileId) {
  49. Unibase.Apps.Collaboration.DocumentManager.Instance().ConvertDocstoPdfDownload(documentFileId).then(function (response) {
  50. Unibase.Themes.Compact.Components.Notification.Instance().Downloadfile(response.result);
  51. });
  52. }
  53. previewSpreadSheet(fileurl, userid) {
  54. let docManger = Unibase.Apps.Collaboration.DocumentManager.Instance();
  55. docManger.getDocumentFileInfo(fileurl).then((response) => {
  56. docManger.getJsonData(response.result.FileId).then((res) => {
  57. docManger.getCustomJsonData(response.result.FileId).then((customresponse) => {
  58. Unibase.Apps.Collaboration.Components.Documents.Instance()._documentId = response.result.FileId;
  59. Unibase.Apps.Collaboration.Components.DocConnector.Instance().init(response.result.FileId, response.result.DocumentGroup);
  60. this.fileCacheHelper.loadJsFiles(["apps/collaboration/components/sheets/formatpainter.js", "apps/collaboration/components/unicloud.js", "apps/collaboration/components/sheets/spellcheck.js", "apps/collaboration/components/sheets/spellcheck.js", "apps/collaboration/components/sheets/autofill.js", "apps/collaboration/components/sheets/ribbon.js", "apps/collaboration/components/sheets/dialogue.js", "apps/collaboration/components/sheets/base.js", 'apps/collaboration/components/common/download.js', 'apps/collaboration/enums/enum.js'], () => {
  61. let sheets = Unibase.Apps.Collaboration.Components.Sheets.Base.Instance();
  62. console.log(response);
  63. if (res.result != null && res.result != "") {
  64. sheets.init(response, res, customresponse);
  65. Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading();
  66. }
  67. else {
  68. }
  69. });
  70. });
  71. });
  72. });
  73. }
  74. ;
  75. previewWordDocument(Fileurl) {
  76. Unibase.Apps.Collaboration.DocumentManager.Instance().getDocumentFileInfo(Fileurl).then((response) => {
  77. Unibase.Apps.Collaboration.DocumentManager.Instance().getJsonData(response.result.FileId).then((res) => {
  78. this.fileCacheHelper.loadJsFiles(['apps/collaboration/components/doceditor/base.js', 'platform/core/helpers/file/filehelper.js', 'apps/collaboration/components/sheets/base.js', 'apps/collaboration/components/unicloud.js', 'apps/collaboration/components/doceditor/ribbon.js', 'apps/collaboration/components/common/download.js'], () => {
  79. let bizDoc = Unibase.Apps.Collaboration.Components.DocEditor.Base.Instance();
  80. bizDoc.init(response, res);
  81. Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading();
  82. });
  83. });
  84. });
  85. }
  86. previewPdf(FileId) {
  87. Unibase.Apps.Collaboration.DocumentManager.Instance().getDocumentFileInfo(FileId).then((response) => {
  88. this.fileCacheHelper.loadJsFiles(['apps/collaboration/components/pdfviewer/base.js'], () => {
  89. let bizPfd = Unibase.Apps.Collaboration.Components.PdfViewer.Base.Instance();
  90. bizPfd.init(response);
  91. Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading();
  92. });
  93. });
  94. }
  95. previewImage(documentFileId) {
  96. Unibase.Apps.Collaboration.DocumentManager.Instance().getDocumentFileInfo(documentFileId).then(function (response) {
  97. var result = response.result;
  98. var fileName = result.DocumentFileName + "." + result.FileType;
  99. var byteCharacters = atob(result.FileData);
  100. var byteNumbers = new Array(byteCharacters.length);
  101. for (var i = 0; i < byteCharacters.length; i++) {
  102. byteNumbers[i] = byteCharacters.charCodeAt(i);
  103. }
  104. var byteArray = new Uint8Array(byteNumbers);
  105. var file = new Blob([byteArray], { type: result.DocumentGroup + '/' + result.FileType + ';base64' });
  106. var fileURL = URL.createObjectURL(file);
  107. window.open(fileURL, fileName, "width=600,height=600,scrollbars=yes");
  108. Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading();
  109. });
  110. }
  111. previewDocument(documentFileId, documentGroup, userid) {
  112. this.documentfileid = documentFileId;
  113. this.documentGroup = documentGroup;
  114. $(".unibase_modal_backdrop").removeAttr('style');
  115. $(".preloader-it").fadeIn();
  116. this.fileCacheHelper.loadJsFiles(["apps/collaboration/managers/documentmanager.js", "apps/collaboration/managers/filemanager.js", "apps/collaboration/components/sheets/spellcheck.js", "apps/collaboration/components/docconnector.js", "apps/collaboration/components/unidochub.js", "apps/collaboration/components/common/util.js", 'libs/syncfusion/ej2.min.js', 'apps/collaboration/components/fullscreen.js'], () => {
  117. this.fileCacheHelper.loadCssFiles(['libs/syncfusion/material.css', 'libs/syncfusion/custom-css.css', 'libs/syncfusion/docx.css', 'libs/syncfusion/spreadsheet-custom.css', 'libs/syncfusion/pdf.css'], () => {
  118. if (documentGroup == "Image") {
  119. this.previewImage(documentFileId);
  120. }
  121. else if (documentGroup == "Excel") {
  122. this.previewSpreadSheet(documentFileId, userid);
  123. }
  124. else if (documentGroup == "Word") {
  125. this.previewWordDocument(documentFileId);
  126. }
  127. else if (documentGroup == "Pdf") {
  128. this.previewPdf(documentFileId);
  129. }
  130. });
  131. });
  132. }
  133. downloadDocument(FileId, documentGroup) {
  134. if (documentGroup == "Excel") {
  135. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/collaboration/managers/documentmanager.js", function () {
  136. var data = {
  137. FileId: FileId
  138. };
  139. Unibase.Apps.Collaboration.DocumentManager.Instance().spreadSheetDownload(data).then(function (response) {
  140. var filepath = response.result;
  141. filepath = encodeURIComponent(filepath);
  142. Unibase.Themes.Compact.Components.Notification.Instance().Downloadfile(filepath);
  143. });
  144. });
  145. }
  146. else if (documentGroup == "Word") {
  147. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/collaboration/managers/documentmanager.js", function () {
  148. Unibase.Apps.Collaboration.DocumentManager.Instance().getDocumentFileInfo(FileId).then(function (response) {
  149. var filepath = response.result.DocumentFilePath;
  150. filepath = encodeURIComponent(filepath);
  151. Unibase.Themes.Compact.Components.Notification.Instance().Downloadfile(filepath);
  152. });
  153. });
  154. }
  155. else {
  156. Unibase.Platform.Helpers.FileCacheHelper.Instance().loadJsFile("apps/collaboration/managers/documentmanager.js", function () {
  157. Unibase.Apps.Collaboration.DocumentManager.Instance().getDocumentFileInfo(FileId).then(function (response) {
  158. var a = document.createElement("a");
  159. a.href = "data:" + response.result.FileType + ";base64," + response.result.FileData;
  160. a.download = response.result.FileTitle + "." + response.result.FileType;
  161. a.click();
  162. });
  163. });
  164. }
  165. }
  166. deleteDocumentFile(DocumentFileId) {
  167. bootbox.confirm("Do you want to Delete this File ?", function (result) {
  168. if (result == true) {
  169. Unibase.Platform.Files.Managers.FileManager.Instance().deleteDocumentFile(DocumentFileId).then(function (response) {
  170. MessageHelper.Instance().showSuccess("Document File Deleted Successfully.", "");
  171. var detailobj = Unibase.Themes.Compact.Components.Details.Instance();
  172. detailobj._recordId = Unibase.Themes.Providers.DetailHelper.recordId;
  173. detailobj._installedAppId = Unibase.Themes.Providers.DetailHelper.installedAppId;
  174. detailobj._containerId = $("._bizgaze_detail_container:visible").attr("id");
  175. var idetailObj = detailobj;
  176. detailobj.loadPortlets(idetailObj);
  177. });
  178. }
  179. });
  180. }
  181. newWordDoc(callback) {
  182. Unibase.Platform.Helpers.NavigationHelper.Instance().showLoading();
  183. this.fileCacheHelper.loadJsFiles(this.ej2Source["Word"].concat(["apps/collaboration/managers/documentmanager.js", "apps/collaboration/components/sheets/spellcheck.js", "apps/collaboration/components/docconnector.js", "apps/collaboration/components/unidochub.js", "apps/collaboration/components/common/util.js", 'apps/collaboration/components/fullscreen.js', 'apps/collaboration/components/sheets/base.js', 'apps/collaboration/components/doceditor/base.js', 'apps/collaboration/components/doceditor/ribbon.js', 'apps/collaboration/components/common/download.js', 'apps/collaboration/enums/enum.js']), () => {
  184. this.fileCacheHelper.loadCssFiles(['libs/syncfusion/material.css', 'libs/syncfusion/custom-css.css', 'libs/syncfusion/docx.css', 'libs/syncfusion/spreadsheet-custom.css', 'libs/syncfusion/pdf.css'], () => {
  185. var response = {
  186. result: { FileTitle: "Untitled Document", NewDocument: true, NewUpload: true }
  187. };
  188. var res = { result: "" };
  189. let bizDoc = Unibase.Apps.Collaboration.Components.DocEditor.Base.Instance();
  190. bizDoc.init(response, res, callback);
  191. Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading();
  192. });
  193. });
  194. }
  195. newExcel(type, callback) {
  196. Unibase.Platform.Helpers.NavigationHelper.Instance().showLoading();
  197. this.fileCacheHelper.loadJsFiles(["apps/collaboration/components/sheets/formatpainter.js", "apps/collaboration/components/unicloud.js", "apps/collaboration/components/docconnector.js", 'libs/syncfusion/ej2.min.js', "apps/collaboration/components/fullscreen.js", "apps/collaboration/components/sheets/spellcheck.js", "apps/collaboration/components/sheets/autofill.js", "apps/collaboration/components/sheets/ribbon.js", "apps/collaboration/components/sheets/dialogue.js", "apps/collaboration/components/sheets/base.js", 'apps/collaboration/components/common/download.js', 'apps/collaboration/components/common/util.js', 'apps/collaboration/enums/enum.js'], () => {
  198. this.fileCacheHelper.loadCssFiles(['libs/syncfusion/material.css', 'libs/syncfusion/custom-css.css', 'libs/syncfusion/docx.css', 'libs/syncfusion/spreadsheet-custom.css', 'libs/syncfusion/pdf.css'], () => {
  199. var folderId;
  200. var res = { result: "" };
  201. var customres = { result: "" };
  202. var response = { result: { FileTitle: "Untitled Spreadsheet", NewDocument: true, NewUpload: true, folderId: folderId } };
  203. if (type != 0 && type != undefined) {
  204. folderId = parseInt(atob(type));
  205. }
  206. else {
  207. folderId = 0;
  208. }
  209. var sheets = Unibase.Apps.Collaboration.Components.Sheets.Base.Instance();
  210. sheets.init(response, res, customres, callback);
  211. Unibase.Platform.Helpers.NavigationHelper.Instance().hideLoading();
  212. });
  213. });
  214. }
  215. static Instance() {
  216. if (this.instance === undefined) {
  217. this.instance = new Documents();
  218. }
  219. return this.instance;
  220. }
  221. }
  222. Components.Documents = Documents;
  223. class sfdtexport {
  224. }
  225. Components.sfdtexport = sfdtexport;
  226. })(Components = Collaboration.Components || (Collaboration.Components = {}));
  227. })(Collaboration = Apps.Collaboration || (Apps.Collaboration = {}));
  228. })(Apps = Unibase.Apps || (Unibase.Apps = {}));
  229. })(Unibase || (Unibase = {}));