|
|
|
|
@ -1,13 +1,19 @@
|
|
|
|
|
<template>
|
|
|
|
|
<Dialog v-model="dialogVisible" :title="dialogTitle">
|
|
|
|
|
<el-form
|
|
|
|
|
ref="formRef"
|
|
|
|
|
v-loading="formLoading"
|
|
|
|
|
:model="formData"
|
|
|
|
|
:rules="formRules"
|
|
|
|
|
label-width="auto"
|
|
|
|
|
class="system-menu-form"
|
|
|
|
|
>
|
|
|
|
|
<div class="system-menu-panel">
|
|
|
|
|
<div class="system-menu-panel__header">
|
|
|
|
|
<div class="system-menu-panel__title">{{ dialogTitle }}</div>
|
|
|
|
|
<el-button text @click="closeForm">
|
|
|
|
|
<Icon icon="ep:close" />
|
|
|
|
|
</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
<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-tree-select
|
|
|
|
|
v-model="formData.parentId"
|
|
|
|
|
@ -111,11 +117,12 @@
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</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 @click="dialogVisible = false">{{ t('common.cancel') }}</el-button>
|
|
|
|
|
</template>
|
|
|
|
|
</Dialog>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
<script lang="ts" setup>
|
|
|
|
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
|
|
|
|
@ -131,7 +138,6 @@ const { wsCache } = useCache()
|
|
|
|
|
const { t } = useI18n() // 国际化
|
|
|
|
|
const message = useMessage() // 消息弹窗
|
|
|
|
|
|
|
|
|
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
|
|
|
|
const dialogTitle = ref('') // 弹窗的标题
|
|
|
|
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
|
|
|
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
|
|
|
|
@ -164,7 +170,6 @@ const formRef = ref() // 表单 Ref
|
|
|
|
|
|
|
|
|
|
/** 打开弹窗 */
|
|
|
|
|
const open = async (type: string, id?: number, parentId?: number, currentClientType?: number) => {
|
|
|
|
|
dialogVisible.value = true
|
|
|
|
|
dialogTitle.value = t('action.' + type)
|
|
|
|
|
formType.value = type
|
|
|
|
|
clientType.value = currentClientType ?? 1
|
|
|
|
|
@ -187,7 +192,7 @@ const open = async (type: string, id?: number, parentId?: number, currentClientT
|
|
|
|
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
|
|
|
|
|
|
|
|
|
/** 提交表单 */
|
|
|
|
|
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
|
|
|
|
const emit = defineEmits(['success', 'closed']) // 定义 success 和 closed 事件
|
|
|
|
|
const submitForm = async () => {
|
|
|
|
|
// 校验表单
|
|
|
|
|
if (!formRef) return
|
|
|
|
|
@ -219,7 +224,7 @@ const submitForm = async () => {
|
|
|
|
|
await MenuApi.updateMenu(data as unknown as MenuApi.MenuVO)
|
|
|
|
|
message.success(t('common.updateSuccess'))
|
|
|
|
|
}
|
|
|
|
|
dialogVisible.value = false
|
|
|
|
|
closeForm()
|
|
|
|
|
// 发送操作成功的事件
|
|
|
|
|
emit('success')
|
|
|
|
|
} finally {
|
|
|
|
|
@ -239,6 +244,10 @@ const getTree = async () => {
|
|
|
|
|
menuTree.value.push(menu)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const closeForm = () => {
|
|
|
|
|
emit('closed')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/** 重置表单 */
|
|
|
|
|
const resetForm = () => {
|
|
|
|
|
formData.value = {
|
|
|
|
|
@ -267,3 +276,57 @@ const isExternal = (path: string) => {
|
|
|
|
|
return /^(https?:|mailto:|tel:)/.test(path)
|
|
|
|
|
}
|
|
|
|
|
</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>
|
|
|
|
|
|