This commit is contained in:
caoqianming 2020-04-27 11:35:36 +08:00
parent 860efa9e29
commit c1f545bc68
5 changed files with 23 additions and 12 deletions

View File

@ -60,6 +60,7 @@
v-loading="listLoading" v-loading="listLoading"
highlight-current-row highlight-current-row
max-height="600" max-height="600"
@sort-change="changeSort"
> >
<el-table-column type="index" width="50"></el-table-column> <el-table-column type="index" width="50"></el-table-column>
<el-table-column align="left" label="类型"> <el-table-column align="left" label="类型">
@ -74,10 +75,10 @@
<el-table-column align="left" label="押题卷"> <el-table-column align="left" label="押题卷">
<template slot-scope="scope">{{ scope.row.paper_name }}</template> <template slot-scope="scope">{{ scope.row.paper_name }}</template>
</el-table-column> </el-table-column>
<el-table-column align="left" label="得分"> <el-table-column align="left" label="得分" sortable='custom' prop="score">
<template slot-scope="scope">{{ scope.row.score }}</template> <template slot-scope="scope">{{ scope.row.score }}</template>
</el-table-column> </el-table-column>
<el-table-column align="left" label="耗时(秒)"> <el-table-column align="left" label="耗时(时分秒)" sortable='custom' prop="took">
<template slot-scope="scope">{{ scope.row.took_format }}</template> <template slot-scope="scope">{{ scope.row.took_format }}</template>
</el-table-column> </el-table-column>
<el-table-column align="left" label="答题时间"> <el-table-column align="left" label="答题时间">
@ -214,6 +215,16 @@ export default {
this.listQuery.start = this.value[0], this.listQuery.start = this.value[0],
this.listQuery.end = this.value[1], this.listQuery.end = this.value[1],
this.getList() this.getList()
},
changeSort (val) {
if(val.order == 'ascending'){
this.listQuery.ordering = val.prop
}else{
this.listQuery.ordering = '-' + val.prop
}
this.getList()
} }
} }
}; };

View File

@ -86,7 +86,7 @@
<el-table-column align="center" label="姓名"> <el-table-column align="center" label="姓名">
<template slot-scope="scope">{{ scope.row.name }}</template> <template slot-scope="scope">{{ scope.row.name }}</template>
</el-table-column> </el-table-column>
<el-table-column align="header-center" label="手机号"> <el-table-column align="header-center" label="手机号" sortable='custom' prop="username">
<template slot-scope="scope">{{ scope.row.username }}</template> <template slot-scope="scope">{{ scope.row.username }}</template>
</el-table-column> </el-table-column>
<el-table-column align="header-center" label="小程序OpenId"> <el-table-column align="header-center" label="小程序OpenId">
@ -95,7 +95,7 @@
<el-table-column align="header-center" label="微信昵称"> <el-table-column align="header-center" label="微信昵称">
<template slot-scope="scope">{{ scope.row.nickname }}</template> <template slot-scope="scope">{{ scope.row.nickname }}</template>
</el-table-column> </el-table-column>
<el-table-column align="header-center" label="单位"> <el-table-column align="header-center" label="单位" sortable='custom' prop="company">
<template <template
slot-scope="scope" slot-scope="scope"
v-if="scope.row.company_name != null" v-if="scope.row.company_name != null"
@ -110,7 +110,7 @@
</el-tag> </el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column align="center" label="工作类别"> <el-table-column align="center" label="工作类别" sortable='custom' prop="workscope">
<template slot-scope="scope" > <template slot-scope="scope" >
<el-tag v-if="scope.row.workscope_name">{{ scope.row.workscope_name }}</el-tag> <el-tag v-if="scope.row.workscope_name">{{ scope.row.workscope_name }}</el-tag>
</template> </template>
@ -317,9 +317,9 @@ export default {
if (!value) return true; if (!value) return true;
return data.label.indexOf(value) !== -1; return data.label.indexOf(value) !== -1;
}, },
getList(query = this.listQuery) { getList() {
this.listLoading = true; this.listLoading = true;
getConsumerList(query).then(response => { getConsumerList(this.listQuery).then(response => {
this.consumerList = response.data.results; this.consumerList = response.data.results;
this.total = response.data.count; this.total = response.data.count;
this.listLoading = false; this.listLoading = false;
@ -453,7 +453,7 @@ export default {
this.listQuery.ordering = '-' + val.prop this.listQuery.ordering = '-' + val.prop
} }
this.getList() this.getList()
} }
} }

View File

@ -3,7 +3,7 @@
<el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on" label-position="left"> <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on" label-position="left">
<div class="title-container"> <div class="title-container">
<h3 class="title">答题平台后台管理</h3> <h3 class="title">辐射学堂后台管理</h3>
</div> </div>
<el-form-item prop="username"> <el-form-item prop="username">

View File

@ -81,8 +81,8 @@ class ConsumerViewSet(ModelViewSet):
queryset = Consumer.objects.filter(is_delete=0).all() queryset = Consumer.objects.filter(is_delete=0).all()
serializer_class = ConsumerSerializer serializer_class = ConsumerSerializer
pagination_class = CommonPagination pagination_class = CommonPagination
ordering_fields = ('id','company','create_time') ordering_fields = ('id','company','create_time', 'username', 'workscope')
ordering = ['-create_time', 'company'] ordering = ['-create_time']
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter] filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
filterset_fields = ('company',) filterset_fields = ('company',)
search_fields = ('^name','^username') search_fields = ('^name','^username')

View File

@ -205,7 +205,7 @@ class ExamTestViewSet(ModelViewSet):
pagination_class = CommonPagination pagination_class = CommonPagination
queryset = ExamTest.objects.filter(is_delete=0).all() queryset = ExamTest.objects.filter(is_delete=0).all()
serializer_class = ExamTestListSerializer serializer_class = ExamTestListSerializer
ordering_fields = ('id','create_time') ordering_fields = ('id','create_time','took','score')
ordering = ['-create_time'] ordering = ['-create_time']
search_fields = ('^name',) search_fields = ('^name',)
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter] filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]