| | | 1 | | @using OzonOrdersWeb.Areas.Studio2.ViewModels.Grid |
| | | 2 | | @model IEnumerable<OzonDomains.Models.OrderCarts.ItemStatus> |
| | | 3 | | @{ |
| | 0 | 4 | | ViewData["Title"] = "Статусы товаров с цветами"; |
| | 0 | 5 | | Layout = "~/Views/Shared/_Layout.cshtml"; |
| | 0 | 6 | | var highlightId = ViewBag.HighlightId as int?; |
| | 0 | 7 | | var statuses = Model.ToList(); |
| | 0 | 8 | | var rows = statuses.Select(s => |
| | 0 | 9 | | { |
| | 0 | 10 | | var orderIds = s.OrderItems.Select(x => x.StudioOrderId).ToArray(); |
| | 0 | 11 | | return new |
| | 0 | 12 | | { |
| | 0 | 13 | | id = s.Id, |
| | 0 | 14 | | name = s.Name, |
| | 0 | 15 | | ordersCount = orderIds.Length, |
| | 0 | 16 | | ordersUrl = orderIds.Length > 0 ? Url.Action("ViewOrders", "Orders", new { area = "Studio2", ids = orderIds |
| | 0 | 17 | | color = s.StatusColor?.ColorCode |
| | 0 | 18 | | }; |
| | 0 | 19 | | }); |
| | | 20 | | } |
| | | 21 | | |
| | 0 | 22 | | @await Html.PartialAsync("_BsxGridShell") |
| | | 23 | | |
| | | 24 | | <div class="container-fluid py-3 bsx-surface"> |
| | | 25 | | <div class="app-section-hero app-section-hero--import d-flex flex-wrap justify-content-between align-items-start gap |
| | | 26 | | <div> |
| | | 27 | | <h1><i class="fas fa-palette me-2 text-primary"></i>Статусы товаров</h1> |
| | | 28 | | <div class="subtitle">Статусы позиций корзины заказа и их цвета</div> |
| | | 29 | | <div class="app-section-hero__quick-links"> |
| | | 30 | | <a asp-area="Studio2" asp-controller="AppStatus" asp-action="Index"><i class="fas fa-tags"></i>Статусы з |
| | | 31 | | <a asp-area="Studio2" asp-controller="SupplierStatus" asp-action="Index"><i class="fas fa-dolly"></i>Ста |
| | | 32 | | </div> |
| | | 33 | | </div> |
| | | 34 | | <div class="bsx-dir-stats"> |
| | 0 | 35 | | <span class="bsx-dir-stat">Всего <b>@statuses.Count</b></span> |
| | 0 | 36 | | <span class="bsx-dir-stat">В заказах <b>@statuses.Count(s => s.OrderItems.Any())</b></span> |
| | | 37 | | </div> |
| | | 38 | | </div> |
| | | 39 | | |
| | 0 | 40 | | @await Html.PartialAsync("_BsxDirectoryGrid", new BsxDirectoryGridViewModel("cartStatus", "Статусы товаров", "fa-pal |
| | 0 | 41 | | "Цвет сохраняется сразу. Количество заказов — ссылка на список этих заказов.")) |
| | | 42 | | </div> |
| | | 43 | | |
| | | 44 | | @section Scripts { |
| | | 45 | | <script src="~/js/Studio2/Grid/bsx-directory.js" asp-append-version="true"></script> |
| | | 46 | | <script> |
| | | 47 | | (function () { |
| | | 48 | | const D = window.BsxDirectory; |
| | 0 | 49 | | const highlightId = @Json.Serialize(highlightId); |
| | | 50 | | |
| | | 51 | | D.grid({ |
| | | 52 | | key: 'dirCartStatus', |
| | | 53 | | prefix: 'cartStatus', |
| | 0 | 54 | | rows: @Json.Serialize(rows), |
| | | 55 | | rowClassRules: { 'bsx-row-current': p => p.data && p.data.id === highlightId }, |
| | | 56 | | onReady: api => { |
| | | 57 | | if (highlightId == null) return; |
| | | 58 | | const node = api.getRowNode(String(highlightId)); |
| | | 59 | | if (node) { api.ensureNodeVisible(node, 'middle'); api.flashCells({ rowNodes: [node] }); } |
| | | 60 | | }, |
| | | 61 | | columnDefs: [ |
| | | 62 | | D.numCol({ field: 'id', headerName: 'ID', width: 90 }), |
| | | 63 | | { field: 'name', headerName: 'Название статуса', flex: 1, minWidth: 240, sort: 'asc', |
| | | 64 | | cellRenderer: p => D.colorPill(p.value, p.data.color) }, |
| | | 65 | | D.numCol({ field: 'ordersCount', headerName: 'Заказов', width: 130, |
| | | 66 | | cellRenderer: p => p.data.ordersUrl |
| | | 67 | | ? `<a href="${BsxGrid.esc(p.data.ordersUrl)}" target="_blank" rel="noopener" title="Заказы с этим |
| | | 68 | | : `<span class="bsx-muted">0</span>` }), |
| | | 69 | | D.colorCol({ |
| | 0 | 70 | | updateUrl: '@Url.Action("UpdateStatusColor", "OrderCartItemStatus", new { area = "Studio2" })', |
| | 0 | 71 | | resetUrl: '@Url.Action("ResetStatusColor", "OrderCartItemStatus", new { area = "Studio2" })', |
| | | 72 | | confirmReset: 'Сбросить цвет статуса?' |
| | | 73 | | }) |
| | | 74 | | ] |
| | | 75 | | }); |
| | | 76 | | })(); |
| | | 77 | | </script> |
| | | 78 | | } |