'use strict'; /** * 补回「发货单」菜单(挂在「订单管理」下)。 * * 背景:订单管理下原本只有「订单」一个列表菜单,2026-09-15 把「订单」菜单改指向订单(状态分表)页面后, * 发货单列表页(views/Order/Index.vue,读写 /api/order-deliveries)失去了菜单入口 → 发货单在界面上不可见。 * 本迁移为它补一个独立菜单项,路径 /order-delivery,与「创建发货单」(/order-create) 成对。 * * 幂等:按 name + path 定位,已存在则跳过。 */ const MENU = { name: '发货单', path: '/order-delivery', type: 2, icon: 'Van', permission: 'orderDelivery:list', component: 'views/Order/Index.vue', sort: 75, }; module.exports = { async up(queryInterface) { const sequelize = queryInterface.sequelize; const [ orderMgmt ] = await sequelize.query( "SELECT id FROM menus WHERE name = '订单管理' AND parent_id = 0 LIMIT 1", { type: sequelize.QueryTypes.SELECT }, ); if (!orderMgmt) return; // 订单管理节点不存在则跳过 const [ exist ] = await sequelize.query( 'SELECT id FROM menus WHERE name = ? AND path = ? LIMIT 1', { replacements: [ MENU.name, MENU.path ], type: sequelize.QueryTypes.SELECT }, ); if (exist) return; await sequelize.query( `INSERT INTO menus (parent_id, name, type, path, icon, permission, component, sort, status, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1, NOW(), NOW())`, { replacements: [ Number(orderMgmt.id), MENU.name, MENU.type, MENU.path, MENU.icon, MENU.permission, MENU.component, MENU.sort, ], }, ); }, async down(queryInterface) { await queryInterface.sequelize.query( 'DELETE FROM menus WHERE name = ? AND path = ?', { replacements: [ MENU.name, MENU.path ] }, ); }, };