Commit 04d2faa9 authored by Davve's avatar Davve

完善帖子

parent 6a7c18d8
......@@ -14,7 +14,9 @@ class GroupSearchView(APIView):
except Exception as e:
raise e
return {'data': data}
return {
'data': ['{id}:{name}'.format(id=search_data['id'], name=search_data['name']) for search_data in data]
}
class CountrySearchView(APIView):
......@@ -24,7 +26,9 @@ class CountrySearchView(APIView):
data = self.rpc['venus/sun/country/search'](name=name).unwrap()
except Exception as e:
raise e
return {'data': data}
return {
'data': ['{id}:{name}'.format(id=search_data['id'], name=search_data['name']) for search_data in data]
}
class UserSearchView(APIView):
......@@ -34,7 +38,9 @@ class UserSearchView(APIView):
data = self.rpc['venus/sun/user/search'](name=name).unwrap()
except Exception as e:
raise e
return {'data': data}
return {
'data': ['{id}:{name}'.format(id=search_data['id'], name=search_data['name']) for search_data in data]
}
class TagSearchView(APIView):
......@@ -44,7 +50,9 @@ class TagSearchView(APIView):
data = self.rpc['venus/sun/tag/search'](name=name).unwrap()
except Exception as e:
raise e
return {'data': data}
return {
'data': ['{id}:{name}'.format(id=search_data['id'], name=search_data['name']) for search_data in data]
}
class CelebritySearchView(APIView):
......@@ -54,7 +62,9 @@ class CelebritySearchView(APIView):
data = self.rpc['venus/sun/celebrity/search'](name=name).unwrap()
except Exception as e:
raise e
return {'data': data}
return {
'data': ['{id}:{name}'.format(id=search_data['id'], name=search_data['name']) for search_data in data]
}
class CitySearchView(APIView):
......@@ -64,7 +74,9 @@ class CitySearchView(APIView):
data = self.rpc['venus/sun/city/search'](name=name).unwrap()
except Exception as e:
raise e
return {'data': data}
return {
'data': ['{id}:{name}'.format(id=search_data['id'], name=search_data['name']) for search_data in data]
}
class TopicSearchView(APIView):
......@@ -74,4 +86,6 @@ class TopicSearchView(APIView):
data = self.rpc['venus/sun/topic/search'](name=name).unwrap()
except Exception as e:
raise e
return {'data': data}
return {
'data': ['{id}:{name}'.format(id=search_data['id'], name=search_data['name']) for search_data in data]
}
......@@ -41,17 +41,17 @@ class TopicUpdateOrCreateView(APIView):
posting_time = analysis_time(request.POST.get('posting_time', 0))
topic_images = list(map(lambda x: x[:-2], json.loads(request.POST.get('topic_images', []))))
tag_ids = list(map(lambda x: x.split(':')[0], json.loads(request.POST.get('tags', '[]'))))
data = {
'topic_images': topic_images,
# '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_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', [])),
'group_id': request.POST.get('group', '').split(':')[0],
'user_id': request.POST.get('user', '').split(':')[0],
'star_id': request.POST.get('star', '').split(':')[0],
'tag_ids': tag_ids,
}
try:
self.rpc['venus/sun/topic/edit'](id=id, data=data).unwrap()
......
......@@ -298,7 +298,6 @@
this.postForm.city = this.temp_city_id;
}
console.log(this.postForm, '=====================')
starCreate(this.postForm).then(response => {
this.$notify({
title: '成功',
......
......@@ -188,7 +188,6 @@
rep.down_tags = down_temp
rep.up_tags = up_temp
this.postForm = rep
console.log(this.postForm)
}).catch(err => {
console.log(err)
})
......
......@@ -32,10 +32,10 @@
<el-row>
<el-col :span="12">
<el-form-item label-width="65px" label="发帖人:" class="postInfo-container-item">
<el-select v-model="postForm.user_name" :remote-method="getRemoteUserList" filterable remote
<el-select v-model="user" :remote-method="getRemoteUserList" filterable remote clearable
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"
:value="item"/>
</el-select>
<el-tag type="danger" v-if="postForm.is_puppet">马甲</el-tag>
</el-form-item>
......@@ -57,10 +57,10 @@
<el-row>
<el-col :span="12">
<el-form-item label-width="75px" label="明星名称:" class="postInfo-container-item">
<el-select v-model="postForm.star_name" :remote-method="getRemoteStarList" filterable remote
<el-select v-model="star" :remote-method="getRemoteStarList" filterable remote clearable
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"
:value="item"/>
</el-select>
......@@ -69,10 +69,10 @@
<el-col :span="12">
<el-form-item label-width="75px" label="小组名称:" class="postInfo-container-item">
<el-select v-model="postForm.group_name" :remote-method="getRemoteGroupList" filterable remote
<el-select v-model="group" :remote-method="getRemoteGroupList" filterable remote clearable
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"
:value="item"/>
</el-select>
</el-form-item>
</el-col>
......@@ -90,11 +90,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
<el-select v-model="tags" :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"
:value="item"/>
</el-select>
</el-form-item>
</el-col>
......@@ -250,7 +250,7 @@
<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"/>
<el-option v-for="(item,index) in userListOptions" :key="item+index" :label="item" :value="item"/>
</el-select>
</el-form-item>
<el-form-item :label="'评论内容'">
......@@ -304,14 +304,13 @@
id: '',
posting_time: '',
content: '',
topic_ids: [],
content_level: 0,
group_name: '',
reported_time: '',
user_name: '',
star_name: '',
group: '',
user: '',
star: '',
is_puppet: '',
tag_ids: [],
is_online: 0,
}
......@@ -341,6 +340,10 @@
postForm: Object.assign({}, defaultForm),
loading: false,
user: '',
star: '',
group: '',
tags: [],
// 搜索相关
userListOptions: [],
groupListOptions: [],
......@@ -368,16 +371,6 @@
return date.getTime() <= Date.now();
}
},
response_tags: [],
temp_data: {
star_id: '',
star_name: '',
group_id: '',
group_name: '',
user_id: '',
user_name: '',
tag_ids: []
},
tempRoute: {},
TopicLevelOptions: [
......@@ -467,32 +460,16 @@
let group = response.data.data.data.group
let user = response.data.data.data.user
let tags = response.data.data.data.tags
let temp_tag = []
this.postForm = response.data.data.data
for (let i = 0; i < tags.length; i++) {
temp_tag.push(tags[i].name); // 把每个标签的名称压入
this.temp_data.tag_ids.push(tags[i]) // 每个标签的ID 压入暂存
this.tags.push(tags[i].id + ':' + tags[i].name);
}
this.postForm.tag_ids = temp_tag;
this.star = star.id + ':' + star.name
this.group = group.id + ':' + group.name
this.user = user.id + ':' + user.name
this.postForm.is_puppet = user.is_puppet
this.edit.hospital_pics = response.data.data.data.topic_images
this.edit.video_url = response.data.data.data.video_url
// 回填明星数据, 后期进行改进
this.temp_data.star_id = star.id
this.postForm.star_name = this.temp_data.star_name = star.name
// 回填小组数据
this.temp_data.group_id = group.id
this.postForm.group_name = this.temp_data.group_name = group.name
console.log(group.name)
this.temp_data.user_id = user.id
this.postForm.user_name = this.temp_data.user_name = user.name
this.postForm.is_puppet = user.is_puppet
}).catch(err => {
console.log(err)
})
......@@ -502,29 +479,15 @@
if (valid) {
this.loading = true
if (this.isEdit) {
this.postForm.tag_ids = Assembledata(this.temp_data.tag_ids, this.postForm.tag_ids)
} else {
this.postForm.tag_ids = JSON.stringify(this.postForm.tag_ids)
}
if (this.postForm.user_name == this.temp_data.user_name){
this.postForm.user_name = this.temp_data.user_id;
}
if (this.postForm.star_name === this.temp_data.star_name){
this.postForm.star_name = this.temp.star_id;
}
if (this.postForm.group_name === this.temp_data.group_name){
this.postForm.group_name = this.temp_data.group_id;
}
this.postForm.tags = JSON.stringify(this.tags)
this.postForm.user = this.user;
this.postForm.star = this.star;
this.postForm.group = this.group;
// 序列化图片
this.postForm.topic_images = JSON.stringify(this.edit.hospital_pics);
this.postForm.video_url = this.edit.video_url;
this.postForm.topic_ids = JSON.stringify(this.postForm.topic_ids)
createTopic(this.postForm).then(response => {
this.$notify({
title: '成功',
......
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