|
|
@ -1,197 +1,199 @@ |
|
|
|
<template> |
|
|
|
<el-dialog |
|
|
|
title="配置菜单" |
|
|
|
model-value |
|
|
|
width="600px" |
|
|
|
:before-close="handleClose" |
|
|
|
> |
|
|
|
<el-form ref="form" :model="formData" :rules="rules" label-width="80px"> |
|
|
|
<el-row> |
|
|
|
<el-col :span="24"> |
|
|
|
<el-form-item label="上级菜单"> |
|
|
|
<el-select |
|
|
|
v-model="formData.parent_name" |
|
|
|
placeholder="选择上级菜单" |
|
|
|
> |
|
|
|
<el-option value="" /> |
|
|
|
<el-tree |
|
|
|
:data="treeMenu" |
|
|
|
:props="defaultProps" |
|
|
|
:expand-on-click-node="false" |
|
|
|
@node-click="handleNodeClick" |
|
|
|
></el-tree> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="12"> |
|
|
|
<el-form-item label="菜单标题" prop="title"> |
|
|
|
<el-input v-model="formData.title" placeholder="请输入菜单标题" /> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="12"> |
|
|
|
<el-form-item label="显示排序"> |
|
|
|
<el-input-number |
|
|
|
v-model="formData.sort" |
|
|
|
controls-position="right" |
|
|
|
:min="0" |
|
|
|
/> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
|
|
|
|
<el-col :span="24"> |
|
|
|
<el-form-item label="菜单类型" prop="menu_type"> |
|
|
|
<el-radio-group v-model="formData.menu_type"> |
|
|
|
<el-radio label="M">目录</el-radio> |
|
|
|
<el-radio label="C">菜单</el-radio> |
|
|
|
<el-radio label="F">按钮</el-radio> |
|
|
|
<el-radio label="A">接口</el-radio> |
|
|
|
</el-radio-group> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="24" v-if="formData.menu_type == 'A'"> |
|
|
|
<el-form-item label="请求方式"> |
|
|
|
<el-radio-group v-model="formData.action"> |
|
|
|
<el-radio label="GET">GET</el-radio> |
|
|
|
<el-radio label="POST">POST</el-radio> |
|
|
|
<el-radio label="PUT">PUT</el-radio> |
|
|
|
<el-radio label="DELETE">DELETE</el-radio> |
|
|
|
</el-radio-group> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="24"> |
|
|
|
<el-form-item label="菜单图标"> |
|
|
|
<el-popover |
|
|
|
placement="bottom" |
|
|
|
width="440px" |
|
|
|
v-model:visible="visible" |
|
|
|
> |
|
|
|
<IconSelect ref="iconSelect" @selected="selected" /> |
|
|
|
<template #reference> |
|
|
|
<el-input v-model="formData.icon" placeholder="点击选择图标" readonly> |
|
|
|
<template #prefix> |
|
|
|
<svg-icon v-if="formData.icon" :icon-class="formData.icon" style="height: 30px;width: 16px;" /> |
|
|
|
<i v-else class="el-icon-search el-input__icon" /> |
|
|
|
</template> |
|
|
|
</el-input> |
|
|
|
</template> |
|
|
|
</el-popover> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col |
|
|
|
:span="12" |
|
|
|
v-if="formData.menu_type == 'M' || formData.menu_type == 'C'" |
|
|
|
> |
|
|
|
<el-form-item label="路由名称" prop="menu_name"> |
|
|
|
<el-input |
|
|
|
v-model="formData.menu_name" |
|
|
|
placeholder="请输入路由名称" |
|
|
|
/> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
|
|
|
|
<el-col |
|
|
|
v-if="formData.menu_type == 'M' || formData.menu_type == 'C'" |
|
|
|
:span="12" |
|
|
|
> |
|
|
|
<el-form-item label="组件路径" prop="component"> |
|
|
|
<el-input |
|
|
|
v-model="formData.component" |
|
|
|
placeholder="请输入组件路径" |
|
|
|
/> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
|
|
|
|
<el-col :span="12" v-if="formData.menu_type != 'F'"> |
|
|
|
<el-form-item label="路由地址" prop="path"> |
|
|
|
<el-input v-model="formData.path" placeholder="请输入路由地址" /> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
|
|
|
|
<el-col |
|
|
|
:span="12" |
|
|
|
v-if="formData.menu_type == 'F' || formData.menu_type == 'C'" |
|
|
|
> |
|
|
|
<el-form-item label="权限标识"> |
|
|
|
<el-input |
|
|
|
v-model="formData.permission" |
|
|
|
placeholder="请权限标识" |
|
|
|
maxlength="50" |
|
|
|
/> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
|
</el-form> |
|
|
|
<template #footer> |
|
|
|
<span class="dialog-footer"> |
|
|
|
<el-button |
|
|
|
type="primary" |
|
|
|
class="dialog-submit-button" |
|
|
|
@click="submitForm" |
|
|
|
>确 定</el-button |
|
|
|
> |
|
|
|
<el-button class="dialog-cancel-button" @click="handleClose" |
|
|
|
>取 消</el-button |
|
|
|
> |
|
|
|
</span> |
|
|
|
</template> |
|
|
|
</el-dialog> |
|
|
|
</template> |
|
|
|
<script> |
|
|
|
import { getTreeMenu } from "@/server/system/menu"; |
|
|
|
import IconSelect from '@/components/IconSelect' |
|
|
|
export default { |
|
|
|
components: { IconSelect }, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
formData: {}, |
|
|
|
// 菜单树选项 |
|
|
|
treeMenu: [], |
|
|
|
defaultProps: { |
|
|
|
children: 'children', |
|
|
|
label: 'title', |
|
|
|
disabled:'disabled' |
|
|
|
}, |
|
|
|
}; |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 确认 |
|
|
|
submitForm() { |
|
|
|
console.log(this.formData); |
|
|
|
}, |
|
|
|
// 取消/关闭 |
|
|
|
handleClose() { |
|
|
|
this.$emit('setIsAddOrEdit') |
|
|
|
}, |
|
|
|
// 查询菜单下拉树结构 |
|
|
|
getTreeMenu() { |
|
|
|
getTreeMenu().then(({code, data}) => { |
|
|
|
if(code ==200 && data){ |
|
|
|
let treeMenu = [{ menu_id: 0, disabled:true, title: '主类目', children: [] }] |
|
|
|
treeMenu[0].children = data; |
|
|
|
this.treeMenu=treeMenu; |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 选择上级菜单后的回调 |
|
|
|
handleNodeClick({parent_id, title}) { |
|
|
|
this.formData.parent_id=parent_id; |
|
|
|
this.formData.parent_name=title; |
|
|
|
}, |
|
|
|
// 选择图标后的操作 |
|
|
|
selected(name){ |
|
|
|
console.log(name); |
|
|
|
this.formData.icon=name; |
|
|
|
} |
|
|
|
}, |
|
|
|
created(){ |
|
|
|
this.getTreeMenu(); |
|
|
|
} |
|
|
|
}; |
|
|
|
</script> |
|
|
|
<style lang="less" scoped> |
|
|
|
/* 去除tree上面的一行高度 */ |
|
|
|
.el-scrollbar .el-scrollbar__view .el-select-dropdown__item { |
|
|
|
height: auto; |
|
|
|
padding: 0; |
|
|
|
} |
|
|
|
<template> |
|
|
|
<el-dialog |
|
|
|
title="配置菜单" |
|
|
|
model-value |
|
|
|
width="600px" |
|
|
|
:before-close="handleClose" |
|
|
|
> |
|
|
|
<el-form ref="form" :model="formData" :rules="rules" label-width="80px"> |
|
|
|
<el-row> |
|
|
|
<el-col :span="24"> |
|
|
|
<el-form-item label="上级菜单"> |
|
|
|
<el-select |
|
|
|
v-model="formData.parent_name" |
|
|
|
placeholder="选择上级菜单" |
|
|
|
> |
|
|
|
<el-option value="" /> |
|
|
|
<el-tree |
|
|
|
:data="treeMenu" |
|
|
|
:props="defaultProps" |
|
|
|
:expand-on-click-node="false" |
|
|
|
@node-click="handleNodeClick" |
|
|
|
></el-tree> |
|
|
|
</el-select> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="12"> |
|
|
|
<el-form-item label="菜单标题" prop="title"> |
|
|
|
<el-input v-model="formData.title" placeholder="请输入菜单标题" /> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="12"> |
|
|
|
<el-form-item label="显示排序"> |
|
|
|
<el-input-number |
|
|
|
v-model="formData.sort" |
|
|
|
controls-position="right" |
|
|
|
:min="0" |
|
|
|
/> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
|
|
|
|
<el-col :span="24"> |
|
|
|
<el-form-item label="菜单类型" prop="menu_type"> |
|
|
|
<el-radio-group v-model="formData.menu_type"> |
|
|
|
<el-radio label="M">目录</el-radio> |
|
|
|
<el-radio label="C">菜单</el-radio> |
|
|
|
<el-radio label="F">按钮</el-radio> |
|
|
|
<el-radio label="A">接口</el-radio> |
|
|
|
</el-radio-group> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="24" v-if="formData.menu_type == 'A'"> |
|
|
|
<el-form-item label="请求方式"> |
|
|
|
<el-radio-group v-model="formData.action"> |
|
|
|
<el-radio label="GET">GET</el-radio> |
|
|
|
<el-radio label="POST">POST</el-radio> |
|
|
|
<el-radio label="PUT">PUT</el-radio> |
|
|
|
<el-radio label="DELETE">DELETE</el-radio> |
|
|
|
</el-radio-group> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col :span="24"> |
|
|
|
<el-form-item label="菜单图标"> |
|
|
|
<el-popover |
|
|
|
placement="bottom" |
|
|
|
width="440px" |
|
|
|
v-model:visible="visible" |
|
|
|
> |
|
|
|
<IconSelect ref="iconSelect" @selected="selected" /> |
|
|
|
<template #reference> |
|
|
|
<el-input v-model="formData.icon" placeholder="点击选择图标" readonly> |
|
|
|
<template #prefix> |
|
|
|
<svg-icon v-if="formData.icon" :icon-class="formData.icon" style="margin-top: 12px;" /> |
|
|
|
<i v-else class="el-icon-search el-input__icon" /> |
|
|
|
</template> |
|
|
|
</el-input> |
|
|
|
</template> |
|
|
|
</el-popover> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
<el-col |
|
|
|
:span="12" |
|
|
|
v-if="formData.menu_type == 'M' || formData.menu_type == 'C'" |
|
|
|
> |
|
|
|
<el-form-item label="路由名称" prop="menu_name"> |
|
|
|
<el-input |
|
|
|
v-model="formData.menu_name" |
|
|
|
placeholder="请输入路由名称" |
|
|
|
/> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
|
|
|
|
<el-col |
|
|
|
v-if="formData.menu_type == 'M' || formData.menu_type == 'C'" |
|
|
|
:span="12" |
|
|
|
> |
|
|
|
<el-form-item label="组件路径" prop="component"> |
|
|
|
<el-input |
|
|
|
v-model="formData.component" |
|
|
|
placeholder="请输入组件路径" |
|
|
|
/> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
|
|
|
|
<el-col :span="12" v-if="formData.menu_type != 'F'"> |
|
|
|
<el-form-item label="路由地址" prop="path"> |
|
|
|
<el-input v-model="formData.path" placeholder="请输入路由地址" /> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
|
|
|
|
<el-col |
|
|
|
:span="12" |
|
|
|
v-if="formData.menu_type == 'F' || formData.menu_type == 'C'" |
|
|
|
> |
|
|
|
<el-form-item label="权限标识"> |
|
|
|
<el-input |
|
|
|
v-model="formData.permission" |
|
|
|
placeholder="请权限标识" |
|
|
|
maxlength="50" |
|
|
|
/> |
|
|
|
</el-form-item> |
|
|
|
</el-col> |
|
|
|
</el-row> |
|
|
|
</el-form> |
|
|
|
<template #footer> |
|
|
|
<span class="dialog-footer"> |
|
|
|
<el-button |
|
|
|
type="primary" |
|
|
|
class="dialog-submit-button" |
|
|
|
@click="submitForm" |
|
|
|
>确 定</el-button |
|
|
|
> |
|
|
|
<el-button class="dialog-cancel-button" @click="handleClose" |
|
|
|
>取 消</el-button |
|
|
|
> |
|
|
|
</span> |
|
|
|
</template> |
|
|
|
</el-dialog> |
|
|
|
</template> |
|
|
|
<script> |
|
|
|
import { getTreeMenu } from "@/server/system/menu"; |
|
|
|
import IconSelect from '@/components/IconSelect'; |
|
|
|
export default { |
|
|
|
components:{ |
|
|
|
IconSelect |
|
|
|
}, |
|
|
|
data() { |
|
|
|
return { |
|
|
|
formData: {}, |
|
|
|
// 菜单树选项 |
|
|
|
treeMenu: [], |
|
|
|
defaultProps: { |
|
|
|
children: 'children', |
|
|
|
label: 'title', |
|
|
|
disabled:'disabled' |
|
|
|
}, |
|
|
|
}; |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
// 确认 |
|
|
|
submitForm() { |
|
|
|
console.log(this.formData); |
|
|
|
}, |
|
|
|
// 取消/关闭 |
|
|
|
handleClose() { |
|
|
|
this.$emit('setIsAddOrEdit') |
|
|
|
}, |
|
|
|
// 查询菜单下拉树结构 |
|
|
|
getTreeMenu() { |
|
|
|
getTreeMenu().then(({code, data}) => { |
|
|
|
if(code ==200 && data){ |
|
|
|
let treeMenu = [{ menu_id: 0, disabled:true, title: '主类目', children: [] }] |
|
|
|
treeMenu[0].children = data; |
|
|
|
this.treeMenu=treeMenu; |
|
|
|
} |
|
|
|
}) |
|
|
|
}, |
|
|
|
// 选择上级菜单后的回调 |
|
|
|
handleNodeClick({parent_id, title}) { |
|
|
|
this.formData.parent_id=parent_id; |
|
|
|
this.formData.parent_name=title; |
|
|
|
}, |
|
|
|
// 选择图标后的操作 |
|
|
|
selected(name){ |
|
|
|
console.log(name); |
|
|
|
this.formData.icon=name; |
|
|
|
} |
|
|
|
}, |
|
|
|
created(){ |
|
|
|
this.getTreeMenu(); |
|
|
|
} |
|
|
|
}; |
|
|
|
</script> |
|
|
|
<style lang="less" scoped> |
|
|
|
/* 去除tree上面的一行高度 */ |
|
|
|
.el-scrollbar .el-scrollbar__view .el-select-dropdown__item { |
|
|
|
height: auto; |
|
|
|
padding: 0; |
|
|
|
} |
|
|
|
</style> |