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
1
Merge Requests
1
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
alpha
sun
Commits
a94c49e4
Commit
a94c49e4
authored
6 years ago
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 @@
...
@@ -3,6 +3,7 @@
# __author__ = "chenwei"
# __author__ = "chenwei"
# Date: 2018/11/17
# Date: 2018/11/17
import
json
from
utils.base
import
APIView
from
utils.base
import
APIView
...
@@ -49,15 +50,14 @@ class TagUpdateOrCreateView(APIView):
...
@@ -49,15 +50,14 @@ class TagUpdateOrCreateView(APIView):
def
post
(
self
,
request
):
def
post
(
self
,
request
):
id
=
request
.
POST
.
get
(
'id'
)
id
=
request
.
POST
.
get
(
'id'
)
print
(
type
(
request
.
POST
.
get
(
'down_tags'
)))
down_tags
=
list
(
set
(
map
(
lambda
x
:
x
.
split
(
":"
)[
0
],
json
.
loads
((
request
.
POST
.
get
(
'down_tags'
,
'[]'
))))))
down_tags
=
list
(
set
(
request
.
POST
.
get
(
'down_tags'
)
.
split
(
','
)))
up_tags
=
list
(
set
(
map
(
lambda
x
:
x
.
split
(
":"
)[
0
],
json
.
loads
((
request
.
POST
.
get
(
'up_tags'
,
'[]'
))))))
up_tags
=
list
(
set
(
request
.
POST
.
get
(
'up_tags'
)
.
split
(
','
)))
data
=
{
data
=
{
'name'
:
request
.
POST
.
get
(
'name'
),
'name'
:
request
.
POST
.
get
(
'name'
),
'description'
:
request
.
POST
.
get
(
'description'
),
'description'
:
request
.
POST
.
get
(
'description'
),
'down_tags'
:
list
(
filter
(
lambda
x
:
x
,
down_tags
))
,
'down_tags'
:
down_tags
,
'up_tags'
:
list
(
filter
(
lambda
x
:
x
,
up_tags
))
,
'up_tags'
:
up_tags
,
}
}
try
:
try
:
self
.
rpc
[
'venus/sun/tag/edit'
](
id
=
id
,
data
=
data
)
.
unwrap
()
self
.
rpc
[
'venus/sun/tag/edit'
](
id
=
id
,
data
=
data
)
.
unwrap
()
...
...
This diff is collapsed.
Click to expand it.
vu/src/views/tag/components/TagDetail.vue
View file @
a94c49e4
...
@@ -42,11 +42,11 @@
...
@@ -42,11 +42,11 @@
<el-row>
<el-row>
<el-col
:span=
"12"
>
<el-col
:span=
"12"
>
<el-form-item
label-width=
"75px"
label=
"上级标签:"
class=
"postInfo-container-item"
>
<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"
value-key=
"id"
placeholder=
"搜索标签"
style=
"width: 70%"
>
placeholder=
"搜索标签"
style=
"width: 70%"
>
<el-option
v-for=
"(item,index) in TagListOptions"
:key=
"item+index"
:label=
"item
.name
"
<el-option
v-for=
"(item,index) in TagListOptions"
:key=
"item+index"
:label=
"item"
:value=
"item
.id
"
/>
:value=
"item"
/>
</el-select>
</el-select>
</el-form-item>
</el-form-item>
</el-col>
</el-col>
...
@@ -54,7 +54,7 @@
...
@@ -54,7 +54,7 @@
<el-form-item
label-width=
"75px"
label=
"下级标签:"
class=
"postInfo-container-item"
>
<el-form-item
label-width=
"75px"
label=
"下级标签:"
class=
"postInfo-container-item"
>
<el-select
<el-select
v-model=
"
postForm.
down_tags"
v-model=
"down_tags"
:remote-method=
"getRemoteTagList"
:remote-method=
"getRemoteTagList"
multiple
multiple
filterable
filterable
...
@@ -65,8 +65,8 @@
...
@@ -65,8 +65,8 @@
:loading=
"loading"
:loading=
"loading"
value-key=
"id"
value-key=
"id"
>
>
<el-option
v-for=
"(item, index) in TagListOptions"
:key=
"item+index"
:label=
"item
.name
"
<el-option
v-for=
"(item, index) in TagListOptions"
:key=
"item+index"
:label=
"item"
:value=
"item
.id
"
/>
:value=
"item"
/>
</el-select>
</el-select>
</el-form-item>
</el-form-item>
</el-col>
</el-col>
...
@@ -145,6 +145,8 @@
...
@@ -145,6 +145,8 @@
postForm
:
Object
.
assign
({},
defaultForm
),
postForm
:
Object
.
assign
({},
defaultForm
),
loading
:
false
,
loading
:
false
,
TagListOptions
:
[],
TagListOptions
:
[],
up_tags
:
[],
down_tags
:
[],
rules
:
{
rules
:
{
name
:
[{
validator
:
validateRequire
,
trigger
:
'blur'
}],
name
:
[{
validator
:
validateRequire
,
trigger
:
'blur'
}],
},
},
...
@@ -175,18 +177,12 @@
...
@@ -175,18 +177,12 @@
fetchTagDetail
(
id
).
then
(
response
=>
{
fetchTagDetail
(
id
).
then
(
response
=>
{
// select 回填数据处理,后期再进行优化
// select 回填数据处理,后期再进行优化
let
rep
=
response
.
data
.
data
.
data
;
let
rep
=
response
.
data
.
data
.
data
;
let
up_temp
=
[]
let
down_temp
=
[]
for
(
let
i
=
0
;
i
<
rep
.
up_tags
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
rep
.
up_tags
.
length
;
i
++
)
{
up_temp
.
push
(
rep
.
up_tags
[
i
][
'name'
]);
this
.
up_tags
.
push
(
rep
.
up_tags
[
i
][
'id'
]
+
':'
+
rep
.
up_tags
[
i
][
'name'
])
this
.
temparray
[
'up_tags'
].
push
(
rep
.
up_tags
[
i
])
}
}
for
(
let
i
=
0
;
i
<
rep
.
down_tags
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
rep
.
down_tags
.
length
;
i
++
)
{
down_temp
.
push
(
rep
.
down_tags
[
i
][
'name'
]);
this
.
down_tags
.
push
(
rep
.
down_tags
[
i
][
'id'
]
+
':'
+
rep
.
down_tags
[
i
][
'name'
])
this
.
temparray
[
'down_tags'
].
push
(
rep
.
down_tags
[
i
])
}
}
rep
.
down_tags
=
down_temp
rep
.
up_tags
=
up_temp
this
.
postForm
=
rep
this
.
postForm
=
rep
}).
catch
(
err
=>
{
}).
catch
(
err
=>
{
console
.
log
(
err
)
console
.
log
(
err
)
...
@@ -196,19 +192,10 @@
...
@@ -196,19 +192,10 @@
this
.
$refs
.
postForm
.
validate
(
valid
=>
{
this
.
$refs
.
postForm
.
validate
(
valid
=>
{
if
(
valid
)
{
if
(
valid
)
{
this
.
loading
=
true
;
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
flag
=
false
;
let
up_tag_arrays
=
removeNull
(
this
.
postForm
.
up_tags
.
split
(
','
))
for
(
let
i
=
0
;
i
<
this
.
up_tags
.
length
;
i
++
)
{
let
down_tags_arrays
=
removeNull
(
this
.
postForm
.
down_tags
.
split
(
','
))
if
(
isInArray
(
this
.
down_tags
,
this
.
up_tags
[
i
]))
{
for
(
let
i
=
0
;
i
<
up_tag_arrays
.
length
;
i
++
)
{
if
(
isInArray
(
down_tags_arrays
,
up_tag_arrays
[
i
]))
{
this
.
$message
.
error
(
'上下级标签不能存相同标签'
)
this
.
$message
.
error
(
'上下级标签不能存相同标签'
)
this
.
postForm
.
up_tags
=
[];
this
.
postForm
.
up_tags
=
[];
this
.
postForm
.
down_tags
=
[];
this
.
postForm
.
down_tags
=
[];
...
@@ -219,7 +206,8 @@
...
@@ -219,7 +206,8 @@
if
(
flag
)
{
if
(
flag
)
{
return
false
;
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
=>
{
CreateTag
(
this
.
postForm
).
then
(
response
=>
{
this
.
$notify
({
this
.
$notify
({
title
:
'成功'
,
title
:
'成功'
,
...
...
This diff is collapsed.
Click to expand it.
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