优化选中

This commit is contained in:
leave 2020-10-29 10:02:57 +08:00
parent 77670ad094
commit f889b51fef

View File

@ -24,11 +24,13 @@
ref="refChooseTable" ref="refChooseTable"
max-height="394" max-height="394"
@selection-change="handleSelectionChange" @selection-change="handleSelectionChange"
:row-key="handleGetRowKeys"
v-if="tableList.length" v-if="tableList.length"
> >
<el-table-column <el-table-column
type="selection" type="selection"
width="40" width="40"
:reserve-selection="true"
></el-table-column> ></el-table-column>
<el-table-column <el-table-column
prop="name" prop="name"
@ -66,13 +68,11 @@
:data="seleactedList" :data="seleactedList"
:show-header="false" :show-header="false"
max-height="394" max-height="394"
:row-key="handleGetRowKeys"
v-if="seleactedList.length>0" v-if="seleactedList.length>0"
> >
<el-table-column <el-table-column
type="selection" type="selection"
width="40" width="40"
:reserve-selection="true"
> >
<template slot-scope="scope"> <template slot-scope="scope">
<i <i
@ -141,7 +141,7 @@ export default {
seleactedList: [], seleactedList: [],
pageInfo: { pageInfo: {
currPage: 1, currPage: 1,
pageSize: 20, pageSize: 1,
totalCount: 1, totalCount: 1,
totalPage: 1 totalPage: 1
} }
@ -153,29 +153,20 @@ export default {
}, },
watch: { watch: {
dialogVisible (newVal, oldVal) { dialogVisible (newVal, oldVal) {
if (newVal) { if (newVal !== oldVal && newVal) {
if (this.filtersDic.currPage === undefined || !this.filtersDic.currPage) {
this.filtersDic['currPage'] = this.pageInfo.currPage
}
if (this.filtersDic.pageSize === undefined || !this.filtersDic.pageSize) {
this.filtersDic['pageSize'] = this.pageInfo.pageSize
}
this.handleDataList() this.handleDataList()
} }
} }
}, },
methods: { methods: {
handleDataList () { handleDataList () {
apiGetEvaluationTeamList(this.filtersDic).then(res => { let paraDic = Object.assign(this.pageInfo, this.filtersDic)
apiGetEvaluationTeamList(paraDic).then(res => {
this.pageInfo.currPage = res.data.currPage this.pageInfo.currPage = res.data.currPage
this.pageInfo.totalCount = res.data.totalCount this.pageInfo.totalCount = res.data.totalCount
this.pageInfo.totalPage = res.data.totalPage this.pageInfo.totalPage = res.data.totalPage
this.tableList = res.data.list this.tableList = res.data.list
}) })
// for (let index = 0; index < 100; index++) {
// let dic = { id: index.toString(), name: '12' + index.toString(), count: '12' }
// this.tableList.push(dic)
// }
}, },
// handleGetRowStyle () { // handleGetRowStyle () {
// return { 'height': '44px' } // return { 'height': '44px' }
@ -190,22 +181,32 @@ export default {
}, },
handleCancel () { handleCancel () {
this.handleClear() this.handleClear()
this.tableList = []
this.seleactedList = []
this.pageInfo = {
currPage: 1,
pageSize: 1,
totalCount: 1,
totalPage: 1
}
this.$emit('close') this.$emit('close')
}, },
handleSubmit () { handleSubmit () {
this.$emit('submitClick', this.seleactedList) this.$emit('submitClick', this.seleactedList)
this.handleCancel()
}, },
handleSelectionChange (val) { handleSelectionChange (val) {
this.seleactedList = val this.seleactedList = val
}, },
handleCurrentChange (val) { handleCurrentChange (val) {
this.pageInfo.currPage = val this.pageInfo.currPage = val
this.filtersDic['currPage'] = this.pageInfo.currPage
this.handleDataList() this.handleDataList()
}, },
handleClear () { handleClear () {
this.seleactedList = [] if (this.seleactedList.length) {
this.$refs.refChooseTable.clearSelection() this.$refs.refChooseTable.clearSelection()
this.seleactedList = []
}
}, },
handleDelete (item, index) { handleDelete (item, index) {
this.seleactedList.splice(index, 1) this.seleactedList.splice(index, 1)