Elbutton.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. MWF.xDesktop.requireApp("process.Xform", "$ElModule", null, false);
  2. /** @class Elbutton 基于Element UI的按钮组件。
  3. * @o2cn 按钮组件
  4. * @example
  5. * //可以在脚本中获取该组件
  6. * //方法1:
  7. * var button = this.form.get("name"); //获取组件
  8. * //方法2
  9. * var button = this.target; //在组件事件脚本中获取
  10. * @extends MWF.xApplication.process.Xform.$Module
  11. * @o2category FormComponents
  12. * @o2range {Process|CMS|Portal}
  13. * @hideconstructor
  14. * @see {@link https://element.eleme.cn/#/zh-CN/component/button|Element UI Button 按钮}
  15. */
  16. MWF.xApplication.process.Xform.Elbutton = MWF.APPElbutton = new Class(
  17. /** @lends MWF.xApplication.process.Xform.Elbutton# */
  18. {
  19. Implements: [Events],
  20. Extends: MWF.APP$ElModule,
  21. /**
  22. * @summary 组件的配置信息,同时也是Vue组件的data。
  23. * @member MWF.xApplication.process.Xform.Elbutton#json {JsonObject}
  24. * @example
  25. * //可以在脚本中获取此对象,下面两行代码是等价的,它们获取的是同一个对象
  26. * var json = this.form.get("elbutton").json; //获取组件的json对象
  27. * var json = this.form.get("elbutton").vm.$data; //获取Vue组件的data数据,
  28. *
  29. * //通过json对象操作Element组件
  30. * json.bttype = "success"; //将按钮样式改为success
  31. * json.loading = true; //将按钮显示为加载中状态
  32. * json.disabled = true; //将按钮设置为禁用
  33. */
  34. _appendVueData: function(){
  35. if (!this.json.size) this.json.size = "";
  36. if (!this.json.bttype) this.json.bttype = "";
  37. if (!this.json.plain) this.json.plain = false;
  38. if (!this.json.round) this.json.round = false;
  39. if (!this.json.circle) this.json.circle = false;
  40. if (!this.json.disabled) this.json.disabled = false;
  41. if (!this.json.loading) this.json.loading = false;
  42. if (!this.json.icon) this.json.icon = false;
  43. },
  44. _createElementHtml: function(){
  45. var html = "<el-button";
  46. html += " :size=\"size\"";
  47. html += " :type=\"bttype\"";
  48. html += " :plain=\"plain\"";
  49. html += " :round=\"round\"";
  50. html += " :circle=\"circle\"";
  51. html += " :disabled=\"disabled\"";
  52. html += " :loading=\"loading\"";
  53. if( this.json.iconPosition !== "right" )html += " :icon=\"icon\"";
  54. if (this.json.autofocus==="yes") html += " autofocus";
  55. if (this.json.elProperties){
  56. Object.keys(this.json.elProperties).forEach(function(k){
  57. if (this.json.elProperties[k]) html += " "+k+"=\""+this.json.elProperties[k]+"\"";
  58. }, this);
  59. }
  60. if (this.json.elStyles) html += " :style=\"elStyles\"";
  61. // if (this.json.elStyles){
  62. // var style = "";
  63. // Object.keys(this.json.elStyles).forEach(function(k){
  64. // if (this.json.elStyles[k]) style += k+":"+this.json.elStyles[k]+";";
  65. // }, this);
  66. // html += " style=\""+style+"\"";
  67. // }
  68. html += ">"+((this.json.circle!=="yes" && (this.json.isText!=="no" && this.json.isText)) ? (this.json.name || this.json.id) : "");
  69. if( this.json.iconPosition === "right" )html += "<i class=\""+ this.json.icon +" el-icon--right\"></i>";
  70. html += "</el-button>";
  71. return html;
  72. }
  73. });