OnlyOffice.js 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. MWF.xDesktop.requireApp("process.Xform", "OnlyOffice", null, false);
  2. MWF.xApplication.cms.Xform.OnlyOffice = MWF.CMSOnlyOffice = new Class({
  3. Extends: MWF.APPOnlyOffice,
  4. createDocument : function (callback){
  5. var data = {
  6. "fileName" : MWF.xApplication.process.Xform.LP.onlyoffice.filetext + "." + this.json.officeType,
  7. "fileType" : this.json.officeType,
  8. "appToken" : "x_cms_assemble_control",
  9. "workId" : this.form.businessData.document.id,
  10. "site" : "filetext"
  11. };
  12. this.action.OnlyofficeAction.createForO2(data,
  13. function( json ){
  14. this.documentId = json.data.fileId;
  15. this.setData();
  16. if (callback) callback();
  17. }.bind(this),null, false
  18. );
  19. },
  20. createDocumentByTemplate : function (callback){
  21. this.action.OnlyofficeAction.get(this.json.template).then(function(json) {
  22. var data = {
  23. "fileName": MWF.xApplication.process.Xform.LP.onlyoffice.filetext + "." + json.data.fileModel.document.fileType,
  24. "fileType": json.data.fileModel.document.fileType,
  25. "appToken" : "x_cms_assemble_control",
  26. "workId" : this.form.businessData.document.id,
  27. "site" : "filetext",
  28. "tempId": this.json.template
  29. };
  30. this.action.OnlyofficeAction.createForO2(data,
  31. function( json ){
  32. this.documentId = json.data.fileId;
  33. this.setData();
  34. if (callback) callback();
  35. }.bind(this),null, false
  36. );
  37. }.bind(this));
  38. },
  39. createUpload : function (){
  40. this.uploadNode = new Element("div",{"style":"margin:10px;"}).inject(this.node);
  41. var uploadBtn = new Element("button",{"text":MWF.xApplication.process.Xform.LP.ofdview.upload,"style":"margin-left: 15px; color: rgb(255, 255, 255); cursor: pointer; height: 26px; line-height: 26px; padding: 0px 10px; min-width: 40px; background-color: rgb(74, 144, 226); border: 1px solid rgb(82, 139, 204); border-radius: 15px;"}).inject(this.uploadNode);
  42. uploadBtn.addEvent("click",function (){
  43. o2.require("o2.widget.Upload", null, false);
  44. var upload = new o2.widget.Upload(this.content, {
  45. "action": o2.Actions.get("x_cms_assemble_control").action,
  46. "method": "replaceAttachment",
  47. "accept" : ".docx,.xlsx,.pptx",
  48. "parameter": {
  49. "id" : this.documentId,
  50. "documentid" : this.form.businessData.document.id,
  51. },
  52. "data":{
  53. },
  54. "onCompleted": function(data){
  55. this.documentId = data.id;
  56. this.setData();
  57. this.node.empty();
  58. this.createUpload();
  59. this.loadDocument();
  60. }.bind(this)
  61. });
  62. upload.load();
  63. }.bind(this));
  64. },
  65. setData: function() {
  66. var data = {
  67. "documentId": this.documentId,
  68. "appToken": "x_cms_assemble_control"
  69. };
  70. this.data = data;
  71. this._setBusinessData(data);
  72. var jsonData = {}
  73. jsonData[this.json.id] = data;
  74. o2.Actions.load("x_cms_assemble_control").DataAction.updateWithDocument(this.form.businessData.document.id, jsonData, function (json) {
  75. data = json.data;
  76. });
  77. }
  78. });