style: 修改系统管理中菜单管理的新增/编辑弹框样式

main
zhongwenkai 2 months ago
parent 951a851d1a
commit 19ff5a4775

@ -1,13 +1,19 @@
<template> <template>
<Dialog v-model="dialogVisible" :title="dialogTitle"> <div class="system-menu-panel">
<el-form <div class="system-menu-panel__header">
ref="formRef" <div class="system-menu-panel__title">{{ dialogTitle }}</div>
v-loading="formLoading" <el-button text @click="closeForm">
:model="formData" <Icon icon="ep:close" />
:rules="formRules" </el-button>
label-width="auto" </div>
class="system-menu-form" <div class="system-menu-dialog" v-loading="formLoading">
> <el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="auto"
class="system-menu-form"
>
<el-form-item :label="t('SystemManagement.Menu.parent')"> <el-form-item :label="t('SystemManagement.Menu.parent')">
<el-tree-select <el-tree-select
v-model="formData.parentId" v-model="formData.parentId"
@ -111,11 +117,12 @@
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-form> </el-form>
<template #footer> </div>
<div class="system-menu-footer">
<el-button @click="closeForm">{{ t('common.cancel') }}</el-button>
<el-button :disabled="formLoading" type="primary" @click="submitForm">{{ t('common.ok') }}</el-button> <el-button :disabled="formLoading" type="primary" @click="submitForm">{{ t('common.ok') }}</el-button>
<el-button @click="dialogVisible = false">{{ t('common.cancel') }}</el-button> </div>
</template> </div>
</Dialog>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
@ -131,7 +138,6 @@ const { wsCache } = useCache()
const { t } = useI18n() // const { t } = useI18n() //
const message = useMessage() // const message = useMessage() //
const dialogVisible = ref(false) //
const dialogTitle = ref('') // const dialogTitle = ref('') //
const formLoading = ref(false) // 12 const formLoading = ref(false) // 12
const formType = ref('') // create - update - const formType = ref('') // create - update -
@ -164,7 +170,6 @@ const formRef = ref() // 表单 Ref
/** 打开弹窗 */ /** 打开弹窗 */
const open = async (type: string, id?: number, parentId?: number, currentClientType?: number) => { const open = async (type: string, id?: number, parentId?: number, currentClientType?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type) dialogTitle.value = t('action.' + type)
formType.value = type formType.value = type
clientType.value = currentClientType ?? 1 clientType.value = currentClientType ?? 1
@ -187,7 +192,7 @@ const open = async (type: string, id?: number, parentId?: number, currentClientT
defineExpose({ open }) // open defineExpose({ open }) // open
/** 提交表单 */ /** 提交表单 */
const emit = defineEmits(['success']) // success const emit = defineEmits(['success', 'closed']) // success closed
const submitForm = async () => { const submitForm = async () => {
// //
if (!formRef) return if (!formRef) return
@ -219,7 +224,7 @@ const submitForm = async () => {
await MenuApi.updateMenu(data as unknown as MenuApi.MenuVO) await MenuApi.updateMenu(data as unknown as MenuApi.MenuVO)
message.success(t('common.updateSuccess')) message.success(t('common.updateSuccess'))
} }
dialogVisible.value = false closeForm()
// //
emit('success') emit('success')
} finally { } finally {
@ -239,6 +244,10 @@ const getTree = async () => {
menuTree.value.push(menu) menuTree.value.push(menu)
} }
const closeForm = () => {
emit('closed')
}
/** 重置表单 */ /** 重置表单 */
const resetForm = () => { const resetForm = () => {
formData.value = { formData.value = {
@ -267,3 +276,57 @@ const isExternal = (path: string) => {
return /^(https?:|mailto:|tel:)/.test(path) return /^(https?:|mailto:|tel:)/.test(path)
} }
</script> </script>
<style lang="scss" scoped>
.system-menu-panel {
background: #fff;
border-radius: 12px;
box-shadow: var(--el-box-shadow-light);
}
.system-menu-panel__header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 16px 20px;
border-bottom: 1px solid #ebeef5;
}
.system-menu-panel__title {
color: #1f2937;
font-size: 18px;
font-weight: 600;
}
.system-menu-dialog {
max-height: calc(100vh - 220px);
padding: 20px 20px 0;
padding-right: 16px;
overflow-y: auto;
}
.system-menu-footer {
display: flex;
justify-content: flex-end;
gap: 12px;
width: 100%;
padding: 16px 20px 20px;
border-top: 1px solid #ebeef5;
}
@media (max-width: 768px) {
.system-menu-panel__header {
padding: 14px 16px;
}
.system-menu-dialog {
max-height: none;
padding: 16px 16px 0;
overflow-y: visible;
}
.system-menu-footer {
padding: 16px;
}
}
</style>

@ -1,4 +1,6 @@
<template> <template>
<div class="system-menu-page">
<div v-show="!formVisible">
<!-- Tabs 切换 Web/APP --> <!-- Tabs 切换 Web/APP -->
<ContentWrap> <ContentWrap>
<el-tabs v-model="activeClientType" @tab-change="handleClientTypeChange"> <el-tabs v-model="activeClientType" @tab-change="handleClientTypeChange">
@ -134,9 +136,11 @@
</el-table-column> </el-table-column>
</el-table> </el-table>
</ContentWrap> </ContentWrap>
</div>
<!-- 表单弹窗添加/修改 --> <!-- 表单添加/修改 -->
<MenuForm ref="formRef" @success="getList" /> <MenuForm v-show="formVisible" ref="formRef" @success="getList" @closed="formVisible = false" />
</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
@ -195,7 +199,10 @@ const resetQuery = () => {
/** 添加/修改操作 */ /** 添加/修改操作 */
const formRef = ref() const formRef = ref()
const openForm = (type: string, id?: number, parentId?: number) => { const formVisible = ref(false)
const openForm = async (type: string, id?: number, parentId?: number) => {
formVisible.value = true
await nextTick()
formRef.value.open(type, id, parentId, activeClientType.value) formRef.value.open(type, id, parentId, activeClientType.value)
} }

Loading…
Cancel
Save