Commit 9c8f0cca authored by Davve's avatar Davve

完成pick添加

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