TableSelectDialog增加查询插槽

pull/1/head
liutao 4 weeks ago
parent bae356efe8
commit f9575447af

@ -1,6 +1,11 @@
<template>
<Dialog :title="title" v-model="dialogVisible" :appendToBody="true" width="1080">
<ContentWrap>
<!-- 新增查询表单区域 -->
<div v-if="$slots.header" class="search-container">
<slot name="header"></slot>
</div>
<el-table
ref="tableRef"
v-loading="loading"
@ -58,12 +63,14 @@ const props = withDefaults(
rowKey?: string
pageSize?: number
initialRows?: any[]
queryParams?: Record<string, any> //
}>(),
{
selectionType: 'multiple',
rowKey: 'id',
pageSize: 10,
initialRows: () => []
initialRows: () => [],
queryParams: () => ({}) //
}
)
@ -108,7 +115,8 @@ const refreshSelectionOnTable = async () => {
const getList = async () => {
loading.value = true
try {
const data = await props.fetchApi(queryParams)
const params = getQueryParams()
const data = await props.fetchApi(params)
list.value = data.list || []
total.value = data.total || 0
await refreshSelectionOnTable()
@ -172,5 +180,31 @@ const submitSelection = () => {
dialogVisible.value = false
}
defineExpose({ open })
//
const reload =async () => {
loading.value = true
//
await getList()
}
// 3. queryParams
const getQueryParams = () => {
return {
pageNum: queryParams.pageNo || 1,
pageSize: queryParams.pageSize || 10,
...props.queryParams //
}
}
// 4.
watch(() => props.queryParams, async () => {
await getList()
}, { deep: true })
defineExpose({ open, reload })
</script>
<style scoped>
.search-container {
margin-bottom: 10px;
padding: 0 0px;
}
</style>

Loading…
Cancel
Save