|
18 | 18 | import FieldSelect from './components/Select.vue';
|
19 | 19 | import FieldRange from './components/Range.vue';
|
20 | 20 | import FieldNumber from './components/Number.vue';
|
21 |
| - import {assign, each, get, parse, isArray, isString, isUndefined, set, warn} from './util'; |
| 21 | + import {assign, each, get, parse, isArray, isString, isFunction, isUndefined, set, warn} from './util'; |
22 | 22 |
|
23 | 23 | export default {
|
24 | 24 |
|
|
72 | 72 | this.$emit('change', value, field);
|
73 | 73 | },
|
74 | 74 |
|
75 |
| - evaluate(expression, values = this.values) { |
76 |
| -
|
77 |
| - try { |
78 |
| -
|
79 |
| - if (isUndefined(expression)) { |
80 |
| - return true; |
81 |
| - } |
82 |
| -
|
83 |
| - if (isString(expression)) { |
84 |
| - expression = parse(expression); |
85 |
| - } |
86 |
| -
|
87 |
| - return expression.call(this, values, { |
88 |
| - $match, $get: key => get(values, key) |
89 |
| - }); |
90 |
| -
|
91 |
| - } catch (e) { |
92 |
| - warn(e); |
93 |
| - } |
94 |
| -
|
95 |
| - return true; |
96 |
| - }, |
97 |
| -
|
98 | 75 | prepare(config = this.config, prefix = this.prefix) {
|
99 | 76 |
|
100 | 77 | const arr = isArray(config), fields = [];
|
|
126 | 103 | });
|
127 | 104 |
|
128 | 105 | return fields;
|
| 106 | + }, |
| 107 | +
|
| 108 | + evaluate(expression, values = this.values) { |
| 109 | +
|
| 110 | + try { |
| 111 | +
|
| 112 | + if (isUndefined(expression)) { |
| 113 | + return true; |
| 114 | + } |
| 115 | +
|
| 116 | + if (isString(expression)) { |
| 117 | + expression = parse(expression); |
| 118 | + } |
| 119 | +
|
| 120 | + if (isFunction(expression)) { |
| 121 | + return expression.call(this, values, {$match, $get: key => get(values, key)}); |
| 122 | + } |
| 123 | +
|
| 124 | + return expression; |
| 125 | +
|
| 126 | + } catch (e) { |
| 127 | + warn(e); |
| 128 | + } |
| 129 | +
|
| 130 | + return true; |
129 | 131 | }
|
130 | 132 |
|
131 | 133 | }
|
|
0 commit comments