|
|
@@ -1,7 +1,7 @@
|
|
|
<template>
|
|
|
<view class="file-picker-wrapper">
|
|
|
<!-- 只读模式:仅展示 -->
|
|
|
- <view v-if="readonly" class="file-list readonly-list">
|
|
|
+ <view v-if="readonly && !noFileList" class="file-list readonly-list">
|
|
|
<view v-for="(file, index) in innerFileList" :key="index" class="file-item readonly-item"
|
|
|
@click="previewFile(file, index)">
|
|
|
<image v-if="isImage(file)" :src="file.url || file.path" mode="aspectFill" class="file-thumb"
|
|
|
@@ -16,52 +16,55 @@
|
|
|
|
|
|
<!-- 正常模式:宫格上传(完全对齐官方 upload-image 样式) -->
|
|
|
<view v-else class="uni-file-picker__container">
|
|
|
- <view class="file-picker__box" v-for="(item, index) in innerFileList" :key="index"
|
|
|
- :style="typeof boxStyle === 'object' ? boxStyle : { cssText: boxStyle }" >
|
|
|
- <view class="file-picker__box-content " :style="borderStyle" >
|
|
|
- <!-- 图片 -->
|
|
|
- <image v-if="isImage(item)" class="file-image cursor-pointer" :data-tooltip="tooltipText(item)" :src="item.url || item.path" mode="aspectFill"
|
|
|
- :style="imgStyle" @click.stop="previewFile(item, index)" />
|
|
|
-
|
|
|
- <!-- 视频 → 显示第一帧 + 播放图标 -->
|
|
|
- <view v-else-if="isVideo(item)" class="file-cover video-box cursor-pointer" :data-tooltip="tooltipText(item)" @click.stop="previewFile(item, index)">
|
|
|
- <image :src="item.url || item.path" class="file-image" mode="aspectFill" :style="imgStyle" />
|
|
|
- <view class="video-play-icon">▶</view>
|
|
|
- </view>
|
|
|
-
|
|
|
- <!-- 其他文件(PDF/Word/Excel) -->
|
|
|
- <view v-else class="file-cover file-box cursor-pointer" :data-tooltip="tooltipText(item)" :class="getFileClass(item.name)"
|
|
|
- @click.stop="previewFile(item, index)">
|
|
|
- <text class="file-big-icon">{{ getFileIcon(item.name) }}</text>
|
|
|
- <text class="file-ext-name">{{ getFileExt(item.name) }}</text>
|
|
|
- </view>
|
|
|
-
|
|
|
- <!-- 删除 -->
|
|
|
- <view v-if="delIcon" class="icon-del-box cursor-pointer" :data-tooltip="t('vu.tooltip.t17')" @click.stop="deleteFile(index)">
|
|
|
- <view class="icon-del"></view>
|
|
|
- <view class="icon-del rotate"></view>
|
|
|
- </view>
|
|
|
-
|
|
|
- <!-- 进度 -->
|
|
|
- <view v-if="item.status === 'uploading'" class="file-picker__progress">
|
|
|
- <progress class="file-picker__progress-item" :percent="item.progress" stroke-width="4"
|
|
|
- backgroundColor="#EBEBEB" />
|
|
|
- </view>
|
|
|
-
|
|
|
- <!-- 失败重试 -->
|
|
|
- <view v-if="item.status === 'error'" class="file-picker__mask" @click.stop="reUploadFile(index)">
|
|
|
- 点击重试
|
|
|
+ <template v-if="!noFileList">
|
|
|
+ <view class="file-picker__box" v-for="(item, index) in innerFileList" :key="index"
|
|
|
+ :style="typeof boxStyle === 'object' ? boxStyle : { cssText: boxStyle }" >
|
|
|
+ <view class="file-picker__box-content " :style="borderStyle" >
|
|
|
+ <!-- 图片 -->
|
|
|
+ <image v-if="isImage(item)" class="file-image cursor-pointer" :data-tooltip="tooltipText(item)" :src="item.url || item.path" mode="aspectFill"
|
|
|
+ :style="imgStyle" @click.stop="previewFile(item, index)" />
|
|
|
+
|
|
|
+ <!-- 视频 → 显示第一帧 + 播放图标 -->
|
|
|
+ <view v-else-if="isVideo(item)" class="file-cover video-box cursor-pointer" :data-tooltip="tooltipText(item)" @click.stop="previewFile(item, index)">
|
|
|
+ <image :src="item.url || item.path" class="file-image" mode="aspectFill" :style="imgStyle" />
|
|
|
+ <view class="video-play-icon">▶</view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 其他文件(PDF/Word/Excel) -->
|
|
|
+ <view v-else class="file-cover file-box cursor-pointer" :data-tooltip="tooltipText(item)" :class="getFileClass(item.name)"
|
|
|
+ @click.stop="previewFile(item, index)">
|
|
|
+ <text class="file-big-icon">{{ getFileIcon(item.name) }}</text>
|
|
|
+ <text class="file-ext-name">{{ getFileExt(item.name) }}</text>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 删除 -->
|
|
|
+ <view v-if="delIcon" class="icon-del-box cursor-pointer" :data-tooltip="t('vu.tooltip.t17')" @click.stop="deleteFile(index)">
|
|
|
+ <view class="icon-del"></view>
|
|
|
+ <view class="icon-del rotate"></view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 进度 -->
|
|
|
+ <view v-if="item.status === 'uploading'" class="file-picker__progress">
|
|
|
+ <progress class="file-picker__progress-item" :percent="item.progress" stroke-width="4"
|
|
|
+ backgroundColor="#EBEBEB" />
|
|
|
+ </view>
|
|
|
+
|
|
|
+ <!-- 失败重试 -->
|
|
|
+ <view v-if="item.status === 'error'" class="file-picker__mask" @click.stop="reUploadFile(index)">
|
|
|
+ 点击重试
|
|
|
+ </view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- </view>
|
|
|
-
|
|
|
+ </template>
|
|
|
<!-- 添加按钮 -->
|
|
|
- <view v-if="innerFileList?.length < limit" class="file-picker__box cursor-pointer"
|
|
|
- :style="typeof boxStyle === 'object' ? boxStyle : { cssText: boxStyle }" :data-tooltip="t('vu.tooltip.t10')" data-placement="top">
|
|
|
- <view class="file-picker__box-content is-add" :style="borderStyle" @click="handleChoose">
|
|
|
- <cwg-icon name="icon_add" class="upload-icon" :size="24" />
|
|
|
+ <slot v-if="innerFileList?.length < limit" name="add-button" :handleChoose="handleChoose">
|
|
|
+ <view class="file-picker__box cursor-pointer"
|
|
|
+ :style="typeof boxStyle === 'object' ? boxStyle : { cssText: boxStyle }" :data-tooltip="t('vu.tooltip.t10')" data-placement="top">
|
|
|
+ <view class="file-picker__box-content is-add" :style="borderStyle" @click="handleChoose">
|
|
|
+ <cwg-icon name="icon_add" class="upload-icon" :size="24" />
|
|
|
+ </view>
|
|
|
</view>
|
|
|
- </view>
|
|
|
+ </slot>
|
|
|
</view>
|
|
|
</view>
|
|
|
<cop-chooseFile :trigger="triggerFlag" accept="*" @receiveRenderFile="handleFile">
|
|
|
@@ -111,6 +114,11 @@ const props = defineProps({
|
|
|
type: Boolean,
|
|
|
default: true
|
|
|
},
|
|
|
+ // 不展示文件列表
|
|
|
+ noFileList: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ },
|
|
|
action: {
|
|
|
type: String,
|
|
|
default: ''
|