优化车辆档案更新逻辑,增加对司机、供应商和客户信息变更的检查,确保数据一致性。调整界面布局,改善重量信息和称重榜单的展示方式,提升用户体验。
This commit is contained in:
@@ -808,11 +808,22 @@ public class WeightRecordOperationViewModel : BaseViewModel
|
|||||||
{
|
{
|
||||||
if (_matchedVehicle != null)
|
if (_matchedVehicle != null)
|
||||||
{
|
{
|
||||||
// 已有档案:仅在司机信息有变动时回写
|
// 已有档案:检查司机、供应商、客户是否需要回写
|
||||||
bool driverChanged =
|
bool driverChanged =
|
||||||
!string.Equals(DriverName, _matchedVehicle.DriverName) ||
|
!string.Equals(DriverName, _matchedVehicle.DriverName) ||
|
||||||
!string.Equals(DriverPhone, _matchedVehicle.DriverPhone);
|
!string.Equals(DriverPhone, _matchedVehicle.DriverPhone);
|
||||||
if (!driverChanged) return;
|
|
||||||
|
// 操作人员通过弹窗选了供应商,且与档案不同(含原来为空的情况)
|
||||||
|
bool supplierChanged = _matchedVehicle.VehicleBelong == "2"
|
||||||
|
&& _selectedSupplier != null
|
||||||
|
&& _selectedSupplier.Id != _matchedVehicle.SupplierId;
|
||||||
|
|
||||||
|
// 操作人员通过弹窗选了客户,且与档案不同(含原来为空的情况)
|
||||||
|
bool customerChanged = _matchedVehicle.VehicleBelong == "1"
|
||||||
|
&& _selectedCustomer != null
|
||||||
|
&& _selectedCustomer.Id != _matchedVehicle.CustomerIds;
|
||||||
|
|
||||||
|
if (!driverChanged && !supplierChanged && !customerChanged) return;
|
||||||
|
|
||||||
await _vehicleService.EditAsync(new MesXslVehicle
|
await _vehicleService.EditAsync(new MesXslVehicle
|
||||||
{
|
{
|
||||||
@@ -821,22 +832,31 @@ public class WeightRecordOperationViewModel : BaseViewModel
|
|||||||
VehicleBelong = _matchedVehicle.VehicleBelong,
|
VehicleBelong = _matchedVehicle.VehicleBelong,
|
||||||
TareWeightKg = _matchedVehicle.TareWeightKg,
|
TareWeightKg = _matchedVehicle.TareWeightKg,
|
||||||
LoadCapacity = _matchedVehicle.LoadCapacity,
|
LoadCapacity = _matchedVehicle.LoadCapacity,
|
||||||
SupplierId = _matchedVehicle.SupplierId,
|
SupplierId = supplierChanged ? _selectedSupplier!.Id : _matchedVehicle.SupplierId,
|
||||||
SupplierName = _matchedVehicle.SupplierName,
|
SupplierName = supplierChanged ? _selectedSupplier!.SupplierName : _matchedVehicle.SupplierName,
|
||||||
SupplierShortName = _matchedVehicle.SupplierShortName,
|
SupplierShortName = supplierChanged ? _selectedSupplier!.SupplierShortName : _matchedVehicle.SupplierShortName,
|
||||||
CustomerIds = _matchedVehicle.CustomerIds,
|
CustomerIds = customerChanged ? _selectedCustomer!.Id : _matchedVehicle.CustomerIds,
|
||||||
CustomerShortName = _matchedVehicle.CustomerShortName,
|
CustomerShortName = customerChanged
|
||||||
|
? (_selectedCustomer!.CustomerShortName ?? _selectedCustomer.CustomerName)
|
||||||
|
: _matchedVehicle.CustomerShortName,
|
||||||
DriverName = DriverName,
|
DriverName = DriverName,
|
||||||
DriverPhone = DriverPhone,
|
DriverPhone = DriverPhone,
|
||||||
Status = _matchedVehicle.Status,
|
Status = _matchedVehicle.Status,
|
||||||
TenantId = _matchedVehicle.TenantId,
|
TenantId = _matchedVehicle.TenantId,
|
||||||
Version = _matchedVehicle.Version,
|
Version = _matchedVehicle.Version,
|
||||||
});
|
});
|
||||||
AddLog($"车辆档案已更新:{PlateNumber}");
|
|
||||||
|
var parts = new List<string>();
|
||||||
|
if (driverChanged) parts.Add("司机信息");
|
||||||
|
if (supplierChanged) parts.Add($"供应商→{_selectedSupplier!.SupplierName}");
|
||||||
|
if (customerChanged) parts.Add($"客户→{_selectedCustomer!.CustomerName}");
|
||||||
|
AddLog($"车辆档案已更新:{PlateNumber}({string.Join("、", parts)})");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// 无档案:根据表单信息新建车辆档案
|
// 只有明确查询过且未找到时才新建,避免从最近榜单带入时重复新建
|
||||||
|
if (VehicleLookupStatus != "NotFound") return;
|
||||||
|
|
||||||
var vehicleBelong = InoutDirection == "2" ? "1" : "2"; // 出厂→客户 进厂→供应商
|
var vehicleBelong = InoutDirection == "2" ? "1" : "2"; // 出厂→客户 进厂→供应商
|
||||||
var newVehicle = new MesXslVehicle
|
var newVehicle = new MesXslVehicle
|
||||||
{
|
{
|
||||||
@@ -845,6 +865,7 @@ public class WeightRecordOperationViewModel : BaseViewModel
|
|||||||
SupplierId = _selectedSupplier?.Id,
|
SupplierId = _selectedSupplier?.Id,
|
||||||
SupplierName = _selectedSupplier?.SupplierName,
|
SupplierName = _selectedSupplier?.SupplierName,
|
||||||
SupplierShortName = _selectedSupplier?.SupplierShortName,
|
SupplierShortName = _selectedSupplier?.SupplierShortName,
|
||||||
|
CustomerIds = _selectedCustomer?.Id,
|
||||||
CustomerShortName = _selectedCustomer?.CustomerShortName
|
CustomerShortName = _selectedCustomer?.CustomerShortName
|
||||||
?? (InoutDirection == "2" ? ReceiverUnit : null),
|
?? (InoutDirection == "2" ? ReceiverUnit : null),
|
||||||
DriverName = DriverName,
|
DriverName = DriverName,
|
||||||
|
|||||||
@@ -513,14 +513,20 @@
|
|||||||
|
|
||||||
<!-- 重量信息 -->
|
<!-- 重量信息 -->
|
||||||
<Border Grid.Row="1" Style="{StaticResource SectionBorderStyle}" Margin="0,0,0,0" Padding="12,10">
|
<Border Grid.Row="1" Style="{StaticResource SectionBorderStyle}" Margin="0,0,0,0" Padding="12,10">
|
||||||
<StackPanel>
|
<Grid>
|
||||||
<StackPanel Orientation="Horizontal" Margin="0,0,0,4">
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="0,0,0,4">
|
||||||
<Border Width="4" Height="18" CornerRadius="2" Background="{StaticResource SectionBorderBrush}"/>
|
<Border Width="4" Height="18" CornerRadius="2" Background="{StaticResource SectionBorderBrush}"/>
|
||||||
<TextBlock Text="重量信息" Style="{StaticResource SectionTitleStyle}"/>
|
<TextBlock Text="重量信息" Style="{StaticResource SectionTitleStyle}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- 毛重 / 皮重并排 -->
|
<!-- 毛重 / 皮重并排 -->
|
||||||
<Grid Margin="0,0,0,8">
|
<Grid Grid.Row="1" Margin="0,0,0,8">
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
<ColumnDefinition Width="16"/>
|
<ColumnDefinition Width="16"/>
|
||||||
@@ -649,7 +655,7 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<!-- 净重展示(横贯全宽) -->
|
<!-- 净重展示(横贯全宽) -->
|
||||||
<StackPanel Margin="0,2,0,0">
|
<StackPanel Grid.Row="2" Margin="0,2,0,0">
|
||||||
<TextBlock Text="净 重 = 毛重 - 皮重 (KG)" FontSize="12"
|
<TextBlock Text="净 重 = 毛重 - 皮重 (KG)" FontSize="12"
|
||||||
Foreground="{DynamicResource SecondaryTextBrush}"
|
Foreground="{DynamicResource SecondaryTextBrush}"
|
||||||
Margin="0,0,0,6" HorizontalAlignment="Center"/>
|
Margin="0,0,0,6" HorizontalAlignment="Center"/>
|
||||||
@@ -662,12 +668,16 @@
|
|||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
|
||||||
<!-- 最近称重榜单 -->
|
<!-- 最近称重榜单 -->
|
||||||
<StackPanel Margin="0,8,0,0">
|
<Grid Grid.Row="3" Margin="0,8,0,0">
|
||||||
<TextBlock Text="最近称重榜单"
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<TextBlock Grid.Row="0" Text="最近称重榜单"
|
||||||
FontSize="12"
|
FontSize="12"
|
||||||
Foreground="{DynamicResource SecondaryTextBrush}"
|
Foreground="{DynamicResource SecondaryTextBrush}"
|
||||||
Margin="0,0,0,6"/>
|
Margin="0,0,0,6"/>
|
||||||
<Border CornerRadius="8"
|
<Border Grid.Row="1" CornerRadius="8"
|
||||||
Background="White"
|
Background="White"
|
||||||
BorderBrush="{DynamicResource BorderBrush}"
|
BorderBrush="{DynamicResource BorderBrush}"
|
||||||
BorderThickness="1"
|
BorderThickness="1"
|
||||||
@@ -692,7 +702,7 @@
|
|||||||
ColumnHeaderHeight="28"
|
ColumnHeaderHeight="28"
|
||||||
RowHeaderWidth="0"
|
RowHeaderWidth="0"
|
||||||
MinHeight="80"
|
MinHeight="80"
|
||||||
MaxHeight="80">
|
VerticalScrollBarVisibility="Auto">
|
||||||
<DataGrid.RowStyle>
|
<DataGrid.RowStyle>
|
||||||
<Style TargetType="DataGridRow">
|
<Style TargetType="DataGridRow">
|
||||||
<Setter Property="Background" Value="White"/>
|
<Setter Property="Background" Value="White"/>
|
||||||
@@ -728,8 +738,8 @@
|
|||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
</Border>
|
</Border>
|
||||||
</StackPanel>
|
</Grid>
|
||||||
</StackPanel>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
Reference in New Issue
Block a user