refactor(dialog): 优化对话框组件的配置和交互

- 修改了多个组件的关闭对话框逻辑,设置 wrapperClosable 为 false
- 更新了多个组件的确认对话框逻辑,使用 $messageBox 替代 $confirm
- 调整了部分对话框的样式和布局
This commit is contained in:
陈昱达
2025-05-08 14:36:34 +08:00
parent fb5bcc16b9
commit 013bdb74b7
18 changed files with 182 additions and 123 deletions

View File

@@ -49,7 +49,7 @@ export default {
}, },
closeOnClickModal: { closeOnClickModal: {
type: Boolean, type: Boolean,
default: true default: false
}, },
beforeClose: { beforeClose: {
type: Function, type: Function,

View File

@@ -53,15 +53,24 @@ export default {
this.$store.dispatch('app/toggleSideBar') this.$store.dispatch('app/toggleSideBar')
}, },
async logout() { async logout() {
this.$confirm('确定要退出吗?', '提示', { this.$messageBox(
confirmButtonText: '确定', async () => {
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
await this.$store.dispatch('user/logout') await this.$store.dispatch('user/logout')
await this.$store.dispatch('user/removeRoles') await this.$store.dispatch('user/removeRoles')
this.$router.push(`/login?redirect=${this.$route.fullPath}`) this.$router.push(`/login?redirect=${this.$route.fullPath}`)
}) },
'确定要退出吗?',
'warning',
'提示'
)
// this.$confirm({
// confirmButtonText: '确定',
// cancelButtonText: '取消',
// type: 'warning'
// }).then(async () => {
//
// })
}, },
resetPassword() { resetPassword() {
this.resetPasswordVisible = true this.resetPasswordVisible = true

View File

@@ -494,6 +494,7 @@ export default {
<el-drawer <el-drawer
append-to-body append-to-body
:modal="false" :modal="false"
:wrapperClosable="false"
:visible.sync="dialogConfig.visible" :visible.sync="dialogConfig.visible"
:title="dialogConfig.title" :title="dialogConfig.title"
:width="dialogConfig.width" :width="dialogConfig.width"

View File

@@ -5,6 +5,7 @@
:visible.sync="visible" :visible.sync="visible"
size="40%" size="40%"
@close="handleClose" @close="handleClose"
:wrapperClosable="false"
> >
<el-form ref="form" :model="form" label-width="80%" label-position="top"> <el-form ref="form" :model="form" label-width="80%" label-position="top">
<el-row> <el-row>

View File

@@ -3,6 +3,7 @@
<el-drawer <el-drawer
:visible.sync="visible" :visible.sync="visible"
size="80%" size="80%"
:wrapperClosable="false"
@close="$emit('update:visible', false)" @close="$emit('update:visible', false)"
> >
<!-- drawer title --> <!-- drawer title -->
@@ -31,6 +32,7 @@
></knowledgeInfo> ></knowledgeInfo>
<!-- 将metadata-operator改为弹窗形式 --> <!-- 将metadata-operator改为弹窗形式 -->
<el-drawer <el-drawer
:wrapperClosable="false"
title="元数据操作" title="元数据操作"
:visible.sync="metadataDialogVisible" :visible.sync="metadataDialogVisible"
width="600px" width="600px"

View File

@@ -28,6 +28,7 @@
<!-- 弹窗 --> <!-- 弹窗 -->
<el-drawer <el-drawer
:wrapperClosable="false"
title="问答详情" title="问答详情"
:visible.sync="dialogVisible" :visible.sync="dialogVisible"
width="50%" width="50%"

View File

@@ -41,6 +41,7 @@
<!-- 弹窗 --> <!-- 弹窗 -->
<el-drawer <el-drawer
title="分段详情" title="分段详情"
:wrapperClosable="false"
:visible.sync="dialogVisible" :visible.sync="dialogVisible"
:modal="false" :modal="false"
append-to-body append-to-body

View File

@@ -231,13 +231,15 @@ export default {
this.currentEditIndex = index this.currentEditIndex = index
}, },
deleteMeta(item) { deleteMeta(item) {
this.$confirm(`确认删除该元数据吗?`, '提示', { this.$messageBox(()=>{ this.handleDelete(item)},`确认删除该元数据吗?`, 'warning','提示')
confirmButtonText: '确定',
cancelButtonText: '取消', // this.$confirm(, {
type: 'warning' // confirmButtonText: '确定',
}).then(() => { // cancelButtonText: '取消',
this.handleDelete(item) // type: 'warning'
}) // }).then(() => {
//
// })
}, },
handleDelete(item) { handleDelete(item) {
deleteMetadata([item.id]).then(res => { deleteMetadata([item.id]).then(res => {

View File

@@ -9,6 +9,7 @@
" "
:visible.sync="dialogVisible" :visible.sync="dialogVisible"
size="30%" size="30%"
:wrapperClosable="false"
:before-close="handleClose" :before-close="handleClose"
> >
<div class="content"> <div class="content">

View File

@@ -8,6 +8,7 @@
: '新增知识题词规则' : '新增知识题词规则'
" "
:visible.sync="dialogVisible" :visible.sync="dialogVisible"
:wrapperClosable="false"
size="30%" size="30%"
:before-close="handleClose" :before-close="handleClose"
> >

View File

@@ -211,6 +211,7 @@
<el-drawer <el-drawer
:title="metaDataDrawer.title" :title="metaDataDrawer.title"
:visible.sync="metaDataDrawer.visible" :visible.sync="metaDataDrawer.visible"
:wrapperClosable="false"
size="30%" size="30%"
> >
<meta-data ref="metaData" :datasetId="$route.query.datasetId"></meta-data> <meta-data ref="metaData" :datasetId="$route.query.datasetId"></meta-data>
@@ -221,6 +222,7 @@
:title="metadataOperatorDrawer.title" :title="metadataOperatorDrawer.title"
:visible.sync="metadataOperatorDrawer.visible" :visible.sync="metadataOperatorDrawer.visible"
size="30%" size="30%"
:wrapperClosable="false"
> >
<metadata-operator <metadata-operator
ref="metadataOperator" ref="metadataOperator"

View File

@@ -178,11 +178,8 @@ export default {
}) })
}, },
deleteKnowLedge(item) { deleteKnowLedge(item) {
this.$confirm('此操作将永久删除该知识库, 是否继续?', '提示', { this.$messageBox(
confirmButtonText: '确定', () => {
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
datasetDelete({ id: item.id }).then(res => { datasetDelete({ id: item.id }).then(res => {
if (res.content.result === '0') { if (res.content.result === '0') {
this.$message({ this.$message({
@@ -192,7 +189,19 @@ export default {
this.getList() this.getList()
} }
}) })
}) },
'此操作将永久删除该知识库, 是否继续?',
'warning',
'提示'
)
// this.$confirm(, {
// confirmButtonText: '确定',
// cancelButtonText: '取消',
// type: 'warning'
// }).then(() => {
//
// })
}, },
getKnowledgeImage(index) { getKnowledgeImage(index) {
const images = [ const images = [

View File

@@ -193,11 +193,8 @@ export default {
}, },
// 处理删除规则` // 处理删除规则`
handleDelete(row, index) { handleDelete(row, index) {
this.$confirm('此操作将永久删除该规则, 是否继续?', '提示', { this.$messageBox(
confirmButtonText: '确定', () => {
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
deleteRule([row.id]) deleteRule([row.id])
.then(() => { .then(() => {
// 删除当前行 // 删除当前行
@@ -219,7 +216,19 @@ export default {
) )
}) })
}) })
}) },
'此操作将永久删除该规则, 是否继续?',
'warning',
'提示'
)
// this.$confirm(, {
// confirmButtonText: '确定',
// cancelButtonText: '取消',
// type: 'warning'
// }).then(() => {
//
// })
}, },
// 处理查询 // 处理查询
handleQuery() { handleQuery() {

View File

@@ -226,12 +226,8 @@ export default {
this.handleQuery() this.handleQuery()
}, },
handleDelete(row) { handleDelete(row) {
this.$confirm('确认删除该菜单吗?', '警告', { this.$messageBox(
confirmButtonText: '确定', () => {
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
this.loading = true this.loading = true
// 将id放入数组中传递 // 将id放入数组中传递
deleteMenu([row.id]) deleteMenu([row.id])
@@ -245,10 +241,23 @@ export default {
.finally(() => { .finally(() => {
this.loading = false this.loading = false
}) })
}) },
.catch(() => { '确认删除该菜单吗?',
this.$message.info('已取消删除') 'warning',
}) '警告'
)
// this.$confirm(, {
// confirmButtonText: '确定',
// cancelButtonText: '取消',
// type: 'warning'
// })
// .then(() => {
//
// })
// .catch(() => {
// this.$message.info('已取消删除')
// })
} }
} }
} }

View File

@@ -67,6 +67,7 @@
<el-drawer <el-drawer
:visible.sync="permissionDrawer.visible" :visible.sync="permissionDrawer.visible"
:title="permissionDrawer.title" :title="permissionDrawer.title"
:wrapperClosable="false"
size="60%" size="60%"
> >
<el-tree <el-tree
@@ -329,12 +330,8 @@ export default {
this.handleQuery() this.handleQuery()
}, },
handleDelete(row) { handleDelete(row) {
this.$confirm('确认删除该角色吗?', '警告', { this.$messageBox(
confirmButtonText: '确定', () => {
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
this.loading = true this.loading = true
// 将id放入数组中传递 // 将id放入数组中传递
deleteRole([row.id]) deleteRole([row.id])
@@ -348,10 +345,23 @@ export default {
.finally(() => { .finally(() => {
this.loading = false this.loading = false
}) })
}) },
.catch(() => { '确认删除该角色吗?',
this.$message.info('已取消删除') 'warning',
}) '警告'
)
// this.$confirm('确认删除该角色吗?', '警告', {
// confirmButtonText: '确定',
// cancelButtonText: '取消',
// type: 'warning'
// })
// .then(() => {
//
// })
// .catch(() => {
// this.$message.info('已取消删除')
// })
}, },
// 关闭权限抽屉 // 关闭权限抽屉
handleOnClose() { handleOnClose() {

View File

@@ -1,5 +1,5 @@
<template> <template>
<el-dialog <r-dialog
:title="title" :title="title"
:visible.sync="visible" :visible.sync="visible"
width="800px" width="800px"
@@ -94,17 +94,17 @@
<div slot="footer" class="dialog-footer" v-if="!isView"> <div slot="footer" class="dialog-footer" v-if="!isView">
<el-button <el-button
type="primary" type="primary"
size="small" size="medium"
:loading="loading" :loading="loading"
@click="submitForm" @click="submitForm"
> </el-button > </el-button
> >
<el-button size="small" @click="handleClose"> </el-button> <el-button size="medium" @click="handleClose"> </el-button>
</div> </div>
<div slot="footer" class="dialog-footer" v-else> <div slot="footer" class="dialog-footer" v-else>
<el-button size="small" @click="handleClose"> </el-button> <el-button size="medium" @click="handleClose"> </el-button>
</div> </div>
</el-dialog> </r-dialog>
</template> </template>
<script> <script>

View File

@@ -316,12 +316,8 @@ export default {
this.getUserList() this.getUserList()
}, },
handleDelete(row) { handleDelete(row) {
this.$confirm('确认删除该用户吗?', '警告', { this.$messageBox(
confirmButtonText: '确定', () => {
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
this.loading = true this.loading = true
// 将id放入数组中传递 // 将id放入数组中传递
deleteUser([row.id]) deleteUser([row.id])
@@ -335,18 +331,17 @@ export default {
.finally(() => { .finally(() => {
this.loading = false this.loading = false
}) })
}) },
.catch(() => { '确认删除该用户吗?',
this.$message.info('已取消删除') 'warning',
}) '警告'
)
}, },
handleToggleStatus(row) { handleToggleStatus(row) {
const statusText = row.status === 0 ? '停用' : '启用' const statusText = row.status === 0 ? '停用' : '启用'
this.$confirm(`确认${statusText}该用户吗?`, '提示', {
confirmButtonText: '确定', this.$messageBox(
cancelButtonText: '取消', () => {
type: 'warning'
}).then(() => {
// 调用changeUserStatus接口 // 调用changeUserStatus接口
const newStatus = row.status === 0 ? 1 : 0 // 切换状态 const newStatus = row.status === 0 ? 1 : 0 // 切换状态
changeUserStatus({ changeUserStatus({
@@ -360,15 +355,16 @@ export default {
.catch(() => { .catch(() => {
this.$message.error(`${statusText}用户出错`) this.$message.error(`${statusText}用户出错`)
}) })
}) },
`确认${statusText}该用户吗?`,
'warning',
'提示'
)
}, },
handleResetPassword(row) { handleResetPassword(row) {
this.currentUserId = row.id this.currentUserId = row.id
this.$confirm('确认重置该用户的密码吗?', '提示', { this.$messageBox(
confirmButtonText: '确定', () => {
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
// 调用resetPassword接口 // 调用resetPassword接口
resetPassword({ resetPassword({
userId: row.id userId: row.id
@@ -376,7 +372,11 @@ export default {
this.$message.success('重置密码成功') this.$message.success('重置密码成功')
this.handleQuery() // 刷新列表 this.handleQuery() // 刷新列表
}) })
}) },
'确认重置该用户的密码吗?',
'warning',
'提示'
)
} }
} }
} }

View File

@@ -316,6 +316,7 @@ export default {
<el-drawer <el-drawer
:title="activeForm.datasetName" :title="activeForm.datasetName"
:visible.sync="infoDialogVisible" :visible.sync="infoDialogVisible"
:wrapperClosable="false"
size="80%" size="80%"
:before-close="() => (infoDialogVisible = false)" :before-close="() => (infoDialogVisible = false)"
> >