通用组件 复选框点击列表行自动勾选

pull/4/head
qiuhongwu 8 months ago
parent 88dfe85d6a
commit 6190801297

@ -25,7 +25,8 @@
<el-card class="hl-card"> <el-card class="hl-card">
<!-- 列表 --> <!-- 列表 -->
<ContentWrap> <ContentWrap>
<el-table v-loading="loading" :data="tablelist" :stripe="true" class="hl-table" @selection-change="handleSelectionChange" selection> <el-table v-loading="loading" :data="tablelist" :stripe="true" class="hl-table" @selection-change="handleSelectionChange"
@row-click="clickRow" ref="multipleTable" selection>
<el-table-column fixed type="selection" width="40" /> <el-table-column fixed type="selection" width="40" />
<el-table-column fixed label="序号" type="index" width="60" /> <el-table-column fixed label="序号" type="index" width="60" />
<el-table-column fixed label="名称" align="center" prop="name" min-width="220" /> <el-table-column fixed label="名称" align="center" prop="name" min-width="220" />
@ -53,6 +54,7 @@
import { getIntDictOptions, getStrDictOptions, DICT_TYPE } from '@/utils/dict' import { getIntDictOptions, getStrDictOptions, DICT_TYPE } from '@/utils/dict'
import { dateFormatter, dateFormatter2, formatDate } from '@/utils/formatTime' import { dateFormatter, dateFormatter2, formatDate } from '@/utils/formatTime'
import { ref } from 'vue' import { ref } from 'vue'
import { ElTable } from 'element-plus'
const message = useMessage() // const message = useMessage() //
const { t } = useI18n() // const { t } = useI18n() //
@ -107,10 +109,20 @@ const tablelist = ref([
} }
]) ])
const multipleTable = ref<InstanceType<typeof ElTable>>()
const multipleSelection = ref([]) const multipleSelection = ref([])
const handleSelectionChange = (val: []) => { const handleSelectionChange = (val: []) => {
multipleSelection.value = val multipleSelection.value = val
} }
const clickRow = (row: any) => {
if(row){
multipleTable.value!.toggleRowSelection(row, undefined)
}else{
multipleTable.value!.clearSelection()
}
}
/** 提交表单 */ /** 提交表单 */
const emit = defineEmits(['success']) // success const emit = defineEmits(['success']) // success
const submitForm = () => { const submitForm = () => {

Loading…
Cancel
Save