Commit f461dd33 authored by Davve's avatar Davve

增加用户搜索和修改标签命名

parent c4958cda
......@@ -13,6 +13,7 @@ class GroupListView(APIView):
filters = self.handle_filter(request.GET.get('filter', ""))
try:
data = self.rpc['venus/community/group/list'](filters=filters, offset=offset, count=count).unwrap()
print(data, '----------------')
except Exception as e:
raise e
return data
......
......@@ -29,7 +29,12 @@ class RegionSearchView(APIView):
class UserSearchView(APIView):
def get(self, request):
pass
name = request.GET.get('name')
try:
data = self.rpc['venus/community/user/search'](name=name).unwrap()
except Exception as e:
raise e
return {'data': data}
class TagSearchView(APIView):
......@@ -39,4 +44,14 @@ class TagSearchView(APIView):
data = self.rpc['venus/community/tag/search'](name=name).unwrap()
except Exception as e:
raise e
return {'data': data}
class StarSearchView(APIView):
def get(self, request):
name = request.GET.get('name')
try:
data = self.rpc['venus/community/star/search'](name=name).unwrap()
except Exception as e:
raise e
return {'data': data}
\ No newline at end of file
......@@ -63,6 +63,7 @@ search_urlpatterns = [
url(r'search/region', RegionSearchView.as_view()),
url(r'search/user', UserSearchView.as_view()),
url(r'search/tag', TagSearchView.as_view()),
url(r'search/star', StarSearchView.as_view()),
]
common_urlpatterns = [
......
......@@ -31,3 +31,11 @@ export function tagSearch(name) {
params: { name }
})
}
export function starSearch(name) {
return request({
url: '/api/search/star',
method: 'get',
params: { name }
})
}
......@@ -14,7 +14,7 @@
<span>小组相关</span>
</div>
<div style="margin-bottom:50px;">
<div >
<el-col :span="24">
<el-form-item style="margin-bottom: 20px;" prop="title">
<MDinput v-model="postForm.name" :maxlength="100" name="name" required>
......@@ -26,27 +26,23 @@
<el-row>
<el-col :span="8">
<el-form-item label-width="75px" label="明星称号:" class="postInfo-container-item">
<el-select v-model="postForm.star_name" :placeholder="'明星称号'" clearable
class="postInfo-container-item"
style="width: 220px">
<el-option v-for="item in []" :key="item.key" :label="item.display_name"
:value="item.key"/>
<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>
</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.pick_type" :placeholder="'性别:'" clearable
class="postInfo-container-item" style="width:220px">
<el-option v-for="item in []" :key="item.key" :label="item.display_name"
:value="item.key"/>
<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>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item style="margin-bottom: 20px;" label-width="75px" label="组员数量:" prop="desc">
<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;" readonly/>
</el-form-item>
</el-col>
</el-row>
......@@ -149,20 +145,17 @@
import {validateURL} from '@/utils/validate'
import {fetchList} from '@/api/user'
import {userSearch} from '@/api/remoteSearch'
import {starSearch, userSearch} from '@/api/remoteSearch'
const defaultForm = {
status: 'draft',
title: '', // 文章题目
name: '', // 文章内容
description: '', // 文章摘要
source_uri: '', // 文章外链
image_uri: '', // 文章图片
display_time: undefined, // 前台展示时间
id: undefined,
platforms: ['a-platform'],
comment_disabled: false,
importance: 0
user_nums: 0,
group_leader: '',
}
export default {
......@@ -211,6 +204,8 @@
content: [{validator: validateRequire}],
},
tempRoute: {},
starListOptions: [],
userListOptions: [],
// 小组相关
list: null,
......@@ -230,7 +225,7 @@
},
computed: {
contentShortLength() {
return this.postForm.content_short.length
return this.postForm.description.length
},
},
created() {
......@@ -304,7 +299,19 @@
this.total = 100
this.listLoading = false
})
}
},
getRemoteStarList(query){
starSearch(query).then(response => {
if (!response.data.data.data) return
this.starListOptions = response.data.data.data
})
},
getRemoteUserList(query){
userSearch(query).then(response => {
if (!response.data.data.data) return
this.starListOptions = response.data.data.data
})
},
}
}
</script>
......
......@@ -7,39 +7,69 @@
</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>
</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="80">
<el-table-column align="center" label="小组ID " width="80">
<template slot-scope="scope">
<router-link :to="'/push/edit/'+scope.row.id" class="link-type">
<router-link :to="'/group/edit/'+scope.row.id" class="link-type">
<span>{{ scope.row.id }}</span>
</router-link>
</template>
</el-table-column>
<el-table-column width="190px" align="center" label="推送内容">
<el-table-column width="190px" align="center" label="小组名称">
<template slot-scope="scope">
<span>{{ scope.row.content }}</span>
<span>{{ scope.row.name }}</span>
</template>
</el-table-column>
<el-table-column width="300px" align="center" label="推送时间">
<el-table-column width="300px" align="center" label="小组简介">
<template slot-scope="scope">
<span>{{ scope.row.push_time }}</span>
<span>{{ scope.row.desc }}</span>
</template>
</el-table-column>
<el-table-column width="120px" align="center" label="创建时间">
<el-table-column width="120px" align="center" label="明星数">
<template slot-scope="scope">
<span>{{ scope.row.create_time }}</span>
<span>{{ scope.row.star_nums }}</span>
</template>
</el-table-column>
<el-table-column width="80px" align="center" label="创建用户">
<el-table-column width="80px" align="center" label="用户数">
<template slot-scope="scope">
<span>{{ scope.row.creator }}</span>
<router-link :to="'/user/edit/'+scope.row.id" class="link-type">
<span>{{ scope.row.user_nums }}</span>
</router-link>
</template>
</el-table-column>
<el-table-column width="80px" align="center" label="帖子数">
<template slot-scope="scope">
<router-link :to="'/topic/list/'+scope.row.id" class="link-type">
<span>{{ scope.row.topic_nums }}</span>
</router-link>
</template>
</el-table-column>
<el-table-column width="80px" align="center" label="组长">
<template slot-scope="scope">
<span>{{ scope.row.creator.name }}</span>
</template>
</el-table-column>
<el-table-column width="120px" 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="120px" align="center" label="下线">
<template slot-scope="scope">
<el-tag :type="scope.row.is_recommend | isOnlineFilter">{{ scope.row.is_recommend==1 ? '是' : '否' }}</el-tag>
</template>
</el-table-column>
......@@ -60,11 +90,29 @@ export default {
name: 'GroupList',
components: { Pagination },
directives: { waves },
filters: {
isOnlineFilter(status) {
const statusMap = {
1: 'success',
0: 'info',
}
return statusMap[status]
},
genderFilter(status) {
const statusMap = {
'男': 'success',
'女': 'info',
'全部': 'danger'
}
return statusMap[status]
},
},
data() {
return {
list: null,
total: 0,
listLoading: true,
multipleSelection: [],
del_list: [],
listQuery: {
page: 0,
......@@ -75,8 +123,8 @@ export default {
},
},
SearchTypeOptions:[
{'key': 'id', 'display_name': '推送ID'},
{'key': 'content', 'display_name': '推送内容'},
{'key': 'id', 'display_name': '小组ID'},
{'key': 'content', 'display_name': '小组名称'},
]
}
},
......@@ -92,6 +140,9 @@ export default {
this.listLoading = false
})
},
handleSelectionChange(val) {
this.multipleSelection = val;
},
handleSizeChange(val) {
this.listQuery.limit = val
this.getList()
......@@ -106,7 +157,25 @@ export default {
},
handleCreate() {
this.$router.push('/push/create')
}
},
handleOfflineOrOnline(val){
const length = this.multipleSelection.length;
let str = '';
this.del_list = this.del_list.concat(this.multipleSelection);
for (let i = 0; i < length; i++) {
if (val === 'offline'){
this.multipleSelection[i].is_online = 0
}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);
})
},
}
}
</script>
......
......@@ -15,28 +15,6 @@
标签名称
</MDinput>
</el-form-item>
<div class="postInfo-container">
<el-row>
<el-col :span="12">
<el-form-item label-width="75px" label="标签类型:" class="postInfo-container-item" prop="type">
<el-select v-model="postForm.type" :placeholder="'标签类型'" clearable class="postInfo-container-item"
style="width: 300px">
<el-option v-for="item in TagTypeOptions" :key="item.key" :label="item.display_name"
:value="item.key"/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label-width="75px" label="标签等级:" class="postInfo-container-item" prop="level">
<el-select v-model="postForm.level" :placeholder="'标签等级'" clearable
class="postInfo-container-item" style="width:300px">
<el-option v-for="item in LevelTypeOptions" :key="item.key" :label="item.display_name"
:value="item.key"/>
</el-select>
</el-form-item>
</el-col>
</el-row>
</div>
</el-col>
</el-row>
<el-row>
......@@ -60,9 +38,9 @@
<el-row>
<el-col :span="12">
<el-form-item label-width="75px" label="上级标签:" class="postInfo-container-item">
<el-select v-model="postForm.up_tag" :remote-method="getRemoteTagList" filterable remote multiple value-key="id"
<el-select v-model="postForm.up_tags" :remote-method="getRemoteTagList" filterable remote multiple value-key="id"
placeholder="搜索标签" style="width: 70%">
<el-option v-for="(item,index) in regionListOptions" :key="item+index" :label="item.name" :value="item.id"/>
<el-option v-for="(item,index) in upTagListOptions" :key="item+index" :label="item.name" :value="item.id"/>
</el-select>
</el-form-item>
</el-col>
......@@ -70,7 +48,7 @@
<el-form-item label-width="75px" label="下级标签:" class="postInfo-container-item">
<el-select
v-model="postForm.down_tag"
v-model="postForm.down_tags"
:remote-method="getRemoteTagList"
multiple
filterable
......@@ -119,11 +97,9 @@
const defaultForm = {
status: 'draft',
name: '',
level: '',
type: '',
description: '',
up_tag: [],
down_tag: [],
up_tags: [],
down_tags: [],
}
export default {
......@@ -150,28 +126,15 @@
return {
postForm: Object.assign({}, defaultForm),
loading: false,
regionListOptions: [],
upTagListOptions: [],
groupListOptions: [],
TagTypeOptions: [
{'key': 0, 'display_name': '用户标签'},
{'key': 1, 'display_name': '帖子标签'},
],
LevelTypeOptions: [
{'key': 1, 'display_name': '一级'},
{'key': 2, 'display_name': '二级'},
{'key': 4, 'display_name': '四级'},
{'key': 5, 'display_name': '五级'},
{'key': 6, 'display_name': '六级'},
],
rules: {
name: [{validator: validateRequire, trigger: 'blur'}],
type: [{validator: validateRequire, trigger: 'blur'}],
level: [{validator: validateRequire, trigger: 'blur'}],
},
tempRoute: {},
temparray:{
'up_tag':[],
'down_tag': [],
'up_tags':[],
'down_tags': [],
}
}
},
......@@ -197,17 +160,18 @@
let rep = response.data.data.data;
let up_temp = []
let down_temp = []
for (let i=0;i<rep.up_tag.length;i++){
up_temp.push(rep.up_tag[i]['name']);
this.temparray['up_tag'].push(rep.up_tag[i])
for (let i=0;i<rep.up_tags.length;i++){
up_temp.push(rep.up_tags[i]['name']);
this.temparray['up_tags'].push(rep.up_tags[i])
}
for (let i=0;i<rep.down_tag.length;i++){
down_temp.push(rep.down_tag[i]['name']);
this.temparray['down_tag'].push(rep.down_tag[i])
for (let i=0;i<rep.down_tags.length;i++){
down_temp.push(rep.down_tags[i]['name']);
this.temparray['down_tags'].push(rep.down_tags[i])
}
rep.down_tag = down_temp
rep.up_tag = up_temp
rep.down_tags = down_temp
rep.up_tags = up_temp
this.postForm = rep
}).catch(err => {
console.log(err)
})
......@@ -217,12 +181,12 @@
if (valid) {
this.loading = true;
if (this.isEdit){
this.postForm.up_tag = Assembledata(this.temparray['up_tag'], this.postForm.up_tag);
this.postForm.down_tag = Assembledata(this.temparray['down_tag'], this.postForm.down_tag);
this.postForm.up_tags = Assembledata(this.temparray['up_tags'], this.postForm.up_tags);
this.postForm.down_tags = Assembledata(this.temparray['down_tags'], this.postForm.down_tags);
}else{
this.postForm.up_tag = this.postForm.up_tag.join(',')
this.postForm.down_tag = this.postForm.down_tag.join(',')
this.postForm.up_tags = this.postForm.up_tags.join(',')
this.postForm.down_tags = this.postForm.down_tags.join(',')
}
CreateTag(this.postForm).then(response => {
......@@ -257,7 +221,7 @@
getRemoteTagList(query) {
tagSearch(query).then(response => {
if (!response.data.data.data) return
this.regionListOptions = response.data.data.data
this.upTagListOptions = response.data.data.data
})
},
}
......
......@@ -5,12 +5,6 @@
<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.level" :placeholder="'标签等级'" clearable class="filter-item" style="width: 110px">
<el-option v-for="item in TagLevelTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
</el-select>
<el-select v-model="listQuery.filter.type" :placeholder="'标签类型'" clearable class="filter-item" style="width: 110px">
<el-option v-for="item in TagtypeTypeOptions" :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: 100px">
<el-option v-for="item in BooleanTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
</el-select>
......@@ -21,7 +15,7 @@
</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="148">
<el-table-column align="center" label="标签ID" >
<template slot-scope="scope">
<router-link :to="'/tag/edit/'+scope.row.id" class="link-type">
<span>{{ scope.row.id }}</span>
......@@ -29,25 +23,14 @@
</template>
</el-table-column>
<el-table-column width="280px" align="center" label="标签名称">
<el-table-column align="center" label="标签名称">
<template slot-scope="scope">
<span>{{ scope.row.name }}</span>
</template>
</el-table-column>
<el-table-column width="280px" align="center" label="标签类型">
<template slot-scope="scope">
<span>{{ scope.row.type }}</span>
</template>
</el-table-column>
<el-table-column width="220px" align="center" label="标签等级">
<template slot-scope="scope">
<span>{{ scope.row.level }}</span>
</template>
</el-table-column>
<el-table-column width="220px" 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>
......@@ -76,14 +59,6 @@ export default {
}
return statusMap[status]
},
genderFilter(status) {
const statusMap = {
'男': 'success',
'女': 'info',
'全部': 'danger'
}
return statusMap[status]
},
},
directives: { waves },
data() {
......@@ -108,17 +83,6 @@ export default {
{'key': 1, 'display_name': '是'},
{'key': 0, 'display_name': '否'}
],
TagLevelTypeOptions: [
{'key': 1, 'display_name': '一级'},
{'key': 2, 'display_name': '二级'},
{'key': 3, 'display_name': '三级'},
{'key': 4, 'display_name': '四级'},
{'key': 5, 'display_name': '五级'},
],
TagtypeTypeOptions: [
{'key': 0, 'display_name': '用户标签'},
{'key': 1, 'display_name': '帖子标签'}
],
SearchTypeOptions:[
{'key': 'id', 'display_name': 'ID'},
{'key': 'name', 'display_name': '标签名称'},
......
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