Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
memberTag-web
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
memberTag
memberTag-web
Commits
93cf0dc7
Commit
93cf0dc7
authored
Apr 16, 2019
by
caoyanzhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
实现标签的拖拽功能
parent
8b22ef1a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
8 deletions
+34
-8
memberGroupEdit.vue
src/view/memberGroup/memberGroupEdit.vue
+2
-2
tags-group-list.vue
src/view/memberGroup/tags-group-list.vue
+11
-0
tags-group.vue
src/view/memberGroup/tags-group.vue
+21
-6
No files found.
src/view/memberGroup/memberGroupEdit.vue
View file @
93cf0dc7
...
...
@@ -135,10 +135,10 @@ export default {
selectedTags
:
[
[
// {
// tagId:
1
,
// tagId:
'a'
,
// tagName: '有车一族',
// tagValue: '233',
// newTagVal: '',
// newTagVal: '
233
',
// tagParams: '',
// isActive: 0
// }
...
...
src/view/memberGroup/tags-group-list.vue
View file @
93cf0dc7
...
...
@@ -15,6 +15,7 @@
@
delTagsGroup=
"delTagsGroup"
@
changeTagsGroupRelation=
"changeTagsGroupRelation"
@
checkTagsGroup=
"checkTagsGroup"
@
dragTag=
"dragTag"
/>
<el-button
class=
"m-t-10 w-548 el-icon-plus color-blue add-group-btn"
v-show=
"selectedTagsData.length
<
3
"
@
click=
"addTagsGroup"
>
添加
...
...
@@ -59,6 +60,16 @@ export default {
tagsGroup
},
methods
:
{
// 拖拽标签
dragTag
(
data
)
{
let
{
fromTagsGroupIndex
,
fromTagIndex
,
toTagsGroupIndex
,
toTagIndex
}
=
{
...
data
};
let
tagData
=
this
.
selectedTagsData
[
fromTagsGroupIndex
].
splice
(
fromTagIndex
,
1
)[
0
];
if
(
this
.
selectedTagsData
[
toTagsGroupIndex
].
length
===
toTagIndex
)
{
this
.
selectedTagsData
[
toTagsGroupIndex
].
push
(
tagData
);
}
else
{
this
.
selectedTagsData
[
toTagsGroupIndex
].
splice
(
toTagsGroupIndex
,
1
,
this
.
selectedTagsData
[
toTagsGroupIndex
][
toTagIndex
],
tagData
);
}
},
// 添加一个标签组,最多只能有3个标签组
addTagsGroup
()
{
if
(
this
.
selectedTagsData
.
length
<
3
)
{
...
...
src/view/memberGroup/tags-group.vue
View file @
93cf0dc7
...
...
@@ -18,12 +18,14 @@
</el-dropdown>
<!--展示选中的标签-->
<div
class=
"tags-group__show"
>
<div
class=
"tags-group__tag"
v-for=
"(item, index) in tagsData"
:key=
"item.tagId"
>
<span>
{{
item
.
tagName
}}
</span>
<span
class=
"tags-group__tag-name"
>
【选择:
{{
item
.
newTagVal
}}
】
</span>
<i
class=
"el-icon-edit"
@
click=
"editTags(index)"
></i>
<i
class=
"el-icon-error"
@
click=
"delTags(index)"
></i>
</div>
<draggable
:options=
"
{ group: 'article' }" style="height: 100%" @end="dragTag" :data-index="tagsGroupIndex">
<div
class=
"tags-group__tag"
v-for=
"(item, index) in tagsData"
:key=
"item.tagId"
>
<span>
{{
item
.
tagName
}}
</span>
<span
class=
"tags-group__tag-name"
>
【选择:
{{
item
.
newTagVal
}}
】
</span>
<i
class=
"el-icon-edit"
@
click=
"editTags(index)"
></i>
<i
class=
"el-icon-error"
@
click=
"delTags(index)"
></i>
</div>
</draggable>
</div>
</div>
<!--标签组之间的关系-->
...
...
@@ -52,8 +54,12 @@
* @editTags 编辑一个标签,将会emit(editTags事件, {tagsGroupIndex: 当前标签组的索引, tagIndex: 当前标签的索引})
* @changeTagsGroupRelation 切换与下一组标签之间的关系,将会emit(changeTagGroupRelation事件)
* */
import
draggable
from
'vuedraggable'
;
export
default
{
name
:
'tags-group'
,
components
:
{
draggable
},
props
:
{
// 一组标签(选中的)的数据
tagsData
:
Array
,
...
...
@@ -112,6 +118,15 @@ export default {
this
.
$emit
(
'checkTagsGroup'
,
{
tagsGroupIndex
:
this
.
tagsGroupIndex
});
},
// 拖拽标签
dragTag
(
evt
)
{
this
.
$emit
(
'dragTag'
,
{
fromTagIndex
:
evt
.
oldIndex
,
toTagIndex
:
evt
.
newIndex
,
fromTagsGroupIndex
:
parseInt
(
evt
.
from
.
getAttribute
(
'data-index'
)),
toTagsGroupIndex
:
parseInt
(
evt
.
to
.
getAttribute
(
'data-index'
))
});
}
}
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment