Elautocomplete.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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.Elautocomplete = MWF.FCElautocomplete = new Class({
  4. Extends: MWF.FCElinput,
  5. Implements: [Options, Events],
  6. options: {
  7. "style": "default",
  8. "propertyPath": "../x_component_process_FormDesigner/Module/Elautocomplete/elautocomplete.html"
  9. },
  10. _initModuleType: function(){
  11. this.className = "Elautocomplete";
  12. this.moduleType = "element";
  13. this.moduleName = "elautocomplete";
  14. },
  15. _createElementHtml: function(){
  16. //var html = "<el-input placeholder=\"请输入内容\"></el-input>";
  17. var html = "<el-autocomplete";
  18. // if (this.json.description) html += " placeholder=\""+this.json.description+"\"";
  19. // if (this.json.size && this.json.size!=="default") html += " size=\""+this.json.size+"\"";
  20. // if (this.json.placement) html += " placement=\""+this.json.placement+"\"";
  21. // if (this.json.popperClass) html += " popper-class=\""+this.json.popperClass+"\"";
  22. // if (this.json.triggerOnFocus===false ) html += " :trigger-on-focus='false'";
  23. // if (this.json.prefixIcon) html += " prefix-icon=\""+this.json.prefixIcon+"\"";
  24. // if (this.json.suffixIcon) html += " suffix-icon=\""+this.json.suffixIcon+"\"";
  25. html += " :placeholder=\"description\"";
  26. html += " :size=\"size\"";
  27. html += " :placement=\"placement\"";
  28. html += " :popper-class=\"popperClass\"";
  29. html += " :trigger-on-focus='false'";
  30. html += " :prefix-icon=\"prefixIcon\"";
  31. html += " :suffix-icon=\"suffixIcon\"";
  32. html += " :fetch-suggestions=\"$fetchSuggestions\"";
  33. if (this.json.elProperties){
  34. Object.keys(this.json.elProperties).forEach(function(k){
  35. if (this.json.elProperties[k]) html += " "+k+"=\""+this.json.elProperties[k]+"\"";
  36. }, this);
  37. }
  38. html += " :style=\"tmpElStyles\"";
  39. // if (this.json.elStyles){
  40. // var style = "";
  41. // Object.keys(this.json.elStyles).forEach(function(k){
  42. // if (this.json.elStyles[k]) style += k+":"+this.json.elStyles[k]+";";
  43. // }, this);
  44. // html += " style=\""+style+"\"";
  45. // }
  46. html += " :value=\"id\">";
  47. if (this.json.vueSlot) html += this.json.vueSlot;
  48. html += "</el-autocomplete>";
  49. return html;
  50. },
  51. _createVueExtend: function(callback){
  52. var _self = this;
  53. return {
  54. data: this._createVueData(),
  55. mounted: function(){
  56. _self._afterMounted(this.$el, callback);
  57. },
  58. methods: {
  59. "$fetchSuggestions": function(qs, cb){
  60. debugger;
  61. if (this.json.itemType!=='script'){
  62. if (this.json.itemValues){
  63. cb(this.json.itemValues.map(function(v){
  64. return {"value": v};
  65. }));
  66. return;
  67. }
  68. }
  69. cb([]);
  70. }.bind(this)
  71. }
  72. };
  73. }
  74. });