|
89 | 89 | return this.for || this.prop;
|
90 | 90 | },
|
91 | 91 | labelStyle() {
|
92 |
| - var ret = {}; |
| 92 | + const ret = {}; |
93 | 93 | if (this.form.labelPosition === 'top') return ret;
|
94 |
| - var labelWidth = this.labelWidth || this.form.labelWidth; |
| 94 | + const labelWidth = this.labelWidth || this.form.labelWidth; |
95 | 95 | if (labelWidth) {
|
96 | 96 | ret.width = labelWidth;
|
97 | 97 | }
|
98 | 98 | return ret;
|
99 | 99 | },
|
100 | 100 | contentStyle() {
|
101 |
| - var ret = {}; |
| 101 | + const ret = {}; |
102 | 102 | const label = this.label;
|
103 | 103 | if (this.form.labelPosition === 'top' || this.form.inline) return ret;
|
104 | 104 | if (!label && !this.labelWidth && this.isNested) return ret;
|
105 |
| - var labelWidth = this.labelWidth || this.form.labelWidth; |
| 105 | + const labelWidth = this.labelWidth || this.form.labelWidth; |
106 | 106 | if (labelWidth) {
|
107 | 107 | ret.marginLeft = labelWidth;
|
108 | 108 | }
|
|
123 | 123 | fieldValue: {
|
124 | 124 | cache: false,
|
125 | 125 | get() {
|
126 |
| - var model = this.form.model; |
| 126 | + const model = this.form.model; |
127 | 127 | if (!model || !this.prop) { return; }
|
128 | 128 |
|
129 |
| - var path = this.prop; |
| 129 | + let path = this.prop; |
130 | 130 | if (path.indexOf(':') !== -1) {
|
131 | 131 | path = path.replace(/:/, '.');
|
132 | 132 | }
|
|
171 | 171 | methods: {
|
172 | 172 | validate(trigger, callback = noop) {
|
173 | 173 | this.validateDisabled = false;
|
174 |
| - var rules = this.getFilteredRule(trigger); |
| 174 | + const rules = this.getFilteredRule(trigger); |
175 | 175 | if ((!rules || rules.length === 0) && this.required === undefined) {
|
176 | 176 | callback();
|
177 | 177 | return true;
|
178 | 178 | }
|
179 | 179 |
|
180 | 180 | this.validateState = 'validating';
|
181 | 181 |
|
182 |
| - var descriptor = {}; |
| 182 | + const descriptor = {}; |
183 | 183 | if (rules && rules.length > 0) {
|
184 | 184 | rules.forEach(rule => {
|
185 | 185 | delete rule.trigger;
|
186 | 186 | });
|
187 | 187 | }
|
188 | 188 | descriptor[this.prop] = rules;
|
189 | 189 |
|
190 |
| - var validator = new AsyncValidator(descriptor); |
191 |
| - var model = {}; |
| 190 | + const validator = new AsyncValidator(descriptor); |
| 191 | + const model = {}; |
192 | 192 |
|
193 | 193 | model[this.prop] = this.fieldValue;
|
194 | 194 |
|
|
226 | 226 | }
|
227 | 227 | },
|
228 | 228 | getRules() {
|
229 |
| - var formRules = this.form.rules; |
230 |
| - var selfRules = this.rules; |
231 |
| - var requiredRule = this.required !== undefined ? { required: !!this.required } : []; |
| 229 | + let formRules = this.form.rules; |
| 230 | + const selfRules = this.rules; |
| 231 | + const requiredRule = this.required !== undefined ? { required: !!this.required } : []; |
232 | 232 |
|
233 | 233 | formRules = formRules ? getPropByPath(formRules, this.prop || '').o[this.prop || ''] : [];
|
234 | 234 |
|
235 | 235 | return [].concat(selfRules || formRules || []).concat(requiredRule);
|
236 | 236 | },
|
237 | 237 | getFilteredRule(trigger) {
|
238 |
| - var rules = this.getRules(); |
| 238 | + const rules = this.getRules(); |
239 | 239 |
|
240 | 240 | return rules.filter(rule => {
|
241 | 241 | return !rule.trigger || rule.trigger.indexOf(trigger) !== -1;
|
|
0 commit comments