| | | 1 | | @using OzonOrdersWeb.Areas.Studio2.ViewModels.Grid |
| | | 2 | | @using OzonOrdersWeb.WebServices.Directories |
| | | 3 | | @model List<WarehouseGridRow> |
| | | 4 | | @{ |
| | 0 | 5 | | ViewData["Title"] = $"Склады ({Model.Count})"; |
| | 0 | 6 | | Layout = "~/Views/Shared/_Layout.cshtml"; |
| | 0 | 7 | | var jsonOptions = new System.Text.Json.JsonSerializerOptions(System.Text.Json.JsonSerializerDefaults.Web); |
| | | 8 | | } |
| | | 9 | | |
| | 0 | 10 | | @await Html.PartialAsync("_BsxGridShell") |
| | | 11 | | |
| | | 12 | | <div class="container-fluid py-3 bsx-surface"> |
| | | 13 | | <div class="app-section-hero app-section-hero--import d-flex flex-wrap justify-content-between align-items-start gap |
| | | 14 | | <div> |
| | | 15 | | <h1><i class="fas fa-warehouse me-2 text-primary"></i>Склады</h1> |
| | | 16 | | <div class="subtitle">Справочник складов отгрузки и привязка к заказам</div> |
| | | 17 | | <div class="subtitle-help"> |
| | | 18 | | Склад отгрузки выбирается в заказе и влияет на маппинг в 1С и синхронизацию остатков Ozon. |
| | | 19 | | В колонке «Связи складов» показаны привязки из справочника маппинга для этого названия склада. |
| | | 20 | | При удалении склада его заказы переводятся на системный склад «Не указан». |
| | | 21 | | </div> |
| | | 22 | | <div class="app-section-hero__quick-links"> |
| | | 23 | | <a asp-area="Studio2" asp-controller="WarehouseMapping" asp-action="Index"><i class="fas fa-link"></i>Св |
| | | 24 | | <a asp-area="Studio2" asp-controller="BitrixStock" asp-action="Index"><i class="fas fa-boxes"></i>Синхро |
| | | 25 | | <a asp-area="Studio2" asp-controller="OzonClients" asp-action="Index"><i class="fas fa-store"></i>Клиент |
| | | 26 | | </div> |
| | | 27 | | </div> |
| | | 28 | | <div class="d-flex flex-wrap gap-2 align-items-center"> |
| | | 29 | | <div class="bsx-dir-stats"> |
| | 0 | 30 | | <span class="bsx-dir-stat">Всего <b>@Model.Count</b></span> |
| | 0 | 31 | | <span class="bsx-dir-stat">Со связями <b>@Model.Count(w => w.Mappings.Count > 0)</b></span> |
| | | 32 | | </div> |
| | | 33 | | <a asp-action="Create" class="btn btn-primary btn-sm"><i class="fas fa-plus me-1"></i>Создать склад</a> |
| | | 34 | | </div> |
| | | 35 | | </div> |
| | | 36 | | |
| | 0 | 37 | | @if (TempData["SuccessMessage"] is string successMessage) |
| | | 38 | | { |
| | | 39 | | <div class="alert alert-success alert-dismissible fade show" role="alert"> |
| | 0 | 40 | | <i class="fas fa-check-circle me-2"></i>@successMessage |
| | | 41 | | <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> |
| | | 42 | | </div> |
| | | 43 | | } |
| | 0 | 44 | | @if (TempData["ErrorMessage"] is string errorMessage) |
| | | 45 | | { |
| | | 46 | | <div class="alert alert-danger alert-dismissible fade show" role="alert"> |
| | 0 | 47 | | <i class="fas fa-exclamation-triangle me-2"></i>@errorMessage |
| | | 48 | | <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button> |
| | | 49 | | </div> |
| | | 50 | | } |
| | | 51 | | |
| | 0 | 52 | | @await Html.PartialAsync("_BsxDirectoryGrid", new BsxDirectoryGridViewModel("warehouse", "Список складов", "fa-wareh |
| | 0 | 53 | | "Двойной клик — страница изменения склада.")) |
| | | 54 | | </div> |
| | | 55 | | |
| | | 56 | | @section Scripts { |
| | | 57 | | <script src="~/js/Studio2/Grid/bsx-directory.js" asp-append-version="true"></script> |
| | | 58 | | <script> |
| | | 59 | | (function () { |
| | | 60 | | const D = window.BsxDirectory; |
| | | 61 | | const esc = BsxGrid.esc; |
| | 0 | 62 | | const editUrl = id => '@Url.Action("Edit", "Warehouse", new { area = "Studio2" })/' + id; |
| | | 63 | | const mappingText = m => [m.ozonWarehouseId ? '#' + m.ozonWarehouseId : '', '→ ' + (m.bitrixWarehouseName || '') |
| | | 64 | | |
| | | 65 | | D.grid({ |
| | | 66 | | key: 'dirWarehouse', |
| | | 67 | | prefix: 'warehouse', |
| | 0 | 68 | | rows: @Html.Raw(System.Text.Json.JsonSerializer.Serialize(Model, jsonOptions)), |
| | | 69 | | rowUrl: r => editUrl(r.id), |
| | | 70 | | gridOptions: { |
| | | 71 | | getRowHeight: p => Math.max(40, 12 + 24 * (p.data && p.data.mappings.length || 1)) |
| | | 72 | | }, |
| | | 73 | | columnDefs: [ |
| | | 74 | | D.numCol({ field: 'id', headerName: 'ID', width: 90, valueFormatter: p => '#' + p.value }), |
| | | 75 | | { field: 'name', headerName: 'Название', width: 260, sort: 'asc', |
| | | 76 | | cellRenderer: p => `<span class="fw-semibold">${esc(p.value)}</span>${p.data.isSystem ? ' ' + D.tone(' |
| | | 77 | | D.setCol({ colId: 'hasMappings', headerName: 'Связи есть', width: 120, hide: true, valueGetter: p => p.d |
| | | 78 | | filterParams: { labels: D.YES_NO_LABELS }, cellRenderer: p => D.yesNo(p.value) }), |
| | | 79 | | { colId: 'mappings', headerName: 'Связи складов', flex: 1, minWidth: 320, sortable: false, |
| | | 80 | | valueGetter: p => p.data.mappings.map(mappingText).join('; '), |
| | | 81 | | cellClass: 'bsx-cell-wrap', |
| | | 82 | | cellRenderer: p => p.data.mappings.length |
| | | 83 | | ? '<div class="bsx-cell-stack">' + p.data.mappings.map(m => |
| | | 84 | | `<span>${m.ozonWarehouseId ? `<span class="bsx-code">#${esc(m.ozonWarehouseId)}</span> ` : ''} |
| | | 85 | | `${m.clientName ? ' ' + D.tone(m.clientName, 'accent') : ''}${m.priority > 0 ? ' ' + D.tone('p |
| | | 86 | | : '<span class="bsx-muted">—</span>' }, |
| | | 87 | | D.actionsCol(r => [ |
| | | 88 | | { icon: 'fa-pencil-alt', title: 'Редактировать', href: editUrl(r.id) }, |
| | | 89 | | r.isSystem |
| | | 90 | | ? { icon: 'fa-lock', title: 'Системный склад нельзя удалить', kind: 'muted', disabled: true } |
| | | 91 | | : { icon: 'fa-trash', title: 'Удалить', kind: 'danger', post: true, |
| | 0 | 92 | | href: '@Url.Action("Delete", "Warehouse", new { area = "Studio2" })/' + r.id, |
| | | 93 | | confirm: 'Удалить склад «' + r.name + '»? Связанные заказы будут переведены на склад «Не ука |
| | | 94 | | ], { width: 100 }) |
| | | 95 | | ] |
| | | 96 | | }); |
| | | 97 | | })(); |
| | | 98 | | </script> |
| | | 99 | | } |