Commit ba55ba85 authored by Davve's avatar Davve

增加排序和pick

parent 05aa8f11
......@@ -54,7 +54,7 @@ class UpdateOrCreateView(APIView):
def post(self, request):
id = request.POST.get('id', '')
pick_group_ids = list(set(map(lambda x: x.split(":")[0], json.loads(request.POST.get('pick_group', '[]')))))
city_ids = list(set(map(lambda x: x.split(":")[0], json.loads(request.POST.get('city', '[]')))))
country_ids = list(set(map(lambda x: x.split(':')[0], json.loads(request.POST.get('country', '[]')))))
position = request.POST.get('position')
gender = request.POST.get('gender')
pick_type = request.POST.get('pick_type')
......@@ -84,7 +84,7 @@ class UpdateOrCreateView(APIView):
'name': request.POST.get('name'),
'desc': request.POST.get('desc'),
'gender': data_dict['gender'] if id else gender,
'region': city_ids,
'country_ids': country_ids,
'pick_type': data_dict['pick_type'] if id else pick_type,
'pick_group': pick_group_ids,
'is_online': int(request.POST.get('is_online')),
......
......@@ -15,12 +15,18 @@ class TopicListView(APIView):
offset = int(request.GET.get('page', 0))
limit = int(request.GET.get('limit', 10))
filter = self.handle_filter(request.GET.get('filter', ""))
sort_params = request.GET.getlist('sort[]')
if user_id:
filter.update({'user_id': user_id})
if group_id:
filter.update({'group_id': group_id})
try:
data = self.rpc['venus/sun/topic/list'](offset=(offset - 1) * limit, limit=limit, filters=filter).unwrap()
data = self.rpc['venus/sun/topic/list'](
offset=(offset - 1) * limit,
limit=limit,
filters=filter,
sort_params=sort_params
).unwrap()
except Exception as e:
error_logger.error(u'获取帖子列表失败%s', e)
raise
......
......@@ -6,6 +6,7 @@
:page-size.sync="pageSize"
:layout="layout"
:total="total"
:pageSizes="pageSizes"
v-bind="$attrs"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"/>
......
......@@ -90,11 +90,11 @@
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label-width="45px" label="城市:" class="postInfo-container-item" prop="city">
<el-select v-model="city" :remote-method="getRemoteCityList" filterable remote multiple
<el-form-item label-width="45px" label="国家:" class="postInfo-container-item" prop="country">
<el-select v-model="country" :remote-method="getRemoteCountryList" filterable remote multiple
value-key="id"
placeholder="搜索地区" style="width: 100%">
<el-option v-for="(item,index) in regionListOptions" :key="item+index" :label="item"
placeholder="搜索国家" style="width: 100%">
<el-option v-for="(item,index) in countryListOptions" :key="item+index" :label="item"
:value="item"/>
</el-select>
</el-form-item>
......@@ -306,7 +306,7 @@
delPickTopic,
delPickCelebrity
} from '@/api/pick'
import {groupSearch, citySearch, celebritySearch, topicSearch} from '@/api/remoteSearch'
import {groupSearch, citySearch, celebritySearch, topicSearch, countrySearch} from '@/api/remoteSearch'
import {isInArray, removeByvale} from "@/utils";
const defaultForm = {
......@@ -315,6 +315,7 @@
desc: '',
gender: '',
city: [],
country: [],
pick_group: [],
pick_type: '',
position: '',
......@@ -347,6 +348,7 @@
postForm: Object.assign({}, defaultForm),
loading: false,
city: [],
country: [],
pick_group: [],
......@@ -355,7 +357,7 @@
celebrity_id: '',
topic_id: '',
del_list: [],
regionListOptions: [],
countryListOptions: [],
groupListOptions: [],
celebrityListOptions: [],
topicListOptions: [],
......@@ -433,10 +435,8 @@
for (let i = 0; i < rep.pick_group.length; i++) {
this.pick_group.push(rep.pick_group[i]['id'] + ':' + rep.pick_group[i]['name'])
}
for (let i = 0; i < rep.region.length; i++) {
this.city.push(rep.region[i]['id'] + ':' + rep.region[i]['name'])
for (let i = 0; i < rep.country.length; i++) {
this.country.push(rep.country[i]['id'] + ':' + rep.country[i]['name'])
}
this.postForm = rep
......@@ -451,6 +451,7 @@
this.loading = true;
this.postForm.city = JSON.stringify(this.city);
this.postForm.country = JSON.stringify(this.country)
this.postForm.pick_group = JSON.stringify(this.pick_group);
CreatePick(this.postForm).then(response => {
......@@ -482,10 +483,10 @@
}
})
},
getRemoteCityList(query) {
citySearch(query).then(response => {
getRemoteCountryList(query){
countrySearch(query).then(response =>{
if (!response.data.data.data) return
this.regionListOptions = response.data.data.data
this.countryListOptions = response.data.data.data
})
},
getRemoteGroupList(query) {
......
......@@ -55,7 +55,7 @@
<el-table-column align="center" label="地区">
<template slot-scope="scope">
<span>{{ scope.row.region }}</span>
<span>{{ scope.row.country }}</span>
</template>
</el-table-column>
......
......@@ -24,9 +24,9 @@
<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 v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%" ref="multipleTable" @selection-change="handleSelectionChange" @sort-change="sortChange">
<el-table-column type="selection" align="center"></el-table-column>
<el-table-column align="center" label="帖子ID " >
<el-table-column align="center" label="帖子ID " sortable="custom" min-width="85px" prop="id">
<template slot-scope="scope">
<router-link :to="'/topic/edit/'+scope.row.id" class="link-type">
<span>{{ scope.row.id }}</span>
......@@ -40,7 +40,7 @@
</template>
</el-table-column>
<el-table-column align="center" label="帖子详情">
<el-table-column align="center" label="帖子详情" min-width="300px;">
<template slot-scope="scope">
<span>{{ scope.row.content }}</span>
</template>
......@@ -85,7 +85,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.sync="listQuery.page" :pageSizes="pageSize" :limit.sync="listQuery.limit" style="margin-left: 150px;" @pagination="getList" />
</div>
</template>
......@@ -120,6 +120,7 @@ export default {
return {
list: null,
total: 0,
pageSize: [10, 30, 50, 100, 250],
listLoading: true,
multipleSelection: [],
del_list: [],
......@@ -134,6 +135,7 @@ export default {
user__is_puppet: '',
content_level: ''
},
sort: ['-id', ]
},
BooleanTypeOptions: [
{'key': 1, 'display_name': '是'},
......@@ -167,7 +169,6 @@ export default {
this.listQuery.user_id = this.$route.query.user_id || ''
this.listQuery.group_id = this.$route.query.group_id || ''
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
......@@ -208,6 +209,22 @@ export default {
},
handleCreate() {
this.$router.push('/topic/create')
},
sortChange(data){
const {prop, order} = data
if (prop === 'id'){
this.sortByID(order)
}
},
sortByID(order){
if (order === 'ascending'){
this.listQuery.sort.shift()
this.listQuery.sort.push(...['id'])
}else{
this.listQuery.sort.shift()
this.listQuery.sort.push(...['-id'])
}
this.handleFilter()
}
}
}
......
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