This commit is contained in:
Николай 2023-05-16 17:57:43 +04:00
parent 0f35bf9e19
commit 10271ea4bd
4 changed files with 2425 additions and 1 deletions

View File

@ -16,7 +16,7 @@
<div class="text-center">
<h2 class="display-4">Покупки</h2>
<p>
<a asp-controller="Home" asp-action="CreatePurchase" class="btn btn-primary btn-lg mb-5">Добавить</a>
<a asp-controller="Home" asp-action="CreatePurchase" class="btn btn-primary mx-2">Добавить</a>
<button type="button" class="btn btn-primary mx-2" id="delete">Удалить заказ</button>
<button type="button" class="btn btn-primary mx-2" id="inwork">Выполняется</button>
<button type="button" class="btn btn-primary mx-2" id="ready">Готов</button>
@ -77,3 +77,85 @@
</div>
}
</div>
@section Styles
{
<style>
tr {
cursor: pointer;
}
.selected {
background-color: #0d6efd;
color: white;
}
</style>
}
@section Scripts
{
<script>
// get selected row
// display selected row data in text input
var table = document.getElementById("table");
var remove = document.getElementById("delete");
var inwork = document.getElementById("inwork");
var ready = document.getElementById("ready");
var done = document.getElementById("done");
var order = 0;
for (var i = 1; i < table.rows.length; i++) {
table.rows[i].onclick = function () {
// remove the background from the previous selected row
if (typeof index !== "undefined") {
table.rows[index].classList.toggle("selected");
}
// get the selected row index
index = this.rowIndex;
// add class selected to the row
this.classList.toggle("selected");
order = parseInt(this.cells[0].innerText);
remove.addEventListener("click", () => {
console.log('try to delete order')
$.ajax(
{
url: `/Storekeeper/DeleteOrder`,
type: 'POST',
data: { id: order }
}
)
})
inwork.addEventListener("click", () => {
console.log('try to delete order')
$.ajax(
{
url: `/Storekeeper/UpdateOrder`,
type: 'POST',
data: { id: order, status: 1 }
}
)
})
ready.addEventListener("click", () => {
console.log('try to delete order')
$.ajax(
{
url: `/Storekeeper/UpdateOrder`,
type: 'POST',
data: { id: order, status: 2 }
}
)
})
done.addEventListener("click", () => {
console.log('try to delete order')
$.ajax(
{
url: `/Storekeeper/UpdateOrder`,
type: 'POST',
data: { id: order, status: 3 }
}
)
})
};
}
</script>
}

View File

@ -7,6 +7,7 @@
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
<link rel="stylesheet" href="~/HardwareShopWorkerApp.styles.css" asp-append-version="true" />
<link rel="stylesheet" href="~/lib/font-awesome-4.7.0/css/font-awesome.min.css">
</head>
<body>
<header>

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long