|
@@ -1,9 +1,9 @@
|
|
<template>
|
|
<template>
|
|
<CommonPage>
|
|
<CommonPage>
|
|
<template #action>
|
|
<template #action>
|
|
- <NButton type="primary" @click="handleAdd">
|
|
|
|
|
|
+ <NButton type="primary" @click="handleAddMenu">
|
|
<i class="i-material-symbols:add mr-4 text-18" />
|
|
<i class="i-material-symbols:add mr-4 text-18" />
|
|
- 新增一级菜单
|
|
|
|
|
|
+ 新增菜单
|
|
</NButton>
|
|
</NButton>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
@@ -14,8 +14,10 @@
|
|
xxx
|
|
xxx
|
|
</div>
|
|
</div>
|
|
<template #header-extra>
|
|
<template #header-extra>
|
|
- <n-dropdown trigger="click" :options="options" :show-arrow="true"
|
|
|
|
- @select="(key) => handleSelect(key, item)">
|
|
|
|
|
|
+ <n-dropdown
|
|
|
|
+ trigger="click" :options="options" :show-arrow="true"
|
|
|
|
+ @select="(key) => handleSelect(key, item)"
|
|
|
|
+ >
|
|
<n-button text>
|
|
<n-button text>
|
|
<i class="i-material-symbols:more-horiz text-24" />
|
|
<i class="i-material-symbols:more-horiz text-24" />
|
|
</n-button>
|
|
</n-button>
|
|
@@ -27,18 +29,29 @@
|
|
|
|
|
|
<MeModal ref="modalRef" width="520px">
|
|
<MeModal ref="modalRef" width="520px">
|
|
<n-form ref="modalFormRef" label-placement="left" label-align="left" :label-width="80" :model="modalForm">
|
|
<n-form ref="modalFormRef" label-placement="left" label-align="left" :label-width="80" :model="modalForm">
|
|
- <n-form-item label="名称" path="title" :rule="{
|
|
|
|
- required: true,
|
|
|
|
- message: '请输入名称',
|
|
|
|
- trigger: ['input', 'blur'],
|
|
|
|
- }">
|
|
|
|
|
|
+ <n-form-item
|
|
|
|
+ label="名称" path="title" :rule="{
|
|
|
|
+ required: true,
|
|
|
|
+ message: '请输入名称',
|
|
|
|
+ trigger: ['input', 'blur'],
|
|
|
|
+ }"
|
|
|
|
+ >
|
|
<n-input v-model:value="modalForm.title" />
|
|
<n-input v-model:value="modalForm.title" />
|
|
</n-form-item>
|
|
</n-form-item>
|
|
|
|
|
|
<n-form-item label="备注" path="remark">
|
|
<n-form-item label="备注" path="remark">
|
|
<n-input v-model:value="modalForm.remark" />
|
|
<n-input v-model:value="modalForm.remark" />
|
|
</n-form-item>
|
|
</n-form-item>
|
|
-
|
|
|
|
|
|
+ <n-form-item label="是否显示" path="isPublish">
|
|
|
|
+ <NSwitch v-model:value="modalForm.isPublish">
|
|
|
|
+ <template #checked>
|
|
|
|
+ 启用
|
|
|
|
+ </template>
|
|
|
|
+ <template #unchecked>
|
|
|
|
+ 停用
|
|
|
|
+ </template>
|
|
|
|
+ </NSwitch>
|
|
|
|
+ </n-form-item>
|
|
<n-form-item label="状态" path="enable">
|
|
<n-form-item label="状态" path="enable">
|
|
<NSwitch v-model:value="modalForm.enable">
|
|
<NSwitch v-model:value="modalForm.enable">
|
|
<template #checked>
|
|
<template #checked>
|
|
@@ -57,11 +70,14 @@
|
|
<script setup>
|
|
<script setup>
|
|
import { MeModal } from '@/components'
|
|
import { MeModal } from '@/components'
|
|
import { useCrud } from '@/composables'
|
|
import { useCrud } from '@/composables'
|
|
|
|
+import { useUserStore } from '@/store/index.js'
|
|
import { onMounted } from 'vue'
|
|
import { onMounted } from 'vue'
|
|
|
|
+import { useRouter } from 'vue-router'
|
|
import MenuApi from './api.js'
|
|
import MenuApi from './api.js'
|
|
|
|
|
|
|
|
+const router = useRouter()
|
|
const topMenu = ref([])
|
|
const topMenu = ref([])
|
|
-
|
|
|
|
|
|
+const { userId } = useUserStore()
|
|
const $table = ref(null)
|
|
const $table = ref(null)
|
|
/** QueryBar筛选参数(可选) */
|
|
/** QueryBar筛选参数(可选) */
|
|
const queryItems = ref({})
|
|
const queryItems = ref({})
|
|
@@ -77,6 +93,14 @@ const { modalRef, modalFormRef, modalAction, modalForm, handleAdd, handleDelete,
|
|
})
|
|
})
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
$table.value?.handleSearch()
|
|
$table.value?.handleSearch()
|
|
|
|
+ getTopMenuList()
|
|
|
|
+})
|
|
|
|
+
|
|
|
|
+watchEffect(() => {
|
|
|
|
+ if (userId) {
|
|
|
|
+ modalForm.value.userId = userId
|
|
|
|
+ modalForm.value.level = 0
|
|
|
|
+ }
|
|
})
|
|
})
|
|
const options = [
|
|
const options = [
|
|
{
|
|
{
|
|
@@ -109,12 +133,15 @@ async function handleTopMenuDelete(id) {
|
|
}
|
|
}
|
|
async function handleTopMenuEdit(id) {
|
|
async function handleTopMenuEdit(id) {
|
|
console.log('id', id)
|
|
console.log('id', id)
|
|
|
|
+ router.push(`/menu/list/${id}`)
|
|
}
|
|
}
|
|
|
|
|
|
function getTopMenuList() {
|
|
function getTopMenuList() {
|
|
MenuApi.getLevel(0).then(({ data = [] }) => (topMenu.value = data))
|
|
MenuApi.getLevel(0).then(({ data = [] }) => (topMenu.value = data))
|
|
}
|
|
}
|
|
-onMounted(() => {
|
|
|
|
- getTopMenuList()
|
|
|
|
-})
|
|
|
|
|
|
+function handleAddMenu() {
|
|
|
|
+ handleAdd(null, null, () => {
|
|
|
|
+ getTopMenuList()
|
|
|
|
+ })
|
|
|
|
+}
|
|
</script>
|
|
</script>
|