完善分配标签的功能
This commit is contained in:
parent
3620763129
commit
341f8221f2
@ -32,12 +32,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div v-if="item.tags && item.tags.length > 0 && !public">
|
<div v-if="item.tags && item.tags.length > 0 && !public">
|
||||||
<div v-if="pc">
|
<div v-if="pc">
|
||||||
<svg-icon v-if="grid" class="pc grid icon-tag" icon-class="tag2" :style="{left: 14 * index -9 + 'px', color: tag.color}" v-for="(tag,index) in item.tags.slice(0, 7)" :key="index"/>
|
<svg-icon v-if="grid" class="pc grid icon-tag" icon-class="tag2" :style="{left: 14 * index + 'px', color: tag.color}" v-for="(tag,index) in item.tags.slice(0, 3)" :key="tag.tagId"/>
|
||||||
<svg-icon v-else class="pc list icon-tag" icon-class="tag2" :style="{left: 14 * index + 3 + 'px', color: tag.color}" v-for="(tag,index) in item.tags.slice(0, 5)" :key="index"/>
|
<!-- 列表模式下只能显示一个标签 -->
|
||||||
|
<svg-icon v-else class="pc list icon-tag" icon-class="tag2" :style="{color: tag.color}" v-for="tag in item.tags.slice(0, 1)" :key="tag.tagId"/>
|
||||||
</div>
|
</div>
|
||||||
<div v-else>
|
<div v-else>
|
||||||
<svg-icon v-if="grid" class="mobile grid icon-tag" icon-class="tag2" :style="{left: 1 * index + 'rem', color: tag.color}" v-for="(tag,index) in item.tags.slice(0, 5)" :key="index"/>
|
<svg-icon v-if="grid" class="mobile grid icon-tag" icon-class="tag2" :style="{left: 1 * index + 'rem', color: tag.color}" v-for="(tag,index) in item.tags.slice(0, 3)" :key="tag.tagId"/>
|
||||||
<svg-icon v-else class="mobile list icon-tag" icon-class="tag2" :style="{left: 1 * index + 'rem', color: tag.color}" v-for="(tag,index) in item.tags.slice(0, 3)" :key="index"/>
|
<svg-icon v-else class="mobile list icon-tag" icon-class="tag2" :style="{color: tag.color}" v-for="tag in item.tags.slice(0, 1)" :key="tag.tagId"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="item.ossFolder && !public">
|
<div v-if="item.ossFolder && !public">
|
||||||
@ -51,7 +52,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<svg-icon v-if="item.isFolder" icon-class="folder"/>
|
<svg-icon v-if="item.isFolder" icon-class="folder"/>
|
||||||
<div v-else-if="item.contentType.indexOf('video') > -1">
|
<div v-else-if="item.contentType && item.contentType.indexOf('video') > -1">
|
||||||
<div v-if="item.mediaCover === undefined || item.mediaCover === 'true'">
|
<div v-if="item.mediaCover === undefined || item.mediaCover === 'true'">
|
||||||
<div v-if="grid && pc" class="grid-play-icon">
|
<div v-if="grid && pc" class="grid-play-icon">
|
||||||
<svg-icon icon-class="play1"/>
|
<svg-icon icon-class="play1"/>
|
||||||
@ -71,7 +72,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<svg-icon v-else icon-class="video"/>
|
<svg-icon v-else icon-class="video"/>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="item.contentType.indexOf('audio') > -1">
|
<div v-else-if="item.contentType && item.contentType.indexOf('audio') > -1">
|
||||||
<div v-if="item.music !== undefined">
|
<div v-if="item.music !== undefined">
|
||||||
<div v-if="item.music.name !== null">
|
<div v-if="item.music.name !== null">
|
||||||
<el-image v-if="grid" :style="{'height':details?'110px':(gridWidth-35) + 'px'}" fit="contain"
|
<el-image v-if="grid" :style="{'height':details?'110px':(gridWidth-35) + 'px'}" fit="contain"
|
||||||
@ -90,7 +91,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<svg-icon v-else icon-class="audio"/>
|
<svg-icon v-else icon-class="audio"/>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="item.contentType.startsWith('image')">
|
<div v-else-if="item.contentType && item.contentType.startsWith('image')">
|
||||||
<el-image v-if="grid || grid === 'details'" :style="{'height':details?'110px':(gridWidth-35) + 'px'}"
|
<el-image v-if="grid || grid === 'details'" :style="{'height':details?'110px':(gridWidth-35) + 'px'}"
|
||||||
fit="contain" :src="item.fileId ? (imageUrl+item.fileId) : (imageUrl+item.id)">
|
fit="contain" :src="item.fileId ? (imageUrl+item.fileId) : (imageUrl+item.id)">
|
||||||
<div slot="error" class="image-slot">
|
<div slot="error" class="image-slot">
|
||||||
@ -254,27 +255,27 @@ export default {
|
|||||||
.pc.grid.icon-tag {
|
.pc.grid.icon-tag {
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
left: 0;
|
left: 0;
|
||||||
bottom: -10px;
|
bottom: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mobile.grid.icon-tag {
|
.mobile.grid.icon-tag {
|
||||||
width: 1rem;
|
width: 1rem;
|
||||||
height: 1rem;
|
height: 1rem;
|
||||||
left: 0;
|
left: 0;
|
||||||
bottom: 1.6rem;
|
bottom: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pc.list.icon-tag {
|
.pc.list.icon-tag {
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
left: 3px;
|
left: 10px;
|
||||||
bottom: 3px;
|
bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mobile.list.icon-tag {
|
.mobile.list.icon-tag {
|
||||||
width: 1rem;
|
width: 1rem;
|
||||||
height: 1rem;
|
height: 1rem;
|
||||||
left: 0;
|
left: 0.5rem;
|
||||||
bottom: 0;
|
bottom: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.oss-folder {
|
.oss-folder {
|
||||||
|
|||||||
@ -807,7 +807,7 @@
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<tag-dialog :fileList.sync="tagDialogObjectList"
|
<tag-dialog :fileList="tagDialogObjectList"
|
||||||
:status.sync="tagDialogVisible" @onSuccess="allocateTagSuccess"/>
|
:status.sync="tagDialogVisible" @onSuccess="allocateTagSuccess"/>
|
||||||
<share-dialog
|
<share-dialog
|
||||||
:file.sync="shareDialogObject"
|
:file.sync="shareDialogObject"
|
||||||
@ -3740,7 +3740,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
allocateTag() {
|
allocateTag() {
|
||||||
this.tagDialogObjectList = this.$refs.fileListTable.tableSelectData;
|
// 将this.$refs.fileListTable.tableSelectData拷贝给tagDialogObjectList而不是赋值
|
||||||
|
this.tagDialogObjectList = JSON.parse(
|
||||||
|
JSON.stringify(this.$refs.fileListTable.tableSelectData)
|
||||||
|
);
|
||||||
this.tagDialogVisible = true
|
this.tagDialogVisible = true
|
||||||
},
|
},
|
||||||
allocateTagSuccess() {
|
allocateTagSuccess() {
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
v-for="tag in tags"
|
v-for="tag in tags"
|
||||||
closable
|
closable
|
||||||
:disable-transitions="false"
|
:disable-transitions="false"
|
||||||
@close="handleClose(tag.id)">
|
@close="handleClose(tag.name)">
|
||||||
|
|
||||||
<el-popover
|
<el-popover
|
||||||
placement="bottom"
|
placement="bottom"
|
||||||
@ -33,6 +33,19 @@
|
|||||||
>
|
>
|
||||||
</el-input>
|
</el-input>
|
||||||
<el-button v-else class="button-new-tag" size="small" @click="showInput">+ 新标签</el-button>
|
<el-button v-else class="button-new-tag" size="small" @click="showInput">+ 新标签</el-button>
|
||||||
|
|
||||||
|
<div class="tag-list">
|
||||||
|
<p>现有标签: </p>
|
||||||
|
<el-button
|
||||||
|
size="small"
|
||||||
|
:key="tag.name"
|
||||||
|
v-for="tag in existingTags"
|
||||||
|
@click="addTag(tag)">
|
||||||
|
<svg-icon :style="{ color: tag.color, fontSize: '14px' }" icon-class="tag2"></svg-icon>
|
||||||
|
{{tag.name}}
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div slot="footer" class="dialog-footer">
|
<div slot="footer" class="dialog-footer">
|
||||||
<el-button size="small" type="primary" @click="submitTag" v-loading="saveLoading">保存
|
<el-button size="small" type="primary" @click="submitTag" v-loading="saveLoading">保存
|
||||||
@ -44,7 +57,8 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
import api from '@/api/file-api'
|
import fileApi from '@/api/file-api'
|
||||||
|
import tagApi from '@/api/tag'
|
||||||
import { Sketch } from 'vue-color'
|
import { Sketch } from 'vue-color'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -69,6 +83,8 @@ export default {
|
|||||||
inputVisible: false,
|
inputVisible: false,
|
||||||
inputValue: '',
|
inputValue: '',
|
||||||
tags: [],
|
tags: [],
|
||||||
|
existingTags: [],
|
||||||
|
tagList: [],
|
||||||
defaultTagColor: '#f56c6c',
|
defaultTagColor: '#f56c6c',
|
||||||
saveLoading: false,
|
saveLoading: false,
|
||||||
colors: {
|
colors: {
|
||||||
@ -99,14 +115,34 @@ export default {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
this.showName = this.fileList.length + '项目'
|
|
||||||
|
// 加载已有标签列表
|
||||||
|
tagApi.tagList({userId: this.$store.state.user.userId,}).then(res => {
|
||||||
|
this.tagList = res.data
|
||||||
|
this.updateExistingTags()
|
||||||
|
})
|
||||||
|
|
||||||
|
if (this.fileList.length === 1) {
|
||||||
|
this.showName = this.fileList[0].name
|
||||||
|
} else {
|
||||||
|
this.showName = this.fileList.length + '项目'
|
||||||
|
}
|
||||||
this.tagDialogVisible = true
|
this.tagDialogVisible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
handleClose(tag) {
|
updateExistingTags() {
|
||||||
this.tags.splice(this.tags.indexOf(tag), 1);
|
this.existingTags = this.tagList.filter(item => {
|
||||||
|
return !this.tags.some(tag => tag.name === item.name)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
handleClose(tagName) {
|
||||||
|
// 删除tags, 找出tags中的tag.name, 删除
|
||||||
|
// 找出tags中的tag.name的索引
|
||||||
|
let index = this.tags.findIndex(item => item.name === tagName)
|
||||||
|
this.tags.splice(index, 1)
|
||||||
|
this.updateExistingTags()
|
||||||
},
|
},
|
||||||
showInput() {
|
showInput() {
|
||||||
this.inputVisible = true;
|
this.inputVisible = true;
|
||||||
@ -128,6 +164,11 @@ export default {
|
|||||||
this.inputVisible = false;
|
this.inputVisible = false;
|
||||||
this.inputValue = '';
|
this.inputValue = '';
|
||||||
},
|
},
|
||||||
|
addTag(tag) {
|
||||||
|
// 是否有相同的标签
|
||||||
|
this.tags.push({ name: tag.name, color: tag.color });
|
||||||
|
this.updateExistingTags()
|
||||||
|
},
|
||||||
tagDialogClose() {
|
tagDialogClose() {
|
||||||
this.$emit('update:status', this.tagDialogVisible)
|
this.$emit('update:status', this.tagDialogVisible)
|
||||||
},
|
},
|
||||||
@ -135,7 +176,7 @@ export default {
|
|||||||
this.saveLoading = true
|
this.saveLoading = true
|
||||||
// 提取出文件id
|
// 提取出文件id
|
||||||
const fileIdList = this.fileList.map(item => item.id)
|
const fileIdList = this.fileList.map(item => item.id)
|
||||||
api.setTags({fileIds: fileIdList}, this.tags).then(() => {
|
fileApi.setTags({fileIds: fileIdList}, this.tags).then(() => {
|
||||||
this.saveLoading = false
|
this.saveLoading = false
|
||||||
this.$message.success('保存成功');
|
this.$message.success('保存成功');
|
||||||
this.$emit('onSuccess')
|
this.$emit('onSuccess')
|
||||||
@ -167,21 +208,21 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.el-tag {
|
.el-tag {
|
||||||
margin-left: 10px;
|
margin-left: 5px;
|
||||||
margin-top: 10px;
|
margin-top: 5px;
|
||||||
}
|
}
|
||||||
.button-new-tag {
|
.button-new-tag {
|
||||||
margin-top: 10px;
|
margin-top: 5px;
|
||||||
margin-left: 10px;
|
margin-left: 5px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
line-height: 30px;
|
line-height: 30px;
|
||||||
padding-top: 0;
|
padding-top: 0;
|
||||||
padding-bottom: 0;
|
padding-bottom: 0;
|
||||||
}
|
}
|
||||||
.input-new-tag {
|
.input-new-tag {
|
||||||
margin-top: 10px;
|
margin-top: 5px;
|
||||||
|
margin-left: 5px;
|
||||||
width: 90px;
|
width: 90px;
|
||||||
margin-left: 10px;
|
|
||||||
vertical-align: bottom;
|
vertical-align: bottom;
|
||||||
}
|
}
|
||||||
.button-tab-icon {
|
.button-tab-icon {
|
||||||
@ -194,6 +235,20 @@ export default {
|
|||||||
width: 25px !important;
|
width: 25px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tag-list {
|
||||||
|
p {
|
||||||
|
margin-top: 15px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
.el-button {
|
||||||
|
margin-left: 5px;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
.el-button+.el-button {
|
||||||
|
margin-left: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user