'use strict'; /** * 新增售后模块权限记录(固定 ID 策略,确保开发/生产一致)。 * * 新增权限明细: * Block(角色组维度): * 516 — 售后-客服组 * 517 — 售后-仓库组 * 518 — 售后-财务组 * * Web Pages(菜单/页面): * 519 — afterSale 售后管理(根菜单) * 520 — afterSale.list 售后列表 * 521 — afterSale.detail 售后明细 * * API: * 522 — afterSale.workList API:售后工作列表查询 * 523 — afterSale.auditList API:售后审计列表查询 * 508 — afterSale.detail API:售后明细查询 * 509 — afterSale.create API:创建售后单 * 510 — afterSale.update API:更新售后单 * 511 — afterSale.transfer API:售后转单 * 512 — afterSale.handleWorkOrder API:处理工单 * 513 — afterSale.registerClaim API:登记理赔 * 514 — afterSale.export API:售后导出 * 515 — afterSale.exportTaskProgress API:导出进度查询 * * 幂等设计:使用 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) { // ── 1. Block 权限(角色组维度,用于权限分配分组)── const blocks = [ [516, null, null, '售后-客服组', null, '售后-客服组', null, 0, 0, null, 'block', 0, 1], [517, null, null, '售后-仓库组', null, '售后-仓库组', null, 0, 0, null, 'block', 0, 1], [518, null, null, '售后-财务组', null, '售后-财务组', null, 0, 0, null, 'block', 0, 1], ]; for (const [id, path, component, name, redirect, meta_title, meta_icon, hidden, always_show, parent_id, type, sort, status] of blocks) { 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] } ); } // ── 2. Web Pages 权限(菜单/页面)── const pages = [ [519, 'afterSale', null, 'afterSale', null, '售后管理', null, 0, 0, null, 'web_pages', 14, 1], [520, 'afterSale.list', null, 'afterSale.list', null, '售后列表', null, 0, 0, 519, 'web_pages', 0, 1], [521, 'afterSale.detail', null, 'afterSale.detail', null, '售后明细', null, 0, 0, 519, 'web_pages', 1, 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] } ); } // ── 3. API 权限 ── const apis = [ [522, 'afterSale.workList', 'API:售后工作列表查询'], [523, 'afterSale.auditList', 'API:售后审计列表查询'], [508, 'afterSale.detail', 'API:售后明细查询'], [509, 'afterSale.create', 'API:创建售后单'], [510, 'afterSale.update', 'API:更新售后单'], [511, 'afterSale.transfer', 'API:售后转单'], [512, 'afterSale.handleWorkOrder', 'API:处理工单'], [513, 'afterSale.registerClaim', 'API:登记理赔'], [514, 'afterSale.export', 'API:售后导出'], [515, 'afterSale.exportTaskProgress', 'API:导出进度查询'], ]; for (const [id, path, meta_title] of apis) { await queryInterface.sequelize.query( `INSERT IGNORE INTO \`${TABLE}\` (${COLUMNS}) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW(), NOW())`, { replacements: [id, path, null, path, null, meta_title, null, 0, 0, null, 'api', 0, 1] } ); } }, // eslint-disable-next-line no-unused-vars async down(queryInterface, Sequelize) { const ids = [516, 517, 518, 519, 520, 521, 522, 523, 508, 509, 510, 511, 512, 513, 514, 515]; const placeholders = ids.map(() => '?').join(', '); await queryInterface.sequelize.query( `DELETE FROM \`${TABLE}\` WHERE id IN (${placeholders})`, { replacements: ids } ); }, };