...
|
...
|
@@ -3,7 +3,7 @@ |
3
|
3
|
import { ComponentType, ColEx } from '/@/components/Form/src/types/index';
|
4
|
4
|
import { computed } from '@vue/reactivity';
|
5
|
5
|
import { isFunction } from '/@/utils/is';
|
6
|
|
- import { unref } from 'vue';
|
|
6
|
+ import { toRaw, unref } from 'vue';
|
7
|
7
|
import { watch } from 'vue';
|
8
|
8
|
import { nextTick } from 'vue';
|
9
|
9
|
import { ref } from 'vue';
|
...
|
...
|
@@ -48,17 +48,13 @@ |
48
|
48
|
}
|
49
|
49
|
);
|
50
|
50
|
|
51
|
|
- const getProps = computed(() => {
|
52
|
|
- return props;
|
53
|
|
- });
|
54
|
|
-
|
55
|
51
|
const batchSetValue = (value: any): ValueItemType[] => {
|
56
|
|
- const { length } = unref(getProps);
|
|
52
|
+ const { length } = props;
|
57
|
53
|
return Array.from({ length }, () => ({ value }));
|
58
|
54
|
};
|
59
|
55
|
|
60
|
56
|
const getTotalControlItem = computed(() => {
|
61
|
|
- const { totalControlProps, component, showTotalControl } = unref(getProps);
|
|
57
|
+ const { totalControlProps, component, showTotalControl } = props;
|
62
|
58
|
return {
|
63
|
59
|
...totalControlProps,
|
64
|
60
|
field: FormFieldsEnum.TOTAL_CONTROL,
|
...
|
...
|
@@ -72,12 +68,12 @@ |
72
|
68
|
} as FormSchema;
|
73
|
69
|
});
|
74
|
70
|
|
75
|
|
- const getSchemas = computed(() => {
|
76
|
|
- const { itemProps, itemLabel, length, component } = unref(getProps);
|
|
71
|
+ const getSchemas = () => {
|
|
72
|
+ const { itemProps, itemLabel, length, component } = props;
|
77
|
73
|
let label = isFunction(itemLabel) ? itemLabel : (index: number) => `#${index}`;
|
78
|
74
|
let _itemProps = isFunction(itemProps) ? itemProps : () => ({});
|
79
|
75
|
const schemas = Array.from(
|
80
|
|
- { length },
|
|
76
|
+ { length: props.length },
|
81
|
77
|
(_item, index) =>
|
82
|
78
|
({
|
83
|
79
|
..._itemProps(index),
|
...
|
...
|
@@ -93,14 +89,14 @@ |
93
|
89
|
} as FormSchema)
|
94
|
90
|
);
|
95
|
91
|
|
96
|
|
- length && schemas.unshift(unref(getTotalControlItem));
|
|
92
|
+ length && schemas.unshift(toRaw(getTotalControlItem.value));
|
97
|
93
|
|
98
|
94
|
return schemas;
|
99
|
|
- });
|
|
95
|
+ };
|
100
|
96
|
|
101
|
97
|
const [registerForm, { getFieldsValue, setProps, setFieldsValue }] = useForm({
|
102
|
98
|
showActionButtonGroup: false,
|
103
|
|
- schemas: unref(getSchemas),
|
|
99
|
+ schemas: toRaw(unref(getSchemas())),
|
104
|
100
|
// baseColProps,
|
105
|
101
|
baseColProps: props.itemColProps,
|
106
|
102
|
});
|
...
|
...
|
@@ -111,19 +107,16 @@ |
111
|
107
|
return;
|
112
|
108
|
}
|
113
|
109
|
const allValue = getFieldsValue();
|
114
|
|
- const sortKeyList = Array.from({ length: unref(getProps).length }, (_v, key) => key);
|
|
110
|
+ const sortKeyList = Array.from({ length: props.length }, (_v, key) => key);
|
115
|
111
|
const res = sortKeyList.map((item) => ({ value: allValue[item] } as ValueItemType));
|
116
|
112
|
|
117
|
113
|
emit(EmitEventEnum.UPDATE_VALUE, res);
|
118
|
114
|
};
|
119
|
115
|
|
120
|
116
|
const transformValue = (value: ValueItemType[]) => {
|
121
|
|
- const { length } = unref(getProps);
|
|
117
|
+ const { length } = props;
|
122
|
118
|
if (value.length !== length) {
|
123
|
|
- value = Array.from(
|
124
|
|
- { length: unref(getProps).length },
|
125
|
|
- () => ({ value: null } as ValueItemType)
|
126
|
|
- );
|
|
119
|
+ value = Array.from({ length: props.length }, () => ({ value: null } as ValueItemType));
|
127
|
120
|
}
|
128
|
121
|
return value.reduce((prev, next, index) => ({ ...prev, [index]: next.value }), {});
|
129
|
122
|
};
|
...
|
...
|
@@ -153,13 +146,11 @@ |
153
|
146
|
|
154
|
147
|
watch(
|
155
|
148
|
() => [props.length, props.component],
|
156
|
|
- (target) => {
|
157
|
|
- if (target !== undefined || target !== null) {
|
158
|
|
- setProps({
|
159
|
|
- schemas: unref(getSchemas),
|
160
|
|
- });
|
161
|
|
- handleUpdateValue();
|
162
|
|
- }
|
|
149
|
+ () => {
|
|
150
|
+ setProps({
|
|
151
|
+ schemas: toRaw(unref(getSchemas())),
|
|
152
|
+ });
|
|
153
|
+ handleUpdateValue();
|
163
|
154
|
}
|
164
|
155
|
);
|
165
|
156
|
|
...
|
...
|
|