12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <template>
- <el-input
- v-model="value"
- :placeholder="placeholder"
- :maxlength="attrs.maxlength"
- :minlength="attrs.minlength"
- :show-word-limit="attrs.showWordLimit"
- :clearable="attrs.clearable"
- :show-password="attrs.showPassword"
- :disabled="attrs.disabled"
- :size="attrs.size"
- :type="attrs.type"
- :prefix-icon="attrs.prefixIcon"
- :suffix-icon="attrs.suffixIcon"
- :rows="attrs.rows"
- :readonly="attrs.readonly"
- @input="onChange"
- @clear="onChange"
- ></el-input>
- </template>
- <script lang="ts">
- import { Component, Prop, Vue, Watch } from "vue-property-decorator";
- import VueViews from '@/benyun/compVue/VueViews'
- @Component
- export default class ByInput extends VueViews {
- value:any=null;
- created(){
- if(this.propConfig){
- this.setConfig(this.propConfig)
- }
- if(this.propValue){
- this.setValue(this.propValue)
- }
- if(this.attrs.defaultValue && !this.value){
- this.setValue(this.attrs.defaultValue);
- this.onChange();
- }
- }
- get placeholder(){
- if(this.attrs.disabled){
- return ''
- }
- if(this.attrs.placeholder){
- return this.attrs.placeholder
- }
- return '请输入内容'
- }
- mounted(){
- }
- setValue(data:any){
- if(data){
- this.value = (this as any).$lodash.cloneDeep(data);
- if(this.attrs.type == 'number'){
- this.value = Number(this.value);
- }
- }else{
- this.value = null;
- }
- }
- getValue(){
- return (this as any).$lodash.cloneDeep(this.value);
- }
- // 清空数据
- clearValue(){
- this.value = ''
- }
- onChange(){
- this.$emit('onChange',this.value);
- }
- }
- </script>
- <style lang="scss" scoped>
- </style>
|