You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
174 lines
5.9 KiB
C#
174 lines
5.9 KiB
C#
using Admin.Core.IRepository;
|
|
using Admin.Core.IService;
|
|
using Admin.Core.Service;
|
|
using Aucma.Core.PrintTo.Models;
|
|
using Aucma.Core.PrintTo.Views;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using log4net;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
|
|
namespace Aucma.Core.PrintTo.ViewModels
|
|
{
|
|
public partial class SupplementPrintPageViewModel : ObservableObject
|
|
{
|
|
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(SupplementPrintPageViewModel));
|
|
private readonly IPrintBarCodeServices? _barCodeServices;
|
|
protected readonly IBaseOrderInfoServices? _baseOrderInfoServices;
|
|
|
|
public SupplementPrintPageViewModel() { }
|
|
|
|
public SupplementPrintPageViewModel(string orderCode, string productCode,string material_code,string materialName)
|
|
{
|
|
OrderNo = orderCode;
|
|
ProductNo = productCode;
|
|
MaterialCode = material_code;
|
|
MaterialName = materialName;
|
|
|
|
_barCodeServices = App.ServiceProvider.GetService<IPrintBarCodeServices>();
|
|
_baseOrderInfoServices = App.ServiceProvider.GetService<IBaseOrderInfoServices>();
|
|
|
|
Task.WaitAll(LoadData(productCode, material_code));
|
|
}
|
|
|
|
#region 选中订单参数
|
|
|
|
#region 产品编码
|
|
private string _productNo;
|
|
|
|
public string ProductNo { get => _productNo; set => SetProperty(ref _productNo, value); }
|
|
#endregion
|
|
|
|
#region 订单编码
|
|
private string _orderNo;
|
|
|
|
public string OrderNo { get => _orderNo; set => SetProperty(ref _orderNo, value); }
|
|
#endregion
|
|
|
|
#region 物料编码
|
|
private string _materialCode;
|
|
|
|
public string MaterialCode { get => _materialCode; set => SetProperty(ref _materialCode, value); }
|
|
#endregion
|
|
|
|
#region 物料型号
|
|
private string _materialName;
|
|
|
|
public string MaterialName { get => _materialName; set => SetProperty(ref _materialName, value); }
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region 打印
|
|
/// <summary>
|
|
/// 打印
|
|
/// </summary>
|
|
[RelayCommand]
|
|
private void Print(string obj)
|
|
{
|
|
if (string.IsNullOrEmpty(obj))
|
|
{
|
|
MessageBox.Show("请选中一行!", "系统提醒");
|
|
return;
|
|
}
|
|
var productCode = SelectedCells.ProductCode;
|
|
var materialCode = SelectedCells.MaterialCode;
|
|
var materialName = SelectedCells.MaterialName;
|
|
var printName = SelectedCells.PrintName;
|
|
var barCode = SelectedCells.BarCode;
|
|
var printType= SelectedCells.PrintType;
|
|
PrintToDevView printToDev = new PrintToDevView(productCode, materialCode, materialName, 1, printName,printType);
|
|
printToDev.ShowDialog();
|
|
}
|
|
#endregion
|
|
|
|
#region 查询
|
|
/// <summary>
|
|
/// 查询
|
|
/// </summary>
|
|
[RelayCommand]
|
|
private async Task QueryBarCode(string queryStr)
|
|
{
|
|
//System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
|
|
//{
|
|
if (!string.IsNullOrEmpty(queryStr))
|
|
{
|
|
Datalist.Clear();
|
|
var list = await _barCodeServices.QueryAsync(d => d.MaterialName.Contains(queryStr) ||d.MaterialBarcode.Equals(ProductNo) || d.OrderCode.Equals(ProductNo));
|
|
|
|
foreach (var item in list)
|
|
{
|
|
Datalist.Add(new BarCodeModel() {
|
|
ProductCode = ProductNo,
|
|
MaterialCode= item.MaterialCode,
|
|
MaterialName=item.MaterialName,
|
|
BarCode = item.MaterialBarcode,
|
|
PrintTime = item.PrintTime,
|
|
SuppleMetNum = item.SupplementMaterial
|
|
});
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Datalist.Clear();
|
|
await LoadData(ProductNo, MaterialCode);
|
|
}
|
|
//}));
|
|
}
|
|
#endregion
|
|
|
|
#region 加载DataGrid数据
|
|
private async Task LoadData(string productCode,string material_code)
|
|
{
|
|
var list = await _barCodeServices.QueryAsync(d => d.OrderCode.Contains(productCode)&& d.MaterialCode.Contains(material_code));
|
|
if (list == null) return;
|
|
foreach (var item in list)
|
|
{
|
|
Datalist.Add(new BarCodeModel() {
|
|
ProductCode = ProductNo,
|
|
MaterialCode = item.MaterialCode,
|
|
MaterialName = item.MaterialName,
|
|
BarCode = item.MaterialBarcode,
|
|
PrintTime = item.PrintTime,
|
|
SuppleMetNum = item.SupplementMaterial
|
|
});
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 初始化datagrid
|
|
private ObservableCollection<BarCodeModel> datalist = new ObservableCollection<BarCodeModel>();
|
|
public ObservableCollection<BarCodeModel> Datalist
|
|
{
|
|
get { return datalist; }
|
|
set
|
|
{
|
|
datalist = value;
|
|
OnPropertyChanged("datalist");//属性通知
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 获取当前行数据 赋值到textbox
|
|
private BarCodeModel selectedCells;
|
|
public BarCodeModel SelectedCells
|
|
{
|
|
get { return selectedCells; }
|
|
set
|
|
{
|
|
selectedCells = value;
|
|
SetProperty(ref selectedCells, value);
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|