1
This commit is contained in:
@ -126,6 +126,7 @@ namespace 货架标准上位机.ViewModel
|
||||
FilterItems(value);
|
||||
}
|
||||
}
|
||||
|
||||
public ManualObservableCollection<DataModel> Items { get; set; } = new();
|
||||
private List<DataModel> matCodes = new List<DataModel>();
|
||||
private void FilterItems(string key)
|
||||
|
@ -1,9 +1,12 @@
|
||||
using HandyControl.Controls;
|
||||
using HandyControl.Collections;
|
||||
using HandyControl.Controls;
|
||||
using HandyControl.Tools.Extension;
|
||||
using Ping9719.WpfEx.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
@ -30,8 +33,68 @@ namespace 货架标准上位机.ViewModel
|
||||
get => matCode; set
|
||||
{
|
||||
SetProperty(ref matCode, value);
|
||||
|
||||
App.Current.Dispatcher.Invoke(() =>
|
||||
{
|
||||
FilterItems(value);
|
||||
});
|
||||
|
||||
if (matCode.Length >= 8
|
||||
|| matCodes.Where(t => t.MatCode == matCode).Any() )
|
||||
{
|
||||
GetMatBaseInfoRequest();
|
||||
}
|
||||
}
|
||||
}
|
||||
public ManualObservableCollection<DataModel> Items { get; set; } = new();
|
||||
private List<DataModel> matCodes = new List<DataModel>();
|
||||
private void FilterItems(string key)
|
||||
{
|
||||
//至少输入三个字符 避免删除或输入时界面变卡
|
||||
if (string.IsNullOrEmpty(key) || key.Length < 3)
|
||||
{
|
||||
Items.Clear();
|
||||
return;
|
||||
}
|
||||
key = key.ToUpper();
|
||||
Items.CanNotify = false;
|
||||
Items.Clear();
|
||||
foreach (var matCode in matCodes)
|
||||
{
|
||||
if (matCode.MatCode.ToUpper().Contains(key))
|
||||
{
|
||||
Items.Add(matCode);
|
||||
}
|
||||
}
|
||||
Items.CanNotify = true;
|
||||
}
|
||||
public class DataModel
|
||||
{
|
||||
public string MatCode { get; set; }
|
||||
}
|
||||
|
||||
public void InitMatCode()
|
||||
{
|
||||
//调用接口更新!
|
||||
Task.Run(() =>
|
||||
{
|
||||
var body = new GetMatCodeListRequest()
|
||||
{
|
||||
IsFromBaseData = true,
|
||||
UserName = LocalStatic.CurrentUser,
|
||||
DeviceType = LocalFile.Config.DeviceType,
|
||||
};
|
||||
|
||||
var Result = ApiHelp.GetDataFromHttp<ResponseCommon<List<string>>>(LocalFile.Config.ApiIpHost + "matBaseInfo/getMatCodeList", body, "POST");
|
||||
if (Result != null && Result.Data != null && Result.Data.Count() > 0)
|
||||
{
|
||||
matCodes = Result.Data.Select(t => new DataModel()
|
||||
{
|
||||
MatCode = t
|
||||
}).ToList();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private string matName;
|
||||
public string MatName
|
||||
@ -164,6 +227,12 @@ namespace 货架标准上位机.ViewModel
|
||||
#region 调用接口获取物料 MatBaseInfo
|
||||
try
|
||||
{
|
||||
if (MatQty == 0)
|
||||
{
|
||||
HandyControl.Controls.MessageBox.Show("数量不能为0!");
|
||||
return;
|
||||
}
|
||||
|
||||
var body = new JinChuanCommitMatInfoRequest()
|
||||
{
|
||||
MatId = MatBaseInfo.Id,
|
||||
@ -267,7 +336,7 @@ namespace 货架标准上位机.ViewModel
|
||||
// 提取第一个字段 CPN物料编码
|
||||
//string firstField = Regex.Match(input, @"^[0-9,a-z,A-Z, ]{9}{").Value;
|
||||
string firstField = Regex.Match(input, LocalFile.Config.RegexMatCode).Value;
|
||||
MatCode = firstField.Replace("{", "").Replace(" ", "");
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
@ -289,6 +358,12 @@ namespace 货架标准上位机.ViewModel
|
||||
MatBatch = thirdField.Replace("{", "").Replace(" ", ""); ;
|
||||
#endregion
|
||||
|
||||
MatCode = firstField.Replace("{", "").Replace(" ", "");
|
||||
//GetMatBaseInfoRequest();
|
||||
}
|
||||
|
||||
public void GetMatBaseInfoRequest()
|
||||
{
|
||||
//调用接口获取物料信息
|
||||
#region 调用接口获取物料 MatBaseInfo
|
||||
try
|
||||
|
@ -39,8 +39,7 @@ namespace 货架标准上位机
|
||||
{
|
||||
viewModel.SelectedataGridItem.IsSelected = !viewModel.SelectedataGridItem.IsSelected;
|
||||
dataGrid.UnselectAllCells();//取消选中 避免手动点击check选项时反选失败 和重新点击该项时反选失败
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -7,7 +7,8 @@
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d"
|
||||
Height="400" Width="340" WindowStyle="None" BorderThickness="0" Background="{x:Null}" AllowsTransparency="True" WindowStartupLocation="CenterScreen" Opacity="1">
|
||||
Loaded="UserControlBase_Loaded"
|
||||
Height="400" Width="340" WindowStyle="None" BorderThickness="0" Background="{x:Null}" AllowsTransparency="True" WindowStartupLocation="CenterScreen" Opacity="1">
|
||||
<Border BorderBrush="Gray" Background="WhiteSmoke" CornerRadius="5" BorderThickness="1">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
@ -35,7 +36,14 @@
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal" Margin="5">
|
||||
<TextBlock Text="物料编码:" FontSize="15" VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
|
||||
<TextBlock Text="{Binding MatCode}" FontSize="15" VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
|
||||
<!--<TextBlock Text="{Binding MatCode}" FontSize="15" VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>-->
|
||||
<hc:AutoCompleteTextBox Grid.Row="1" Grid.Column="1" MinWidth="120" FontSize="18" IsEditable="True"
|
||||
Height="20"
|
||||
IsTextSearchEnabled="True"
|
||||
Name="cbxMatCode" Margin="1"
|
||||
ItemsSource="{Binding Items}"
|
||||
Text="{Binding MatCode}"
|
||||
DisplayMemberPath="MatCode"/>
|
||||
</StackPanel>
|
||||
|
||||
<StackPanel Orientation="Horizontal" Margin="5">
|
||||
|
@ -69,5 +69,10 @@ namespace 货架标准上位机
|
||||
txtTotalCount.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
private void UserControlBase_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
viewModel.InitMatCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ namespace 货架标准上位机
|
||||
if (viewModel.SelectedataGridItem != null)
|
||||
{
|
||||
viewModel.SelectedataGridItem.IsSelected = !viewModel.SelectedataGridItem.IsSelected;
|
||||
//dataGrid.UnselectAllCells();
|
||||
dataGrid.UnselectAllCells();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -72,6 +72,7 @@
|
||||
<DataGrid.ContextMenu>
|
||||
<ContextMenu Name="dgmenu1" StaysOpen="true">
|
||||
<MenuItem Header="查询当前标定值/电压值" Click="MenuItem_Click"/>
|
||||
<MenuItem Header="手动标定" Click="MenuItem_Click"/>
|
||||
</ContextMenu>
|
||||
</DataGrid.ContextMenu>
|
||||
<DataGrid.Columns>
|
||||
|
Reference in New Issue
Block a user