添加学科过滤

This commit is contained in:
中青华年 2025-02-23 09:54:25 +08:00
parent 5085c98f31
commit c46475239e
3 changed files with 95 additions and 31 deletions

View File

@ -45,7 +45,25 @@
<!-- </el-table-column>-->
<el-table-column
column-key="majorId"
:filter-multiple="false"
:filters="[
{text: '语文', value: 1},
{text: '地理', value: 4},
{text: '历史', value: 7},
{text: '政治', value: 8}
]"
:filter-method="filterMajor"
prop="majorId"
header-align="center"
align="center"
label="学科">
<template slot-scope="scope">
{{ isMajor(scope.row.majorId) }}
</template>
</el-table-column>
<el-table-column
header-align="center"
align="center"
prop="groupId"
@ -218,7 +236,7 @@ export default {
// }
},
//
getDataList(prop='',sort='') {
getDataList(prop='', sort='', arr='') {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/teach/list'),
@ -228,7 +246,8 @@ export default {
'limit': this.pageSize,
'userName': this.dataForm.userName,
'prop': prop,
'sort': sort
'sort': sort,
'arr': arr
})
}).then(({data}) => {
if (data && data.code === 200) {
@ -290,6 +309,19 @@ export default {
})
}).catch(() => {
})
},
//
filterMajor(value, row) {
return row.majorId == value;
},
//
isMajor(majorId) {
switch (majorId) {
case 1: return '语文'
case 4: return '地理'
case 7: return '历史'
case 8: return '政治'
}
}
}
}

View File

@ -42,6 +42,25 @@
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column
column-key="majorId"
:filter-multiple="false"
:filters="[
{text: '语文', value: 1},
{text: '地理', value: 4},
{text: '历史', value: 7},
{text: '政治', value: 8}
]"
:filter-method="filterMajor"
prop="majorId"
header-align="center"
align="center"
label="学科">
<template slot-scope="scope">
{{ isMajor(scope.row.majorId) }}
</template>
</el-table-column>
<el-table-column
header-align="center"
align="center"
@ -206,7 +225,7 @@ export default {
// }
},
//
getDataList(prop='',sort='') {
getDataList(prop='', sort='', arr='') {
this.dataListLoading = true
this.$http({
url: this.$http.adornUrl('/stu/list'),
@ -216,7 +235,8 @@ export default {
'limit': this.pageSize,
'userName': this.dataForm.userName,
'prop': prop,
'sort': sort
'sort': sort,
'arr': arr //
})
}).then(({data}) => {
if (data && data.code === 200) {
@ -278,6 +298,17 @@ export default {
})
}).catch(() => {
})
},
filterMajor(value, row) {
return row.majorId == value;
},
isMajor(majorId) {
switch (majorId) {
case 1: return '语文'
case 4: return '地理'
case 7: return '历史'
case 8: return '政治'
}
}
}
}

View File

@ -100,13 +100,19 @@
<el-table-column sortable="custom" prop="sex" header-align="center" align="center" label="性别">
</el-table-column>
<el-table-column
v-if="isAuth('sys:user:list')"
:show-overflow-tooltip="true"
min-width="120"
column-key="majorId"
:filter-multiple="false"
:filters="[{text: '语文', value: 1}, {text: '地理', value: 4}, {text: '历史', value: 7}, {text: '政治', value: 8}]"
filter-placement="bottom-end"
prop="majorId" header-align="center" align="center" label="学科">
:filters="[
{text: '语文', value: 1},
{text: '地理', value: 4},
{text: '历史', value: 7},
{text: '政治', value: 8}
]"
:filter-method="filterMajor"
prop="majorId"
header-align="center"
align="center"
label="学科">
<template slot-scope="scope">
{{ isMajor(scope.row.majorId) }}
</template>
@ -327,25 +333,16 @@ export default {
// const property = column["property"];
// return row[property] === value;
// },
filterChange(value){
console.log(value)
let arr=''
console.log(value["el-table_1_column_7"])
value["el-table_1_column_7"].forEach((item) => {
if (item) {
arr += item + ','
}
})
this.getDataList('','',arr).then(()=>{
this.myPageSize=[this.totalCount]
if (value["el-table_1_column_7"].length===0){
this.myPageSize=[5,10, 20, 50, 100,500]
}
})
filterChange(value) {
const majorFilter = value.majorId || []
const majorIds = majorFilter.join(',')
// value.forEach((item) => {
// console.log(item)
// })
//
this.pageIndex = 1
//
this.myPageSize = [5, 10, 20, 50, 100, 500]
this.getDataList('', '', majorIds)
},
isMajor(majorId) {
@ -511,7 +508,7 @@ export default {
// }
},
//
async getDataList(prop='',sort='',arr='') {
async getDataList(prop = '', sort = '', arr = '') {
this.dataListLoading = true
await this.$http({
url: this.$http.adornUrl('/wai/list'),
@ -522,7 +519,7 @@ export default {
'userName': this.dataForm.userName,
'prop': prop,
'sort': sort,
'arr':arr
'arr': arr
})
}).then(({data}) => {
if (data && data.code === 200) {
@ -539,7 +536,7 @@ export default {
//
sizeChangeHandle(val) {
this.pageSize = val
this.pageIndex = 1
this.pageIndex = 1 //
this.getDataList()
},
//
@ -646,6 +643,10 @@ export default {
this.waiCount = {...data.data}
})
},
//
filterMajor(value, row) {
return row.majorId == value;
},
}
}
</script>