Commit dd8c1d90 authored by 水落(YangLei)'s avatar 水落(YangLei)

feat: 菜单页面基本完成

parent 9df83c42
<template>
<a-tree-select
show-search
style="width: 100%"
:dropdown-style="{ maxHeight: '400px', overflow: 'auto' }"
placeholder="请选择"
allow-clear
tree-default-expand-all
:treeData="treeData"
:replaceFields="replaceFields"
v-bind="$attrs"
v-on="$listeners"
/>
</template>
<script>
import { getMenuDataApi } from '@/api';
import { convertListToTree } from '@/utils';
export default {
model: {
prop: 'value',
event: 'change',
},
data() {
return {
treeData: [],
replaceFields: {
title: 'menuName',
key: 'menuId',
value: 'menuId',
},
};
},
async mounted() {
this.treeData = convertListToTree(await getMenuDataApi(), true);
console.log(this.treeData);
},
};
</script>
...@@ -124,12 +124,12 @@ export default { ...@@ -124,12 +124,12 @@ export default {
this.submitLoading = true; this.submitLoading = true;
try { try {
await this.addBtn?.onOk(); await this.addBtn?.onOk();
this.addVisible = false;
this.getData(); this.getData();
} catch (error) { } catch (error) {
// todo // todo
} }
this.submitLoading = false; this.submitLoading = false;
this.addVisible = false;
}, },
showAdd() { showAdd() {
this.addVisible = true; this.addVisible = true;
......
<template> <template>
<a-form-model layout="vertical" :model="form" :rules="rules"> <a-form-model layout="vertical" :model="form" :rules="rules" ref="form">
<a-form-model-item label="父级" v-if="isAdd"> <a-form-model-item label="父级" extra="没选择代表根目录" v-if="isAdd">
<MenuTree @check="onCheck" :value="checkedKeys" checkStrictly /> <MenuTree v-model="form.parentMenuId" />
</a-form-model-item> </a-form-model-item>
<a-form-model-item label="类型"> <a-form-model-item label="类型">
<a-radio-group v-model="form.menuType" :disabled="isEdit"> <a-radio-group v-model="form.menuType" :disabled="isEdit">
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
<script> <script>
import { addMenuApi } from '@/api'; import { addMenuApi } from '@/api';
import MenuTree from '@/components/menu_tree/index.vue'; import MenuTree from '@/components/menu_tree/select.vue';
export default { export default {
components: { MenuTree }, components: { MenuTree },
...@@ -40,16 +40,12 @@ export default { ...@@ -40,16 +40,12 @@ export default {
type: 0, type: 0,
form: { form: {
menuType: 'CATALOG', menuType: 'CATALOG',
parentMenuId: 0, parentMenuId: null,
menuName: '', menuName: '',
}, },
rules: { rules: {
menuUrl: [{ required: true }], menuUrl: [{ required: true }],
}, },
checkedKeys: {
checked: [],
halfChecked: [],
},
}), }),
computed: { computed: {
isAdd() { isAdd() {
...@@ -60,12 +56,9 @@ export default { ...@@ -60,12 +56,9 @@ export default {
}, },
}, },
methods: { methods: {
submit() { async submit() {
return addMenuApi({ ...this.form, parentMenuId: this.checkedKeys.checked[0] ?? 0 }); await this.$refs['form'].validate();
}, return addMenuApi({ ...this.form, parentMenuId: this.form.parentMenuId ?? 0 });
onCheck(checkedKeys) {
const checked = checkedKeys.checked.slice(-1);
this.checkedKeys = { checked };
}, },
setEdit(data) { setEdit(data) {
this.type = 1; this.type = 1;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment