fix: element-plus版本升级问题调整
Former-commit-id: 74a0b83abe42f3ace71c23b5091a5dc7cf487213
This commit is contained in:
@@ -30,7 +30,7 @@ export function listSelectDepartments(): AxiosPromise<Option[]> {
|
|||||||
*
|
*
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
export function getDeptFormDetail(id: number): AxiosPromise<DeptFormData> {
|
export function getDeptDetail(id: string): AxiosPromise<DeptFormData> {
|
||||||
return request({
|
return request({
|
||||||
url: '/youlai-admin/api/v1/depts/' + id,
|
url: '/youlai-admin/api/v1/depts/' + id,
|
||||||
method: 'get'
|
method: 'get'
|
||||||
@@ -57,7 +57,7 @@ export function addDept(data: DeptFormData) {
|
|||||||
* @param id
|
* @param id
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
export function updateDept(id: number, data: DeptFormData) {
|
export function updateDept(id: string, data: DeptFormData) {
|
||||||
return request({
|
return request({
|
||||||
url: '/youlai-admin/api/v1/depts/' + id,
|
url: '/youlai-admin/api/v1/depts/' + id,
|
||||||
method: 'put',
|
method: 'put',
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ export function listSelectMenus(): AxiosPromise<Option[]> {
|
|||||||
* 获取菜单详情
|
* 获取菜单详情
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
export function getMenuFormDetail(id: number): AxiosPromise<MenuFormData> {
|
export function getMenuDetail(id: number): AxiosPromise<MenuFormData> {
|
||||||
return request({
|
return request({
|
||||||
url: '/youlai-admin/api/v1/menus/' + id,
|
url: '/youlai-admin/api/v1/menus/' + id,
|
||||||
method: 'get'
|
method: 'get'
|
||||||
@@ -66,7 +66,7 @@ export function addMenu(data: MenuFormData) {
|
|||||||
* @param id
|
* @param id
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
export function updateMenu(id: number, data: MenuFormData) {
|
export function updateMenu(id: string, data: MenuFormData) {
|
||||||
return request({
|
return request({
|
||||||
url: '/youlai-admin/api/v1/menus/' + id,
|
url: '/youlai-admin/api/v1/menus/' + id,
|
||||||
method: 'put',
|
method: 'put',
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="icon-body">
|
<div class="icon-select">
|
||||||
<el-input v-model="iconName" style="position: relative;" clearable placeholder="请输入图标名称" @clear="filterIcons"
|
<el-input v-model="iconName" clearable placeholder="请输入图标名称" @clear="filterIcons"
|
||||||
@input="filterIcons">
|
@input="filterIcons">
|
||||||
<template #suffix><i class="el-icon-search el-input__icon" /></template>
|
<template #suffix><i class="el-icon-search el-input__icon" /></template>
|
||||||
</el-input>
|
</el-input>
|
||||||
<div class="icon-list">
|
<div class="icon-select__list">
|
||||||
<div v-for="(item, index) in iconList" :key="index" @click="selectedIcon(item)">
|
<div v-for="(item, index) in iconList" :key="index" @click="selectedIcon(item)">
|
||||||
<svg-icon color="#999" :icon-class="item" style="height: 30px;width: 16px;margin-right: 5px" />
|
<svg-icon color="#999" :icon-class="item" style="height: 30px;width: 16px;margin-right: 5px" />
|
||||||
<span>{{ item }}</span>
|
<span>{{ item }}</span>
|
||||||
@@ -18,9 +18,9 @@ import { ref } from "vue";
|
|||||||
import SvgIcon from '@/components/SvgIcon/index.vue';
|
import SvgIcon from '@/components/SvgIcon/index.vue';
|
||||||
|
|
||||||
const icons = [] as string[]
|
const icons = [] as string[]
|
||||||
const modules = import.meta.glob('../../assets/icons/svg/*.svg');
|
const modules = import.meta.glob('../../assets/icons/*.svg');
|
||||||
for (const path in modules) {
|
for (const path in modules) {
|
||||||
const p = path.split('assets/icons/svg/')[1].split('.svg')[0];
|
const p = path.split('assets/icons/')[1].split('.svg')[0];
|
||||||
icons.push(p);
|
icons.push(p);
|
||||||
}
|
}
|
||||||
const iconList = ref(icons);
|
const iconList = ref(icons);
|
||||||
@@ -52,11 +52,11 @@ defineExpose({
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang='scss' scoped>
|
<style lang='scss' scoped>
|
||||||
.icon-body {
|
.icon-select {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
|
||||||
.icon-list {
|
&__list {
|
||||||
height: 200px;
|
height: 200px;
|
||||||
overflow-y: scroll;
|
overflow-y: scroll;
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const props=defineProps({
|
|||||||
},
|
},
|
||||||
iconClass: {
|
iconClass: {
|
||||||
type: String,
|
type: String,
|
||||||
required: true,
|
required: false
|
||||||
},
|
},
|
||||||
color: {
|
color: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|||||||
8
src/types/api/system/dept.d.ts
vendored
8
src/types/api/system/dept.d.ts
vendored
@@ -12,9 +12,9 @@ export interface DeptQueryParam {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
export interface DeptItem {
|
export interface DeptItem {
|
||||||
id: number;
|
id: string;
|
||||||
name: string;
|
name: string;
|
||||||
parentId: number;
|
parentId: string;
|
||||||
treePath: string;
|
treePath: string;
|
||||||
sort: number;
|
sort: number;
|
||||||
status: number;
|
status: number;
|
||||||
@@ -28,8 +28,8 @@ export interface DeptItem {
|
|||||||
* 部门表单类型声明
|
* 部门表单类型声明
|
||||||
*/
|
*/
|
||||||
export interface DeptFormData {
|
export interface DeptFormData {
|
||||||
id: number|undefined,
|
id?: string,
|
||||||
parentId: number,
|
parentId: string,
|
||||||
name: string,
|
name: string,
|
||||||
sort: number,
|
sort: number,
|
||||||
status: number
|
status: number
|
||||||
|
|||||||
4
src/types/api/system/menu.d.ts
vendored
4
src/types/api/system/menu.d.ts
vendored
@@ -30,11 +30,11 @@ export interface MenuFormData {
|
|||||||
/**
|
/**
|
||||||
* 菜单ID
|
* 菜单ID
|
||||||
*/
|
*/
|
||||||
id: number | undefined,
|
id: string ,
|
||||||
/**
|
/**
|
||||||
* 父菜单ID
|
* 父菜单ID
|
||||||
*/
|
*/
|
||||||
parentId: number,
|
parentId: string,
|
||||||
/**
|
/**
|
||||||
* 菜单名称
|
* 菜单名称
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ import { onMounted, reactive, unref, ref, toRefs } from "vue";
|
|||||||
|
|
||||||
// API依赖
|
// API依赖
|
||||||
import {
|
import {
|
||||||
getDeptFormDetail,
|
getDeptDetail,
|
||||||
deleteDept,
|
deleteDept,
|
||||||
updateDept,
|
updateDept,
|
||||||
addDept,
|
addDept,
|
||||||
@@ -177,11 +177,11 @@ function handleSelectionChange(selection: any) {
|
|||||||
/**
|
/**
|
||||||
* 加载部门下拉数据源
|
* 加载部门下拉数据源
|
||||||
*/
|
*/
|
||||||
async function loadDeptOptions() {
|
async function loadDeptData() {
|
||||||
const deptOptions: any[] = [];
|
const deptOptions: any[] = [];
|
||||||
listSelectDepartments().then((response) => {
|
listSelectDepartments().then((response) => {
|
||||||
const rootDeptOption = {
|
const rootDeptOption = {
|
||||||
id: 0,
|
value: "0",
|
||||||
label: "顶级部门",
|
label: "顶级部门",
|
||||||
children: response.data,
|
children: response.data,
|
||||||
};
|
};
|
||||||
@@ -194,11 +194,11 @@ async function loadDeptOptions() {
|
|||||||
* 添加部门
|
* 添加部门
|
||||||
*/
|
*/
|
||||||
function handleAdd(row: any) {
|
function handleAdd(row: any) {
|
||||||
loadDeptOptions();
|
loadDeptData();
|
||||||
state.formData.parentId = row.id;
|
state.formData.parentId = row.id;
|
||||||
state.dialog = {
|
state.dialog = {
|
||||||
title: "添加部门",
|
title: "添加部门",
|
||||||
visible: true,
|
visible: true
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,13 +206,13 @@ function handleAdd(row: any) {
|
|||||||
* 修改部门
|
* 修改部门
|
||||||
*/
|
*/
|
||||||
async function handleUpdate(row: any) {
|
async function handleUpdate(row: any) {
|
||||||
await loadDeptOptions();
|
await loadDeptData();
|
||||||
const deptId = row.id || state.ids;
|
const deptId = row.id || state.ids;
|
||||||
state.dialog = {
|
state.dialog = {
|
||||||
title: "修改部门",
|
title: "修改部门",
|
||||||
visible: true,
|
visible: true
|
||||||
};
|
};
|
||||||
getDeptFormDetail(deptId).then((response: any) => {
|
getDeptDetail(deptId).then((response: any) => {
|
||||||
state.formData = response.data;
|
state.formData = response.data;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -221,8 +221,7 @@ async function handleUpdate(row: any) {
|
|||||||
* 部门表单提交
|
* 部门表单提交
|
||||||
*/
|
*/
|
||||||
function submitForm() {
|
function submitForm() {
|
||||||
const dataForm = unref(dataFormRef);
|
dataFormRef.value.validate((valid: any) => {
|
||||||
dataForm.validate((valid: any) => {
|
|
||||||
if (valid) {
|
if (valid) {
|
||||||
if (state.formData.id) {
|
if (state.formData.id) {
|
||||||
updateDept(state.formData.id, state.formData).then(() => {
|
updateDept(state.formData.id, state.formData).then(() => {
|
||||||
@@ -270,7 +269,6 @@ function handleDelete(row: any) {
|
|||||||
* 取消/关闭弹窗
|
* 取消/关闭弹窗
|
||||||
**/
|
**/
|
||||||
function cancel() {
|
function cancel() {
|
||||||
state.formData.id = undefined;
|
|
||||||
dataFormRef.value.resetFields();
|
dataFormRef.value.resetFields();
|
||||||
state.dialog.visible = false;
|
state.dialog.visible = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,9 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
|
||||||
|
<el-table-column label="排序" align="center" width="100" prop="sort">
|
||||||
|
</el-table-column>
|
||||||
|
|
||||||
<el-table-column label="操作" align="center" width="200">
|
<el-table-column label="操作" align="center" width="200">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-button type="success" :icon="Plus" circle plain @click.stop="handleAdd(scope.row)" />
|
<el-button type="success" :icon="Plus" circle plain @click.stop="handleAdd(scope.row)" />
|
||||||
@@ -43,7 +46,7 @@
|
|||||||
</el-table>
|
</el-table>
|
||||||
|
|
||||||
<!-- 弹窗表单 -->
|
<!-- 弹窗表单 -->
|
||||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="750px">
|
<el-dialog :title="dialog.title" v-model="dialog.visible" @close="cancel" width="750px">
|
||||||
<el-form ref="dataFormRef" :model="formData" :rules="rules" label-width="100px">
|
<el-form ref="dataFormRef" :model="formData" :rules="rules" label-width="100px">
|
||||||
<el-form-item label="父级菜单" prop="parentId">
|
<el-form-item label="父级菜单" prop="parentId">
|
||||||
<el-tree-select v-model="formData.parentId" placeholder="选择上级菜单" :data="menuOptions" filterable />
|
<el-tree-select v-model="formData.parentId" placeholder="选择上级菜单" :data="menuOptions" filterable />
|
||||||
@@ -76,16 +79,16 @@
|
|||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
<el-form-item label="图标" prop="icon">
|
<el-form-item label="图标" prop="icon">
|
||||||
<el-popover placement="bottom-start" :width="570" trigger="click" visible="iconSelectVisible">
|
<el-popover ref="popoverRef" placement="bottom-start" :width="570" trigger="click">
|
||||||
<icon-select ref="iconSelectRef" @selected="selected" />
|
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<el-input v-model="formData.icon" placeholder="点击选择图标" readonly @click="iconSelectVisible = true">
|
<el-input v-model="formData.icon" placeholder="点击选择图标" readonly @click="iconSelectVisible = true">
|
||||||
<template #prefix>
|
<template #prefix>
|
||||||
<svg-icon :icon-class="formData.icon ? formData.icon : 'color'" class="el-input__icon"
|
<svg-icon :icon-class="formData.icon" style="margin: auto" />
|
||||||
style="margin: auto" color="#999" />
|
|
||||||
</template>
|
</template>
|
||||||
</el-input>
|
</el-input>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<icon-select @selected="selected" />
|
||||||
</el-popover>
|
</el-popover>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
|
||||||
@@ -119,7 +122,7 @@
|
|||||||
import { reactive, ref, onMounted, toRefs } from "vue";
|
import { reactive, ref, onMounted, toRefs } from "vue";
|
||||||
|
|
||||||
import { Search, Plus, Edit, Refresh, Delete } from "@element-plus/icons-vue";
|
import { Search, Plus, Edit, Refresh, Delete } from "@element-plus/icons-vue";
|
||||||
import { ElForm, ElMessage, ElMessageBox } from "element-plus";
|
import { ElForm, ElMessage, ElMessageBox, ElPopover } from "element-plus";
|
||||||
|
|
||||||
import { isExternal } from "@/utils/validate";
|
import { isExternal } from "@/utils/validate";
|
||||||
import {
|
import {
|
||||||
@@ -132,21 +135,20 @@ import {
|
|||||||
// API 依赖
|
// API 依赖
|
||||||
import {
|
import {
|
||||||
listTableMenus,
|
listTableMenus,
|
||||||
getMenuFormDetail,
|
getMenuDetail,
|
||||||
listSelectMenus,
|
listSelectMenus,
|
||||||
addMenu,
|
addMenu,
|
||||||
deleteMenus,
|
deleteMenus,
|
||||||
updateMenu,
|
updateMenu
|
||||||
} from "@/api/system/menu";
|
} from "@/api/system/menu";
|
||||||
|
|
||||||
import SvgIcon from "@/components/SvgIcon/index.vue";
|
import SvgIcon from "@/components/SvgIcon/index.vue";
|
||||||
import IconSelect from "@/components/IconSelect/index.vue";
|
import IconSelect from "@/components/IconSelect/index.vue";
|
||||||
|
|
||||||
const emit = defineEmits(["menuClick"]);
|
const emit = defineEmits(["menuClick"]);
|
||||||
const iconSelectRef = ref(null);
|
|
||||||
|
|
||||||
const queryFormRef = ref(ElForm);
|
const queryFormRef = ref(ElForm);
|
||||||
const dataFormRef = ref(ElForm);
|
const dataFormRef = ref(ElForm);
|
||||||
|
const popoverRef = ref(ElPopover)
|
||||||
|
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
loading: true,
|
loading: true,
|
||||||
@@ -160,7 +162,7 @@ const state = reactive({
|
|||||||
menuList: [] as MenuItem[],
|
menuList: [] as MenuItem[],
|
||||||
dialog: { visible: false } as Dialog,
|
dialog: { visible: false } as Dialog,
|
||||||
formData: {
|
formData: {
|
||||||
parentId: 0,
|
parentId: "0",
|
||||||
visible: 1,
|
visible: 1,
|
||||||
sort: 1,
|
sort: 1,
|
||||||
component: "Layout",
|
component: "Layout",
|
||||||
@@ -173,6 +175,7 @@ const state = reactive({
|
|||||||
menuOptions: [] as Option[],
|
menuOptions: [] as Option[],
|
||||||
currentRow: undefined,
|
currentRow: undefined,
|
||||||
isExternalPath: false,
|
isExternalPath: false,
|
||||||
|
// Icon选择器显示状态
|
||||||
iconSelectVisible: false
|
iconSelectVisible: false
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -185,7 +188,7 @@ const {
|
|||||||
rules,
|
rules,
|
||||||
menuOptions,
|
menuOptions,
|
||||||
isExternalPath,
|
isExternalPath,
|
||||||
iconSelectVisible,
|
iconSelectVisible
|
||||||
} = toRefs(state);
|
} = toRefs(state);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -204,10 +207,10 @@ function handleQuery() {
|
|||||||
/**
|
/**
|
||||||
* 加载菜单下拉树
|
* 加载菜单下拉树
|
||||||
*/
|
*/
|
||||||
async function loadTreeSelectMenuOptions() {
|
async function loadMenuData() {
|
||||||
const menuOptions: any[] = [];
|
const menuOptions: any[] = [];
|
||||||
await listSelectMenus().then(({ data }) => {
|
await listSelectMenus().then(({ data }) => {
|
||||||
const menuOption = { value: 0, label: "顶级菜单", children: data };
|
const menuOption = { value: "0", label: "顶级菜单", children: data };
|
||||||
menuOptions.push(menuOption);
|
menuOptions.push(menuOption);
|
||||||
state.menuOptions = menuOptions;
|
state.menuOptions = menuOptions;
|
||||||
});
|
});
|
||||||
@@ -227,7 +230,7 @@ function handleRowClick(row: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleAdd(row: any) {
|
async function handleAdd(row: any) {
|
||||||
await loadTreeSelectMenuOptions();
|
await loadMenuData();
|
||||||
state.dialog = {
|
state.dialog = {
|
||||||
title: "添加菜单",
|
title: "添加菜单",
|
||||||
visible: true,
|
visible: true,
|
||||||
@@ -246,20 +249,22 @@ async function handleAdd(row: any) {
|
|||||||
state.formData.parentId = (state.currentRow as any).id;
|
state.formData.parentId = (state.currentRow as any).id;
|
||||||
state.formData.component = "";
|
state.formData.component = "";
|
||||||
} else {
|
} else {
|
||||||
state.formData.parentId = 0;
|
state.formData.parentId = "0";
|
||||||
state.formData.component = "Layout";
|
state.formData.component = "Layout";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleUpdate(row: any) {
|
async function handleUpdate(row: any) {
|
||||||
await loadTreeSelectMenuOptions();
|
await loadMenuData();
|
||||||
|
console.log('menuop',state.menuOptions)
|
||||||
state.dialog = {
|
state.dialog = {
|
||||||
title: "修改菜单",
|
title: "修改菜单",
|
||||||
visible: true,
|
visible: true
|
||||||
};
|
};
|
||||||
const id = row.id || state.ids;
|
const id = row.id || state.ids;
|
||||||
getMenuFormDetail(id).then(({ data }) => {
|
console.log('id',id)
|
||||||
|
getMenuDetail(id).then(({ data }) => {
|
||||||
state.formData = data;
|
state.formData = data;
|
||||||
// 判断是否外部链接
|
// 判断是否外部链接
|
||||||
state.isExternalPath = isExternal(state.formData.path);
|
state.isExternalPath = isExternal(state.formData.path);
|
||||||
@@ -267,7 +272,7 @@ async function handleUpdate(row: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 表单提交
|
* 菜单表单提交
|
||||||
*/
|
*/
|
||||||
function submitForm() {
|
function submitForm() {
|
||||||
dataFormRef.value.validate((isValid: boolean) => {
|
dataFormRef.value.validate((isValid: boolean) => {
|
||||||
@@ -309,7 +314,6 @@ function handleDelete(row: any) {
|
|||||||
* 取消关闭弹窗
|
* 取消关闭弹窗
|
||||||
*/
|
*/
|
||||||
function cancel() {
|
function cancel() {
|
||||||
state.formData.id = undefined;
|
|
||||||
dataFormRef.value.resetFields();
|
dataFormRef.value.resetFields();
|
||||||
state.dialog.visible = false;
|
state.dialog.visible = false;
|
||||||
}
|
}
|
||||||
@@ -322,6 +326,7 @@ function selected(name: string) {
|
|||||||
state.iconSelectVisible = false;
|
state.iconSelectVisible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
handleQuery();
|
handleQuery();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,19 +1,15 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="menu-container">
|
<div class="menu-container">
|
||||||
<el-form>
|
|
||||||
<el-form-item>
|
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="16">
|
<el-col :span="12">
|
||||||
<el-button type="success" plain :icon="Switch" @click="toggleExpandAll">展开/折叠</el-button>
|
<el-button plain :icon="Switch" @click="toggleExpandAll">展开/折叠</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="8" style="text-align: right">
|
<el-col :span="12" style="text-align: right">
|
||||||
<el-button type="primary" :icon="Check" @click="handleSubmit">提交</el-button>
|
<el-button type="primary" :icon="Check" @click="handleSubmit">提交</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
|
|
||||||
<el-tree ref="menuRef" v-if="refreshTree" :default-expanded-keys="expandedKeys" :default-expand-all="isExpandAll"
|
<el-tree class="menu-container__tree" ref="menuRef" v-if="refreshTree" :default-expanded-keys="expandedKeys" :default-expand-all="isExpandAll"
|
||||||
:data="menuOptions" show-checkbox node-key="value" empty-text="加载菜单中..." :check-strictly="checkStrictly"
|
:data="menuOptions" show-checkbox node-key="value" empty-text="加载菜单中..." :check-strictly="checkStrictly"
|
||||||
highlight-current @node-click="handleNodeClick" />
|
highlight-current @node-click="handleNodeClick" />
|
||||||
</div>
|
</div>
|
||||||
@@ -31,21 +27,19 @@ const emit = defineEmits(["menuClick"]);
|
|||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
role: {
|
role: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => {
|
default: () => { }
|
||||||
return {}
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const menuRef = ref(ElTree); // 属性名必须和元素的ref属性值一致
|
const menuRef = ref(ElTree); // 属性名必须和元素的ref属性值一致
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.role.id as any,
|
() => props.role.id,
|
||||||
() => {
|
(newVal) => {
|
||||||
const roleId = props.role.id;
|
if (newVal) {
|
||||||
if (roleId) {
|
|
||||||
state.checkStrictly = true;
|
state.checkStrictly = true;
|
||||||
listRoleMenuIds(roleId).then(({ data }) => {
|
// 获取角色拥有的的菜单ID
|
||||||
|
listRoleMenuIds(newVal).then(({ data }) => {
|
||||||
menuRef.value.setCheckedKeys(data);
|
menuRef.value.setCheckedKeys(data);
|
||||||
state.checkStrictly = false;
|
state.checkStrictly = false;
|
||||||
});
|
});
|
||||||
@@ -67,7 +61,7 @@ const { expandedKeys, menuOptions, checkStrictly, isExpandAll, refreshTree } =
|
|||||||
/**
|
/**
|
||||||
* 加载菜单树
|
* 加载菜单树
|
||||||
*/
|
*/
|
||||||
async function loadTreeSelectMenuOptions() {
|
async function loadMenuData() {
|
||||||
await listSelectMenus().then(({ data }) => {
|
await listSelectMenus().then(({ data }) => {
|
||||||
state.menuOptions = data;
|
state.menuOptions = data;
|
||||||
});
|
});
|
||||||
@@ -101,12 +95,14 @@ function handleSubmit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadTreeSelectMenuOptions();
|
loadMenuData();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
.menu-container {
|
.menu-container {
|
||||||
width: 100%;
|
&__tree{
|
||||||
|
margin-top: 10px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user