Elslider.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. MWF.xApplication.process.FormDesigner.Module = MWF.xApplication.process.FormDesigner.Module || {};
  2. MWF.xDesktop.requireApp("process.FormDesigner", "Module.Elinput", null, false);
  3. MWF.xApplication.process.FormDesigner.Module.Elslider = MWF.FCElslider = new Class({
  4. Extends: MWF.FCElinput,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "../x_component_process_FormDesigner/Module/Elslider/elslider.html"
  9. },
  10. _initModuleType: function(){
  11. this.className = "Elslider";
  12. this.moduleType = "element";
  13. this.moduleName = "elslider";
  14. },
  15. _createElementHtml: function(){
  16. //var html = "<el-input placeholder=\"请输入内容\"></el-input>";
  17. var html = "<el-slider";
  18. html += " v-model=\"tmpValue\"";
  19. // if (this.json.max) html += " max=\""+this.json.max+"\"";
  20. // if (this.json.min) html += " min=\""+this.json.min+"\"";
  21. // if (this.json.step) html += " step=\""+this.json.step+"\"";
  22. // if (this.json.showStops) html += " show-stops";
  23. // if (this.json.showTooltip) html += " show-tooltip";
  24. // if (this.json.range) html += " range";
  25. // if (this.json.vertical) html += " vertical";
  26. // if (this.json.vertical && !this.json.height) this.json.height = "100px";
  27. // if (this.json.height) html += " height=\""+this.json.height+"\"";
  28. // if (this.json.showInput) html += " show-input";
  29. // if (this.json.showInputControls===false) html += " :show-input-controls=\"tmpShowInputControls\"";
  30. // if (this.json.inputSize) html += " input-size=\""+this.json.inputSize+"\"";
  31. // if (this.json.showTooltip!==false) html += " show-tooltip";
  32. // if (this.json.tooltipClass) html += " tooltip-class=\""+this.json.tooltipClass+"\"";
  33. html += " :max=\"getMax()\"";
  34. html += " :min=\"getMin()\"";
  35. html += " :step=\"getStep()\"";
  36. html += " :show-stops=\"showStops\"";
  37. html += " :show-tooltip=\"showTooltip\"";
  38. html += " :range=\"range\"";
  39. html += " :vertical=\"vertical\"";
  40. html += " :height=\"getHeight()\"";
  41. html += " :show-input=\"showInput\"";
  42. html += " :show-input-controls=\"showInputControls\"";
  43. html += " :input-size=\"inputSize\"";
  44. html += " :show-tooltip=\"showTooltip\"";
  45. html += " :tooltip-class=\"tooltipClass\"";
  46. html += " :style=\"tmpElStyles\"";
  47. html += "></el-slider>";
  48. return html;
  49. },
  50. _createVueExtend: function(callback){
  51. var _self = this;
  52. return {
  53. data: this._createVueData(),
  54. mounted: function(){
  55. _self._afterMounted(this.$el, callback);
  56. },
  57. methods: {
  58. getHeight: function(){
  59. return (this.$data.vertical && !this.$data.height) ? "100px" : this.$data.height;
  60. },
  61. getMax: function(){
  62. return this.$data.max.toFloat();
  63. },
  64. getMin: function(){
  65. return this.$data.min.toFloat();
  66. },
  67. getStep: function(){
  68. return this.$data.step.toFloat();
  69. }
  70. }
  71. };
  72. },
  73. _createVueData: function(){
  74. this.setElStyles();
  75. var data = this.json;
  76. Object.assign(data, this.tmpVueData||{});
  77. var max = (!this.json.max || !this.json.max.toFloat()) ? 100 : this.json.max.toFloat();
  78. var min = (!this.json.min || !this.json.min.toFloat()) ? 0 : this.json.min.toFloat();
  79. if (this.json.range){
  80. var d1 = ((max-min)/3);
  81. data.tmpValue = [d1+min, d1*2+min];
  82. }else{
  83. var d = (max-min)/2+min;
  84. data.tmpValue = d;
  85. }
  86. if (this.json.showInputControls===false) data.tmpShowInputControls = false;
  87. return data;
  88. },
  89. _setEditStyle_custom: function(name){
  90. switch (name){
  91. case "name": this.setPropertyName(); break;
  92. case "id": this.setPropertyId(); break;
  93. case "range":
  94. case "max":
  95. case "vertical":
  96. case "step":
  97. var max = (!this.json.max || !this.json.max.toFloat()) ? 100 : this.json.max.toFloat();
  98. var min = (!this.json.min || !this.json.min.toFloat()) ? 0 : this.json.min.toFloat();
  99. if (this.json.range){
  100. var d1 = ((max-min)/3);
  101. this.json.tmpValue = [d1+min, d1*2+min];
  102. }else{
  103. var d = (max-min)/2+min;
  104. this.json.tmpValue = d;
  105. }
  106. break;
  107. default: ;
  108. }
  109. },
  110. setPropertyName: function(){},
  111. setPropertyId: function(){}
  112. });