WMS_MAIN/database/migrations/20260809130200-add-after-sale-permissions.js
liufumingren 296536c83e feat: 售后模块V2全面落地
数据库:

- 创建 wms_after_sale 主表 (36字段/16索引)

- 创建 wms_after_sale_detail 步骤表 (11字段/3索引)

- 插入售后权限 16条 (ID 508-523)

- 绑定6个角色权限 (客服/仓库/生产主管/拣货组长)

代码:

- Model: after_sale.js + after_sale_detail.js (含常量枚举)

- Service: systemMethods/afterSale.js + systems/afterSale.js (19方法)

文档:

- API定义: methods/system.json (+9 methods)

- 设计文档: database/designs/after-sale-v2-design.md

- 开发/生产环境均已执行迁移,权限ID完全一致
2026-08-09 21:17:34 +08:00

98 lines
4.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'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 }
);
},
};