Commit a9129aa7 authored by Davve's avatar Davve

增加用户身份可修改

parent 1609ea0b
......@@ -96,3 +96,15 @@ class GroupRelatedUserGET(APIView):
except Exception as e:
raise e
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 = [
url(r'^group/create$', GroupUpdateOrCreate.as_view()),
url(r'^group/user/list$', GroupRelatedUser.as_view()),
url(r'^group/user/get$', GroupRelatedUserGET.as_view()),
url(r'^group/user/edit_group_identify', GroupRelatedUserGET.as_view()),
# topic相关
url(r'^topic/list$', TopicListView.as_view()),
......
......@@ -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 @@
<div style="margin-bottom: 20px;">
<el-form-item style="margin-bottom: 40px;" label-width="75px" label="小组头像:" prop="icon" >
<span v-model="uploadType"></span>
<Upload v-model="postForm.icon" :uploadType="uploadType" />
</el-form-item>
</div>
<el-form-item style="margin-bottom: 40px;" label-width="75px" label="小组头像:" prop="icon">
<span v-model="uploadType"></span>
<Upload v-model="postForm.icon" :uploadType="uploadType"/>
</el-form-item>
</div>
</el-card>
</el-row>
<el-row :gutter="20" style="margin-top:50px;" >
<el-row :gutter="20" style="margin-top:50px;">
<el-card class="box-card">
<div slot="header" class="clearfix">
<span>组员相关</span>
......@@ -108,15 +108,16 @@
<div style="margin-bottom:50px;">
<div class="filter-container">
<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" :value="item"/>
</el-select>
value-key="id"
placeholder="用户" style="width: 220px">
<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">添加
</el-button>
<el-button v-waves class="filter-item" type="primary" icon="el-icon-delete" @click="delUser">移除
</el-button>
</div>
<el-table :data="data" border fit highlight-current-row style="width: 100%"
ref="multipleTable" @selection-change="handleSelectionChange">
......@@ -148,9 +149,37 @@
<span>{{ scope.row.user_identify }}</span>
</template>
</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">
<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>
</el-table-column>
......@@ -177,23 +206,10 @@
import Pagination from '@/components/Pagination'
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'
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 = {
status: 'draft',
name: '', // 小组名称
......@@ -209,6 +225,18 @@
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 {
name: 'GroupDetail',
components: {MDinput, Sticky, Pagination, Upload},
......@@ -244,6 +272,7 @@
temp_user_ids: '',
group_users: [],
judge_user_ids: [],
group_identify: '',
tempRoute: {},
uploadType: 98,
......@@ -265,6 +294,8 @@
key: '',
},
},
GroupIndentify: GroupIndentify,
}
},
computed: {
......@@ -304,7 +335,7 @@
this.postForm = response.data.data
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'])
}
}).catch(err => {
......@@ -315,7 +346,7 @@
this.$refs.postForm.validate(valid => {
if (valid) {
this.loading = true
if (this.user === ''){
if (this.user === '') {
this.$message.error('小组组长必须填')
this.loading = false;
return false;
......@@ -365,14 +396,14 @@
this.getList()
},
appendUser() {
if (this.temp_user_ids == ""){
if (this.temp_user_ids == "") {
this.$message.error('还没输入小组呢~~')
this.temp_user_ids = ''
return false
}
let append_user_id = parseInt(this.temp_user_ids.split(':')[0])
for (let i = 0;i < this.tableData.length; i++){
if (append_user_id == this.tableData[i].user_id){
for (let i = 0; i < this.tableData.length; i++) {
if (append_user_id == this.tableData[i].user_id) {
this.$message.error('存在同样数据, 请勿重复操作')
this.temp_user_ids = ''
return false;
......@@ -380,7 +411,7 @@
}
GroupUserDetail(this.temp_user_ids).then(response => {
if (!response.data.data) return
if (!response.data.data[0].user_id){
if (!response.data.data[0].user_id) {
this.$message.error('这条数据错误, 请换条数据')
return
}
......@@ -399,14 +430,14 @@
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)
}
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)
}
for (let i =0; i < origin_user_ids.length; i++){
if (!isInArray(select_user_ids ,origin_user_ids[i])){
for (let i = 0; i < origin_user_ids.length; i++) {
if (!isInArray(select_user_ids, origin_user_ids[i])) {
left_user_ids.push(origin_user_ids[i])
}
}
......@@ -414,12 +445,17 @@
},
getList() {
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 => {
let rep = response.data.data.data
this.tableData = response.data.data.data
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)
}
......@@ -440,6 +476,32 @@
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>
......@@ -478,4 +540,14 @@
top: 0px;
}
}
.edit-select {
padding-right: 50px;
}
.cancel-btn {
position: absolute;
right: 15px;
top: 10px;
}
</style>
......@@ -6,7 +6,7 @@
<div class="right-menu">
<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">
<screenfull class="screenfull right-menu-item"/>
......@@ -51,7 +51,7 @@
import { mapGetters } from 'vuex'
import Breadcrumb from '@/components/Breadcrumb'
import Hamburger from '@/components/Hamburger'
import ErrorLog from '@/components/ErrorLog'
// import ErrorLog from '@/components/ErrorLog'
import Screenfull from '@/components/Screenfull'
import SizeSelect from '@/components/SizeSelect'
import ThemePicker from '@/components/ThemePicker'
......@@ -60,7 +60,7 @@ export default {
components: {
Breadcrumb,
Hamburger,
ErrorLog,
// ErrorLog,
Screenfull,
SizeSelect,
ThemePicker,
......
......@@ -457,7 +457,6 @@
this.postForm.city = JSON.stringify(this.city);
this.postForm.pick_group = JSON.stringify(this.pick_group);
CreatePick(this.postForm).then(response => {
this.$notify({
title: '成功',
......
......@@ -108,7 +108,7 @@
<el-radio :label="0"></el-radio>
</el-radio-group>
</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
placeholder="请输入内容"/>
<span v-show="contentShortLength" class="word-counter">{{ contentShortLength }}</span>
......@@ -337,7 +337,8 @@
// 表单验证相关
rules: {
posting_time: [{validator: validateRequire, trigger: 'blur'}]
posting_time: [{validator: validateRequire, trigger: 'blur'}],
content: [{validator: validateRequire, trigger: 'blur'}]
},
ReplyTypeOptions: [
......@@ -465,6 +466,11 @@
if (valid) {
this.loading = true
if (!this.tags.length){
this.$message.error('标签必填')
this.loading = false
return false
}
this.postForm.tags = JSON.stringify(this.tags)
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