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

1004 lines
34 KiB

2 years ago
using BarcodeLib;
using BBWY.Client.APIServices;
2 years ago
using BBWY.Client.Extensions;
2 years ago
using BBWY.Client.Helpers;
using BBWY.Client.Models;
using BBWY.Client.Models.APIModel.Request;
using BBWY.Client.Models.PackTask;
using BBWY.Client.Views.PackTask;
using BBWY.Common.Models;
using BBWY.Common.Trigger;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
2 years ago
2 years ago
namespace BBWY.Client.ViewModels.PackTask
{
public class CreatePackTaskViewModel : BaseVM, IDenpendency
2 years ago
{
2 years ago
#region 属性
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); } }
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> {
"单件","多件"
};
public ObservableCollection<string> PackTypeList { get => packTypeList; set { Set(ref packTypeList, value); } }
private ObservableCollection<string> basicPackList = new ObservableCollection<string> {
"快递袋","纸箱","麻袋"
};
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); } }
private ObservableCollection<string> certificatePositionList = new ObservableCollection<string> {
"无","外部包装","产品包装"
};
public ObservableCollection<string> CertificatePositionList { get => certificatePositionList; set { Set(ref certificatePositionList, value); } }
private ObservableCollection<string> availabilityList = new ObservableCollection<string> {
"已到货","部分到货","未到货"
};
public ObservableCollection<string> AvailabilityList { get => availabilityList; set { Set(ref availabilityList, value); } }
2 years ago
private bool isLoading = false;
public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } }
2 years ago
private DelayTrigger delayTrigger;
private string searchIncrementKeyWord;
/// <summary>
/// 增量耗材查询关键字
/// </summary>
public string SearchIncrementKeyWord
{
get => searchIncrementKeyWord; set
{
if (Set(ref searchIncrementKeyWord, value))
{
delayTrigger.SetKey(value);
}
}
}
private ObservableCollection<IncreateModel> increateList;
/// <summary>
/// 增量耗材查询关键字
/// </summary>
public ObservableCollection<IncreateModel> IncreateList { get => increateList; set { Set(ref increateList, value); } }
private string searchSkuId;
/// <summary>
/// skuId
/// </summary>
public string SearchSkuId { get => searchSkuId; set { Set(ref searchSkuId, value); } }
/// <summary>
/// 店铺Sku图链接
/// </summary>
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 brandName;
/// <summary>
/// 品名(手写上传)
/// </summary>
public string BrandName { get => brandName; set { Set(ref brandName, value); } }
/// <summary>
/// 需求方店铺id
/// </summary>
private string shopName;
/// <summary>
/// 需求方店铺id
/// </summary>
public string ShopName { get => shopName; set { Set(ref shopName, value); } }
private string modelNo;
/// <summary>
/// 货号
/// </summary>
public string ModelNo { get => modelNo; set { Set(ref modelNo, value); } }
/// <summary>
/// 货号
/// </summary>
private string productNo;
/// <summary>
/// 货号
/// </summary>
public string ProductNo { get => productNo; set { Set(ref productNo, value); } }
private int goodsNumber;
/// <summary>
/// 配件数
/// </summary>
public int GoodsNumber { get => goodsNumber; set { Set(ref goodsNumber, value); } }
private long taskId;
/// <summary>
/// 绑定数据
/// </summary>
public long TaskId { get => taskId; set { Set(ref taskId, value); } }
private string departmentName;
/// <summary>
/// 部门名称
/// </summary>
public string DepartmentName { get => departmentName; set { Set(ref departmentName, value); } }
private string acceptName;
/// <summary>
/// 对接人
/// </summary>
public string AcceptName { get => acceptName; set { Set(ref acceptName, value); } }
private int skuCount;
/// <summary>
/// sku数量
/// </summary>
public int SkuCount { get => skuCount; set { Set(ref skuCount, value); } }
2 years ago
private Availability availability;
2 years ago
/// <summary>
/// 到货情况(待收货=0,部分收货=1,已到货=2)
/// </summary>
2 years ago
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 string skuTitle;
/// <summary>
/// sku配件商品名称
/// </summary>
public string SkuTitle { get => skuTitle; set { Set(ref skuTitle, 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); } }
2 years ago
private Need isNeedBarCode;
2 years ago
/// <summary>
/// 是否需要合格证
/// </summary>
2 years ago
public Need IsNeedBarCode { get => isNeedBarCode; set { Set(ref isNeedBarCode, value); } }
2 years ago
2 years ago
private Need isNeedCertificateModel;
2 years ago
/// <summary>
/// 是否需要条形码
/// </summary>
2 years ago
public Need IsNeedCertificateModel { get => isNeedCertificateModel; set { Set(ref isNeedCertificateModel, value); } }
2 years ago
private BarCodeModel barCodeModel;
/// <summary>
/// 条形码
/// </summary>
public BarCodeModel BarCodeModel { get => barCodeModel; set { Set(ref barCodeModel, value); } }
private bool isSetBarCode;
/// <summary>
/// 设置显示(条形码)
/// </summary>
public bool IsSetBarCode
{
get => isSetBarCode; set
{
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.;
}
}
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模板";
}
}
2 years ago
2 years ago
private string saveTask;
/// <summary>
2 years ago
/// 发布按钮(发布/保存)
2 years ago
/// </summary>
public string SaveTask { get => saveTask; set { Set(ref saveTask, value); } }
2 years ago
private string spuId;
/// <summary>
2 years ago
/// spu
/// </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
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); } }
2 years ago
#endregion
2 years ago
private readonly PackTaskService packTaskService;
private readonly GlobalContext globalContext;
private readonly ProductService productService;
private string AccepUserId = "";//对接人
public ICommand SetBarCodeCommand { get; set; }
public ICommand SetCertificateCommand { get; set; }
public ICommand SearchSkuCommand { get; set; }
public ICommand CreateTaskCommand { get; set; }
public ICommand SaveCerCommand { get; set; }
public ICommand SaveBarCodeCommand { get; set; }
public ICommand BarLabelCheckCommand { get; set; }
public ICommand CerLabelCheckCommand { get; set; }
public ICommand SpuCerLabelCheckCommand { get; set; }
2 years ago
public ICommand LookBarCommand { get; set; }
public ICommand LookCerCommand { get; set; }
public ICommand SetSpuCerCommand { get; set; }
public ICommand SaveSpuCerCommand { get; set; }
public ICommand InseartCerCommand { get; set; }
2 years ago
string[] increates = new string[] { "气泡纸", "气泡袋", "POP袋", "折纸箱", "气泡纸封边", "彩盒", "剪胶", "剪彩带", "快递袋", "收纳盒", "纸箱子", "装纸箱", "封边", "胶带", "折彩盒" };
2 years ago
public void InitData(PackTaskModel model = null)
2 years ago
{
2 years ago
2 years ago
IncreateList = new ObservableCollection<IncreateModel>();
SpuId = string.Empty;
2 years ago
if (model == null)
{
2 years ago
2 years ago
SaveTask = "发布";
TaskId = 0;
Logo = string.Empty;
SearchSkuId = "";
SkuId = "";
SkuCount = 0;
SkuName = string.Empty;
ProductNo = string.Empty;
Brand = string.Empty;
2 years ago
BrandName = string.Empty;
2 years ago
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
});
}
return;
}
SaveTask = "保存";
2 years ago
Logo = model.ItemList[0].Logo.Copy();
SearchSkuId = model.SkuId;
2 years ago
SkuId = model.SkuId;
SkuCount = model.SkuCount;
SkuName = model.ItemList[0].SkuName;
ProductNo = model.ItemList[0].GoodsNo;
Brand = model.Brand;
BrandName = model.ItemList[0].BrandName;
IsSetBarCode = model.BarCodeModel != null ? false : true;
IsSetCertificate = model.CertificateModel != null ? false : true;
2 years ago
BarCodeModel = model.BarCodeModel;
CertificateModel = model.CertificateModel;
SkuTitle = model.SkuTitle;
GoodsNumber = model.GoodsNumber;
Availability = model.Availability;
2 years ago
if (string.IsNullOrEmpty(model.OrderId))
{
PositionType = model.PositionType.ToEnum<PositionType>();
}
PackType = model.PackType;
2 years ago
BasicPack = model.BasicPack;
2 years ago
IsNeedBarCode = model.BarCodeModel == null ? Need. : Need.;
IsNeedCertificateModel = model.CertificateModel == null ? Need. : Need.;
2 years ago
CertificatePosition = model.CertificatePosition;
TaskId = model.TaskId;
string[] increateDatas = model.Increment1.Split(',');
2 years ago
bool isSelected = false;
foreach (var item in increates)
{
isSelected = false;
if (increateDatas.Contains(item))
{
isSelected = true;
}
2 years ago
App.Current.Dispatcher.Invoke(() =>
{
2 years ago
IncreateList.Add(new IncreateModel
{
IncreateName = item,
IsSelected = isSelected
});
2 years ago
});
}
SearchSku();
2 years ago
2 years ago
}
public CreatePackTaskViewModel(PackTaskService packTaskService, GlobalContext globalContext, ProductService productService)
{
2 years ago
Messenger.Default.Register<PackTaskModel>(this, "InitData", message =>
{
2 years ago
2 years ago
InitData(message);
2 years ago
});
this.productService = productService;
this.packTaskService = packTaskService;
AccepUserId = globalContext.User.Id.ToString();
IsSetBarCode = true;
IsSetCertificate = true;
//数据库获取增量耗材数据
2 years ago
2 years ago
IncreateList = new ObservableCollection<IncreateModel>();
foreach (var item in increates)
{
IncreateList.Add(new IncreateModel
{
IncreateName = item,
IsSelected = false
});
}
//查询sku
SearchSkuCommand = new RelayCommand(() =>
{
Task.Factory.StartNew(() => { SearchSku(); });
});
CreateTaskCommand = new RelayCommand<object>(CreateTask);
this.globalContext = globalContext;
SetBarCodeCommand = new RelayCommand(SetBarCode);
SetCertificateCommand = new RelayCommand(SetCertificate);
2 years ago
BarLabelCheckCommand = new RelayCommand<BarcodeLabelModel>(BarLabelCheck);
2 years ago
LookBarCommand = new RelayCommand(LookBar);
LookCerCommand = new RelayCommand(LookCer);
2 years ago
2 years ago
delayTrigger = new DelayTrigger(500);
delayTrigger.OnExecute = OnSearchIncreateKeyWordChanged;
2 years ago
BarLabelCheck(BarcodeLabelModel.);//默认精简模式
2 years ago
}
2 years ago
private void OnSearchIncreateKeyWordChanged(string key)
{
foreach (var s in this.IncreateList)
s.IsSelected = false;
App.Current.Dispatcher.Invoke(() =>
{
this.IncreateList.Clear();
string[] increates = new string[] { "气泡纸", "气泡袋", "POP袋", "折纸箱", "气泡纸封边", "彩盒", "剪胶", "剪彩带", "快递袋", "收纳盒", "纸箱子", "装纸箱", "封边", "胶带", "折彩盒" };
List<IncreateModel> keyWordShopList = new List<IncreateModel>();
foreach (var item in increates)
{
keyWordShopList.Add(new IncreateModel
{
IncreateName = item,
IsSelected = false
});
}
if (!string.IsNullOrEmpty(key.Trim()))
{
keyWordShopList = keyWordShopList.Where(s => s.IncreateName.Contains(key)).ToList();
}
if (keyWordShopList.Count() > 0)
{
foreach (var shop in keyWordShopList)
IncreateList.Add(shop);
}
});
}
/// <summary>
/// 查看合格证
/// </summary>
private void LookCer()
{
LookCerWindow lookCerWindow = new LookCerWindow(CertificateModel);
lookCerWindow.Show();
}
/// <summary>
/// 查看条形码
/// </summary>
private void LookBar()
{
LookBarCodeWindow look = new LookBarCodeWindow();
look.SetData(new BarCodeModel
2 years ago
{
Brand = BarCodeModel.Brand,
2 years ago
BrandName = BarCodeModel.BrandName,
LabelModel = BarCodeModel.LabelModel,
ProductNo = BarCodeModel.ProductNo,
SkuId = BarCodeModel.SkuId,
SkuName = BarCodeModel.SkuName
2 years ago
});
look.Show();
}
2 years ago
2 years ago
/// <summary>
///
/// </summary>
/// <param name="barcodeLabelModel"></param>
/// <exception cref="NotImplementedException"></exception>
private void BarLabelCheck(BarcodeLabelModel barcodeLabelModel)
{
LabelModel = barcodeLabelModel;
if (LabelModel == BarcodeLabelModel.)//标准版 判断数据是否异常
2 years ago
{
if (string.IsNullOrEmpty(ProductNo) || ProductNo == "待填写")
{
TipsWindow tips = new TipsWindow("该SKU无货号信息,将影响条形码打印\r\n请先设置好货号信息或调整打印模板类型");
tips.ShowDialog();
}
}
//throw new NotImplementedException();
}
2 years ago
/// <summary>
/// 保存合格证
/// </summary>
2 years ago
//private void SaveCer()
//{
// if (string.IsNullOrEmpty(CertificateModel.ExcuteStander)
// || string.IsNullOrEmpty(CertificateModel.Shader) || string.IsNullOrEmpty(CertificateModel.BrandName)
// || string.IsNullOrEmpty(CertificateModel.Brand) || string.IsNullOrEmpty(CertificateModel.ProductShop)
// || string.IsNullOrEmpty(CertificateModel.ProductAdress))
// {
// new TipsWindow("参数出错!请重新填写!").Show();
// return;
// }
// var resData = packTaskService.SaveCer(new CerRequest
// {
// Brand = CertificateModel.Brand,
// BrandName = CertificateModel.BrandName,
// ProductNo = CertificateModel.ProductNo,
// SkuId = CertificateModel.SkuId,
// ExcuteStander = CertificateModel.ExcuteStander.Replace(",", ","),
// LabelModel = (int)CertificateModel.LabelModel,
// FactoryNumber = CertificateModel.FactoryNumber,
// IsLogo = CertificateModel.IsLogo,
// ProductAdress = CertificateModel.ProductAdress,
// ProductShop = CertificateModel.ProductShop,
// Shader = CertificateModel.Shader,
// ApplyAge = CertificateModel.ApplyAge,
// });
// if (resData == null || !resData.Success)
// {
// IsSetCertificate = false;
// return;
// }
// IsNeedCertificateModel = Need.需要;
// CertificateModel.Id = resData.Data;
// IsSetCertificate = false;
// setCerWindow.Close();
//}
2 years ago
SetBarCodeWindow setBarCodeWindow = null; SetCerWindow setCerWindow = null; SetSpuCerWindow setSpuCerWindow = null;
2 years ago
public BarcodeLabelModel LabelModel = BarcodeLabelModel.;
2 years ago
private void SetBarCode()
{
2 years ago
if (string.IsNullOrEmpty(SkuId))
2 years ago
{
return;
}
2 years ago
if (BarCodeModel == null)
{
BarCodeModel = new BarCodeModel();
BarCodeModel.ProductNo = ProductNo;
BarCodeModel.Brand = Brand;
BarCodeModel.SkuId = SkuId;
BarCodeModel.SkuName = SkuName;
}
2 years ago
if (!string.IsNullOrEmpty(BrandName))
BarCodeModel.BrandName = BrandName;
2 years ago
2 years ago
SetBarCodeWindow setBarCodeWindow = new SetBarCodeWindow();
setBarCodeWindow.LoadData(BarCodeModel, packTaskService);
setBarCodeWindow.SaveResult = b =>
{
BarCodeModel = b;
IsSetBarCode = false;
IsNeedBarCode = Need.;
};
setBarCodeWindow.Show();
2 years ago
}
2 years ago
/// <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
//CertificateModel.Foreach(c=>c.BrandName = BrandName) ;
2 years ago
SetCerWindow setCerWindow = new SetCerWindow();
setCerWindow.LoadData(CertificateModel, packTaskService, spuCertificateModel, IsSetSpuCertificate, SaveType.C端);
2 years ago
setCerWindow.SaveResult = s =>
{
CertificateModel = s;
IsSetCertificate = false;
IsNeedCertificateModel = Need.;
};
setCerWindow.Show();
}
2 years ago
private void SaveBarCode()
{
2 years ago
if (LabelModel == BarcodeLabelModel.)//标准版 判断数据是否异常
2 years ago
{
if (string.IsNullOrEmpty(ProductNo) || ProductNo == "待填写")
{
TipsWindow tips = new TipsWindow("该SKU无货号信息,将影响条形码打印\r\n请先设置好货号信息或调整打印模板类型");
tips.Show();
2 years ago
return;
}
}
2 years ago
//保存到服务器中 返回id
var resData = packTaskService.SaveBarCode(new BarCodeRequest
{
2 years ago
Brand = BarCodeModel.Brand,
2 years ago
BrandName = BarCodeModel.BrandName,
ProductNo = BarCodeModel.ProductNo,
SkuId = BarCodeModel.SkuId,
SkuName = BarCodeModel.SkuName,
LabelModel = BarCodeModel.LabelModel
2 years ago
});
if (resData == null || !resData.Success)
{
IsSetBarCode = false;
return;
}
2 years ago
BarCodeModel.Id = resData.Data;
2 years ago
IsNeedBarCode = Need.;
2 years ago
IsSetBarCode = false;
setBarCodeWindow.Close();
}
public string SkuId { get; set; }
2 years ago
public Action ReflashWindow { get; set; }
2 years ago
/// <summary>
/// 发布任务
/// </summary>
public void CreateTask(object obj)
{
if (string.IsNullOrEmpty(SkuId))
{
2 years ago
new TipsWindow("请先搜索SkuId!").Show();
return;
}
if (SkuCount <= 0)
2 years ago
{
new TipsWindow("请设置SKU任务数!").Show();
2 years ago
return;
}
string increateStr = "";
var increates = IncreateList.Where(i => i.IsSelected).Select(i => i.IncreateName);
if (increates != null && increates.Count() > 0)
{
increateStr = string.Join(",", increates);
}
var createTaskModel = new Models.APIModel.Request.CreateTaskRequest
{
ProductNo = ProductNo,
Logo = Logo,
SkuName = SkuName,
TaskId = TaskId,
2 years ago
BrandName = BrandName,
Availability = (int)Availability,
BasicPack = (int)BasicPack,
SkuId = SkuId,
CreateTime = DateTime.Now,
Increment1 = increateStr,
CertificatePosition = (int)CertificatePosition,
PackType = (int)PackType,
2 years ago
MarkMessage = MarkMessage,
2 years ago
PositionType = (int)PositionType,
GoodsNumber = GoodsNumber,
SkuGoodsTitle = SkuTitle,
SkuCount = SkuCount,
UserId = AccepUserId,
ShopId = globalContext.User.Shop.ShopId.ToString(),
2 years ago
};
2 years ago
if (IsNeedBarCode == Need.)
2 years ago
{
if (BarCodeModel == null || BarCodeModel.Id <= 0)
{
new TipsWindow("请设置条形码模板").Show();
2 years ago
return;
}
2 years ago
createTaskModel.BarCodeId = BarCodeModel.Id;
2 years ago
}
2 years ago
if (IsNeedCertificateModel == Need.)
2 years ago
{
2 years ago
if (CertificateModel == null || CertificateModel.Count() <= 0)
2 years ago
{
new TipsWindow("请设置合格证模板").Show();
2 years ago
return;
}
2 years ago
createTaskModel.CerId = string.Join(",", CertificateModel.Select(c => c.Id));//
2 years ago
}
2 years ago
ApiResponse<object> res = null;
if (TaskId > 0)//修改界面
2 years ago
{
res = packTaskService.UpdateTask(createTaskModel);
}
else
2 years ago
{
res = packTaskService.CreateTask(createTaskModel);
}
2 years ago
if (res.Success)
{
2 years ago
if (ReflashWindow != null) ReflashWindow();//刷新主界面
2 years ago
var win = obj as System.Windows.Window;
win.Close();
}
}
/// <summary>
/// 搜索 skuId
/// </summary>
public void SearchSku()
{
if (string.IsNullOrEmpty(SearchSkuId))
{
return;
}
SearchSkuId = SearchSkuId.Trim();//去掉空格 避免数据异常
2 years ago
IsLoading = true;
SkuId = SearchSkuId;
2 years ago
ApiResponse<ProductListResponse> productApiResponse = null;
var skuResponse = productService.GetProductSkuList(string.Empty, SkuId);
if (skuResponse.Success)
{
if (skuResponse.Data.Count == 0)
{
IsLoading = false;
return;
}
Logo = skuResponse.Data[0].Logo;
SkuName = skuResponse.Data[0].Title;
// ProductNo = skuResponse.Data[0].ProductItemNum;
SpuId = skuResponse.Data[0].ProductId;
2 years ago
productApiResponse = productService.GetProductList(skuResponse.Data[0].ProductId, string.Empty, string.Empty, 1);
if (productApiResponse.Success)
{
if (productApiResponse.Data.Count == 0)
{
IsLoading = false;
return;
}
ProductNo = productApiResponse.Data.Items[0].ProductItemNum;
Brand = productApiResponse.Data.Items[0].BrandName;
}
2 years ago
var productSku = packTaskService.SearchProduct(searchSkuId);
2 years ago
if (productSku == null || !productSku.Success)
{
IsLoading = false;
return;
}
2 years ago
2 years ago
if (productSku.Data.PackConfig != null)
2 years ago
{
var config = productSku.Data.PackConfig;
SkuTitle = config.SkuGoodsTitle;
GoodsNumber = config.GoodsNumber;
PackType = (PackType)config.PackType;
2 years ago
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
string[] increateDatas = config.Increment1.Split(',');
bool isSelected = false;
foreach (var item in increates)
{
isSelected = false;
if (increateDatas.Contains(item))
{
isSelected = true;
}
2 years ago
App.Current.Dispatcher.Invoke(() =>
2 years ago
{
2 years ago
IncreateList.Add(new IncreateModel
{
IncreateName = item,
IsSelected = isSelected
});
2 years ago
});
}
}
2 years ago
BrandName = productSku.Data.BrandName;
2 years ago
CertificateModel = productSku.Data.Cers;
IsSetCertificate = false;
2 years ago
if (CertificateModel == null)
{
2 years ago
CertificateModel = new CertificateModel[] {
2 years ago
new CertificateModel{ }
};
IsSetCertificate = true;
2 years ago
}
2 years ago
foreach (var item in CertificateModel)
item.Brand = Brand;
2 years ago
2 years ago
if (!string.IsNullOrEmpty(BrandName))
2 years ago
foreach (var item in CertificateModel)
{
item.BrandName = BrandName;
item.ProductNo = ProductNo;
item.SkuId = SkuId;
}
2 years ago
2 years ago
BarCodeModel = productSku.Data.BarCodeModel;
IsSetBarCode = false;
2 years ago
if (BarCodeModel == null)
{
BarCodeModel = new BarCodeModel();
IsSetBarCode = true;
2 years ago
}
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;
2 years ago
2 years ago
BarCodeModel.SkuId = SkuId;
BarCodeModel.SkuName = SkuName;
}
else
{
IsLoading = false;
App.Current.Dispatcher.Invoke(() => MessageBox.Show(skuResponse.Msg, "加载sku"));
return;
}
IsLoading = false;
//查看有木有存在
}
public void SearSpuCer()
{
if (string.IsNullOrEmpty(SpuId))
{
SearchSku();
return;
}
SpuId = SpuId.Trim();//去掉空格 避免数据异常
IsLoading = true;
var productSku = packTaskService.GetSpuCer(SpuId);
if (productSku == null || !productSku.Success)
{
IsSetSpuCertificate = true;
IsLoading = false;
return;
}
SpuCertificateModel = productSku.Data;
IsSetSpuCertificate = false;
if (SpuCertificateModel == null)
{
SpuCertificateModel = new CertificateModel();
IsSetSpuCertificate = true;
SpuCertificateModel.Brand = Brand;
2 years ago
if (!string.IsNullOrEmpty(BrandName))
SpuCertificateModel.BrandName = BrandName;
SpuCertificateModel.ProductNo = ProductNo;
SpuCertificateModel.SpuId = SpuId;
}
IsLoading = false;
}
2 years ago
}
}