|
|
@@ -5,38 +5,73 @@
|
|
|
<vue-draggable
|
|
|
v-if="fileList && fileList.length"
|
|
|
v-model="fileList"
|
|
|
- v-bind="draggableOptions"
|
|
|
+ v-bind="draggableBindOptions"
|
|
|
class="list-group"
|
|
|
@start="isDragging = true"
|
|
|
@end="()=>{isDragging= false}"
|
|
|
>
|
|
|
- <li
|
|
|
- v-for="(item, index) in fileList"
|
|
|
- :key="index"
|
|
|
- class="image-reader-item"
|
|
|
- :style="{
|
|
|
- 'backgroundImage': 'url(' + getImageUrl(item.id) + ')',
|
|
|
- 'backgroundPosition': 'center center',
|
|
|
- 'backgroundRepeat': 'no-repeat',
|
|
|
- 'backgroundSize': 'cover',
|
|
|
- 'width': `${$utils.isEmpty(width) ? 100 : width}px`,
|
|
|
- 'height': `${$utils.isEmpty(height) ? 100 : height}px`
|
|
|
- }"
|
|
|
- @click="clickHandler(item, index)"
|
|
|
- @mouseover="showTips(item, index)"
|
|
|
- @mouseout="hideTips(item, index)"
|
|
|
- >
|
|
|
- <el-tag v-if="!disabled" class="image-reader-item-tag" @click.stop="onDeleteImage(index)">
|
|
|
- <i class="el-icon-delete" />
|
|
|
- </el-tag>
|
|
|
- <el-tag v-if="!disabled" class="image-reader-item-tag" @click.stop="onDownloadImage(index)">
|
|
|
- <i class="el-icon-download" />
|
|
|
- </el-tag>
|
|
|
- <el-tag v-if="!disabled" class="image-reader-item-tag draggable" @click.stop="onDownloadImage(index)">
|
|
|
- <i class="el-icon-rank" />
|
|
|
- </el-tag>
|
|
|
- <div :class="{ 'image-tip-visible': item.uid !== uid, 'image-tip': item.uid === uid }" v-text="tip" />
|
|
|
- </li>
|
|
|
+ <template v-if="isEllipsis">
|
|
|
+ <li class="image-reader-item image-reader-item--ellipsis">
|
|
|
+ <div
|
|
|
+ class="image-reader-item-thumb"
|
|
|
+ :style="getItemStyle(0)"
|
|
|
+ @click="clickHandler(fileList[0], 0)"
|
|
|
+ @mouseover="showTips(fileList[0], 0)"
|
|
|
+ @mouseout="hideTips(fileList[0], 0)"
|
|
|
+ >
|
|
|
+ <el-tag v-if="!disabled" class="image-reader-item-tag" @click.stop="onDeleteImage(0)">
|
|
|
+ <i class="el-icon-delete" />
|
|
|
+ </el-tag>
|
|
|
+ <el-tag v-if="!disabled" class="image-reader-item-tag" @click.stop="onDownloadImage(0)">
|
|
|
+ <i class="el-icon-download" />
|
|
|
+ </el-tag>
|
|
|
+ <el-tag v-if="!disabled" class="image-reader-item-tag draggable" @click.stop="onDownloadImage(0)">
|
|
|
+ <i class="el-icon-rank" />
|
|
|
+ </el-tag>
|
|
|
+ <div :class="{ 'image-tip-visible': fileList[0].uid !== uid, 'image-tip': fileList[0].uid === uid }" v-text="tip" />
|
|
|
+ </div>
|
|
|
+ <div v-if="ellipsisFileList.length" class="image-reader-item-filenames">
|
|
|
+ <div
|
|
|
+ v-for="(item, index) in ellipsisFileList"
|
|
|
+ :key="index + 1"
|
|
|
+ class="image-reader-item-filename-row"
|
|
|
+ @click.stop="clickHandler(item, index + 1)"
|
|
|
+ >
|
|
|
+ <span class="image-reader-item-filename" :title="getFileName(item)">{{ getFileName(item) }}</span>
|
|
|
+ <span v-if="!disabled" class="image-reader-item-filename-actions">
|
|
|
+ <el-tag class="image-reader-item-tag" @click.stop="onDeleteImage(index + 1)">
|
|
|
+ <i class="el-icon-delete" />
|
|
|
+ </el-tag>
|
|
|
+ <el-tag class="image-reader-item-tag" @click.stop="onDownloadImage(index + 1)">
|
|
|
+ <i class="el-icon-download" />
|
|
|
+ </el-tag>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </li>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <li
|
|
|
+ v-for="(item, index) in fileList"
|
|
|
+ :key="index"
|
|
|
+ class="image-reader-item"
|
|
|
+ :style="getItemStyle(index)"
|
|
|
+ @click="clickHandler(item, index)"
|
|
|
+ @mouseover="showTips(item, index)"
|
|
|
+ @mouseout="hideTips(item, index)"
|
|
|
+ >
|
|
|
+ <el-tag v-if="!disabled" class="image-reader-item-tag" @click.stop="onDeleteImage(index)">
|
|
|
+ <i class="el-icon-delete" />
|
|
|
+ </el-tag>
|
|
|
+ <el-tag v-if="!disabled" class="image-reader-item-tag" @click.stop="onDownloadImage(index)">
|
|
|
+ <i class="el-icon-download" />
|
|
|
+ </el-tag>
|
|
|
+ <el-tag v-if="!disabled" class="image-reader-item-tag draggable" @click.stop="onDownloadImage(index)">
|
|
|
+ <i class="el-icon-rank" />
|
|
|
+ </el-tag>
|
|
|
+ <div :class="{ 'image-tip-visible': item.uid !== uid, 'image-tip': item.uid === uid }" v-text="tip" />
|
|
|
+ </li>
|
|
|
+ </template>
|
|
|
</vue-draggable>
|
|
|
</ul>
|
|
|
<template v-if="!disabled && (isBuilder || fileList.length < limit || !limit)">
|
|
|
@@ -145,6 +180,10 @@ export default {
|
|
|
type: String,
|
|
|
default: 'attachment'
|
|
|
},
|
|
|
+ isEllipsis: { // 是否省略显示
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ },
|
|
|
store: {
|
|
|
type: String,
|
|
|
default: 'json',
|
|
|
@@ -194,6 +233,12 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
computed: {
|
|
|
+ draggableBindOptions () {
|
|
|
+ return {
|
|
|
+ ...this.draggableOptions,
|
|
|
+ disabled: this.isEllipsis || this.disabled
|
|
|
+ }
|
|
|
+ },
|
|
|
flieLimit () {
|
|
|
return this.$utils.isNotEmpty(this.limit) ? parseInt(this.limit) : null
|
|
|
},
|
|
|
@@ -218,6 +263,12 @@ export default {
|
|
|
'lineHeight': `${this.$utils.isEmpty(height) ? 100 : height}px`,
|
|
|
'display': 'inline'
|
|
|
}
|
|
|
+ },
|
|
|
+ ellipsisFileList () {
|
|
|
+ if (!this.isEllipsis || this.$utils.isEmpty(this.fileList) || this.fileList.length <= 1) {
|
|
|
+ return []
|
|
|
+ }
|
|
|
+ return this.fileList.slice(1)
|
|
|
}
|
|
|
},
|
|
|
watch: {
|
|
|
@@ -518,6 +569,21 @@ export default {
|
|
|
},
|
|
|
getImageUrl (id) {
|
|
|
return previewFile(id)
|
|
|
+ },
|
|
|
+ getFileName (item) {
|
|
|
+ const id = item[this.valueKey]
|
|
|
+ const source = this.cacheData[id] || item
|
|
|
+ return source[this.labelKey] || source.fileName || source.name || ''
|
|
|
+ },
|
|
|
+ getItemStyle (index) {
|
|
|
+ return {
|
|
|
+ 'backgroundImage': 'url(' + this.getImageUrl(this.fileList[index].id) + ')',
|
|
|
+ 'backgroundPosition': 'center center',
|
|
|
+ 'backgroundRepeat': 'no-repeat',
|
|
|
+ 'backgroundSize': 'cover',
|
|
|
+ 'width': `${this.$utils.isEmpty(this.width) ? 100 : this.width}px`,
|
|
|
+ 'height': `${this.$utils.isEmpty(this.height) ? 100 : this.height}px`
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -569,6 +635,58 @@ export default {
|
|
|
font-size: 12px;
|
|
|
width: 100%;
|
|
|
}
|
|
|
+ &--ellipsis {
|
|
|
+ float: none;
|
|
|
+ width: auto;
|
|
|
+ height: auto;
|
|
|
+ margin-bottom: 4px;
|
|
|
+ margin-right: 0;
|
|
|
+ padding-bottom: 0;
|
|
|
+ background: none;
|
|
|
+ box-shadow: none;
|
|
|
+ overflow: visible;
|
|
|
+ .image-reader-item-thumb {
|
|
|
+ position: relative;
|
|
|
+ background: #FFF;
|
|
|
+ box-shadow: 0 5px 20px rgba(197, 202, 213, .25);
|
|
|
+ border-radius: 4px;
|
|
|
+ overflow: hidden;
|
|
|
+ }
|
|
|
+ .image-reader-item-filenames {
|
|
|
+ margin-top: 4px;
|
|
|
+ }
|
|
|
+ .image-reader-item-filename-row {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ min-height: 28px;
|
|
|
+ margin-bottom: 2px;
|
|
|
+ padding: 2px 8px;
|
|
|
+ background: #f5f7fa;
|
|
|
+ border-radius: 2px;
|
|
|
+ cursor: pointer;
|
|
|
+ &:last-child {
|
|
|
+ margin-bottom: 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .image-reader-item-filename {
|
|
|
+ flex: 1;
|
|
|
+ font-size: 12px;
|
|
|
+ color: #606266;
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ white-space: nowrap;
|
|
|
+ line-height: 24px;
|
|
|
+ }
|
|
|
+ .image-reader-item-filename-actions {
|
|
|
+ flex-shrink: 0;
|
|
|
+ margin-left: 4px;
|
|
|
+ .image-reader-item-tag {
|
|
|
+ float: none;
|
|
|
+ display: inline-block;
|
|
|
+ margin-left: 2px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</style>
|