办学质量监测教学评价系统
shenrongliang
2025-06-13 11d86cc6c26bb4f709e407acadf4805c2024e79f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<script setup lang="ts">
import { computed, ref } from 'vue';
 
import { useVbenModal } from '@vben/common-ui';
 
import { Alert } from 'ant-design-vue';
 
import { ImageUpload } from '#/components/upload';
 
const emit = defineEmits<{ reload: [] }>();
 
const fileList = ref<string[]>([]);
const [BasicModal, modalApi] = useVbenModal({
  onOpenChange: (isOpen) => {
    if (isOpen) {
      return null;
    }
    if (fileList.value.length > 0) {
      fileList.value = [];
      emit('reload');
      modalApi.close();
      return null;
    }
  },
});
 
const accept = ref(['jpg', 'jpeg', 'png', 'gif', 'webp']);
const maxNumber = ref(3);
 
const message = computed(() => {
  return `支持 [${accept.value.join(', ')}] 格式,最多上传 ${maxNumber.value} 张图片`;
});
</script>
 
<template>
  <BasicModal
    :close-on-click-modal="false"
    :footer="false"
    :fullscreen-button="false"
    title="图片上传"
  >
    <div class="flex flex-col gap-4">
      <Alert :message="message" show-icon type="info">aaa</Alert>
      <ImageUpload
        v-model:value="fileList"
        :accept="accept"
        :max-number="maxNumber"
      />
    </div>
  </BasicModal>
</template>