add product

This commit is contained in:
Timi
2026-09-03 14:27:40 +08:00
parent 7f669621fb
commit 333999fe21
63 changed files with 5662 additions and 2210 deletions
+106
View File
@@ -0,0 +1,106 @@
import { axios } from "timi-web-api";
import type { Product, ProductCategory, ProductCategoryPage, ProductPage, ProductPageResult, ProductStock, ProductStockChangeRequest, ProductStockPage, StockRecord, StockRecordPage } from "@/types/Product";
import { getCurrentStoreId, withCurrentStoreId } from "@/utils/store";
const PRODUCT_URI = "/gao/product";
const STOCK_URI = "/gao/product/stock";
async function categoryList(page: ProductCategoryPage): Promise<ProductPageResult<ProductCategory>> {
return await axios.post(`${PRODUCT_URI}/category/list`, withCurrentStoreId(page));
}
async function categoryCreate(category: ProductCategory): Promise<string> {
return await axios.post(`${PRODUCT_URI}/category/create`, withCurrentStoreId(category));
}
async function categoryUpdate(category: ProductCategory): Promise<void> {
await axios.post(`${PRODUCT_URI}/category/update`, withCurrentStoreId(category));
}
async function categorySort(idList: string[]): Promise<void> {
return await axios.post(`${PRODUCT_URI}/category/sort`, idList);
}
async function categoryDisable(id: string): Promise<void> {
await axios.post(`${PRODUCT_URI}/category/disable`, undefined, { params: { id } });
}
async function list(page: ProductPage): Promise<ProductPageResult<Product>> {
return await axios.post(`${PRODUCT_URI}/list`, withCurrentStoreId(page));
}
async function detail(id: string): Promise<Product> {
return await axios.post(`${PRODUCT_URI}/detail`, undefined, { params: { id } });
}
async function create(product: Product): Promise<string> {
return await axios.post(`${PRODUCT_URI}/create`, withCurrentStoreId(product));
}
async function update(product: Product): Promise<void> {
await axios.post(`${PRODUCT_URI}/update`, withCurrentStoreId(product));
}
async function disable(id: string): Promise<void> {
await axios.post(`${PRODUCT_URI}/disable`, undefined, { params: { id } });
}
async function sellableList(page: ProductPage): Promise<Product[]> {
return await axios.post(`${PRODUCT_URI}/sellable/list`, withCurrentStoreId(page));
}
async function stockList(page: ProductStockPage): Promise<ProductPageResult<ProductStock>> {
return await axios.post(`${STOCK_URI}/list`, withCurrentStoreId(page));
}
async function stockDetail(productId: string, storeId?: string): Promise<ProductStock> {
return await axios.post(`${STOCK_URI}/detail`, undefined, {
params: { productId, storeId: storeId || getCurrentStoreId() }
});
}
async function initialIn(request: ProductStockChangeRequest): Promise<ProductStock> {
return await axios.post(`${STOCK_URI}/initial-in`, withCurrentStoreId(request));
}
async function manualIn(request: ProductStockChangeRequest): Promise<ProductStock> {
return await axios.post(`${STOCK_URI}/manual-in`, withCurrentStoreId(request));
}
async function manualOut(request: ProductStockChangeRequest): Promise<ProductStock> {
return await axios.post(`${STOCK_URI}/manual-out`, withCurrentStoreId(request));
}
async function stocktakeGain(request: ProductStockChangeRequest): Promise<ProductStock> {
return await axios.post(`${STOCK_URI}/stocktake-gain`, withCurrentStoreId(request));
}
async function stocktakeLoss(request: ProductStockChangeRequest): Promise<ProductStock> {
return await axios.post(`${STOCK_URI}/stocktake-loss`, withCurrentStoreId(request));
}
async function recordList(page: StockRecordPage): Promise<ProductPageResult<StockRecord>> {
return await axios.post(`${STOCK_URI}/record/list`, withCurrentStoreId(page));
}
export default {
categoryList,
categoryCreate,
categoryUpdate,
categorySort,
categoryDisable,
list,
detail,
create,
update,
disable,
sellableList,
stockList,
stockDetail,
initialIn,
manualIn,
manualOut,
stocktakeGain,
stocktakeLoss,
recordList
};