Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
sun
Project
Project
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
钟尚武
sun
Commits
a94c49e4
Commit
a94c49e4
authored
Dec 01, 2018
by
Davve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善tag
parent
fc562549
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
31 deletions
+19
-31
tag.py
api/tag.py
+5
-5
TagDetail.vue
vu/src/views/tag/components/TagDetail.vue
+14
-26
No files found.
api/tag.py
View file @
a94c49e4
...
...
@@ -3,6 +3,7 @@
# __author__ = "chenwei"
# Date: 2018/11/17
import
json
from
utils.base
import
APIView
...
...
@@ -49,15 +50,14 @@ class TagUpdateOrCreateView(APIView):
def
post
(
self
,
request
):
id
=
request
.
POST
.
get
(
'id'
)
print
(
type
(
request
.
POST
.
get
(
'down_tags'
)))
down_tags
=
list
(
set
(
request
.
POST
.
get
(
'down_tags'
)
.
split
(
','
)))
up_tags
=
list
(
set
(
request
.
POST
.
get
(
'up_tags'
)
.
split
(
','
)))
down_tags
=
list
(
set
(
map
(
lambda
x
:
x
.
split
(
":"
)[
0
],
json
.
loads
((
request
.
POST
.
get
(
'down_tags'
,
'[]'
))))))
up_tags
=
list
(
set
(
map
(
lambda
x
:
x
.
split
(
":"
)[
0
],
json
.
loads
((
request
.
POST
.
get
(
'up_tags'
,
'[]'
))))))
data
=
{
'name'
:
request
.
POST
.
get
(
'name'
),
'description'
:
request
.
POST
.
get
(
'description'
),
'down_tags'
:
list
(
filter
(
lambda
x
:
x
,
down_tags
))
,
'up_tags'
:
list
(
filter
(
lambda
x
:
x
,
up_tags
))
,
'down_tags'
:
down_tags
,
'up_tags'
:
up_tags
,
}
try
:
self
.
rpc
[
'venus/sun/tag/edit'
](
id
=
id
,
data
=
data
)
.
unwrap
()
...
...
vu/src/views/tag/components/TagDetail.vue
View file @
a94c49e4
...
...
@@ -42,11 +42,11 @@
<el-row>
<el-col
:span=
"12"
>
<el-form-item
label-width=
"75px"
label=
"上级标签:"
class=
"postInfo-container-item"
>
<el-select
v-model=
"
postForm.
up_tags"
:remote-method=
"getRemoteTagList"
filterable
remote
multiple
<el-select
v-model=
"up_tags"
:remote-method=
"getRemoteTagList"
filterable
remote
multiple
value-key=
"id"
placeholder=
"搜索标签"
style=
"width: 70%"
>
<el-option
v-for=
"(item,index) in TagListOptions"
:key=
"item+index"
:label=
"item
.name
"
:value=
"item
.id
"
/>
<el-option
v-for=
"(item,index) in TagListOptions"
:key=
"item+index"
:label=
"item"
:value=
"item"
/>
</el-select>
</el-form-item>
</el-col>
...
...
@@ -54,7 +54,7 @@
<el-form-item
label-width=
"75px"
label=
"下级标签:"
class=
"postInfo-container-item"
>
<el-select
v-model=
"
postForm.
down_tags"
v-model=
"down_tags"
:remote-method=
"getRemoteTagList"
multiple
filterable
...
...
@@ -65,8 +65,8 @@
:loading=
"loading"
value-key=
"id"
>
<el-option
v-for=
"(item, index) in TagListOptions"
:key=
"item+index"
:label=
"item
.name
"
:value=
"item
.id
"
/>
<el-option
v-for=
"(item, index) in TagListOptions"
:key=
"item+index"
:label=
"item"
:value=
"item"
/>
</el-select>
</el-form-item>
</el-col>
...
...
@@ -145,6 +145,8 @@
postForm
:
Object
.
assign
({},
defaultForm
),
loading
:
false
,
TagListOptions
:
[],
up_tags
:
[],
down_tags
:
[],
rules
:
{
name
:
[{
validator
:
validateRequire
,
trigger
:
'blur'
}],
},
...
...
@@ -175,18 +177,12 @@
fetchTagDetail
(
id
).
then
(
response
=>
{
// select 回填数据处理,后期再进行优化
let
rep
=
response
.
data
.
data
.
data
;
let
up_temp
=
[]
let
down_temp
=
[]
for
(
let
i
=
0
;
i
<
rep
.
up_tags
.
length
;
i
++
)
{
up_temp
.
push
(
rep
.
up_tags
[
i
][
'name'
]);
this
.
temparray
[
'up_tags'
].
push
(
rep
.
up_tags
[
i
])
this
.
up_tags
.
push
(
rep
.
up_tags
[
i
][
'id'
]
+
':'
+
rep
.
up_tags
[
i
][
'name'
])
}
for
(
let
i
=
0
;
i
<
rep
.
down_tags
.
length
;
i
++
)
{
down_temp
.
push
(
rep
.
down_tags
[
i
][
'name'
]);
this
.
temparray
[
'down_tags'
].
push
(
rep
.
down_tags
[
i
])
this
.
down_tags
.
push
(
rep
.
down_tags
[
i
][
'id'
]
+
':'
+
rep
.
down_tags
[
i
][
'name'
])
}
rep
.
down_tags
=
down_temp
rep
.
up_tags
=
up_temp
this
.
postForm
=
rep
}).
catch
(
err
=>
{
console
.
log
(
err
)
...
...
@@ -196,19 +192,10 @@
this
.
$refs
.
postForm
.
validate
(
valid
=>
{
if
(
valid
)
{
this
.
loading
=
true
;
if
(
this
.
isEdit
)
{
this
.
postForm
.
up_tags
=
Assembledata
(
this
.
temparray
[
'up_tags'
],
this
.
postForm
.
up_tags
);
this
.
postForm
.
down_tags
=
Assembledata
(
this
.
temparray
[
'down_tags'
],
this
.
postForm
.
down_tags
);
}
else
{
this
.
postForm
.
up_tags
=
this
.
postForm
.
up_tags
.
join
(
','
)
this
.
postForm
.
down_tags
=
this
.
postForm
.
down_tags
.
join
(
','
)
}
let
flag
=
false
;
let
up_tag_arrays
=
removeNull
(
this
.
postForm
.
up_tags
.
split
(
','
))
let
down_tags_arrays
=
removeNull
(
this
.
postForm
.
down_tags
.
split
(
','
))
for
(
let
i
=
0
;
i
<
up_tag_arrays
.
length
;
i
++
)
{
if
(
isInArray
(
down_tags_arrays
,
up_tag_arrays
[
i
]))
{
for
(
let
i
=
0
;
i
<
this
.
up_tags
.
length
;
i
++
)
{
if
(
isInArray
(
this
.
down_tags
,
this
.
up_tags
[
i
]))
{
this
.
$message
.
error
(
'上下级标签不能存相同标签'
)
this
.
postForm
.
up_tags
=
[];
this
.
postForm
.
down_tags
=
[];
...
...
@@ -219,7 +206,8 @@
if
(
flag
)
{
return
false
;
}
this
.
postForm
.
up_tags
=
JSON
.
stringify
(
this
.
up_tags
)
this
.
postForm
.
down_tags
=
JSON
.
stringify
(
this
.
down_tags
);
CreateTag
(
this
.
postForm
).
then
(
response
=>
{
this
.
$notify
({
title
:
'成功'
,
...
...
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