Commit ba219b88 authored by Davve's avatar Davve

完成明星相关

parent a7b59391
...@@ -40,23 +40,10 @@ class GroupUpdateOrCreate(APIView): ...@@ -40,23 +40,10 @@ class GroupUpdateOrCreate(APIView):
def get(self, request): def get(self, request):
id = request.GET.get('id') id = request.GET.get('id')
try: try:
data = self.rpc['venus/community/group/detail'](id=id).unwrap() data = self.rpc['venus/sun/group/get'](id=id).unwrap()
except Exception as e: except Exception as e:
data = [{ raise e
'id': 1, return [data]
'name': '我是一个小组名称',
'description': '小组简介简介',
'user_nums': 22,
'topic_nums': 32,
'user': {
'id': 22,
'name': '真好',
}
},]
return {
'total': 20,
'data': data
}
def post(self, request): def post(self, request):
pass pass
\ No newline at end of file
...@@ -10,7 +10,7 @@ class GroupSearchView(APIView): ...@@ -10,7 +10,7 @@ class GroupSearchView(APIView):
def get(self, request): def get(self, request):
name = request.GET.get('name') name = request.GET.get('name')
try: try:
data = self.rpc['venus/community/group/search'](name=name).unwrap() data = self.rpc['venus/sun/group/search'](name=name).unwrap()
except Exception as e: except Exception as e:
raise e raise e
...@@ -21,7 +21,7 @@ class RegionSearchView(APIView): ...@@ -21,7 +21,7 @@ class RegionSearchView(APIView):
def get(self, request): def get(self, request):
name = request.GET.get('name') name = request.GET.get('name')
try: try:
data = self.rpc['venus/community/country/search'](name=name).unwrap() data = self.rpc['venus/sun/country/search'](name=name).unwrap()
except Exception as e: except Exception as e:
raise e raise e
return {'data': data} return {'data': data}
...@@ -31,7 +31,7 @@ class UserSearchView(APIView): ...@@ -31,7 +31,7 @@ class UserSearchView(APIView):
def get(self, request): def get(self, request):
name = request.GET.get('name') name = request.GET.get('name')
try: try:
data = self.rpc['venus/community/user/search'](name=name).unwrap() data = self.rpc['venus/sun/user/search'](name=name).unwrap()
except Exception as e: except Exception as e:
raise e raise e
return {'data': data} return {'data': data}
...@@ -41,7 +41,7 @@ class TagSearchView(APIView): ...@@ -41,7 +41,7 @@ class TagSearchView(APIView):
def get(self, request): def get(self, request):
name = request.GET.get('name') name = request.GET.get('name')
try: try:
data = self.rpc['venus/community/tag/search'](name=name).unwrap() data = self.rpc['venus/sun/tag/search'](name=name).unwrap()
except Exception as e: except Exception as e:
raise e raise e
return {'data': data} return {'data': data}
...@@ -51,7 +51,17 @@ class StarSearchView(APIView): ...@@ -51,7 +51,17 @@ class StarSearchView(APIView):
def get(self, request): def get(self, request):
name = request.GET.get('name') name = request.GET.get('name')
try: try:
data = self.rpc['venus/community/star/search'](name=name).unwrap() data = self.rpc['venus/sun/star/search'](name=name).unwrap()
except Exception as e: except Exception as e:
raise e raise e
return {'data': data} return {'data': data}
\ No newline at end of file
class CitySearchView(APIView):
def get(self, request):
name = request.GET.get('name')
try:
data = self.rpc['venus/sun/city/search'](name=name).unwrap()
except Exception as e:
raise e
return {'data': data}
...@@ -9,11 +9,11 @@ from utils.base import APIView ...@@ -9,11 +9,11 @@ from utils.base import APIView
class StarListView(APIView): class StarListView(APIView):
def get(self, request): def get(self, request):
page = int(request.GET.get('page', 1)) page = int(request.GET.get('page', 0))
limit = int(request.GET.get('limit', 10)) limit = int(request.GET.get('limit', 10))
filter = self.handle_filter(request.GET.get('filter', "")) filter = self.handle_filter(request.GET.get('filter', ""))
try: try:
data = self.rpc['venus/community/star/get'](offset=page, limit=limit, filters=filter).unwrap() data = self.rpc['venus/sun/star/list'](offset=page, limit=limit, filters=filter).unwrap()
except Exception as e: except Exception as e:
raise e raise e
return data return data
...@@ -23,25 +23,41 @@ class StarUpdateOrCreate(APIView): ...@@ -23,25 +23,41 @@ class StarUpdateOrCreate(APIView):
def get(self, request): def get(self, request):
id = request.GET.get('id') id = request.GET.get('id')
try: try:
data = self.rpc['venus/community/star/detail'](id=id).unwrap() data = self.rpc['venus/sun/star/get'](id=id).unwrap()
except Exception as e: except Exception as e:
raise e raise e
return {'data': data} return {'data': data}
def post(self, request): def post(self, request):
id = request.POST.get('id', '')
data = { data = {
'name': request.POST.get('name'),
'gender': request.POST.get('gender'), 'gender': request.POST.get('gender'),
'region': request.POST.get('region'), 'city_id': request.POST.get('city'),
'is_online': request.POST.get('is_online'), 'is_online': int(request.POST.get('is_online')),
'description': request.POST.get('description'), 'description': request.POST.get('description'),
'avatar': request.POST.get('avatar')[:-2], 'icon': request.POST.get('avatar'),
'group_ids': list(set(json.loads(request.POST.get('group_ids', [])))), 'group_ids': list(set(json.loads(request.POST.get('group_ids', [])))),
} }
print(json.loads(request.POST.get('group_ids', [])))
try: try:
self.rpc['venus/community/star/create'](data=data).unwrap() self.rpc['venus/sun/star/edit'](id=id, data=data).unwrap()
except Exception as e: except Exception as e:
raise e raise e
return { return {
'message': '更新成功' 'message': '更新成功'
} }
\ No newline at end of file
class StarRelatedGroup(APIView):
def get(self, request):
id = request.GET.get('id')
offset = int(request.GET.get('page', 0))
count = int(request.GET.get('limit', 10))
filters = {'star_id': id}
try:
data = self.rpc['venus/sun/group/list'](filters=filters, offset=offset, limit=count).unwrap()
except Exception as e:
raise e
return data
...@@ -43,6 +43,7 @@ urlpatterns = [ ...@@ -43,6 +43,7 @@ urlpatterns = [
url(r'star/list$', StarListView.as_view()), url(r'star/list$', StarListView.as_view()),
url(r'star/create', StarUpdateOrCreate.as_view()), url(r'star/create', StarUpdateOrCreate.as_view()),
url(r'star/detail', StarUpdateOrCreate.as_view()), url(r'star/detail', StarUpdateOrCreate.as_view()),
url(r'star/star_related_group_info', StarRelatedGroup.as_view()),
# push相关 # push相关
url(r'push/list$', PushListView.as_view()), url(r'push/list$', PushListView.as_view()),
...@@ -68,6 +69,7 @@ search_urlpatterns = [ ...@@ -68,6 +69,7 @@ search_urlpatterns = [
url(r'search/user', UserSearchView.as_view()), url(r'search/user', UserSearchView.as_view()),
url(r'search/tag', TagSearchView.as_view()), url(r'search/tag', TagSearchView.as_view()),
url(r'search/star', StarSearchView.as_view()), url(r'search/star', StarSearchView.as_view()),
url(r'search/city', CitySearchView.as_view()),
] ]
common_urlpatterns = [ common_urlpatterns = [
......
...@@ -39,3 +39,11 @@ export function starSearch(name) { ...@@ -39,3 +39,11 @@ export function starSearch(name) {
params: { name } params: { name }
}) })
} }
export function citySearch(name) {
return request({
url: '/api/search/city',
method: 'get',
params: { name }
})
}
...@@ -324,3 +324,16 @@ export function removeByvale(arr, val) { ...@@ -324,3 +324,16 @@ export function removeByvale(arr, val) {
} }
} }
} }
export function Assembledata(target, source) {
var region_data = []
for (var i=0;i<target.length;i++){
if (isInArray(source, target[i]['name'])){
region_data.push(target[i]['id'])
console.log(region_data)
removeByvale(source, target[i]['name']);
}
}
region_data.push(...source)
return region_data.join(',')
}
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item style="margin-bottom: 20px;" label-width="75px" label="明星ID:" v-if="isEdit"> <el-form-item style="margin-bottom: 20px;" label-width="75px" label="明星ID:" v-if="isEdit">
<el-input v-model="postForm.ID" type="text" placeholder="请输入内容" style="width: 230px;" readonly/> <el-input v-model="postForm.id" type="text" style="width: 230px;" readonly/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
...@@ -37,13 +37,13 @@ ...@@ -37,13 +37,13 @@
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item style="margin-bottom: 20px;" label-width="45px" label="用户:" prop="desc" <el-form-item style="margin-bottom: 20px;" label-width="75px" label="用户数:"
v-if="isEdit"> v-if="isEdit">
<el-input v-model="postForm.user_nums" type="number" style="width: 220px;" readonly/> <el-input v-model="postForm.user_nums" type="number" style="width: 220px;" readonly/>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item style="margin-bottom: 20px;" label-width="45px" label="帖子:" prop="desc" <el-form-item style="margin-bottom: 20px;" label-width="75px" label="帖子数:"
v-if="isEdit"> v-if="isEdit">
<el-input v-model="postForm.topic_nums" type="number" style="width: 220px;" readonly/> <el-input v-model="postForm.topic_nums" type="number" style="width: 220px;" readonly/>
</el-form-item> </el-form-item>
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12"> <el-col :span="12">
<el-form-item style="margin-bottom: 20px;" label-width="45px" label="小组:" v-if="isEdit"> <el-form-item style="margin-bottom: 20px;" label-width="75px" label="小组数:" v-if="isEdit">
<el-input v-model="postForm.group_nums" type="number" style="width: 220px;" readonly/> <el-input v-model="postForm.group_nums" type="number" style="width: 220px;" readonly/>
</el-form-item> </el-form-item>
</el-col> </el-col>
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
</div> </div>
</el-col> </el-col>
</div> </div>
<el-form-item label-width="45px" label="性别:" style="margin-left: 10px"> <el-form-item label-width="75px" label="性别:" style="margin-left: 10px">
<el-select v-model="postForm.gender" :placeholder="'性别:'" clearable <el-select v-model="postForm.gender" :placeholder="'性别:'" clearable
class="postInfo-container-item" class="postInfo-container-item"
style="width: 220px"> style="width: 220px">
...@@ -71,14 +71,14 @@ ...@@ -71,14 +71,14 @@
:value="item.key"/> :value="item.key"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label-width="45px" label="地区:" style="margin-left: 10px"> <el-form-item label-width="75px" label="城市:" style="margin-left: 10px">
<el-select v-model="postForm.region" :remote-method="getRemoteRegionList" filterable remote <el-select v-model="postForm.city" :remote-method="getRemoteCityList" filterable remote
value-key="id" value-key="id"
placeholder="搜索地区" style="width: 220px"> placeholder="搜索地区" style="width: 220px">
<el-option v-for="(item,index) in regionListOptions" :key="item+index" :label="item.name" :value="item.id"/> <el-option v-for="(item,index) in regionListOptions" :key="item+index" :label="item.name" :value="item.id"/>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item style="margin-bottom: 20px;margin-left: 10px" label-width="45px" label="下线:"> <el-form-item style="margin-bottom: 20px;margin-left: 10px" label-width="75px" label="下线:">
<el-radio-group v-model="postForm.is_online"> <el-radio-group v-model="postForm.is_online">
<el-radio :label="1"></el-radio> <el-radio :label="1"></el-radio>
<el-radio :label="0"></el-radio> <el-radio :label="0"></el-radio>
...@@ -149,7 +149,7 @@ ...@@ -149,7 +149,7 @@
</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.user.name }}</span> <span>{{ scope.row.creator_name }}</span>
</template> </template>
</el-table-column> </el-table-column>
...@@ -173,17 +173,18 @@ ...@@ -173,17 +173,18 @@
import Pagination from '@/components/Pagination' import Pagination from '@/components/Pagination'
import {starCreate, starDetail, fetchStarRelatedGroup} from '@/api/star' import {starCreate, starDetail, fetchStarRelatedGroup} from '@/api/star'
import { GroupDetail } from '@/api/group' import { GroupDetail } from '@/api/group'
import {regionSearch, groupSearch} from '@/api/remoteSearch' import {citySearch, groupSearch} from '@/api/remoteSearch'
import { isInArray } from "@/utils";
const defaultForm = { const defaultForm = {
status: 'draft', status: 'draft',
name: '', name: '',
id: '',
gender: '', gender: '',
region: '', city: '',
is_online: undefined, is_online: undefined,
description: '', description: '',
avatar: '', avatar: '',
group_ids: [],
} }
export default { export default {
...@@ -212,7 +213,8 @@ ...@@ -212,7 +213,8 @@
postForm: Object.assign({}, defaultForm), postForm: Object.assign({}, defaultForm),
loading: false, loading: false,
groupListOptions: [], groupListOptions: [],
temp_group_ids: [], temp_group_ids: '',
group_ids: [],
rules: { rules: {
content: [{validator: validateRequire, trigger: 'blur'}] content: [{validator: validateRequire, trigger: 'blur'}]
}, },
...@@ -233,6 +235,8 @@ ...@@ -233,6 +235,8 @@
page: 0, page: 0,
limit: 10, limit: 10,
}, },
temp_city_id: '',
temp_city_name: '',
} }
}, },
computed: { computed: {
...@@ -270,12 +274,11 @@ ...@@ -270,12 +274,11 @@
}, },
methods: { methods: {
fetchData(id) { fetchData(id) {
fetchArticle(id).then(response => { starDetail(id).then(response => {
this.postForm = response.data let rep = response.data.data.data
// Just for test this.postForm = rep
this.postForm.title += ` Article Id:${this.postForm.id}` this.temp_city_id = response.data.data.data.city.id
this.postForm.content_short += ` Article Id:${this.postForm.id}` this.postForm.city = this.temp_city_name = rep.city.name
}).catch(err => { }).catch(err => {
console.log(err) console.log(err)
}) })
...@@ -284,7 +287,11 @@ ...@@ -284,7 +287,11 @@
this.$refs.postForm.validate(valid => { this.$refs.postForm.validate(valid => {
if (valid) { if (valid) {
this.loading = true this.loading = true
this.postForm.group_ids = JSON.stringify(this.postForm.group_ids) this.postForm.group_ids = JSON.stringify(this.group_ids);
// 处理未修改标签
if (this.temp_city_name === this.postForm.city){
this.postForm.city = this.temp_city_id;
}
starCreate(this.postForm).then(response => { starCreate(this.postForm).then(response => {
this.$notify({ this.$notify({
title: '成功', title: '成功',
...@@ -320,25 +327,30 @@ ...@@ -320,25 +327,30 @@
this.groupListOptions = response.data.data.data this.groupListOptions = response.data.data.data
}) })
}, },
getRemoteRegionList(query) { getRemoteCityList(query) {
regionSearch(query).then(response => { citySearch(query).then(response => {
if (!response.data.data.data) return if (!response.data.data.data) return
this.regionListOptions = response.data.data.data this.regionListOptions = response.data.data.data
}) })
}, },
appendUser() { appendUser() {
if (isInArray(this.group_ids, this.temp_group_ids)){
this.$message({
message: '数据添加重复',
type: 'error'
})
return false;
}
GroupDetail(this.temp_group_ids).then(response => { GroupDetail(this.temp_group_ids).then(response => {
if (!response.data.data.data) return if (!response.data.data) return
this.tableData.push(...response.data.data.data) this.tableData.push(...response.data.data)
this.total = response.data.data.total this.total = this.tableData.length
}) })
this.postForm.group_ids.push(this.temp_group_ids) this.group_ids.push(this.temp_group_ids)
this.temp_group_ids = '' this.temp_group_ids = ''
}, },
delUser() { delUser() {
const lenth = this.multipleSelection.length; this.postForm.group_ids.push(...this.multipleSelection)
this.del_list = this.del_list.concat(this.multipleSelection);
console.log(this.del_list)
}, },
handleSelectionChange(val) { handleSelectionChange(val) {
this.multipleSelection = val; this.multipleSelection = val;
...@@ -354,8 +366,12 @@ ...@@ -354,8 +366,12 @@
getList(id) { getList(id) {
this.listLoading = true this.listLoading = true
fetchStarRelatedGroup(id).then(response => { fetchStarRelatedGroup(id).then(response => {
this.list = [] let rep = response.data.data.data;
this.total = 100 for (let i = 0; i < rep.length; i++){
this.group_ids.push(rep[i].id)
}
this.tableData = response.data.data.data
this.total = response.data.data.total
this.listLoading = false this.listLoading = false
}) })
}, },
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<el-table-column type="selection" align="center"></el-table-column> <el-table-column type="selection" align="center"></el-table-column>
<el-table-column align="center" label="明星ID" width="80"> <el-table-column align="center" label="明星ID" width="80">
<template slot-scope="scope"> <template slot-scope="scope">
<router-link :to="'/pick/edit/'+scope.row.id" class="link-type"> <router-link :to="'/star/edit/'+scope.row.id" class="link-type">
<span>{{ scope.row.id }}</span> <span>{{ scope.row.id }}</span>
</router-link> </router-link>
</template> </template>
...@@ -38,16 +38,16 @@ ...@@ -38,16 +38,16 @@
</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.region }}</span> <span>{{ scope.row.city.name }}</span>
</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">
<router-link :to="'/pick/edit/'+scope.row.id" class="link-type"> <router-link :to="'/group/edit/'+scope.row.id" class="link-type">
<span>{{ scope.row.group_counts }}</span> <span>{{ scope.row.group_nums }}</span>
</router-link> </router-link>
</template> </template>
</el-table-column> </el-table-column>
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
</el-table> </el-table>
<pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" style="margin-left: 150px;" @pagination="getList" /> <pagination v-show="total>0" :total="total" :page="listQuery.page" :limit="listQuery.limit" style="margin-left: 150px;" @pagination="getList" />
</div> </div>
</template> </template>
...@@ -99,7 +99,7 @@ export default { ...@@ -99,7 +99,7 @@ export default {
multipleSelection: [], multipleSelection: [],
del_list: [], del_list: [],
listQuery: { listQuery: {
page: 1, page: 0,
limit: 10, limit: 10,
filter: { filter: {
value: '', value: '',
...@@ -158,12 +158,11 @@ export default { ...@@ -158,12 +158,11 @@ export default {
} }
OffLineOrOnLine({type:val, ids:str}).then(response => { OffLineOrOnLine({type:val, ids:str}).then(response => {
this.multipleSelection = []; this.multipleSelection = [];
response.data.data.message
this.$message.success(response.data.data.message); this.$message.success(response.data.data.message);
}) })
}, },
handleFilter() { handleFilter() {
this.listQuery.page = 1 this.listQuery.page = 0
this.getList() this.getList()
}, },
handleCreate() { handleCreate() {
......
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