Commit 932a0316 authored by Davve's avatar Davve

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

parent ba219b88
......@@ -3,6 +3,7 @@
# __author__ = "chenwei"
# Date: 2018/11/16
from django.conf import settings
from utils.base import APIView
......@@ -95,7 +96,7 @@ class LoginView(APIView):
username = request.POST.get('username')
password = request.POST.get('password')
if username == 'admin' and password == '123123':
if username == settings.USERNAME and password == settings.PASSWORD:
data = {
'id': 1,
'roles': ['admin'],
......
......@@ -5,7 +5,7 @@
import datetime
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):
......@@ -31,10 +31,8 @@ class PushUpdateOrCreateView(APIView):
def post(self, request):
id = request.POST.get('id', '')
try:
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')
push_time = analysis_time(request.POST.get('push_time', 0))
data = {
'url': request.POST.get('url', ''),
'push_time': push_time,
......
......@@ -3,32 +3,126 @@
# __author__ = "chenwei"
# Date: 2018/11/15
import json
from utils.base import APIView
from utils.time_utils import analysis_time
class TopicListView(APIView):
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))
filter = self.handle_filter(request.GET.get('filter', ""))
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:
# 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 = {
'total': 200,
'data':[
{"id": "1", "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': 1, 'is_reported': 0},
{"id": "2", "content": '内容', 'newly_reply': '最新回复', 'group_name': '小组名', 'update_time': '2019-09-18 23:59:59',
'reported_time': '2019-09-18 23:59:59', 'user_name': 'alex','is_online': 0, 'is_reported': 0},
{"id": "3", "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': 1, 'is_reported': 1},
{"id": "4", "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': 1, 'is_reported': 1},
{"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},
'topic_images': topic_images,
'topic_ids': json.loads(request.POST.get('topic_ids', '')),
'video_url': request.POST.get('video_url', ''),
'posting_time': posting_time,
'content': request.POST.get('content', ''),
'content_level': request.POST.get('content_level', ''),
'group_name': request.POST.get('group_name', ''),
'user_id': request.POST.get('user_id', ''),
'star_name': request.POST.get('star_name', ''),
'tag_ids': json.loads(request.POST.get('tag_ids', [])),
}
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 = [
# topic相关
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相关
url(r'star/list$', StarListView.as_view()),
......
......@@ -138,3 +138,7 @@ QINIU_ACCESS_KEY = "UPCOYIJkZOMcdd9FDzpBqYjzWUh55fBpVi3AhWpL"
QINIU_SECRET_KEY = "z5YvpDDSam_JE345Z8J_f3TufzelOW2VOGNoBl9e"
QINIU_HOST = "http://wanmeizhensuo.qiniudn.com/"
QINIU_SCOPE = 'wanmeizhensuo'
# 超级管理员
USERNAME = 'admin'
PASSWORD = 'admin'
\ No newline at end of file
......@@ -2,7 +2,7 @@ import request from '@/utils/request'
export function userSearch(name) {
return request({
url: '/search/user',
url: '/api/search/user',
method: 'get',
params: { name }
})
......
......@@ -19,13 +19,12 @@ export function OffLineOrOnLine(data) {
export function createRemark(data) {
return request({
url: '/api/topic/create_remark',
url: '/api/topic/reply/create',
method: 'post',
data
})
}
export function fetchTopic(id) {
return request({
url: '/api/topic/detail',
......@@ -33,3 +32,27 @@ export function fetchTopic(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 {
},
page: {
type: Number,
default: 1
default: 0
},
limit: {
type: Number,
......
......@@ -31,9 +31,6 @@ Mock.mock(/\/article\/create/, 'post', articleAPI.createArticle)
Mock.mock(/\/article\/update/, 'post', articleAPI.updateArticle)
// 搜索相关
Mock.mock(/\/search\/user/, 'get', remoteSearchAPI.searchUser)
// 账单相关
Mock.mock(/\/transaction\/list/, 'get', transactionAPI.getList)
export default Mock
......@@ -55,7 +55,7 @@ export default {
}
}
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'))
} else {
callback()
......@@ -64,7 +64,7 @@ export default {
return {
loginForm: {
username: 'admin',
password: '123123'
password: 'admin'
},
loginRules: {
username: [{ required: true, trigger: 'blur', validator: validateUsername }],
......
......@@ -241,6 +241,7 @@
this.postForm.region = Assembledata(this.temparray['region'], this.postForm.region);
this.postForm.pick_group = Assembledata(this.temparray['pick_group'], this.postForm.pick_group);
}else{
this.postForm.region = this.postForm.region.join(',')
this.postForm.region = this.postForm.region.join(',')
this.postForm.pick_group = this.postForm.pick_group.join(',')
}
......
......@@ -10,7 +10,7 @@
<el-row :gutter="20">
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>明星相关</span>
<span>帖子相关</span>
</div>
<el-row>
<el-col :span="24">
......@@ -24,7 +24,7 @@
</el-col>
<el-col :span="12">
<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/>
</el-form-item>
</el-col>
......@@ -32,38 +32,41 @@
<el-row>
<el-col :span="12">
<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">
<el-option v-for="(item,index) in groupListOptions" :key="item+index" :label="item"
:value="item"/>
<el-option v-for="(item,index) in userListOptions" :key="item+index" :label="item.name" :value="item.id"/>
</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-col>
<el-col :span="12">
<el-form-item label-width="75px" label="发帖时间:" class="postInfo-container-item">
<el-date-picker v-model="postForm.posting_time " type="datetime" format="yyyy-MM-dd HH:mm:ss"
placeholder="选择日期时间" style="width: 230px"/>
<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"
:picker-options="expireTimeOption"
placeholder="选择日期时间"
style="width: 230px"
/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label-width="75px" label="明星名称:" class="postInfo-container-item">
<el-select v-model="postForm.author" :remote-method="getRemoteStarList" filterable remote
placeholder="搜索小组" style="width: 230px">
<el-option v-for="(item,index) in userListOptions" :key="item+index" :label="item"
:value="item"/>
<el-select v-model="postForm.star_name" :remote-method="getRemoteStarList" filterable remote
placeholder="搜索明星" style="width: 230px">
<el-option v-for="(item,index) in starListOptions" :key="item+index" :label="item.name" :value="item.id"/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label-width="75px" label="小组名称:" class="postInfo-container-item">
<el-select v-model="postForm.author" :remote-method="getRemoteGroupList" filterable remote
placeholder="搜索用户" style="width: 230px">
<el-option v-for="(item,index) in userListOptions" :key="item+index" :label="item"
:value="item"/>
<el-select v-model="postForm.group_name" :remote-method="getRemoteGroupList" filterable remote
placeholder="搜索小组" style="width: 230px">
<el-option v-for="(item,index) in groupListOptions" :key="item+index" :label="item.name" :value="item.id"/>
</el-select>
</el-form-item>
</el-col>
......@@ -71,7 +74,7 @@
<el-row>
<el-col :span="12">
<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">
<el-option v-for="item in TopicLevelOptions" :key="item.key" :label="item.display_name"
:value="item.key"/>
......@@ -81,10 +84,9 @@
<el-col :span="12">
<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">
<el-option v-for="(item,index) in tagListOptions" :key="item+index" :label="item"
:value="item"/>
<el-option v-for="(item,index) in tagListOptions" :key="item+index" :label="item.name" :value="item.id"/>
</el-select>
</el-form-item>
</el-col>
......@@ -92,6 +94,12 @@
</div>
</el-col>
</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-input :rows="1" v-model="postForm.content" type="textarea" class="article-textarea" autosize
placeholder="请输入内容"/>
......@@ -99,9 +107,9 @@
</el-form-item>
<div class="item real">
<div class="name">
<span>帖子图片</span>
<span style="color: #606266;text-align:center;font-size:14px;padding:0 12px 0 0;">帖子图片</span>
</div>
<div class="value">
<div class="value" style="margin-left: 50px">
<edit-upload :value="edit.hospital_pics" @input="uploadPics" multiple :limit="9" :uploadType="'26'"
@limit="uploadRealLimit"></edit-upload>
<div class="error_icon" v-show="showHospitalPicTip">
......@@ -117,9 +125,9 @@
<div v-if="hide">
<div class="item video">
<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 class="value">
<div class="value" style="margin-left: 50px">
<div class="up-video">
<ul class="video-items clearfix" v-if="edit.video_url">
<li class="video-item" @click.stop="playVideo">
......@@ -154,50 +162,52 @@
</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">
<div slot="header" class="clearfix">
<span>帖子相关</span>
<span>评论相关</span>
</div>
<div style="margin-bottom:50px;">
<div class="filter-container">
<el-button class="filter-item" type="primary" icon="el-icon-edit" @click="handleCreate">回复</el-button>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-delete" @click="delUser">下线
<el-select v-model="listQuery.filter.replyType" :placeholder="'评论搜索'" clearable class="filter-item" style="width: 120px">
<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>
</div>
<el-table :data="list" 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 ">
<el-table-column align="center" label="帖子ID ">
<template slot-scope="scope">
<router-link :to="'/push/edit/'+scope.row.id" class="link-type">
<span>{{ scope.row.id }}</span>
</router-link>
</template>
</el-table-column>
<el-table-column align="center" label="评论用户">
<template slot-scope="scope">
<span>{{ scope.row.username }}</span>
<span>{{ scope.row.reply_name }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="被评论用户">
<template slot-scope="scope">
<span>{{ scope.phone }}</span>
<span>{{ scope.row.be_reply_name }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="评论时间">
<template slot-scope="scope">
<span>{{ scope.row.topic_nums }}</span>
<span>{{ scope.row.create_time }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="贴主评论">
<template slot-scope="scope">
<span>{{ scope.row.user_identity }}</span>
<span>{{ scope.row.reply_type }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="评论内容">
<template slot-scope="scope">
<span>{{ scope.row.internal_identity }}</span>
<span>{{ scope.row.content }}</span>
</template>
</el-table-column>
......@@ -215,29 +225,28 @@
<el-dialog :visible.sync="dialogFormVisible">
<el-form ref="dataForm" :rules="rules" :model="temp" label-position="left" label-width="70px"
style="width: 400px; margin-left:50px;">
<el-form-item :label="'被评论用户'" prop="be_remarked_user">
<el-select v-model="temp.be_remarked_user" :remote-method="getRemoteUserList" filterable remote multiple
<el-form-item :label="'被评论用户'" prop="be_reply_name">
<el-select v-model="temp.be_reply_name" :remote-method="getRemoteUserList" filterable remote
value-key="id"
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-form-item>
<el-form-item :label="'评论用户'" prop="remark_user">
<el-select v-model="temp.remark_user" :remote-method="getRemoteUserList" filterable remote
<el-form-item :label="'评论用户'" prop="reply_name">
<el-select v-model="temp.reply_name" :remote-method="getRemoteUserList" filterable remote
value-key="id"
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-form-item>
<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"/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button @click="dialogFormVisible = false">{{ $t('table.cancel') }}</el-button>
<el-button type="primary" @click="dialogStatus==='create'?createData():updateData()">{{ $t('table.confirm') }}
</el-button>
<el-button @click="dialogFormVisible = false">取消</el-button>
<el-button type="primary" @click="dialogStatus==='create'?createData():updateData()">确认</el-button>
</div>
</el-dialog>
......@@ -254,25 +263,39 @@
import Modal from '@/components/Modal'
import VideoPlayer from '@/components/Video'
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 {getToken} from '@/api/qiniu'
import {postVideo} from '@/api/upload'
import {userSearch, groupSearch, starSearch, tagSearch} from '@/api/remoteSearch'
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 defaultForm = {
status: 'draft',
title: '', // 文章题目
id: '',
posting_time: '',
content: '',
source_uri: '', // 文章外链
image_uri: '', // 文章图片
display_time: undefined, // 前台展示时间
id: undefined,
platforms: ['a-platform'],
comment_disabled: false,
posting_time: undefined,
topic_ids: [],
content_level: '',
group_name: '',
user_name: '',
star_name: '',
is_puppet: '',
tag_ids: [],
is_online: '',
}
export default {
......@@ -300,16 +323,46 @@
return {
postForm: Object.assign({}, defaultForm),
loading: false,
// 搜索相关
userListOptions: [],
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: {
video_url: '',
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: {},
TopicLevelOptions: [
{'key': 1, 'display_name': '1星'},
......@@ -325,14 +378,12 @@
areaType: 1,
multipleSelection: [],
tagListOptions: [],
del_list: [],
is_puppet: 0,
listQuery: {
page: 0,
limit: 10,
filter: {
value: '',
key: '',
replyType: ''
},
},
......@@ -379,6 +430,7 @@
if (this.isEdit) {
const id = this.$route.params && this.$route.params.id
this.fetchData(id)
this.getList(id)
} else {
this.postForm = Object.assign({}, defaultForm)
getToken().then(response => {
......@@ -390,34 +442,78 @@
methods: {
fetchData(id) {
fetchTopic(id).then(response => {
this.postForm = response.data
// Just for test
this.postForm.title += ` Article Id:${this.postForm.id}`
this.postForm.content_short += ` Article Id:${this.postForm.id}`
let star = response.data.data.data.star
let group = response.data.data.data.group
let user = response.data.data.data.user
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 => {
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
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({
title: '成功',
message: '发布文章成功',
message: response.data.data.message,
type: 'success',
duration: 2000
})
setTimeout(() => {
this.$router.push('/topic/list')
}, 1000)
}).catch(err => {
this.$notify({
title: '失败',
message: '操作失败',
type: 'danger',
duration: 2000
})
});
this.postForm.status = 'published'
this.loading = false
} else {
......@@ -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) {
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
})
},
getRemoteGroupList(query) {
groupSearch(query).then(response => {
if (!response.data.items) return
this.userListOptions = response.data.data.data
if (!response.data.data.data) return
this.groupListOptions = response.data.data.data
})
},
getRemoteStarList(query) {
starSearch(query).then(response => {
if (!response.data.items) return
this.userListOptions = response.data.data.data
if (!response.data.data.data) return
this.starListOptions = response.data.data.data
})
},
getRemoteTagList(query) {
tagSearch(query).then(response => {
if (!response.data.items) return
this.userListOptions = response.data.data.data
if (!response.data.data.data) return
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
fetchList(this.listQuery).then(response => {
this.list = []
this.total = 100
this.listQuery.id = id
fetchReply(this.listQuery).then(response => {
this.list = response.data.data.data
this.total = response.data.data.total
this.listLoading = false
})
},
// 图片上传
dropzoneS(file) {
console.log(file)
this.$message({message: 'Upload success', type: 'success'})
......@@ -488,19 +589,6 @@
console.log(file)
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) {
this.edit.hospital_pics = images
},
......@@ -513,6 +601,20 @@
hide() {
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) {
let file = e.target.files[0]
......@@ -596,16 +698,12 @@
resetTemp() {
this.temp = {
id: undefined,
importance: 1,
remark: '',
timestamp: new Date(),
title: '',
status: 'published',
type: ''
'reply_name': '',
'be_reply_name': '',
'content': '',
}
},
handleCreate() {
reply() {
this.resetTemp()
this.dialogStatus = 'create'
this.dialogFormVisible = true
......@@ -616,13 +714,11 @@
createData() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
this.temp.id = parseInt(Math.random() * 100) + 1024 // mock a id
this.temp.author = 'vue-element-admin'
createRemark(this.temp).then(() => {
this.list.unshift(this.temp)
this.temp.topic_id = this.postForm.id
createRemark(this.temp).then((response) => {
this.list.push(response.data.data.data)
this.dialogFormVisible = false
this.$notify({
title: '成功',
message: '创建成功',
type: 'success',
duration: 2000
......@@ -632,6 +728,10 @@
})
},
handleFilter() {
this.listQuery.page = 0
this.getList(this.postForm.id);
},
}
}
</script>
......
......@@ -11,6 +11,14 @@
<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-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 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>
......@@ -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>
</div>
<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 align="center" label="帖子ID " width="70">
<el-table-column type="selection" align="center"></el-table-column>
<el-table-column align="center" label="帖子ID " >
<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>
</router-link>
</template>
</el-table-column>
<el-table-column width="70px" align="center" label="用户">
<el-table-column align="center" label="用户">
<template slot-scope="scope">
<span>{{ scope.row.user_name }}</span>
<span>{{ scope.row.user.name }}</span>
</template>
</el-table-column>
<el-table-column width="204px" align="center" label="帖子详情">
<el-table-column align="center" label="帖子详情">
<template slot-scope="scope">
<span>{{ scope.row.content }}</span>
</template>
</el-table-column>
<el-table-column width="130px" align="center" label="最新回复">
<el-table-column align="center" label="最新回复">
<template slot-scope="scope">
<span>{{ scope.row.newly_reply }}</span>
</template>
</el-table-column>
<el-table-column width="80px" align="center" label="小组">
<el-table-column align="center" label="小组">
<template slot-scope="scope">
<span>{{ scope.row.group_name }}</span>
<span>{{ scope.row.group.name }}</span>
</template>
</el-table-column>
<el-table-column width="155px" align="center" label="更新时间">
<el-table-column align="center" label="更新时间">
<template slot-scope="scope">
<span>{{ scope.row.update_time }}</span>
</template>
</el-table-column>
<el-table-column width="155px" align="center" label="举报时间">
<el-table-column align="center" label="举报时间">
<template slot-scope="scope">
<span>{{ scope.row.reported_time? scope.row.reported_time: '无' }}</span>
</template>
</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">
<el-tag :type="scope.row.is_online | isOnlineFilter">{{ scope.row.is_online==1 ? '是' : '否' }}</el-tag>
</template>
</el-table-column>
<el-table-column width="70px" align="center" label="推荐">
<el-table-column align="center" label="推荐">
<template slot-scope="scope">
<el-tag :type="scope.row.is_reported | isOnlineFilter">{{ scope.row.is_reported==1 ? '是' : '否' }}</el-tag>
</template>
......@@ -77,7 +91,7 @@
</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>
</template>
......@@ -116,13 +130,15 @@ export default {
multipleSelection: [],
del_list: [],
listQuery: {
page: 1,
page: 0,
limit: 10,
filter: {
value: '',
key: '',
is_online: '',
is_reported: '',
complaints__isnull: '',
user__is_puppet: '',
content_level: ''
},
},
BooleanTypeOptions: [
......@@ -135,9 +151,15 @@ export default {
],
SearchTypeOptions:[
{'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() {
......@@ -147,6 +169,7 @@ export default {
getList() {
this.listLoading = true
fetchList(this.listQuery).then(response => {
console.log(response.data.data)
this.list = response.data.data.data
this.total = response.data.data.total
this.listLoading = false
......@@ -184,7 +207,7 @@ export default {
})
},
handleFilter() {
this.listQuery.page = 1
this.listQuery.page = 0
this.getList()
},
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