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.
245 lines
8.7 KiB
C#
245 lines
8.7 KiB
C#
using Admin.Core.IService;
|
|
using Admin.Core.Wpf.Models;
|
|
using Admin.Core.Wpf.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 Admin.Core.Wpf.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)
|
|
{
|
|
Datalist.Add(new OrderInfo() {
|
|
created_time = item.CreateTime.ToString(),
|
|
order_code = item.OrderCode,
|
|
product_code = item.ProductCode,
|
|
product_name = item.ProductName,
|
|
plan_amount = item.PlanAmount,
|
|
complete_amount = item.CompleteAmount.ToString() == "" ? 0 : item.CompleteAmount,
|
|
material_code = item.MaterialCode,
|
|
material_name = item.MaterialName,
|
|
standard_amount = item.StandardAmount,
|
|
ErrorNum = item.ErrorAmount,
|
|
LinerCodeNum = item.LinerAmount,
|
|
BoxCodeNum = item.BoxAmount
|
|
|
|
});
|
|
}
|
|
}
|
|
|
|
#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)
|
|
{
|
|
Datalist.Add(new OrderInfo() {
|
|
created_time = item.CreateTime.ToString(),
|
|
order_code = item.OrderCode,
|
|
product_code = item.ProductCode,
|
|
product_name = item.ProductName,
|
|
plan_amount = item.PlanAmount,
|
|
complete_amount = item.CompleteAmount.ToString() == "" ? 0 : item.CompleteAmount,
|
|
material_code = item.MaterialCode,
|
|
material_name = item.MaterialName,
|
|
standard_amount = item.StandardAmount,
|
|
ErrorNum = item.ErrorAmount,
|
|
LinerCodeNum = item.LinerAmount,
|
|
BoxCodeNum = item.BoxAmount
|
|
});
|
|
}
|
|
}
|
|
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)
|
|
{
|
|
Datalist.Add(new OrderInfo() {
|
|
created_time = item.CreateTime.ToString(),
|
|
order_code = item.OrderCode,
|
|
product_code = item.ProductCode,
|
|
product_name = item.ProductName,
|
|
plan_amount = item.PlanAmount,
|
|
complete_amount = item.CompleteAmount.ToString() == "" ? 0 : item.CompleteAmount,
|
|
material_code = item.MaterialCode,
|
|
material_name = item.MaterialName,
|
|
standard_amount = item.StandardAmount,
|
|
ErrorNum = item.ErrorAmount,
|
|
LinerCodeNum = item.LinerAmount,
|
|
BoxCodeNum = item.BoxAmount
|
|
});
|
|
}
|
|
}
|
|
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.product_code;
|
|
string product_code = SelectedCells.product_code;
|
|
string product_name = SelectedCells.product_name;
|
|
string material_code = SelectedCells.material_code;
|
|
string material_name = SelectedCells.material_name;
|
|
int standard_amount = SelectedCells.standard_amount;
|
|
|
|
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.order_code;
|
|
string product_code = SelectedCells.product_code;
|
|
string product_name = SelectedCells.product_name;
|
|
string material_code = SelectedCells.material_code;
|
|
string material_name = SelectedCells.material_name;
|
|
int standard_amount = SelectedCells.standard_amount;
|
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|