Commit 0666b763 authored by Davve's avatar Davve

修复明星

parent d9fc94d3
......@@ -18,6 +18,24 @@ class CelebrityListView(APIView):
raise e
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
try:
self.rpc['venus/sun/celebrity/batch/update'](updates=updates, ids=ids).unwrap()
except Exception as e:
raise e
return {
"message": "更新成功"
}
class CelebrityUpdateOrCreate(APIView):
def get(self, request):
......@@ -35,11 +53,10 @@ class CelebrityUpdateOrCreate(APIView):
'gender': request.POST.get('gender'),
'city_id': request.POST.get('city'),
'is_online': int(request.POST.get('is_online')),
'description': request.POST.get('description'),
'icon': request.POST.get('avatar'),
'desc': request.POST.get('description'),
'portrait': request.POST.get('avatar')[:-2],
'group_ids': list(set(json.loads(request.POST.get('group_ids', [])))),
}
print(json.loads(request.POST.get('group_ids', [])))
try:
self.rpc['venus/sun/celebrity/edit'](id=id, data=data).unwrap()
except Exception as e:
......
......@@ -52,6 +52,7 @@ urlpatterns = [
# star相关
url(r'^celebrity/list$', CelebrityListView.as_view()),
url(r'^celebrity/list/update$', CelebrityListView.as_view()),
url(r'^celebrity/create$', CelebrityUpdateOrCreate.as_view()),
url(r'^celebrity/detail$', CelebrityUpdateOrCreate.as_view()),
url(r'^celebrity/celebrity_related_group_info', CelebrityRelatedGroup.as_view()),
......
......@@ -26,7 +26,7 @@ export function starDetail(id) {
export function OffLineOrOnLine(data) {
return request({
url: '/api/celebrity/update_or_create',
url: '/api/celebrity//list/update',
method: 'post',
data
})
......
......@@ -372,6 +372,11 @@
this.getList()
},
appendUser() {
if (this.temp_user_ids){
this.$message.error('还没输入小组呢~~')
this.temp_user_ids = ''
return false
}
GroupUserDetail(this.temp_user_ids).then(response => {
if (!response.data.data) return
this.tableData.push(...response.data.data)
......
......@@ -63,7 +63,7 @@
</div>
</el-col>
</div>
<el-form-item label-width="75px" label="性别:" style="margin-left: 10px">
<el-form-item label-width="75px" label="性别:" style="margin-left: 10px" prop="gender">
<el-select v-model="postForm.gender" :placeholder="'性别:'" clearable
class="postInfo-container-item"
style="width: 220px">
......@@ -71,7 +71,7 @@
:value="item.key"/>
</el-select>
</el-form-item>
<el-form-item label-width="75px" label="城市:" style="margin-left: 10px">
<el-form-item label-width="75px" label="城市:" style="margin-left: 10px" prop="city">
<el-select v-model="postForm.city" :remote-method="getRemoteCityList" filterable remote
value-key="id"
placeholder="搜索地区" style="width: 220px">
......@@ -216,7 +216,10 @@
temp_group_ids: '',
group_ids: [],
rules: {
content: [{validator: validateRequire, trigger: 'blur'}]
city: [{validator: validateRequire, trigger: 'blur'}],
name: [{validator: validateRequire, trigger: 'blur'}],
gender: [{validator: validateRequire, trigger: 'blur'}],
avatar: [{validator: validateRequire, trigger: 'blur'}],
},
GenderTypeOptions: [
{'key': 0, 'display_name': '男'},
......@@ -289,11 +292,13 @@
if (valid) {
this.loading = true
this.postForm.group_ids = JSON.stringify(this.group_ids);
console.log(this.postForm.group_ids)
// 处理未修改标签
if (this.temp_city_name === this.postForm.city){
this.postForm.city = this.temp_city_id;
}
starCreate(this.postForm).then(response => {
this.$notify({
title: '成功',
......@@ -336,16 +341,14 @@
})
},
appendUser() {
if (isInArray(this.group_ids, this.temp_group_ids)){
this.$message({
message: '数据添加重复',
type: 'error'
})
return false;
if (!this.temp_group_ids){
this.$message.error('还没输入小组呢~~')
this.temp_group_ids = ''
return false
}
GroupDetail(this.temp_group_ids).then(response => {
if (!response.data.data) return
this.tableData.push(...response.data.data)
this.tableData.push(response.data.data)
this.total = this.tableData.length
})
this.group_ids.push(this.temp_group_ids)
......@@ -353,7 +356,24 @@
},
delUser() {
let origin_group_ids = [];
var left_group_ids = [];
let select_group_ids = []
this.del_list.push(...this.multipleSelection)
for (let i = 0; i < this.tableData.length; i++){
origin_group_ids.push(this.tableData[i].id)
}
for (let i = 0; i < this.multipleSelection.length; i++){
select_group_ids.push(this.multipleSelection[i].id)
}
for (let i =0; i < origin_group_ids.length; i++){
if (!isInArray(select_group_ids ,origin_group_ids[i])){
left_group_ids.push(origin_group_ids[i])
}
}
this.group_ids = left_group_ids;
},
handleSelectionChange(val) {
this.multipleSelection = val;
......
......@@ -34,7 +34,7 @@
<el-table-column align="center" label="性别">
<template slot-scope="scope">
<el-tag :type="scope.row.gender | genderFilter">{{ scope.row.gender==0 ? '男' : '女' }}</el-tag>
<el-tag>{{ scope.row.gender==0 ? '男' : '女' }}</el-tag>
</template>
</el-table-column>
......@@ -54,7 +54,7 @@
<el-table-column align="center" label="下线">
<template slot-scope="scope">
<el-tag :type="scope.row.is_online | isOnlineFilter">{{ scope.row.is_online==1 ? '是' : '否' }}</el-tag>
<el-tag>{{ scope.row.is_online==1 ? '否' : '是' }}</el-tag>
</template>
</el-table-column>
......@@ -73,23 +73,6 @@ import waves from '@/directive/waves'
export default {
name: 'StartList',
components: { Pagination },
filters: {
isOnlineFilter(status) {
const statusMap = {
1: 'success',
0: 'info',
}
return statusMap[status]
},
genderFilter(status) {
const statusMap = {
'男': 'success',
'女': 'info',
'全部': 'danger'
}
return statusMap[status]
},
},
directives: { waves },
data() {
return {
......
......@@ -254,37 +254,16 @@
callback()
}
}
const validateSourceUri = (rule, value, callback) => {
if (value) {
if (validateURL(value)) {
callback()
} else {
this.$message({
message: '外链url填写不正确',
type: 'error'
})
callback(new Error('外链url填写不正确'))
}
} else {
callback()
}
}
return {
postForm: Object.assign({}, defaultForm),
loading: false,
group_ids: [],
groupListOptions: [],
rules: {
image_uri: [{validator: validateRequire}],
image_uri: [{validator: validateRequire, trigger: 'blur'}],
title: [{validator: validateRequire}],
content: [{validator: validateRequire}],
source_uri: [{validator: validateSourceUri, trigger: 'blur'}]
},
// expireTimeOption: {
// disabledDate(date){
// return date.getTime() <= Date.now();
// }
// },
tempRoute: {},
listQuery: {
page: 1,
......
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