Browse Source

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

* fix: #2767

* fix: #2884

* fix: #2868
invalid w 1 year ago
parent
commit
5425dc241f

+ 2 - 2
src/components/CardList/src/CardList.vue

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

+ 27 - 3
src/components/Form/src/hooks/useFormEvents.ts

@@ -94,9 +94,7 @@ export function useFormEvents({
           formModel[field] = defaultValueObj![field];
           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());
     nextTick(() => clearValidate());
 
 
@@ -407,3 +405,29 @@ export function useFormEvents({
     scrollToField,
     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);
+}

+ 3 - 2
src/views/form-design/components/VFormDesign/modules/FormComponentPanel.vue

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