byInput.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. import VueViews from '@/benyun/compVue/VueViews'
  23. @Component
  24. export default class ByInput extends VueViews {
  25. value:any='';
  26. created(){
  27. if(this.propConfig){
  28. this.setConfig(this.propConfig)
  29. }
  30. if(this.propValue){
  31. this.setValue(this.propConfig)
  32. }
  33. }
  34. mounted(){
  35. if(this.propValue){
  36. this.value = this.propValue
  37. }
  38. }
  39. setValue(data:any){
  40. if(data){
  41. this.value = (this as any).$lodash.cloneDeep(data);
  42. }else{
  43. this.value = '';
  44. }
  45. }
  46. getValue(){
  47. return (this as any).$lodash.cloneDeep(this.value);
  48. }
  49. // 清空数据
  50. clearValue(){
  51. this.value = ''
  52. }
  53. onChange(){
  54. this.$emit('onChange',this.value);
  55. }
  56. }
  57. </script>
  58. <style lang="scss" scoped>
  59. </style>