|
|
|
|
using Admin.Core.IService;
|
|
|
|
|
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.ObjectModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 首页信息
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
namespace Aucma.Core.PrintTo.ViewModels
|
|
|
|
|
{
|
|
|
|
|
public partial class IndexPageViewModel : ObservableObject
|
|
|
|
|
{
|
|
|
|
|
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(IndexPageViewModel));
|
|
|
|
|
protected readonly IBaseOrderInfoServices _baseOrderInfoServices;
|
|
|
|
|
|
|
|
|
|
public IndexPageViewModel()
|
|
|
|
|
{
|
|
|
|
|
_baseOrderInfoServices = App.ServiceProvider.GetService<IBaseOrderInfoServices>();
|
|
|
|
|
_=LoadData();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region 加载DataGrid数据
|
|
|
|
|
private async Task LoadData()
|
|
|
|
|
{
|
|
|
|
|
Datalist.Clear();
|
|
|
|
|
var list = await _baseOrderInfoServices.QueryPrintInfo();
|
|
|
|
|
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
OrderInfo info = new OrderInfo();
|
|
|
|
|
info.CreatedTime = item.CreateTime;
|
|
|
|
|
info.OrderCode = item.OrderCode;
|
|
|
|
|
info.ProductCode = item.ProductCode;
|
|
|
|
|
info.ProductName = item.ProductName;
|
|
|
|
|
info.PlanAmount = item.PlanAmount;
|
|
|
|
|
info.CompleteAmount = item.CompleteAmount;
|
|
|
|
|
info.MaterialCode = item.MaterialCode;
|
|
|
|
|
info.MaterialName = item.MaterialName;
|
|
|
|
|
info.StandardAmount = item.StandardAmount;
|
|
|
|
|
info.ErrorNum = item.ErrorAmount;
|
|
|
|
|
info.LinerCodeNum = item.LinerAmount;
|
|
|
|
|
info.BoxCodeNum = item.BoxAmount;
|
|
|
|
|
Datalist.Add(info);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 查询按钮
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询
|
|
|
|
|
/// </summary>
|
|
|
|
|
[RelayCommand]
|
|
|
|
|
private void QueryString(string queryStr)
|
|
|
|
|
{
|
|
|
|
|
System.Windows.Application.Current.Dispatcher.Invoke((Action)(async () =>
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(queryStr))
|
|
|
|
|
{
|
|
|
|
|
Datalist.Clear();
|
|
|
|
|
|
|
|
|
|
//Expression<Func<OrderInfo, bool>> whereExpression = x => (bool)x.DelFlag == false;
|
|
|
|
|
//if (queryStr.IsNotEmptyOrNull())
|
|
|
|
|
//{
|
|
|
|
|
// whereExpression = whereExpression.And(x => x.PLAN_CODE.Contains(queryStr));
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
var list = await _baseOrderInfoServices.QueryPrintInfo();
|
|
|
|
|
//list.Where(d => d.MaterialName.Contains("U壳") || d.MaterialName.Contains("内胆"));
|
|
|
|
|
|
|
|
|
|
var orderList = list.Where(d => d.OrderCode.Contains(queryStr) || d.ProductCode.Contains(queryStr) || d.ProductName.Contains(queryStr) || d.MaterialCode.Contains(queryStr) || d.MaterialName.Contains(queryStr));
|
|
|
|
|
foreach (var item in orderList)
|
|
|
|
|
{
|
|
|
|
|
OrderInfo info = new OrderInfo();
|
|
|
|
|
info.CreatedTime = item.CreateTime;
|
|
|
|
|
info.OrderCode = item.OrderCode;
|
|
|
|
|
info.ProductCode = item.ProductCode;
|
|
|
|
|
info.ProductName = item.ProductName;
|
|
|
|
|
info.PlanAmount = item.PlanAmount;
|
|
|
|
|
info.CompleteAmount = item.CompleteAmount;
|
|
|
|
|
info.MaterialCode = item.MaterialCode;
|
|
|
|
|
info.MaterialName = item.MaterialName;
|
|
|
|
|
info.StandardAmount = item.StandardAmount;
|
|
|
|
|
info.ErrorNum = item.ErrorAmount;
|
|
|
|
|
info.LinerCodeNum = item.LinerAmount;
|
|
|
|
|
info.BoxCodeNum = item.BoxAmount;
|
|
|
|
|
Datalist.Add(info);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Datalist.Clear();
|
|
|
|
|
_ = LoadData();
|
|
|
|
|
}
|
|
|
|
|
//Datalist.Insert(0, Datalist[Datalist.Count - 1]);
|
|
|
|
|
//Datalist.RemoveAt(Datalist.Count - 1);
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region radio查询按钮
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 查询
|
|
|
|
|
/// </summary>
|
|
|
|
|
[RelayCommand]
|
|
|
|
|
private async Task RadioQuery(string query)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
string materialName= string.Empty;
|
|
|
|
|
//if (string.IsNullOrEmpty(query)) materialName = "内胆";
|
|
|
|
|
//if (query == "Liner") materialName = "内胆";
|
|
|
|
|
//if (query== "UShell") materialName = "U壳";
|
|
|
|
|
|
|
|
|
|
Datalist.Clear();
|
|
|
|
|
var list = await _baseOrderInfoServices.QueryPrintInfo();
|
|
|
|
|
var orderList = list.Where(d => d.MaterialName.Contains(query) );
|
|
|
|
|
foreach (var item in orderList)
|
|
|
|
|
{
|
|
|
|
|
OrderInfo info = new OrderInfo();
|
|
|
|
|
info.CreatedTime = item.CreateTime;
|
|
|
|
|
info.OrderCode = item.OrderCode;
|
|
|
|
|
info.ProductCode = item.ProductCode;
|
|
|
|
|
info.ProductName = item.ProductName;
|
|
|
|
|
info.PlanAmount = item.PlanAmount;
|
|
|
|
|
info.CompleteAmount = item.CompleteAmount;
|
|
|
|
|
info.MaterialCode = item.MaterialCode;
|
|
|
|
|
info.MaterialName = item.MaterialName;
|
|
|
|
|
info.StandardAmount = item.StandardAmount;
|
|
|
|
|
info.ErrorNum = item.ErrorAmount;
|
|
|
|
|
info.LinerCodeNum = item.LinerAmount;
|
|
|
|
|
info.BoxCodeNum = item.BoxAmount;
|
|
|
|
|
Datalist.Add(info);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
log.Error("查询数据异常", ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 打印
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 打印
|
|
|
|
|
/// </summary>
|
|
|
|
|
[RelayCommand]
|
|
|
|
|
private void Print(string obj)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(obj))
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请选中一行!","系统提醒");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string order_code = SelectedCells.OrderCode;
|
|
|
|
|
string product_code = SelectedCells.ProductCode;
|
|
|
|
|
string product_name = SelectedCells.ProductName;
|
|
|
|
|
string material_code = SelectedCells.MaterialCode;
|
|
|
|
|
string material_name = SelectedCells.MaterialName;
|
|
|
|
|
int standard_amount = SelectedCells.StandardAmount;
|
|
|
|
|
|
|
|
|
|
PrintToDevView printToDev= new PrintToDevView(product_code, material_code, material_name, standard_amount);
|
|
|
|
|
printToDev.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 补打
|
|
|
|
|
/// <summary>
|
|
|
|
|
///补打
|
|
|
|
|
/// </summary>
|
|
|
|
|
[RelayCommand]
|
|
|
|
|
private void SupplementPrint(string obj)
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrEmpty(obj))
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("请选中要补打的数据!", "系统提醒");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
string order_code = SelectedCells.OrderCode;
|
|
|
|
|
string product_code = SelectedCells.ProductCode;
|
|
|
|
|
string product_name = SelectedCells.ProductName;
|
|
|
|
|
string material_code = SelectedCells.MaterialCode;
|
|
|
|
|
string material_name = SelectedCells.MaterialName;
|
|
|
|
|
int standard_amount = SelectedCells.StandardAmount;
|
|
|
|
|
|
|
|
|
|
SupplementPrintPageView printToDev = new SupplementPrintPageView(order_code,product_code, material_code, material_name);
|
|
|
|
|
printToDev.ShowDialog();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 续打
|
|
|
|
|
/// <summary>
|
|
|
|
|
///续打
|
|
|
|
|
/// </summary>
|
|
|
|
|
[RelayCommand]
|
|
|
|
|
private void ContinuedPrint()
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("续打");
|
|
|
|
|
|
|
|
|
|
// OrderInfo info = new OrderInfo();
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 初始化datagrid
|
|
|
|
|
private ObservableCollection<OrderInfo> datalist = new ObservableCollection<OrderInfo>();
|
|
|
|
|
public ObservableCollection<OrderInfo> Datalist
|
|
|
|
|
{
|
|
|
|
|
get { return datalist; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
datalist = value;
|
|
|
|
|
OnPropertyChanged();//属性通知
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取当前行数据 赋值到textbox
|
|
|
|
|
private OrderInfo selectedCells;
|
|
|
|
|
public OrderInfo SelectedCells
|
|
|
|
|
{
|
|
|
|
|
get { return selectedCells; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
selectedCells = value;
|
|
|
|
|
SetProperty(ref selectedCells, value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|