Image.js 3.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. MWF.xDesktop.requireApp("process.Xform", "$Module", null, false);
  2. /** @class Image 图片。
  3. * @example
  4. * //可以在脚本中获取该组件
  5. * //方法1:
  6. * var attachment = this.form.get("name"); //获取组件
  7. * //方法2
  8. * var attachment = this.target; //在组件事件脚本中获取
  9. * @extends MWF.xApplication.process.Xform.$Module
  10. * @category FormComponents
  11. * @hideconstructor
  12. */
  13. MWF.xApplication.process.Xform.Image = MWF.APPImage = new Class(
  14. {
  15. Extends: MWF.APP$Module,
  16. _loadUserInterface: function(){
  17. if (this.json.properties && this.json.properties["src"]){
  18. var value = this.json.properties["src"];
  19. if ((value.indexOf("x_processplatform_assemble_surface")!=-1 || value.indexOf("x_portal_assemble_surface")!=-1 || value.indexOf("x_cms_assemble_control")!=-1)){
  20. var host1 = MWF.Actions.getHost("x_processplatform_assemble_surface");
  21. var host2 = MWF.Actions.getHost("x_portal_assemble_surface");
  22. var host3 = MWF.Actions.getHost("x_cms_assemble_control");
  23. if (value.indexOf("/x_processplatform_assemble_surface")!==-1){
  24. value = value.replace("/x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  25. }else if (value.indexOf("x_processplatform_assemble_surface")!==-1){
  26. value = value.replace("x_processplatform_assemble_surface", host1+"/x_processplatform_assemble_surface");
  27. }
  28. if (value.indexOf("/x_portal_assemble_surface")!==-1){
  29. value = value.replace("/x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  30. }else if (value.indexOf("x_portal_assemble_surface")!==-1){
  31. value = value.replace("x_portal_assemble_surface", host2+"/x_portal_assemble_surface");
  32. }
  33. if (value.indexOf("/x_cms_assemble_control")!==-1){
  34. value = value.replace("/x_cms_assemble_control", host3+"/x_cms_assemble_control");
  35. }else if (value.indexOf("x_cms_assemble_control")!==-1){
  36. value = value.replace("x_cms_assemble_control", host3+"/x_cms_assemble_control");
  37. }
  38. value = o2.filterUrl(value);
  39. }
  40. try{
  41. this.node.set("src", value);
  42. }catch(e){}
  43. }else if (this.json.srcfile && this.json.srcfile!="none"){
  44. value = this.json.srcfile;
  45. if (typeOf(value)==="object"){
  46. var url = (value.portal) ? MWF.xDesktop.getPortalFileUr(value.id, value.portal) : MWF.xDesktop.getProcessFileUr(value.id, value.application);
  47. url = o2.filterUrl(url);
  48. this.node.set("src", url);
  49. }else{
  50. var host = MWF.Actions.getHost("x_portal_assemble_surface");
  51. var action = MWF.Actions.get("x_portal_assemble_surface");
  52. var uri = action.action.actions.readFile.uri;
  53. uri = uri.replace("{flag}", value);
  54. uri = uri.replace("{applicationFlag}", this.form.json.application);
  55. value = host+"/x_portal_assemble_surface"+uri;
  56. value = o2.filterUrl(value);
  57. this.node.set("src", value);
  58. }
  59. }else if (typeOf(this.json.src)=="object"){
  60. var src = MWF.xDesktop.getImageSrc( this.json.src.imageId );
  61. this.node.set("src", src);
  62. }
  63. },
  64. reset: function(){
  65. this._loadUserInterface();
  66. }
  67. });