Commit fc562549 authored by Davve's avatar Davve

完善pick

parent 1c2e953f
...@@ -45,7 +45,7 @@ class GroupListView(APIView): ...@@ -45,7 +45,7 @@ class GroupListView(APIView):
class GroupUpdateOrCreate(APIView): class GroupUpdateOrCreate(APIView):
def get(self, request): def get(self, request):
id = request.GET.get('id') id = request.GET.get('id').split(':')[0]
try: try:
data = self.rpc['venus/sun/group/get'](id=id).unwrap() data = self.rpc['venus/sun/group/get'](id=id).unwrap()
except Exception as e: except Exception as e:
......
...@@ -49,13 +49,31 @@ class UpdateOrCreateView(APIView): ...@@ -49,13 +49,31 @@ class UpdateOrCreateView(APIView):
def post(self, request): def post(self, request):
id = request.POST.get('id', '') 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', '[]')))))
gender = request.POST.get('gender')
pick_type = request.POST.get('pick_type')
if gender == '全部':
gender_value = 2
elif gender == '男':
gender_value = 0
elif gender == '女':
gender_value = 1
if pick_type == '明星打榜':
pick_type_vale = 1
elif pick_type == 'PICK帖子':
pick_type_vale = 0
data = { data = {
'name': request.POST.get('name'), 'name': request.POST.get('name'),
'desc': request.POST.get('desc'), 'desc': request.POST.get('desc'),
'gender': request.POST.get('gender'), 'gender': gender_value,
'region': list(set(request.POST.get('region', '').split(','))), 'region': city_ids,
'pick_type': request.POST.get('pick_type'), 'pick_type': pick_type_vale,
'pick_group': list(set(request.POST.get('pick_group', '').split(','))), 'pick_group': pick_group_ids,
'position': request.POST.get('position'), 'position': request.POST.get('position'),
'is_online': int(request.POST.get('is_online')), 'is_online': int(request.POST.get('is_online')),
} }
...@@ -81,6 +99,11 @@ class PickUserListView(APIView): ...@@ -81,6 +99,11 @@ class PickUserListView(APIView):
PICK_TYPE.CELEBRITY: 'venus/sun/pick/celebrity/list', PICK_TYPE.CELEBRITY: 'venus/sun/pick/celebrity/list',
PICK_TYPE.TOPIC: 'venus/sun/pick/topic/list' PICK_TYPE.TOPIC: 'venus/sun/pick/topic/list'
} }
# try:
# data = self.rpc['venus/sun/pick/get'](id=pick_id).unwrap()
# pick_type = data['pick_type_origin']
# except:
# pick_type = 0
try: try:
data = self.rpc[dispatch_rpc_endpoint[pick_type]](offset=(offset - 1) * limit, limit=limit, filters=filters).unwrap() data = self.rpc[dispatch_rpc_endpoint[pick_type]](offset=(offset - 1) * limit, limit=limit, filters=filters).unwrap()
...@@ -102,8 +125,26 @@ class PickUserListView(APIView): ...@@ -102,8 +125,26 @@ class PickUserListView(APIView):
class PickTopicView(APIView): class PickTopicView(APIView):
def get(self, request):
pick_id = request.GET.get('id', 0)
offset = int(request.GET.get('page', 0))
limit = int(request.GET.get('limit', 10))
filters = {
'pick_id': pick_id
}
try:
data = self.rpc['venus/sun/pick/topic/list'](
offset=(offset - 1) * limit,
limit=limit,
filters=filters
).unwrap()
except Exception as e:
raise e
return data
def post(self, request): def post(self, request):
topic_id = request.POST.get('topic_id') topic_id = request.POST.get('topic_id').split(":")[0]
pick_id = request.POST.get('pick_id') pick_id = request.POST.get('pick_id')
del_ids = json.loads(request.POST.get('del_ids', '""')) del_ids = json.loads(request.POST.get('del_ids', '""'))
try: try:
...@@ -114,8 +155,26 @@ class PickTopicView(APIView): ...@@ -114,8 +155,26 @@ class PickTopicView(APIView):
class PickCelebrityListView(APIView): class PickCelebrityListView(APIView):
def get(self, request):
pick_id = request.GET.get('id', 0)
offset = int(request.GET.get('page', 0))
limit = int(request.GET.get('limit', 10))
filters = {
'pick_id': pick_id
}
try:
data = self.rpc['venus/sun/pick/celebrity/list'](
offset=(offset - 1) * limit,
limit=limit,
filters=filters
).unwrap()
except Exception as e:
raise e
return data
def post(self, request): def post(self, request):
celebrity_id = request.POST.get('celebrity_id') celebrity_id = request.POST.get('celebrity_id').split(":")[0]
pick_id = request.POST.get('pick_id') pick_id = request.POST.get('pick_id')
del_ids = json.loads(request.POST.get('del_ids', '""')) del_ids = json.loads(request.POST.get('del_ids', '""'))
try: try:
......
...@@ -48,14 +48,17 @@ class CelebrityUpdateOrCreate(APIView): ...@@ -48,14 +48,17 @@ class CelebrityUpdateOrCreate(APIView):
def post(self, request): def post(self, request):
id = request.POST.get('id', '') id = request.POST.get('id', '')
group_ids = list(set(map(lambda x: x.split(":")[0], json.loads(request.POST.get('groups', '[]')))))
data = { data = {
'name': request.POST.get('name'), 'name': request.POST.get('name'),
'gender': int(request.POST.get('gender')), 'gender': int(request.POST.get('gender')),
'city_id': request.POST.get('city'), 'city_id': request.POST.get('city').split(":")[0],
'is_online': int(request.POST.get('is_online')), 'is_online': int(request.POST.get('is_online')),
'desc': request.POST.get('description'), 'desc': request.POST.get('description'),
'portrait': request.POST.get('avatar')[:-2], 'portrait': request.POST.get('avatar')[:-2],
'group_ids': list(set(json.loads(request.POST.get('group_ids', [])))), 'group_ids': group_ids,
} }
try: try:
self.rpc['venus/sun/celebrity/edit'](id=id, data=data).unwrap() self.rpc['venus/sun/celebrity/edit'](id=id, data=data).unwrap()
......
...@@ -68,7 +68,8 @@ urlpatterns = [ ...@@ -68,7 +68,8 @@ urlpatterns = [
url(r'^pick/list/update$', PickListView.as_view()), url(r'^pick/list/update$', PickListView.as_view()),
url(r'^pick/create$', UpdateOrCreateView.as_view()), url(r'^pick/create$', UpdateOrCreateView.as_view()),
url(r'^pick/detail/', UpdateOrCreateView.as_view()), url(r'^pick/detail/', UpdateOrCreateView.as_view()),
url(r'^pick/user/list$', PickUserListView.as_view()), url(r'^pick/topic/list$', PickTopicView.as_view()),
url(r'^pick/celebrity/list$', PickCelebrityListView.as_view()),
url(r'^pick/add_fake_pick_nums$', PickUserListView.as_view()), url(r'^pick/add_fake_pick_nums$', PickUserListView.as_view()),
url(r'^pick/topic', PickTopicView.as_view()), url(r'^pick/topic', PickTopicView.as_view()),
url(r'^pick/celebrity', PickCelebrityListView.as_view()), url(r'^pick/celebrity', PickCelebrityListView.as_view()),
......
...@@ -33,9 +33,17 @@ export function fetchPickDetail(id) { ...@@ -33,9 +33,17 @@ export function fetchPickDetail(id) {
}) })
} }
export function fetchPickUserList(query) { export function fetchPickTopicList(query) {
return request({ return request({
url: '/api/pick/user/list', url: '/api/pick/topic/list',
method: 'get',
params: query
})
}
export function fetchPickCelebrityList(query) {
return request({
url: '/api/pick/celebrity/list',
method: 'get', method: 'get',
params: query params: query
}) })
......
...@@ -396,7 +396,7 @@ ...@@ -396,7 +396,7 @@
left_user_ids.push(origin_user_ids[i]) left_user_ids.push(origin_user_ids[i])
} }
} }
this.user_ids = left_user_ids; this.group_users = left_user_ids;
}, },
getList() { getList() {
this.listLoading = true this.listLoading = true
...@@ -406,7 +406,7 @@ ...@@ -406,7 +406,7 @@
this.tableData = response.data.data.data this.tableData = response.data.data.data
this.total = response.data.data.total this.total = response.data.data.total
for (let i=0;i<rep.length;i++){ for (let i=0;i<rep.length;i++){
this.user_ids.push(rep[i].user_id) this.group_users.push(rep[i].user_id + ':' + rep[i].nick_name)
} }
this.listLoading = false this.listLoading = false
......
...@@ -90,12 +90,12 @@ ...@@ -90,12 +90,12 @@
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item label-width="45px" label="地区:" class="postInfo-container-item" prop="region"> <el-form-item label-width="45px" label="城市:" class="postInfo-container-item" prop="region">
<el-select v-model="postForm.region" :remote-method="getRemoteCityList" filterable remote multiple <el-select v-model="city" :remote-method="getRemoteCityList" filterable remote multiple
value-key="id" value-key="id"
placeholder="搜索地区" style="width: 100%"> placeholder="搜索地区" style="width: 100%">
<el-option v-for="(item,index) in regionListOptions" :key="item+index" :label="item.name" <el-option v-for="(item,index) in regionListOptions" :key="item+index" :label="item"
:value="item.id"/> :value="item"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
...@@ -103,19 +103,20 @@ ...@@ -103,19 +103,20 @@
<el-form-item label-width="45px" label="小组:" class="postInfo-container-item"> <el-form-item label-width="45px" label="小组:" class="postInfo-container-item">
<el-select <el-select
v-model="postForm.pick_group" v-model="pick_group"
:remote-method="getRemoteGroupList" :remote-method="getRemoteGroupList"
multiple multiple
filterable filterable
remote remote
reserve-keyword reserve-keyword
clearable
placeholder="搜索小组" placeholder="搜索小组"
style="width: 100%" style="width: 100%"
:loading="loading" :loading="loading"
value-key="id" value-key="id"
> >
<el-option v-for="(item, index) in groupListOptions" :key="item+index" :label="item.name" <el-option v-for="(item, index) in groupListOptions" :key="item+index" :label="item"
:value="item.id"/> :value="item"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
...@@ -142,11 +143,11 @@ ...@@ -142,11 +143,11 @@
</div> </div>
<div style="margin-bottom:50px;"> <div style="margin-bottom:50px;">
<div class="filter-container"> <div class="filter-container">
<el-select v-model="celebrity_id" :remote-method="getRemoteCelebrityList" filterable remote <el-select v-model="celebrity_id" :remote-method="getRemoteCelebrityList" filterable remote clearable
value-key="id" value-key="id"
placeholder="添加明星" style="width: 220px"> placeholder="添加明星" style="width: 220px">
<el-option v-for="(item,index) in celebrityListOptions" :key="item+index" <el-option v-for="(item,index) in celebrityListOptions" :key="item+index"
:label="item.id + ':' + item.name" :value="item.id"/> :label="item" :value="item"/>
</el-select> </el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-edit" @click="append">添加 <el-button v-waves class="filter-item" type="primary" icon="el-icon-edit" @click="append">添加
...@@ -214,11 +215,11 @@ ...@@ -214,11 +215,11 @@
</div> </div>
<div style="margin-bottom:50px;"> <div style="margin-bottom:50px;">
<div class="filter-container"> <div class="filter-container">
<el-select v-model="topic_id" :remote-method="getRemoteTopicList" filterable remote <el-select v-model="topic_id" :remote-method="getRemoteTopicList" filterable remote clearable
value-key="id" value-key="id"
placeholder="添加帖子" style="width: 220px"> placeholder="添加帖子" style="width: 220px">
<el-option v-for="(item, index) in topicListOptions" :key="item+index" <el-option v-for="(item, index) in topicListOptions" :key="item+index"
:label="item.id + ':' + item.name" :value="item.id"/> :label="item" :value="item"/>
</el-select> </el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-edit" @click="append">添加 <el-button v-waves class="filter-item" type="primary" icon="el-icon-edit" @click="append">添加
...@@ -297,7 +298,8 @@ ...@@ -297,7 +298,8 @@
import { import {
fetchPickDetail, fetchPickDetail,
CreatePick, CreatePick,
fetchPickUserList, fetchPickTopicList,
fetchPickCelebrityList,
AddFakePickNums, AddFakePickNums,
PickTopicDetail, PickTopicDetail,
PickCelebrityDetail, PickCelebrityDetail,
...@@ -324,7 +326,7 @@ ...@@ -324,7 +326,7 @@
name: '', name: '',
desc: '', desc: '',
gender: '', gender: '',
region: [], city: [],
pick_group: [], pick_group: [],
pick_type: '', pick_type: '',
position: '', position: '',
...@@ -356,6 +358,11 @@ ...@@ -356,6 +358,11 @@
return { return {
postForm: Object.assign({}, defaultForm), postForm: Object.assign({}, defaultForm),
loading: false, loading: false,
city: [],
pick_group: [],
pick_type_origin: '', pick_type_origin: '',
celebrity_id: '', celebrity_id: '',
topic_id: '', topic_id: '',
...@@ -381,10 +388,6 @@ ...@@ -381,10 +388,6 @@
pick_type: [{validator: validateRequire, trigger: 'blur'}], pick_type: [{validator: validateRequire, trigger: 'blur'}],
}, },
tempRoute: {}, tempRoute: {},
temparray: {
'region': [],
'pick_group': [],
},
listQuery: { listQuery: {
id: '', id: '',
pick_type: '', pick_type: '',
...@@ -438,20 +441,17 @@ ...@@ -438,20 +441,17 @@
fetchPickDetail(id).then(response => { fetchPickDetail(id).then(response => {
// select 回填数据处理,后期再进行优化 // select 回填数据处理,后期再进行优化
let rep = response.data.data.data; let rep = response.data.data.data;
let pick_temp = []
let region_temp = []
for (let i = 0; i < rep.pick_group.length; i++) { for (let i = 0; i < rep.pick_group.length; i++) {
pick_temp.push(rep.pick_group[i]['name']); this.pick_group.push(rep.pick_group[i]['id'] + ':' + rep.pick_group[i]['name'])
this.temparray['pick_group'].push(rep.pick_group[i])
} }
for (let i = 0; i < rep.region.length; i++) { for (let i = 0; i < rep.region.length; i++) {
region_temp.push(rep.region[i]['name']); this.city.push(rep.region[i]['id'] + ':' + rep.region[i]['name'])
this.temparray['region'].push(rep.region[i])
} }
rep.region = region_temp
rep.pick_group = pick_temp
this.postForm = rep this.postForm = rep
this.pick_type_origin = rep.pick_type_origin; this.listQuery.pick_type = rep.pick_type_origin
}).catch(err => { }).catch(err => {
console.log(err) console.log(err)
}) })
...@@ -460,13 +460,11 @@ ...@@ -460,13 +460,11 @@
this.$refs.postForm.validate(valid => { this.$refs.postForm.validate(valid => {
if (valid) { if (valid) {
this.loading = true; this.loading = true;
if (this.isEdit) {
this.postForm.region = Assembledata(this.temparray['region'], this.postForm.region); this.postForm.city = JSON.stringify(this.city);
this.postForm.pick_group = Assembledata(this.temparray['pick_group'], this.postForm.pick_group); this.postForm.pick_group = JSON.stringify(this.pick_group);
} else {
this.postForm.region = this.postForm.region.join(',')
this.postForm.pick_group = this.postForm.pick_group.join(',')
}
CreatePick(this.postForm).then(response => { CreatePick(this.postForm).then(response => {
this.$notify({ this.$notify({
title: '成功', title: '成功',
...@@ -527,8 +525,8 @@ ...@@ -527,8 +525,8 @@
getList() { getList() {
this.listLoading = true this.listLoading = true
this.listQuery.id = this.$route.params && this.$route.params.id this.listQuery.id = this.$route.params && this.$route.params.id
this.listQuery.pick_type = this.pick_type_origin if (this.$route.query.pick_type === '1'){
fetchPickUserList(this.listQuery).then(response => { fetchPickCelebrityList(this.listQuery).then(response => {
const items = response.data.data.data const items = response.data.data.data
this.list = items.map(v => { this.list = items.map(v => {
this.$set(v, 'edit', false) this.$set(v, 'edit', false)
...@@ -539,6 +537,20 @@ ...@@ -539,6 +537,20 @@
this.origin_len = response.data.data.total this.origin_len = response.data.data.total
this.listLoading = false; this.listLoading = false;
}) })
} else{
fetchPickTopicList(this.listQuery).then(response => {
const items = response.data.data.data
this.list = items.map(v => {
this.$set(v, 'edit', false)
v.original_fake_pick_nums = v.fake_pick_nums
return v
})
this.total = response.data.data.total
this.origin_len = response.data.data.total
this.listLoading = false;
})
}
}, },
cancelEdit(row) { cancelEdit(row) {
row.fake_pick_nums = row.original_fake_pick_nums row.fake_pick_nums = row.original_fake_pick_nums
...@@ -575,7 +587,7 @@ ...@@ -575,7 +587,7 @@
pick_id: this.postForm.id, pick_id: this.postForm.id,
} }
PickTopicDetail(data).then(response => { PickTopicDetail(data).then(response => {
this.$message.info(response.data.data.message) this.$message.success(response.data.data.message)
}) })
this.topic_id = '' this.topic_id = ''
setTimeout(() => { setTimeout(() => {
...@@ -593,7 +605,7 @@ ...@@ -593,7 +605,7 @@
pick_id: this.postForm.id, pick_id: this.postForm.id,
} }
PickCelebrityDetail(data).then(response => { PickCelebrityDetail(data).then(response => {
this.$message.info(response.data.data.message) this.$message.success(response.data.data.message)
}) })
this.celebrity_id = '' this.celebrity_id = ''
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
<el-table-column type="selection" align="center"></el-table-column> <el-table-column type="selection" align="center"></el-table-column>
<el-table-column align="center" label="pickID" width="80"> <el-table-column align="center" label="pickID" width="80">
<template slot-scope="scope"> <template slot-scope="scope">
<router-link :to="'/pick/edit/'+scope.row.id" class="link-type"> <router-link :to="{path: '/pick/edit/'+scope.row.id, query: {pick_type: scope.row.pick_type_origin}}" class="link-type">
<span>{{ scope.row.id }}</span> <span>{{ scope.row.id }}</span>
</router-link> </router-link>
</template> </template>
......
...@@ -72,10 +72,10 @@ ...@@ -72,10 +72,10 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label-width="75px" label="城市:" style="margin-left: 10px" prop="city"> <el-form-item label-width="75px" label="城市:" style="margin-left: 10px" prop="city">
<el-select v-model="postForm.city" :remote-method="getRemoteCityList" filterable remote <el-select v-model="city" :remote-method="getRemoteCityList" filterable remote clearable
value-key="id" value-key="id"
placeholder="搜索地区" style="width: 220px"> placeholder="搜索地区" style="width: 220px">
<el-option v-for="(item,index) in regionListOptions" :key="item+index" :label="item.name" :value="item.id"/> <el-option v-for="(item,index) in regionListOptions" :key="item+index" :label="item" :value="item"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item style="margin-bottom: 20px;margin-left: 10px" label-width="75px" label="下线:"> <el-form-item style="margin-bottom: 20px;margin-left: 10px" label-width="75px" label="下线:">
...@@ -107,10 +107,10 @@ ...@@ -107,10 +107,10 @@
</div> </div>
<div style="margin-bottom:50px;"> <div style="margin-bottom:50px;">
<div class="filter-container"> <div class="filter-container">
<el-select v-model="temp_group_ids" :remote-method="getRemoteGroupList" filterable remote <el-select v-model="temp_group_ids" :remote-method="getRemoteGroupList" filterable remote clearable
value-key="id" value-key="id"
placeholder="小组" style="width: 220px"> placeholder="小组" style="width: 220px">
<el-option v-for="(item,index) in groupListOptions" :key="item+index" :label="item.id + ':' + item.name" :value="item.id"/> <el-option v-for="(item,index) in groupListOptions" :key="item+index" :label="item" :value="item"/>
</el-select> </el-select>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-edit" @click="appendUser">添加 <el-button v-waves class="filter-item" type="primary" icon="el-icon-edit" @click="appendUser">添加
</el-button> </el-button>
...@@ -185,6 +185,7 @@ ...@@ -185,6 +185,7 @@
is_online: 0, is_online: 0,
description: '', description: '',
avatar: '', avatar: '',
groups: [],
} }
export default { export default {
...@@ -213,10 +214,13 @@ ...@@ -213,10 +214,13 @@
postForm: Object.assign({}, defaultForm), postForm: Object.assign({}, defaultForm),
loading: false, loading: false,
groupListOptions: [], groupListOptions: [],
temp_group_ids: '', temp_group_ids: '',
group_ids: [], group_ids: [],
city: '',
rules: { rules: {
city: [{validator: validateRequire, trigger: 'blur'}],
name: [{validator: validateRequire, trigger: 'blur'}], name: [{validator: validateRequire, trigger: 'blur'}],
gender: [{validator: validateRequire, trigger: 'blur'}], gender: [{validator: validateRequire, trigger: 'blur'}],
avatar: [{validator: validateRequire, trigger: 'blur'}], avatar: [{validator: validateRequire, trigger: 'blur'}],
...@@ -239,8 +243,6 @@ ...@@ -239,8 +243,6 @@
page: 0, page: 0,
limit: 10, limit: 10,
}, },
temp_city_id: '',
temp_city_name: '',
} }
}, },
computed: { computed: {
...@@ -281,8 +283,7 @@ ...@@ -281,8 +283,7 @@
starDetail(id).then(response => { starDetail(id).then(response => {
let rep = response.data.data.data let rep = response.data.data.data
this.postForm = rep this.postForm = rep
this.temp_city_id = response.data.data.data.city.id this.city = rep.city.id + ':' + rep.city.name
this.postForm.city = this.temp_city_name = rep.city.name
}).catch(err => { }).catch(err => {
console.log(err) console.log(err)
}) })
...@@ -291,13 +292,8 @@ ...@@ -291,13 +292,8 @@
this.$refs.postForm.validate(valid => { this.$refs.postForm.validate(valid => {
if (valid) { if (valid) {
this.loading = true this.loading = true
this.postForm.group_ids = JSON.stringify(this.group_ids); this.postForm.groups = JSON.stringify(this.group_ids);
// 处理未修改标签 this.postForm.city = this.city
if (this.temp_city_name === this.postForm.city){
this.postForm.city = this.temp_city_id;
}
starCreate(this.postForm).then(response => { starCreate(this.postForm).then(response => {
this.$notify({ this.$notify({
title: '成功', title: '成功',
......
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