@form-create/component-elm-group 2.5.18 → 2.5.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/component.jsx +36 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@form-create/component-elm-group",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.25",
|
|
4
4
|
"description": "@form-create/element-ui 内置组件",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "4f13bd4d5789a2ab473523f3d1306e877279d4ee"
|
|
43
43
|
}
|
package/src/component.jsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {hasProperty} from '@form-create/utils/lib/type';
|
|
2
|
-
import {deepCopy} from '@form-create/utils/lib/deepextend';
|
|
2
|
+
import deepExtend, {deepCopy} from '@form-create/utils/lib/deepextend';
|
|
3
3
|
import extend from '@form-create/utils/lib/extend';
|
|
4
4
|
|
|
5
5
|
const NAME = 'fcGroup';
|
|
@@ -66,16 +66,39 @@ export default {
|
|
|
66
66
|
},
|
|
67
67
|
computed: {
|
|
68
68
|
formRule() {
|
|
69
|
-
if (this.rule) {
|
|
70
|
-
return Array.isArray(this.rule) ? this.rule : [this.rule];
|
|
71
|
-
}
|
|
72
69
|
if (this.rules) {
|
|
73
70
|
return this.rules;
|
|
74
71
|
}
|
|
72
|
+
if (this.rule) {
|
|
73
|
+
return Array.isArray(this.rule) ? this.rule : [this.rule];
|
|
74
|
+
}
|
|
75
75
|
return [];
|
|
76
76
|
}
|
|
77
77
|
},
|
|
78
78
|
watch: {
|
|
79
|
+
formRule: {
|
|
80
|
+
handler(n, o) {
|
|
81
|
+
Object.keys(this.cacheRule).forEach(v => {
|
|
82
|
+
const item = this.cacheRule[v];
|
|
83
|
+
if (item.$f) {
|
|
84
|
+
const val = item.$f.formData();
|
|
85
|
+
if (n === o) {
|
|
86
|
+
item.$f.deferSyncValue(() => {
|
|
87
|
+
deepExtend(item.rule, n);
|
|
88
|
+
item.$f.setValue(val);
|
|
89
|
+
}, true);
|
|
90
|
+
} else {
|
|
91
|
+
const val = item.$f.formData();
|
|
92
|
+
item.$f.once('reloading', () => {
|
|
93
|
+
item.$f.setValue(val);
|
|
94
|
+
})
|
|
95
|
+
item.rule = deepCopy(n);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
},
|
|
100
|
+
deep: true
|
|
101
|
+
},
|
|
79
102
|
disabled(n) {
|
|
80
103
|
if (this.syncDisabled) {
|
|
81
104
|
const lst = this.cacheRule;
|
|
@@ -105,7 +128,6 @@ export default {
|
|
|
105
128
|
for (let i = 0; i < len; i++) {
|
|
106
129
|
this.removeRule(keys[total - i - 1]);
|
|
107
130
|
}
|
|
108
|
-
this.subForm();
|
|
109
131
|
}
|
|
110
132
|
n.forEach((val, i) => {
|
|
111
133
|
this.setValue(keys[i], n[i]);
|
|
@@ -167,7 +189,6 @@ export default {
|
|
|
167
189
|
},
|
|
168
190
|
add$f(i, key, $f) {
|
|
169
191
|
this.cacheRule[key].$f = $f;
|
|
170
|
-
this.subForm();
|
|
171
192
|
this.formData(key, $f.formData());
|
|
172
193
|
this.$nextTick(() => {
|
|
173
194
|
if (this.syncDisabled) {
|
|
@@ -176,9 +197,6 @@ export default {
|
|
|
176
197
|
this.$emit('itemMounted', $f, Object.keys(this.cacheRule).indexOf(key));
|
|
177
198
|
});
|
|
178
199
|
},
|
|
179
|
-
subForm() {
|
|
180
|
-
this.formCreateInject.subForm(Object.keys(this.cacheRule).map(k => this.cacheRule[k].$f));
|
|
181
|
-
},
|
|
182
200
|
removeRule(key, emit) {
|
|
183
201
|
const index = Object.keys(this.cacheRule).indexOf(key);
|
|
184
202
|
this.$delete(this.cacheRule, key);
|
|
@@ -198,7 +216,6 @@ export default {
|
|
|
198
216
|
return;
|
|
199
217
|
}
|
|
200
218
|
this.removeRule(key, true);
|
|
201
|
-
this.subForm();
|
|
202
219
|
this.value.splice(index, 1);
|
|
203
220
|
this.input(this.value);
|
|
204
221
|
},
|
|
@@ -271,10 +288,15 @@ export default {
|
|
|
271
288
|
'emit-event': (name, ...args) => this.emitEvent(name, args, index, key),
|
|
272
289
|
input: ($f) => this.add$f(index, key, $f)
|
|
273
290
|
}}
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
291
|
+
props={{
|
|
292
|
+
value: this.field ? {[this.field]: this._value(this.value[index])} : this.value[index],
|
|
293
|
+
rule,
|
|
294
|
+
option: options,
|
|
295
|
+
extendOption: true,
|
|
296
|
+
inFor: true
|
|
297
|
+
}}/></ElFormItem></ElCol>
|
|
298
|
+
{button ? <ElCol
|
|
299
|
+
props={{span: 2, pull: 1, push: 1}}>{this.makeIcon(keys.length, index, key)}</ElCol> : null}
|
|
278
300
|
</ElRow>
|
|
279
301
|
})}</div>
|
|
280
302
|
}
|