qiangdanxitong/frontend/src/api/thirdPartyDb.ts
Your Name 3056f44a6e feat: 第三方数据库配置 + 库存检查功能
1. 系统设置新增第三方数据库配置管理
   - 支持SQL Server/MySQL/PostgreSQL
   - 支持连接测试、启用/禁用

2. 任务子类型新增「检查库存」选项
   - 启用后发布任务需要输入商品条码
   - 自动查询聚水潭库存信息

3. 发起任务页面集成库存检查
   - 库存>1才允许发布任务
   - 库存不足提示先申请样品

库存查询配置:
- 数据表:jst_inventoryInfo
- 仓库条件:wms_co_id='14138566'
2026-01-05 14:58:12 +08:00

95 lines
2.0 KiB
TypeScript

import request from '@/utils/request'
export interface ThirdPartyDbConfig {
id?: number
name: string
dbType: string
host: string
port: number
database: string
username: string
password: string
enabled: number
connectionTimeout?: number
remark?: string
createTime?: string
updateTime?: string
}
export interface InventoryResult {
barcode: string
found: boolean
quantity: number
availableQty?: number
skuId?: string
itemId?: string
name?: string
lockQty?: number
canPublish?: boolean
message?: string
}
/**
* 获取所有第三方数据库配置
*/
export const getAllConfigs = () => {
return request.get<ThirdPartyDbConfig[]>('/third-party-db/configs')
}
/**
* 获取配置详情
*/
export const getConfigById = (id: number) => {
return request.get<ThirdPartyDbConfig>(`/third-party-db/configs/${id}`)
}
/**
* 获取启用的配置
*/
export const getEnabledConfig = () => {
return request.get<ThirdPartyDbConfig>('/third-party-db/configs/enabled')
}
/**
* 创建配置
*/
export const createConfig = (config: ThirdPartyDbConfig) => {
return request.post<ThirdPartyDbConfig>('/third-party-db/configs', config)
}
/**
* 更新配置
*/
export const updateConfig = (id: number, config: ThirdPartyDbConfig) => {
return request.put<ThirdPartyDbConfig>(`/third-party-db/configs/${id}`, config)
}
/**
* 删除配置
*/
export const deleteConfig = (id: number) => {
return request.delete<void>(`/third-party-db/configs/${id}`)
}
/**
* 测试数据库连接
*/
export const testConnection = (config: ThirdPartyDbConfig) => {
return request.post<boolean>('/third-party-db/configs/test', config)
}
/**
* 查询商品库存
*/
export const checkInventory = (barcode: string) => {
return request.get<InventoryResult>(`/third-party-db/inventory/${barcode}`)
}
/**
* 检查库存是否满足发布任务条件
*/
export const checkInventoryForTask = (barcode: string) => {
return request.get<InventoryResult>(`/third-party-db/inventory/check-for-task/${barcode}`)
}