Commit 7c2f2970 authored by Davve's avatar Davve

增加用户是否在线和用户下线相关逻辑 以及统一上下线推荐逻辑

parent ba55ba85
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# __author__ = "chenwei" # __author__ = "chenwei"
# Date: 2018/11/16 # Date: 2018/11/16
import json
from django.conf import settings from django.conf import settings
from utils.base import APIView from utils.base import APIView
from utils.user_util import make_password_own from utils.user_util import make_password_own
...@@ -21,13 +22,8 @@ class AccountList(APIView): ...@@ -21,13 +22,8 @@ class AccountList(APIView):
return data return data
def post(self, request): def post(self, request):
ids = request.POST.get('ids', '').split() ids = json.loads(request.POST.get('ids', '[]'))
type = request.POST.get('type', '') updates = json.loads(request.POST.get('update', '{}'))
updates = {}
if type == 'offline':
updates['is_online'] = 0
else:
updates['is_online'] = 1
try: try:
self.rpc['venus/sun/account/batch/update'](updates=updates, ids=ids).unwrap() self.rpc['venus/sun/account/batch/update'](updates=updates, ids=ids).unwrap()
except Exception as e: except Exception as e:
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
# __author__ = "chenwei" # __author__ = "chenwei"
# Date: 2018/12/11 # Date: 2018/12/11
import json
from utils.base import APIView from utils.base import APIView
from utils.logger import error_logger from utils.logger import error_logger
...@@ -60,15 +61,9 @@ class StarListView(APIView): ...@@ -60,15 +61,9 @@ class StarListView(APIView):
return data return data
def post(self, request): def post(self, request):
ids = request.POST.get('ids', '').split() ids = json.loads(request.POST.get('ids', '[]'))
tp = request.POST.get('type', '') updates = json.loads(request.POST.get('update', '{}'))
updates = {}
if tp == 'offline':
updates['is_online'] = 0
else:
updates['is_online'] = 1
try: try:
self.rpc['mercury/face/batch/update'](ids=ids, updates=updates).unwrap() self.rpc['mercury/face/batch/update'](ids=ids, updates=updates).unwrap()
except Exception as e: except Exception as e:
......
...@@ -27,15 +27,8 @@ class GroupListView(APIView): ...@@ -27,15 +27,8 @@ class GroupListView(APIView):
return data return data
def post(self, request): def post(self, request):
ids = request.POST.get('ids', '').split() ids = json.loads(request.POST.get('ids', '[]'))
type = request.POST.get('type') updates = json.loads(request.POST.get('updates', '{}'))
updates = {}
if type == 'offline':
updates['is_online'] = False
elif type == 'is_recommend':
updates['is_recommend'] = True
else:
updates['is_online'] = True
try: try:
self.rpc['venus/sun/group/batch/update'](updates=updates, ids=ids).unwrap() self.rpc['venus/sun/group/batch/update'](updates=updates, ids=ids).unwrap()
except Exception as e: except Exception as e:
......
...@@ -22,15 +22,8 @@ class PickListView(APIView): ...@@ -22,15 +22,8 @@ class PickListView(APIView):
return data return data
def post(self, request): def post(self, request):
ids = request.POST.get('ids', '').split() ids = json.loads(request.POST.get('ids', '[]'))
type = request.POST.get('type', '') updates = json.loads(request.POST.get('update', '{}'))
updates = {}
if type == 'offline':
updates['is_online'] = 0
else:
updates['is_online'] = 1
try: try:
self.rpc['venus/sun/pick/batch/update'](updates=updates, ids=ids).unwrap() self.rpc['venus/sun/pick/batch/update'](updates=updates, ids=ids).unwrap()
except Exception as e: except Exception as e:
......
...@@ -21,15 +21,9 @@ class CelebrityListView(APIView): ...@@ -21,15 +21,9 @@ class CelebrityListView(APIView):
return data return data
def post(self, request): def post(self, request):
ids = request.POST.get('ids', '').split() ids = json.loads(request.POST.get('ids', '[]'))
type = request.POST.get('type', '') updates = json.loads(request.POST.get('update', '{}'))
updates = {}
if type == 'offline':
updates['is_online'] = 0
else:
updates['is_online'] = 1
try: try:
self.rpc['venus/sun/celebrity/batch/update'](updates=updates, ids=ids).unwrap() self.rpc['venus/sun/celebrity/batch/update'](updates=updates, ids=ids).unwrap()
except Exception as e: except Exception as e:
......
...@@ -21,13 +21,8 @@ class TagListView(APIView): ...@@ -21,13 +21,8 @@ class TagListView(APIView):
return data return data
def post(self, request): def post(self, request):
ids = request.POST.get('ids', '').split() ids = json.loads(request.POST.get('ids', '[]'))
type = request.POST.get('type', '') updates = json.loads(request.POST.get('update', '{}'))
updates = {}
if type == 'offline':
updates['is_online'] = False
else:
updates['is_online'] = True
try: try:
self.rpc['venus/sun/tag/batch/update'](updates=updates, ids=ids).unwrap() self.rpc['venus/sun/tag/batch/update'](updates=updates, ids=ids).unwrap()
except Exception as e: except Exception as e:
...@@ -87,12 +82,8 @@ class TagTypeListView(APIView): ...@@ -87,12 +82,8 @@ class TagTypeListView(APIView):
return data return data
def post(self, request): def post(self, request):
ids = request.POST.get('ids', '').split() ids = json.loads(request.POST.get('ids', '[]'))
update = int(request.POST.get('update', '')) updates = json.loads(request.POST.get('updates', '{}'))
updates = {
'is_online': bool(update)
}
try: try:
self.rpc['venus/sun/tag/tagtype/batch/update'](updates=updates, ids=ids).unwrap() self.rpc['venus/sun/tag/tagtype/batch/update'](updates=updates, ids=ids).unwrap()
......
...@@ -117,13 +117,9 @@ class ReplyCreate(APIView): ...@@ -117,13 +117,9 @@ class ReplyCreate(APIView):
class TopicListBatchUpdate(APIView): class TopicListBatchUpdate(APIView):
def post(self, request): def post(self, request):
ids = request.POST.get('ids', '').split() ids = json.loads(request.POST.get('ids', '[]'))
type = request.POST.get('type') updates = json.loads(request.POST.get('update', '{}'))
updates = {}
if type == 'offline':
updates['is_online'] = False
else:
updates['is_online'] = True
try: try:
self.rpc['venus/sun/topic/batch/update'](updates=updates, ids=ids).unwrap() self.rpc['venus/sun/topic/batch/update'](updates=updates, ids=ids).unwrap()
except Exception as e: except Exception as e:
......
...@@ -27,14 +27,7 @@ class UserListView(APIView): ...@@ -27,14 +27,7 @@ class UserListView(APIView):
def post(self, request): def post(self, request):
ids = json.loads(request.POST.get('ids', '[]')) ids = json.loads(request.POST.get('ids', '[]'))
type = request.POST.get('type', '') updates = json.loads(request.POST.get('updates', '{}'))
updates = {}
if type == 'recommend':
updates['is_recommend'] = 1
else:
pass
try: try:
self.rpc['venus/sun/user/batch/update'](updates=updates, ids=ids).unwrap() self.rpc['venus/sun/user/batch/update'](updates=updates, ids=ids).unwrap()
except Exception as e: except Exception as e:
......
...@@ -138,17 +138,20 @@ ...@@ -138,17 +138,20 @@
}, },
handleOfflineOrOnline(val) { handleOfflineOrOnline(val) {
const length = this.multipleSelection.length; const length = this.multipleSelection.length;
let str = ''; var ids = []
var updates = {}
this.del_list = this.del_list.concat(this.multipleSelection); this.del_list = this.del_list.concat(this.multipleSelection);
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if (val === 'offline') { if (val === 'offline') {
this.multipleSelection[i].is_online = 0 this.multipleSelection[i].is_online = 0
updates['is_online'] = 0
} else { } else {
this.multipleSelection[i].is_online = 1 this.multipleSelection[i].is_online = 1
updates['is_online'] = 1
} }
str += this.multipleSelection[i].id + ' '; ids.push(this.multipleSelection[i].id)
} }
OffLineOrOnLine({type: val, ids: str}).then(response => { OffLineOrOnLine({updates: JSON.stringify(updates), ids: JSON.stringify(ids)}).then(response => {
this.multipleSelection = []; this.multipleSelection = [];
this.$message.success(response.data.data.message); this.$message.success(response.data.data.message);
this.$router.go(0) this.$router.go(0)
......
...@@ -198,17 +198,20 @@ export default { ...@@ -198,17 +198,20 @@ export default {
}, },
handleOfflineOrOnline(val) { handleOfflineOrOnline(val) {
const length = this.multipleSelection.length const length = this.multipleSelection.length
let str = '' var ids = []
var updates = {}
this.del_list = this.del_list.concat(this.multipleSelection) this.del_list = this.del_list.concat(this.multipleSelection)
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if (val === 'offline') { if (val === 'offline') {
this.multipleSelection[i].is_online = 0 this.multipleSelection[i].is_online = 0
updates['is_online'] = 0
} else { } else {
this.multipleSelection[i].is_online = 1 this.multipleSelection[i].is_online = 1
updates['is_online'] = 1
} }
str += this.multipleSelection[i].id + ' ' ids.push(this.multipleSelection[i].id)
} }
OffLineOrOnLine({ type: val, ids: str }).then(response => { OffLineOrOnLine({updates: JSON.stringify(updates), ids: JSON.stringify(ids)}).then(response => {
this.multipleSelection = [] this.multipleSelection = []
this.$message.success(response.data.data.message) this.$message.success(response.data.data.message)
this.$router.go(0) this.$router.go(0)
......
...@@ -172,20 +172,24 @@ export default { ...@@ -172,20 +172,24 @@ export default {
}, },
handleOfflineOrOnline(val){ handleOfflineOrOnline(val){
const length = this.multipleSelection.length; const length = this.multipleSelection.length;
let str = ''; var ids = []
var updates = {}
this.del_list = this.del_list.concat(this.multipleSelection); this.del_list = this.del_list.concat(this.multipleSelection);
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if (val === 'offline'){ if (val === 'offline'){
this.multipleSelection[i].is_online = 0 this.multipleSelection[i].is_online = 0
updates['is_online'] = 0
}else if (val == 'is_recommend'){ }else if (val == 'is_recommend'){
this.multipleSelection[i].is_recommend = 1 this.multipleSelection[i].is_recommend = 1
updates['is_recommend'] = 1
} }
else{ else{
this.multipleSelection[i].is_online = 1 this.multipleSelection[i].is_online = 1
updates['is_online'] = 1
} }
str += this.multipleSelection[i].id + ' '; ids.push(this.multipleSelection[i].id)
} }
OffLineOrOnLine({type:val, ids:str}).then(response => { OffLineOrOnLine({updates: JSON.stringify(updates), ids: JSON.stringify(ids)}).then(response => {
this.multipleSelection = []; this.multipleSelection = [];
this.$message.success(response.data.data.message); this.$message.success(response.data.data.message);
......
...@@ -149,17 +149,20 @@ export default { ...@@ -149,17 +149,20 @@ export default {
}, },
handleOfflineOrOnline(val){ handleOfflineOrOnline(val){
const length = this.multipleSelection.length; const length = this.multipleSelection.length;
let str = ''; var ids = []
var updates = {}
this.del_list = this.del_list.concat(this.multipleSelection); this.del_list = this.del_list.concat(this.multipleSelection);
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if (val === 'offline'){ if (val === 'offline'){
this.multipleSelection[i].is_online = 0 this.multipleSelection[i].is_online = 0
updates['is_online'] = 0
}else{ }else{
this.multipleSelection[i].is_online = 1 this.multipleSelection[i].is_online = 1
updates['is_online'] = 1
} }
str += this.multipleSelection[i].id + ' '; str += this.multipleSelection[i].id + ' ';
} }
OffLineOrOnLine({type:val, ids:str}).then(response => { OffLineOrOnLine({updates: JSON.stringify(updates), ids: JSON.stringify(ids)}).then(response => {
this.multipleSelection = []; this.multipleSelection = [];
this.$message.success(response.data.data.message); this.$message.success(response.data.data.message);
}) })
......
...@@ -130,17 +130,20 @@ export default { ...@@ -130,17 +130,20 @@ export default {
}, },
handleOfflineOrOnline(val){ handleOfflineOrOnline(val){
const length = this.multipleSelection.length; const length = this.multipleSelection.length;
let str = ''; var ids = []
var updates = {}
this.del_list = this.del_list.concat(this.multipleSelection); this.del_list = this.del_list.concat(this.multipleSelection);
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if (val === 'offline'){ if (val === 'offline'){
this.multipleSelection[i].is_online = 0 this.multipleSelection[i].is_online = 0
updates['is_online'] = 0
}else{ }else{
this.multipleSelection[i].is_online = 1 this.multipleSelection[i].is_online = 1
updates['is_online'] = 1
} }
str += this.multipleSelection[i].id + ' '; ids.push(this.multipleSelection[i].id)
} }
OffLineOrOnLine({type:val, ids:str}).then(response => { OffLineOrOnLine({updates: JSON.stringify(updates), ids: JSON.stringify(ids)}).then(response => {
this.multipleSelection = []; this.multipleSelection = [];
this.$message.success(response.data.data.message); this.$message.success(response.data.data.message);
setTimeout(() => { setTimeout(() => {
......
...@@ -115,17 +115,20 @@ export default { ...@@ -115,17 +115,20 @@ export default {
}, },
handleOfflineOrOnline(val){ handleOfflineOrOnline(val){
const length = this.multipleSelection.length; const length = this.multipleSelection.length;
let str = ''; var ids = []
var updates = {}
this.del_list = this.del_list.concat(this.multipleSelection); this.del_list = this.del_list.concat(this.multipleSelection);
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if (val === 'offline'){ if (val === 'offline'){
this.multipleSelection[i].is_online = 0 this.multipleSelection[i].is_online = 0
updates['is_online'] = 0
}else{ }else{
this.multipleSelection[i].is_online = 1 this.multipleSelection[i].is_online = 1
updates['is_online'] = 1
} }
str += this.multipleSelection[i].id + ' '; ids.push(this.multipleSelection[i].id)
} }
OffLineOrOnLine({type:val, ids:str}).then(response => { OffLineOrOnLine({updates: JSON.stringify(updates), ids: JSON.stringify(ids)}).then(response => {
this.multipleSelection = []; this.multipleSelection = [];
this.$message.success(response.data.data.message); this.$message.success(response.data.data.message);
}) })
......
...@@ -114,20 +114,20 @@ export default { ...@@ -114,20 +114,20 @@ export default {
}, },
handleOfflineOrOnline(val){ handleOfflineOrOnline(val){
const length = this.multipleSelection.length; const length = this.multipleSelection.length;
let str = ''; var ids = [];
var update = '' var updates = ''
this.del_list = this.del_list.concat(this.multipleSelection); this.del_list = this.del_list.concat(this.multipleSelection);
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if (val === 'offline'){ if (val === 'offline'){
this.multipleSelection[i].is_online = 0 this.multipleSelection[i].is_online = 0
update = 0; updates['is_online'] = 0
}else{ }else{
this.multipleSelection[i].is_online = 1 this.multipleSelection[i].is_online = 1
update = 1; updates['is_online'] = 0
} }
str += this.multipleSelection[i].id + ' '; ids.push(this.multipleSelection[i].id)
} }
OffLineOrOnLine({update:update, ids:str}).then(response => { OffLineOrOnLine({updates: JSON.stringify(updates), ids: JSON.stringify(ids)}).then(response => {
this.multipleSelection = []; this.multipleSelection = [];
this.$message.success(response.data.data.message); this.$message.success(response.data.data.message);
}) })
......
...@@ -187,17 +187,20 @@ export default { ...@@ -187,17 +187,20 @@ export default {
}, },
handleOfflineOrOnline(val){ handleOfflineOrOnline(val){
const length = this.multipleSelection.length; const length = this.multipleSelection.length;
let str = ''; var ids = []
var updates = {}
this.del_list = this.del_list.concat(this.multipleSelection); this.del_list = this.del_list.concat(this.multipleSelection);
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if (val === 'offline'){ if (val === 'offline'){
this.multipleSelection[i].is_online = 0 this.multipleSelection[i].is_online = 0
updates['is_online'] = 0
} else{ } else{
this.multipleSelection[i].is_online = 1 this.multipleSelection[i].is_online = 1
updates['is_online'] = 1
} }
str += this.multipleSelection[i].id + ' '; ids.push(this.multipleSelection[i].id)
} }
OffLineOrOnLine({type:val, ids:str}).then(response => { OffLineOrOnLine({updates: JSON.stringify(updates), ids: JSON.stringify(ids)}).then(response => {
this.multipleSelection = []; this.multipleSelection = [];
this.$message.success(response.data.data.message); this.$message.success(response.data.data.message);
this.$router.go(0) this.$router.go(0)
......
...@@ -11,9 +11,6 @@ ...@@ -11,9 +11,6 @@
style="width: 110px"> style="width: 110px">
<el-option v-for="item in UserTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/> <el-option v-for="item in UserTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
</el-select> </el-select>
<!--<el-select v-model="listQuery.filter.group_type" :placeholder="'组内身份'" clearable class="filter-item" style="width: 110px">-->
<!--<el-option v-for="item in IdentifyTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>-->
<!--</el-select>-->
<el-select v-model="listQuery.filter.is_recommend" :placeholder="'推荐'" clearable class="filter-item" <el-select v-model="listQuery.filter.is_recommend" :placeholder="'推荐'" clearable class="filter-item"
style="width: 100px"> style="width: 100px">
<el-option v-for="item in ReBooleanTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/> <el-option v-for="item in ReBooleanTypeOptions" :key="item.key" :label="item.display_name" :value="item.key"/>
...@@ -25,6 +22,12 @@ ...@@ -25,6 +22,12 @@
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit" <el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit"
@click="handleOfflineOrOnline('recommend')">推荐 @click="handleOfflineOrOnline('recommend')">推荐
</el-button> </el-button>
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit"
@click="handleOfflineOrOnline('offline')">下线
</el-button>
<el-button class="filter-item" style="margin-left: 10px;" type="primary" icon="el-icon-edit"
@click="handleOfflineOrOnline('online')">上线
</el-button>
</div> </div>
<el-table v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%" <el-table v-loading="listLoading" :data="list" border fit highlight-current-row style="width: 100%"
ref="multipleTable" @selection-change="handleSelectionChange"> ref="multipleTable" @selection-change="handleSelectionChange">
...@@ -50,9 +53,9 @@ ...@@ -50,9 +53,9 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="联系电话"> <el-table-column align="center" label="是否在线">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.phone }}</span> <el-tag :type="scope.row.is_online | isOnlineFilter">{{ scope.row.is_online==true ? '是' : '否' }}</el-tag>
</template> </template>
</el-table-column> </el-table-column>
...@@ -79,12 +82,6 @@ ...@@ -79,12 +82,6 @@
</template> </template>
</el-table-column> </el-table-column>
<!--<el-table-column width="150px" align="center" label="组内身份">-->
<!--<template slot-scope="scope">-->
<!--<span>{{ scope.row.group_identify }}</span>-->
<!--</template>-->
<!--</el-table-column>-->
<el-table-column align="center" label="用户身份"> <el-table-column align="center" label="用户身份">
<template slot-scope="scope"> <template slot-scope="scope">
<span>{{ scope.row.user_identify }}</span> <span>{{ scope.row.user_identify }}</span>
...@@ -93,7 +90,7 @@ ...@@ -93,7 +90,7 @@
<el-table-column align="center" label="是否推荐"> <el-table-column align="center" label="是否推荐">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag :type="scope.row.is_recommend | isOnlineFilter">{{ scope.row.is_recommend==1 ? '是' : '否' }}</el-tag> <el-tag :type="scope.row.is_recommend | isOnlineFilter">{{ scope.row.is_recommend==true ? '是' : '否' }}</el-tag>
</template> </template>
</el-table-column> </el-table-column>
is_recommend is_recommend
...@@ -118,8 +115,8 @@ ...@@ -118,8 +115,8 @@
filters: { filters: {
isOnlineFilter(status) { isOnlineFilter(status) {
const statusMap = { const statusMap = {
1: 'success', true: 'success',
0: 'info', false: 'info',
} }
return statusMap[status] return statusMap[status]
}, },
...@@ -205,18 +202,22 @@ ...@@ -205,18 +202,22 @@
handleOfflineOrOnline(val) { handleOfflineOrOnline(val) {
const length = this.multipleSelection.length; const length = this.multipleSelection.length;
var ids = []; var ids = [];
var updates = {};
this.del_list = this.del_list.concat(this.multipleSelection); this.del_list = this.del_list.concat(this.multipleSelection);
for (let i = 0; i < length; i++) { for (let i = 0; i < length; i++) {
if (val === 'offline') { if (val === 'offline') {
this.multipleSelection[i].is_online = 0 this.multipleSelection[i].is_online = 0
updates['is_online'] = 0
} else if (val === 'recommend') { } else if (val === 'recommend') {
this.multipleSelection[i].is_recommend = 0 this.multipleSelection[i].is_recommend = 0
updates['is_recommend'] = 0
} else { } else {
this.multipleSelection[i].is_online = 1 this.multipleSelection[i].is_online = 1
updates['is_online'] = 1
} }
ids.push(this.multipleSelection[i].user_id) ids.push(this.multipleSelection[i].user_id)
} }
OffLineOrOnLine({type: val, ids: JSON.stringify(ids)}).then(response => { OffLineOrOnLine({updates: JSON.stringify(updates), ids: JSON.stringify(ids)}).then(response => {
this.multipleSelection = []; this.multipleSelection = [];
this.$message.success(response.data.data.message); this.$message.success(response.data.data.message);
setTimeout(() => { setTimeout(() => {
......
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