Commit 1c2e953f authored by Davve's avatar Davve

完善小组

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