添加学科过滤
This commit is contained in:
parent
5085c98f31
commit
c46475239e
|
@ -45,7 +45,25 @@
|
||||||
<!-- </el-table-column>-->
|
<!-- </el-table-column>-->
|
||||||
|
|
||||||
<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"
|
header-align="center"
|
||||||
align="center"
|
align="center"
|
||||||
prop="groupId"
|
prop="groupId"
|
||||||
|
@ -218,7 +236,7 @@ export default {
|
||||||
// }
|
// }
|
||||||
},
|
},
|
||||||
// 获取数据列表
|
// 获取数据列表
|
||||||
getDataList(prop='',sort='') {
|
getDataList(prop='', sort='', arr='') {
|
||||||
this.dataListLoading = true
|
this.dataListLoading = true
|
||||||
this.$http({
|
this.$http({
|
||||||
url: this.$http.adornUrl('/teach/list'),
|
url: this.$http.adornUrl('/teach/list'),
|
||||||
|
@ -228,7 +246,8 @@ export default {
|
||||||
'limit': this.pageSize,
|
'limit': this.pageSize,
|
||||||
'userName': this.dataForm.userName,
|
'userName': this.dataForm.userName,
|
||||||
'prop': prop,
|
'prop': prop,
|
||||||
'sort': sort
|
'sort': sort,
|
||||||
|
'arr': arr
|
||||||
})
|
})
|
||||||
}).then(({data}) => {
|
}).then(({data}) => {
|
||||||
if (data && data.code === 200) {
|
if (data && data.code === 200) {
|
||||||
|
@ -290,6 +309,19 @@ export default {
|
||||||
})
|
})
|
||||||
}).catch(() => {
|
}).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>-->
|
<!-- </template>-->
|
||||||
<!-- </el-table-column>-->
|
<!-- </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
|
<el-table-column
|
||||||
header-align="center"
|
header-align="center"
|
||||||
align="center"
|
align="center"
|
||||||
|
@ -206,7 +225,7 @@ export default {
|
||||||
// }
|
// }
|
||||||
},
|
},
|
||||||
// 获取数据列表
|
// 获取数据列表
|
||||||
getDataList(prop='',sort='') {
|
getDataList(prop='', sort='', arr='') {
|
||||||
this.dataListLoading = true
|
this.dataListLoading = true
|
||||||
this.$http({
|
this.$http({
|
||||||
url: this.$http.adornUrl('/stu/list'),
|
url: this.$http.adornUrl('/stu/list'),
|
||||||
|
@ -216,7 +235,8 @@ export default {
|
||||||
'limit': this.pageSize,
|
'limit': this.pageSize,
|
||||||
'userName': this.dataForm.userName,
|
'userName': this.dataForm.userName,
|
||||||
'prop': prop,
|
'prop': prop,
|
||||||
'sort': sort
|
'sort': sort,
|
||||||
|
'arr': arr // 新增筛选参数
|
||||||
})
|
})
|
||||||
}).then(({data}) => {
|
}).then(({data}) => {
|
||||||
if (data && data.code === 200) {
|
if (data && data.code === 200) {
|
||||||
|
@ -278,6 +298,17 @@ export default {
|
||||||
})
|
})
|
||||||
}).catch(() => {
|
}).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 sortable="custom" prop="sex" header-align="center" align="center" label="性别">
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column
|
<el-table-column
|
||||||
v-if="isAuth('sys:user:list')"
|
column-key="majorId"
|
||||||
:show-overflow-tooltip="true"
|
|
||||||
min-width="120"
|
|
||||||
:filter-multiple="false"
|
:filter-multiple="false"
|
||||||
:filters="[{text: '语文', value: 1}, {text: '地理', value: 4}, {text: '历史', value: 7}, {text: '政治', value: 8}]"
|
:filters="[
|
||||||
filter-placement="bottom-end"
|
{text: '语文', value: 1},
|
||||||
prop="majorId" header-align="center" align="center" label="学科">
|
{text: '地理', value: 4},
|
||||||
|
{text: '历史', value: 7},
|
||||||
|
{text: '政治', value: 8}
|
||||||
|
]"
|
||||||
|
:filter-method="filterMajor"
|
||||||
|
prop="majorId"
|
||||||
|
header-align="center"
|
||||||
|
align="center"
|
||||||
|
label="学科">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
{{ isMajor(scope.row.majorId) }}
|
{{ isMajor(scope.row.majorId) }}
|
||||||
</template>
|
</template>
|
||||||
|
@ -327,25 +333,16 @@ export default {
|
||||||
// const property = column["property"];
|
// const property = column["property"];
|
||||||
// return row[property] === value;
|
// return row[property] === value;
|
||||||
// },
|
// },
|
||||||
filterChange(value){
|
filterChange(value) {
|
||||||
console.log(value)
|
const majorFilter = value.majorId || []
|
||||||
let arr=''
|
const majorIds = majorFilter.join(',')
|
||||||
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]
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
// value.forEach((item) => {
|
// 重置页码到第一页
|
||||||
// console.log(item)
|
this.pageIndex = 1
|
||||||
// })
|
// 恢复默认分页选项
|
||||||
|
this.myPageSize = [5, 10, 20, 50, 100, 500]
|
||||||
|
|
||||||
|
this.getDataList('', '', majorIds)
|
||||||
},
|
},
|
||||||
|
|
||||||
isMajor(majorId) {
|
isMajor(majorId) {
|
||||||
|
@ -511,7 +508,7 @@ export default {
|
||||||
// }
|
// }
|
||||||
},
|
},
|
||||||
// 获取数据列表
|
// 获取数据列表
|
||||||
async getDataList(prop='',sort='',arr='') {
|
async getDataList(prop = '', sort = '', arr = '') {
|
||||||
this.dataListLoading = true
|
this.dataListLoading = true
|
||||||
await this.$http({
|
await this.$http({
|
||||||
url: this.$http.adornUrl('/wai/list'),
|
url: this.$http.adornUrl('/wai/list'),
|
||||||
|
@ -522,7 +519,7 @@ export default {
|
||||||
'userName': this.dataForm.userName,
|
'userName': this.dataForm.userName,
|
||||||
'prop': prop,
|
'prop': prop,
|
||||||
'sort': sort,
|
'sort': sort,
|
||||||
'arr':arr
|
'arr': arr
|
||||||
})
|
})
|
||||||
}).then(({data}) => {
|
}).then(({data}) => {
|
||||||
if (data && data.code === 200) {
|
if (data && data.code === 200) {
|
||||||
|
@ -539,7 +536,7 @@ export default {
|
||||||
// 每页数
|
// 每页数
|
||||||
sizeChangeHandle(val) {
|
sizeChangeHandle(val) {
|
||||||
this.pageSize = val
|
this.pageSize = val
|
||||||
this.pageIndex = 1
|
this.pageIndex = 1 // 切换分页大小时重置到第一页
|
||||||
this.getDataList()
|
this.getDataList()
|
||||||
},
|
},
|
||||||
// 当前页
|
// 当前页
|
||||||
|
@ -646,6 +643,10 @@ export default {
|
||||||
this.waiCount = {...data.data}
|
this.waiCount = {...data.data}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
// 新增学科过滤方法
|
||||||
|
filterMajor(value, row) {
|
||||||
|
return row.majorId == value;
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue