using BBWY.Client.APIServices;
using BBWY.Client.Models.APIModel.Response.PackTask;
using BBWY.Client.ViewModels;
using BBWY.Client.Views.PackTask;
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Input;
namespace BBWY.Client.Models
{
///
/// 打包任务 数据绑定
///
public class PackTaskModel : BaseVM
{
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); } }
private readonly PackTaskService packTaskService;
WorkProcessService workProcessService;
public ICommand SetTaskStatusCommand { get; set; }
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; }
IncreateServiceService increateServiceService;
public ConsumableService consumableService;
public PackTaskModel(PackTaskService packTaskService, ConsumableService consumableService, WorkProcessService workProcessService, IncreateServiceService increateServiceService)
{
SetTaskStatusCommand = new RelayCommand(SetTaskStatus);
PrintBarcodeCommand = new RelayCommand(PrintBarcode);
PrintCerCommand = new RelayCommand(PrintCer);
LookBarCommand = new RelayCommand(LookBar);
LookCerCommand = new RelayCommand(LookCer);
SetServiceCommand = new RelayCommand(SetService);
this.packTaskService = packTaskService;
this.consumableService = consumableService;
this.workProcessService = workProcessService;
this.increateServiceService = increateServiceService;
}
private void SetService()
{
//加载数据
ServiceWindow service = new ServiceWindow(packTaskService, TaskId, SkuCount, consumableService, workProcessService, increateServiceService);//设置
service.model.SetAllFees = new Action>((feesItem, packUsers) =>
{
FeesItemResponse = feesItem;
PackUser = string.Join("\r\n", packUsers);
IsShowFees = feesItem.AllFees > 0 ? true : false;
});
service.Show();
}
///
/// 查看合格证
///
private void LookCer()
{
if (CertificateModel == null)
{
new TipsWindow("该任务无设置合格证信息,无法查看!").ShowDialog();
return;
}
LookCerWindow lookCerWindow = new LookCerWindow(CertificateModel);
lookCerWindow.Show();
}
///
/// 查看条形码
///
private void LookBar()
{
if (BarCodeModel == null)
{
new TipsWindow("该任务无设置条形码信息,无法查看!").ShowDialog();
return;
}
LookBarCodeWindow look = new LookBarCodeWindow(new BarCodeModel
{
Brand = BarCodeModel.Brand,
BrandName = BarCodeModel.BrandName,
LabelModel = BarCodeModel.LabelModel,
ProductNo = BarCodeModel.ProductNo,
SkuId = BarCodeModel.SkuId,
SkuName = BarCodeModel.SkuName
});
look.Show();
}
private void PrintCer()
{
if (CertificateModel == null)
{
new TipsWindow("该任务无设置合格证信息,无法打印!").ShowDialog();
return;
}
PrintWindow printWindow = new PrintWindow();
printWindow.LabelName = CertificateModel.LabelModel.ToString();//加载模板信息
printWindow.certificateModel = certificateModel;
printWindow.LoadData();
printWindow.Datas = LoadCerLabelModels();
printWindow.Show();
}
///
/// 打印条形码
///
private void PrintBarcode()
{
if (BarCodeModel == null)
{
new TipsWindow("该任务无设置条形码信息,无法打印!").ShowDialog();
return;
}
PrintWindow printWindow = new PrintWindow();
printWindow.LabelName = BarCodeModel.LabelModel.ToString();//加载模板信息
printWindow.barCodeModel = new BarCodeModel
{
Brand = BarCodeModel.Brand,
BrandName = BarCodeModel.BrandName,
LabelModel = BarCodeModel.LabelModel,
ProductNo = BarCodeModel.ProductNo,
SkuId = BarCodeModel.SkuId,
SkuName = BarCodeModel.SkuName
};
printWindow.LoadData();
printWindow.Datas = LoadBarLabelModels();
printWindow.Show();
}
public void SetTaskStatus(long taskId)
{
if (this.TaskStatus == TaskStateType.已完成)
{
return;
}
///修改完成
var model = packTaskService.UpdateTaskStatus(taskId, 1);
if (model != null && model.Success)
{
this.TaskStatus = TaskStateType.已完成;
new TipsWindow("修改成功").Show();
}
}
public Dictionary LoadBarLabelModels()
{
Dictionary data = new Dictionary();
data.Add("pinming", $"品名: {BarCodeModel.BrandName}");
data.Add("guige", $"规格: {BarCodeModel.SkuName}");
data.Add("pop", $"POP{BarCodeModel.SkuId}");
switch (BarCodeModel.LabelModel)
{
case BarcodeLabelModel.barstander:
data.Add("pinpai", $"品牌: {BarCodeModel.Brand}");
data.Add("xinghao", $"型号: {BarCodeModel.ProductNo}");
return data;
case BarcodeLabelModel.barsimplify:
return data;
default:
break;
}
return data;
}
public Dictionary LoadCerLabelModels()
{
Dictionary data = new Dictionary();
data.Add("pinming", $"品名: {CertificateModel.BrandName}");
data.Add("pinpai", $"品牌: {CertificateModel.Brand}");
data.Add("xinghao", $"型号: {CertificateModel.ProductNo}");
data.Add("dizhi", $"地址: {CertificateModel.ProductAdress}");
data.Add("caizhi", $"材质: {CertificateModel.Shader}");
data.Add("changshang", $"生产商: {CertificateModel.ProductShop}");
switch (CertificateModel.IsLogo)
{
case 0://无图
data.Add("gongchangid", $"无");
break;
case 1://有图
data.Add("gongchangid", $"{CertificateModel.FactoryNumber}");
break;
default:
break;
}
string[] excutes = CertificateModel.ExcuteStander.Split(',', StringSplitOptions.RemoveEmptyEntries);
StringBuilder sb = new StringBuilder();
sb.Append("执行标准: ");
for (int i = 0; i < excutes.Count(); i++)
{
if (i % 2 == 0 && i > 0)//间隔两个换行
{
sb.Append("\r\n").Append(" ");
}
sb.Append(excutes[i]).Append(" ");
}
sb.Remove(sb.Length - 3, 3);
data.Add("biaozhun", sb.ToString());
return data;
}
private DateTime endTime;
///
/// 提交时间
///
public DateTime EndTime { get => endTime; set { Set(ref endTime, value); } }
private long taskId;
///
/// 绑定数据
///
public long TaskId { get => taskId; set { Set(ref taskId, value); } }
private string departmentName;
///
/// 部门名称
///
public string DepartmentName { get => departmentName; set { Set(ref departmentName, value); } }
private string acceptName;
///
/// 对接人
///
public string AcceptName { get => acceptName; set { Set(ref acceptName, value); } }
private int skuCount;
///
/// sku数量
///
public int SkuCount { get => skuCount; set { Set(ref skuCount, value); } }
private TaskState availability;
///
/// 到货情况(待收货=0,部分收货=1,已到货=2)
///
public TaskState Availability { get => availability; set { Set(ref availability, value); } }
private TaskStateType taskStatus;
///
/// 任务状态(未完成=0,已完成=1)
///
public TaskStateType TaskStatus { get => taskStatus; set { Set(ref taskStatus, value); } }
private PackType packType;
///
/// 打包类型(单件=0,多件=1)
///
public PackType PackType { get => packType; set { Set(ref packType, value); } }
private int goodsNumber;
///
/// 配件数
///
public int GoodsNumber { get => goodsNumber; set { Set(ref goodsNumber, value); } }
private string skuTitle;
///
/// sku配件商品名称
///
public string SkuTitle { get => skuTitle; set { Set(ref skuTitle, value); } }
private BasicPack basicPack;
///
/// 基础包装(快递袋=0,纸箱=1,麻袋=2)
///
public BasicPack BasicPack { get => basicPack; set { Set(ref basicPack, value); } }
private string increment1;
///
/// 增量1()
///
public string Increment1 { get => increment1; set { Set(ref increment1, value); } }
private Increment increment2;
///
/// 增量2()
///
public Increment Increment2 { get => increment2; set { Set(ref increment2, value); } }
private PositionType positionType;
///
/// 落仓(本地仓=0,齐越仓=1,京东仓=2)
///
public PositionType PositionType { get => positionType; set { Set(ref positionType, value); } }
#region 条形码数据
///
/// 条形码id
///
public long BarCodeId { get; set; }
///
/// 标签模板
///
public BarcodeLabelModel LabelModel { get; set; }
private string brand;
///
/// 品牌
///
public string Brand { get => brand; set { Set(ref brand, value); } }
private string brandName;
///
/// 品名
///
public string BrandName { get => brandName; set { Set(ref brandName, value); } }
private string producNo;
///
/// 货号
///
public string ProductNo { get => producNo; set { Set(ref producNo, value); } }
private string skuName;
///
/// sku名称
///
public string SkuName { get => skuName; set { Set(ref skuName, value); } }
private string skuId;
///
/// skuId(条形码号=POP+SkuId)
///
public string SkuId { get => skuId; set { Set(ref skuId, value); } }
private string modelNo;
///
/// 型号
///
public string ModelNo { get => modelNo; set { Set(ref modelNo, value); } }
#endregion
private BarCodeModel barCodeModel;
///
/// 合格证
///
public BarCodeModel BarCodeModel { get => barCodeModel; set { Set(ref barCodeModel, value); } }
private CertificateModel certificateModel;
///
/// 合格证
///
public CertificateModel CertificateModel { get => certificateModel; set { Set(ref certificateModel, value); } }
///
/// 合格证位置(外部包装=0,产品包装=1)
///
private CertificatePosition certificatePosition;
///
/// 合格证位置(外部包装=0,产品包装=1)
///
public CertificatePosition CertificatePosition { get => certificatePosition; set { Set(ref certificatePosition, value); } }
///
/// 注意事项(对接备注)
///
private string markMessage;
///
/// 注意事项(对接备注)
///
public string MarkMessage { get => markMessage; set { Set(ref markMessage, value); } }
///
/// 服务收费 (单个任务id 消耗的总费用)
///
private decimal feesMoney;
///
/// 服务收费 (单个任务id 消耗的总费用)
///
public decimal FeesMoney { get => feesMoney; set { Set(ref feesMoney, value); } }
///
/// 打包员
///
private string packUser;
///
/// 打包员
///
public string PackUser { get => packUser; set { Set(ref packUser, value); } }
//public FeesItemTypeDTO FeesItemTypeDTO { get; set; }
private FeesItemResponse feesItemResponse;
public FeesItemResponse FeesItemResponse { get => feesItemResponse; set { Set(ref feesItemResponse, value); } }
public IList ItemList { get; set; }
}
public class SkuMessage : NotifyObject
{
private long id;
public long Id { get => id; set { Set(ref id, value); } }
///
/// 店铺Sku图链接
///
private string logo;
///
/// 店铺Sku图链接
///
public string Logo { get => logo; set { Set(ref logo, value); } }
///
/// 采购Sku名称
///
private string skuName;
///
/// 采购Sku名称
///
public string SkuName { get => skuName; set { Set(ref skuName, value); } }
///
/// 货号品名(手写上传)
///
private string brandName;
///
/// 货号品名(手写上传)
///
public string BrandName { get => brandName; set { Set(ref brandName, value); } }
///
/// 需求方店铺id
///
private string shopName;
///
/// 需求方店铺id
///
public string ShopName { get => shopName; set { Set(ref shopName, value); } }
///
/// 货号
///
private string goodsNo;
///
/// 货号
///
public string GoodsNo { get => goodsNo; set { Set(ref goodsNo, value); } }
}
}