mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 02:29:19 +08:00
feat: 菜单增加前端路由名字段
This commit is contained in:
@@ -11,6 +11,8 @@ export namespace MenuDTO {
|
||||
superMenu?: number;
|
||||
/** 菜单名称 */
|
||||
name: string;
|
||||
/** 路由名称(Vue Router name,建议英文唯一) */
|
||||
routeName?: string;
|
||||
/** 菜单标题 */
|
||||
title?: string;
|
||||
/** 路由路径 */
|
||||
@@ -43,6 +45,8 @@ export namespace MenuDTO {
|
||||
superMenu?: number;
|
||||
/** 菜单名称 */
|
||||
name: string;
|
||||
/** 路由名称(Vue Router name,建议英文唯一) */
|
||||
routeName?: string;
|
||||
/** 菜单标题 */
|
||||
title?: string;
|
||||
/** 路由路径 */
|
||||
|
||||
@@ -14,6 +14,8 @@ export namespace MenuVO {
|
||||
superMenu?: number;
|
||||
/** 菜单名称 */
|
||||
name: string;
|
||||
/** 路由名称(Vue Router name) */
|
||||
routeName?: string;
|
||||
/** 菜单标题 */
|
||||
title?: string;
|
||||
/** 路由路径 */
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import type { MenuProps } from 'ant-design-vue';
|
||||
|
||||
import { computed, h, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
@@ -9,7 +7,6 @@ import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import {
|
||||
DatePicker,
|
||||
Dropdown,
|
||||
InputNumber,
|
||||
message,
|
||||
Popover,
|
||||
@@ -41,7 +38,7 @@ import WorkbenchMultiTab from './tabs/multi/index.vue';
|
||||
import WorkbenchPeriodCompareTab from './tabs/compare/index.vue';
|
||||
import WorkbenchSalesRankTab from './tabs/sales-rank/index.vue';
|
||||
|
||||
defineOptions({ name: 'PddWorkbench' });
|
||||
defineOptions({ name: 'Workbench' });
|
||||
|
||||
const openPopover = ref<string | null>(null);
|
||||
|
||||
@@ -99,21 +96,11 @@ const summaryTablesPanel = computed(
|
||||
|
||||
const router = useRouter();
|
||||
|
||||
const ImportOrderIcon = createIconifyIcon('lucide:upload');
|
||||
const AdFeeIcon = createIconifyIcon('lucide:dollar-sign');
|
||||
const ToolbarToggleIcon = createIconifyIcon('lucide:sliders-horizontal');
|
||||
const ReceiptIcon = createIconifyIcon('lucide:receipt');
|
||||
const CalendarIcon = createIconifyIcon('lucide:calendar');
|
||||
const RefreshIcon = createIconifyIcon('lucide:refresh-cw');
|
||||
|
||||
function goToImportOrder() {
|
||||
void router.push('/import/order');
|
||||
}
|
||||
|
||||
function goToImportAdFee() {
|
||||
void router.push('/import/ad-fee');
|
||||
}
|
||||
|
||||
/** 快捷区间 + 自定义 RangePicker */
|
||||
const dateRange = ref<[dayjs.Dayjs, dayjs.Dayjs]>([
|
||||
dayjs().startOf('month'),
|
||||
@@ -164,24 +151,6 @@ const timeRangeLabel = computed(() => {
|
||||
return '日期';
|
||||
});
|
||||
|
||||
const importMenuItems: MenuProps['items'] = [
|
||||
{
|
||||
key: 'order',
|
||||
label: '导入订单',
|
||||
icon: () => h(ImportOrderIcon, { class: 'size-4' }),
|
||||
},
|
||||
{
|
||||
key: 'ad-fee',
|
||||
label: '导入广告费',
|
||||
icon: () => h(AdFeeIcon, { class: 'size-4' }),
|
||||
},
|
||||
];
|
||||
|
||||
const onImportMenuClick: MenuProps['onClick'] = ({ key }) => {
|
||||
if (key === 'order') goToImportOrder();
|
||||
else if (key === 'ad-fee') goToImportAdFee();
|
||||
};
|
||||
|
||||
const switchTimeRange = (type: TimeRangeKey) => {
|
||||
activeTimeRange.value = type;
|
||||
let startDate: dayjs.Dayjs;
|
||||
@@ -693,24 +662,6 @@ onUnmounted(() => {
|
||||
<div
|
||||
class="workbench-header-extra flex w-full max-w-full flex-col gap-2 sm:w-auto sm:flex-row sm:items-center sm:gap-2"
|
||||
>
|
||||
<Dropdown
|
||||
:trigger="['click']"
|
||||
:menu="{ items: importMenuItems, onClick: onImportMenuClick }"
|
||||
>
|
||||
<div :class="[toolbarShellClass, 'cursor-pointer']">
|
||||
<div
|
||||
:class="[toolbarPanelClass, 'flex items-center gap-1 px-2 py-1']"
|
||||
>
|
||||
<ImportOrderIcon class="h-4 w-4 shrink-0" />
|
||||
<span
|
||||
class="whitespace-nowrap text-xs font-bold text-slate-700 dark:text-slate-300"
|
||||
>
|
||||
导入
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</Dropdown>
|
||||
|
||||
<Popover
|
||||
trigger="click"
|
||||
:open="openPopover === 'taxRate'"
|
||||
|
||||
@@ -18,11 +18,7 @@ const ChartIcon = createIconifyIcon('solar:chart-2-linear');
|
||||
const DownloadIcon = createIconifyIcon('solar:file-download-linear');
|
||||
|
||||
const goWorkbench = () => {
|
||||
router.push('/dashboard/workbench');
|
||||
};
|
||||
|
||||
const goImportTask = () => {
|
||||
router.push('/import/order');
|
||||
router.push({ name: 'Workbench' });
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -77,9 +73,6 @@ const goImportTask = () => {
|
||||
|
||||
<div class="btn-group">
|
||||
<button class="btn-primary" @click="goWorkbench">工作台</button>
|
||||
<button class="btn-secondary" type="button" @click="goImportTask">
|
||||
导入订单
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -294,15 +287,11 @@ const goImportTask = () => {
|
||||
margin-top: clamp(20px, 3vw, 30px);
|
||||
}
|
||||
|
||||
.btn-primary,
|
||||
.btn-secondary {
|
||||
.btn-primary {
|
||||
border-radius: 8px;
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
padding: 12px 30px;
|
||||
border: none;
|
||||
color: #fff;
|
||||
@@ -319,13 +308,6 @@ const goImportTask = () => {
|
||||
box-shadow: 0 10px 24px rgb(37 99 235 / 30%);
|
||||
}
|
||||
|
||||
.btn-secondary {
|
||||
padding: 12px 25px;
|
||||
border: 1px solid var(--border-color);
|
||||
color: var(--text-dark);
|
||||
background: var(--surface-strong);
|
||||
}
|
||||
|
||||
.flowchart-wrap {
|
||||
flex: 1 1 480px;
|
||||
min-width: 0;
|
||||
@@ -575,8 +557,7 @@ const goImportTask = () => {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.btn-primary,
|
||||
.btn-secondary {
|
||||
.btn-primary {
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ interface FormData {
|
||||
parentId: number | null;
|
||||
superMenu: boolean;
|
||||
name: string;
|
||||
routeName: string;
|
||||
title: string;
|
||||
path: string;
|
||||
component: string;
|
||||
@@ -84,6 +85,7 @@ const formData = ref<FormData>({
|
||||
parentId: null,
|
||||
superMenu: false,
|
||||
name: '',
|
||||
routeName: '',
|
||||
title: '',
|
||||
path: '',
|
||||
component: '',
|
||||
@@ -346,6 +348,7 @@ function open(edit: boolean, record?: MenuVO.MenuInfo) {
|
||||
parentId: record.parentId || null,
|
||||
superMenu: record.superMenu === 1, // 转换为boolean
|
||||
name: record.name,
|
||||
routeName: record.routeName || '',
|
||||
title: record.title || '',
|
||||
path: record.path || '',
|
||||
component: record.component || '',
|
||||
@@ -375,6 +378,7 @@ function open(edit: boolean, record?: MenuVO.MenuInfo) {
|
||||
parentId: record.id, // 自动设置为当前菜单的ID作为父菜单
|
||||
superMenu: false,
|
||||
name: '',
|
||||
routeName: '',
|
||||
title: '',
|
||||
path: '',
|
||||
component: '',
|
||||
@@ -393,6 +397,7 @@ function open(edit: boolean, record?: MenuVO.MenuInfo) {
|
||||
parentId: null,
|
||||
superMenu: false,
|
||||
name: '',
|
||||
routeName: '',
|
||||
title: '',
|
||||
path: '',
|
||||
component: '',
|
||||
@@ -484,6 +489,7 @@ async function handleSubmit() {
|
||||
const submitData = {
|
||||
...formData.value,
|
||||
parentId: formData.value.parentId ?? null,
|
||||
routeName: formData.value.routeName?.trim() || null,
|
||||
icon: formData.value.icon?.trim() || null,
|
||||
iconSvg: formData.value.iconSvg?.trim() || null,
|
||||
superMenu: formData.value.superMenu ? 1 : 0,
|
||||
@@ -612,6 +618,22 @@ defineExpose({
|
||||
<Input v-model:value="formData.name" placeholder="请输入菜单名称" />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="路由名称"
|
||||
name="routeName"
|
||||
:rules="[
|
||||
{
|
||||
pattern: /^[A-Za-z][A-Za-z0-9_]*$/,
|
||||
message: '须以字母开头,仅字母/数字/下划线',
|
||||
},
|
||||
]"
|
||||
>
|
||||
<Input
|
||||
v-model:value="formData.routeName"
|
||||
placeholder="Vue Router name,如 ShopList(可空,空则用菜单名称)"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="菜单标题" name="title">
|
||||
<Input v-model:value="formData.title" placeholder="请输入菜单标题" />
|
||||
</Form.Item>
|
||||
|
||||
@@ -67,6 +67,12 @@ const gridOptions: VxeGridProps<any> = {
|
||||
dragSort: true, // 启用拖拽排序
|
||||
// 移除自定义插槽,让拖拽控件正常显示
|
||||
},
|
||||
{
|
||||
field: 'routeName',
|
||||
title: '路由名称',
|
||||
minWidth: 140,
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'title',
|
||||
title: '菜单标题',
|
||||
|
||||
Reference in New Issue
Block a user