添加学科过滤
This commit is contained in:
parent
5085c98f31
commit
c46475239e
|
@ -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 '政治'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 '政治'
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue