This commit is contained in:
hehaibing-1996
2024-07-05 14:36:34 +08:00
parent adb0367a83
commit ed3673db03
35 changed files with 1435 additions and 1939 deletions

View File

@ -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