Commit 932a0316 authored by Davve's avatar Davve

完成帖子创建编辑后端逻辑

parent ba219b88
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# __author__ = "chenwei" # __author__ = "chenwei"
# Date: 2018/11/16 # Date: 2018/11/16
from django.conf import settings
from utils.base import APIView from utils.base import APIView
...@@ -95,7 +96,7 @@ class LoginView(APIView): ...@@ -95,7 +96,7 @@ class LoginView(APIView):
username = request.POST.get('username') username = request.POST.get('username')
password = request.POST.get('password') password = request.POST.get('password')
if username == 'admin' and password == '123123': if username == settings.USERNAME and password == settings.PASSWORD:
data = { data = {
'id': 1, 'id': 1,
'roles': ['admin'], 'roles': ['admin'],
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
import datetime import datetime
from utils.base import APIView from utils.base import APIView
from utils.time_utils import utc_to_datetime, datetime_toString, unix_time_to_datetime, analysis_time from utils.time_utils import utc_to_datetime, unix_time_to_datetime, analysis_time
class PushListView(APIView): class PushListView(APIView):
...@@ -31,10 +31,8 @@ class PushUpdateOrCreateView(APIView): ...@@ -31,10 +31,8 @@ class PushUpdateOrCreateView(APIView):
def post(self, request): def post(self, request):
id = request.POST.get('id', '') id = request.POST.get('id', '')
try: push_time = analysis_time(request.POST.get('push_time', 0))
push_time = unix_time_to_datetime(int(request.POST.get('push_time', 0)) / 1000)
except ValueError:
push_time = utc_to_datetime(request.POST.get('push_time', '')[:-5] + 'Z')
data = { data = {
'url': request.POST.get('url', ''), 'url': request.POST.get('url', ''),
'push_time': push_time, 'push_time': push_time,
......
...@@ -3,32 +3,126 @@ ...@@ -3,32 +3,126 @@
# __author__ = "chenwei" # __author__ = "chenwei"
# Date: 2018/11/15 # Date: 2018/11/15
import json
from utils.base import APIView from utils.base import APIView
from utils.time_utils import analysis_time
class TopicListView(APIView): class TopicListView(APIView):
def get(self, request): def get(self, request):
page = int(request.GET.get('page', 1)) page = int(request.GET.get('page', 0))
limit = int(request.GET.get('limit', 10)) limit = int(request.GET.get('limit', 10))
filter = self.handle_filter(request.GET.get('filter', "")) filter = self.handle_filter(request.GET.get('filter', ""))
try: try:
data = self.rpc['venus/community/topic/get'](offset=page, limit=limit, filters=filter).unwrap() data = self.rpc['venus/sun/topic/list'](offset=page, limit=limit, filters=filter).unwrap()
except Exception as e: except Exception as e:
# raise e raise e
return data
class TopicUpdateOrCreateView(APIView):
def get(self, request):
id = request.GET.get('id')
try: # TODO 少返回了is_online
data = self.rpc['venus/sun/topic/get'](id=id).unwrap()
except Exception as e:
raise e
return {'data': data}
def post(self, request):
id = request.POST.get('id', '')
posting_time = analysis_time(request.POST.get('posting_time', 0))
topic_images = list(map(lambda x: x[:-2], json.loads(request.POST.get('topic_images', []))))
data = { data = {
'total': 200, 'topic_images': topic_images,
'data':[ 'topic_ids': json.loads(request.POST.get('topic_ids', '')),
{"id": "1", "content": '内容', 'user_name': 'alex','newly_reply': '最新回复', 'group_name': '小组名', 'update_time': '2019-09-18 23:59:59', 'video_url': request.POST.get('video_url', ''),
'reported_time': '2019-09-18 23:59:59', 'is_online': 1, 'is_reported': 0}, 'posting_time': posting_time,
{"id": "2", "content": '内容', 'newly_reply': '最新回复', 'group_name': '小组名', 'update_time': '2019-09-18 23:59:59', 'content': request.POST.get('content', ''),
'reported_time': '2019-09-18 23:59:59', 'user_name': 'alex','is_online': 0, 'is_reported': 0}, 'content_level': request.POST.get('content_level', ''),
{"id": "3", "content": '内容', 'user_name': 'alex','newly_reply': '最新回复', 'group_name': '小组名', 'update_time': '2019-09-18 23:59:59', 'group_name': request.POST.get('group_name', ''),
'reported_time': '2019-09-18 23:59:59', 'is_online': 1, 'is_reported': 1}, 'user_id': request.POST.get('user_id', ''),
{"id": "4", "content": '内容', 'user_name': 'alex','newly_reply': '最新回复', 'group_name': '小组名', 'update_time': '2019-09-18 23:59:59', 'star_name': request.POST.get('star_name', ''),
'reported_time': '2019-09-18 23:59:59', 'is_online': 1, 'is_reported': 1}, 'tag_ids': json.loads(request.POST.get('tag_ids', [])),
{"id": "5", "content": '内容', 'user_name': 'alex','newly_reply': '最新回复', 'group_name': '小组名', 'update_time': '2019-09-18 23:59:59', }
'reported_time': '2019-09-18 23:59:59', 'is_online': 0, 'is_reported': 0}, try:
self.rpc['venus/sun/topic/edit'](id=id, data=data).unwrap()
except Exception as e:
raise e
return {
'message': '更新成功'
}
class ReplyUpdateOrCreateView(APIView):
def get(self, request):
id = request.GET.get('id')
page = int(request.GET.get('page', 0))
limit = int(request.GET.get('limit', 10))
filter = self.handle_filter(request.GET.get('filter', ""))
filter.update({'id': id})
try:
data = self.rpc['venus/sun/topic/reply/list'](offset=page, limit=limit, filters=filter).unwrap()
except Exception as e:
data = [
{
'id': 1,
'reply_name': '真好',
'be_reply_name': '王二',
'create_time': '2018-09-10 23:23:23',
'reply_type': '贴主的评论',
'content': '内容真好',
},
] ]
return {
'total': 10,
'data': data
} }
return data
def post(self, request):
reply_ids = json.loads(request.POST.get('reply_ids', []))
try:
self.rpc['venus/sun/topic/reply/batch_delete'](data=reply_ids).unwrap()
except Exception as e:
raise e
return {
'message': '操作成功'
}
class ReplyCreate(APIView):
def post(self, request):
data = {
'topic_id': request.POST.get('topic_id'),
'reply_name': request.POST.get('reply_name'),
'be_reply_name': request.POST.get('be_reply_name'),
'content': request.POST.get('content'),
}
try:
data = self.rpc['venus/sun/topic/reply/create'](data=data).unwrap()
"""
data = {
'id': 1,
'reply_type': 1,
'create_time': '2108-09-92 12:12:12',
'reply_name': 'xxxxx',
'be_reply_name': 'xxxxxx',
'content': '测试测试',
}
"""
except Exception as e:
# raise e
data = {
'id': 6,
'reply_type': "贴住的评论",
'create_time': '2108-09-92 12:12:12',
'reply_name': 'xxxxx',
'be_reply_name': 'xxxxxx',
'content': '测试测试',
}
return {'data': data}
...@@ -38,6 +38,11 @@ urlpatterns = [ ...@@ -38,6 +38,11 @@ urlpatterns = [
# topic相关 # topic相关
url(r'topic/list$', TopicListView.as_view()), url(r'topic/list$', TopicListView.as_view()),
url(r'topic/detail', TopicUpdateOrCreateView.as_view()),
url(r'topic/creacte', TopicUpdateOrCreateView.as_view()),
url(r'topic/reply/list', ReplyUpdateOrCreateView.as_view()),
url(r'topic/reply/batch_delete', ReplyUpdateOrCreateView.as_view()),
url(r'topic/reply/create', ReplyCreate.as_view()),
# star相关 # star相关
url(r'star/list$', StarListView.as_view()), url(r'star/list$', StarListView.as_view()),
......
...@@ -138,3 +138,7 @@ QINIU_ACCESS_KEY = "UPCOYIJkZOMcdd9FDzpBqYjzWUh55fBpVi3AhWpL" ...@@ -138,3 +138,7 @@ QINIU_ACCESS_KEY = "UPCOYIJkZOMcdd9FDzpBqYjzWUh55fBpVi3AhWpL"
QINIU_SECRET_KEY = "z5YvpDDSam_JE345Z8J_f3TufzelOW2VOGNoBl9e" QINIU_SECRET_KEY = "z5YvpDDSam_JE345Z8J_f3TufzelOW2VOGNoBl9e"
QINIU_HOST = "http://wanmeizhensuo.qiniudn.com/" QINIU_HOST = "http://wanmeizhensuo.qiniudn.com/"
QINIU_SCOPE = 'wanmeizhensuo' QINIU_SCOPE = 'wanmeizhensuo'
# 超级管理员
USERNAME = 'admin'
PASSWORD = 'admin'
\ No newline at end of file
...@@ -2,7 +2,7 @@ import request from '@/utils/request' ...@@ -2,7 +2,7 @@ import request from '@/utils/request'
export function userSearch(name) { export function userSearch(name) {
return request({ return request({
url: '/search/user', url: '/api/search/user',
method: 'get', method: 'get',
params: { name } params: { name }
}) })
......
...@@ -19,13 +19,12 @@ export function OffLineOrOnLine(data) { ...@@ -19,13 +19,12 @@ export function OffLineOrOnLine(data) {
export function createRemark(data) { export function createRemark(data) {
return request({ return request({
url: '/api/topic/create_remark', url: '/api/topic/reply/create',
method: 'post', method: 'post',
data data
}) })
} }
export function fetchTopic(id) { export function fetchTopic(id) {
return request({ return request({
url: '/api/topic/detail', url: '/api/topic/detail',
...@@ -33,3 +32,27 @@ export function fetchTopic(id) { ...@@ -33,3 +32,27 @@ export function fetchTopic(id) {
params: { id } params: { id }
}) })
} }
export function createTopic(data) {
return request({
url: '/api/topic/create',
method: 'post',
data
})
}
export function fetchReply(query) {
return request({
url: '/api/topic/reply/list',
method: 'get',
params: query
})
}
export function DelReply(data) {
return request({
url: '/api/topic/reply/batch_delete',
method: 'post',
data
})
}
...@@ -24,7 +24,7 @@ export default { ...@@ -24,7 +24,7 @@ export default {
}, },
page: { page: {
type: Number, type: Number,
default: 1 default: 0
}, },
limit: { limit: {
type: Number, type: Number,
......
...@@ -31,9 +31,6 @@ Mock.mock(/\/article\/create/, 'post', articleAPI.createArticle) ...@@ -31,9 +31,6 @@ Mock.mock(/\/article\/create/, 'post', articleAPI.createArticle)
Mock.mock(/\/article\/update/, 'post', articleAPI.updateArticle) Mock.mock(/\/article\/update/, 'post', articleAPI.updateArticle)
// 搜索相关 // 搜索相关
Mock.mock(/\/search\/user/, 'get', remoteSearchAPI.searchUser)
// 账单相关
Mock.mock(/\/transaction\/list/, 'get', transactionAPI.getList) Mock.mock(/\/transaction\/list/, 'get', transactionAPI.getList)
export default Mock export default Mock
...@@ -55,7 +55,7 @@ export default { ...@@ -55,7 +55,7 @@ export default {
} }
} }
const validatePassword = (rule, value, callback) => { const validatePassword = (rule, value, callback) => {
if (value.length < 6) { if (value.length < 5) {
callback(new Error('The password can not be less than 6 digits')) callback(new Error('The password can not be less than 6 digits'))
} else { } else {
callback() callback()
...@@ -64,7 +64,7 @@ export default { ...@@ -64,7 +64,7 @@ export default {
return { return {
loginForm: { loginForm: {
username: 'admin', username: 'admin',
password: '123123' password: 'admin'
}, },
loginRules: { loginRules: {
username: [{ required: true, trigger: 'blur', validator: validateUsername }], username: [{ required: true, trigger: 'blur', validator: validateUsername }],
......
...@@ -241,6 +241,7 @@ ...@@ -241,6 +241,7 @@
this.postForm.region = Assembledata(this.temparray['region'], this.postForm.region); this.postForm.region = Assembledata(this.temparray['region'], this.postForm.region);
this.postForm.pick_group = Assembledata(this.temparray['pick_group'], this.postForm.pick_group); this.postForm.pick_group = Assembledata(this.temparray['pick_group'], this.postForm.pick_group);
}else{ }else{
this.postForm.region = this.postForm.region.join(',')
this.postForm.region = this.postForm.region.join(',') this.postForm.region = this.postForm.region.join(',')
this.postForm.pick_group = this.postForm.pick_group.join(',') this.postForm.pick_group = this.postForm.pick_group.join(',')
} }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
<el-row :gutter="20"> <el-row :gutter="20">
<el-card class="box-card"> <el-card class="box-card">
<div slot="header" class="clearfix"> <div slot="header" class="clearfix">
<span>明星相关</span> <span>帖子相关</span>
</div> </div>
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label-width="75px" label="举报时间:" class="postInfo-container-item" v-if="isEdit"> <el-form-item label-width="75px" label="举报时间:" class="postInfo-container-item" v-if="isEdit">
<el-input :rows="1" v-model="postForm.report_time" type="text" class="article-textarea" <el-input :rows="1" v-model="postForm.reported_time" type="text" class="article-textarea"
style="width: 230px" readonly/> style="width: 230px" readonly/>
</el-form-item> </el-form-item>
</el-col> </el-col>
...@@ -32,38 +32,41 @@ ...@@ -32,38 +32,41 @@
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label-width="65px" label="发帖人:" class="postInfo-container-item"> <el-form-item label-width="65px" label="发帖人:" class="postInfo-container-item">
<el-select v-model="postForm.author" :remote-method="getRemoteGroupList" filterable remote <el-select v-model="postForm.user_name" :remote-method="getRemoteUserList" filterable remote
placeholder="搜索用户" style="width: 230px;margin-left: 10px"> placeholder="搜索用户" style="width: 230px;margin-left: 10px">
<el-option v-for="(item,index) in groupListOptions" :key="item+index" :label="item" <el-option v-for="(item,index) in userListOptions" :key="item+index" :label="item.name" :value="item.id"/>
:value="item"/>
</el-select> </el-select>
<el-tag type="danger" v-if="is_puppet">马甲</el-tag> <el-tag type="danger" v-if="postForm.is_puppet">马甲</el-tag>
</el-form-item> </el-form-item>
</el-col> </el-col>
<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" prop="posting_time">
<el-date-picker v-model="postForm.posting_time " type="datetime" format="yyyy-MM-dd HH:mm:ss" <el-date-picker
placeholder="选择日期时间" style="width: 230px"/> v-model="postForm.posting_time "
type="datetime"
format="yyyy-MM-dd HH:mm:ss"
:picker-options="expireTimeOption"
placeholder="选择日期时间"
style="width: 230px"
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
<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.author" :remote-method="getRemoteStarList" filterable remote <el-select v-model="postForm.star_name" :remote-method="getRemoteStarList" filterable remote
placeholder="搜索小组" style="width: 230px"> placeholder="搜索明星" style="width: 230px">
<el-option v-for="(item,index) in userListOptions" :key="item+index" :label="item" <el-option v-for="(item,index) in starListOptions" :key="item+index" :label="item.name" :value="item.id"/>
:value="item"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<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.author" :remote-method="getRemoteGroupList" filterable remote <el-select v-model="postForm.group_name" :remote-method="getRemoteGroupList" filterable remote
placeholder="搜索用户" style="width: 230px"> placeholder="搜索小组" style="width: 230px">
<el-option v-for="(item,index) in userListOptions" :key="item+index" :label="item" <el-option v-for="(item,index) in groupListOptions" :key="item+index" :label="item.name" :value="item.id"/>
:value="item"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
...@@ -71,7 +74,7 @@ ...@@ -71,7 +74,7 @@
<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.topic_level" :placeholder="'级别:'" clearable <el-select v-model="postForm.content_level" :placeholder="'级别:'" clearable
class="postInfo-container-item" style="width:230px"> class="postInfo-container-item" style="width:230px">
<el-option v-for="item in TopicLevelOptions" :key="item.key" :label="item.display_name" <el-option v-for="item in TopicLevelOptions" :key="item.key" :label="item.display_name"
:value="item.key"/> :value="item.key"/>
...@@ -81,10 +84,9 @@ ...@@ -81,10 +84,9 @@
<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.author" :remote-method="getRemoteTagList" filterable remote <el-select v-model="postForm.tag_ids" :remote-method="getRemoteTagList" filterable remote multiple value-key="id"
placeholder="搜索标签" style="width: 230px"> placeholder="搜索标签" style="width: 230px">
<el-option v-for="(item,index) in tagListOptions" :key="item+index" :label="item" <el-option v-for="(item,index) in tagListOptions" :key="item+index" :label="item.name" :value="item.id"/>
:value="item"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
...@@ -92,6 +94,12 @@ ...@@ -92,6 +94,12 @@
</div> </div>
</el-col> </el-col>
</el-row> </el-row>
<el-form-item style="margin-bottom: 20px" label-width="75px" label="下线:">
<el-radio-group v-model="postForm.is_online">
<el-radio :label="1"></el-radio>
<el-radio :label="0"></el-radio>
</el-radio-group>
</el-form-item>
<el-form-item style="margin-bottom: 40px;" label-width="75px" label="帖子内容:"> <el-form-item style="margin-bottom: 40px;" label-width="75px" label="帖子内容:">
<el-input :rows="1" v-model="postForm.content" type="textarea" class="article-textarea" autosize <el-input :rows="1" v-model="postForm.content" type="textarea" class="article-textarea" autosize
placeholder="请输入内容"/> placeholder="请输入内容"/>
...@@ -99,9 +107,9 @@ ...@@ -99,9 +107,9 @@
</el-form-item> </el-form-item>
<div class="item real"> <div class="item real">
<div class="name"> <div class="name">
<span>帖子图片</span> <span style="color: #606266;text-align:center;font-size:14px;padding:0 12px 0 0;">帖子图片</span>
</div> </div>
<div class="value"> <div class="value" style="margin-left: 50px">
<edit-upload :value="edit.hospital_pics" @input="uploadPics" multiple :limit="9" :uploadType="'26'" <edit-upload :value="edit.hospital_pics" @input="uploadPics" multiple :limit="9" :uploadType="'26'"
@limit="uploadRealLimit"></edit-upload> @limit="uploadRealLimit"></edit-upload>
<div class="error_icon" v-show="showHospitalPicTip"> <div class="error_icon" v-show="showHospitalPicTip">
...@@ -117,9 +125,9 @@ ...@@ -117,9 +125,9 @@
<div v-if="hide"> <div v-if="hide">
<div class="item video"> <div class="item video">
<div class="name"> <div class="name">
<i></i><span>帖子视频</span> <span style="color: #606266;text-align:center;font-size:14px;padding:0 12px 0 0;">帖子视频</span>
</div> </div>
<div class="value"> <div class="value" style="margin-left: 50px">
<div class="up-video"> <div class="up-video">
<ul class="video-items clearfix" v-if="edit.video_url"> <ul class="video-items clearfix" v-if="edit.video_url">
<li class="video-item" @click.stop="playVideo"> <li class="video-item" @click.stop="playVideo">
...@@ -154,50 +162,52 @@ ...@@ -154,50 +162,52 @@
</el-row> </el-row>
<el-row :gutter="20" style="margin-top:50px;"> <el-row :gutter="20" style="margin-top:50px;" v-if="isEdit">
<el-card class="box-card"> <el-card class="box-card">
<div slot="header" class="clearfix"> <div slot="header" class="clearfix">
<span>帖子相关</span> <span>评论相关</span>
</div> </div>
<div style="margin-bottom:50px;"> <div style="margin-bottom:50px;">
<div class="filter-container"> <div class="filter-container">
<el-button class="filter-item" type="primary" icon="el-icon-edit" @click="handleCreate">回复</el-button> <el-select v-model="listQuery.filter.replyType" :placeholder="'评论搜索'" clearable class="filter-item" style="width: 120px">
<el-button v-waves class="filter-item" type="primary" icon="el-icon-delete" @click="delUser">下线 <el-option v-for="item in ReplyTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
</el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">搜索</el-button>
<el-button class="filter-item" type="primary" icon="el-icon-edit" @click="reply">回复</el-button>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-delete" @click="delreply">下线
</el-button> </el-button>
</div> </div>
<el-table :data="list" border fit highlight-current-row style="width: 100%" <el-table :data="list" border fit highlight-current-row style="width: 100%"
ref="multipleTable" @selection-change="handleSelectionChange"> ref="multipleTable" @selection-change="handleSelectionChange">
<el-table-column type="selection" align="center"></el-table-column> <el-table-column type="selection" align="center"></el-table-column>
<el-table-column align="center" label="用户ID "> <el-table-column align="center" label="帖子ID ">
<template slot-scope="scope"> <template slot-scope="scope">
<router-link :to="'/push/edit/'+scope.row.id" class="link-type">
<span>{{ scope.row.id }}</span> <span>{{ scope.row.id }}</span>
</router-link>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="评论用户"> <el-table-column align="center" label="评论用户">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.username }}</span> <span>{{ scope.row.reply_name }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="被评论用户"> <el-table-column align="center" label="被评论用户">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.phone }}</span> <span>{{ scope.row.be_reply_name }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="评论时间"> <el-table-column align="center" label="评论时间">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.topic_nums }}</span> <span>{{ scope.row.create_time }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="贴主评论"> <el-table-column align="center" label="贴主评论">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.user_identity }}</span> <span>{{ scope.row.reply_type }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="评论内容"> <el-table-column align="center" label="评论内容">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.internal_identity }}</span> <span>{{ scope.row.content }}</span>
</template> </template>
</el-table-column> </el-table-column>
...@@ -215,29 +225,28 @@ ...@@ -215,29 +225,28 @@
<el-dialog :visible.sync="dialogFormVisible"> <el-dialog :visible.sync="dialogFormVisible">
<el-form ref="dataForm" :rules="rules" :model="temp" label-position="left" label-width="70px" <el-form ref="dataForm" :rules="rules" :model="temp" label-position="left" label-width="70px"
style="width: 400px; margin-left:50px;"> style="width: 400px; margin-left:50px;">
<el-form-item :label="'被评论用户'" prop="be_remarked_user"> <el-form-item :label="'被评论用户'" prop="be_reply_name">
<el-select v-model="temp.be_remarked_user" :remote-method="getRemoteUserList" filterable remote multiple <el-select v-model="temp.be_reply_name" :remote-method="getRemoteUserList" filterable remote
value-key="id" value-key="id"
placeholder="搜索用户" style="width: 100%"> placeholder="搜索用户" style="width: 100%">
<el-option v-for="(item,index) in remarkListOptions" :key="item+index" :label="item.name" :value="item.id"/> <el-option v-for="(item,index) in userListOptions" :key="item+index" :label="item.name" :value="item.id"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item :label="'评论用户'" prop="remark_user"> <el-form-item :label="'评论用户'" prop="reply_name">
<el-select v-model="temp.remark_user" :remote-method="getRemoteUserList" filterable remote <el-select v-model="temp.reply_name" :remote-method="getRemoteUserList" filterable remote
value-key="id" value-key="id"
placeholder="搜索用户" style="width: 100%"> placeholder="搜索用户" style="width: 100%">
<el-option v-for="(item,index) in remarkListOptions" :key="item+index" :label="item.name" :value="item.id"/> <el-option v-for="(item,index) in userListOptions" :key="item+index" :label="item.name" :value="item.id"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item :label="'评论内容'"> <el-form-item :label="'评论内容'">
<el-input :autosize="{ minRows: 2, maxRows: 4}" v-model="temp.remark" type="textarea" <el-input :autosize="{ minRows: 2, maxRows: 4}" v-model="temp.content" type="textarea"
placeholder="Please input"/> placeholder="Please input"/>
</el-form-item> </el-form-item>
</el-form> </el-form>
<div slot="footer" class="dialog-footer"> <div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false">{{ $t('table.cancel') }}</el-button> <el-button @click="dialogFormVisible = false">取消</el-button>
<el-button type="primary" @click="dialogStatus==='create'?createData():updateData()">{{ $t('table.confirm') }} <el-button type="primary" @click="dialogStatus==='create'?createData():updateData()">确认</el-button>
</el-button>
</div> </div>
</el-dialog> </el-dialog>
...@@ -254,25 +263,39 @@ ...@@ -254,25 +263,39 @@
import Modal from '@/components/Modal' import Modal from '@/components/Modal'
import VideoPlayer from '@/components/Video' import VideoPlayer from '@/components/Video'
import waves from '@/directive/waves' import waves from '@/directive/waves'
import {createRemark, fetchTopic} from '@/api/topic' import {createRemark, fetchTopic, createTopic, fetchReply, DelReply} from '@/api/topic'
import {fetchList} from '@/api/user' import {fetchList} from '@/api/user'
import {getToken} from '@/api/qiniu' import {getToken} from '@/api/qiniu'
import {postVideo} from '@/api/upload' import {postVideo} from '@/api/upload'
import {userSearch, groupSearch, starSearch, tagSearch} from '@/api/remoteSearch' import {userSearch, groupSearch, starSearch, tagSearch} from '@/api/remoteSearch'
import {VIDEO_PREFIX} from '@/components/Upload/utils/default' import {VIDEO_PREFIX} from '@/components/Upload/utils/default'
function Assembledata(target, source) {
var region_data = []
for (var i=0;i<target.length;i++){
if (isInArray(source, target[i]['name'])){
region_data.push(target[i]['id'])
removeByvale(source, target[i]['name']);
}
}
region_data.push(...source)
return region_data.join(',')
}
const VIDEO_MAX_SIZE = 100 * 1024 * 1024 const VIDEO_MAX_SIZE = 100 * 1024 * 1024
const defaultForm = { const defaultForm = {
status: 'draft', status: 'draft',
title: '', // 文章题目 id: '',
posting_time: '',
content: '', content: '',
source_uri: '', // 文章外链 topic_ids: [],
image_uri: '', // 文章图片 content_level: '',
display_time: undefined, // 前台展示时间 group_name: '',
id: undefined, user_name: '',
platforms: ['a-platform'], star_name: '',
comment_disabled: false, is_puppet: '',
posting_time: undefined, tag_ids: [],
is_online: '',
} }
export default { export default {
...@@ -300,16 +323,46 @@ ...@@ -300,16 +323,46 @@
return { return {
postForm: Object.assign({}, defaultForm), postForm: Object.assign({}, defaultForm),
loading: false, loading: false,
// 搜索相关
userListOptions: [], userListOptions: [],
groupListOptions: [], groupListOptions: [],
remarkListOptions: [], tagListOptions: [],
starListOptions: [],
// 表单验证相关
rules: {
posting_time: [{validator: validateRequire, trigger: 'blur'}]
},
ReplyTypeOptions: [
{'key': 1, 'display_name': '帖主的评论'},
{'key': 2, 'display_name': '评论帖子'},
{'key': 3, 'display_name': '评论的回复'},
{'key': 4, 'display_name': '马甲的评论'},
{'key': 5, 'display_name': '马甲评论的回复'},
],
edit: { edit: {
video_url: '', video_url: '',
hospital_pics: [] hospital_pics: []
}, },
rules: {
posting_time: [{validator: validateRequire, trigger: 'blur'}] expireTimeOption: {
disabledDate(date){
return date.getTime() <= Date.now();
}
}, },
temp_data:{
star_id: '',
star_name: '',
group_id: '',
group_name: '',
user_id: '',
user_name: '',
tag_ids: []
},
tempRoute: {}, tempRoute: {},
TopicLevelOptions: [ TopicLevelOptions: [
{'key': 1, 'display_name': '1星'}, {'key': 1, 'display_name': '1星'},
...@@ -325,14 +378,12 @@ ...@@ -325,14 +378,12 @@
areaType: 1, areaType: 1,
multipleSelection: [], multipleSelection: [],
tagListOptions: [], tagListOptions: [],
del_list: [],
is_puppet: 0, is_puppet: 0,
listQuery: { listQuery: {
page: 0, page: 0,
limit: 10, limit: 10,
filter: { filter: {
value: '', replyType: ''
key: '',
}, },
}, },
...@@ -379,6 +430,7 @@ ...@@ -379,6 +430,7 @@
if (this.isEdit) { if (this.isEdit) {
const id = this.$route.params && this.$route.params.id const id = this.$route.params && this.$route.params.id
this.fetchData(id) this.fetchData(id)
this.getList(id)
} else { } else {
this.postForm = Object.assign({}, defaultForm) this.postForm = Object.assign({}, defaultForm)
getToken().then(response => { getToken().then(response => {
...@@ -390,34 +442,78 @@ ...@@ -390,34 +442,78 @@
methods: { methods: {
fetchData(id) { fetchData(id) {
fetchTopic(id).then(response => { fetchTopic(id).then(response => {
this.postForm = response.data let star = response.data.data.data.star
// Just for test let group = response.data.data.data.group
this.postForm.title += ` Article Id:${this.postForm.id}` let user = response.data.data.data.user
this.postForm.content_short += ` Article Id:${this.postForm.id}` let tags = response.data.data.data.tags
let temp_tag = []
this.postForm = response.data.data.data
for (let i = 0; i < tags.length; i ++){
temp_tag.push(tags[i].name); // 把每个标签的名称压入
this.temp_data.tag_ids.push(tags[i].id) // 每个标签的ID 压入暂存
}
this.postForm.tag_ids = temp_tag;
this.edit.hospital_pics = response.data.data.data.topic_images
this.edit.video_url = response.data.data.data.video_url
// 回填明星数据, 后期进行改进
this.temp_data.star_id = star.id
this.postForm.star_name = this.temp_data.star_name = star.name
// 回填小组数据
this.temp_data.group_id = group.id
this.postForm.group_name = this.temp_data.group_name = group.name
this.temp_data.user_id = user.id
this.postForm.user_name = this.temp_data.user_name = user.name
this.postForm.is_puppet = user.is_puppet
// 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)
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.tag_ids = Assembledata(this.temp_data.tag_ids, this.postForm.tag_ids)
}else{
this.postForm.tag_ids = JSON.stringify(this.postForm.tag_ids)
}
// 序列化图片
this.postForm.topic_images = JSON.stringify(this.edit.hospital_pics);
this.postForm.video_url = this.edit.video_url;
this.postForm.topic_ids = JSON.stringify(this.postForm.topic_ids)
createTopic(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('/topic/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 {
...@@ -426,60 +522,65 @@ ...@@ -426,60 +522,65 @@
} }
}) })
}, },
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 console.log(response.data.data.data)
if (!response.data.data.data) return
this.userListOptions = response.data.data.data this.userListOptions = response.data.data.data
}) })
}, },
getRemoteGroupList(query) { getRemoteGroupList(query) {
groupSearch(query).then(response => { groupSearch(query).then(response => {
if (!response.data.items) return if (!response.data.data.data) return
this.userListOptions = response.data.data.data this.groupListOptions = response.data.data.data
}) })
}, },
getRemoteStarList(query) { getRemoteStarList(query) {
starSearch(query).then(response => { starSearch(query).then(response => {
if (!response.data.items) return if (!response.data.data.data) return
this.userListOptions = response.data.data.data this.starListOptions = response.data.data.data
}) })
}, },
getRemoteTagList(query) { getRemoteTagList(query) {
tagSearch(query).then(response => { tagSearch(query).then(response => {
if (!response.data.items) return if (!response.data.data.data) return
this.userListOptions = response.data.data.data this.tagListOptions = response.data.data.data
}) })
}, },
appendUser() {
},
delUser() {
// reply() {
//
// },
delreply() {
const length = this.multipleSelection.length
let del_list = []
for (let i = 0;i < length;i++){
del_list.push(this.multipleSelection[i].id)
}
DelReply({'reply_ids': JSON.stringify(del_list)}).then(response => {
this.$message({
message: response.data.data.message,
type: 'success'
})
})
setTimeout(() => {
this.$router.go(0)
}, 1000)
}, },
getList() { getList(id) {
this.listLoading = true this.listLoading = true
fetchList(this.listQuery).then(response => { this.listQuery.id = id
this.list = [] fetchReply(this.listQuery).then(response => {
this.total = 100 this.list = response.data.data.data
this.total = response.data.data.total
this.listLoading = false this.listLoading = false
}) })
}, },
// 图片上传
dropzoneS(file) { dropzoneS(file) {
console.log(file) console.log(file)
this.$message({message: 'Upload success', type: 'success'}) this.$message({message: 'Upload success', type: 'success'})
...@@ -488,19 +589,6 @@ ...@@ -488,19 +589,6 @@
console.log(file) console.log(file)
this.$message({message: 'Delete success', type: 'success'}) this.$message({message: 'Delete success', type: 'success'})
}, },
handleSelectionChange(val) {
this.multipleSelection = val;
},
handleSizeChange(val) {
this.listQuery.limit = val
this.getList()
},
handleCurrentChange(val) {
this.listQuery.page = val
this.getList()
},
uploadPics(images) { uploadPics(images) {
this.edit.hospital_pics = images this.edit.hospital_pics = images
}, },
...@@ -513,6 +601,20 @@ ...@@ -513,6 +601,20 @@
hide() { hide() {
return Number(this.areaType) === 1 return Number(this.areaType) === 1
}, },
// 分页相关
handleSelectionChange(val) {
this.multipleSelection = val;
},
handleSizeChange(val) {
this.listQuery.limit = val
this.getList()
},
handleCurrentChange(val) {
this.listQuery.page = val
this.getList()
},
// 上传视频 // 上传视频
uploadVideo(e) { uploadVideo(e) {
let file = e.target.files[0] let file = e.target.files[0]
...@@ -596,16 +698,12 @@ ...@@ -596,16 +698,12 @@
resetTemp() { resetTemp() {
this.temp = { this.temp = {
id: undefined, 'reply_name': '',
importance: 1, 'be_reply_name': '',
remark: '', 'content': '',
timestamp: new Date(),
title: '',
status: 'published',
type: ''
} }
}, },
handleCreate() { reply() {
this.resetTemp() this.resetTemp()
this.dialogStatus = 'create' this.dialogStatus = 'create'
this.dialogFormVisible = true this.dialogFormVisible = true
...@@ -616,13 +714,11 @@ ...@@ -616,13 +714,11 @@
createData() { createData() {
this.$refs['dataForm'].validate((valid) => { this.$refs['dataForm'].validate((valid) => {
if (valid) { if (valid) {
this.temp.id = parseInt(Math.random() * 100) + 1024 // mock a id this.temp.topic_id = this.postForm.id
this.temp.author = 'vue-element-admin' createRemark(this.temp).then((response) => {
createRemark(this.temp).then(() => { this.list.push(response.data.data.data)
this.list.unshift(this.temp)
this.dialogFormVisible = false this.dialogFormVisible = false
this.$notify({ this.$notify({
title: '成功',
message: '创建成功', message: '创建成功',
type: 'success', type: 'success',
duration: 2000 duration: 2000
...@@ -632,6 +728,10 @@ ...@@ -632,6 +728,10 @@
}) })
}, },
handleFilter() {
this.listQuery.page = 0
this.getList(this.postForm.id);
},
} }
} }
</script> </script>
......
...@@ -11,6 +11,14 @@ ...@@ -11,6 +11,14 @@
<el-select v-model="listQuery.filter.is_reported" :placeholder="'举报'" clearable class="filter-item" style="width: 100px"> <el-select v-model="listQuery.filter.is_reported" :placeholder="'举报'" clearable class="filter-item" style="width: 100px">
<el-option v-for="item in ReBooleanTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/> <el-option v-for="item in ReBooleanTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
</el-select> </el-select>
<el-select v-model="listQuery.filter.is_puppet" :placeholder="'马甲'" clearable class="filter-item" style="width: 100px">
<el-option v-for="item in ReBooleanTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
</el-select>
<el-select v-model="listQuery.filter.content_level" :placeholder="'帖子星级'" clearable class="filter-item" style="width: 100px">
<el-option v-for="item in ContentLevelTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
</el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">搜索</el-button> <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">搜索</el-button>
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleCreate">创建</el-button> <el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleCreate">创建</el-button>
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleOfflineOrOnline('offline')">下线</el-button> <el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleOfflineOrOnline('offline')">下线</el-button>
...@@ -18,58 +26,64 @@ ...@@ -18,58 +26,64 @@
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleOfflineOrOnline('is_reported')">推荐</el-button> <el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleOfflineOrOnline('is_reported')">推荐</el-button>
</div> </div>
<el-table v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%" ref="multipleTable" @selection-change="handleSelectionChange"> <el-table v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%" ref="multipleTable" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center"></el-table-column> <el-table-column type="selection" align="center"></el-table-column>
<el-table-column align="center" label="帖子ID " width="70"> <el-table-column align="center" label="帖子ID " >
<template slot-scope="scope"> <template slot-scope="scope">
<router-link :to="'/pick/edit/'+scope.row.id" class="link-type"> <router-link :to="'/topic/edit/'+scope.row.id" class="link-type">
<span>{{ scope.row.id }}</span> <span>{{ scope.row.id }}</span>
</router-link> </router-link>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="70px" align="center" label="用户"> <el-table-column align="center" label="用户">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.user_name }}</span> <span>{{ scope.row.user.name }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="204px" align="center" label="帖子详情"> <el-table-column align="center" label="帖子详情">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.content }}</span> <span>{{ scope.row.content }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="130px" align="center" label="最新回复"> <el-table-column align="center" label="最新回复">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.newly_reply }}</span> <span>{{ scope.row.newly_reply }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="80px" align="center" label="小组"> <el-table-column align="center" label="小组">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.group_name }}</span> <span>{{ scope.row.group.name }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="155px" align="center" label="更新时间"> <el-table-column align="center" label="更新时间">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.update_time }}</span> <span>{{ scope.row.update_time }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="155px" align="center" label="举报时间"> <el-table-column align="center" label="举报时间">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.reported_time? scope.row.reported_time: '无' }}</span> <span>{{ scope.row.reported_time? scope.row.reported_time: '无' }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="70px" align="center" label="下线"> <el-table-column align="center" label="帖子星级">
<template slot-scope="scope">
<span>{{ scope.row.content_level }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="下线">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag :type="scope.row.is_online | isOnlineFilter">{{ scope.row.is_online==1 ? '是' : '否' }}</el-tag> <el-tag :type="scope.row.is_online | isOnlineFilter">{{ scope.row.is_online==1 ? '是' : '否' }}</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column width="70px" align="center" label="推荐"> <el-table-column align="center" label="推荐">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag :type="scope.row.is_reported | isOnlineFilter">{{ scope.row.is_reported==1 ? '是' : '否' }}</el-tag> <el-tag :type="scope.row.is_reported | isOnlineFilter">{{ scope.row.is_reported==1 ? '是' : '否' }}</el-tag>
</template> </template>
...@@ -77,7 +91,7 @@ ...@@ -77,7 +91,7 @@
</el-table> </el-table>
<pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" style="margin-left: 150px;" @pagination="getList" /> <pagination v-show="total>0" :total="total" :page="listQuery.page" :limit="listQuery.limit" style="margin-left: 150px;" @pagination="getList" />
</div> </div>
</template> </template>
...@@ -116,13 +130,15 @@ export default { ...@@ -116,13 +130,15 @@ export default {
multipleSelection: [], multipleSelection: [],
del_list: [], del_list: [],
listQuery: { listQuery: {
page: 1, page: 0,
limit: 10, limit: 10,
filter: { filter: {
value: '', value: '',
key: '', key: '',
is_online: '', is_online: '',
is_reported: '', complaints__isnull: '',
user__is_puppet: '',
content_level: ''
}, },
}, },
BooleanTypeOptions: [ BooleanTypeOptions: [
...@@ -135,9 +151,15 @@ export default { ...@@ -135,9 +151,15 @@ export default {
], ],
SearchTypeOptions:[ SearchTypeOptions:[
{'key': 'id', 'display_name': '帖子ID'}, {'key': 'id', 'display_name': '帖子ID'},
{'key': 'group__name', 'display_name': '小组名称'}, {'key': 'content', 'display_name': '帖子内容'},
{'key': 'content', 'display_name': '明星名称'}, ],
] ContentLevelTypeOptions:[
{'key': 1, 'display_name': '星级一'},
{'key': 2, 'display_name': '星级二'},
{'key': 3, 'display_name': '星级三'},
{'key': 4, 'display_name': '星级四'},
{'key': 5, 'display_name': '星级五'},
],
} }
}, },
created() { created() {
...@@ -147,6 +169,7 @@ export default { ...@@ -147,6 +169,7 @@ export default {
getList() { getList() {
this.listLoading = true this.listLoading = true
fetchList(this.listQuery).then(response => { fetchList(this.listQuery).then(response => {
console.log(response.data.data)
this.list = response.data.data.data this.list = response.data.data.data
this.total = response.data.data.total this.total = response.data.data.total
this.listLoading = false this.listLoading = false
...@@ -184,7 +207,7 @@ export default { ...@@ -184,7 +207,7 @@ export default {
}) })
}, },
handleFilter() { handleFilter() {
this.listQuery.page = 1 this.listQuery.page = 0
this.getList() this.getList()
}, },
handleCreate() { handleCreate() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment