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
a7b59391
Commit
a7b59391
authored
Nov 21, 2018
by
Davve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成明星创建逻辑
parent
208b2164
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
178 additions
and
97 deletions
+178
-97
group.py
api/group.py
+27
-1
star.py
api/star.py
+30
-0
urls.py
api/urls.py
+3
-0
group.js
vu/src/api/group.js
+8
-0
star.js
vu/src/api/star.js
+23
-0
PickDetail.vue
vu/src/views/pick/components/PickDetail.vue
+0
-1
StarDetail.vue
vu/src/views/star/components/StarDetail.vue
+87
-95
No files found.
api/group.py
View file @
a7b59391
...
...
@@ -13,7 +13,6 @@ class GroupListView(APIView):
filters
=
self
.
handle_filter
(
request
.
GET
.
get
(
'filter'
,
""
))
try
:
data
=
self
.
rpc
[
'venus/community/group/list'
](
filters
=
filters
,
offset
=
offset
,
count
=
count
)
.
unwrap
()
print
(
data
,
'----------------'
)
except
Exception
as
e
:
raise
e
return
data
...
...
@@ -35,3 +34,29 @@ class GroupListView(APIView):
return
{
"message"
:
"更新成功"
}
class
GroupUpdateOrCreate
(
APIView
):
def
get
(
self
,
request
):
id
=
request
.
GET
.
get
(
'id'
)
try
:
data
=
self
.
rpc
[
'venus/community/group/detail'
](
id
=
id
)
.
unwrap
()
except
Exception
as
e
:
data
=
[{
'id'
:
1
,
'name'
:
'我是一个小组名称'
,
'description'
:
'小组简介简介'
,
'user_nums'
:
22
,
'topic_nums'
:
32
,
'user'
:
{
'id'
:
22
,
'name'
:
'真好'
,
}
},]
return
{
'total'
:
20
,
'data'
:
data
}
def
post
(
self
,
request
):
pass
\ No newline at end of file
api/star.py
View file @
a7b59391
...
...
@@ -3,6 +3,7 @@
# __author__ = "chenwei"
# Date: 2018/11/15
import
json
from
utils.base
import
APIView
...
...
@@ -16,3 +17,31 @@ class StarListView(APIView):
except
Exception
as
e
:
raise
e
return
data
class
StarUpdateOrCreate
(
APIView
):
def
get
(
self
,
request
):
id
=
request
.
GET
.
get
(
'id'
)
try
:
data
=
self
.
rpc
[
'venus/community/star/detail'
](
id
=
id
)
.
unwrap
()
except
Exception
as
e
:
raise
e
return
{
'data'
:
data
}
def
post
(
self
,
request
):
data
=
{
'gender'
:
request
.
POST
.
get
(
'gender'
),
'region'
:
request
.
POST
.
get
(
'region'
),
'is_online'
:
request
.
POST
.
get
(
'is_online'
),
'description'
:
request
.
POST
.
get
(
'description'
),
'avatar'
:
request
.
POST
.
get
(
'avatar'
)[:
-
2
],
'group_ids'
:
list
(
set
(
json
.
loads
(
request
.
POST
.
get
(
'group_ids'
,
[])))),
}
try
:
self
.
rpc
[
'venus/community/star/create'
](
data
=
data
)
.
unwrap
()
except
Exception
as
e
:
raise
e
return
{
'message'
:
'更新成功'
}
\ No newline at end of file
api/urls.py
View file @
a7b59391
...
...
@@ -34,12 +34,15 @@ urlpatterns = [
# group相关
url
(
r'group/list$'
,
GroupListView
.
as_view
()),
url
(
r'group/update$'
,
GroupListView
.
as_view
()),
url
(
r'group/detail'
,
GroupUpdateOrCreate
.
as_view
()),
# topic相关
url
(
r'topic/list$'
,
TopicListView
.
as_view
()),
# star相关
url
(
r'star/list$'
,
StarListView
.
as_view
()),
url
(
r'star/create'
,
StarUpdateOrCreate
.
as_view
()),
url
(
r'star/detail'
,
StarUpdateOrCreate
.
as_view
()),
# push相关
url
(
r'push/list$'
,
PushListView
.
as_view
()),
...
...
vu/src/api/group.js
View file @
a7b59391
...
...
@@ -15,3 +15,11 @@ export function OffLineOrOnLine(data) {
data
})
}
export
function
GroupDetail
(
id
)
{
return
request
({
url
:
'/api/group/detail'
,
method
:
'get'
,
params
:
{
id
}
})
}
vu/src/api/star.js
View file @
a7b59391
...
...
@@ -8,6 +8,21 @@ export function fetchList(query) {
})
}
export
function
starCreate
(
data
)
{
return
request
({
url
:
'/api/star/create'
,
method
:
'post'
,
data
})
}
export
function
starDetail
(
id
)
{
return
request
({
url
:
'/api/star/detail'
,
method
:
'get'
,
params
:
{
id
}
})
}
export
function
OffLineOrOnLine
(
data
)
{
return
request
({
...
...
@@ -16,3 +31,11 @@ export function OffLineOrOnLine(data) {
data
})
}
export
function
fetchStarRelatedGroup
(
id
)
{
return
request
({
url
:
'/api/star/star_related_group_info'
,
method
:
'get'
,
params
:
{
id
}
})
}
vu/src/views/pick/components/PickDetail.vue
View file @
a7b59391
...
...
@@ -241,7 +241,6 @@
this
.
postForm
.
region
=
Assembledata
(
this
.
temparray
[
'region'
],
this
.
postForm
.
region
);
this
.
postForm
.
pick_group
=
Assembledata
(
this
.
temparray
[
'pick_group'
],
this
.
postForm
.
pick_group
);
}
else
{
console
.
log
(
this
.
postForm
.
region
)
this
.
postForm
.
region
=
this
.
postForm
.
region
.
join
(
','
)
this
.
postForm
.
pick_group
=
this
.
postForm
.
pick_group
.
join
(
','
)
}
...
...
vu/src/views/star/components/StarDetail.vue
View file @
a7b59391
...
...
@@ -72,11 +72,10 @@
</el-select>
</el-form-item>
<el-form-item
label-width=
"45px"
label=
"地区:"
style=
"margin-left: 10px"
>
<el-select
v-model=
"postForm.region"
:remote-method=
"getRemote
Group
List"
filterable
remote
multiple
value-key=
"id"
<el-select
v-model=
"postForm.region"
:remote-method=
"getRemote
Region
List"
filterable
remote
value-key=
"id"
placeholder=
"搜索地区"
style=
"width: 220px"
>
<el-option
v-for=
"(item,index) in regionListOptions"
:key=
"item+index"
:label=
"item.name"
:value=
"item.id"
/>
<el-option
v-for=
"(item,index) in regionListOptions"
:key=
"item+index"
:label=
"item.name"
:value=
"item.id"
/>
</el-select>
</el-form-item>
<el-form-item
style=
"margin-bottom: 20px;margin-left: 10px"
label-width=
"45px"
label=
"下线:"
>
...
...
@@ -94,8 +93,8 @@
<div
style=
"margin-bottom: 20px;margin-left: 10px"
>
<el-form-item
style=
"margin-bottom: 40px;"
label-width=
"75px"
label=
"明星头像:"
prop=
"avatar"
>
<span
v-model=
"
t
ype"
></span>
<Upload
v-model=
"postForm.avatar"
:
type=
"t
ype"
/>
<span
v-model=
"
uploadT
ype"
></span>
<Upload
v-model=
"postForm.avatar"
:
uploadType=
"uploadT
ype"
/>
</el-form-item>
</div>
...
...
@@ -108,15 +107,17 @@
</div>
<div
style=
"margin-bottom:50px;"
>
<div
class=
"filter-container"
>
<el-input
:placeholder=
"'添加小组'"
v-model=
"listQuery.filter.value"
style=
"width: 180px;"
class=
"filter-item"
@
keyup
.
enter
.
native=
"appendUser"
/>
<el-select
v-model=
"temp_group_ids"
:remote-method=
"getRemoteGroupList"
filterable
remote
value-key=
"id"
placeholder=
"小组"
style=
"width: 220px"
>
<el-option
v-for=
"(item,index) in groupListOptions"
:key=
"item+index"
:label=
"item.id + ':' + item.name"
:value=
"item.id"
/>
</el-select>
<el-button
v-waves
class=
"filter-item"
type=
"primary"
icon=
"el-icon-edit"
@
click=
"appendUser"
>
添加
</el-button>
<el-button
v-waves
class=
"filter-item"
type=
"primary"
icon=
"el-icon-delete"
@
click=
"delUser"
>
移除
</el-button>
</div>
<el-table
:data=
"
list
"
border
fit
highlight-current-row
style=
"width: 100%"
<el-table
:data=
"
data
"
border
fit
highlight-current-row
style=
"width: 100%"
ref=
"multipleTable"
@
selection-change=
"handleSelectionChange"
>
<el-table-column
type=
"selection"
align=
"center"
></el-table-column>
<el-table-column
align=
"center"
label=
"小组ID "
>
...
...
@@ -128,27 +129,27 @@
</el-table-column>
<el-table-column
align=
"center"
label=
"小组名称"
>
<
template
slot-scope=
"scope"
>
<span>
{{
scope
.
row
.
user
name
}}
</span>
<span>
{{
scope
.
row
.
name
}}
</span>
</
template
>
</el-table-column>
<el-table-column
align=
"center"
label=
"小组简介"
>
<
template
slot-scope=
"scope"
>
<span>
{{
scope
.
phone
}}
</span>
<span>
{{
scope
.
row
.
description
}}
</span>
</
template
>
</el-table-column>
<el-table-column
align=
"center"
label=
"用户数"
>
<
template
slot-scope=
"scope"
>
<span>
{{
scope
.
row
.
topic
_nums
}}
</span>
<span>
{{
scope
.
row
.
user
_nums
}}
</span>
</
template
>
</el-table-column>
<el-table-column
align=
"center"
label=
"帖子数"
>
<
template
slot-scope=
"scope"
>
<span>
{{
scope
.
row
.
user_identity
}}
</span>
<span>
{{
scope
.
row
.
topic_nums
}}
</span>
</
template
>
</el-table-column>
<el-table-column
align=
"center"
label=
"组长"
>
<
template
slot-scope=
"scope"
>
<span>
{{
scope
.
row
.
internal_identity
}}
</span>
<span>
{{
scope
.
row
.
user
.
name
}}
</span>
</
template
>
</el-table-column>
...
...
@@ -165,34 +166,29 @@
</template>
<
script
>
import
Tinymce
from
'@/components/Tinymce'
import
Upload
from
'@/components/Upload/singleImage3'
import
MDinput
from
'@/components/MDinput'
import
Sticky
from
'@/components/Sticky'
// 粘性header组件
import
waves
from
'@/directive/waves'
import
Pagination
from
'@/components/Pagination'
import
{
validateURL
}
from
'@/utils/validate
'
import
{
fetchArticle
}
from
'@/api/article
'
import
{
regionSearch
}
from
'@/api/remoteSearch'
import
{
starCreate
,
starDetail
,
fetchStarRelatedGroup
}
from
'@/api/star
'
import
{
GroupDetail
}
from
'@/api/group
'
import
{
regionSearch
,
groupSearch
}
from
'@/api/remoteSearch'
const
defaultForm
=
{
status
:
'draft'
,
title
:
''
,
// 文章题目
content
:
''
,
// 文章内容
content_short
:
''
,
// 文章摘要
source_uri
:
''
,
// 文章外链
image_uri
:
''
,
// 文章图片
display_time
:
undefined
,
// 前台展示时间
id
:
undefined
,
platforms
:
[
'a-platform'
],
comment_disabled
:
false
,
importance
:
0
,
avatar
:
''
name
:
''
,
gender
:
''
,
region
:
''
,
is_online
:
undefined
,
description
:
''
,
avatar
:
''
,
group_ids
:
[],
}
export
default
{
name
:
'
Article
Detail'
,
components
:
{
Tinymce
,
MDinput
,
Upload
,
Sticky
,
Pagination
},
name
:
'
Star
Detail'
,
components
:
{
MDinput
,
Upload
,
Sticky
,
Pagination
},
directives
:
{
waves
},
props
:
{
isEdit
:
{
...
...
@@ -212,30 +208,13 @@
callback
()
}
}
const
validateSourceUri
=
(
rule
,
value
,
callback
)
=>
{
if
(
value
)
{
if
(
validateURL
(
value
))
{
callback
()
}
else
{
this
.
$message
({
message
:
'外链url填写不正确'
,
type
:
'error'
})
callback
(
new
Error
(
'外链url填写不正确'
))
}
}
else
{
callback
()
}
}
return
{
postForm
:
Object
.
assign
({},
defaultForm
),
loading
:
false
,
userListOptions
:
[],
groupListOptions
:
[],
temp_group_ids
:
[],
rules
:
{
image_uri
:
[{
validator
:
validateRequire
}],
title
:
[{
validator
:
validateRequire
}],
content
:
[{
validator
:
validateRequire
}],
source_uri
:
[{
validator
:
validateSourceUri
,
trigger
:
'blur'
}]
content
:
[{
validator
:
validateRequire
,
trigger
:
'blur'
}]
},
GenderTypeOptions
:
[
{
'key'
:
0
,
'display_name'
:
'男'
},
...
...
@@ -243,42 +222,50 @@
],
tempRoute
:
{},
regionListOptions
:
[],
type
:
99
,
list
:
null
,
total
:
1
,
uploadType
:
99
,
list
:
[],
tableData
:
[],
total
:
0
,
listLoading
:
true
,
multipleSelection
:
[],
del_list
:
[],
listQuery
:
{
page
:
0
,
limit
:
10
,
filter
:
{
value
:
''
,
key
:
''
,
},
},
}
},
computed
:
{
contentShortLength
()
{
return
this
.
postForm
.
content_short
.
length
return
this
.
postForm
.
description
.
length
},
lang
()
{
return
this
.
$store
.
getters
.
language
},
data
()
{
return
this
.
tableData
.
filter
((
d
)
=>
{
let
is_del
=
false
;
for
(
let
i
=
0
;
i
<
this
.
del_list
.
length
;
i
++
){
if
(
d
.
id
==
this
.
del_list
[
i
].
id
){
is_del
=
true
;
break
}
}
if
(
!
is_del
){
return
d
}
})
}
},
created
()
{
if
(
this
.
isEdit
)
{
const
id
=
this
.
$route
.
params
&&
this
.
$route
.
params
.
id
this
.
fetchData
(
id
)
this
.
getList
()
this
.
getList
(
id
)
}
else
{
this
.
postForm
=
Object
.
assign
({},
defaultForm
)
}
// Why need to make a copy of this.$route here?
// Because if you enter this page and quickly switch tag, may be in the execution of the setTagsViewTitle function, this.$route is no longer pointing to the current page
// https://github.com/PanJiaChen/vue-element-admin/issues/1221
this
.
tempRoute
=
Object
.
assign
({},
this
.
$route
)
},
methods
:
{
...
...
@@ -289,64 +276,69 @@
this
.
postForm
.
title
+=
` Article Id:
${
this
.
postForm
.
id
}
`
this
.
postForm
.
content_short
+=
` Article Id:
${
this
.
postForm
.
id
}
`
// Set tagsview title
this
.
setTagsViewTitle
()
}).
catch
(
err
=>
{
console
.
log
(
err
)
})
},
setTagsViewTitle
()
{
const
title
=
this
.
lang
===
'zh'
?
'编辑文章'
:
'Edit Article'
const
route
=
Object
.
assign
({},
this
.
tempRoute
,
{
title
:
`
${
title
}
-
${
this
.
postForm
.
id
}
`
})
this
.
$store
.
dispatch
(
'updateVisitedView'
,
route
)
},
submitForm
()
{
this
.
postForm
.
display_time
=
parseInt
(
this
.
display_time
/
1000
)
console
.
log
(
this
.
postForm
)
this
.
$refs
.
postForm
.
validate
(
valid
=>
{
if
(
valid
)
{
this
.
loading
=
true
this
.
postForm
.
group_ids
=
JSON
.
stringify
(
this
.
postForm
.
group_ids
)
starCreate
(
this
.
postForm
).
then
(
response
=>
{
this
.
$notify
({
title
:
'成功'
,
message
:
'发布文章成功'
,
message
:
response
.
data
.
data
.
message
,
type
:
'success'
,
duration
:
2000
})
setTimeout
(()
=>
{
this
.
$router
.
push
(
'/star/list'
)
},
1000
)
}).
catch
(
err
=>
{
this
.
$notify
({
title
:
'失败'
,
message
:
'操作失败'
,
type
:
'danger'
,
duration
:
2000
})
});
this
.
postForm
.
status
=
'published'
this
.
loading
=
false
}
else
{
console
.
log
(
'error submit!!'
)
return
false
}
})
},
draftForm
()
{
if
(
this
.
postForm
.
content
.
length
===
0
||
this
.
postForm
.
title
.
length
===
0
)
{
this
.
$message
({
message
:
'请填写必要的标题和内容'
,
type
:
'warning'
})
return
}
this
.
$message
({
message
:
'保存成功'
,
type
:
'success'
,
showClose
:
true
,
duration
:
1000
getRemoteGroupList
(
query
)
{
groupSearch
(
query
).
then
(
response
=>
{
if
(
!
response
.
data
.
data
.
data
)
return
this
.
groupListOptions
=
response
.
data
.
data
.
data
})
this
.
postForm
.
status
=
'draft'
},
getRemote
Group
List
(
query
)
{
getRemote
Region
List
(
query
)
{
regionSearch
(
query
).
then
(
response
=>
{
if
(
!
response
.
data
.
items
)
return
this
.
userListOptions
=
response
.
data
.
items
.
map
(
v
=>
v
.
name
)
if
(
!
response
.
data
.
data
.
data
)
return
this
.
regionListOptions
=
response
.
data
.
data
.
data
})
},
appendUser
()
{
GroupDetail
(
this
.
temp_group_ids
).
then
(
response
=>
{
if
(
!
response
.
data
.
data
.
data
)
return
this
.
tableData
.
push
(...
response
.
data
.
data
.
data
)
this
.
total
=
response
.
data
.
data
.
total
})
this
.
postForm
.
group_ids
.
push
(
this
.
temp_group_ids
)
this
.
temp_group_ids
=
''
},
delUser
()
{
const
lenth
=
this
.
multipleSelection
.
length
;
this
.
del_list
=
this
.
del_list
.
concat
(
this
.
multipleSelection
);
console
.
log
(
this
.
del_list
)
},
handleSelectionChange
(
val
)
{
this
.
multipleSelection
=
val
;
...
...
@@ -359,9 +351,9 @@
this
.
listQuery
.
page
=
val
this
.
getList
()
},
getList
()
{
getList
(
id
)
{
this
.
listLoading
=
true
fetch
List
(
this
.
listQuery
).
then
(
response
=>
{
fetch
StarRelatedGroup
(
id
).
then
(
response
=>
{
this
.
list
=
[]
this
.
total
=
100
this
.
listLoading
=
false
...
...
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