using BBWY.Client.APIServices;
using BBWY.Client.APIServices.QiKu;
using BBWY.Client.Models.APIModel;
using BBWY.Client.Models.APIModel.Response.PackTask;
using BBWY.Client.ViewModels;
using BBWY.Client.ViewModels.PackTask;
using BBWY.Client.Views.PackTask;
using BBWY.Client.Views.QualityTask;
using BBWY.Client.Views.QualityTipWindows;
using BBWY.Client.Views.SplitTask;
using BBWY.Client.Views.StorePickSelf;
using GalaSoft.MvvmLight.Command;
using Microsoft.Extensions.DependencyInjection;
using NPOI.Util;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using WebSocketSharp;
namespace BBWY.Client.Models
{
///
/// 打包任务 数据绑定
///
public class PackTaskModel : BaseVM
{
private string taskIdRemark;
///
///任务备注(原任务:10000 子任务:10000-1)
///
public string TaskIdRemark { get => taskIdRemark; set { Set(ref taskIdRemark, value); } }
private bool showSendMsg = false;
///
/// 展示留言信息
///
public bool ShowSendMsg { get => showSendMsg; set { Set(ref showSendMsg, value); } }
private string taskMarkMsg;
///
/// 展示留言信息
///
public string TaskMarkMsg { get => taskMarkMsg; set { Set(ref taskMarkMsg, value); } }
private bool showMoreMsg = true;
///
/// 展示留言信息
///
public bool ShowMoreMsg { get => showMoreMsg; set { Set(ref showMoreMsg, value); } }
private bool isShowFees;
public bool IsShowFees { get => isShowFees; set { Set(ref isShowFees, value); } }
private long id;
public long Id { get => id; set { Set(ref id, value); } }
public ICommand PrintBarcodeCommand { get; set; }
public ICommand PrintCerCommand { get; set; }
public ICommand LookCerCommand { get; set; }
public ICommand LookBarCommand { get; set; }
public ICommand SetServiceCommand { get; set; }
///
/// 修改任务
///
public ICommand UpdateTaskCommand { get; set; }
///
/// 任务拆分
///
public ICommand TaskSplitCommand { get; set; }
///
/// 挂起
///
public ICommand PackagingTaskExceptionCommand { get; set; }
///
/// 商家自取
///
public ICommand StoreGetBySelfCommand { get; set; }
///
/// 包装任务释放挂起
///
public ICommand DisposeTaskCommand { get; set; }
///
/// 删除任务
///
public ICommand DeletedTaskCommand { get; set; }
public Action ReflashTask { get; set; }
private void UpdateTask()
{
try
{
if (!this.SkuPurchaseSchemeId.IsNullOrEmpty())//B端有采购方案
{
UpdatePurchaseTaskWindow updatePurchaseWindow = new UpdatePurchaseTaskWindow(this, ReflashTask);
updatePurchaseWindow.ShowDialog();
return;
}
if (!OrderId.IsNullOrEmpty() && SkuPurchaseSchemeId.IsNullOrEmpty())//B端无采购方案 ,手动添加合格证
{
PublishTaskWindow publishB = new PublishTaskWindow(ReflashTask, this, SaveType.B端);
publishB.ShowDialog();
return;
}
PublishTaskWindow publish = new PublishTaskWindow(ReflashTask, this, SaveType.C端);
publish.ShowDialog();
}
catch (Exception)
{
}
}
private IServiceProvider sp;
public PackTaskModel()
{
sp = (App.Current as App).ServiceProvider;
using (var ss = sp.CreateScope())
{
packTaskService = ss.ServiceProvider.GetRequiredService();
packTaskAbortService = ss.ServiceProvider.GetRequiredService();
}
PrintBarcodeCommand = new RelayCommand(PrintBarcode);
PrintCerCommand = new RelayCommand(PrintCer);
LookBarCommand = new RelayCommand(LookBar);
LookCerCommand = new RelayCommand(LookCer);
SetServiceCommand = new RelayCommand(SetService);
UpdateTaskCommand = new RelayCommand(UpdateTask);
DeletedTaskCommand = new RelayCommand