Commit 9c8f0cca authored by Davve's avatar Davve

完成pick添加

parent 6e82e2ba
...@@ -75,7 +75,6 @@ class GroupUpdateOrCreate(APIView): ...@@ -75,7 +75,6 @@ class GroupUpdateOrCreate(APIView):
class GroupRelatedUser(APIView): class GroupRelatedUser(APIView):
def get(self, request): def get(self, request):
print(request.GET)
id = request.GET.get('id') id = request.GET.get('id')
offset = int(request.GET.get('page', 0)) offset = int(request.GET.get('page', 0))
count = int(request.GET.get('limit', 10)) count = int(request.GET.get('limit', 10))
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# __author__ = "chenwei" # __author__ = "chenwei"
# Date: 2018/11/15 # Date: 2018/11/15
import json
from utils.base import APIView from utils.base import APIView
from alpha_types.venus import PICK_TYPE from alpha_types.venus import PICK_TYPE
...@@ -101,20 +102,24 @@ class PickUserListView(APIView): ...@@ -101,20 +102,24 @@ class PickUserListView(APIView):
class PickTopicView(APIView): class PickTopicView(APIView):
def get(self, request): def post(self, request):
topic_id = request.GET.get('id') topic_id = request.POST.get('topic_id')
pick_id = request.POST.get('pick_id')
del_ids = json.loads(request.POST.get('del_ids', '""'))
try: try:
data = self.rpc['venus/sun/topic/pick_topic'](id=topic_id).unwrap() data = self.rpc['venus/sun/pick/pick_topic'](topic_id=topic_id, pick_id=pick_id, del_ids=del_ids).unwrap()
except Exception as e: except Exception as e:
raise e raise e
return [data, ] return data
class PickCelebrityListView(APIView): class PickCelebrityListView(APIView):
def get(self, request): def post(self, request):
celebrity_id = request.GET.get('id') celebrity_id = request.POST.get('celebrity_id')
pick_id = request.POST.get('pick_id')
del_ids = json.loads(request.POST.get('del_ids', '""'))
try: try:
data = self.rpc['venus/sun/pick/pick_celebrity'](id=celebrity_id).unwrap() data = self.rpc['venus/sun/pick/pick_celebrity'](celebrity_id=celebrity_id, pick_id=pick_id, del_ids=del_ids).unwrap()
except Exception as e: except Exception as e:
raise e raise e
return [data, ] return data
\ No newline at end of file \ No newline at end of file
...@@ -72,6 +72,8 @@ urlpatterns = [ ...@@ -72,6 +72,8 @@ urlpatterns = [
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()),
url(r'^pick/del_celebrity', PickCelebrityListView.as_view()),
url(r'^pick/del_topic', PickTopicView.as_view()),
# 标签相关 # 标签相关
url(r'^tag/list$', TagListView.as_view()), url(r'^tag/list$', TagListView.as_view()),
......
...@@ -49,18 +49,34 @@ export function AddFakePickNums(data) { ...@@ -49,18 +49,34 @@ export function AddFakePickNums(data) {
}) })
} }
export function PickTopicDetail(id) { export function PickTopicDetail(data) {
return request({ return request({
url: '/api/pick/topic', url: '/api/pick/topic',
method: 'get', method: 'post',
params: { id } data
}) })
} }
export function PickCelebrityDetail(id) { export function PickCelebrityDetail(data) {
return request({ return request({
url: '/api/pick/celebrity', url: '/api/pick/celebrity',
method: 'get', method: 'post',
params: { id } data
})
}
export function delPickCelebrity(data) {
return request({
url: '/api/pick/del_celebrity',
method: 'post',
data
})
}
export function delPickTopic(data) {
return request({
url: '/api/pick/del_topic',
method: 'post',
data
}) })
} }
...@@ -300,7 +300,9 @@ ...@@ -300,7 +300,9 @@
fetchPickUserList, fetchPickUserList,
AddFakePickNums, AddFakePickNums,
PickTopicDetail, PickTopicDetail,
PickCelebrityDetail PickCelebrityDetail,
delPickTopic,
delPickCelebrity
} from '@/api/pick' } from '@/api/pick'
import {groupSearch, citySearch, celebritySearch, topicSearch} from '@/api/remoteSearch' import {groupSearch, citySearch, celebritySearch, topicSearch} from '@/api/remoteSearch'
import {isInArray, removeByvale} from "@/utils"; import {isInArray, removeByvale} from "@/utils";
...@@ -396,6 +398,9 @@ ...@@ -396,6 +398,9 @@
origin_len: 0, origin_len: 0,
topic_ids: [], topic_ids: [],
celebrity_ids: [], celebrity_ids: [],
new_ids: [],
del_ids: [],
} }
}, },
computed: { computed: {
...@@ -565,13 +570,17 @@ ...@@ -565,13 +570,17 @@
this.topic_id = '' this.topic_id = ''
return false return false
} }
PickTopicDetail(this.topic_id).then(response => { let data = {
if (!response.data.data) return topic_id: this.topic_id,
this.list.unshift(...response.data.data) pick_id: this.postForm.id,
this.total = this.list.length }
PickTopicDetail(data).then(response => {
this.$message.info(response.data.data.message)
}) })
// this.user_ids.push(this.temp_user_ids)
this.topic_id = '' this.topic_id = ''
setTimeout(() => {
this.$router.go(0)
}, 1300)
} else if (this.postForm.pick_type_origin == 1) { } else if (this.postForm.pick_type_origin == 1) {
if (this.celebrity_id == "") { if (this.celebrity_id == "") {
...@@ -579,50 +588,61 @@ ...@@ -579,50 +588,61 @@
this.celebrity_id = '' this.celebrity_id = ''
return false; return false;
} else { } else {
PickCelebrityDetail(this.celebrity_id).then(response => { let data = {
if (!response.data.data) return celebrity_id: this.celebrity_id,
this.list.unshift(...response.data.data) pick_id: this.postForm.id,
this.total = this.list.length }
PickCelebrityDetail(data).then(response => {
this.$message.info(response.data.data.message)
}) })
// this.user_ids.push(this.temp_user_ids)
this.celebrity_id = '' this.celebrity_id = ''
setTimeout(() => {
this.$router.go(0)
}, 1300)
} }
} }
}, },
del() { del() {
this.topic_ids = left__ids;
this.total = this.origin_len - this.del_list.length this.total = this.origin_len - this.del_list.length
let origin__ids = [];
var left__ids = [];
let select__ids = [] let select__ids = []
this.del_list.push(...this.multipleSelection) this.del_list.push(...this.multipleSelection)
if (this.postForm.pick_type_origin == 0) { if (this.postForm.pick_type_origin == 0) {
for (let i = 0; i < this.list.length; i++) {
origin__ids.push(this.list[i].topic_id)
}
for (let i = 0; i < this.multipleSelection.length; i++) { for (let i = 0; i < this.multipleSelection.length; i++) {
select__ids.push(this.multipleSelection[i].topic_id) select__ids.push(this.multipleSelection[i].topic_id)
} }
} else { let data = {
for (let i = 0; i < this.list.length; i++) { del_ids: JSON.stringify(select__ids),
origin__ids.push(this.list[i].celebrity_id) pick_id: this.postForm.id,
} }
delPickTopic(data).then(response => {
this.$message.success('操作成功')
setTimeout(() => {
this.$router.go(0)
}, 1300)
})
} else {
for (let i = 0; i < this.multipleSelection.length; i++) { for (let i = 0; i < this.multipleSelection.length; i++) {
select__ids.push(this.multipleSelection[i].celebrity_id) select__ids.push(this.multipleSelection[i].celebrity_id)
} }
let data = {
del_ids: JSON.stringify(select__ids),
pick_id: this.postForm.id,
} }
delPickCelebrity(data).then(response => {
for (let i = 0; i < origin__ids.length; i++) { this.$message.success('操作成功')
if (!isInArray(select__ids, origin__ids[i])) { setTimeout(() => {
left__ids.push(origin__ids[i]) this.$router.go(0)
} }, 1300)
})
} }
}, },
} }
} }
......
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