Commit 89443bb1 authored by Davve's avatar Davve

完成用户创建接口

parent 932a0316
......@@ -3,32 +3,33 @@
# __author__ = "chenwei"
# Date: 2018/11/15
import json
from utils.base import APIView
class GroupListView(APIView):
def get(self, request):
offset = int(request.GET.get('page', 0))
count = int(request.GET.get('limit', 10))
limit = int(request.GET.get('limit', 10))
filters = self.handle_filter(request.GET.get('filter', ""))
try:
data = self.rpc['venus/community/group/list'](filters=filters, offset=offset, count=count).unwrap()
data = self.rpc['venus/sun/group/list'](filters=filters, offset=(offset-1)*limit, limit=limit).unwrap()
except Exception as e:
raise e
return data
def post(self, request):
group_ids = request.POST.get('ids', '').split()
ids = request.POST.get('ids', '').split()
type = request.POST.get('type')
filters = {}
updates = {}
if type == 'offline':
filters['is_online'] = False
elif type == 'recommend':
filters['is_recommend'] = True
updates['is_online'] = False
elif type == 'is_recommend':
updates['is_recommend'] = True
else:
filters['is_online'] = True
updates['is_online'] = True
try:
self.rpc['venus/community/group/batch/update'](filters=filters, group_ids=group_ids).unwrap()
self.rpc['venus/sun/group/batch/update'](updates=updates, ids=ids).unwrap()
except Exception as e:
raise e
return {
......@@ -43,7 +44,46 @@ class GroupUpdateOrCreate(APIView):
data = self.rpc['venus/sun/group/get'](id=id).unwrap()
except Exception as e:
raise e
return [data]
return data
def post(self, request):
pass
\ No newline at end of file
id = request.POST.get('id')
data = {
'name': request.POST.get('name', ''),
'description': request.POST.get('description', ''),
'creator_id': request.POST.get('group_leader', ''),
'star_ids': json.loads(request.POST.get('star', '')).split(','), # TODO是否需要加
'is_online': request.POST.get('is_online', ''),
'is_recommend': request.POST.get('is_recommend', ''),
'user_ids': json.loads(request.POST.get('user_ids', ''))
}
try:
self.rpc['venus/sun/group/edit'](id=id, data=data).unwrap()
except Exception as e:
raise e
return {
'message': '更新成功'
}
class GroupRelatedUser(APIView):
def get(self, request):
id = request.GET.get('id')
offset = int(request.GET.get('page', 0))
count = int(request.GET.get('limit', 10))
filters = {'group_id': id}
try:
data = self.rpc['venus/sun/group/user/list'](filters=filters, offset=offset, limit=count).unwrap()
except Exception as e:
raise e
return data
class GroupRelatedUserGET(APIView):
def get(self, request):
id = request.GET.get('id')
try:
data = self.rpc['venus/sun/group/user/get'](id=id).unwrap()
except Exception as e:
raise e
return [data, ]
......@@ -2,10 +2,9 @@
# -*- coding: utf-8 -*-
# __author__ = "chenwei"
# Date: 2018/11/15
import datetime
from utils.base import APIView
from utils.time_utils import utc_to_datetime, unix_time_to_datetime, analysis_time
from utils.time_utils import analysis_time
class PushListView(APIView):
......
......@@ -13,7 +13,7 @@ class StarListView(APIView):
limit = int(request.GET.get('limit', 10))
filter = self.handle_filter(request.GET.get('filter', ""))
try:
data = self.rpc['venus/sun/star/list'](offset=page, limit=limit, filters=filter).unwrap()
data = self.rpc['venus/sun/star/list'](offset=(page-1)*limit, limit=limit, filters=filter).unwrap()
except Exception as e:
raise e
return data
......@@ -57,7 +57,7 @@ class StarRelatedGroup(APIView):
count = int(request.GET.get('limit', 10))
filters = {'star_id': id}
try:
data = self.rpc['venus/sun/group/list'](filters=filters, offset=offset, limit=count).unwrap()
data = self.rpc['venus/sun/group/list'](filters=filters, offset=(offset-1) * count, limit=count).unwrap()
except Exception as e:
raise e
return data
......@@ -10,11 +10,11 @@ from utils.time_utils import analysis_time
class TopicListView(APIView):
def get(self, request):
page = int(request.GET.get('page', 0))
offset = 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/sun/topic/list'](offset=page, limit=limit, filters=filter).unwrap()
data = self.rpc['venus/sun/topic/list'](offset=(offset - 1) * limit, limit=limit, filters=filter).unwrap()
except Exception as e:
raise e
return data
......@@ -24,7 +24,7 @@ class TopicUpdateOrCreateView(APIView):
def get(self, request):
id = request.GET.get('id')
try: # TODO 少返回了is_online
try:
data = self.rpc['venus/sun/topic/get'](id=id).unwrap()
except Exception as e:
raise e
......@@ -38,14 +38,14 @@ class TopicUpdateOrCreateView(APIView):
data = {
'topic_images': topic_images,
'topic_ids': json.loads(request.POST.get('topic_ids', '')),
# 'reply_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', ''),
'group_id': request.POST.get('group_name', ''),
'user_id': request.POST.get('user_name', ''),
'star_id': request.POST.get('star_name', ''),
'tag_ids': json.loads(request.POST.get('tag_ids', [])),
}
try:
......@@ -60,28 +60,15 @@ class TopicUpdateOrCreateView(APIView):
class ReplyUpdateOrCreateView(APIView):
def get(self, request):
id = request.GET.get('id')
page = int(request.GET.get('page', 0))
offset = 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})
filter.update({'topic_id': id})
try:
data = self.rpc['venus/sun/topic/reply/list'](offset=page, limit=limit, filters=filter).unwrap()
data = self.rpc['venus/sun/topic/reply/list'](offset=(offset-1) * limit, 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
}
raise e
return data
def post(self, request):
reply_ids = json.loads(request.POST.get('reply_ids', []))
......@@ -97,32 +84,14 @@ class ReplyUpdateOrCreateView(APIView):
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'),
'user_id': request.POST.get('user_id'),
'replied_id': request.POST.get("replied_id", None),
'topic_id': request.POST.get("topic_id", None),
'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': '测试测试',
}
"""
data = self.rpc['venus/sun/topic/reply/edit'](id=None, data=data).unwrap()
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': '测试测试',
}
raise e
return {'data': data}
......@@ -20,35 +20,41 @@ from .token import *
urlpatterns = [
# 登陆,注销相关
url(r'account/login$', LoginView.as_view()),
url(r'account/logout$', LogoutView.as_view()),
url(r'account/get$', LoginView.as_view()),
url(r'^account/login$', LoginView.as_view()),
url(r'^account/logout$', LogoutView.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/create$', AccountUpdateOrCreateView.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/create$', AccountUpdateOrCreateView.as_view()),
# user相关
url(r'user/list$', UserListView.as_view()),
url(r'^user/list$', UserListView.as_view()),
url(r'^user/get$', UserUpdateOrCreate.as_view()),
url(r'^user/create$', UserUpdateOrCreate.as_view()),
url(r'^user/group/list$', UserGroupView.as_view()),
# group相关
url(r'group/list$', GroupListView.as_view()),
url(r'group/update$', GroupListView.as_view()),
url(r'group/detail', GroupUpdateOrCreate.as_view()),
url(r'^group/list$', GroupListView.as_view()),
url(r'^group/list/update$', GroupListView.as_view()),
url(r'^group/get$', GroupUpdateOrCreate.as_view()),
url(r'group/create$', GroupUpdateOrCreate.as_view()),
url(r'^group/user/list$', GroupRelatedUser.as_view()),
url(r'^group/user/get$', GroupRelatedUserGET.as_view()),
# 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()),
url(r'^topic/list$', TopicListView.as_view()),
url(r'^topic/detail$', TopicUpdateOrCreateView.as_view()),
url(r'^topic/create$', 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()),
url(r'star/create', StarUpdateOrCreate.as_view()),
url(r'star/detail', StarUpdateOrCreate.as_view()),
url(r'star/star_related_group_info', StarRelatedGroup.as_view()),
url(r'^star/list$', StarListView.as_view()),
url(r'^star/create$', StarUpdateOrCreate.as_view()),
url(r'^star/detail$', StarUpdateOrCreate.as_view()),
url(r'^star/star_related_group_info', StarRelatedGroup.as_view()),
# push相关
url(r'push/list$', PushListView.as_view()),
......
......@@ -3,7 +3,9 @@
# __author__ = "chenwei"
# Date: 2018/11/15
import json
from utils.base import APIView
from utils.time_utils import analysis_time
class UserListView(APIView):
......@@ -12,20 +14,56 @@ class UserListView(APIView):
limit = int(request.GET.get('limit', 10))
filter = self.handle_filter(request.GET.get('filter', ""))
try:
data = self.rpc['venus/community/user/get'](offset=page, limit=limit, filters=filter).unwrap()
data = self.rpc['venus/sun/user/list'](offset=(page-1)*limit, limit=limit, filters=filter).unwrap()
except Exception as e:
data = {
'total': 200,
'data': [
{"id": 1, 'username': 'alex', 'phone': '12345678912', 'email': 'http://www.baid.com', 'group_nums': 23,
'topic_num': 12, 'group_identify': '组长,长老', 'user_identify': '普通用户', 'is_recommend': 1},
{"id": 2, 'username': 'ttt', 'phone': '12345678912', 'email': 'http://www.baid.com', 'group_nums': 23,
'topic_num': 12, 'group_identify': '长老', 'user_identify': '马甲用户', 'is_recommend': 0},
{"id": 3, 'username': 'xcc', 'phone': '12345678912', 'email': 'http://www.baid.com', 'group_nums': 23,
'topic_num': 12, 'group_identify': '精英', 'user_identify': '普通用户', 'is_recommend': 1},
{"id": 4, 'username': 'aaa', 'phone': '12345678912', 'email': 'http://www.baid.com', 'group_nums': 23,
'topic_num': 12, 'group_identify': '高级会有', 'user_identify': '马甲用户', 'is_recommend': 0},
]
raise e
return data
class UserUpdateOrCreate(APIView):
def get(self, request):
id = request.GET.get('id')
try:
data = self.rpc['venus/sun/user/get'](id=id).unwrap()
except Exception as e:
raise e
return data
def post(self, request):
id = request.POST.get('id', '')
show_time = analysis_time(request.POST.get('show_time', 0))
data = {
'is_recommend': request.POST.get('is_recommend'),
'avatar': request.POST.get('avatar'),
'nick_name': request.POST.get('nick_name'),
'tag_ids': request.POST.get('tag_ids'),
'is_puppet': request.POST.get('is_puppet'),
'city': request.POST.get('city'),
'show_time': show_time,
'phone': request.POST.get('phone'),
'email': request.POST.get('email'),
'gender': request.POST.get('gender'),
'group_ids': json.loads(request.POST.get('group_ids')),
}
return data
\ No newline at end of file
try:
self.rpc['venus/sun/user/edit'](id=id, data=data).unwrap()
except Exception as e:
raise e
return {
'message': '更新成功'
}
class UserGroupView(APIView):
def get(self, request):
user_id = request.GET.get('id')
try:
data = self.rpc['venus/sun/user/group/list'](user_id=user_id).unwrap()
except Exception as e:
raise e
return {
'total': 1,
'data': data
}
\ No newline at end of file
......@@ -10,7 +10,7 @@ export function fetchList(query) {
export function OffLineOrOnLine(data) {
return request({
url: '/api/group/update',
url: '/api/group/list/update',
method: 'post',
data
})
......@@ -18,8 +18,33 @@ export function OffLineOrOnLine(data) {
export function GroupDetail(id) {
return request({
url: '/api/group/detail',
url: '/api/group/get',
method: 'get',
params: { id }
})
}
export function createGroup(data) {
return request({
url: '/api/group/create',
method: 'post',
data
})
}
export function fetchGroupRelateduser(query) {
return request({
url: '/api/group/user/list',
method: 'get',
params: query
})
}
export function GroupUserDetail(id) {
return request({
url: '/api/group/user/get',
method: 'get',
params: { id }
})
}
......@@ -56,3 +56,11 @@ export function DelReply(data) {
data
})
}
export function ModifyReply(data) {
return request({
url: '/api/topic/reply/create',
method: 'post',
data
})
}
......@@ -16,3 +16,28 @@ export function OffLineOrOnLine(data) {
data
})
}
export function UserDetail(id) {
return request({
url: '/api/user/get',
method: 'get',
params: { id }
})
}
export function fetchGroupUser(query) {
return request({
url: '/api/user/group/list',
method: 'get',
params: query
})
}
export function userCreate(data) {
return request({
url: '/api/user/create',
method: 'post',
data,
})
}
......@@ -21,7 +21,7 @@ Mock.XHR.prototype.send = function() {
// 登录相关
Mock.mock(/\/login\/login/, 'post', loginAPI.loginByUsername)
Mock.mock(/\/login\/logout/, 'post', loginAPI.logout)
Mock.mock(/\/user\/info\.*/, 'get', loginAPI.getUserInfo)
// Mock.mock(/\/user\/info\.*/, 'get', loginAPI.getUserInfo)
// 文章相关
Mock.mock(/\/article\/list/, 'get', articleAPI.getList)
......
......@@ -105,7 +105,7 @@ export default {
this.getList()
},
handleFilter() {
this.listQuery.page = 0
this.listQuery.page = 1
this.getList()
},
handleCreate() {
......
......@@ -3,7 +3,7 @@
<el-form ref="postForm" :model="postForm" :rules="rules" class="form-container">
<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>
</sticky>
<div class="createPost-main-container">
......@@ -26,42 +26,54 @@
<el-row>
<el-col :span="8">
<el-form-item label-width="75px" label="明星称号:" class="postInfo-container-item">
<el-select v-model="postForm.star_name" :remote-method="getRemoteStarList" filterable remote multiple value-key="id"
placeholder="搜索明星" style="width: 100%">
<el-option v-for="(item,index) in starListOptions" :key="item+index" :label="item.name" :value="item.id"/>
<el-select
v-model="postForm.star"
:remote-method="getRemoteStarList"
filterable
remote
multiple
reserve-keyword
value-key="id"
placeholder="搜索明星"
style="width: 100%">
<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="8">
<el-form-item label-width="75px" label="小组组长:" class="postInfo-container-item">
<el-select v-model="postForm.group_leader" :remote-method="getRemoteUserList" filterable remote multiple value-key="id"
placeholder="搜索明星" style="width: 100%">
<el-option v-for="(item,index) in starListOptions" :key="item+index" :label="item.name" :value="item.id"/>
<el-select v-model="postForm.user_id" :remote-method="getRemoteUserList" filterable remote
value-key="id"
placeholder="搜索用户" style="width: 100%">
<el-option v-for="(item,index) in userListOptions" :key="item+index" :label="item.name"
:value="item.id"/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item style="margin-bottom: 20px;" label-width="75px" label="组员数量:" prop="user_nums">
<el-input v-model="postForm.user_nums" type="number" placeholder="请输入内容" style="width: 230px;" readonly/>
<el-input v-model="postForm.user_nums" type="number" placeholder="请输入内容" style="width: 230px;"
disabled/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<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-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-col>
<el-col :span="8">
<el-form-item style="margin-bottom: 20px;" label-width="75px" label="推荐小组:">
<el-radio-group v-model="postForm.is_recommend">
<el-radio :label="1"></el-radio>
<el-radio :label="0"></el-radio>
</el-radio-group>
</el-form-item>
<el-radio-group v-model="postForm.is_recommend">
<el-radio :label="1"></el-radio>
<el-radio :label="0"></el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="8">
......@@ -86,47 +98,50 @@
</div>
<div style="margin-bottom:50px;">
<div class="filter-container">
<el-input :placeholder="'添加用户'" v-model="listQuery.filter.value" style="width: 180px;"
class="filter-item"
@keyup.enter.native="appendUser"/>
<el-select v-model="temp_user_ids" :remote-method="getRemoteUserList" filterable remote
value-key="id"
placeholder="用户" style="width: 220px">
<el-option v-for="(item,index) in userListOptions" :key="item+index" :label="item.id + ':' + item.name" :value="item.id"/>
</el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-edit" @click="appendUser">添加
</el-button>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-delete" @click="delUser">移除
</el-button>
</div>
<el-table :data="list" border fit highlight-current-row style="width: 100%"
<el-table :data="data" border fit highlight-current-row style="width: 100%"
ref="multipleTable" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="76" 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 :to="'/push/edit/'+scope.row.user_id" class="link-type">
<span>{{ scope.row.user_id }}</span>
</router-link>
</template>
</el-table-column>
<el-table-column align="center" label="用户名">
<el-table-column align="center" label="用户名">
<template slot-scope="scope">
<span>{{ scope.row.username }}</span>
<span>{{ scope.row.nick_name }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="联系电话">
<el-table-column align="center" label="联系电话">
<template slot-scope="scope">
<span>{{ scope.phone }}</span>
<span>{{ scope.row.phone }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="发布帖子数">
<el-table-column align="center" label="发布帖子数">
<template slot-scope="scope">
<span>{{ scope.row.topic_nums }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="用户身份">
<el-table-column align="center" label="用户身份">
<template slot-scope="scope">
<span>{{ scope.row.user_identity }}</span>
<span>{{ scope.row.user_identify }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="组内身份">
<el-table-column align="center" label="组内身份" v-if="isEdit">
<template slot-scope="scope">
<span>{{ scope.row.internal_identity }}</span>
<span>{{ scope.row.group_identify }}</span>
</template>
</el-table-column>
......@@ -151,19 +166,35 @@
import waves from '@/directive/waves'
import Pagination from '@/components/Pagination'
import {validateURL} from '@/utils/validate'
import {fetchList} from '@/api/user'
import {createGroup, GroupDetail, fetchGroupRelateduser, GroupUserDetail} from '@/api/group'
import {starSearch, userSearch} from '@/api/remoteSearch'
import { isInArray, removeByvale} from "@/utils";
function Assembledata(target, source) {
var region_data = []
console.log(target, source)
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 defaultForm = {
status: 'draft',
title: '', // 文章题目
name: '', // 文章内容
description: '', // 文章摘要
display_time: undefined, // 前台展示时间
name: '', // 小组名称
description: '', // 小组简介
id: undefined,
user_nums: 0,
group_leader: '',
user_id: '',
star: [],
is_online: 1,
is_recommend: 1,
user_ids: [],
}
export default {
......@@ -188,39 +219,32 @@
callback()
}
}
const validateSourceUri = (rule, value, callback) => {
if (value) {
if (validateURL(value)) {
callback()
} else {
this.$message({
message: '外链url填写不正确',
type: 'error'
})
callback(new Error('外链url填写不正确'))
}
} else {
callback()
}
}
return {
postForm: Object.assign({}, defaultForm),
loading: false,
userListOptions: [],
rules: {
title: [{validator: validateRequire}],
content: [{validator: validateRequire}],
},
tempRoute: {},
temp_user_ids: '',
user_ids: [],
starListOptions: [],
userListOptions: [],
// 小组相关
list: null,
total: 1,
tableData: [],
temp:{
user_id: '',
user_name: '',
user_ids: [],
star_ids: [],
},
del_list: [],
total: 0,
listLoading: true,
multipleSelection: [],
del_list: [],
listQuery: {
page: 0,
limit: 10,
......@@ -235,6 +259,20 @@
contentShortLength() {
return this.postForm.description.length
},
data() {
return this.tableData.filter((d) => {
let is_del = false;
for (let i = 0; i < this.del_list.length; i++) {
if (d.user_id == this.del_list[i].user_id) {
is_del = true;
break
}
}
if (!is_del) {
return d
}
})
}
},
created() {
if (this.isEdit) {
......@@ -249,24 +287,61 @@
},
methods: {
fetchData(id) {
fetchArticle(id).then(response => {
this.postForm = response.data
GroupDetail(id).then(response => {
let rep = response.data.data
let temp_star_list = []
this.postForm = response.data.data
this.temp.user_id = rep.creator.id
this.postForm.user_id = this.temp.user_name = rep.creator.name
// TODO
for (let i = 0;i < rep.star.length; i++){
temp_star_list.push(rep.star[i]['name'])
this.temp.star_ids.push(rep.star[i])
}
this.postForm.star = temp_star_list
}).catch(err => {
console.log(err)
})
},
submitForm() {
this.postForm.display_time = parseInt(this.display_time / 1000)
console.log(this.postForm)
this.$refs.postForm.validate(valid => {
if (valid) {
this.loading = true
this.$notify({
title: '成功',
message: '发布文章成功',
type: 'success',
duration: 2000
})
if (this.postForm.user_id === this.temp.user_name){
this.postForm.user_id = this.temp.user_id
}
let user_ids = []
for (let i = 0;i < this.tableData.length; i++){
user_ids.push(this.tableData[i].user_id)
}
if (this.isEdit){
this.postForm.star = Assembledata(this.temp.star_ids, this.postForm.star)
}
this.postForm.user_ids = JSON.stringify(user_ids);
createGroup(this.postForm).then(response => {
this.$notify({
title: '成功',
message: response.data.data.message,
type: 'success',
duration: 2000
})
setTimeout(() => {
this.$router.push('/group/list')
}, 1000)
}).catch(err => {
this.$notify({
title: '失败',
message: '操作失败',
type: 'danger',
duration: 2000
})
});
this.postForm.status = 'published'
this.loading = false
} else {
......@@ -275,13 +350,6 @@
}
})
},
getRemoteUserList(query) {
userSearch(query).then(response => {
if (!response.data.items) return
this.userListOptions = response.data.items.map(v => v.name)
})
},
// 添加组员相关
handleSelectionChange(val) {
this.multipleSelection = val;
......@@ -295,29 +363,52 @@
this.getList()
},
appendUser() {
if (isInArray(this.user_ids, this.temp_user_ids)) {
this.$message({
message: '数据添加重复',
type: 'error'
})
return false;
}
GroupUserDetail(this.temp_user_ids).then(response => {
if (!response.data.data) return
this.tableData.push(...response.data.data)
this.total = this.tableData.length
})
this.user_ids.push(this.temp_user_ids)
this.temp_user_ids = ''
},
delUser() {
this.del_list.push(...this.multipleSelection)
},
getList() {
this.listLoading = true
fetchList(this.listQuery).then(response => {
this.list = []
this.total = 100
let id = this.$route.params && this.$route.params.id;
this.listQuery.id = this.$route.params && this.$route.params.id
fetchGroupRelateduser(this.list.listQuery).then(response => {
let rep = response.data.data.data
this.tableData = response.data.data.data
this.total = response.data.data.total
for (let i=0;i<rep.length;i++){
this.user_ids.push(rep[i].user_id)
}
this.listLoading = false
})
},
getRemoteStarList(query){
starSearch(query).then(response => {
// 远程搜索
getRemoteUserList(query) {
userSearch(query).then(response => {
if (!response.data.data.data) return
this.starListOptions = response.data.data.data
this.userListOptions = response.data.data.data
})
},
getRemoteUserList(query){
userSearch(query).then(response => {
getRemoteStarList(query) {
starSearch(query).then(response => {
if (!response.data.data.data) return
this.starListOptions = response.data.data.data
console.log(response.data.data.data)
})
},
}
......
......@@ -5,10 +5,17 @@
<el-select v-model="listQuery.filter.key" :placeholder="'搜索字段'" clearable class="filter-item" style="width: 110px">
<el-option v-for="item in SearchTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
</el-select>
<el-select v-model="listQuery.filter.is_online" :placeholder="'是否下线'" clearable class="filter-item" style="width: 110px">
<el-option v-for="item in OnlineTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
</el-select>
<el-select v-model="listQuery.filter.is_recommend" :placeholder="'是否推荐'" clearable class="filter-item" style="width: 110px">
<el-option v-for="item in recommendTypeOptions" :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>
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleOfflineOrOnline('online')">上线</el-button>
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleOfflineOrOnline('is_recommend')">推荐</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" align="center"></el-table-column>
......@@ -28,7 +35,7 @@
<el-table-column align="center" label="小组简介">
<template slot-scope="scope">
<span>{{ scope.row.desc }}</span>
<span>{{ scope.row.description }}</span>
</template>
</el-table-column>
......@@ -61,13 +68,13 @@
</template>
</el-table-column>
<el-table-column align="center" label="线">
<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 align="center" label="推荐">
<el-table-column align="center" label="是否推荐">
<template slot-scope="scope">
<el-tag :type="scope.row.is_recommend | isOnlineFilter">{{ scope.row.is_recommend==1 ? '是' : '否' }}</el-tag>
</template>
......@@ -120,12 +127,22 @@ export default {
filter: {
value: '',
key: '',
is_online: '',
is_recommend: '',
},
},
SearchTypeOptions:[
{'key': 'id', 'display_name': '小组ID'},
{'key': 'content', 'display_name': '小组名称'},
]
{'key': 'name', 'display_name': '小组名称'},
],
OnlineTypeOptions: [
{'key': 0, 'display_name': '否'},
{'key': 1, 'display_name': '是'},
],
recommendTypeOptions: [
{'key': 0, 'display_name': '否'},
{'key': 1, 'display_name': '是'},
],
}
},
created() {
......@@ -135,6 +152,7 @@ export default {
getList() {
this.listLoading = true
fetchList(this.listQuery).then(response => {
console.log(response.data.data.data)
this.list = response.data.data.data
this.total = response.data.data.total
this.listLoading = false
......@@ -152,11 +170,11 @@ export default {
this.getList()
},
handleFilter() {
this.listQuery.page = 0
this.listQuery.page = 1
this.getList()
},
handleCreate() {
this.$router.push('/push/create')
this.$router.push('/group/create')
},
handleOfflineOrOnline(val){
const length = this.multipleSelection.length;
......@@ -165,14 +183,16 @@ export default {
for (let i = 0; i < length; i++) {
if (val === 'offline'){
this.multipleSelection[i].is_online = 0
}else{
}else if (val == 'is_recommend'){
this.multipleSelection[i].is_recommend = 1
}
else{
this.multipleSelection[i].is_online = 1
}
str += this.multipleSelection[i].id + ' ';
}
OffLineOrOnLine({type:val, ids:str}).then(response => {
this.multipleSelection = [];
response.data.data.message
this.$message.success(response.data.data.message);
})
},
......
......@@ -53,19 +53,19 @@
<el-col :span="8">
<el-form-item style="margin-bottom: 40px;" label-width="45px" label="pickid:" prop="id" v-if="isEdit">
<el-input :rows="1" v-model="postForm.id" type="number" class="article-textarea"
style="width: 120px" readonly/>
style="width: 120px" disabled/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item style="margin-bottom: 40px;" label-width="75px" label="pick用户:" prop="user_nums" v-if="isEdit">
<el-input :rows="1" v-model="postForm.user_nums" type="number" class="article-textarea"
style="width: 120px" readonly/>
style="width: 120px" disabled/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item style="margin-bottom: 40px;" label-width="85px" label="创建时间:" prop="create_time" v-if="isEdit">
<el-input :rows="1" v-model="postForm.create_time" type="text" class="article-textarea"
style="width: 170px" readonly/>
style="width: 170px" disabled/>
</el-form-item>
</el-col>
</el-row>
......
......@@ -22,20 +22,20 @@
<el-col :span="8">
<el-form-item style="margin-bottom: 40px;" label-width="75px" label="推送ID:" prop="id" v-if="isEdit">
<el-input :rows="1" v-model="postForm.id" type="text" class="article-textarea"
style="width: 180px" readonly v-if="isEdit"/>
style="width: 180px" disabled v-if="isEdit"/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item style="margin-bottom: 40px;" label-width="75px" label="创建时间:" prop="create_time" v-if="isEdit">
<el-input :rows="1" v-model="postForm.create_time" type="text" class="article-textarea"
style="width: 199px" readonly v-if="isEdit"/>
style="width: 199px" disabled v-if="isEdit"/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item style="margin-bottom: 40px;" label-width="75px" label="创建用户:" v-if="isEdit">
<el-input :rows="1" v-model="postForm.user.name" type="text" class="article-textarea"
style="width: 180px" readonly v-if="isEdit"/>
style="width: 180px" disabled v-if="isEdit"/>
</el-form-item>
</el-col>
</el-row>
......
......@@ -107,7 +107,7 @@ export default {
this.getList()
},
handleFilter() {
this.listQuery.page = 0
this.listQuery.page = 1
this.getList()
},
handleCreate() {
......
......@@ -24,13 +24,13 @@
<el-row>
<el-col :span="12">
<el-form-item style="margin-bottom: 20px;" label-width="75px" label="明星ID:" v-if="isEdit">
<el-input v-model="postForm.id" type="text" style="width: 230px;" readonly/>
<el-input v-model="postForm.id" type="text" style="width: 230px;" disabled/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item style="margin-bottom: 20px;" label-width="75px" label="创建时间:" v-if="isEdit">
<el-input v-model="postForm.create_time" type="text" placeholder="请输入内容" style="width: 230px;"
readonly/>
disabled/>
</el-form-item>
</el-col>
</el-row>
......@@ -39,20 +39,20 @@
<el-col :span="12">
<el-form-item style="margin-bottom: 20px;" label-width="75px" label="用户数:"
v-if="isEdit">
<el-input v-model="postForm.user_nums" type="number" style="width: 220px;" readonly/>
<el-input v-model="postForm.user_nums" type="number" style="width: 220px;" disabled/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item style="margin-bottom: 20px;" label-width="75px" label="帖子数:"
v-if="isEdit">
<el-input v-model="postForm.topic_nums" type="number" style="width: 220px;" readonly/>
<el-input v-model="postForm.topic_nums" type="number" style="width: 220px;" disabled/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item style="margin-bottom: 20px;" label-width="75px" label="小组数:" v-if="isEdit">
<el-input v-model="postForm.group_nums" type="number" style="width: 220px;" readonly/>
<el-input v-model="postForm.group_nums" type="number" style="width: 220px;" disabled/>
</el-form-item>
</el-col>
<el-col :span="12">
......@@ -288,6 +288,7 @@
if (valid) {
this.loading = true
this.postForm.group_ids = JSON.stringify(this.group_ids);
console.log(this.postForm.group_ids)
// 处理未修改标签
if (this.temp_city_name === this.postForm.city){
this.postForm.city = this.temp_city_id;
......@@ -350,7 +351,8 @@
this.temp_group_ids = ''
},
delUser() {
this.postForm.group_ids.push(...this.multipleSelection)
this.del_list.push(...this.multipleSelection)
},
handleSelectionChange(val) {
this.multipleSelection = val;
......
......@@ -60,7 +60,7 @@
</el-table>
<pagination v-show="total>0" :total="total" :page="listQuery.page" :limit="listQuery.limit" style="margin-left: 150px;" @pagination="getList" />
<pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" style="margin-left: 150px;" @pagination="getList" />
</div>
</template>
......@@ -162,7 +162,7 @@ export default {
})
},
handleFilter() {
this.listQuery.page = 0
this.listQuery.page = 1
this.getList()
},
handleCreate() {
......
......@@ -19,13 +19,13 @@
<el-col :span="12">
<el-form-item label-width="75px" label="帖子ID:" class="postInfo-container-item" v-if="isEdit">
<el-input :rows="1" v-model="postForm.id" type="number" class="article-textarea"
style="width: 230px" readonly/>
style="width: 230px" disabled/>
</el-form-item>
</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.reported_time" type="text" class="article-textarea"
style="width: 230px" readonly/>
style="width: 230px" disabled/>
</el-form-item>
</el-col>
</el-row>
......@@ -34,13 +34,15 @@
<el-form-item label-width="65px" label="发帖人:" class="postInfo-container-item">
<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 userListOptions" :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-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" prop="posting_time">
<el-form-item label-width="75px" label="发帖时间:" class="postInfo-container-item"
prop="posting_time">
<el-date-picker
v-model="postForm.posting_time "
type="datetime"
......@@ -57,7 +59,8 @@
<el-form-item label-width="75px" label="明星名称:" class="postInfo-container-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-option v-for="(item,index) in starListOptions" :key="item+index" :label="item.name"
:value="item.id"/>
</el-select>
</el-form-item>
</el-col>
......@@ -66,7 +69,8 @@
<el-form-item label-width="75px" label="小组名称:" class="postInfo-container-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-option v-for="(item,index) in groupListOptions" :key="item+index" :label="item.name"
:value="item.id"/>
</el-select>
</el-form-item>
</el-col>
......@@ -84,9 +88,11 @@
<el-col :span="12">
<el-form-item label-width="75px" label="标签:" class="postInfo-container-item">
<el-select v-model="postForm.tag_ids" :remote-method="getRemoteTagList" filterable remote multiple value-key="id"
<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.name" :value="item.id"/>
<el-option v-for="(item,index) in tagListOptions" :key="item+index" :label="item.name"
:value="item.id"/>
</el-select>
</el-form-item>
</el-col>
......@@ -169,30 +175,33 @@
</div>
<div style="margin-bottom:50px;">
<div class="filter-container">
<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 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-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">
<span>{{ scope.row.id }}</span>
<span>{{ scope.row.id }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="评论用户">
<template slot-scope="scope">
<span>{{ scope.row.reply_name }}</span>
<span>{{ scope.row.reply_user.id }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="被评论用户">
<template slot-scope="scope">
<span>{{ scope.row.be_reply_name }}</span>
<span>{{ scope.row.be_reply_user.name }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="评论时间">
......@@ -205,12 +214,22 @@
<span>{{ scope.row.reply_type }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="评论内容">
<el-table-column label="评论内容">
<template slot-scope="scope">
<span>{{ scope.row.content }}</span>
<span >{{ scope.row.content }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="操作" >
<template slot-scope="scope">
<el-button class="filter-item" type="primary" icon="el-icon-edit" @click="reply(scope.row)">回复</el-button>
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit"
......@@ -225,15 +244,8 @@
<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_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 userListOptions" :key="item+index" :label="item.name" :value="item.id"/>
</el-select>
</el-form-item>
<el-form-item :label="'评论用户'" prop="reply_name">
<el-select v-model="temp.reply_name" :remote-method="getRemoteUserList" filterable remote
<el-form-item :label="'评论用户'" prop="user_name">
<el-select v-model="temp.user_id" :remote-method="getRemoteUserList" filterable remote
value-key="id"
placeholder="搜索用户" style="width: 100%">
<el-option v-for="(item,index) in userListOptions" :key="item+index" :label="item.name" :value="item.id"/>
......@@ -263,7 +275,7 @@
import Modal from '@/components/Modal'
import VideoPlayer from '@/components/Video'
import waves from '@/directive/waves'
import {createRemark, fetchTopic, createTopic, fetchReply, DelReply} from '@/api/topic'
import {createRemark, fetchTopic, createTopic, fetchReply, DelReply, ModifyReply} from '@/api/topic'
import {fetchList} from '@/api/user'
import {getToken} from '@/api/qiniu'
import {postVideo} from '@/api/upload'
......@@ -272,8 +284,8 @@
function Assembledata(target, source) {
var region_data = []
for (var i=0;i<target.length;i++){
if (isInArray(source, target[i]['name'])){
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']);
}
......@@ -291,6 +303,7 @@
topic_ids: [],
content_level: '',
group_name: '',
reported_time: '',
user_name: '',
star_name: '',
is_puppet: '',
......@@ -327,7 +340,6 @@
// 搜索相关
userListOptions: [],
groupListOptions: [],
tagListOptions: [],
starListOptions: [],
// 表单验证相关
......@@ -348,12 +360,12 @@
},
expireTimeOption: {
disabledDate(date){
disabledDate(date) {
return date.getTime() <= Date.now();
}
},
temp_data:{
temp_data: {
star_id: '',
star_name: '',
group_id: '',
......@@ -380,6 +392,7 @@
tagListOptions: [],
is_puppet: 0,
listQuery: {
id: '',
page: 0,
limit: 10,
filter: {
......@@ -407,9 +420,8 @@
},
temp: {
remark: '',
be_remarked_user: '',
remark_user: '',
user_id: '',
content: '',
},
dialogFormVisible: false,
dialogStatus: '',
......@@ -430,7 +442,7 @@
if (this.isEdit) {
const id = this.$route.params && this.$route.params.id
this.fetchData(id)
this.getList(id)
this.getList()
} else {
this.postForm = Object.assign({}, defaultForm)
getToken().then(response => {
......@@ -442,6 +454,7 @@
methods: {
fetchData(id) {
fetchTopic(id).then(response => {
console.log(response.data.data.data)
let star = response.data.data.data.star
let group = response.data.data.data.group
let user = response.data.data.data.user
......@@ -450,7 +463,7 @@
this.postForm = response.data.data.data
for (let i = 0; i < tags.length; i ++){
for (let i = 0; i < tags.length; i++) {
temp_tag.push(tags[i].name); // 把每个标签的名称压入
this.temp_data.tag_ids.push(tags[i].id) // 每个标签的ID 压入暂存
}
......@@ -480,12 +493,21 @@
if (valid) {
this.loading = true
if (this.isEdit){
if (this.isEdit) {
this.postForm.tag_ids = Assembledata(this.temp_data.tag_ids, this.postForm.tag_ids)
}else{
} else {
this.postForm.tag_ids = JSON.stringify(this.postForm.tag_ids)
}
if (this.postForm.user_name === this.temp.user_name){
this.postForm.user_name = this.temp.user_id;
}
if (this.postForm.star_name === this.temp.star_name){
this.postForm.star_name = this.temp.star_id;
}
if (this.postForm.group_name === this.temp.group_name){
this.postForm.group_name = this.temp.group_id;
}
// 序列化图片
this.postForm.topic_images = JSON.stringify(this.edit.hospital_pics);
......@@ -502,7 +524,7 @@
duration: 2000
})
setTimeout(() => {
this.$router.push('/topic/list')
this.$router.push('/group/list')
}, 1000)
}).catch(err => {
......@@ -526,7 +548,6 @@
// 远程数据搜索
getRemoteUserList(query) {
userSearch(query).then(response => {
console.log(response.data.data.data)
if (!response.data.data.data) return
this.userListOptions = response.data.data.data
})
......@@ -550,31 +571,32 @@
})
},
// 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'
})
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)
})
setTimeout(() => {
this.$router.go(0)
}, 1000)
},
getList(id) {
getList() {
this.listLoading = true
this.listQuery.id = id
this.listQuery.id = this.$route.params && this.$route.params.id
fetchReply(this.listQuery).then(response => {
this.list = response.data.data.data
const items = response.data.data.data
this.list = items.map(v => {
this.$set(v, 'edit', false)
v.originalcontent = v.content
return v
})
this.total = response.data.data.total
this.listLoading = false
})
......@@ -582,11 +604,9 @@
// 图片上传
dropzoneS(file) {
console.log(file)
this.$message({message: 'Upload success', type: 'success'})
},
dropzoneR(file) {
console.log(file)
this.$message({message: 'Delete success', type: 'success'})
},
uploadPics(images) {
......@@ -606,14 +626,6 @@
handleSelectionChange(val) {
this.multipleSelection = val;
},
handleSizeChange(val) {
this.listQuery.limit = val
this.getList()
},
handleCurrentChange(val) {
this.listQuery.page = val
this.getList()
},
// 上传视频
uploadVideo(e) {
......@@ -690,7 +702,6 @@
type: 'video/mp4',
src: this.videoUrl()
}]
console.log(this.opts.sources)
},
videoUrl() {
return VIDEO_PREFIX + this.edit.video_url
......@@ -698,19 +709,29 @@
resetTemp() {
this.temp = {
'reply_name': '',
'be_reply_name': '',
'content': '',
user_id: '',
content: '',
}
},
reply() {
reply(row) {
this.resetTemp()
if (row){
this.temp.replied_id = row.id
}
this.dialogStatus = 'create'
this.dialogFormVisible = true
this.$nextTick(() => {
this.$refs['dataForm'].clearValidate()
})
},
handleSizeChange(val) {
this.listQuery.limit = val
this.getList()
},
handleCurrentChange(val) {
this.listQuery.page = val
this.getList()
},
createData() {
this.$refs['dataForm'].validate((valid) => {
if (valid) {
......@@ -729,16 +750,27 @@
},
handleFilter() {
this.listQuery.page = 0
this.getList(this.postForm.id);
this.listQuery.offset = 1
this.getList();
},
}
}
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
@import "src/styles/mixin.scss";
.edit-input {
padding-right: 100px;
}
.cancel-btn {
position: absolute;
right: 15px;
top: 10px;
}
.up-video {
.video-items {
float: left;
......
......@@ -8,12 +8,12 @@
<el-select v-model="listQuery.filter.is_online" :placeholder="'上线'" clearable class="filter-item" style="width: 100px">
<el-option v-for="item in BooleanTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
</el-select>
<el-select v-model="listQuery.filter.is_reported" :placeholder="'举报'" clearable class="filter-item" style="width: 100px">
<el-select v-model="listQuery.filter.complaints__isnull" :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-option v-for="item in BooleanTypeOptions" :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">
......@@ -23,7 +23,6 @@
<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('online')">上线</el-button>
<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" align="center"></el-table-column>
......@@ -80,18 +79,13 @@
<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 align="center" label="推荐">
<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_online | isOnlineFilter">{{ scope.row.is_online=== 1 ? '是' : '否' }}</el-tag>
</template>
</el-table-column>
</el-table>
<pagination v-show="total>0" :total="total" :page="listQuery.page" :limit="listQuery.limit" style="margin-left: 150px;" @pagination="getList" />
<pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" style="margin-left: 150px;" @pagination="getList" />
</div>
</template>
......@@ -146,8 +140,8 @@ export default {
{'key': 0, 'display_name': '否'}
],
ReBooleanTypeOptions: [
{'key': 1, 'display_name': '是'},
{'key': 0, 'display_name': '否'}
{'key': 0, 'display_name': '是'},
{'key': 1, 'display_name': '否'}
],
SearchTypeOptions:[
{'key': 'id', 'display_name': '帖子ID'},
......@@ -193,8 +187,6 @@ export default {
for (let i = 0; i < length; i++) {
if (val === 'offline'){
this.multipleSelection[i].is_online = 0
} else if(val === 'is_reported'){
this.multipleSelection[i].is_reported = 0
} else{
this.multipleSelection[i].is_online = 1
}
......@@ -207,11 +199,11 @@ export default {
})
},
handleFilter() {
this.listQuery.page = 0
this.listQuery.page = 1
this.getList()
},
handleCreate() {
this.$router.push('/pick/create')
this.$router.push('/topic/create')
}
}
}
......
......@@ -20,39 +20,39 @@
<el-row>
<el-col :span="12" >
<el-form-item style="margin-bottom: 20px;" label-width="75px" label="ID:" v-if="isEdit">
<el-input v-model="postForm.id" type="text" style="width: 230px;" readonly/>
<el-input v-model="postForm.user_id" type="text" style="width: 230px;" disabled/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item style="margin-bottom: 20px;" label-width="75px" label="注册时间:" v-if="isEdit">
<el-input v-model="postForm.create_time" type="text" style="width: 230px;"
readonly/>
disabled/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item style="margin-bottom: 20px;" label-width="75px" label="密码:" v-if="isEdit">
<el-input v-model="postForm.password" type="text" style="width: 230px;" readonly/>
<el-input v-model="postForm.password" type="text" style="width: 230px;" disabled/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item style="margin-bottom: 20px;" label-width="75px" label="帖子:" v-if="isEdit">
<el-input v-model="postForm.topic_nums" type="text" style="width: 230px;"
readonly/>
disabled/>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item style="margin-bottom: 20px;" label-width="75px" label="用户名:" prop="username">
<el-input v-model="postForm.username" type="text" style="width: 230px"/>
<el-input v-model="postForm.nick_name" type="text" style="width: 230px"/>
</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.show_time " type="datetime" format="yyyy-MM-dd HH:mm:ss"
placeholder="选择日期时间" style="width: 230px"/>
placeholder="选择日期时间" :picker-options="expireTimeOption" style="width: 230px"/>
</el-form-item>
</el-col>
</el-row>
......@@ -81,8 +81,8 @@
</el-col>
<el-col :span="12">
<el-form-item label-width="75px" label="地区:">
<el-select v-model="postForm.region" :remote-method="getRemoteGroupList" filterable remote
multiple value-key="id"
<el-select v-model="postForm.city" :remote-method="getRemoteCityList" filterable remote
value-key="id"
placeholder="搜索地区" style="width: 230px">
<el-option v-for="(item,index) in regionListOptions" :key="item+index" :label="item.name"
:value="item.id"/>
......@@ -93,7 +93,7 @@
<el-row>
<el-col :span="24">
<el-form-item label-width="75px" label="标签:">
<el-select v-model="postForm.region" :remote-method="getRemoteTagList" filterable remote
<el-select v-model="postForm.tag_ids" :remote-method="getRemoteTagList" filterable remote
multiple value-key="id"
placeholder="搜索地区" style="width: 720px">
<el-option v-for="(item,index) in tagListOptions" :key="item+index" :label="item.name"
......@@ -105,7 +105,7 @@
<el-row>
<el-col :span="12">
<el-form-item style="margin-bottom: 20px;margin-left: 10px" label-width="75px" label="马甲号:">
<el-radio-group v-model="postForm.is_online">
<el-radio-group v-model="postForm.is_puppet">
<el-radio :label="1"></el-radio>
<el-radio :label="0"></el-radio>
</el-radio-group>
......@@ -139,9 +139,11 @@
</div>
<div style="margin-bottom:50px;">
<div class="filter-container">
<el-input :placeholder="'添加小组'" v-model="listQuery.filter.value" style="width: 180px;"
class="filter-item"
@keyup.enter.native="appendGroup"/>
<el-select v-model="temp_group_ids" :remote-method="getRemoteGroupList" filterable remote
value-key="id"
placeholder="小组" style="width: 220px">
<el-option v-for="(item,index) in groupListOptions" :key="item+index" :label="item.id + ':' + item.name" :value="item.id"/>
</el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-edit" @click="appendGroup">添加
</el-button>
</div>
......@@ -159,12 +161,12 @@
</el-table-column>
<el-table-column align="center" label="小组简介">
<template slot-scope="scope">
<span>{{ scope.description }}</span>
<span>{{ scope.row.description }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="组长">
<template slot-scope="scope">
<span>{{ scope.row.creator }}</span>
<span>{{ scope.row.creator.name }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="帖子数">
......@@ -174,7 +176,7 @@
</el-table-column>
<el-table-column align="center" label="组内身份">
<template slot-scope="scope">
<span>{{ scope.row.user_identity }}</span>
<span>{{ scope.row.group_identify }}</span>
</template>
</el-table-column>
......@@ -198,27 +200,40 @@
import waves from '@/directive/waves'
import Pagination from '@/components/Pagination'
import {validateURL} from '@/utils/validate'
import {fetchArticle, getList} from '@/api/article'
import {regionSearch, tagSearch} from '@/api/remoteSearch'
import {UserDetail, fetchGroupUser, userCreate} from '@/api/user'
import { GroupDetail } from '@/api/group'
import {regionSearch, tagSearch, groupSearch, citySearch} from '@/api/remoteSearch'
import { isInArray, removeByvale} from "@/utils";
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 defaultForm = {
status: 'draft',
title: '', // 文章题目
content: '', // 文章内容
source_uri: '', // 文章外链
image_uri: '', // 文章图片
display_time: undefined, // 前台展示时间
id: undefined,
platforms: ['a-platform'],
comment_disabled: false,
importance: 0,
uploadType: '',
is_recommend: 1,
is_online: 1,
user_id: '',
create_time: '',
topic_nums: 0,
password: '',
avatar: '',
nick_name: '',
tag_ids: [],
is_puppet: 1,
city: '',
}
export default {
name: 'GroupDetail',
name: 'UserDetail',
components: {Tinymce, MDinput, Upload, Sticky, Pagination},
directives: {waves},
props: {
......@@ -257,20 +272,24 @@
return {
postForm: Object.assign({}, defaultForm),
loading: false,
userListOptions: [],
group_ids: [],
groupListOptions: [],
rules: {
image_uri: [{validator: validateRequire}],
title: [{validator: validateRequire}],
content: [{validator: validateRequire}],
source_uri: [{validator: validateSourceUri, trigger: 'blur'}]
},
expireTimeOption: {
disabledDate(date){
return date.getTime() <= Date.now();
}
},
tempRoute: {},
listQuery: {
page: 0,
page: 1,
limit: 10,
filter: {
value: '',
key: '',
},
},
GenderTypeOptions: [
......@@ -279,12 +298,18 @@
],
regionListOptions: [],
tagListOptions: [],
temp_group_ids: '',
uploadType: 99,
list: null,
total: 1,
list: [],
total: 0,
listLoading: true,
multipleSelection: [],
del_list: [],
temp: {
tags:[],
city_temp:'',
group_ids: []
}
}
},
computed: {
......@@ -300,43 +325,59 @@
} else {
this.postForm = Object.assign({}, defaultForm)
}
// Why need to make a copy of this.$route here?
// Because if you enter this page and quickly switch tag, may be in the execution of the setTagsViewTitle function, this.$route is no longer pointing to the current page
// https://github.com/PanJiaChen/vue-element-admin/issues/1221
this.tempRoute = Object.assign({}, this.$route)
},
methods: {
fetchData(id) {
fetchArticle(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}`
UserDetail(id).then(response => {
let rep = response.data.data
let temp_tags = []
this.postForm = response.data.data
console.log(rep.tag_list.length)
for (let i = 0;i < rep.tag_list.length; i++){
temp_tags.push(rep.tag_list[i].name)
this.temp.tags.push(rep.tag_list[i])
}
this.postForm.tag_ids = temp_tags
// Set tagsview title
this.setTagsViewTitle()
}).catch(err => {
console.log(err)
})
},
setTagsViewTitle() {
const title = this.lang === 'zh' ? '编辑文章' : 'Edit Article'
const route = Object.assign({}, this.tempRoute, {title: `${title}-${this.postForm.id}`})
this.$store.dispatch('updateVisitedView', route)
},
submitForm() {
this.postForm.display_time = parseInt(this.display_time / 1000)
console.log(this.postForm)
this.$refs.postForm.validate(valid => {
if (valid) {
this.loading = true
this.$notify({
title: '成功',
message: '发布文章成功',
type: 'success',
duration: 2000
})
this.postForm.group_ids = JSON.stringify(this.temp.group_ids)
if (this.isEdit){
this.postForm.tag_ids = Assembledata(this.temp.tags, this.postForm.tag_ids)
}else{
this.postForm.tag_ids = this.postForm.tag_ids.join(',')
}
userCreate(this.postForm).then(response => {
this.$notify({
title: '成功',
message: response.data.data.message,
type: 'success',
duration: 2000
})
setTimeout(() => {
this.$router.push('/user/list')
}, 1000)
}).catch(err => {
this.$notify({
title: '失败',
message: '操作失败',
type: 'danger',
duration: 2000
})
});
this.postForm.status = 'published'
this.loading = false
} else {
......@@ -345,35 +386,34 @@
}
})
},
draftForm() {
if (this.postForm.content.length === 0 || this.postForm.title.length === 0) {
appendGroup() {
if (isInArray(this.group_ids, this.temp_group_ids)){
this.$message({
message: '请填写必要的标题和内容',
type: 'warning'
message: '数据添加重复',
type: 'error'
})
return
return false;
}
this.$message({
message: '保存成功',
type: 'success',
showClose: true,
duration: 1000
GroupDetail(this.temp_group_ids).then(response => {
if (!response.data.data) return
console.log(response.data.data)
console.log(this.list)
this.list.push(response.data.data)
this.total = this.list.length
})
this.postForm.status = 'draft'
this.temp.group_ids.push(this.temp_group_ids)
this.temp_group_ids = ''
},
getRemoteUserList(query) {
userSearch(query).then(response => {
if (!response.data.items) return
this.userListOptions = response.data.items.map(v => v.name)
getRemoteGroupList(query) {
groupSearch(query).then(response => {
if (!response.data.data.data) return
this.groupListOptions = response.data.data.data
})
},
appendGroup() {
},
getRemoteGroupList(query) {
regionSearch(query).then(response => {
if (!response.data.items) return
this.userListOptions = response.data.data.data
getRemoteCityList(query) {
citySearch(query).then(response => {
if (!response.data.data.data) return
this.regionListOptions = response.data.data.data
})
},
getRemoteTagList(query) {
......@@ -384,9 +424,14 @@
},
getList() {
this.listLoading = true
fetchList(this.listQuery).then(response => {
this.list = []
this.total = 100
this.listQuery.id = this.$route.params && this.$route.params.id
fetchGroupUser(this.listQuery).then(response => {
let rep = response.data.data.data
this.list = response.data.data.data
this.total = response.data.data.total
for (let i=0;i<rep.length;i++){
this.temp.group_ids.push(rep[i].id)
}
this.listLoading = false
})
},
......
......@@ -8,9 +8,9 @@
<el-select v-model="listQuery.filter.user_type" :placeholder="'用户身份'" clearable class="filter-item" style="width: 110px">
<el-option v-for="item in UserTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
</el-select>
<el-select v-model="listQuery.filter.group_type" :placeholder="'组内身份'" clearable class="filter-item" style="width: 110px">
<el-option v-for="item in IdentifyTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
</el-select>
<!--<el-select v-model="listQuery.filter.group_type" :placeholder="'组内身份'" clearable class="filter-item" style="width: 110px">-->
<!--<el-option v-for="item in IdentifyTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>-->
<!--</el-select>-->
<el-select v-model="listQuery.filter.is_recommend" :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>
......@@ -19,59 +19,59 @@
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" @click="handleOfflineOrOnline('recommend')">推荐</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 type="selection" align="center"></el-table-column>
<el-table-column align="center" label="用户ID " width="80">
<template slot-scope="scope">
<router-link :to="'/pick/edit/'+scope.row.id" class="link-type">
<span>{{ scope.row.id }}</span>
<router-link :to="'/user/edit/'+scope.row.user_id" class="link-type">
<span>{{ scope.row.user_id }}</span>
</router-link>
</template>
</el-table-column>
<el-table-column width="140px" align="center" label="用户名">
<el-table-column align="center" label="用户名">
<template slot-scope="scope">
<span>{{ scope.row.username }}</span>
<span>{{ scope.row.nick_name }}</span>
</template>
</el-table-column>
<el-table-column width="140px" align="center" label="联系电话">
<el-table-column align="center" label="联系电话">
<template slot-scope="scope">
<span>{{ scope.row.phone }}</span>
</template>
</el-table-column>
<el-table-column width="180px" align="center" label="邮箱">
<el-table-column align="center" label="邮箱">
<template slot-scope="scope">
<span>{{ scope.row.email }}</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.group_nums }}</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.topic_num }}</span>
<span>{{ scope.row.topic_nums }}</span>
</template>
</el-table-column>
<el-table-column width="150px" align="center" label="组内身份">
<template slot-scope="scope">
<span>{{ scope.row.group_identify }}</span>
</template>
</el-table-column>
<!--<el-table-column width="150px" align="center" label="组内身份">-->
<!--<template slot-scope="scope">-->
<!--<span>{{ scope.row.group_identify }}</span>-->
<!--</template>-->
<!--</el-table-column>-->
<el-table-column width="100px" align="center" label="用户身份">
<el-table-column align="center" label="用户身份">
<template slot-scope="scope">
<span>{{ scope.row.user_identify }}</span>
</template>
</el-table-column>
<el-table-column width="80px" align="center" label="推荐">
<el-table-column align="center" label="推荐">
<template slot-scope="scope">
<el-tag :type="scope.row.is_recommend | isOnlineFilter">{{ scope.row.is_recommend==1 ? '是' : '否' }}</el-tag>
</template>
......@@ -191,7 +191,6 @@ export default {
}
OffLineOrOnLine({type:val, ids:str}).then(response => {
this.multipleSelection = [];
response.data.data.message
this.$message.success(response.data.data.message);
})
},
......
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