菜单管理

This commit is contained in:
sjl
2024-11-18 16:02:19 +08:00
parent 5cdbee88b4
commit a57ebbcc62
14 changed files with 355 additions and 292 deletions

View File

@@ -3,11 +3,13 @@
<el-form :model="formContent" ref='dialogFormRef' :rules='rules' >
<el-form-item label="上级菜单" prop="pid" :label-width="100">
<el-tree-select
v-model="formContent.pid"
v-model="displayPid"
:data="functionList"
check-strictly
:render-after-expand="false"
show-checkbox
check-on-click-node
node-key="id"
:props="defaultProps"
/>
</el-form-item>
@@ -20,7 +22,7 @@
<el-form-item label="图标" prop="icon" :label-width="100">
<IconSelect
:iconValue="formContent.icon"
@update:iconValue="(value) => formContent.icon = value"
@update:icon-value="iconValue => formContent.icon = iconValue"
placeholder="选择一个图标"
/>
</el-form-item>
@@ -37,8 +39,8 @@
<el-select v-model="formContent.type" clearable placeholder="请选择资源类型">
<el-option label="菜单" :value="0"></el-option>
<el-option label="按钮" :value="1"></el-option>
<el-option label="公共资源" :value="2"></el-option>
<el-option label="服务间调用资源" :value="3"></el-option>
<!-- <el-option label="公共资源" :value="2"></el-option>
<el-option label="服务间调用资源" :value="3"></el-option> -->
</el-select>
</el-form-item>
<el-form-item label="描述" prop="remark" :label-width="100">
@@ -67,8 +69,9 @@
const defaultProps = {
children: 'children',
label: 'name',
value: 'id'
};
const functionList = ref<Function.ResFunction[]>([])
const dictStore = useDictStore()
// 定义弹出组件元信息
const dialogFormRef = ref()
@@ -91,7 +94,7 @@
})
return { dialogVisible, titleType, formContent }
}
const { dialogVisible, titleType, formContent } = useMetaInfo()
// 清空formContent
const resetFormContent = () => {
@@ -136,12 +139,29 @@ const close = () => {
dialogFormRef.value?.resetFields()
}
// 计算属性,用于控制显示的 pid
const displayPid = computed({
get: () => {
return formContent.value.pid === '0' ? '' : formContent.value.pid;
},
set: (value) => {
formContent.value.pid = value;
}
});
// 保存数据
const save = () => {
try {
console.log(formContent.value)
dialogFormRef.value?.validate(async (valid: boolean) => {
console.log(formContent.value)
if (formContent.value.pid === undefined || formContent.value.pid === null || formContent.value.pid === '') {
formContent.value.pid = '0';
}
if (formContent.value.pids === undefined || formContent.value.pids === null || formContent.value.pids === '') {
formContent.value.pids = '0';
}
if (valid) {
if (formContent.value.id) {
await updateFunction(formContent.value);
@@ -152,20 +172,26 @@ const close = () => {
close()
// 刷新表格
await props.refreshTable!()
}
})
} catch (err) {
//console.error('验证过程中出现错误', err)
console.error('验证过程中出现错误', err)
}
}
const functionList = ref<Function.ResFunction[]>([])
// 打开弹窗,可能是新增,也可能是编辑
const open = async (sign: string, data: Function.ResFunction) => {
const response = await getFunctionListNoButton()
functionList.value = response.data as unknown as Function.ResFunction[]
titleType.value = sign
dialogVisible.value = true
if (formContent.value.pid ==='0') {
formContent.value.pid = '';
}
if (data.id) {
formContent.value = { ...data }
} else {