Browse Source

fix: #2767 #2884 #2868 (#2956)

* fix: #2767

* fix: #2884

* fix: #2868
pull/2968/head
invalid w 3 years ago
committed by GitHub
parent
commit
5425dc241f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/components/CardList/src/CardList.vue
  2. 30
      src/components/Form/src/hooks/useFormEvents.ts
  3. 5
      src/views/form-design/components/VFormDesign/modules/FormComponentPanel.vue

4
src/components/CardList/src/CardList.vue

@ -61,7 +61,7 @@
<CardMeta>
<template #title>
<TypographyText :content="item.name" :ellipsis="{ tooltip: item.address }" />
<TypographyParagraph :content="item.name" :ellipsis="{ tooltip: item.address }" />
</template>
<template #avatar>
<Avatar :src="item.avatar" />
@ -93,7 +93,7 @@
const ListItem = List.Item;
const CardMeta = Card.Meta;
const TypographyText = Typography.Text;
const TypographyParagraph = Typography.Paragraph;
// slider
const sliderProp = computed(() => useSlider(4));
//

30
src/components/Form/src/hooks/useFormEvents.ts

@ -94,9 +94,7 @@ export function useFormEvents({
formModel[field] = defaultValueObj![field];
});
}
const isInput = schema?.component && defaultValueComponents.includes(schema.component);
const defaultValue = cloneDeep(defaultValueRef.value[key]);
formModel[key] = isInput ? defaultValue || '' : defaultValue;
formModel[key] = getDefaultValue(schema, defaultValueRef, key);
});
nextTick(() => clearValidate());
@ -407,3 +405,29 @@ export function useFormEvents({
scrollToField,
};
}
function getDefaultValue(
schema: FormSchema | undefined,
defaultValueRef: UseFormActionContext['defaultValueRef'],
key: string,
) {
let defaultValue = cloneDeep(defaultValueRef.value[key]);
const isInput = checkIsInput(schema);
if (isInput) {
return defaultValue || '';
}
if (!defaultValue && schema && checkIsRangeSlider(schema)) {
defaultValue = [0, 0];
}
return defaultValue;
}
function checkIsRangeSlider(schema: FormSchema) {
if (schema.component === 'Slider' && schema.componentProps && schema.componentProps.range) {
return true;
}
}
function checkIsInput(schema?: FormSchema) {
return schema?.component && defaultValueComponents.includes(schema.component);
}

5
src/views/form-design/components/VFormDesign/modules/FormComponentPanel.vue

@ -131,15 +131,16 @@
}
.draggable-box {
height: calc(100vh - 200px);
// width: 100%;
overflow: auto;
.drag-move {
min-height: 62px;
cursor: move;
}
.list-main {
height: 100%;
overflow: auto;
//
.list-enter-active {
transition: all 0.5s;

Loading…
Cancel
Save