'use strict'; /** * 新增售后模块页面权限(售后工单 + 工单列表)。 * * 新增: * Web Pages: * 524 — afterSale.workOrder 售后工单(根菜单) * 525 — afterSale.workOrder.list 工单列表(子页面,parent_id=524) * * 幂等设计:使用 INSERT IGNORE,已存在的 id 不会重复插入。 */ const TABLE = 'wms_permission'; const COLUMNS = 'id, path, component, name, redirect, meta_title, meta_icon, hidden, always_show, parent_id, type, sort, status, created_at, update_at'; module.exports = { // eslint-disable-next-line no-unused-vars async up(queryInterface, Sequelize) { const pages = [ [524, 'afterSale.workOrder', null, 'afterSale.workOrder', null, '售后工单', null, 0, 0, null, 'web_pages', 15, 1], [525, 'afterSale.workOrder.list', null, 'afterSale.workOrder.list', null, '工单列表', null, 0, 0, 524, 'web_pages', 0, 1], ]; for (const [id, path, component, name, redirect, meta_title, meta_icon, hidden, always_show, parent_id, type, sort, status] of pages) { await queryInterface.sequelize.query( `INSERT IGNORE INTO \`${TABLE}\` (${COLUMNS}) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), NOW())`, { replacements: [id, path, component, name, redirect, meta_title, meta_icon, hidden, always_show, parent_id, type, sort, status] } ); } }, // eslint-disable-next-line no-unused-vars async down(queryInterface, Sequelize) { const ids = [524, 525]; const placeholders = ids.map(() => '?').join(', '); await queryInterface.sequelize.query( `DELETE FROM \`${TABLE}\` WHERE id IN (${placeholders})`, { replacements: ids } ); }, };