|
@@ -457,40 +457,25 @@ export default {
|
|
|
|
|
|
/**
|
|
|
* 预览图片
|
|
|
- * @param {Object} file - 文件信息
|
|
|
- * @param {number} index - 当前图片索引
|
|
|
+ * @param {Object} file - 文件对象
|
|
|
+ * @param {number} index - 索引
|
|
|
*/
|
|
|
previewImage(file, index = 0) {
|
|
|
- if (this.isVideoFile(file.fileName)) {
|
|
|
- // 视频预览
|
|
|
- this.previewVideoUrl = file.fileUrl
|
|
|
- this.videoPreviewVisible = true
|
|
|
- } else if (this.isImageFile(file.fileName)) {
|
|
|
- // 图片预览
|
|
|
- const imageFiles = this.attachmentList.filter(item => this.isImageFile(item.fileName))
|
|
|
- this.previewImageList = imageFiles.map(item => item.fileUrl)
|
|
|
- this.currentPreviewIndex = imageFiles.findIndex(item => item.id === file.id)
|
|
|
- this.previewImageUrl = file.fileUrl
|
|
|
- this.imagePreviewVisible = true
|
|
|
- }
|
|
|
+ // 获取所有图片文件
|
|
|
+ const imageFiles = this.attachmentList.filter(item => this.isImageFile(item.fileName))
|
|
|
+ this.previewImageList = imageFiles.map(item => item.fileUrl)
|
|
|
+ this.currentPreviewIndex = imageFiles.findIndex(item => item.id === file.id)
|
|
|
+ this.previewImageUrl = file.fileUrl
|
|
|
+ this.imagePreviewVisible = true
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
- * 关闭图片预览
|
|
|
+ * 预览视频
|
|
|
+ * @param {Object} file - 文件对象
|
|
|
*/
|
|
|
- closeImagePreview() {
|
|
|
- this.imagePreviewVisible = false
|
|
|
- this.previewImageUrl = ''
|
|
|
- this.previewImageList = []
|
|
|
- this.currentPreviewIndex = 0
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * 关闭视频预览
|
|
|
- */
|
|
|
- closeVideoPreview() {
|
|
|
- this.videoPreviewVisible = false
|
|
|
- this.previewVideoUrl = ''
|
|
|
+ previewVideo(file) {
|
|
|
+ this.previewVideoUrl = file.fileUrl
|
|
|
+ this.videoPreviewVisible = true
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -546,6 +531,24 @@ export default {
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
+ * 关闭图片预览
|
|
|
+ */
|
|
|
+ closeImagePreview() {
|
|
|
+ this.imagePreviewVisible = false
|
|
|
+ this.previewImageUrl = ''
|
|
|
+ this.previewImageList = []
|
|
|
+ this.currentPreviewIndex = 0
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 关闭视频预览
|
|
|
+ */
|
|
|
+ closeVideoPreview() {
|
|
|
+ this.videoPreviewVisible = false
|
|
|
+ this.previewVideoUrl = ''
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
* 处理视频加载错误
|
|
|
* @param {Event} event - 错误事件
|
|
|
*/
|