检验资质排序

This commit is contained in:
shilixia 2020-10-28 12:05:42 +08:00
parent 4905729e07
commit 243f6996c1
4 changed files with 54 additions and 37 deletions

View File

@ -9,7 +9,7 @@ export function getQualificationList(query) {
} }
export function getQualificationGroup(query) { export function getQualificationGroup(query) {
return request({ return request({
url: '/system/organization/group/', url: '/ability/qualification/group/',
method: 'get', method: 'get',
params: query params: query
}) })
@ -58,6 +58,13 @@ export function getQualificationotherList(query) {
params: query params: query
}) })
} }
export function getQualificationGroup1(query) {
return request({
url: '/ability/qualificationother/group/',
method: 'get',
params: query
})
}
export function deletes(data) export function deletes(data)
{ {
return request({ return request({

View File

@ -4,10 +4,10 @@
<el-col :xs="24" :md="4"> <el-col :xs="24" :md="4">
<el-select v-model="listQuery.qualification__ssbm__name" placeholder="所属单位" @change="handleFilter2" clearable style="width: 100%;"> <el-select v-model="listQuery.qualification__ssbm__name" placeholder="所属单位" @change="handleFilter2" clearable style="width: 100%;">
<el-option <el-option
v-for="item in groupBy.name" v-for="item in groupBy.qualification__ssbm__name"
:key="item.value" :key="item.value"
:label="item.text" :label="item.text"
:value="item.value"> :value="item.value">
</el-option> </el-option>
</el-select> </el-select>
</el-col> </el-col>
@ -76,9 +76,10 @@
style="width: 100%;margin-top:10px;" style="width: 100%;margin-top:10px;"
border border
fit fit
stripe stripe
highlight-current-row highlight-current-row
height="650"
ref="filterTable" ref="filterTable"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
@filter-change="filterChange" @filter-change="filterChange"
@ -138,8 +139,9 @@
} }
</style> </style>
<script> <script>
import { getQualificationList,getQualificationotherList,deletes, getQualificationGroup, createQualification, updateQualification, deleteQualification, importQualification } from "@/api/qualification"; import { getQualificationList,getQualificationotherList,deletes, getQualificationGroup1, createQualification, updateQualification, deleteQualification, importQualification } from "@/api/qualification";
import checkPermission from "@/utils/permission" import checkPermission from "@/utils/permission"
import {getOrgList} from "@/api/org";
import { upUrl, upHeaders } from "@/api/file" import { upUrl, upHeaders } from "@/api/file"
import Pagination from "@/components/Pagination" // secondary package based on el-pagination import Pagination from "@/components/Pagination" // secondary package based on el-pagination
const defaultCMA = { const defaultCMA = {
@ -162,7 +164,7 @@ export default {
delarr:[], delarr:[],
upHeaders: upHeaders(), upHeaders: upHeaders(),
upUrl: upUrl(), upUrl: upUrl(),
groupBy:{name:[]}, groupBy:{qualification__ssbm__name:[]},
tableData: [], tableData: [],
rowIndex: '-1', rowIndex: '-1',
OrderIndexArr: [], OrderIndexArr: [],
@ -233,9 +235,8 @@ delarr:[],
this.tableData = response.data this.tableData = response.data
let OrderObj = {}
let OrderObj = {}
this.tableData.forEach((element, index) => { this.tableData.forEach((element, index) => {
element.rowIndex = index element.rowIndex = index
if (OrderObj[element.qualification_.id]) { if (OrderObj[element.qualification_.id]) {
@ -244,8 +245,11 @@ delarr:[],
OrderObj[element.qualification_.id] = [] OrderObj[element.qualification_.id] = []
OrderObj[element.qualification_.id].push(index) OrderObj[element.qualification_.id].push(index)
} }
}) })
this.$nextTick(()=>{
this.$refs.filterTable.doLayout()
})
// 将数组长度大于1的值 存储到this.OrderIndexArr也就是需要合并的项 // 将数组长度大于1的值 存储到this.OrderIndexArr也就是需要合并的项
for (let k in OrderObj) { for (let k in OrderObj) {
if (OrderObj[k].length > 1) { if (OrderObj[k].length > 1) {
@ -254,7 +258,9 @@ delarr:[],
} }
} }
this.listLoading = false this.listLoading = false
}) })
}, },
// 合并单元格 // 合并单元格
objectSpanMethod({row,column,rowIndex,columnIndex}) { objectSpanMethod({row,column,rowIndex,columnIndex}) {
@ -279,8 +285,10 @@ delarr:[],
} }
} }
} }
}, },
handleSelectionChange(val) { handleSelectionChange(val) {
this.multipleSelection = val; this.multipleSelection = val;
}, },
@ -314,13 +322,13 @@ delarr:[],
getGroup() { getGroup() {
for(let key in this.groupBy){ for (let key in this.groupBy) {
let data = Object.assign({}, this.listQuery) let data = Object.assign({}, this.listQuery);
data.group_by = key data.group_by = key;
getQualificationGroup(data).then(response => { getQualificationGroup1(data).then((response) => {
this.groupBy[key] = response.data this.groupBy[key] = response.data;
console.log(response.data) console.log(this.groupBy);
}) });
} }
}, },
resetFilter() { resetFilter() {

View File

@ -180,16 +180,31 @@ class QualificationotherViewSet(PageOrNot,ModelViewSet):
'put': 'qualificationother_update', 'delete': 'qualificationother_delete'} 'put': 'qualificationother_update', 'delete': 'qualificationother_delete'}
queryset = Qualificationother.objects.all() queryset = Qualificationother.objects.all()
serializer_class = QualificationotherSerializer serializer_class = QualificationotherSerializer
search_fields = ['qualification__cma', 'name','description','qualification__cnas', 'qualification__ssbm__name', 'qualification__service'] search_fields = ['qualification__cma', 'name','description','qualification__cnas', 'qualification__ssbm__id', 'qualification__service']
filterset_fields = ['qualification__ssbm__name'] filterset_fields = ['qualification__ssbm__name']
ordering_fields = ['qualification__ssbm__name'] ordering_fields = ['qualification__ssbm__name']
ordering = ['qualification__ssbm__name'] ordering = ['qualification__ssbm__sort']
@action(methods=['post'], detail=False, url_path='deletes', url_name='qualificationother_deletes', perms_map = {'post':'qualificationother_deletes'}) @action(methods=['post'], detail=False, url_path='deletes', url_name='qualificationother_deletes', perms_map = {'post':'qualificationother_deletes'})
def deletes(self, request): def deletes(self, request):
array = request.data['ids'] array = request.data['ids']
Qualificationother.objects.filter(pk__in=array).delete() Qualificationother.objects.filter(pk__in=array).delete()
return Response(status = status.HTTP_200_OK) return Response(status = status.HTTP_200_OK)
@action(methods=['get'], detail=False,url_name='qualification_group_by', perms_map = {'*':'*'})
def group(self, request, pk=None):
"""
聚合查询列
"""
queryset = self.filter_queryset(self.get_queryset())
ret = []
if request.query_params.get('group_by', None):
group_by = request.query_params.get('group_by')
group_by_data = list(queryset.values(group_by).annotate(count=Count(group_by)).order_by('qualification__ssbm__sort', group_by))
for i in group_by_data:
if i[group_by] and i['count']:
ret.append({'text':i[group_by]+'('+ str(i['count']) +')','value':i[group_by]})
return Response(ret)
class InspectionViewSet(ModelViewSet): class InspectionViewSet(ModelViewSet):
""" """
CNAS检测能力增删改查 CNAS检测能力增删改查

View File

@ -21,6 +21,7 @@ from rest_framework_simplejwt.tokens import RefreshToken
from utils.queryset import get_child_queryset2 from utils.queryset import get_child_queryset2
from django.db.models import Count from django.db.models import Count
from utils.pagination import PageOrNot
from .filters import UserFilter from .filters import UserFilter
from .models import (Dict, DictType, File, Message, Organization, Permission, from .models import (Dict, DictType, File, Message, Organization, Permission,
Position, Role, User) Position, Role, User)
@ -174,7 +175,7 @@ class PermissionViewSet(ModelViewSet):
ordering = 'sort' ordering = 'sort'
class OrganizationViewSet(ModelViewSet): class OrganizationViewSet(PageOrNot,ModelViewSet):
""" """
组织机构增删改查 组织机构增删改查
""" """
@ -186,21 +187,7 @@ class OrganizationViewSet(ModelViewSet):
search_fields = ['name'] search_fields = ['name']
ordering_fields = ['sort'] ordering_fields = ['sort']
ordering = ['sort', 'pk'] ordering = ['sort', 'pk']
@action(methods=['get'], detail=False,url_name='organization_group_by', perms_map = {'*':'*'})
def group(self, request, pk=None):
"""
聚合查询列
"""
queryset = self.filter_queryset(self.get_queryset())
ret = []
if request.query_params.get('group_by', None):
group_by = request.query_params.get('group_by')
group_by_data = list(queryset.values(group_by).annotate(count=Count(group_by)).order_by(group_by))
for i in group_by_data:
if i[group_by] and i['count']:
ret.append({'text':i[group_by]+'('+ str(i['count']) +')','value':i[group_by]})
return Response(ret)
class RoleViewSet(ModelViewSet): class RoleViewSet(ModelViewSet):
""" """
角色增删改查 角色增删改查