|
@@ -78,7 +78,8 @@
|
|
validateDisabled: false,
|
|
validateDisabled: false,
|
|
validating: false,
|
|
validating: false,
|
|
validator: {},
|
|
validator: {},
|
|
- isRequired: false
|
|
|
|
|
|
+ isRequired: false,
|
|
|
|
+ initialValue: null
|
|
};
|
|
};
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
@@ -118,12 +119,9 @@
|
|
if (Array.isArray(value) && value.length > 0) {
|
|
if (Array.isArray(value) && value.length > 0) {
|
|
this.validateDisabled = true;
|
|
this.validateDisabled = true;
|
|
model[this.prop] = [];
|
|
model[this.prop] = [];
|
|
- } else if (typeof value === 'string' && value !== '') {
|
|
|
|
|
|
+ } else if (value) {
|
|
this.validateDisabled = true;
|
|
this.validateDisabled = true;
|
|
- model[this.prop] = '';
|
|
|
|
- } else if (typeof value === 'number') {
|
|
|
|
- this.validateDisabled = true;
|
|
|
|
- model[this.prop] = 0;
|
|
|
|
|
|
+ model[this.prop] = this.initialValue;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
getRules() {
|
|
getRules() {
|
|
@@ -151,12 +149,22 @@
|
|
}
|
|
}
|
|
|
|
|
|
this.validate('change');
|
|
this.validate('change');
|
|
|
|
+ },
|
|
|
|
+ getInitialValue() {
|
|
|
|
+ var value = this.form.model[this.prop];
|
|
|
|
+ if (value === undefined) {
|
|
|
|
+ return value;
|
|
|
|
+ } else {
|
|
|
|
+ return JSON.parse(JSON.stringify(value));
|
|
|
|
+ }
|
|
}
|
|
}
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
if (this.prop) {
|
|
if (this.prop) {
|
|
this.dispatch('form', 'el.form.addField', [this]);
|
|
this.dispatch('form', 'el.form.addField', [this]);
|
|
|
|
|
|
|
|
+ this.initialValue = this.getInitialValue();
|
|
|
|
+
|
|
let rules = this.getRules();
|
|
let rules = this.getRules();
|
|
|
|
|
|
if (rules.length) {
|
|
if (rules.length) {
|