67 lines
2.5 KiB
Vue
67 lines
2.5 KiB
Vue
<template>
|
|
<div :style="{ marginLeft: depth * 20 + 'px' }" style="margin-top: 8px; padding: 0 14px 10px;">
|
|
<div class="op-card" style="border-left: 3px solid var(--primary);">
|
|
<div class="op-card-head">
|
|
<div class="op-card-title" style="font-size: 14px;">{{ node.menuName }}</div>
|
|
<StatusTag :text="menuTypeLabel(node.menuType)" :variant="menuTypeTone(node.menuType)" />
|
|
</div>
|
|
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: var(--bg); border-radius: var(--rs); padding: 8px 10px; margin-top: 6px;">
|
|
<div>
|
|
<div style="font-size: 11px; color: var(--text-muted);">编码</div>
|
|
<div style="font-size: 13px; font-weight: 500; color: var(--text); margin-top: 2px;">{{ node.menuCode || '-' }}</div>
|
|
</div>
|
|
<div>
|
|
<div style="font-size: 11px; color: var(--text-muted);">排序</div>
|
|
<div style="font-size: 13px; font-weight: 500; color: var(--text); margin-top: 2px;">{{ node.sortOrder }}</div>
|
|
</div>
|
|
</div>
|
|
<div class="op-card-body">
|
|
<div class="op-actions">
|
|
<button class="btn btn-sm btn-primary" @click="$emit('add-child', node.id)">新增子菜单</button>
|
|
<button class="btn btn-sm btn-primary" @click="$emit('edit', node)">编辑</button>
|
|
<button class="btn btn-sm btn-danger" :disabled="loadingMap['delete-' + node.id]" @click="$emit('delete', node)">
|
|
{{ loadingMap['delete-' + node.id] ? '删除中...' : '删除' }}
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<template v-if="node.children && node.children.length > 0">
|
|
<MenuNode
|
|
v-for="child in node.children"
|
|
:key="child.id"
|
|
:node="child"
|
|
:depth="depth + 1"
|
|
:loading-map="loadingMap"
|
|
@edit="(n: any) => $emit('edit', n)"
|
|
@delete="(n: any) => $emit('delete', n)"
|
|
@add-child="(id: number) => $emit('add-child', id)"
|
|
/>
|
|
</template>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
import { menuTypeLabel } from '@/utils/format'
|
|
import StatusTag from '@/components/mobile/StatusTag.vue'
|
|
|
|
defineOptions({ name: 'MenuNode' })
|
|
|
|
defineProps<{
|
|
node: Record<string, any>
|
|
depth: number
|
|
loadingMap: Record<string, boolean>
|
|
}>()
|
|
|
|
defineEmits<{
|
|
(e: 'edit', menu: any): void
|
|
(e: 'delete', menu: any): void
|
|
(e: 'add-child', parentId: number): void
|
|
}>()
|
|
|
|
function menuTypeTone(menuType: number): string {
|
|
if (menuType === 1) return 'processing'
|
|
if (menuType === 2) return 'success'
|
|
return 'info'
|
|
}
|
|
</script>
|