步步为盈
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

496 lines
16 KiB

2 years ago
using BBWY.Client.APIServices;
using BBWY.Client.Helpers;
using BBWY.Client.Models;
using BBWY.Client.Views.Order;
using BBWY.Common.Models;
using BBWY.Controls;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows.Input;
using System.Windows;
using BBWY.Common.Extensions;
2 years ago
using System.Threading.Tasks;
using BBWY.Client.Views.PackTask;
using HandyControl.Tools.Extension;
using Newtonsoft.Json;
using BBWY.Client.Models.APIModel.Response.PackTask;
using BBWY.Client.Models.PackTask;
2 years ago
using WebSocketSharp;
2 years ago
namespace BBWY.Client.ViewModels.PackTask
{
2 years ago
/// <summary>
///
/// </summary>
public partial class TaskListViewModel : BaseVM, IDenpendency//注入服务
2 years ago
{
2 years ago
#region 属性绑定
2 years ago
/// <summary>
2 years ago
/// 查询时间段
2 years ago
/// </summary>
2 years ago
private DateTime startTime;
public DateTime StartTime { get => startTime; set { Set(ref startTime, value); } }
2 years ago
private DateTime endTime;
2 years ago
public DateTime EndTime { get => endTime; set { Set(ref endTime, value); } }
2 years ago
/// <summary>
2 years ago
/// 查询任务id
2 years ago
/// </summary>
2 years ago
private string searchTaskId;
public string SearchTaskId
{
get => searchTaskId; set
{
Set(ref searchTaskId, value);
}
}
2 years ago
/// <summary>
2 years ago
/// 查询Sku
2 years ago
/// </summary>
2 years ago
private string searchSkuId;
public string SearchSkuId { get => searchSkuId; set { Set(ref searchSkuId, value); } }
2 years ago
2 years ago
public TaskState? taskState;
2 years ago
/// <summary>
2 years ago
/// 任务状态
2 years ago
/// </summary>
2 years ago
public TaskState? TaskState
{
get => taskState; private set
{
Set(ref taskState, value);
}
}
2 years ago
2 years ago
private int pageIndex = 1;
private int pageSize = 10;
2 years ago
2 years ago
public int PageIndex { get => pageIndex; set { Set(ref pageIndex, value); } }
2 years ago
2 years ago
public int PageSize { get => pageSize; set { Set(ref pageSize, value); } }
private int orderCount;//总数量
public int OrderCount { get => orderCount; set { Set(ref orderCount, value); } }
2 years ago
/// <summary>
2 years ago
/// 未到货数量
2 years ago
/// </summary>
2 years ago
public string NoArrivedCount { get => noArrivedCount; set { Set(ref noArrivedCount, value); } }
private string noArrivedCount;
private string someArrivedCount;
2 years ago
/// <summary>
2 years ago
/// 部分到货数量
2 years ago
/// </summary>
2 years ago
public string SomeArrivedCount { get => someArrivedCount; set { Set(ref someArrivedCount, value); } }
2 years ago
2 years ago
private string arrivedCount;
2 years ago
/// <summary>
2 years ago
/// 已到货数量
2 years ago
/// </summary>
2 years ago
public string ArrivedCount { get => arrivedCount; set { Set(ref arrivedCount, value); } }
2 years ago
2 years ago
private bool isLoading;
public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } }
private string waitPackCount;
/// <summary>
/// 待打包任务数
/// </summary>
public string WaitPackCount { get => waitPackCount; set { Set(ref waitPackCount, value); } }
private string waitSealBoxCount;
/// <summary>
/// 带封箱任务数
/// </summary>
public string WaitSealBoxCount { get => waitSealBoxCount; set { Set(ref waitSealBoxCount, value); } }
2 years ago
2 years ago
private string waitFallWareCount;
/// <summary>
/// 待落仓任务数
/// </summary>
public string WaitFallWareCount { get => waitFallWareCount; set { Set(ref waitFallWareCount, value); } }
private string waitOutbound;
/// <summary>
/// 待出库任务数
/// </summary>
public string WaitOutbound { get => waitOutbound; set { Set(ref waitOutbound, value); } }
private string waitCompleted;
/// <summary>
/// 待完成任务数
/// </summary>
public string WaitCompleted { get => waitCompleted; set { Set(ref waitCompleted, value); } }
2 years ago
2 years ago
private readonly PackTaskService packTaskService;
WorkProcessService workProcessService;
public int? taskStatus { get; set; }
private ObservableCollection<PackTaskModel> packTaskList;
2 years ago
/// <summary>
2 years ago
/// 动态数据表
2 years ago
/// </summary>
2 years ago
public ObservableCollection<PackTaskModel> PackTaskList { get => packTaskList; set { Set(ref packTaskList, value); } }
2 years ago
2 years ago
2 years ago
#endregion
2 years ago
2 years ago
public TaskListViewModel(PackTaskService packTaskService, GlobalContext globalContext, ProductService productService, ConsumableService consumableService, WorkProcessService workProcessService, IncreateServiceService increateServiceService)
2 years ago
{
2 years ago
this.globalContext = globalContext;
this.productService = productService;
this.consumableService = consumableService;
this.workProcessService = workProcessService;
this.increateServiceService = increateServiceService;
2 years ago
this.packTaskService = packTaskService;
PackTaskList = new ObservableCollection<PackTaskModel>();//初始化数据
2 years ago
2 years ago
SetTaskStateCommand = new RelayCommand<TaskState?>(SetTaskState);
CreateTaskCommand = new RelayCommand(CreateTask);
SearchTaskCommand = new RelayCommand(() =>
2 years ago
{
PageIndex = 1;
2 years ago
Task.Factory.StartNew(() => SearchTaskList()); //手动点击查询订单
2 years ago
});
2 years ago
TaskPageIndexChangedCommand = new RelayCommand<PageArgs>(p =>
2 years ago
{
2 years ago
LoadIndex(p.PageIndex);
2 years ago
});
2 years ago
OpenSkuDetailCommand = new RelayCommand<object>(OpenSkuDetail);
2 years ago
DeletedTaskCommand = new RelayCommand<object>(DeletedTask);
2 years ago
2 years ago
StartTime = DateTime.Now.Date;
EndTime = DateTime.Now.Date;
IsLoading = false;
//加载数据
2 years ago
SetTaskState(null);
2 years ago
2 years ago
}
2 years ago
2 years ago
private void DeletedTask(object obj)
{
2 years ago
var packTaskmodel = (PackTaskModel)obj;
if (!packTaskmodel.OrderId.IsNullOrEmpty())
{
System.Windows.MessageBox.Show("暂不支持删除采购组的任务");
return;
}
2 years ago
MessageBoxResult result = MessageBox.Show("确定取消任务?", "提示",
2 years ago
MessageBoxButton.YesNo,
MessageBoxImage.Warning);
2 years ago
2 years ago
if (result != MessageBoxResult.Yes) return;
2 years ago
packTaskService.DeletedTask(packTaskmodel.TaskId);
2 years ago
Task.Factory.StartNew(() => SearchTaskList());
}
2 years ago
2 years ago
private void IsLoadCount()
2 years ago
{
2 years ago
var packTaskResult = packTaskService.GetTaskAllCount(globalContext.User.Shop.ShopId.ToString());
if (packTaskResult != null && packTaskResult.Success && packTaskResult.Data != null)
2 years ago
{
2 years ago
App.Current.Dispatcher.Invoke(new Action(() =>
2 years ago
{
2 years ago
ArrivedCount = packTaskResult.Data.ArrivedCount.ToString();
NoArrivedCount = packTaskResult.Data.NoArrivedCount.ToString();
SomeArrivedCount = packTaskResult.Data.SomeArrivedCount.ToString();
//WorryCount = packTaskResult.Data.WorryCount.ToString();
WaitOutbound = packTaskResult.Data.WaitOutbound?.ToString();
WaitPackCount = packTaskResult.Data.WaitPackCount?.ToString();
WaitSealBoxCount = packTaskResult.Data.WaitSealBox?.ToString();
WaitFallWareCount = packTaskResult.Data.WaitFallWareCount?.ToString();
WaitCompleted = packTaskResult.Data.WaitCompleted?.ToString();
}));
2 years ago
}
2 years ago
}
2 years ago
private void LoadIndex(int pageIndex)
2 years ago
{
2 years ago
PageIndex = pageIndex;//
SearchTaskList();
2 years ago
}
2 years ago
#region 事件绑定
/// <summary>
/// 筛选数据
/// </summary>
public ICommand SetTaskStateCommand { get; set; }
/// <summary>
/// 搜索数据
/// </summary>
public ICommand SearchTaskCommand { get; set; }
2 years ago
2 years ago
/// <summary>
/// 创建任务
/// </summary>
public ICommand CreateTaskCommand { get; set; }
2 years ago
2 years ago
/// <summary>
/// 页面改变事件
/// </summary>
public ICommand TaskPageIndexChangedCommand { get; set; }
2 years ago
2 years ago
/// <summary>
/// 打开图片链接
/// </summary>
public ICommand OpenSkuDetailCommand { get; set; }
2 years ago
2 years ago
/// <summary>
2 years ago
/// 删除任务
2 years ago
/// </summary>
2 years ago
public ICommand DeletedTaskCommand { get; set; }
2 years ago
2 years ago
public void SetTaskState(TaskState? taskState)
2 years ago
{
2 years ago
PageIndex = 1;
2 years ago
TaskState = taskState;
SearchTaskList();
2 years ago
}
2 years ago
2 years ago
private ConsumableService consumableService;
private IncreateServiceService increateServiceService;
2 years ago
public void ReflashTask()//刷新界面
{
SearchTaskList();
}
2 years ago
/// <summary>
/// 搜索任务列表
/// </summary>
public void SearchTaskList()
2 years ago
{
2 years ago
try
{
if (SearchTaskId != null && !string.IsNullOrEmpty(SearchTaskId.Trim()))
Convert.ToInt64(SearchTaskId);
}
catch
{
System.Windows.MessageBox.Show("任务id必须为数字");
return;
}
2 years ago
IsLoading = true;
Task.Factory.StartNew(() =>
2 years ago
{
2 years ago
try
2 years ago
{
2 years ago
PackTaskList = new ObservableCollection<PackTaskModel>();//初始化数据
2 years ago
var datas = packTaskService.GetTaskList(SearchSkuId, SearchTaskId, StartTime, EndTime, (this.TaskState),
2 years ago
PageIndex, PageSize);
if (datas != null && datas.Data != null && datas.Success)
2 years ago
{
2 years ago
var dataModel = datas.Data;
OrderCount = dataModel.TotalCount;
foreach (var item in dataModel.Items)
2 years ago
{
2 years ago
2 years ago
var data = new PackTaskModel()
2 years ago
{
Brand = item.Brand,
SkuId = item.SkuId,
AcceptName = item.UserName,
2 years ago
Availability = (Availability)item.Availability,
2 years ago
BasicPack = (BasicPack)item.BasicPack,
DepartmentName = item.DepartmentName,
CertificatePosition = (CertificatePosition)item.CertificatePosition,
GoodsNumber = item.GoodsNumber,
Increment1 = item.Increment1,
ItemList = new List<SkuMessage>() { new SkuMessage
2 years ago
{ BrandName = item.BrandName,
GoodsNo = item.ProductItemNum, Logo= item.Logo,
2 years ago
ShopName = item.ShopName, SkuName = item.SkuName,
Id = item.SkuId
2 years ago
} },
2 years ago
MarkMessage = item.MarkMessage,
PackType = (PackType)item.PackType,
2 years ago
PositionType = item.PositionType,
2 years ago
SkuCount = item.SkuCount,
SkuTitle = item.SkuGoodsTitle,
TaskId = item.TaskId,
2 years ago
2 years ago
EndTime = item.CreateTime,
2 years ago
BrandName = item.BrandName,
OrderId = item.OrderId,
TaskState = item.TaskState,
// IsWorry = (Worry)item.IsWorry,
2 years ago
};
if (item.BarCodeDTO != null && item.BarCodeDTO.Id > 0)
{
data.BarCodeModel = item.BarCodeDTO;
}
2 years ago
if (item.Cers != null)
2 years ago
{
2 years ago
data.CertificateModel = item.Cers;
2 years ago
}
if (item.FeesItemResponse != null)
{
data.FeesItemResponse = item.FeesItemResponse;
data.FeesMoney = item.FeesItemResponse.SingleFees;
data.IsShowFees = data.FeesMoney > 0 ? true : false;
2 years ago
data.FeesItemResponse.DiscountSingleFees = item.FeesItemResponse.SingleFees * item.FeesItemResponse.disCount;
2 years ago
data.FeesItemResponse.DiscountAllFees = item.FeesItemResponse.AllFees * item.FeesItemResponse.disCount;
2 years ago
}
else
{
data.IsShowFees = false;
}
if (item.PackUserName != null && item.PackUserName.Count() > 0)
{
data.PackUser = string.Join("\r\n", item.PackUserName);
}
data.ReflashTask = ReflashTask;
App.Current.Dispatcher.BeginInvoke(new Action(() =>
{
PackTaskList.Add(data);
}));
2 years ago
}
2 years ago
2 years ago
}
2 years ago
else
{
MessageBox.Show("查不到数据");
2 years ago
2 years ago
}
IsLoadCount();
2 years ago
}
2 years ago
catch (Exception ex)
2 years ago
{
2 years ago
2 years ago
}
IsLoading = false;
});
2 years ago
}
2 years ago
GlobalContext globalContext;
ProductService productService;
2 years ago
2 years ago
/// <summary>
/// 展示发布任务页面
/// </summary>
public void CreateTask()
2 years ago
{
2 years ago
ViewModelLocator viewModel = new ViewModelLocator();
2 years ago
var publicTaskViewModel = viewModel.PublishTask;
if (publicTaskViewModel.ReflashWindow == null)
publicTaskViewModel.ReflashWindow = ReflashTask;
publicTaskViewModel.InitData();
PublishTaskWindow publish = new PublishTaskWindow();
publish.Show();
2 years ago
}
2 years ago
/// <summary>
/// 弹出条形码可视化界面
/// </summary>
public void ShowBarCodeWindow()
2 years ago
{
}
2 years ago
/// <summary>
/// 弹出合格证 可视化页面
/// </summary>
public void ShowCertificateWindow()
2 years ago
{
}
2 years ago
/// <summary>
/// 筛选任务状态数据(根据TaskList数据)
/// </summary>
public void SelectTaskStatus() { }
#endregion
2 years ago
private void OpenSkuDetail(object param)
{
var paramList = (object[])param;
// var orderId = paramList[0].ToString();
var skuId = paramList[1].ToString();
var url = $"https://item.jd.com/{skuId}.html";
try
{
System.Diagnostics.Process.Start("explorer.exe", url);
}
catch (Exception ex)
{
Clipboard.SetText(url);
MessageBox.Show($"{ex.Message}\r\n调用浏览器失败,网页链接已复制到剪切板,请手动打开浏览器访问", "提示");
}
}
2 years ago
2 years ago
}
}