|
|
@@ -1,68 +1,86 @@
|
|
|
<template>
|
|
|
<div class="file-upload-preview-area">
|
|
|
- <div>文件预览区域</div>
|
|
|
-
|
|
|
- <a-upload
|
|
|
- :file-list="file_list"
|
|
|
- :multiple="true"
|
|
|
- :limit="MAX_ACCEPT_FILE"
|
|
|
- :auto-upload="false"
|
|
|
- :show-upload-button="{ showOnExceedLimit: false }"
|
|
|
- accept=".pdf,.docx"
|
|
|
- @change="handleFileChange"
|
|
|
- >
|
|
|
- <template #upload-button>
|
|
|
- <a-tooltip :content="upload_warning_text">
|
|
|
- <a-button class="upload-button">
|
|
|
- <template #icon>
|
|
|
- <icon-upload />
|
|
|
- </template>
|
|
|
-
|
|
|
- <template #default>点击上传</template>
|
|
|
- </a-button>
|
|
|
- </a-tooltip>
|
|
|
- </template>
|
|
|
-
|
|
|
- <template #file-name="{ fileItem }">
|
|
|
- <a-tooltip :content="fileItem.name">
|
|
|
- <span>{{ fileItem.name }}</span>
|
|
|
- </a-tooltip>
|
|
|
- </template>
|
|
|
-
|
|
|
- <!-- <template #upload-item="{ fileItem, index }">
|
|
|
- <div>
|
|
|
- <div>{{ fileItem.name }}</div>
|
|
|
- </div>
|
|
|
- </template> -->
|
|
|
- </a-upload>
|
|
|
+ <div class="file-doc-preview-container">
|
|
|
+ <FileItemDocPreview v-for="(item, index) of file_doc_list" :key="item.id + item.index" :file="item.file" />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <div class="file-image-preview-container">
|
|
|
+ <FileItemImagePreview v-for="(item, index) of file_images_list" :key="item.id + item.index" :file="item.file" />
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
<script setup>
|
|
|
import { ref, computed } from 'vue';
|
|
|
+import FileItemDocPreview from './FileItemDocPreview.vue';
|
|
|
+import FileItemImagePreview from './FileItemImagePreview.vue';
|
|
|
|
|
|
const props = defineProps({
|
|
|
file_list: Array
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
- * 文件处理
|
|
|
+ * 判断一个文件的后缀名是否是图片
|
|
|
+ * @param endfix
|
|
|
*/
|
|
|
-const file_list = ref([]);
|
|
|
-const MAX_ACCEPT_FILE = 30;
|
|
|
-const file_total = computed(() => {
|
|
|
- return file_list.value.length;
|
|
|
+const isImageEndfix = (endfix) => {
|
|
|
+ return endfix === 'jpg' || endfix === 'png' || endfix === 'jpeg' || endfix === 'gif';
|
|
|
+};
|
|
|
+
|
|
|
+/**
|
|
|
+ * 图片类型的列表
|
|
|
+ */
|
|
|
+const file_images_list = computed(() => {
|
|
|
+ const arr = [];
|
|
|
+
|
|
|
+ props.file_list.forEach((item, index) => {
|
|
|
+ const file_name = item.file.name;
|
|
|
+ const name_info_arr = file_name.split('.');
|
|
|
+ const end_fix = name_info_arr[name_info_arr.length - 1];
|
|
|
+
|
|
|
+ const is_image = isImageEndfix(end_fix);
|
|
|
+
|
|
|
+ if (is_image) {
|
|
|
+ arr.push(item);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return arr;
|
|
|
});
|
|
|
|
|
|
-const upload_warning_text = '';
|
|
|
+/**
|
|
|
+ * 文档类型的列表
|
|
|
+ */
|
|
|
+const file_doc_list = computed(() => {
|
|
|
+ const arr = [];
|
|
|
+
|
|
|
+ props.file_list.forEach((item, index) => {
|
|
|
+ const file_name = item.file.name;
|
|
|
+ const name_info_arr = file_name.split('.');
|
|
|
+ const end_fix = name_info_arr[name_info_arr.length - 1];
|
|
|
+
|
|
|
+ const is_image = isImageEndfix(end_fix);
|
|
|
+
|
|
|
+ if (!is_image) {
|
|
|
+ arr.push(item);
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
-const handleFileChange = () => {};
|
|
|
+ return arr;
|
|
|
+});
|
|
|
</script>
|
|
|
|
|
|
<style lang="css" scoped>
|
|
|
.file-upload-preview-area {
|
|
|
- display: flex;
|
|
|
+ /* display: flex;
|
|
|
justify-content: space-between;
|
|
|
- align-items: center;
|
|
|
+ align-items: center; */
|
|
|
+}
|
|
|
+
|
|
|
+.file-doc-preview-container {
|
|
|
+ display: flex;
|
|
|
+}
|
|
|
+.file-image-preview-container {
|
|
|
+ display: flex;
|
|
|
}
|
|
|
</style>
|