mirror of
https://github.com/vbenjs/vue-vben-admin.git
synced 2025-01-25 02:58:43 +08:00
Co-authored-by: maxiaojing <maxiaojing@hashdata.cn>
This commit is contained in:
parent
0ab2a541cb
commit
4c67d8c388
@ -76,6 +76,11 @@ export function useFormEvents({
|
|||||||
const hasKey = Reflect.has(values, key);
|
const hasKey = Reflect.has(values, key);
|
||||||
|
|
||||||
value = handleInputNumberValue(schema?.component, value);
|
value = handleInputNumberValue(schema?.component, value);
|
||||||
|
const { componentProps } = schema || {};
|
||||||
|
let _props = componentProps as any;
|
||||||
|
if (typeof componentProps === 'function') {
|
||||||
|
_props = _props({ formModel: unref(formModel) });
|
||||||
|
}
|
||||||
// 0| '' is allow
|
// 0| '' is allow
|
||||||
if (hasKey && fields.includes(key)) {
|
if (hasKey && fields.includes(key)) {
|
||||||
// time type
|
// time type
|
||||||
@ -85,17 +90,15 @@ export function useFormEvents({
|
|||||||
for (const ele of value) {
|
for (const ele of value) {
|
||||||
arr.push(ele ? dateUtil(ele) : null);
|
arr.push(ele ? dateUtil(ele) : null);
|
||||||
}
|
}
|
||||||
formModel[key] = arr;
|
unref(formModel)[key] = arr;
|
||||||
} else {
|
} else {
|
||||||
const { componentProps } = schema || {};
|
unref(formModel)[key] = value ? (_props?.valueFormat ? value : dateUtil(value)) : null;
|
||||||
let _props = componentProps as any;
|
|
||||||
if (typeof componentProps === 'function') {
|
|
||||||
_props = _props({ formModel });
|
|
||||||
}
|
|
||||||
formModel[key] = value ? (_props?.valueFormat ? value : dateUtil(value)) : null;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
formModel[key] = value;
|
unref(formModel)[key] = value;
|
||||||
|
}
|
||||||
|
if (_props?.onChange) {
|
||||||
|
_props?.onChange(value);
|
||||||
}
|
}
|
||||||
validKeys.push(key);
|
validKeys.push(key);
|
||||||
} else {
|
} else {
|
||||||
@ -103,13 +106,13 @@ export function useFormEvents({
|
|||||||
try {
|
try {
|
||||||
const value = nestKey.split('.').reduce((out, item) => out[item], values);
|
const value = nestKey.split('.').reduce((out, item) => out[item], values);
|
||||||
if (isDef(value)) {
|
if (isDef(value)) {
|
||||||
formModel[nestKey] = value;
|
unref(formModel)[nestKey] = unref(value);
|
||||||
validKeys.push(nestKey);
|
validKeys.push(nestKey);
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// key not exist
|
// key not exist
|
||||||
if (isDef(defaultValueRef.value[nestKey])) {
|
if (isDef(defaultValueRef.value[nestKey])) {
|
||||||
formModel[nestKey] = cloneDeep(defaultValueRef.value[nestKey]);
|
unref(formModel)[nestKey] = cloneDeep(unref(defaultValueRef.value[nestKey]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -98,6 +98,9 @@
|
|||||||
key: '2',
|
key: '2',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
onChange: (value) => {
|
||||||
|
console.log(value, '123');
|
||||||
|
},
|
||||||
},
|
},
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
@ -235,6 +238,7 @@
|
|||||||
function setFormValues() {
|
function setFormValues() {
|
||||||
setFieldsValue({
|
setFieldsValue({
|
||||||
field1: 1111,
|
field1: 1111,
|
||||||
|
field4: ['1'],
|
||||||
field5: ['1'],
|
field5: ['1'],
|
||||||
field7: '1',
|
field7: '1',
|
||||||
field33: '2020-12-12',
|
field33: '2020-12-12',
|
||||||
|
Loading…
Reference in New Issue
Block a user