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.
224 lines
6.8 KiB
C#
224 lines
6.8 KiB
C#
using Admin.Core.Common;
|
|
using Admin.Core.IService;
|
|
using Admin.Core.Model;
|
|
using Admin.Core.Service;
|
|
using Aucma.Core.PrintTo.Common;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using CommunityToolkit.Mvvm.Messaging;
|
|
using FastReport;
|
|
using log4net;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
/**
|
|
* 补码打印
|
|
* */
|
|
namespace Aucma.Core.PrintTo.ViewModels
|
|
{
|
|
public class SupplementViewModel : ObservableObject
|
|
{
|
|
private readonly IPrintSuppleMentBarCodeServices _printSuppleMentBarCodeServices;
|
|
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(SupplementViewModel));
|
|
private PrintState printState { get; set; } = PrintState.Idle;//打印状态
|
|
|
|
public SupplementViewModel(string orderCode,string materialCode,string materialName,string printName, string barCode)
|
|
{
|
|
_printSuppleMentBarCodeServices = App.ServiceProvider.GetService<IPrintSuppleMentBarCodeServices>();
|
|
_orderCode = orderCode;
|
|
ProductCode = materialCode;
|
|
ProductName = materialName;
|
|
_barCode= barCode;
|
|
PrintAmount = 1;
|
|
PrintName = printName;
|
|
Progress = 0;
|
|
MaxProgress = 1;//最大数
|
|
State = "Green";
|
|
ErrorNum = 0;//异常
|
|
SuspendEnabled = "False";//暂停打印
|
|
OperateEnabled = "True";//打印
|
|
}
|
|
|
|
#region 打印
|
|
|
|
public void Print()
|
|
{
|
|
try
|
|
{
|
|
string printer = Appsettings.app("Printer", "PrinterName");
|
|
|
|
#region 打印
|
|
|
|
//对接打印机
|
|
Report barReport = new Report();
|
|
barReport.Load(System.Environment.CurrentDirectory + @"\Report\MaterialBar.frx");//打印报表位置
|
|
|
|
// 设置打印机和打印选项
|
|
barReport.PrintSettings.ShowDialog = false; // 是否打开打印机选择框
|
|
barReport.PrintSettings.Printer = printer; // 设置打印机名称
|
|
barReport.PrintSettings.Copies = 1; // 设置打印份数
|
|
//barReport.PrintSettings.PageRange = "1-3"; // 设置打印页范围
|
|
|
|
barReport.SetParameterValue("BoxBarData.Id", _barCode);
|
|
barReport.SetParameterValue("BoxBarData.Order_No", _orderCode);//订单号
|
|
barReport.SetParameterValue("BoxBarData.Order_Material_Name", PrintName);//物料简码
|
|
barReport.SetParameterValue("BoxBarData.Bar_Code", _barCode);//二维码
|
|
PrintProgress = $"[1/1] {_barCode}";
|
|
barReport.Print();
|
|
|
|
#endregion
|
|
|
|
//打印完成
|
|
SetCompletetd();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Error($"打印出错:{ex.Message}");
|
|
Console.WriteLine($"打印出错:{ex.Message}");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region 选中订单参数
|
|
|
|
#region 订单编码
|
|
private string _orderCode;
|
|
|
|
public string OrderCode { get => _orderCode; set => SetProperty(ref _orderCode, value); }
|
|
#endregion
|
|
|
|
#region 订单编码
|
|
private string _orderNo;
|
|
|
|
public string OrderNo { get => _orderNo; set => SetProperty(ref _orderNo, value); }
|
|
#endregion
|
|
|
|
#region 打印名称
|
|
private string _printName;
|
|
|
|
public string PrintName
|
|
{
|
|
get => _printName;
|
|
set => SetProperty(ref _printName, value);
|
|
}
|
|
#endregion
|
|
|
|
#region 产品编码
|
|
private string _productCode;
|
|
|
|
public string ProductCode { get => _productCode; set => SetProperty(ref _productCode, value); }
|
|
#endregion
|
|
|
|
#region 产品名称
|
|
private string _productName;
|
|
|
|
public string ProductName { get => _productName; set => SetProperty(ref _productName, value); }
|
|
#endregion
|
|
|
|
#region 物料编码
|
|
private string _barCode;
|
|
|
|
public string BarCode { get => _barCode; set => SetProperty(ref _barCode, value); }
|
|
#endregion
|
|
|
|
#region 型号简码
|
|
private string _materialName;
|
|
|
|
public string MaterialName { get => _materialName; set => SetProperty(ref _materialName, value); }
|
|
#endregion
|
|
|
|
#region 物料编码
|
|
private string _materialCode;
|
|
|
|
public string MaterialCode { get => _materialCode; set => SetProperty(ref _materialCode, value); }
|
|
#endregion
|
|
|
|
#region 打印数量
|
|
private int _printAmount;
|
|
|
|
public int PrintAmount { get => _printAmount; set => SetProperty(ref _printAmount, value); }
|
|
#endregion
|
|
|
|
#region 异常数量
|
|
private int _errorNum;
|
|
|
|
public int ErrorNum { get => _errorNum; set => SetProperty(ref _errorNum, value); }
|
|
#endregion
|
|
|
|
#region 打印进度
|
|
private string _printProgress;
|
|
|
|
public string PrintProgress { get => _printProgress; set => SetProperty(ref _printProgress, value); }
|
|
#endregion
|
|
|
|
#region 进度条最大值
|
|
private int _maxProgress;
|
|
|
|
public int MaxProgress { get => _maxProgress; set => SetProperty(ref _maxProgress, value); }
|
|
#endregion
|
|
|
|
#region 进度条进度
|
|
private int _progress;
|
|
|
|
public int Progress { get => _progress; set => SetProperty(ref _progress, value); }
|
|
#endregion
|
|
|
|
#region 打印状态
|
|
private string _state;
|
|
|
|
public string State { get => _state; set => SetProperty(ref _state, value); }
|
|
#endregion
|
|
|
|
#region 开启、暂停状态按钮 名称
|
|
private string _stopOrStart;
|
|
|
|
public string StopOrStart { get => _stopOrStart; set => SetProperty(ref _stopOrStart, value); }
|
|
#endregion
|
|
|
|
#region 操作打印按钮状态
|
|
private string _operateEnabled;
|
|
public string OperateEnabled
|
|
{
|
|
get => _operateEnabled;
|
|
set => SetProperty(ref _operateEnabled, value);
|
|
}
|
|
#endregion
|
|
|
|
#region 操作暂停按钮状态
|
|
private string _suspendEnabled;
|
|
public string SuspendEnabled
|
|
{
|
|
get => _suspendEnabled;
|
|
set => SetProperty(ref _suspendEnabled, value);
|
|
}
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region 完成
|
|
/// <summary>
|
|
/// 暂停
|
|
/// </summary>
|
|
private void SetCompletetd()
|
|
{
|
|
printState = PrintState.Completetd;
|
|
|
|
State = "Green";
|
|
StopOrStart = "已完成";
|
|
OperateEnabled = "True";
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
}
|
|
}
|