Commit 1c2e953f authored by Davve's avatar Davve

完善小组

parent 72407245
...@@ -54,14 +54,16 @@ class GroupUpdateOrCreate(APIView): ...@@ -54,14 +54,16 @@ class GroupUpdateOrCreate(APIView):
def post(self, request): def post(self, request):
id = request.POST.get('id') id = request.POST.get('id')
star_ids = list(map(lambda x: x.split(":")[0], json.loads(request.POST.get('star', '[]'))))
group_user_ids = list(map(lambda x: x.split(":")[0], json.loads(request.POST.get('group_users', '[]'))))
data = { data = {
'name': request.POST.get('name', ''), 'name': request.POST.get('name', ''),
'description': request.POST.get('description', ''), 'description': request.POST.get('description', ''),
'creator_id': request.POST.get('user_id', ''), 'creator_id': request.POST.get('user', '').split(':')[0],
'celebrity_ids': json.loads(request.POST.get('star', '')), 'celebrity_ids': star_ids,
'is_online': int(request.POST.get('is_online', 0)), 'is_online': int(request.POST.get('is_online', 0)),
'is_recommend': int(request.POST.get('is_recommend', 0)), 'is_recommend': int(request.POST.get('is_recommend', 0)),
'group_user_ids': json.loads(request.POST.get('user_ids', '')), 'group_user_ids':group_user_ids,
'icon': request.POST.get('icon', '')[:-2] 'icon': request.POST.get('icon', '')[:-2]
} }
try: try:
...@@ -88,7 +90,7 @@ class GroupRelatedUser(APIView): ...@@ -88,7 +90,7 @@ class GroupRelatedUser(APIView):
class GroupRelatedUserGET(APIView): class GroupRelatedUserGET(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/user/get'](id=id).unwrap() data = self.rpc['venus/sun/group/user/get'](id=id).unwrap()
except Exception as e: except Exception as e:
......
...@@ -27,27 +27,28 @@ ...@@ -27,27 +27,28 @@
<el-col :span="8"> <el-col :span="8">
<el-form-item label-width="75px" label="明星称号:" class="postInfo-container-item"> <el-form-item label-width="75px" label="明星称号:" class="postInfo-container-item">
<el-select <el-select
v-model="postForm.star" v-model="star"
:remote-method="getRemoteStarList" :remote-method="getRemoteStarList"
filterable filterable
remote remote
multiple multiple
clearable
reserve-keyword reserve-keyword
value-key="id" value-key="id"
placeholder="搜索明星" placeholder="搜索明星"
style="width: 100%"> style="width: 100%">
<el-option v-for="(item,index) in starListOptions" :key="item+index" :label="item.name" <el-option v-for="(item,index) in starListOptions" :key="item+index" :label="item"
:value="item.id"/> :value="item"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label-width="75px" label="小组组长:" class="postInfo-container-item"> <el-form-item label-width="75px" label="小组组长:" class="postInfo-container-item">
<el-select v-model="postForm.user_id" :remote-method="getRemoteUserList" filterable remote <el-select v-model="user" :remote-method="getRemoteUserList" filterable remote clearable
value-key="id" value-key="id"
placeholder="搜索用户" style="width: 100%"> placeholder="搜索用户" style="width: 100%">
<el-option v-for="(item,index) in userListOptions" :key="item+index" :label="item.name" <el-option v-for="(item,index) in userListOptions" :key="item+index" :label="item"
:value="item.id"/> :value="item"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
...@@ -109,7 +110,7 @@ ...@@ -109,7 +110,7 @@
<el-select v-model="temp_user_ids" :remote-method="getRemoteUserList" filterable remote <el-select v-model="temp_user_ids" :remote-method="getRemoteUserList" filterable remote
value-key="id" value-key="id"
placeholder="用户" style="width: 220px"> placeholder="用户" style="width: 220px">
<el-option v-for="(item,index) in userListOptions" :key="item+index" :label="item.id + ':' + item.name" :value="item.id"/> <el-option v-for="(item,index) in userListOptions" :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">添加
...@@ -199,12 +200,13 @@ ...@@ -199,12 +200,13 @@
description: '', // 小组简介 description: '', // 小组简介
id: undefined, id: undefined,
user_nums: 0, user_nums: 0,
user_id: '',
user: '',
star: [], star: [],
icon: '', icon: '',
is_online: 0, is_online: 0,
is_recommend: 0, is_recommend: 0,
user_ids: [], group_users: [],
} }
export default { export default {
...@@ -236,9 +238,13 @@ ...@@ -236,9 +238,13 @@
title: [{validator: validateRequire}], title: [{validator: validateRequire}],
content: [{validator: validateRequire}], content: [{validator: validateRequire}],
}, },
tempRoute: {},
user: '',
star: [],
temp_user_ids: '', temp_user_ids: '',
user_ids: [], group_users: [],
tempRoute: {},
uploadType: 98, uploadType: 98,
starListOptions: [], starListOptions: [],
userListOptions: [], userListOptions: [],
...@@ -246,11 +252,6 @@ ...@@ -246,11 +252,6 @@
// 小组相关 // 小组相关
list: null, list: null,
tableData: [], tableData: [],
temp:{
user_id: '',
user_name: '',
star_ids: [],
},
del_list: [], del_list: [],
total: 0, total: 0,
listLoading: true, listLoading: true,
...@@ -299,19 +300,12 @@ ...@@ -299,19 +300,12 @@
fetchData(id) { fetchData(id) {
GroupDetail(id).then(response => { GroupDetail(id).then(response => {
let rep = response.data.data let rep = response.data.data
let temp_star_list = []
this.postForm = response.data.data this.postForm = response.data.data
this.temp.user_id = rep.creator.id this.user = rep.creator.id + ':' + rep.creator.name
this.postForm.user_id = this.temp.user_name = rep.creator.name
// TODO
for (let i = 0;i < rep.star.length; i++){ for (let i = 0;i < rep.star.length; i++){
temp_star_list.push(rep.star[i]['name']) this.star.push(rep.star[i]['id'] + ':' + rep.star[i]['name'])
this.temp.star_ids.push(rep.star[i])
} }
this.postForm.star = temp_star_list
}).catch(err => { }).catch(err => {
console.log(err) console.log(err)
}) })
...@@ -320,16 +314,10 @@ ...@@ -320,16 +314,10 @@
this.$refs.postForm.validate(valid => { this.$refs.postForm.validate(valid => {
if (valid) { if (valid) {
this.loading = true this.loading = true
if (this.postForm.user_id === this.temp.user_name){
this.postForm.user_id = this.temp.user_id
}
if (this.isEdit){ this.postForm.user = this.user
this.postForm.star = Assembledata(this.temp.star_ids, this.postForm.star) this.postForm.star = JSON.stringify(this.star)
} else{ this.postForm.group_users = JSON.stringify(this.group_users);
this.postForm.star = JSON.stringify(this.postForm.star)
}
this.postForm.user_ids = JSON.stringify(this.user_ids);
createGroup(this.postForm).then(response => { createGroup(this.postForm).then(response => {
this.$notify({ this.$notify({
title: '成功', title: '成功',
...@@ -338,8 +326,7 @@ ...@@ -338,8 +326,7 @@
duration: 2000 duration: 2000
}) })
setTimeout(() => { setTimeout(() => {
// this.$router.push('/group/list') this.$router.push('/group/list')
this.$router.go(0)
}, 1000) }, 1000)
}).catch(err => { }).catch(err => {
...@@ -386,7 +373,7 @@ ...@@ -386,7 +373,7 @@
} }
this.tableData.push(...response.data.data) this.tableData.push(...response.data.data)
this.total = this.tableData.length this.total = this.tableData.length
this.user_ids.push(this.temp_user_ids) this.group_users.push(this.temp_user_ids)
this.temp_user_ids = '' this.temp_user_ids = ''
}) })
......
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