步步为盈
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.

589 lines
20 KiB

2 years ago
using BBWY.Client.APIServices;
using BBWY.Client.Models.PackTask;
2 years ago
using BBWY.Client.ViewModels;
using BBWY.Client.Views.PackTask;
2 years ago
using BBWY.Common.Models;
2 years ago
using GalaSoft.MvvmLight.Command;
2 years ago
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
2 years ago
using System.Windows.Controls;
using System.Windows.Input;
2 years ago
namespace BBWY.Client.Models
{
2 years ago
//public class ComboxItem
//{
// public int { get; set; }
//}
2 years ago
public class BatchPublishTask : NotifyObject
{
#region 属性
2 years ago
//private bool isSelected;
//public bool IsSelected { get => isSelected; set { Set(ref isSelected, value); } }
2 years ago
2 years ago
private ObservableCollection<string> worryList = new ObservableCollection<string> {
"否","是"
};
public ObservableCollection<string> WorryList { get => worryList; set { Set(ref worryList, value); } }
2 years ago
2 years ago
private ObservableCollection<string> positionTypeList = new ObservableCollection<string> {
"商家仓","云仓", "京仓","聚水潭"};
2 years ago
public ObservableCollection<string> PositionTypeList { get => positionTypeList; set { Set(ref positionTypeList, value); } }
private ObservableCollection<string> packTypeList = new ObservableCollection<string> {
"单件","多件"
2 years ago
};
2 years ago
public ObservableCollection<string> PackTypeList { get => packTypeList; set { Set(ref packTypeList, value); } }
2 years ago
2 years ago
private ObservableCollection<string> basicPackList = new ObservableCollection<string> {
"快递袋","纸箱","麻袋"
2 years ago
};
2 years ago
public ObservableCollection<string> BasicPackList { get => basicPackList; set { Set(ref basicPackList, value); } }
private ObservableCollection<string> isNeedBarCodeList = new ObservableCollection<string> {
"需要", "不需要" };
public ObservableCollection<string> IsNeedBarCodeList { get => isNeedBarCodeList; set { Set(ref isNeedBarCodeList, value); } }
2 years ago
2 years ago
private ObservableCollection<string> isNeedCertificateList = new ObservableCollection<string> {
"需要", "不需要" };
public ObservableCollection<string> IsNeedCertificateList { get => isNeedCertificateList; set { Set(ref isNeedCertificateList, value); } }
2 years ago
private ObservableCollection<string> certificatePositionList = new ObservableCollection<string> {
2 years ago
"无需合格证","外部包装","产品包装"
2 years ago
};
2 years ago
public ObservableCollection<string> CertificatePositionList { get => certificatePositionList; set { Set(ref certificatePositionList, value); } }
2 years ago
//private ObservableCollection<string> availabilityList = new ObservableCollection<string> {
// "已到货","部分到货","未到货"
// };
//public ObservableCollection<string> AvailabilityList { get => availabilityList; set { Set(ref availabilityList, value); } }
2 years ago
private int skuCount;
/// <summary>
/// Sku任务数
/// </summary>
public int SkuCount { get => skuCount; set { Set(ref skuCount, value); } }
private string skuId;
/// <summary>
/// Sku
/// </summary>
public string SkuId { get => skuId; set { Set(ref skuId, value); } }
private string logo;
/// <summary>
/// 店铺Sku图链接
/// </summary>
public string Logo { get => logo; set { Set(ref logo, value); } }
private string skuName;
/// <summary>
/// 采购Sku名称
/// </summary>
public string SkuName { get => skuName; set { Set(ref skuName, value); } }
private string brand;
/// <summary>
/// 品牌
/// </summary>
public string Brand { get => brand; set { Set(ref brand, value); } }
private string productNo;
/// <summary>
/// 货号
/// </summary>
public string ProductNo { get => productNo; set { Set(ref productNo, value); } }
private string brandName;
/// <summary>
/// 品名(手写上传)
/// </summary>
public string BrandName { get => brandName; set { Set(ref brandName, value); } }
private int goodsNumber;
/// <summary>
/// 配件数
/// </summary>
public int GoodsNumber { get => goodsNumber; set { Set(ref goodsNumber, value); } }
//private Worry isWorry;
///// <summary>
///// 是否加急
///// </summary>
//public Worry IsWorry { get => isWorry; set { Set(ref isWorry, value); } }
2 years ago
2 years ago
//private Availability availability;
///// <summary>
///// 到货情况(待收货=0,部分收货=1,已到货=2)
///// </summary>
//public Availability Availability { get => availability; set { Set(ref availability, value); } }
2 years ago
private PackType packType;
/// <summary>
/// 打包类型(单件=0,多件=1)
/// </summary>
public PackType PackType { get => packType; set { Set(ref packType, value); } }
private BasicPack basicPack;
/// <summary>
/// 基础包装(快递袋=0,纸箱=1,麻袋=2)
/// </summary>
public BasicPack BasicPack { get => basicPack; set { Set(ref basicPack, value); } }
private PositionType positionType;
/// <summary>
2 years ago
/// 落仓(本地仓=0,云仓=1,京仓=2)
2 years ago
/// </summary>
public PositionType PositionType { get => positionType; set { Set(ref positionType, value); } }
private string skuTitle;
/// <summary>
/// sku配件商品名称
/// </summary>
public string SkuTitle { get => skuTitle; set { Set(ref skuTitle, value); } }
private Need isNeedBarCode;
/// <summary>
/// 是否需要合格证
/// </summary>
public Need IsNeedBarCode { get => isNeedBarCode; set { Set(ref isNeedBarCode, value); } }
private Need isNeedCertificateModel;
/// <summary>
/// 是否需要条形码
/// </summary>
public Need IsNeedCertificateModel { get => isNeedCertificateModel; set { Set(ref isNeedCertificateModel, value); } }
private BarCodeModel barCodeModel;
/// <summary>
/// 条形码
/// </summary>
public BarCodeModel BarCodeModel { get => barCodeModel; set { Set(ref barCodeModel, value); } }
private bool isSetBarCode;
/// <summary>
/// 设置显示(条形码)
/// </summary>
public bool IsSetBarCode
{
2 years ago
get => isSetBarCode;
set
2 years ago
{
Set(ref isSetBarCode, value);
2 years ago
//IsNeedBarCode = IsSetBarCode ? Need.不需要 : Need.需要;
2 years ago
}
}
private bool isSetCertificate;
/// <summary>
/// 设置显示(合格证)
/// </summary>
public bool IsSetCertificate
{
get => isSetCertificate; set
{
Set(ref isSetCertificate, value);
2 years ago
// IsNeedCertificateModel = IsSetCertificate ? Need.不需要 : Need.需要;
2 years ago
}
}
private string setSpuCerStatus;
public string SetSpuCerStatus { get => setSpuCerStatus; set { Set(ref setSpuCerStatus, value); } }
private bool isSetSpuCertificate = true;
/// <summary>
/// 设置spu显示(合格证)
/// </summary>
public bool IsSetSpuCertificate
{
get => isSetSpuCertificate; set
{
Set(ref isSetSpuCertificate, value);
SetSpuCerStatus = IsSetSpuCertificate ? "设置spu模板" : "修改spu模板";
}
}
private string saveTask;
/// <summary>
/// 设置显示(合格证)
/// </summary>
public string SaveTask { get => saveTask; set { Set(ref saveTask, value); } }
private string spuId;
/// <summary>
/// 合格证
/// </summary>
public string SpuId { get => spuId; set { Set(ref spuId, value); } }
private CertificateModel spuCertificateModel;
/// <summary>
/// spu合格证
/// </summary>
public CertificateModel SpuCertificateModel { get => spuCertificateModel; set { Set(ref spuCertificateModel, value); } }
2 years ago
private CertificateModel[] certificateModel;
2 years ago
/// <summary>
/// 合格证
/// </summary>
2 years ago
public CertificateModel[] CertificateModel { get => certificateModel; set { Set(ref certificateModel, value); } }
2 years ago
/// <summary>
/// 合格证位置(外部包装=0,产品包装=1)
/// </summary>
private CertificatePosition certificatePosition;
/// <summary>
/// 合格证位置(外部包装=0,产品包装=1)
/// </summary>
public CertificatePosition CertificatePosition { get => certificatePosition; set { Set(ref certificatePosition, value); } }
/// <summary>
/// 注意事项(对接备注)
/// </summary>
private string markMessage;
/// <summary>
/// 注意事项(对接备注)
/// </summary>
public string MarkMessage { get => markMessage; set { Set(ref markMessage, value); } }
private ObservableCollection<IncreateModel> increateList;
/// <summary>
/// 增量耗材查询关键字
/// </summary>
public ObservableCollection<IncreateModel> IncreateList { get => increateList; set { Set(ref increateList, value); } }
#endregion
string[] increates = new string[] { "气泡纸", "气泡袋", "POP袋", "折纸箱", "气泡纸封边", "彩盒", "剪胶", "剪彩带", "快递袋", "收纳盒", "纸箱子", "装纸箱", "封边", "胶带", "折彩盒" };
public PackTaskService packTaskService;
public ProductService productService;
public BatchPublishTask()
{
2 years ago
IncreateList = new ObservableCollection<IncreateModel>();
foreach (var item in increates)
{
IncreateList.Add(new IncreateModel
{
IncreateName = item,
IsSelected = false
});
}
SetBarCodeCommand = new RelayCommand(SetBarCode);
SetCertificateCommand = new RelayCommand(SetCertificate);
LookBarCommand = new RelayCommand(LookBar);
LookCerCommand = new RelayCommand(LookCer);
2 years ago
2 years ago
}
#region 方法
2 years ago
public ICommand SetBarCodeCommand { get; set; }
public ICommand SetCertificateCommand { get; set; }
public ICommand LookBarCommand { get; set; }
public ICommand LookCerCommand { get; set; }
private void SetBarCode()
{
if (string.IsNullOrEmpty(SkuId))
{
return;
}
if (BarCodeModel == null)
{
BarCodeModel = new BarCodeModel();
BarCodeModel.ProductNo = ProductNo;
BarCodeModel.Brand = Brand;
BarCodeModel.SkuId = SkuId;
BarCodeModel.SkuName = SkuName;
}
if (!string.IsNullOrEmpty(BrandName))
BarCodeModel.BrandName = BrandName;
SetBarCodeWindow setBarCodeWindow = new SetBarCodeWindow();
setBarCodeWindow.LoadData(BarCodeModel, packTaskService);
setBarCodeWindow.SaveResult = b =>
{
BarCodeModel = b;
IsSetBarCode = false;
IsNeedBarCode = Need.;
};
setBarCodeWindow.Show();
}
/// <summary>
/// 设置合格证
/// </summary>
private void SetCertificate()
{
if (string.IsNullOrEmpty(SkuId))
return;
SearSpuCer();
if (CertificateModel == null)
{
2 years ago
CertificateModel = new CertificateModel[] {
new CertificateModel{
ProductNo = ProductNo,
Brand = Brand,
SkuId = SkuId
}
};
2 years ago
}
if (!string.IsNullOrEmpty(BrandName))
2 years ago
foreach (var item in CertificateModel) item.BrandName = BrandName;
2 years ago
SetCerWindow setCerWindow = new SetCerWindow();
setCerWindow.LoadData(CertificateModel, packTaskService, spuCertificateModel, IsSetSpuCertificate, SaveType.B端);
2 years ago
setCerWindow.SaveResult = s =>
{
CertificateModel = s;
IsSetCertificate = false;
IsNeedCertificateModel = Need.;
};
setCerWindow.Show();
}
/// <summary>
/// 查看合格证
/// </summary>
private void LookCer()
{
LookCerWindow lookCerWindow = new LookCerWindow(CertificateModel);
lookCerWindow.Show();
}
/// <summary>
/// 查看条形码
/// </summary>
private void LookBar()
{
LookBarCodeWindow look = new LookBarCodeWindow();
look.SetData(BarCodeModel);
look.Show();
}
2 years ago
/// <summary>
/// 搜索 skuId
/// </summary>
public void SearchSku(string skuid)
{
if (string.IsNullOrEmpty(skuid))
return;
ApiResponse<ProductListResponse> productApiResponse = null;
var skuResponse = productService.GetProductSkuList(string.Empty, skuid);
if (skuResponse.Success)
{
if (skuResponse.Data.Count == 0)
{
return;
}
2 years ago
Logo = skuResponse.Data[0].Logo.Replace("80x80", "200x200");
2 years ago
SkuName = skuResponse.Data[0].Title;
2 years ago
2 years ago
SpuId = skuResponse.Data[0].ProductId;
productApiResponse = productService.GetProductList(skuResponse.Data[0].ProductId, string.Empty, string.Empty, 1);
if (productApiResponse.Success)
{
if (productApiResponse.Data.Count == 0)
{
return;
}
ProductNo = productApiResponse.Data.Items[0].ProductItemNum;
Brand = productApiResponse.Data.Items[0].BrandName;
}
2 years ago
var productSku = packTaskService.SearchProduct(skuid);
2 years ago
if (productSku == null || !productSku.Success)
{
return;
}
BrandName = productSku.Data.BrandName;
2 years ago
CertificateModel = productSku.Data.Cers;
2 years ago
IsSetCertificate = false;
if (CertificateModel == null)
{
2 years ago
CertificateModel = new CertificateModel[] {
new CertificateModel{ }
};
2 years ago
IsSetCertificate = true;
}
2 years ago
foreach (var item in CertificateModel)
{
item.Brand = Brand;
if (!string.IsNullOrEmpty(BrandName))
item.BrandName = BrandName;
item.ProductNo = ProductNo;
item.SkuId = skuid;
}
2 years ago
BarCodeModel = productSku.Data.BarCodeModel;
IsSetBarCode = false;
if (BarCodeModel == null)
{
BarCodeModel = new BarCodeModel();
IsSetBarCode = true;
}
2 years ago
if (BarCodeModel.LabelModel== BarcodeLabelModel.)
{
BarCodeModel.LabelModel = BarcodeLabelModel.;
}
2 years ago
BarCodeModel.Brand = Brand;
2 years ago
if (!string.IsNullOrEmpty(BrandName))
BarCodeModel.BrandName = BrandName;
2 years ago
BarCodeModel.ProductNo = ProductNo;
BarCodeModel.SkuId = skuid;
BarCodeModel.SkuName = SkuName;
2 years ago
IsNeedBarCode = Need.;
IsSetBarCode = true;
IsSetCertificate = true;
if (productSku.Data.PackConfig != null)
{
var config = productSku.Data.PackConfig;
SkuTitle = config.SkuGoodsTitle;
GoodsNumber = config.GoodsNumber;
PackType = (PackType)config.PackType;
BasicPack = (BasicPack)config.BasicPack;
2 years ago
// Availability = (Availability)config.Availability;
2 years ago
MarkMessage = config.MarkMessage;
2 years ago
CertificatePosition = config.CertificatePosition == null ? CertificatePosition. : (CertificatePosition)config.CertificatePosition.Value;
2 years ago
// Increment1 = config.Increment1;
string[] increateDatas = config.Increment1.Split(',');
IsNeedBarCode = config.NeedBar ? Need. : Need.;
IsNeedCertificateModel = config.NeedCer ? Need. : Need.;
IsSetBarCode = !config.NeedBar;
IsSetCertificate = !config.NeedCer;
bool isSelected = false;
foreach (var item in increates)
{
isSelected = false;
if (increateDatas.Contains(item))
{
isSelected = true;
}
App.Current.Dispatcher.Invoke(() =>
{
IncreateList.Add(new IncreateModel
{
IncreateName = item,
IsSelected = isSelected
});
});
}
}
2 years ago
}
else
{
App.Current.Dispatcher.Invoke(() => MessageBox.Show(skuResponse.Msg, "加载sku"));
return;
}
2 years ago
2 years ago
}
2 years ago
public void SearSpuCer()
{
if (string.IsNullOrEmpty(SpuId))
{
SearchSku(SkuId);
return;
}
SpuId = SpuId.Trim();//去掉空格 避免数据异常
var productSku = packTaskService.GetSpuCer(SpuId);
if (productSku == null || !productSku.Success)
{
IsSetSpuCertificate = true;
return;
}
SpuCertificateModel = productSku.Data;
IsSetSpuCertificate = false;
if (SpuCertificateModel == null)
{
SpuCertificateModel = new CertificateModel();
IsSetSpuCertificate = true;
SpuCertificateModel.Brand = Brand;
SpuCertificateModel.BrandName = BrandName;
SpuCertificateModel.ProductNo = ProductNo;
SpuCertificateModel.SpuId = SpuId;
}
}
2 years ago
public void InitData()
{
IncreateList = new ObservableCollection<IncreateModel>();
SpuId = string.Empty;
SaveTask = "发布";
Logo = string.Empty;
SkuId = "";
SkuCount = 0;
SkuName = string.Empty;
ProductNo = string.Empty;
Brand = string.Empty;
BrandName = string.Empty;
this.MarkMessage = "";
IsSetBarCode = true;
IsSetCertificate = true;
BarCodeModel = null;
CertificateModel = null;
SkuTitle = string.Empty;
GoodsNumber = 0;
foreach (var item in increates)
{
IncreateList.Add(new IncreateModel
{
IncreateName = item,
IsSelected = false
});
}
//SearchSku(SkuId);
}
#endregion
}
}