export
This commit is contained in:
parent
426c2fdae1
commit
860efa9e29
|
@ -171,6 +171,9 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {},
|
computed: {},
|
||||||
|
watch:{
|
||||||
|
value:'setTimeRange',
|
||||||
|
},
|
||||||
created() {
|
created() {
|
||||||
this.getList();
|
this.getList();
|
||||||
},
|
},
|
||||||
|
@ -191,8 +194,9 @@ export default {
|
||||||
this.listQuery = {
|
this.listQuery = {
|
||||||
page: 1,
|
page: 1,
|
||||||
limit: 20,
|
limit: 20,
|
||||||
search:''
|
search:'',
|
||||||
};
|
};
|
||||||
|
this.value = []
|
||||||
this.getList();
|
this.getList();
|
||||||
},
|
},
|
||||||
handleDetail(scope) {
|
handleDetail(scope) {
|
||||||
|
@ -205,6 +209,11 @@ export default {
|
||||||
loading.close()
|
loading.close()
|
||||||
window.open(response.data.path, "_blank");
|
window.open(response.data.path, "_blank");
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
setTimeRange(){
|
||||||
|
this.listQuery.start = this.value[0],
|
||||||
|
this.listQuery.end = this.value[1],
|
||||||
|
this.getList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -36,9 +36,9 @@
|
||||||
placeholder="姓名或手机号"
|
placeholder="姓名或手机号"
|
||||||
style="width: 200px;"
|
style="width: 200px;"
|
||||||
class="filter-item"
|
class="filter-item"
|
||||||
@keyup.enter.native="handleSearch"
|
@keyup.enter.native="handleFilter"
|
||||||
/>
|
/>
|
||||||
<el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleSearch">搜索</el-button>
|
<el-button class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter">搜索</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
class="filter-item"
|
class="filter-item"
|
||||||
type="primary"
|
type="primary"
|
||||||
|
@ -80,6 +80,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="center" label="姓名">
|
<el-table-column align="center" label="姓名">
|
||||||
|
@ -114,7 +115,7 @@
|
||||||
<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>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="创建日期">
|
<el-table-column label="创建日期" sortable='custom' prop="create_time">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span>{{ scope.row.create_time }}</span>
|
<span>{{ scope.row.create_time }}</span>
|
||||||
</template>
|
</template>
|
||||||
|
@ -353,9 +354,6 @@ export default {
|
||||||
this.listQuery.page = 1;
|
this.listQuery.page = 1;
|
||||||
this.getList();
|
this.getList();
|
||||||
},
|
},
|
||||||
handleSearch() {
|
|
||||||
this.getList(this.listQuery);
|
|
||||||
},
|
|
||||||
handleAddUser() {
|
handleAddUser() {
|
||||||
this.consumer = Object.assign({}, defaultConsumer);
|
this.consumer = Object.assign({}, defaultConsumer);
|
||||||
this.dialogType = "new";
|
this.dialogType = "new";
|
||||||
|
@ -396,7 +394,7 @@ export default {
|
||||||
const isEdit = this.dialogType === "edit";
|
const isEdit = this.dialogType === "edit";
|
||||||
if (isEdit) {
|
if (isEdit) {
|
||||||
let consumer = this.consumer
|
let consumer = this.consumer
|
||||||
updateConsumer(this.consumer.id, consumer).then(() => {
|
updateConsumer(this.consumer.id, consumer).then(res => {
|
||||||
// for (let index = 0; index < this.consumerList.length; index++) {
|
// for (let index = 0; index < this.consumerList.length; index++) {
|
||||||
// if (this.consumerList[index].id === this.consumer.id) {
|
// if (this.consumerList[index].id === this.consumer.id) {
|
||||||
// this.consumerList.splice(
|
// this.consumerList.splice(
|
||||||
|
@ -409,12 +407,15 @@ export default {
|
||||||
// }
|
// }
|
||||||
this.getList()
|
this.getList()
|
||||||
this.dialogVisible = false;
|
this.dialogVisible = false;
|
||||||
this.$notify({
|
if(res.code >=200){
|
||||||
title: "成功",
|
this.$notify({
|
||||||
message: "编辑成功",
|
title: "成功",
|
||||||
type: "success",
|
message: "编辑成功",
|
||||||
duration: 2000
|
type: "success",
|
||||||
});
|
duration: 2000
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
createConsumer(this.consumer).then(res => {
|
createConsumer(this.consumer).then(res => {
|
||||||
|
@ -422,12 +423,15 @@ export default {
|
||||||
// this.consumerList.unshift(this.consumer)
|
// this.consumerList.unshift(this.consumer)
|
||||||
this.getList();
|
this.getList();
|
||||||
this.dialogVisible = false;
|
this.dialogVisible = false;
|
||||||
this.$notify({
|
if(res.code >=200){
|
||||||
|
this.$notify({
|
||||||
title: "成功",
|
title: "成功",
|
||||||
message: "新增成功",
|
message: "新增成功",
|
||||||
type: "success",
|
type: "success",
|
||||||
duration: 2000
|
duration: 2000
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -441,6 +445,16 @@ export default {
|
||||||
loading.close()
|
loading.close()
|
||||||
window.open(response.data.path, "_blank");
|
window.open(response.data.path, "_blank");
|
||||||
});
|
});
|
||||||
|
},
|
||||||
|
changeSort (val) {
|
||||||
|
if(val.order == 'ascending'){
|
||||||
|
this.listQuery.ordering = val.prop
|
||||||
|
}else{
|
||||||
|
this.listQuery.ordering = '-' + val.prop
|
||||||
|
}
|
||||||
|
|
||||||
|
this.getList()
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -82,7 +82,7 @@ class ConsumerViewSet(ModelViewSet):
|
||||||
serializer_class = ConsumerSerializer
|
serializer_class = ConsumerSerializer
|
||||||
pagination_class = CommonPagination
|
pagination_class = CommonPagination
|
||||||
ordering_fields = ('id','company','create_time')
|
ordering_fields = ('id','company','create_time')
|
||||||
ordering = ['company','-create_time']
|
ordering = ['-create_time', 'company']
|
||||||
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
|
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
|
||||||
filterset_fields = ('company',)
|
filterset_fields = ('company',)
|
||||||
search_fields = ('^name','^username')
|
search_fields = ('^name','^username')
|
||||||
|
@ -94,10 +94,8 @@ class ConsumerViewSet(ModelViewSet):
|
||||||
|
|
||||||
def create(self, request, *args, **kwargs):
|
def create(self, request, *args, **kwargs):
|
||||||
serializer = self.get_serializer(data=request.data)
|
serializer = self.get_serializer(data=request.data)
|
||||||
if serializer.is_valid():
|
serializer.is_valid(raise_exception=True)
|
||||||
instance = serializer.save()
|
instance = serializer.save()
|
||||||
else:
|
|
||||||
return Response(serializer.errors)
|
|
||||||
if request.data.get('subjects', None):
|
if request.data.get('subjects', None):
|
||||||
for i in request.data.get('subjects'):
|
for i in request.data.get('subjects'):
|
||||||
PaySubject.objects.get_or_create(consumer = instance, subject__id=i, defaults={'consumer':instance,'subject':Questioncat.objects.get(id=i)})
|
PaySubject.objects.get_or_create(consumer = instance, subject__id=i, defaults={'consumer':instance,'subject':Questioncat.objects.get(id=i)})
|
||||||
|
@ -190,7 +188,6 @@ class ConsumerViewSet(ModelViewSet):
|
||||||
if sheet['d2'].value != '工作类别':
|
if sheet['d2'].value != '工作类别':
|
||||||
return Response({"error":"工作类别列错误!"})
|
return Response({"error":"工作类别列错误!"})
|
||||||
companydict = {}
|
companydict = {}
|
||||||
consumerdict = {}
|
|
||||||
companys = Company.objects.filter(is_delete=0)
|
companys = Company.objects.filter(is_delete=0)
|
||||||
for i in companys:
|
for i in companys:
|
||||||
companydict[i.name] = i.id
|
companydict[i.name] = i.id
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from django.db.models import Avg
|
from django.db.models import Avg
|
||||||
|
from django.db.models.query import QuerySet
|
||||||
from django_filters.rest_framework import DjangoFilterBackend
|
from django_filters.rest_framework import DjangoFilterBackend
|
||||||
from openpyxl import Workbook, load_workbook
|
from openpyxl import Workbook, load_workbook
|
||||||
from rest_framework import status
|
from rest_framework import status
|
||||||
|
@ -210,6 +211,22 @@ class ExamTestViewSet(ModelViewSet):
|
||||||
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
|
filter_backends = [DjangoFilterBackend, SearchFilter, OrderingFilter]
|
||||||
filterset_fields = ['type','is_pass']
|
filterset_fields = ['type','is_pass']
|
||||||
|
|
||||||
|
def get_queryset(self):
|
||||||
|
assert self.queryset is not None, (
|
||||||
|
"'%s' should either include a `queryset` attribute, "
|
||||||
|
"or override the `get_queryset()` method."
|
||||||
|
% self.__class__.__name__
|
||||||
|
)
|
||||||
|
queryset = self.queryset
|
||||||
|
|
||||||
|
if isinstance(queryset, QuerySet):
|
||||||
|
# Ensure queryset is re-evaluated on each request.
|
||||||
|
queryset = queryset.all()
|
||||||
|
if self.request.query_params.get('start'):
|
||||||
|
queryset = queryset.filter(start_time__gte=self.request.query_params['start'] )
|
||||||
|
if self.request.query_params.get('end'):
|
||||||
|
queryset = queryset.filter(start_time__lte=self.request.query_params['end'])
|
||||||
|
return queryset
|
||||||
@action(methods=['get'], detail=False,url_path='self', url_name='selftest', perms_map = [{'*':'my_examtest'}])
|
@action(methods=['get'], detail=False,url_path='self', url_name='selftest', perms_map = [{'*':'my_examtest'}])
|
||||||
def selftest(self, request, pk=None):
|
def selftest(self, request, pk=None):
|
||||||
'''
|
'''
|
||||||
|
@ -263,7 +280,7 @@ class ExamTestViewSet(ModelViewSet):
|
||||||
@action(methods=['get'], detail=False,
|
@action(methods=['get'], detail=False,
|
||||||
url_path='export', url_name='export_test', perms_map=[{'*':'export_test'}])
|
url_path='export', url_name='export_test', perms_map=[{'*':'export_test'}])
|
||||||
def export(self, request):
|
def export(self, request):
|
||||||
queryset = self.filter_queryset(self.queryset)
|
queryset = self.filter_queryset(self.get_queryset())
|
||||||
queryset = ExamTestListSerializer.setup_eager_loading(queryset) # 性能优化
|
queryset = ExamTestListSerializer.setup_eager_loading(queryset) # 性能优化
|
||||||
serializer = ExamTestListSerializer(instance=queryset, many=True)
|
serializer = ExamTestListSerializer(instance=queryset, many=True)
|
||||||
path = export_test(serializer.data)
|
path = export_test(serializer.data)
|
||||||
|
|
Loading…
Reference in New Issue