@form-create/component-antdv-group 2.5.15 → 2.5.20
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 +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/component.jsx +31 -11
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@form-create/component-antdv-group",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.20",
|
|
4
4
|
"description": "@form-create/ant-design-vue 内置组件",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"author": "xaboy",
|
|
31
31
|
"license": "MIT",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@form-create/utils": "^2.5.
|
|
33
|
+
"@form-create/utils": "^2.5.18"
|
|
34
34
|
},
|
|
35
35
|
"bugs": {
|
|
36
36
|
"url": "https://github.com/xaboy/form-create/issues"
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"publishConfig": {
|
|
40
40
|
"access": "public"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "196b3c5b14af477d3d86fa37418a60e47ac4bc1f"
|
|
43
43
|
}
|
package/src/component.jsx
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import {hasProperty} from '@form-create/utils/lib/type';
|
|
2
|
+
import deepExtend, {deepCopy} from '@form-create/utils/lib/deepextend';
|
|
3
|
+
import extend from '@form-create/utils/lib/extend';
|
|
2
4
|
|
|
3
5
|
const NAME = 'fcGroup';
|
|
4
6
|
|
|
@@ -30,6 +32,7 @@ export default {
|
|
|
30
32
|
type: Array,
|
|
31
33
|
default: () => []
|
|
32
34
|
},
|
|
35
|
+
defaultValue: Object,
|
|
33
36
|
disabled: {
|
|
34
37
|
type: Boolean,
|
|
35
38
|
default: false
|
|
@@ -63,16 +66,33 @@ export default {
|
|
|
63
66
|
},
|
|
64
67
|
computed: {
|
|
65
68
|
formRule() {
|
|
66
|
-
if (this.rule) {
|
|
67
|
-
return Array.isArray(this.rule) ? this.rule : [this.rule];
|
|
68
|
-
}
|
|
69
69
|
if (this.rules) {
|
|
70
70
|
return this.rules;
|
|
71
71
|
}
|
|
72
|
+
if (this.rule) {
|
|
73
|
+
return Array.isArray(this.rule) ? this.rule : [this.rule];
|
|
74
|
+
}
|
|
72
75
|
return [];
|
|
73
76
|
}
|
|
74
77
|
},
|
|
75
78
|
watch: {
|
|
79
|
+
formRule: {
|
|
80
|
+
handler(n, o) {
|
|
81
|
+
Object.keys(this.cacheRule).forEach(v => {
|
|
82
|
+
const item = this.cacheRule[v];
|
|
83
|
+
if (n === o) {
|
|
84
|
+
deepExtend(item.rule, n)
|
|
85
|
+
} else {
|
|
86
|
+
const val = item.$f.formData();
|
|
87
|
+
item.$f.once('reload', () => {
|
|
88
|
+
item.$f.setValue(val);
|
|
89
|
+
})
|
|
90
|
+
item.rule = deepCopy(n);
|
|
91
|
+
}
|
|
92
|
+
})
|
|
93
|
+
},
|
|
94
|
+
deep: true
|
|
95
|
+
},
|
|
76
96
|
disabled(n) {
|
|
77
97
|
if (this.syncDisabled) {
|
|
78
98
|
const lst = this.cacheRule;
|
|
@@ -102,7 +122,6 @@ export default {
|
|
|
102
122
|
for (let i = 0; i < len; i++) {
|
|
103
123
|
this.removeRule(keys[total - i - 1]);
|
|
104
124
|
}
|
|
105
|
-
this.subForm();
|
|
106
125
|
}
|
|
107
126
|
n.forEach((val, i) => {
|
|
108
127
|
this.setValue(keys[i], n[i]);
|
|
@@ -152,7 +171,11 @@ export default {
|
|
|
152
171
|
submitBtn: false,
|
|
153
172
|
resetBtn: false,
|
|
154
173
|
};
|
|
155
|
-
|
|
174
|
+
if (this.defaultValue) {
|
|
175
|
+
if (!options.formData) options.formData = {};
|
|
176
|
+
const defVal = deepCopy(this.defaultValue);
|
|
177
|
+
extend(options.formData, this.field ? {[this.field]: defVal} : defVal);
|
|
178
|
+
}
|
|
156
179
|
this.$set(this.cacheRule, ++this.len, {rule, options});
|
|
157
180
|
if (emit) {
|
|
158
181
|
this.$nextTick(() => this.$emit('add', rule, Object.keys(this.cacheRule).length - 1));
|
|
@@ -160,7 +183,7 @@ export default {
|
|
|
160
183
|
},
|
|
161
184
|
add$f(i, key, $f) {
|
|
162
185
|
this.cacheRule[key].$f = $f;
|
|
163
|
-
this.
|
|
186
|
+
this.formData(key, $f.formData());
|
|
164
187
|
this.$nextTick(() => {
|
|
165
188
|
if (this.syncDisabled) {
|
|
166
189
|
$f.disabled(this.disabled);
|
|
@@ -168,9 +191,6 @@ export default {
|
|
|
168
191
|
this.$emit('itemMounted', $f, Object.keys(this.cacheRule).indexOf(key));
|
|
169
192
|
});
|
|
170
193
|
},
|
|
171
|
-
subForm() {
|
|
172
|
-
this.formCreateInject.subForm(Object.keys(this.cacheRule).map(k => this.cacheRule[k].$f));
|
|
173
|
-
},
|
|
174
194
|
removeRule(key, emit) {
|
|
175
195
|
const index = Object.keys(this.cacheRule).indexOf(key);
|
|
176
196
|
this.$delete(this.cacheRule, key);
|
|
@@ -190,7 +210,6 @@ export default {
|
|
|
190
210
|
return;
|
|
191
211
|
}
|
|
192
212
|
this.removeRule(key, true);
|
|
193
|
-
this.subForm();
|
|
194
213
|
this.value.splice(index, 1);
|
|
195
214
|
this.input(this.value);
|
|
196
215
|
},
|
|
@@ -257,12 +276,13 @@ export default {
|
|
|
257
276
|
return <ARow align="middle" type="flex" key={key}
|
|
258
277
|
style="border-bottom:1px dashed #d9d9d9;margin-bottom:10px;">
|
|
259
278
|
<ACol span={button ? 20 : 24}><Type
|
|
260
|
-
key={key}
|
|
279
|
+
key={key} inFor={true}
|
|
261
280
|
on={{
|
|
262
281
|
'update:value': (formData) => this.formData(key, formData),
|
|
263
282
|
'emit-event': (name, ...args) => this.emitEvent(name, args, index, key),
|
|
264
283
|
input: ($f) => this.add$f(index, key, $f)
|
|
265
284
|
}}
|
|
285
|
+
value={this.field ? {[this.field]: this._value(this.value[index])} : this.value[index]}
|
|
266
286
|
rule={rule}
|
|
267
287
|
option={options} extendOption={true}/></ACol>
|
|
268
288
|
{button ? <ACol span={2} pull={1} push={1}>{this.makeIcon(keys.length, index, key)}</ACol> : null}
|