Files
shanxia2.0/web-admin/src/api/crm/product.ts
T
2026-06-01 08:21:21 +08:00

91 lines
2.5 KiB
TypeScript

import request from '@/utils/http'
// ── 产品分类 ──
/** 产品分类树(不分页) */
export function fetchCategoryTree(data?: Record<string, any>) {
return request.post({ url: '/web/crm/product-categories/tree', data })
}
/** 新增分类 */
export function fetchCreateCategory(data: Record<string, any>) {
return request.post({ url: '/web/crm/product-categories/add', data })
}
/** 更新分类 */
export function fetchUpdateCategory(data: Record<string, any>) {
return request.post({ url: '/web/crm/product-categories/update', data })
}
/** 删除分类 */
export function fetchDeleteCategory(data: { id: string }) {
return request.post({ url: '/web/crm/product-categories/delete', data })
}
// ── 产品管理 ──
/** 产品分页列表 */
export function fetchProductList(data: Record<string, any>) {
return request.post({ url: '/web/crm/products/list', data })
}
/** 产品详情 */
export function fetchProductDetail(data: { id: string }) {
return request.post({ url: '/web/crm/products/detail', data })
}
/** 新增产品 */
export function fetchCreateProduct(data: Record<string, any>) {
return request.post({ url: '/web/crm/products/add', data })
}
/** 更新产品 */
export function fetchUpdateProduct(data: Record<string, any>) {
return request.post({ url: '/web/crm/products/update', data })
}
/** 删除产品(单条或批量) */
export function fetchDeleteProduct(data: { id?: string; ids?: string[] }) {
return request.post({ url: '/web/crm/products/delete', data })
}
/** 产品下拉选项(不分页) */
export function fetchProductOptions(data?: Record<string, any>) {
return request.post({ url: '/web/crm/products/options', data })
}
/** 批量上下架 */
export function fetchUpdateProductStatus(data: { ids: string[]; status: string }) {
return request.post({ url: '/web/crm/products/update-status', data })
}
// ── Excel 导入导出 ──
/** Excel 导入产品 */
export function fetchImportProducts(file: File) {
const formData = new FormData()
formData.append('file', file)
return request.post({
url: '/web/crm/products/import',
data: formData,
headers: { 'Content-Type': 'multipart/form-data' },
})
}
/** Excel 导出产品 */
export function fetchExportProducts(data: Record<string, any>) {
return request.post({
url: '/web/crm/products/export',
data,
responseType: 'blob',
})
}
/** 下载导入模板 */
export function fetchImportTemplate() {
return request.post({
url: '/web/crm/products/import-template',
responseType: 'blob',
})
}