vbenjs / vue-vben-admin

A modern vue admin. It is based on Vue3, vite and TypeScript. It's fast!

Home Page:https://vben.vvbin.cn/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG]当upload的值在两个以上,使用默认的删除会将列表清空

electroluxcode opened this issue · comments

⚠️ IMPORTANT ⚠️ Please check the following list before proceeding. If you ignore this issue template, your issue will be directly closed.

  • Read the docs.
  • Make sure the code is up to date. (Some bugs have been fixed in the latest code)
  • This is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.

Describe the bug

当upload的值在两个以上。预期是该行的删除就删除该行的数据,但是目前使用previewModal会将列表清空。

定位问题是在没有显式绑定 handleFn 的 key值。显式绑定即可,等一下会提交pr

Reproduction

<template>
  <Alert message="bug report" />
  <BasicForm @register="registerValiate" class="my-5" />
</template>

<script setup lang="ts">
  import { Alert } from 'ant-design-vue';
  import { BasicForm, FormSchema, useForm } from '@/components/Form';
  import { useMessage } from '@/hooks/web/useMessage';
  import { uploadApi } from '@/api/sys/upload';

  const { createMessage } = useMessage();

  const schemasValiate: FormSchema[] = [
    {
      field: 'field1',
      component: 'Upload',
      label: '字段1',
      defaultValue:["https://avatars.githubusercontent.com/u/59329360?v=4","http://localhost:5173/src/assets/images/logo.png"],
      componentProps: {
        api: uploadApi,
        maxNumber:3
      
      },
    
    },
  ];
  const [registerValiate, { getFieldsValue: getFieldsValueValiate, validate }] = useForm({
    labelWidth: 160,
    schemas: schemasValiate,
    actionColOptions: {
      span: 18,
    },
    submitFunc: () => {
      return new Promise((resolve) => {
        validate()
          .then(() => {
            resolve();
            console.log(getFieldsValueValiate());
            createMessage.success(`请到控制台查看结果`);
          })
          .catch(() => {
            createMessage.error(`请输入必填项`);
          });
      });
    },
  });
</script>