Получение со склада через карточку инструмента
This commit is contained in:
Binary file not shown.
Binary file not shown.
+10
-3
@@ -49,14 +49,20 @@ async def post_requests(
|
||||
action = request_data.get("body").get("action").get("operation")
|
||||
logger.info(f"Получение запроса на перемещение ({action}) инструмента")
|
||||
userId = request_data.get("body").get("userData").get("id")
|
||||
sourceTollboxId = (
|
||||
sourceTollboxId = int(
|
||||
request_data.get("body").get("action").get("selectedItem").get("toolboxId")
|
||||
)
|
||||
toolkitId = request_data.get("body").get("action").get("selectedItem").get("id")
|
||||
toolkitId = int(
|
||||
request_data.get("body").get("action").get("selectedItem").get("id")
|
||||
)
|
||||
quantity = request_data.get("body").get("action").get("quantity")
|
||||
price = round(
|
||||
float(
|
||||
request_data.get("body").get("action").get("selectedItem").get("totalCost")
|
||||
/ request_data.get("body").get("action").get("selectedItem").get("available"),
|
||||
)
|
||||
/ int(
|
||||
request_data.get("body").get("action").get("selectedItem").get("available")
|
||||
),
|
||||
2,
|
||||
)
|
||||
reason = request_data.get("body").get("action").get("comment")
|
||||
@@ -78,6 +84,7 @@ async def post_requests(
|
||||
if result:
|
||||
resonse["status"] = "ok"
|
||||
case "get":
|
||||
logger.info(f"Получение инструмента {toolkitId} из ящика {sourceTollboxId}")
|
||||
targetTollboxId = await ToolboxHandler.getIdByOwner(userId)
|
||||
result = await StocksActions.takeToolkit(
|
||||
sourceTollboxId,
|
||||
|
||||
@@ -28,6 +28,7 @@ async def toolkit_request(
|
||||
if not toolboxes:
|
||||
return response
|
||||
toolboxesTitles = {toolbox["id"]: toolbox["title"] for toolbox in toolboxes}
|
||||
toolboxesOwners = {toolbox["id"]: toolbox["owner_id"] for toolbox in toolboxes}
|
||||
stocksData = {"count": 0, "toolboxes": {}}
|
||||
for stock in stocks:
|
||||
toolboxTitle = toolboxesTitles.get(stock["toolbox_id"], None)
|
||||
@@ -39,8 +40,18 @@ async def toolkit_request(
|
||||
"count": stock["quantity"],
|
||||
"placement": stock["placement"],
|
||||
}
|
||||
logger.info(stock.keys())
|
||||
if not toolboxesOwners.get(stock["toolbox_id"]):
|
||||
stocksData["toolboxes"][toolboxTitle]["id"] = stock["toolbox_id"]
|
||||
stocksData["toolboxes"][toolboxTitle]["totalCost"] = (
|
||||
stock["price"] * stock["quantity"]
|
||||
)
|
||||
else:
|
||||
stocksData["toolboxes"][toolboxTitle]["count"] += stock["quantity"]
|
||||
if not toolboxesOwners.get(stock["toolbox_id"]):
|
||||
stocksData["toolboxes"][toolboxTitle]["totalCost"] += (
|
||||
stock["price"] * stock["quantity"]
|
||||
)
|
||||
response["status"] = "ok"
|
||||
response["data"] = stocksData
|
||||
return response
|
||||
|
||||
+29
-1
@@ -1732,7 +1732,15 @@ async function showToolkitDetailsModal(item) {
|
||||
${Object.entries(toolkitStocks.toolboxes).map(([key, value]) => `
|
||||
<tr>
|
||||
<td style="width: 60%"><strong>${key}:</strong></td>
|
||||
<td>${value.count} шт.</td>
|
||||
<td>${value.count} шт.${value.id && accessData.available_own_toolbox ? `
|
||||
<button class="btn btn-sm btn-outline-success" data-action="get"
|
||||
data-toolbox_id="${value.id}" data-id="${item.id}"
|
||||
data-available="${value.count}" data-totalcost="${value.totalCost}"
|
||||
title="Получить">
|
||||
<i class="bi bi-box-arrow-in-down"></i>
|
||||
</button>
|
||||
` : ''}
|
||||
</td>
|
||||
<td class="fw-bold">${value.placement || ''}</td>
|
||||
</tr>
|
||||
`).join('')}
|
||||
@@ -1754,6 +1762,24 @@ async function showToolkitDetailsModal(item) {
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Добавляем обработчики для кнопок в строке
|
||||
modal.querySelectorAll('button[data-action]').forEach(button => {
|
||||
button.addEventListener('click', async (e) => {
|
||||
e.stopPropagation();
|
||||
const action = e.currentTarget.dataset.action;
|
||||
const id = e.currentTarget.dataset.id;
|
||||
const toolboxId = e.currentTarget.dataset.toolbox_id;
|
||||
const available = e.currentTarget.dataset.available;
|
||||
const totalQuantity = available;
|
||||
const title = item.title;
|
||||
const totalCost = e.currentTarget.dataset.totalcost;
|
||||
const skipRefresh = true;
|
||||
const selectedItem = { id, toolboxId, available, totalQuantity, title, totalCost, skipRefresh };
|
||||
await showOperationModal(action, selectedItem);
|
||||
modal.querySelector('button[data-bs-dismiss="modal"]').click();
|
||||
});
|
||||
});
|
||||
|
||||
document.body.appendChild(modal);
|
||||
|
||||
const bsModal = new bootstrap.Modal(modal);
|
||||
@@ -1874,7 +1900,9 @@ async function showOperationModal(operation, selectedItem) {
|
||||
if (success) {
|
||||
bsModal.hide();
|
||||
showInfo(`Запрос на ${operationTitles[operation]} успешно создан`, 'success');
|
||||
if (!selectedItem.skipRefresh) {
|
||||
await loadToolboxContent(selectedItem.toolboxId);
|
||||
}
|
||||
} else {
|
||||
showError('Ошибка выполнения операции');
|
||||
resetButton();
|
||||
|
||||
Reference in New Issue
Block a user