ADD: Warehouse inventory management dashboard
- Add WarehouseItemService.js — API client for all warehouse item endpoints (items CRUD, transactions, stock queries) - Add WarehouseService.js — API client for warehouse location management - Add ListWarehouseItems.vue — item catalogue table with inline create/edit dialog and bilingual unit picker - Add WarehouseItemStockView.vue — per-item stock dashboard showing total + per-warehouse breakdown, IN/OUT transaction dialog with reason presets, inline transaction history with delete - Add ListWarehouseItemTransactions.vue — full transaction history with filter panel (item, warehouse, type, date range) - Add ListWarehouses.vue — warehouse location management with create/edit dialogs - Update AppMenu.vue — add 'مدیریت انبار' menu group with 3 items - Update router/index.js — register 4 new warehouse management routes
This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
import axios from 'axios';
|
||||
|
||||
const getAuthHeader = () => {
|
||||
const bmToken = document.cookie
|
||||
.split('; ')
|
||||
.find((row) => row.startsWith('bm-token='))
|
||||
?.split('=')[1];
|
||||
return { Authorization: `Bearer ${bmToken}` };
|
||||
};
|
||||
|
||||
export const WarehouseItemService = {
|
||||
// ─── Items ────────────────────────────────────────────────────────────────
|
||||
listItems: async (params = {}) => {
|
||||
const response = await axios.get('/api/warehouse-items/admin/items', {
|
||||
params,
|
||||
withCredentials: true,
|
||||
headers: getAuthHeader()
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
createItem: async (data) => {
|
||||
const response = await axios.post('/api/warehouse-items/admin/items', data, {
|
||||
withCredentials: true,
|
||||
headers: getAuthHeader()
|
||||
});
|
||||
return response.data.data;
|
||||
},
|
||||
|
||||
getItem: async (itemId) => {
|
||||
const response = await axios.get(`/api/warehouse-items/admin/items/${itemId}`, {
|
||||
withCredentials: true,
|
||||
headers: getAuthHeader()
|
||||
});
|
||||
return response.data.data;
|
||||
},
|
||||
|
||||
updateItem: async (itemId, data) => {
|
||||
const response = await axios.patch(`/api/warehouse-items/admin/items/${itemId}`, data, {
|
||||
withCredentials: true,
|
||||
headers: getAuthHeader()
|
||||
});
|
||||
return response.data.data;
|
||||
},
|
||||
|
||||
deleteItem: async (itemId) => {
|
||||
await axios.delete(`/api/warehouse-items/admin/items/${itemId}`, {
|
||||
withCredentials: true,
|
||||
headers: getAuthHeader()
|
||||
});
|
||||
},
|
||||
|
||||
// ─── Transactions ─────────────────────────────────────────────────────────
|
||||
listTransactions: async (params = {}) => {
|
||||
const response = await axios.get('/api/warehouse-items/admin/transactions', {
|
||||
params,
|
||||
withCredentials: true,
|
||||
headers: getAuthHeader()
|
||||
});
|
||||
return response.data;
|
||||
},
|
||||
|
||||
createTransaction: async (data) => {
|
||||
const response = await axios.post('/api/warehouse-items/admin/transactions', data, {
|
||||
withCredentials: true,
|
||||
headers: getAuthHeader()
|
||||
});
|
||||
return response.data.data;
|
||||
},
|
||||
|
||||
deleteTransaction: async (transactionId) => {
|
||||
await axios.delete(`/api/warehouse-items/admin/transactions/${transactionId}`, {
|
||||
withCredentials: true,
|
||||
headers: getAuthHeader()
|
||||
});
|
||||
},
|
||||
|
||||
// ─── Stock ────────────────────────────────────────────────────────────────
|
||||
getTotalStock: async () => {
|
||||
const response = await axios.get('/api/warehouse-items/admin/stock/total', {
|
||||
withCredentials: true,
|
||||
headers: getAuthHeader()
|
||||
});
|
||||
return response.data.data;
|
||||
},
|
||||
|
||||
getStockByItem: async (itemId) => {
|
||||
const response = await axios.get(`/api/warehouse-items/admin/stock/by-item/${itemId}`, {
|
||||
withCredentials: true,
|
||||
headers: getAuthHeader()
|
||||
});
|
||||
return response.data.data;
|
||||
},
|
||||
|
||||
getStockByWarehouse: async (warehouseId) => {
|
||||
const response = await axios.get(`/api/warehouse-items/admin/stock/by-warehouse/${warehouseId}`, {
|
||||
withCredentials: true,
|
||||
headers: getAuthHeader()
|
||||
});
|
||||
return response.data.data;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user