- product_categories / product_brands / product_units 新增 subsidiary_id(NULL 表示主体级、全集团共用) - 列表与下拉按货主范围过滤:货主权限仅可见「主体级 + 自己所属公司」,并支持按货主筛选 - 新增/编辑支持选择货主,货主权限只能选主体或自己所属公司;同货主范围内名称唯一 - 详情/更新/删除对越权属性返回 403;导出新增货主列并收窄到可见范围 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
68 lines
2.0 KiB
TypeScript
68 lines
2.0 KiB
TypeScript
import { get, post, put, del } from '@/utils/request'
|
||
|
||
/** 商品品牌(按主体隔离) */
|
||
export interface ProductBrand {
|
||
id: number
|
||
principal_id: number
|
||
/** 所属货主(下属公司ID);null 表示主体级(全集团共用) */
|
||
subsidiary_id: number | null
|
||
/** 所属货主名称(列表/详情接口返回,主体级为空串) */
|
||
subsidiary_name?: string
|
||
/** 所属货主明细(列表/详情接口返回) */
|
||
subsidiary?: { id: number; name: string } | null
|
||
name: string
|
||
code: string | null
|
||
status: number
|
||
sort: number
|
||
remark: string | null
|
||
/** 是否系统默认:1系统数据(不可改/删,全部主体可见) 0自定义(按主体隔离) */
|
||
is_system?: number
|
||
/** 被商品使用次数(被引用时禁止删除) */
|
||
used_count?: number
|
||
created_at?: string
|
||
updated_at?: string
|
||
}
|
||
|
||
/** 下拉项(仅启用) */
|
||
export interface ProductAttributeOption {
|
||
id: number
|
||
name: string
|
||
code: string | null
|
||
/** 所属货主(下属公司ID);null 表示主体级 */
|
||
subsidiary_id?: number | null
|
||
}
|
||
|
||
export interface ProductBrandPayload {
|
||
/** 所属货主(下属公司ID);null/不传表示主体级 */
|
||
subsidiary_id?: number | null
|
||
name: string
|
||
code?: string | null
|
||
status?: number
|
||
sort?: number
|
||
remark?: string | null
|
||
}
|
||
|
||
export function getProductBrands(params?: object) {
|
||
return get<{ list: ProductBrand[]; total: number; page: number; pageSize: number }>(
|
||
'/product-brands',
|
||
params,
|
||
)
|
||
}
|
||
|
||
/** 下拉用:仅返回启用商品品牌(按 sort 升序) */
|
||
export function getProductBrandOptions() {
|
||
return get<ProductAttributeOption[]>('/product-brands/select')
|
||
}
|
||
|
||
export function createProductBrand(data: ProductBrandPayload) {
|
||
return post<{ id: number }>('/product-brands', data)
|
||
}
|
||
|
||
export function updateProductBrand(id: number, data: Partial<ProductBrandPayload>) {
|
||
return put<{ id: number }>(`/product-brands/${id}`, data)
|
||
}
|
||
|
||
export function deleteProductBrand(id: number) {
|
||
return del<{ id: number }>(`/product-brands/${id}`)
|
||
}
|