This commit is contained in:
shilixia 2020-10-22 15:48:20 +08:00
parent e8653fcaab
commit f6ea77f58b
3 changed files with 121 additions and 30 deletions

View File

@ -58,3 +58,11 @@ export function getQualificationotherList(query) {
params: query
})
}
export function deletes(data)
{
return request({
url: `/ability/qualificationother/deletes/`,
method: 'post',
data
})
}

View File

@ -2,7 +2,7 @@
<div class="app-container">
<el-row :gutter="6">
<el-col :xs="24" :md="4">
<el-select v-model="listQuery.sszx" placeholder="所属单位" @change="handleFilter2" clearable style="width: 100%;">
<el-select v-model="listQuery.qualification__sszx" placeholder="所属单位" @change="handleFilter2" clearable style="width: 100%;">
<el-option
v-for="item in groupBy.sszx"
:key="item.value"
@ -65,22 +65,30 @@
<el-button slot="reference">导入资质</el-button>
</el-popover>
<el-button @click="delAll()" v-if="checkPermission(['qualification_deletes'])">批量删除</el-button>
</div>
<el-table
v-loading="listLoading"
:data="tableData.results"
:span-method="objectSpanMethod"
style="width: 100%;margin-top:10px;"
border
fit
stripe
highlight-current-row
max-height="700"
height="600"
ref="filterTable"
@selection-change="handleSelectionChange"
@filter-change="filterChange"
>
<el-table-column fixed type="index" width="50" />
<el-table-column fixed label="所属单位" width="150"
<el-table-column
type="selection"
width="55">
</el-table-column>
<el-table-column label="所属单位"
prop="sszx"
column-key="sszx"
:filters="groupBy.sszx"
@ -88,52 +96,34 @@
>
<template slot-scope="scope">{{ scope.row.qualification_.sszx }}</template>
</el-table-column>
<el-table-column width="150" fixed label="CMA资质">
<el-table-column label="CMA资质">
<template slot-scope="scope">
<span v-html="showlight(scope.row.qualification_.cma)"></span>
</template>
</el-table-column>
<el-table-column width="150" fixed label="CNAS资质">
<el-table-column label="CNAS资质">
<template slot-scope="scope">
<span v-html="showlight(scope.row.qualification_.cnas)"></span>
</template>
</el-table-column>
<el-table-column width="1050" label="检验检测相关其他资质及校准资质">
<el-table-column label="其它资质" width="360">
<el-table-column label="检验检测相关其他资质及校准资质">
<el-table-column label="其它资质" >
<template slot-scope="scope">
<span v-html="showlight(scope.row.name)" ></span>
</template>
</el-table-column>
<el-table-column label="资质范围" width="690">
<el-table-column label="资质范围" >
<template slot-scope="scope">
<span v-html="showlight(scope.row.description)" ></span>
</template>
</el-table-column>
</el-table-column>
<el-table-column fixed="right" width="200" label="主要服务">
<el-table-column label="主要服务">
<template slot-scope="scope">
<span v-html="showlight(scope.row.qualification_.service)"></span>
</template>
</el-table-column>
<el-table-column width="150" fixed="right" label="操作">
<template slot-scope="scope">
<el-button
style="display:none"
:disabled="!checkPermission(['qualification_update'])"
type="primary"
size="small"
icon="el-icon-edit"
@click="handleEdit(scope)"
/>
<el-button
:disabled="!checkPermission(['qualification_delete'])"
type="danger"
size="small"
icon="el-icon-delete"
@click="handleDelete(scope)"
/>
</template>
</el-table-column>
</el-table>
<pagination
@ -181,7 +171,7 @@
}
</style>
<script>
import { getQualificationList,getQualificationotherList, getQualificationGroup, createQualification, updateQualification, deleteQualification, importQualification } from "@/api/qualification";
import { getQualificationList,getQualificationotherList,deletes, getQualificationGroup, createQualification, updateQualification, deleteQualification, importQualification } from "@/api/qualification";
import checkPermission from "@/utils/permission"
import { upUrl, upHeaders } from "@/api/file"
import Pagination from "@/components/Pagination" // secondary package based on el-pagination
@ -210,10 +200,14 @@ export default {
service:null
},
delarr:[],
upHeaders: upHeaders(),
upUrl: upUrl(),
groupBy:{sszx:[]},
tableData: {count:0},
rowIndex: '-1',
OrderIndexArr: [],
hoverOrderArr: [],
listLoading: true,
listQuery: Object.assign({}, dflistQuery),
enabledOptions: [
@ -277,11 +271,89 @@ export default {
this.listLoading = true;
getQualificationotherList(this.listQuery).then(response => {
if (response.data) {
this.tableData = response.data
let OrderObj = {}
this.tableData.results.forEach((element, index) => {
element.rowIndex = index
if (OrderObj[element.qualification_.id]) {
OrderObj[element.qualification_.id].push(index)
} else {
OrderObj[element.qualification_.id] = []
OrderObj[element.qualification_.id].push(index)
}
})
// 将数组长度大于1的值 存储到this.OrderIndexArr也就是需要合并的项
for (let k in OrderObj) {
if (OrderObj[k].length > 1) {
this.OrderIndexArr.push(OrderObj[k])
}
}
}
this.listLoading = false
})
},
// 合并单元格
objectSpanMethod({row,column,rowIndex,columnIndex}) {
if (columnIndex === 1 || columnIndex === 2|| columnIndex === 3|| columnIndex === 6) {
for (let i = 0; i < this.OrderIndexArr.length; i++) {
let element = this.OrderIndexArr[i]
for (let j = 0; j < element.length; j++) {
let item = element[j]
if (rowIndex == item) {
if (j == 0) {
return {
rowspan: element.length,
colspan: 1
}
} else if (j != 0) {
return {
rowspan: 0,
colspan: 0
}
}
}
}
}
}
},
handleSelectionChange(val) {
this.multipleSelection = val;
},
delAll() {
this.$confirm("确认删除?", "警告", {
confirmButtonText: "确认",
cancelButtonText: "取消",
type: "error",
})
.then(async () => {
const lengths = this.multipleSelection.length;
for (let i = 0; i < lengths; i++) {
this.delarr.push(this.multipleSelection[i].id);
}
let data = { ids: this.delarr };
deletes(data)
.then((res) => {
this.$message({
message: "删除成功",
type: "success",
});
this.getList();
})
})
.catch((err) => {
console.error(err);
});
},
getGroup() {
for(let key in this.groupBy){
let data = Object.assign({}, this.listQuery)
@ -313,6 +385,8 @@ export default {
this.$refs["Form"].clearValidate()
})
},
handleEdit(scope) {
this.formData = Object.assign({}, scope.row) // copy obj
this.dialogType = "edit"

View File

@ -178,6 +178,15 @@ class QualificationotherViewSet(ModelViewSet):
'put': 'qualificationother_update', 'delete': 'qualificationother_delete'}
queryset = Qualificationother.objects.all()
serializer_class = QualificationotherSerializer
search_fields = ['qualification__cma', 'name','description','qualification__cnas', 'qualification__sszx', 'qualification__service']
filterset_fields = ['qualification__sszx']
ordering = ['qualification__sszx']
@action(methods=['post'], detail=False, url_path='deletes', url_name='qualificationother_deletes', perms_map = {'post':'qualificationother_deletes'})
def deletes(self, request):
array = request.data['ids']
Qualificationother.objects.filter(pk__in=array).delete()
return Response(status = status.HTTP_200_OK)
class InspectionViewSet(ModelViewSet):
"""
CNAS检测能力增删改查