diff --git a/src/ZB.MOM.WW.OtOpcUa.Admin/Components/Pages/Clusters/EquipmentTab.razor b/src/ZB.MOM.WW.OtOpcUa.Admin/Components/Pages/Clusters/EquipmentTab.razor
index fdc28f1..4bc3d4f 100644
--- a/src/ZB.MOM.WW.OtOpcUa.Admin/Components/Pages/Clusters/EquipmentTab.razor
+++ b/src/ZB.MOM.WW.OtOpcUa.Admin/Components/Pages/Clusters/EquipmentTab.razor
@@ -36,7 +36,10 @@ else if (_equipment.Count > 0)
@e.SAPID |
@e.Manufacturer / @e.Model |
@e.SerialNumber |
- |
+
+
+
+ |
}
@@ -47,8 +50,8 @@ else if (_equipment.Count > 0)
{
-
New equipment
-
+ @(_editMode ? "Edit equipment" : "New equipment")
+
@@ -78,24 +81,13 @@ else if (_equipment.Count > 0)
- OPC 40010 Identification
-
-
-
-
-
-
-
-
-
-
-
+
@if (_error is not null) { @_error
}
-
+
@@ -106,6 +98,7 @@ else if (_equipment.Count > 0)
[Parameter] public long GenerationId { get; set; }
private List
? _equipment;
private bool _showForm;
+ private bool _editMode;
private Equipment _draft = NewBlankDraft();
private string? _error;
@@ -125,20 +118,68 @@ else if (_equipment.Count > 0)
private void StartAdd()
{
_draft = NewBlankDraft();
+ _editMode = false;
_error = null;
_showForm = true;
}
+ private void StartEdit(Equipment row)
+ {
+ // Shallow-clone so Cancel doesn't mutate the list-displayed row with in-flight form edits.
+ _draft = new Equipment
+ {
+ EquipmentRowId = row.EquipmentRowId,
+ GenerationId = row.GenerationId,
+ EquipmentId = row.EquipmentId,
+ EquipmentUuid = row.EquipmentUuid,
+ DriverInstanceId = row.DriverInstanceId,
+ DeviceId = row.DeviceId,
+ UnsLineId = row.UnsLineId,
+ Name = row.Name,
+ MachineCode = row.MachineCode,
+ ZTag = row.ZTag,
+ SAPID = row.SAPID,
+ Manufacturer = row.Manufacturer,
+ Model = row.Model,
+ SerialNumber = row.SerialNumber,
+ HardwareRevision = row.HardwareRevision,
+ SoftwareRevision = row.SoftwareRevision,
+ YearOfConstruction = row.YearOfConstruction,
+ AssetLocation = row.AssetLocation,
+ ManufacturerUri = row.ManufacturerUri,
+ DeviceManualUri = row.DeviceManualUri,
+ EquipmentClassRef = row.EquipmentClassRef,
+ Enabled = row.Enabled,
+ };
+ _editMode = true;
+ _error = null;
+ _showForm = true;
+ }
+
+ private void Cancel()
+ {
+ _showForm = false;
+ _editMode = false;
+ }
+
private async Task SaveAsync()
{
_error = null;
- _draft.EquipmentUuid = Guid.NewGuid();
- _draft.EquipmentId = DraftValidator.DeriveEquipmentId(_draft.EquipmentUuid);
- _draft.GenerationId = GenerationId;
try
{
- await EquipmentSvc.CreateAsync(GenerationId, _draft, CancellationToken.None);
+ if (_editMode)
+ {
+ await EquipmentSvc.UpdateAsync(_draft, CancellationToken.None);
+ }
+ else
+ {
+ _draft.EquipmentUuid = Guid.NewGuid();
+ _draft.EquipmentId = DraftValidator.DeriveEquipmentId(_draft.EquipmentUuid);
+ _draft.GenerationId = GenerationId;
+ await EquipmentSvc.CreateAsync(GenerationId, _draft, CancellationToken.None);
+ }
_showForm = false;
+ _editMode = false;
await ReloadAsync();
}
catch (Exception ex) { _error = ex.Message; }
diff --git a/src/ZB.MOM.WW.OtOpcUa.Admin/Components/Pages/Clusters/IdentificationFields.razor b/src/ZB.MOM.WW.OtOpcUa.Admin/Components/Pages/Clusters/IdentificationFields.razor
new file mode 100644
index 0000000..582bfde
--- /dev/null
+++ b/src/ZB.MOM.WW.OtOpcUa.Admin/Components/Pages/Clusters/IdentificationFields.razor
@@ -0,0 +1,49 @@
+@using ZB.MOM.WW.OtOpcUa.Configuration.Entities
+
+@* Reusable OPC 40010 Machinery Identification editor. Binds to an Equipment row and renders the
+ nine decision #139 fields in a consistent 3-column Bootstrap grid. Used by EquipmentTab's
+ create + edit forms so the same UI renders regardless of which flow opened it. *@
+
+OPC 40010 Identification
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+@code {
+ [Parameter, EditorRequired] public Equipment? Equipment { get; set; }
+}