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
9176b660
Commit
9176b660
authored
Nov 16, 2018
by
Davve
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成pick前端编写
parent
2230190d
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
134 additions
and
114 deletions
+134
-114
group.py
api/group.py
+3
-3
pick.py
api/pick.py
+36
-6
urls.py
api/urls.py
+8
-3
account.js
vu/src/api/account.js
+1
-2
pick.js
vu/src/api/pick.js
+26
-1
list.vue
vu/src/views/group/list.vue
+2
-2
PickDetail.vue
vu/src/views/pick/components/PickDetail.vue
+58
-97
No files found.
api/group.py
View file @
9176b660
...
@@ -18,17 +18,17 @@ class GroupListView(APIView):
...
@@ -18,17 +18,17 @@ class GroupListView(APIView):
return
data
return
data
def
post
(
self
,
request
):
def
post
(
self
,
request
):
ids
=
request
.
POST
.
get
(
'ids'
,
''
)
.
split
()
group_
ids
=
request
.
POST
.
get
(
'ids'
,
''
)
.
split
()
type
=
request
.
POST
.
get
(
'type'
)
type
=
request
.
POST
.
get
(
'type'
)
filters
=
{}
filters
=
{}
if
type
==
'offline'
:
if
type
==
'offline'
:
filters
[
'is_online'
]
=
False
filters
[
'is_online'
]
=
False
elif
type
==
'recommend'
:
elif
type
==
'recommend'
:
filters
[
'recommend'
]
=
True
filters
[
'
is_
recommend'
]
=
True
else
:
else
:
filters
[
'is_online'
]
=
True
filters
[
'is_online'
]
=
True
try
:
try
:
self
.
rpc
[
'venus/community/group/batch/update'
](
filters
=
filters
,
ids
=
ids
)
.
unwrap
()
self
.
rpc
[
'venus/community/group/batch/update'
](
filters
=
filters
,
group_ids
=
group_
ids
)
.
unwrap
()
except
Exception
as
e
:
except
Exception
as
e
:
raise
e
raise
e
return
{
return
{
...
...
api/pick.py
View file @
9176b660
...
@@ -18,20 +18,49 @@ class PickListView(APIView):
...
@@ -18,20 +18,49 @@ class PickListView(APIView):
return
data
return
data
def
post
(
self
,
request
):
def
post
(
self
,
request
):
pass
ids
=
request
.
POST
.
get
(
'ids'
,
''
)
.
split
()
type
=
request
.
POST
.
get
(
'type'
,
''
)
try
:
self
.
rpc
[
'venus/community/pick/offline_pick'
](
type
=
type
,
ids
=
ids
)
.
unwrap
()
except
Exception
as
e
:
raise
e
return
{
"message"
:
"更新成功"
}
class
UpdateOrCreateView
(
APIView
):
class
UpdateOrCreateView
(
APIView
):
def
get
(
self
,
request
):
def
get
(
self
,
request
):
pass
id
=
request
.
GET
.
get
(
'id'
)
try
:
data
=
self
.
rpc
[
'venus/community/pick/detail'
](
id
=
id
)
.
unwrap
()
except
Exception
as
e
:
# raise e
data
=
{
'name'
:
1
,
'desc'
:
'hahah'
,
'gender'
:
'哈哈'
,
'region'
:
'123124312423'
,
'pick_type'
:
'www.baid.com'
,
'position'
:
22
,
'is_online'
:
1
}
return
{
'data'
:
data
}
def
post
(
self
,
request
):
def
post
(
self
,
request
):
ids
=
request
.
POST
.
get
(
'ids'
,
''
)
.
split
()
data
=
{
type
=
request
.
POST
.
get
(
'type'
,
''
)
'name'
:
request
.
POST
.
get
(
' name'
),
'desc'
:
request
.
POST
.
get
(
' desc'
),
'gender'
:
request
.
POST
.
get
(
' gender'
),
'region'
:
request
.
POST
.
get
(
' region'
),
'pick_type'
:
request
.
POST
.
get
(
' pick_type'
),
'position'
:
request
.
POST
.
get
(
' position'
),
'is_online'
:
request
.
POST
.
get
(
' is_online'
),
}
try
:
try
:
self
.
rpc
[
'venus/community/pick/
offline_pick'
](
type
=
type
,
ids
=
ids
)
.
unwrap
()
self
.
rpc
[
'venus/community/pick/
create'
](
data
=
data
)
.
unwrap
()
except
Exception
as
e
:
except
Exception
as
e
:
raise
e
raise
e
return
{
return
{
"message"
:
"更新成功"
'message'
:
'操作成功'
}
}
\ No newline at end of file
api/urls.py
View file @
9176b660
...
@@ -18,9 +18,10 @@ urlpatterns = [
...
@@ -18,9 +18,10 @@ urlpatterns = [
# 登陆,注销相关
# 登陆,注销相关
url
(
r'account/login$'
,
LoginView
.
as_view
()),
url
(
r'account/login$'
,
LoginView
.
as_view
()),
url
(
r'account/logout'
,
LogoutView
.
as_view
()),
url
(
r'account/logout'
,
LogoutView
.
as_view
()),
url
(
r'account/list'
,
AccountList
.
as_view
()),
url
(
r'account/update'
,
AccountList
.
as_view
()),
url
(
r'account/get'
,
LoginView
.
as_view
()),
url
(
r'account/get'
,
LoginView
.
as_view
()),
url
(
r'account/list'
,
AccountList
.
as_view
()),
url
(
r'account/list/update'
,
AccountList
.
as_view
()),
url
(
r'account/detail'
,
AccountUpdateOrCreateView
.
as_view
()),
url
(
r'account/detail'
,
AccountUpdateOrCreateView
.
as_view
()),
url
(
r'account/create'
,
AccountUpdateOrCreateView
.
as_view
()),
url
(
r'account/create'
,
AccountUpdateOrCreateView
.
as_view
()),
# user相关
# user相关
...
@@ -41,5 +42,8 @@ urlpatterns = [
...
@@ -41,5 +42,8 @@ urlpatterns = [
# pick相关
# pick相关
url
(
r'pick/list$'
,
PickListView
.
as_view
()),
url
(
r'pick/list$'
,
PickListView
.
as_view
()),
url
(
r'pick/update_or_create'
,
UpdateOrCreateView
.
as_view
()),
url
(
r'pick/list/update$'
,
PickListView
.
as_view
()),
url
(
r'pick/create'
,
UpdateOrCreateView
.
as_view
()),
url
(
r'pick/detail'
,
UpdateOrCreateView
.
as_view
()),
]
]
\ No newline at end of file
vu/src/api/account.js
View file @
9176b660
...
@@ -10,7 +10,7 @@ export function fetchList(query) {
...
@@ -10,7 +10,7 @@ export function fetchList(query) {
export
function
OffLineOrOnLine
(
data
)
{
export
function
OffLineOrOnLine
(
data
)
{
return
request
({
return
request
({
url
:
'/api/account/update'
,
url
:
'/api/account/
list/
update'
,
method
:
'post'
,
method
:
'post'
,
data
data
})
})
...
@@ -31,4 +31,3 @@ export function fetchAccountDetail(id) {
...
@@ -31,4 +31,3 @@ export function fetchAccountDetail(id) {
param
:
{
id
}
param
:
{
id
}
})
})
}
}
vu/src/api/pick.js
View file @
9176b660
...
@@ -11,8 +11,33 @@ export function fetchList(query) {
...
@@ -11,8 +11,33 @@ export function fetchList(query) {
export
function
OffLineOrOnLine
(
data
)
{
export
function
OffLineOrOnLine
(
data
)
{
console
.
log
(
data
)
console
.
log
(
data
)
return
request
({
return
request
({
url
:
'/api/pick/
update_or_cre
ate'
,
url
:
'/api/pick/
list/upd
ate'
,
method
:
'post'
,
method
:
'post'
,
data
data
})
})
}
}
export
function
fetchPickDetail
(
id
)
{
return
request
({
url
:
'/api/account/detail'
,
method
:
'get'
,
param
:
{
id
}
})
}
export
function
CreatePick
(
data
)
{
return
request
({
url
:
'/api/pick/create'
,
method
:
'post'
,
data
})
}
export
function
fetchPPickDetail
(
id
)
{
return
request
({
url
:
'/api/pick/detail'
,
method
:
'get'
,
param
:
{
id
}
})
}
vu/src/views/group/list.vue
View file @
9176b660
...
@@ -54,7 +54,7 @@
...
@@ -54,7 +54,7 @@
<el-table-column
width=
"80px"
align=
"center"
label=
"帖子数"
>
<el-table-column
width=
"80px"
align=
"center"
label=
"帖子数"
>
<
template
slot-scope=
"scope"
>
<
template
slot-scope=
"scope"
>
<span>
{{
scope
.
row
.
topic_num
}}
</span>
<span>
{{
scope
.
row
.
topic_num
s
}}
</span>
</
template
>
</
template
>
</el-table-column>
</el-table-column>
...
@@ -171,7 +171,7 @@ export default {
...
@@ -171,7 +171,7 @@ export default {
if
(
val
===
'offline'
){
if
(
val
===
'offline'
){
this
.
multipleSelection
[
i
].
is_online
=
0
this
.
multipleSelection
[
i
].
is_online
=
0
}
else
if
(
val
===
'recommend'
){
}
else
if
(
val
===
'recommend'
){
this
.
multipleSelection
[
i
].
is_recommend
=
0
this
.
multipleSelection
[
i
].
is_recommend
=
1
}
else
{
}
else
{
this
.
multipleSelection
[
i
].
is_online
=
1
this
.
multipleSelection
[
i
].
is_online
=
1
}
}
...
...
vu/src/views/pick/components/PickDetail.vue
View file @
9176b660
...
@@ -5,44 +5,41 @@
...
@@ -5,44 +5,41 @@
<sticky
:class-name=
"'sub-navbar '+postForm.status"
>
<sticky
:class-name=
"'sub-navbar '+postForm.status"
>
<el-button
v-loading=
"loading"
style=
"margin-left: 10px;"
type=
"success"
@
click=
"submitForm"
>
发布
<el-button
v-loading=
"loading"
style=
"margin-left: 10px;"
type=
"success"
@
click=
"submitForm"
>
发布
</el-button>
</el-button>
<el-button
v-loading=
"loading"
type=
"warning"
@
click=
"draftForm"
>
草稿
</el-button>
</sticky>
</sticky>
<div
class=
"createPost-main-container"
>
<div
class=
"createPost-main-container"
>
<el-row>
<el-row>
<el-col
:span=
"24"
>
<el-col
:span=
"24"
>
<el-form-item
style=
"margin-bottom: 40px;"
prop=
"
titl
e"
>
<el-form-item
style=
"margin-bottom: 40px;"
prop=
"
nam
e"
>
<MDinput
v-model=
"postForm.
titl
e"
:maxlength=
"100"
name=
"name"
required
>
<MDinput
v-model=
"postForm.
nam
e"
:maxlength=
"100"
name=
"name"
required
>
标题
pick名称
</MDinput>
</MDinput>
</el-form-item>
</el-form-item>
<div
class=
"postInfo-container"
>
<div
class=
"postInfo-container"
>
<el-row>
<el-row>
<el-col
:span=
"8"
>
<el-col
:span=
"8"
>
<el-form-item
label-width=
"45px"
label=
"
作者:"
class=
"postInfo-container-item"
>
<el-form-item
label-width=
"45px"
label=
"
性别:"
class=
"postInfo-container-item"
>
<el-select
v-model=
"postForm.
author"
:remote-method=
"getRemoteUserList"
filterable
remote
placeholder=
"搜索用户"
>
<el-select
v-model=
"postForm.
gender"
:remote-method=
"getRemoteUserList"
filterable
remote
placeholder=
"搜索用户"
>
<el-option
v-for=
"(item,index) in userListOptions"
:key=
"item+index"
:label=
"item"
:value=
"item"
/>
<el-option
v-for=
"(item,index) in userListOptions"
:key=
"item+index"
:label=
"item"
:value=
"item"
/>
</el-select>
</el-select>
</el-form-item>
</el-form-item>
</el-col>
</el-col>
<el-col
:span=
"10"
>
<el-col
:span=
"8"
>
<el-form-item
label-width=
"80px"
label=
"发布时间:"
class=
"postInfo-container-item"
>
<el-form-item
label-width=
"60px"
label=
"地区:"
class=
"postInfo-container-item"
>
<el-date-picker
v-model=
"postForm.display_time"
type=
"datetime"
format=
"yyyy-MM-dd HH:mm:ss"
placeholder=
"选择日期时间"
/>
<el-select
v-model=
"postForm.region"
:remote-method=
"getRemoteUserList"
filterable
remote
placeholder=
"搜索用户"
>
<el-option
v-for=
"(item,index) in userListOptions"
:key=
"item+index"
:label=
"item"
:value=
"item"
/>
</el-select>
</el-form-item>
</el-form-item>
</el-col>
</el-col>
<el-col
:span=
"6"
>
<el-col
:span=
"8"
>
<el-form-item
label-width=
"60px"
label=
"重要性:"
class=
"postInfo-container-item"
>
<el-form-item
label-width=
"60px"
label=
"属性:"
class=
"postInfo-container-item"
>
<el-rate
<el-select
v-model=
"postForm.pick_type"
:remote-method=
"getRemoteUserList"
filterable
remote
placeholder=
"搜索用户"
>
v-model=
"postForm.importance"
<el-option
v-for=
"(item,index) in userListOptions"
:key=
"item+index"
:label=
"item"
:value=
"item"
/>
:max=
"3"
</el-select>
:colors=
"['#99A9BF', '#F7BA2A', '#FF9900']"
:low-threshold=
"1"
:high-threshold=
"3"
style=
"margin-top:8px;"
/>
</el-form-item>
</el-form-item>
</el-col>
</el-col>
</el-row>
</el-row>
...
@@ -50,18 +47,22 @@
...
@@ -50,18 +47,22 @@
</el-col>
</el-col>
</el-row>
</el-row>
<el-form-item
style=
"margin-bottom: 40px;"
label-width=
"45px"
label=
"摘要:"
>
<el-form-item
style=
"margin-bottom: 40px;"
label-width=
"45px"
label=
"位置:"
prop=
"position"
>
<el-input
:rows=
"1"
v-model=
"postForm.content_short"
type=
"textarea"
class=
"article-textarea"
autosize
placeholder=
"请输入内容"
/>
<el-input
:rows=
"1"
v-model=
"postForm.position"
type=
"number"
class=
"article-textarea"
autosize
placeholder=
"请输入内容"
/>
</el-form-item>
<el-form-item
style=
"margin-bottom: 40px;"
label-width=
"45px"
label=
"简介:"
prop=
"desc"
>
<el-input
:rows=
"1"
v-model=
"postForm.desc"
type=
"textarea"
class=
"article-textarea"
autosize
placeholder=
"请输入内容"
/>
<span
v-show=
"contentShortLength"
class=
"word-counter"
>
{{
contentShortLength
}}
字
</span>
<span
v-show=
"contentShortLength"
class=
"word-counter"
>
{{
contentShortLength
}}
字
</span>
</el-form-item>
</el-form-item>
<div
class=
"editor-container"
>
<el-form-item
style=
"margin-bottom: 40px;"
label-width=
"45px"
label=
"下线:"
>
<Tinymce
ref=
"editor"
:height=
"400"
v-model=
"postForm.content"
/>
<el-radio-group
v-model=
"postForm.is_online"
>
</div>
<el-radio
:label=
"1"
>
是
</el-radio>
<el-radio
:label=
"0"
>
否
</el-radio>
</el-radio-group>
</el-form-item>
<div
style=
"margin-bottom: 20px;"
>
<Upload
v-model=
"postForm.image_uri"
/>
</div>
</div>
</div>
</el-form>
</el-form>
...
@@ -69,31 +70,25 @@
...
@@ -69,31 +70,25 @@
</
template
>
</
template
>
<
script
>
<
script
>
import
Tinymce
from
'@/components/Tinymce'
import
Upload
from
'@/components/Upload/singleImage3'
import
MDinput
from
'@/components/MDinput'
import
MDinput
from
'@/components/MDinput'
import
Sticky
from
'@/components/Sticky'
// 粘性header组件
import
Sticky
from
'@/components/Sticky'
// 粘性header组件
import
{
validateURL
}
from
'@/utils/validate'
import
{
fetchPickDetail
,
CreatePick
,
fetchPPickDetail
}
from
'@/api/pick'
import
{
fetchArticle
}
from
'@/api/article'
import
{
userSearch
}
from
'@/api/remoteSearch'
import
{
userSearch
}
from
'@/api/remoteSearch'
const
defaultForm
=
{
const
defaultForm
=
{
status
:
'draft'
,
status
:
'draft'
,
title
:
''
,
// 文章题目
name
:
''
,
content
:
''
,
// 文章内容
desc
:
''
,
content_short
:
''
,
// 文章摘要
gender
:
''
,
source_uri
:
''
,
// 文章外链
region
:
''
,
image_uri
:
''
,
// 文章图片
pick_type
:
''
,
display_time
:
undefined
,
// 前台展示时间
position
:
''
,
id
:
undefined
,
is_online
:
1
,
platforms
:
[
'a-platform'
],
comment_disabled
:
false
,
importance
:
0
}
}
export
default
{
export
default
{
name
:
'ArticleDetail'
,
name
:
'ArticleDetail'
,
components
:
{
Tinymce
,
MDinput
,
Upload
,
Sticky
},
components
:
{
MDinput
,
Sticky
},
props
:
{
props
:
{
isEdit
:
{
isEdit
:
{
type
:
Boolean
,
type
:
Boolean
,
...
@@ -112,40 +107,21 @@ export default {
...
@@ -112,40 +107,21 @@ export default {
callback
()
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
{
return
{
postForm
:
Object
.
assign
({},
defaultForm
),
postForm
:
Object
.
assign
({},
defaultForm
),
loading
:
false
,
loading
:
false
,
userListOptions
:
[],
userListOptions
:
[],
rules
:
{
rules
:
{
image_uri
:
[{
validator
:
validateRequire
}],
name
:
[{
validator
:
validateRequire
,
trigger
:
'blur'
}],
title
:
[{
validator
:
validateRequire
}],
desc
:
[{
validator
:
validateRequire
,
trigger
:
'blur'
}],
content
:
[{
validator
:
validateRequire
}],
position
:
[{
validator
:
validateRequire
,
trigger
:
'blur'
}],
source_uri
:
[{
validator
:
validateSourceUri
,
trigger
:
'blur'
}]
},
},
tempRoute
:
{}
tempRoute
:
{}
}
}
},
},
computed
:
{
computed
:
{
contentShortLength
()
{
contentShortLength
()
{
return
this
.
postForm
.
content_short
.
length
return
this
.
postForm
.
desc
.
length
},
lang
()
{
return
this
.
$store
.
getters
.
language
}
}
},
},
created
()
{
created
()
{
...
@@ -156,42 +132,43 @@ export default {
...
@@ -156,42 +132,43 @@ export default {
this
.
postForm
=
Object
.
assign
({},
defaultForm
)
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
)
this
.
tempRoute
=
Object
.
assign
({},
this
.
$route
)
},
},
methods
:
{
methods
:
{
fetchData
(
id
)
{
fetchData
(
id
)
{
fetchArticle
(
id
).
then
(
response
=>
{
fetchPPickDetail
(
id
).
then
(
response
=>
{
this
.
postForm
=
response
.
data
this
.
postForm
=
response
.
data
.
data
.
data
// Just for test
this
.
postForm
.
title
+=
` Article Id:
${
this
.
postForm
.
id
}
`
this
.
postForm
.
content_short
+=
` Article Id:
${
this
.
postForm
.
id
}
`
// Set tagsview title
this
.
setTagsViewTitle
()
}).
catch
(
err
=>
{
}).
catch
(
err
=>
{
console
.
log
(
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
()
{
submitForm
()
{
this
.
postForm
.
display_time
=
parseInt
(
this
.
display_time
/
1000
)
console
.
log
(
this
.
postForm
)
console
.
log
(
this
.
postForm
)
this
.
$refs
.
postForm
.
validate
(
valid
=>
{
this
.
$refs
.
postForm
.
validate
(
valid
=>
{
if
(
valid
)
{
if
(
valid
)
{
this
.
loading
=
true
this
.
loading
=
true
CreatePick
(
this
.
postForm
).
then
(
response
=>
{
this
.
$notify
({
this
.
$notify
({
title
:
'成功'
,
title
:
'成功'
,
message
:
'发布文章成功'
,
message
:
response
.
data
.
data
.
message
,
type
:
'success'
,
type
:
'success'
,
duration
:
2000
duration
:
2000
})
})
setTimeout
(()
=>
{
this
.
$router
.
push
(
'/pick/list'
)
},
1000
)
}).
catch
(
err
=>
{
this
.
$notify
({
title
:
'失败'
,
message
:
'操作失败'
,
type
:
'danger'
,
duration
:
2000
})
});
this
.
postForm
.
status
=
'published'
this
.
postForm
.
status
=
'published'
this
.
loading
=
false
this
.
loading
=
false
}
else
{
}
else
{
...
@@ -200,22 +177,6 @@ export default {
...
@@ -200,22 +177,6 @@ export default {
}
}
})
})
},
},
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
})
this
.
postForm
.
status
=
'draft'
},
getRemoteUserList
(
query
)
{
getRemoteUserList
(
query
)
{
userSearch
(
query
).
then
(
response
=>
{
userSearch
(
query
).
then
(
response
=>
{
if
(
!
response
.
data
.
items
)
return
if
(
!
response
.
data
.
items
)
return
...
...
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