mirror of https://github.com/ElemeFE/element
				
				
				
			fix reset method
							parent
							
								
									426ce5da36
								
							
						
					
					
						commit
						5b4114ea3c
					
				| 
						 | 
				
			
			@ -4,6 +4,8 @@
 | 
			
		|||
 | 
			
		||||
*2016-XX-XX*
 | 
			
		||||
 | 
			
		||||
- 修复 Form reset method 对日期控件不起效的问题
 | 
			
		||||
 | 
			
		||||
#### 非兼容性更新
 | 
			
		||||
 | 
			
		||||
- 全屏 Loading 现在默认不再锁定屏幕滚动。如果需要的话,可添加 `lock` 修饰符
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -78,7 +78,8 @@
 | 
			
		|||
        validateDisabled: false,
 | 
			
		||||
        validating: false,
 | 
			
		||||
        validator: {},
 | 
			
		||||
        isRequired: false
 | 
			
		||||
        isRequired: false,
 | 
			
		||||
        initialValue: null
 | 
			
		||||
      };
 | 
			
		||||
    },
 | 
			
		||||
    methods: {
 | 
			
		||||
| 
						 | 
				
			
			@ -118,12 +119,9 @@
 | 
			
		|||
        if (Array.isArray(value) && value.length > 0) {
 | 
			
		||||
          this.validateDisabled = true;
 | 
			
		||||
          model[this.prop] = [];
 | 
			
		||||
        } else if (typeof value === 'string' && value !== '') {
 | 
			
		||||
        } else if (value) {
 | 
			
		||||
          this.validateDisabled = true;
 | 
			
		||||
          model[this.prop] = '';
 | 
			
		||||
        } else if (typeof value === 'number') {
 | 
			
		||||
          this.validateDisabled = true;
 | 
			
		||||
          model[this.prop] = 0;
 | 
			
		||||
          model[this.prop] = this.initialValue;
 | 
			
		||||
        }
 | 
			
		||||
      },
 | 
			
		||||
      getRules() {
 | 
			
		||||
| 
						 | 
				
			
			@ -151,12 +149,22 @@
 | 
			
		|||
        }
 | 
			
		||||
 | 
			
		||||
        this.validate('change');
 | 
			
		||||
      },
 | 
			
		||||
      getInitialValue() {
 | 
			
		||||
        var value = this.form.model[this.prop];
 | 
			
		||||
        if (value === undefined) {
 | 
			
		||||
          return value;
 | 
			
		||||
        } else {
 | 
			
		||||
          return JSON.parse(JSON.stringify(value));
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    },
 | 
			
		||||
    mounted() {
 | 
			
		||||
      if (this.prop) {
 | 
			
		||||
        this.dispatch('form', 'el.form.addField', [this]);
 | 
			
		||||
 | 
			
		||||
        this.initialValue = this.getInitialValue();
 | 
			
		||||
 | 
			
		||||
        let rules = this.getRules();
 | 
			
		||||
 | 
			
		||||
        if (rules.length) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue