|
@@ -61,6 +61,11 @@ export default {
|
|
|
{ required: true, message: '请选择审核时间', trigger: 'change' }
|
|
|
]
|
|
|
},
|
|
|
+ // 添加图片预览相关状态
|
|
|
+ imagePreviewVisible: false,
|
|
|
+ previewImageUrl: '',
|
|
|
+ previewImageList: [],
|
|
|
+ currentPreviewIndex: 0,
|
|
|
option: {
|
|
|
height: 'auto',
|
|
|
calcHeight: 30,
|
|
@@ -423,6 +428,62 @@ export default {
|
|
|
window.open(file.fileUrl)
|
|
|
},
|
|
|
|
|
|
+ /**
|
|
|
+ * 判断文件是否为图片
|
|
|
+ * @param {string} fileName - 文件名
|
|
|
+ * @returns {boolean} 是否为图片
|
|
|
+ */
|
|
|
+ isImageFile(fileName) {
|
|
|
+ if (!fileName) return false
|
|
|
+ const imageExtensions = ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.webp', '.svg']
|
|
|
+ const extension = fileName.toLowerCase().substring(fileName.lastIndexOf('.'))
|
|
|
+ return imageExtensions.includes(extension)
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断文件是否为视频
|
|
|
+ * @param {string} fileName - 文件名
|
|
|
+ * @returns {boolean} 是否为视频
|
|
|
+ */
|
|
|
+ isVideoFile(fileName) {
|
|
|
+ if (!fileName) return false
|
|
|
+ const videoExtensions = ['.mp4', '.avi', '.mov', '.wmv', '.flv', '.webm', '.mkv']
|
|
|
+ const extension = fileName.toLowerCase().substring(fileName.lastIndexOf('.'))
|
|
|
+ return videoExtensions.includes(extension)
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 预览图片
|
|
|
+ * @param {Object} file - 文件信息
|
|
|
+ * @param {number} index - 当前图片索引
|
|
|
+ */
|
|
|
+ previewImage(file, index = 0) {
|
|
|
+ // 获取所有图片文件
|
|
|
+ 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
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 关闭图片预览
|
|
|
+ */
|
|
|
+ closeImagePreview() {
|
|
|
+ this.imagePreviewVisible = false
|
|
|
+ this.previewImageUrl = ''
|
|
|
+ this.previewImageList = []
|
|
|
+ this.currentPreviewIndex = 0
|
|
|
+ },
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理图片加载错误
|
|
|
+ * @param {Event} event - 错误事件
|
|
|
+ */
|
|
|
+ handleImageError(event) {
|
|
|
+ event.target.src = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDAiIGhlaWdodD0iNDAiIHZpZXdCb3g9IjAgMCA0MCA0MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHJlY3Qgd2lkdGg9IjQwIiBoZWlnaHQ9IjQwIiBmaWxsPSIjRjVGNUY1Ii8+CjxwYXRoIGQ9Ik0yMCAyNkM5LjUgMjYgMSAxNy41IDEgN0MxIDMuNSA0IDEgNyAxSDMzQzM2IDEgMzkgMy41IDM5IDdDMzkgMTcuNSAzMC41IDI2IDIwIDI2WiIgZmlsbD0iI0NDQ0NDQyIvPgo8L3N2Zz4K'
|
|
|
+ },
|
|
|
+
|
|
|
// 添加公共方法引用
|
|
|
formatFileSize,
|
|
|
|