Commit a9129aa7 authored by Davve's avatar Davve

增加用户身份可修改

parent 1609ea0b
...@@ -96,3 +96,15 @@ class GroupRelatedUserGET(APIView): ...@@ -96,3 +96,15 @@ class GroupRelatedUserGET(APIView):
except Exception as e: except Exception as e:
raise e raise e
return [data, ] return [data, ]
def post(self, request):
group_id = request.POST.get('group_id')
user_id = request.POST.get('user_id')
data = {
'role_id': request.POST.get('original_group_identify'),
}
try:
self.rpc['venus/sun/group/user/edit'](id=group_id, user_id=user_id, data=data).unwrap()
except Exception as e:
raise e
return
\ No newline at end of file
...@@ -42,6 +42,7 @@ urlpatterns = [ ...@@ -42,6 +42,7 @@ urlpatterns = [
url(r'^group/create$', GroupUpdateOrCreate.as_view()), url(r'^group/create$', GroupUpdateOrCreate.as_view()),
url(r'^group/user/list$', GroupRelatedUser.as_view()), url(r'^group/user/list$', GroupRelatedUser.as_view()),
url(r'^group/user/get$', GroupRelatedUserGET.as_view()), url(r'^group/user/get$', GroupRelatedUserGET.as_view()),
url(r'^group/user/edit_group_identify', GroupRelatedUserGET.as_view()),
# topic相关 # topic相关
url(r'^topic/list$', TopicListView.as_view()), url(r'^topic/list$', TopicListView.as_view()),
......
...@@ -48,3 +48,11 @@ export function GroupUserDetail(id) { ...@@ -48,3 +48,11 @@ export function GroupUserDetail(id) {
}) })
} }
export function ModifyGroupIdentify(data) {
return request({
url: '/api/group/user/edit_group_identify',
method: 'post',
data
})
}
...@@ -91,16 +91,16 @@ ...@@ -91,16 +91,16 @@
<div style="margin-bottom: 20px;"> <div style="margin-bottom: 20px;">
<el-form-item style="margin-bottom: 40px;" label-width="75px" label="小组头像:" prop="icon" > <el-form-item style="margin-bottom: 40px;" label-width="75px" label="小组头像:" prop="icon">
<span v-model="uploadType"></span> <span v-model="uploadType"></span>
<Upload v-model="postForm.icon" :uploadType="uploadType" /> <Upload v-model="postForm.icon" :uploadType="uploadType"/>
</el-form-item> </el-form-item>
</div> </div>
</el-card> </el-card>
</el-row> </el-row>
<el-row :gutter="20" style="margin-top:50px;" > <el-row :gutter="20" style="margin-top:50px;">
<el-card class="box-card"> <el-card class="box-card">
<div slot="header" class="clearfix"> <div slot="header" class="clearfix">
<span>组员相关</span> <span>组员相关</span>
...@@ -108,15 +108,16 @@ ...@@ -108,15 +108,16 @@
<div style="margin-bottom:50px;"> <div style="margin-bottom:50px;">
<div class="filter-container"> <div class="filter-container">
<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" :value="item"/> <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">添加
</el-button> </el-button>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-delete" @click="delUser">移除 <el-button v-waves class="filter-item" type="primary" icon="el-icon-delete" @click="delUser">移除
</el-button> </el-button>
</div> </div>
<el-table :data="data" border fit highlight-current-row style="width: 100%" <el-table :data="data" border fit highlight-current-row style="width: 100%"
ref="multipleTable" @selection-change="handleSelectionChange"> ref="multipleTable" @selection-change="handleSelectionChange">
...@@ -148,9 +149,37 @@ ...@@ -148,9 +149,37 @@
<span>{{ scope.row.user_identify }}</span> <span>{{ scope.row.user_identify }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="组内身份" v-if="isEdit"> <!--<el-table-column align="center" label="组内身份" v-if="isEdit">-->
<!--<template slot-scope="scope">-->
<!--<span>{{ scope.row.group_identify }}</span>-->
<!--</template>-->
<!--</el-table-column>-->
<el-table-column align="center" min-width="200px" label="组内身份" v-if="isEdit">
<template slot-scope="scope">
<template v-if="scope.row.edit">
<el-select v-model="scope.row.group_identify" :placeholder="'组内身份'" clearable
class="filter-item edit-select" style="width: 160px">
<el-option v-for="item in GroupIndentify" :key="item.key" :label="item.display_name"
:value="item.key"/>
</el-select>
<el-button class="cancel-btn" size="small" icon="el-icon-refresh" type="warning"
@click="cancelEdit(scope.row)">取消
</el-button>
</template>
<span v-else>{{ scope.row.group_identify }}</span>
</template>
</el-table-column>
<el-table-column align="center" label="操作">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.group_identify }}</span> <el-button v-if="scope.row.edit" type="success" size="small" icon="el-icon-circle-check-outline"
@click="confirmEdit(scope.row)">确认
</el-button>
<el-button v-else type="primary" size="small" icon="el-icon-edit"
@click="scope.row.edit=!scope.row.edit">修改
</el-button>
</template> </template>
</el-table-column> </el-table-column>
...@@ -177,23 +206,10 @@ ...@@ -177,23 +206,10 @@
import Pagination from '@/components/Pagination' import Pagination from '@/components/Pagination'
import {isInArray, removeByvale} from "@/utils"; import {isInArray, removeByvale} from "@/utils";
import {createGroup, GroupDetail, fetchGroupRelateduser, GroupUserDetail} from '@/api/group' import {createGroup, GroupDetail, fetchGroupRelateduser, GroupUserDetail, ModifyGroupIdentify} from '@/api/group'
import {starSearch, userSearch} from '@/api/remoteSearch' import {starSearch, userSearch} from '@/api/remoteSearch'
function Assembledata(target, source) {
var region_data = []
console.log(target, source)
for (var i=0;i<target.length;i++){
if (isInArray(source, target[i]['name'])){
region_data.push(target[i]['id'])
removeByvale(source, target[i]['name']);
}
}
region_data.push(...source)
return JSON.stringify(region_data)
}
const defaultForm = { const defaultForm = {
status: 'draft', status: 'draft',
name: '', // 小组名称 name: '', // 小组名称
...@@ -209,6 +225,18 @@ ...@@ -209,6 +225,18 @@
group_users: [], group_users: [],
} }
const GroupIndentify = [
{'key': 0, 'display_name': '创始人'},
{'key': 1, 'display_name': '长老'},
{'key': 2, 'display_name': '用户'},
{'key': 3, 'display_name': '访客'},
];
const GroupTypeKeyValue = GroupIndentify.reduce((acc, cur) => {
acc[cur.key] = cur.display_name
return acc
}, {});
export default { export default {
name: 'GroupDetail', name: 'GroupDetail',
components: {MDinput, Sticky, Pagination, Upload}, components: {MDinput, Sticky, Pagination, Upload},
...@@ -244,6 +272,7 @@ ...@@ -244,6 +272,7 @@
temp_user_ids: '', temp_user_ids: '',
group_users: [], group_users: [],
judge_user_ids: [], judge_user_ids: [],
group_identify: '',
tempRoute: {}, tempRoute: {},
uploadType: 98, uploadType: 98,
...@@ -265,6 +294,8 @@ ...@@ -265,6 +294,8 @@
key: '', key: '',
}, },
}, },
GroupIndentify: GroupIndentify,
} }
}, },
computed: { computed: {
...@@ -304,7 +335,7 @@ ...@@ -304,7 +335,7 @@
this.postForm = response.data.data this.postForm = response.data.data
this.user = rep.creator.id + ':' + rep.creator.name this.user = rep.creator.id + ':' + rep.creator.name
for (let i = 0;i < rep.star.length; i++){ for (let i = 0; i < rep.star.length; i++) {
this.star.push(rep.star[i]['id'] + ':' + rep.star[i]['name']) this.star.push(rep.star[i]['id'] + ':' + rep.star[i]['name'])
} }
}).catch(err => { }).catch(err => {
...@@ -315,7 +346,7 @@ ...@@ -315,7 +346,7 @@
this.$refs.postForm.validate(valid => { this.$refs.postForm.validate(valid => {
if (valid) { if (valid) {
this.loading = true this.loading = true
if (this.user === ''){ if (this.user === '') {
this.$message.error('小组组长必须填') this.$message.error('小组组长必须填')
this.loading = false; this.loading = false;
return false; return false;
...@@ -365,14 +396,14 @@ ...@@ -365,14 +396,14 @@
this.getList() this.getList()
}, },
appendUser() { appendUser() {
if (this.temp_user_ids == ""){ if (this.temp_user_ids == "") {
this.$message.error('还没输入小组呢~~') this.$message.error('还没输入小组呢~~')
this.temp_user_ids = '' this.temp_user_ids = ''
return false return false
} }
let append_user_id = parseInt(this.temp_user_ids.split(':')[0]) let append_user_id = parseInt(this.temp_user_ids.split(':')[0])
for (let i = 0;i < this.tableData.length; i++){ for (let i = 0; i < this.tableData.length; i++) {
if (append_user_id == this.tableData[i].user_id){ if (append_user_id == this.tableData[i].user_id) {
this.$message.error('存在同样数据, 请勿重复操作') this.$message.error('存在同样数据, 请勿重复操作')
this.temp_user_ids = '' this.temp_user_ids = ''
return false; return false;
...@@ -380,7 +411,7 @@ ...@@ -380,7 +411,7 @@
} }
GroupUserDetail(this.temp_user_ids).then(response => { GroupUserDetail(this.temp_user_ids).then(response => {
if (!response.data.data) return if (!response.data.data) return
if (!response.data.data[0].user_id){ if (!response.data.data[0].user_id) {
this.$message.error('这条数据错误, 请换条数据') this.$message.error('这条数据错误, 请换条数据')
return return
} }
...@@ -399,14 +430,14 @@ ...@@ -399,14 +430,14 @@
this.del_list.push(...this.multipleSelection) this.del_list.push(...this.multipleSelection)
for (let i = 0; i < this.tableData.length; i++){ for (let i = 0; i < this.tableData.length; i++) {
origin_user_ids.push(this.tableData[i].user_id) origin_user_ids.push(this.tableData[i].user_id)
} }
for (let i = 0; i < this.multipleSelection.length; i++){ for (let i = 0; i < this.multipleSelection.length; i++) {
select_user_ids.push(this.multipleSelection[i].user_id) select_user_ids.push(this.multipleSelection[i].user_id)
} }
for (let i =0; i < origin_user_ids.length; i++){ for (let i = 0; i < origin_user_ids.length; i++) {
if (!isInArray(select_user_ids ,origin_user_ids[i])){ if (!isInArray(select_user_ids, origin_user_ids[i])) {
left_user_ids.push(origin_user_ids[i]) left_user_ids.push(origin_user_ids[i])
} }
} }
...@@ -414,12 +445,17 @@ ...@@ -414,12 +445,17 @@
}, },
getList() { getList() {
this.listLoading = true this.listLoading = true
this.listQuery.id = this.$route.params && this.$route.params.id this.listQuery.id = this.$route.params && this.$route.params.id
fetchGroupRelateduser(this.listQuery).then(response => { fetchGroupRelateduser(this.listQuery).then(response => {
let rep = response.data.data.data let rep = response.data.data.data
this.tableData = response.data.data.data
this.total = response.data.data.total this.total = response.data.data.total
for (let i=0;i<rep.length;i++){
this.tableData = response.data.data.data.map(v => {
this.$set(v, 'edit', false)
v.original_group_identify = v.group_identify
return v
})
for (let i = 0; i < rep.length; i++) {
this.group_users.push(rep[i].user_id + ':' + rep[i].nick_name) this.group_users.push(rep[i].user_id + ':' + rep[i].nick_name)
} }
...@@ -440,6 +476,32 @@ ...@@ -440,6 +476,32 @@
this.starListOptions = response.data.data.data this.starListOptions = response.data.data.data
}) })
}, },
cancelEdit(row) {
row.group_identify = row.original_group_identify
row.edit = false
this.$message({
message: '取消成功',
type: 'warning'
})
},
confirmEdit(row) {
row.edit = false
row.original_group_identify = row.group_identify
row.group_identify = GroupTypeKeyValue[row.group_identify]
row.group_id = this.postForm.id
this.$message({
message: '修改成功',
type: 'success'
})
ModifyGroupIdentify(row).then(response => {
setTimeout(() => {
this.$router.go(0)
}, 1000)
}).catch(err => {
})
},
} }
} }
</script> </script>
...@@ -478,4 +540,14 @@ ...@@ -478,4 +540,14 @@
top: 0px; top: 0px;
} }
} }
.edit-select {
padding-right: 50px;
}
.cancel-btn {
position: absolute;
right: 15px;
top: 10px;
}
</style> </style>
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<div class="right-menu"> <div class="right-menu">
<template v-if="device!=='mobile'"> <template v-if="device!=='mobile'">
<error-log class="errLog-container right-menu-item"/> <!--<error-log class="errLog-container right-menu-item"/>-->
<el-tooltip :content="$t('navbar.screenfull')" effect="dark" placement="bottom"> <el-tooltip :content="$t('navbar.screenfull')" effect="dark" placement="bottom">
<screenfull class="screenfull right-menu-item"/> <screenfull class="screenfull right-menu-item"/>
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
import { mapGetters } from 'vuex' import { mapGetters } from 'vuex'
import Breadcrumb from '@/components/Breadcrumb' import Breadcrumb from '@/components/Breadcrumb'
import Hamburger from '@/components/Hamburger' import Hamburger from '@/components/Hamburger'
import ErrorLog from '@/components/ErrorLog' // import ErrorLog from '@/components/ErrorLog'
import Screenfull from '@/components/Screenfull' import Screenfull from '@/components/Screenfull'
import SizeSelect from '@/components/SizeSelect' import SizeSelect from '@/components/SizeSelect'
import ThemePicker from '@/components/ThemePicker' import ThemePicker from '@/components/ThemePicker'
...@@ -60,7 +60,7 @@ export default { ...@@ -60,7 +60,7 @@ export default {
components: { components: {
Breadcrumb, Breadcrumb,
Hamburger, Hamburger,
ErrorLog, // ErrorLog,
Screenfull, Screenfull,
SizeSelect, SizeSelect,
ThemePicker, ThemePicker,
......
...@@ -457,7 +457,6 @@ ...@@ -457,7 +457,6 @@
this.postForm.city = JSON.stringify(this.city); this.postForm.city = JSON.stringify(this.city);
this.postForm.pick_group = JSON.stringify(this.pick_group); this.postForm.pick_group = JSON.stringify(this.pick_group);
CreatePick(this.postForm).then(response => { CreatePick(this.postForm).then(response => {
this.$notify({ this.$notify({
title: '成功', title: '成功',
......
...@@ -108,7 +108,7 @@ ...@@ -108,7 +108,7 @@
<el-radio :label="0"></el-radio> <el-radio :label="0"></el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item style="margin-bottom: 40px;" label-width="75px" label="帖子内容:"> <el-form-item style="margin-bottom: 40px;" label-width="75px" label="帖子内容:" prop="content">
<el-input :rows="1" v-model="postForm.content" type="textarea" class="article-textarea" autosize <el-input :rows="1" v-model="postForm.content" type="textarea" class="article-textarea" autosize
placeholder="请输入内容"/> placeholder="请输入内容"/>
<span v-show="contentShortLength" class="word-counter">{{ contentShortLength }}</span> <span v-show="contentShortLength" class="word-counter">{{ contentShortLength }}</span>
...@@ -337,7 +337,8 @@ ...@@ -337,7 +337,8 @@
// 表单验证相关 // 表单验证相关
rules: { rules: {
posting_time: [{validator: validateRequire, trigger: 'blur'}] posting_time: [{validator: validateRequire, trigger: 'blur'}],
content: [{validator: validateRequire, trigger: 'blur'}]
}, },
ReplyTypeOptions: [ ReplyTypeOptions: [
...@@ -465,6 +466,11 @@ ...@@ -465,6 +466,11 @@
if (valid) { if (valid) {
this.loading = true this.loading = true
if (!this.tags.length){
this.$message.error('标签必填')
this.loading = false
return false
}
this.postForm.tags = JSON.stringify(this.tags) this.postForm.tags = JSON.stringify(this.tags)
this.postForm.user = this.user; this.postForm.user = this.user;
......
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