byInput.vue 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <template>
  2. <el-input
  3. v-model="value"
  4. :placeholder="attrs.placeholder?attrs.placeholder:'请输入内容'"
  5. :maxlength="attrs.maxlength"
  6. :minlength="attrs.minlength"
  7. :show-word-limit="attrs.showWordLimit"
  8. :clearable="attrs.clearable"
  9. :show-password="attrs.showPassword"
  10. :disabled="attrs.disabled"
  11. :size="attrs.size"
  12. :prefix-icon="attrs.prefixIcon"
  13. :suffix-icon="attrs.suffixIcon"
  14. :rows="attrs.rows"
  15. :readonly="attrs.readonly"
  16. @input="onChange"
  17. @clear="onChange"
  18. ></el-input>
  19. </template>
  20. <script lang="ts">
  21. import { Component, Prop, Vue, Watch } from "vue-property-decorator";
  22. @Component
  23. export default class ByInput extends Vue {
  24. config:any={};
  25. value:any='';
  26. @Prop()
  27. propConfig: any
  28. @Prop()
  29. propValue:any
  30. get attrs(){
  31. return this.config?.attr ? this.config.attr : {};
  32. }
  33. created(){
  34. if(this.propConfig){
  35. this.setConfig(this.propConfig)
  36. }
  37. if(this.propValue){
  38. this.setValue(this.propConfig)
  39. }
  40. }
  41. mounted(){
  42. }
  43. setConfig(c:any){
  44. if(c){
  45. this.config = c;
  46. }
  47. }
  48. getConfig(){
  49. return (this as any).$lodash.cloneDeep(this.config)
  50. }
  51. setValue(data:any){
  52. if(data){
  53. this.value = (this as any).$lodash.cloneDeep(data);
  54. }else{
  55. this.value = {};
  56. }
  57. }
  58. getValue(){
  59. return (this as any).$lodash.cloneDeep(this.value);
  60. }
  61. // 清空数据
  62. clearValue(){
  63. this.value = ''
  64. }
  65. onChange(){
  66. this.$emit('onChange',this.value);
  67. }
  68. }
  69. </script>
  70. <style lang="scss" scoped>
  71. </style>