Commit 7c2f2970 authored by Davve's avatar Davve

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

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