feat: 修改多次绑定on事件

This commit is contained in:
duan
2025-02-28 18:14:29 +08:00
parent 03062abfe7
commit ad52c6bbf9
4 changed files with 19 additions and 7 deletions

View File

@@ -38,10 +38,14 @@ const myDialogRef = ref(null)
const ruleFormRef = ref(null)
onMounted(() => {
getList()
eventBus.on('search', (res) => {
getList(res)
})
})
eventBus.on('search', (res) => {
getList(res)
onBeforeUnmount(() => {
eventBus.off('search')
})
async function getList(data = {}) {
const res = await API.getPage({ page: datas.pagingConfig.pageNumber, size: datas.pagingConfig.pageSize, ...data })
datas.tableData = res.records

View File

@@ -98,9 +98,8 @@ const ruleFormRef = ref(null)
onMounted(() => {
getList()
})
eventBus.on('search', (res) => {
getList(res)
})
async function getList(data = {}) {
const res = await API.getPage({ page: datas.pagingConfig.pageNumber, size: datas.pagingConfig.pageSize, ...data })
datas.tableData = res.records

View File

@@ -56,9 +56,12 @@ const myDialogRef = ref(null)
const ruleFormRef = ref(null)
onMounted(() => {
getList()
eventBus.on('search', (res) => {
getList(res)
})
})
eventBus.on('search', (res) => {
getList(res)
onBeforeUnmount(() => {
eventBus.off('search')
})
async function getList(data = {}) {
const res = await API.getPage({ page: datas.pagingConfig.pageNumber, size: datas.pagingConfig.pageSize, ...data })

View File

@@ -84,6 +84,12 @@ const myDialogRef = ref(null)
const ruleFormRef = ref(null)
onMounted(() => {
getList()
eventBus.on('search', (res) => {
getList(res)
})
})
onBeforeUnmount(() => {
eventBus.off('search')
})
eventBus.on('search', (res) => {
getList(res)