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.
961 lines
33 KiB
961 lines
33 KiB
using BBWY.Client.APIServices;
|
|
using BBWY.Client.APIServices.QiKu;
|
|
using BBWY.Client.Extensions;
|
|
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 GalaSoft.MvvmLight.Command;
|
|
using GalaSoft.MvvmLight.Messaging;
|
|
using Newtonsoft.Json;
|
|
using Org.BouncyCastle.Ocsp;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Net.Mail;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
|
|
namespace BBWY.Client.ViewModels.PackTask
|
|
{
|
|
public class PublishTaskViewModel : BaseVM
|
|
{
|
|
|
|
#region 属性
|
|
|
|
|
|
private ObservableCollection<PackTaskExpress> packTaskExpressList;
|
|
public ObservableCollection<PackTaskExpress> PackTaskExpressList { get => packTaskExpressList; set { Set(ref packTaskExpressList, value); } }
|
|
|
|
|
|
public DistributionMode? distributionMode = Models.DistributionMode.快递配送;
|
|
/// <summary>
|
|
/// 配送方式
|
|
/// </summary>
|
|
public DistributionMode? DistributionMode { get => distributionMode; set { Set(ref distributionMode, value); } }
|
|
|
|
|
|
private ObservableCollection<DistributionMode> distributionModeList = new ObservableCollection<DistributionMode> {
|
|
Models.DistributionMode.自送, Models.DistributionMode.快递配送};
|
|
public ObservableCollection<DistributionMode> DistributionModeList { get => distributionModeList; set { Set(ref distributionModeList, value); } }
|
|
|
|
public SaveType SaveType { get; set; }
|
|
|
|
private string searchSkuId;
|
|
public string SearchSkuId { get => searchSkuId; set { Set(ref searchSkuId, value); } }
|
|
|
|
private long taskId;
|
|
public long TaskId { get => taskId; set { Set(ref taskId, value); } }
|
|
//private bool isSelected;
|
|
//public bool IsSelected { get => isSelected; set { Set(ref isSelected, value); } }
|
|
|
|
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> {
|
|
"商家仓","云仓", "京仓","聚水潭"};
|
|
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> isNeedCerList = new ObservableCollection<string> {
|
|
"需要", "不需要" };
|
|
public ObservableCollection<string> IsNeedCerList { get => isNeedCerList; set { Set(ref isNeedCerList, 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); } }
|
|
|
|
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 Availability availability;
|
|
/// <summary>
|
|
/// 到货情况(待收货=0,部分收货=1,已到货=2)
|
|
/// </summary>
|
|
public Availability Availability { get => availability; set { Set(ref availability, value); } }
|
|
|
|
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>
|
|
/// 落仓(商家仓=0,云仓=1,京仓=2,聚水潭=3)
|
|
/// </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
|
|
{
|
|
get => isSetBarCode;
|
|
set
|
|
{
|
|
|
|
Set(ref isSetBarCode, value);
|
|
// IsNeedBarCode = IsSetBarCode ? Need.不需要 : Need.需要;
|
|
}
|
|
}
|
|
|
|
private bool isSetCertificate;
|
|
/// <summary>
|
|
/// 设置显示(合格证)
|
|
/// </summary>
|
|
public bool IsSetCertificate
|
|
{
|
|
get => isSetCertificate; set
|
|
{
|
|
|
|
Set(ref isSetCertificate, value);
|
|
//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模板";
|
|
}
|
|
}
|
|
|
|
|
|
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); } }
|
|
|
|
|
|
|
|
private CertificateModel[] certificateModel;
|
|
/// <summary>
|
|
/// 合格证
|
|
/// </summary>
|
|
public CertificateModel[] CertificateModel { get => certificateModel; set { Set(ref certificateModel, value); } }
|
|
|
|
/// <summary>
|
|
/// 合格证位置(外部包装=0,产品包装=1)
|
|
/// </summary>
|
|
private CertificatePosition certificatePosition;
|
|
/// <summary>
|
|
/// 合格证位置(外部包装=0,产品包装=1)
|
|
/// </summary>
|
|
public CertificatePosition CertificatePosition { get => certificatePosition; set { Set(ref certificatePosition, value); } }
|
|
|
|
|
|
|
|
private string showMarkMessage;
|
|
/// <summary>
|
|
/// 显示对接备注消息
|
|
/// </summary>
|
|
public string ShowMarkMessage { get => showMarkMessage; set { Set(ref showMarkMessage, 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); } }
|
|
string[] increates = new string[] { "气泡纸", "气泡袋", "POP袋", "折纸箱", "气泡纸封边", "彩盒", "剪胶", "剪彩带", "快递袋", "收纳盒", "纸箱子", "装纸箱", "封边", "胶带", "折彩盒" };
|
|
|
|
PackTaskService packTaskService;
|
|
ProductService productService;
|
|
GlobalContext globalContext;
|
|
private bool isLoading = false;
|
|
public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } }
|
|
#endregion
|
|
|
|
public PublishTaskViewModel(PackTaskService packTaskService, ProductService productService, GlobalContext globalContext, MarkMessageService markMessageService, PackTaskExpressService packTaskExpressService)
|
|
{
|
|
PackTaskExpressList = new ObservableCollection<PackTaskExpress>();
|
|
this.packTaskService = packTaskService;
|
|
this.productService = productService;
|
|
this.globalContext = globalContext;
|
|
CreateTaskCommand = new RelayCommand<object>(CreateTask);
|
|
OpenSkuDetailCommand = new RelayCommand<object>(OpenSkuDetail);
|
|
SetBarCodeCommand = new RelayCommand(SetBarCode);
|
|
SetCertificateCommand = new RelayCommand(SetCertificate);
|
|
LookBarCommand = new RelayCommand(LookBar);
|
|
LookCerCommand = new RelayCommand(LookCer);
|
|
SearchSkuCommand = new RelayCommand<object>(SearchSku);
|
|
IncreateList = new ObservableCollection<IncreateModel>();
|
|
foreach (var item in increates)
|
|
{
|
|
IncreateList.Add(new IncreateModel
|
|
{
|
|
IncreateName = item,
|
|
IsSelected = false
|
|
});
|
|
}
|
|
Messenger.Default.Register<PackTaskModel>(this, "InitData", message =>
|
|
{
|
|
|
|
InitData(message);
|
|
});
|
|
|
|
|
|
AppendMarkMessageCommand = new RelayCommand(AppendMarkMessage);
|
|
this.markMessageService = markMessageService;
|
|
|
|
|
|
|
|
AddExpressCommand = new RelayCommand(AddExpress);
|
|
UpdateExpressCommand = new RelayCommand<PackTaskExpress>(UpdateExpress);
|
|
|
|
DeletedExpressCommand = new RelayCommand<PackTaskExpress>(DeletedExpress);
|
|
this.packTaskExpressService = packTaskExpressService;
|
|
}
|
|
|
|
private void DeletedExpress(PackTaskExpress express)
|
|
{
|
|
var expressdata = PackTaskExpressList.SingleOrDefault(e => e.NewGuid == express.NewGuid);
|
|
if (expressdata != null)
|
|
PackTaskExpressList.Remove(expressdata);
|
|
|
|
|
|
}
|
|
|
|
private void UpdateExpress(PackTaskExpress express)
|
|
{
|
|
AddExpressWindow addExpress = new AddExpressWindow((newGuid, waybillNo, ExpressName) =>
|
|
{
|
|
|
|
App.Current.Dispatcher.Invoke(() =>
|
|
{
|
|
var express = PackTaskExpressList.SingleOrDefault(e => e.NewGuid == newGuid);
|
|
if (express != null)
|
|
{
|
|
|
|
App.Current.Dispatcher.Invoke(() =>
|
|
{
|
|
express.WaybillNo = waybillNo;
|
|
express.SourceExpressName = ExpressName;
|
|
|
|
});
|
|
}
|
|
|
|
});
|
|
|
|
|
|
}, globalContext.ExpressNameList, packTaskExpressService, express);
|
|
addExpress.ShowDialog();
|
|
}
|
|
|
|
PackTaskExpressService packTaskExpressService;
|
|
|
|
private void AddExpress()
|
|
{
|
|
AddExpressWindow addExpress = new AddExpressWindow((newGuid, waybillNo, ExpressName) =>
|
|
{
|
|
|
|
App.Current.Dispatcher.Invoke(() =>
|
|
{
|
|
PackTaskExpressList.Add(new PackTaskExpress
|
|
{
|
|
SourceExpressName = ExpressName,
|
|
WaybillNo = waybillNo,
|
|
NewGuid = newGuid
|
|
});
|
|
|
|
});
|
|
|
|
|
|
}, globalContext.ExpressNameList, packTaskExpressService);
|
|
addExpress.ShowDialog();
|
|
}
|
|
|
|
|
|
|
|
#region 方法
|
|
public ICommand SetBarCodeCommand { get; set; }
|
|
public ICommand SetCertificateCommand { get; set; }
|
|
public ICommand LookBarCommand { get; set; }
|
|
public ICommand LookCerCommand { get; set; }
|
|
|
|
public ICommand OpenSkuDetailCommand { get; set; }
|
|
public ICommand CreateTaskCommand { get; set; }
|
|
public ICommand SearchSkuCommand { get; set; }
|
|
|
|
public ICommand AppendMarkMessageCommand { get; set; }
|
|
|
|
|
|
public ICommand AddExpressCommand { get; set; }
|
|
|
|
public ICommand UpdateExpressCommand { get; set; }
|
|
|
|
public ICommand DeletedExpressCommand { get; set; }
|
|
|
|
|
|
MarkMessageService markMessageService;
|
|
|
|
private void AppendMarkMessage()
|
|
{
|
|
var res = markMessageService.AppendMarkMessage(TaskId, MarkMessage, globalContext.User.Name);
|
|
if (res == null)
|
|
{
|
|
|
|
return;
|
|
}
|
|
if (!res.Success)
|
|
{
|
|
MessageBox.Show(res.Msg);
|
|
return;
|
|
}
|
|
|
|
MarkMessage = string.Empty;
|
|
|
|
var resShow = markMessageService.ShowTaskMarkMessage(TaskId);
|
|
if (resShow != null && resShow.Success && resShow.Data != null)
|
|
{
|
|
ShowMarkMessage = string.Join("\r\n", resShow.Data.Select(d => d.ToString()));
|
|
}
|
|
|
|
}
|
|
|
|
|
|
private void SetBarCode()
|
|
{
|
|
if (string.IsNullOrEmpty(SkuId))
|
|
{
|
|
return;
|
|
}
|
|
if (TaskId > 0 && string.IsNullOrEmpty(SpuId))//修改界面刷新配置数据
|
|
{
|
|
SearchSku(SkuId);
|
|
}
|
|
|
|
if (BarCodeModel == null)
|
|
{
|
|
BarCodeModel = new BarCodeModel();
|
|
BarCodeModel.ProductNo = ProductNo;
|
|
BarCodeModel.Brand = Brand;
|
|
BarCodeModel.SkuId = SkuId;
|
|
BarCodeModel.SkuName = SkuName;
|
|
|
|
}
|
|
BarCodeModel.ShopName = globalContext.User.Shop.ShopName;
|
|
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)
|
|
{
|
|
CertificateModel = new CertificateModel[] {
|
|
new CertificateModel{
|
|
ProductNo = ProductNo,
|
|
Brand = Brand,
|
|
SkuId = SkuId,
|
|
|
|
}
|
|
};
|
|
|
|
|
|
}
|
|
if (!string.IsNullOrEmpty(BrandName))
|
|
foreach (var item in CertificateModel) item.BrandName = BrandName;
|
|
|
|
SetCerWindow setCerWindow = new SetCerWindow();
|
|
setCerWindow.LoadData(CertificateModel, packTaskService, spuCertificateModel, IsSetSpuCertificate, SaveType);
|
|
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();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 搜索 skuId
|
|
/// </summary>
|
|
public void SearchSku(object obj)
|
|
{
|
|
string skuid = (string)obj;
|
|
if (string.IsNullOrEmpty(skuid))
|
|
return;
|
|
|
|
SkuId = skuid;
|
|
ApiResponse<ProductListResponse> productApiResponse = null;
|
|
var skuResponse = productService.GetProductSkuList(string.Empty, skuid);
|
|
if (skuResponse.Success)
|
|
{
|
|
if (skuResponse.Data.Count == 0)
|
|
{
|
|
return;
|
|
}
|
|
Logo = skuResponse.Data[0].Logo.Replace("80x80", "200x200");
|
|
SkuName = skuResponse.Data[0].Title;
|
|
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;
|
|
|
|
}
|
|
var productSku = packTaskService.SearchProduct(skuid);
|
|
if (productSku == null || !productSku.Success || productSku.Data == null)
|
|
return;
|
|
if (TaskId <= 0)
|
|
BrandName = productSku.Data.BrandName;
|
|
CertificateModel = productSku.Data.Cers;
|
|
|
|
IsSetCertificate = false;
|
|
if (CertificateModel == null)
|
|
{
|
|
IsSetCertificate = true;
|
|
CertificateModel = new CertificateModel[] {
|
|
new CertificateModel{ }
|
|
};
|
|
|
|
|
|
}
|
|
foreach (var item in CertificateModel)
|
|
{
|
|
item.Brand = Brand;
|
|
if (!string.IsNullOrEmpty(BrandName))
|
|
item.BrandName = BrandName;
|
|
item.ProductNo = ProductNo;
|
|
item.SkuId = skuid;
|
|
}
|
|
BarCodeModel = productSku.Data.BarCodeModel;
|
|
if (BarCodeModel == null)
|
|
{
|
|
BarCodeModel = new BarCodeModel();
|
|
}
|
|
if (BarCodeModel.LabelModel == BarcodeLabelModel.无型号模板)
|
|
BarCodeModel.LabelModel = BarcodeLabelModel.精简模板;
|
|
|
|
BarCodeModel.Brand = Brand;
|
|
if (!string.IsNullOrEmpty(BrandName))
|
|
BarCodeModel.BrandName = BrandName;
|
|
BarCodeModel.ProductNo = ProductNo;
|
|
BarCodeModel.SkuId = skuid;
|
|
BarCodeModel.SkuName = SkuName;
|
|
|
|
if (TaskId <= 0)
|
|
{
|
|
IsNeedBarCode = Need.需要;
|
|
IsSetBarCode = true;
|
|
|
|
}
|
|
if (productSku.Data.PackConfig != null && TaskId <= 0)
|
|
{
|
|
var config = productSku.Data.PackConfig;
|
|
SkuTitle = config.SkuGoodsTitle;
|
|
GoodsNumber = config.GoodsNumber;
|
|
PackType = (PackType)config.PackType;
|
|
BasicPack = (BasicPack)config.BasicPack;
|
|
CertificatePosition = config.CertificatePosition == null ? CertificatePosition.无需合格证 : (CertificatePosition)config.CertificatePosition.Value;
|
|
string[] increateDatas = config.Increment1.Split(',');
|
|
IsNeedBarCode = config.NeedBar ? Need.需要 : Need.不需要;
|
|
IsNeedCertificateModel = config.NeedCer ? Need.需要 : Need.不需要;
|
|
IsSetBarCode = !config.NeedBar;
|
|
bool isSelected = false;
|
|
IncreateList = new ObservableCollection<IncreateModel>();
|
|
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
|
|
});
|
|
});
|
|
}
|
|
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
App.Current.Dispatcher.Invoke(() => MessageBox.Show(skuResponse.Msg, "加载sku"));
|
|
return;
|
|
}
|
|
|
|
//加载配置文件
|
|
}
|
|
|
|
public void SearSpuCer()
|
|
{
|
|
if (string.IsNullOrEmpty(SpuId) && globalContext.User.Shop != null)
|
|
{
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public Action ReflashWindow { get; set; }
|
|
public void InitData(PackTaskModel model = null)
|
|
{
|
|
|
|
//展示数据
|
|
|
|
|
|
|
|
IncreateList = new ObservableCollection<IncreateModel>();
|
|
SpuId = string.Empty;
|
|
if (model == null)
|
|
{
|
|
Availability = Availability.未到货;
|
|
|
|
CertificatePosition = CertificatePosition.外部包装;
|
|
SaveTask = "发布";
|
|
TaskId = 0;
|
|
Logo = string.Empty;
|
|
SearchSkuId = "";
|
|
SkuId = "";
|
|
SkuCount = 0;
|
|
SkuName = string.Empty;
|
|
ProductNo = string.Empty;
|
|
Brand = string.Empty;
|
|
BrandName = string.Empty;
|
|
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
|
|
});
|
|
}
|
|
IsNeedBarCode = Need.需要;
|
|
return;
|
|
}
|
|
SaveTask = "保存";
|
|
Logo = model.ItemList[0].Logo.Replace("80x80", "200x200");
|
|
SearchSkuId = model.SkuId;
|
|
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;
|
|
BarCodeModel = model.BarCodeModel;
|
|
CertificateModel = model.CertificateModel;
|
|
SkuTitle = model.SkuTitle;
|
|
GoodsNumber = model.GoodsNumber;
|
|
|
|
if (model.ExpressOrderList!=null&&model.ExpressOrderList.Any())
|
|
{
|
|
DistributionMode = Models.DistributionMode.快递配送;
|
|
model.ExpressOrderList.ForEach(s => {
|
|
|
|
|
|
PackTaskExpressList.Add(new PackTaskExpress { NewGuid=Guid.NewGuid().ToString(),
|
|
SourceExpressName=s.TargetExpressName,
|
|
WaybillNo =s.WaybillNo
|
|
});
|
|
|
|
|
|
});
|
|
}
|
|
else
|
|
{
|
|
DistributionMode = Models.DistributionMode.自送;
|
|
}
|
|
|
|
|
|
try
|
|
{
|
|
PositionType = model.PositionType.ToEnum<PositionType>();//多个仓库异常 todo:
|
|
}
|
|
catch
|
|
{
|
|
|
|
}
|
|
PackType = model.PackType;
|
|
BasicPack = model.BasicPack;
|
|
IsNeedBarCode = model.BarCodeModel == null ? Need.不需要 : Need.需要;
|
|
IsNeedCertificateModel = model.CertificateModel == null ? Need.不需要 : Need.需要;
|
|
CertificatePosition = model.CertificatePosition;
|
|
TaskId = model.TaskId;
|
|
|
|
var res = markMessageService.ShowTaskMarkMessage(TaskId);
|
|
if (res != null && res.Success && res.Data != null)
|
|
{
|
|
ShowMarkMessage = string.Join("\r\n", res.Data.Select(d => d.ToString()));
|
|
}
|
|
|
|
string[] increateDatas = model.Increment1?.Split(',');
|
|
|
|
bool isTrue = false;
|
|
foreach (var item in increates)
|
|
{
|
|
isTrue = false;
|
|
if (increateDatas != null && increateDatas.Count() > 0 && increateDatas.Contains(item))
|
|
{
|
|
isTrue = true;
|
|
}
|
|
App.Current.Dispatcher.Invoke(() =>
|
|
{
|
|
IncreateList.Add(new IncreateModel
|
|
{
|
|
IncreateName = item,
|
|
IsSelected = isTrue
|
|
});
|
|
});
|
|
}
|
|
// SearchSku(SkuId);
|
|
|
|
}
|
|
private void OpenSkuDetail(object param)
|
|
{
|
|
var paramList = (object[])param;
|
|
// var orderId = paramList[0].ToString();
|
|
var skuId = paramList[0].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调用浏览器失败,网页链接已复制到剪切板,请手动打开浏览器访问", "提示");
|
|
}
|
|
|
|
}
|
|
private void CreateTask(object obj)
|
|
{
|
|
if (string.IsNullOrEmpty(SkuId))
|
|
{
|
|
new TipsWindow("请先搜索SkuId!").Show();
|
|
return;
|
|
}
|
|
if (SkuCount <= 0)
|
|
{
|
|
new TipsWindow("请设置SKU任务数!").Show();
|
|
return;
|
|
}
|
|
string increateStr = "";
|
|
var increates = IncreateList.Where(i => i.IsSelected).Select(i => i.IncreateName);
|
|
if (increates != null && increates.Count() > 0)
|
|
{
|
|
increateStr = string.Join(",", increates);
|
|
}
|
|
if (DistributionMode == Models.DistributionMode.快递配送 && (PackTaskExpressList == null || !PackTaskExpressList.Any()))
|
|
{
|
|
MessageBox.Show("请添加快递信息", "提示");
|
|
return;
|
|
}
|
|
var createTaskModel = new Models.APIModel.Request.CreatePackTaskV2Request
|
|
{
|
|
ProductNo = ProductNo,
|
|
Logo = Logo.Replace("200x200", "80x80"),
|
|
SkuName = SkuName,
|
|
BrandName = BrandName,
|
|
BasicPack = (int)BasicPack,
|
|
SkuId = SkuId,
|
|
Increment1 = increateStr,
|
|
CertificatePosition = (int)CertificatePosition,
|
|
PackType = (int)PackType,
|
|
MarkMessage = MarkMessage,
|
|
PositionType = PositionType,
|
|
GoodsNumber = GoodsNumber,
|
|
SkuGoodsTitle = SkuTitle,
|
|
SkuCount = SkuCount,
|
|
UserId = globalContext.User.Id.ToString(),
|
|
ShopId = globalContext.User.Shop.ShopId.ToString(),
|
|
NeedBar = IsNeedBarCode == Need.需要,
|
|
NeedCer = IsNeedCertificateModel == Need.需要,
|
|
DistributionMode = DistributionMode,
|
|
WayBillNoList = PackTaskExpressList?.Select(p => p.WaybillNo)?.ToList()
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
if (IsNeedBarCode == Need.需要)
|
|
{
|
|
if (BarCodeModel == null || IsSetBarCode || BarCodeModel.Id <= 0)
|
|
{
|
|
new TipsWindow("请设置条形码模板").Show();
|
|
return;
|
|
}
|
|
createTaskModel.BarCodeId = BarCodeModel.Id;
|
|
}
|
|
if (CertificatePosition != CertificatePosition.无需合格证)
|
|
{
|
|
if (CertificateModel == null || IsSetCertificate || CertificateModel.Count() <= 0)
|
|
{
|
|
MessageBox.Show("请设置合格证模板", "提示");
|
|
return;
|
|
}
|
|
createTaskModel.CerId = string.Join(",", CertificateModel.Where(c => c.Id > 0).Select(c => c.Id));//
|
|
}
|
|
|
|
ApiResponse<object> res = null;
|
|
if (TaskId > 0)//修改界面
|
|
{
|
|
var updateTaskModel = JsonConvert.DeserializeObject<UpdatePackTaskV2Request>(JsonConvert.SerializeObject(createTaskModel));
|
|
|
|
updateTaskModel.TaskId = TaskId;
|
|
updateTaskModel.SaveType = SaveType;
|
|
res = packTaskService.UpdatePackTaskV2(updateTaskModel);
|
|
}
|
|
else
|
|
{
|
|
res = packTaskService.CreatePackTaskV2(createTaskModel);
|
|
}
|
|
|
|
if (res == null)
|
|
{
|
|
MessageBox.Show("未知错误");
|
|
return;
|
|
}
|
|
if (!res.Success)
|
|
{
|
|
MessageBox.Show(res.Msg);
|
|
return;
|
|
}
|
|
|
|
if (res.Success)
|
|
{
|
|
if (ReflashWindow != null) ReflashWindow();//刷新主界面
|
|
|
|
var win = obj as System.Windows.Window;
|
|
win.Close();
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
}
|
|
|