YozoOffice.js 3.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. MWF.xDesktop.requireApp("process.Xform", "YozoOffice", null, false);
  2. MWF.xApplication.cms.Xform.YozoOffice = MWF.CMSYozoOffice = new Class({
  3. Extends: MWF.APPYozoOffice,
  4. initialize: function(node, json, form, options){
  5. this.node = $(node);
  6. this.node.store("module", this);
  7. this.json = json;
  8. this.form = form;
  9. this.mode = "write";
  10. this.appToken = "x_cms_assemble_control";
  11. },
  12. createDocument : function (callback){
  13. var data = {
  14. "fileName" : MWF.xApplication.process.Xform.LP.onlyoffice.filetext + "." + this.getFileType(this.json.officeType),
  15. "appToken" : this.appToken,
  16. "workId" : this.form.businessData.document.id,
  17. "site" : "filetext"
  18. };
  19. this.action.CustomAction.createForO2(data,
  20. function( json ){
  21. debugger
  22. this.documentId = json.data.fileId;
  23. this.setData();
  24. if (callback) callback();
  25. }.bind(this),null, false
  26. );
  27. },
  28. createDocumentByTemplate : function (callback){
  29. this.action.CustomAction.getInfo(this.json.template).then(function(json) {
  30. var data = {
  31. "fileName": MWF.xApplication.process.Xform.LP.onlyoffice.filetext + "." + json.data.extension,
  32. "fileType": json.data.extension,
  33. "appToken" : "x_cms_assemble_control",
  34. "workId" : this.form.businessData.document.id,
  35. "site" : "filetext",
  36. "tempId": this.json.template
  37. };
  38. this.action.CustomAction.createForO2(data,
  39. function( json ){
  40. this.documentId = json.data.fileId;
  41. this.setData();
  42. if (callback) callback();
  43. }.bind(this),null, false
  44. );
  45. }.bind(this));
  46. },
  47. createUpload : function (){
  48. this.uploadNode = new Element("div",{"style":"margin:10px;"}).inject(this.node);
  49. 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);
  50. uploadBtn.addEvent("click",function (){
  51. o2.require("o2.widget.Upload", null, false);
  52. var upload = new o2.widget.Upload(this.content, {
  53. "action": o2.Actions.get("x_cms_assemble_control").action,
  54. "method": "uploadAttachment",
  55. "accept" : ".docx,.xlsx,.pptx",
  56. "parameter": {
  57. "id" : this.form.businessData.document.id,
  58. },
  59. "data":{
  60. },
  61. "onCompleted": function(data){
  62. o2.Actions.load(this.appToken).FileInfoAction.delete(this.documentId,function( json ){
  63. }.bind(this));
  64. this.documentId = data.id;
  65. this.reload();
  66. }.bind(this)
  67. });
  68. upload.load();
  69. }.bind(this));
  70. },
  71. setData: function() {
  72. var data = {
  73. "documentId": this.documentId,
  74. "appToken": "x_cms_assemble_control"
  75. };
  76. this.data = data;
  77. this._setBusinessData(data);
  78. var jsonData = {}
  79. jsonData[this.json.id] = data;
  80. o2.Actions.load("x_cms_assemble_control").DataAction.updateWithDocument(this.form.businessData.document.id, jsonData, function (json) {
  81. data = json.data;
  82. });
  83. }
  84. });