- product_categories / product_brands / product_units 新增 subsidiary_id(NULL 表示主体级、全集团共用) - 列表与下拉按货主范围过滤:货主权限仅可见「主体级 + 自己所属公司」,并支持按货主筛选 - 新增/编辑支持选择货主,货主权限只能选主体或自己所属公司;同货主范围内名称唯一 - 详情/更新/删除对越权属性返回 403;导出新增货主列并收窄到可见范围 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
34 lines
1.2 KiB
JavaScript
34 lines
1.2 KiB
JavaScript
'use strict';
|
||
|
||
/**
|
||
* 商品属性(分类 / 品牌 / 单位)关联下属公司:三张表各增加 subsidiary_id。
|
||
*
|
||
* NULL 表示主体级(全集团共用);填写则为某个下属公司(货主)私有。
|
||
* 所在公司权限只能新增/维护「主体级」与「自己所属公司」的属性,列表也仅可见这两类。
|
||
*/
|
||
const TABLES = [ 'product_categories', 'product_brands', 'product_units' ];
|
||
|
||
module.exports = {
|
||
async up(queryInterface, Sequelize) {
|
||
for (const table of TABLES) {
|
||
await queryInterface.addColumn(table, 'subsidiary_id', {
|
||
type: Sequelize.BIGINT.UNSIGNED,
|
||
allowNull: true,
|
||
comment: '所属货主(下属公司ID);NULL 表示主体级(全集团共用)',
|
||
references: { model: 'principal_subsidiaries', key: 'id' },
|
||
after: 'principal_id',
|
||
});
|
||
await queryInterface.addIndex(table, [ 'principal_id', 'subsidiary_id' ], {
|
||
name: `idx_${table}_principal_subsidiary`,
|
||
});
|
||
}
|
||
},
|
||
|
||
async down(queryInterface) {
|
||
for (const table of TABLES) {
|
||
await queryInterface.removeIndex(table, `idx_${table}_principal_subsidiary`);
|
||
await queryInterface.removeColumn(table, 'subsidiary_id');
|
||
}
|
||
},
|
||
};
|