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

72 lines
2.4 KiB

2 years ago
using BBWY.Client.APIServices;
using BBWY.Client.Models;
using BBWY.Common.Models;
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text;
using System.Windows.Input;
namespace BBWY.Client.ViewModels
{
public class BatchPublishTaskViewModel : BaseVM, IDenpendency
{
PackTaskService packTaskService;
ProductService productService;
private bool isLoading = false;
public bool IsLoading { get => isLoading; set { Set(ref isLoading, value); } }
private ObservableCollection<BatchPublishTask> batchPublishTasks;
public ObservableCollection<BatchPublishTask> BatchPublishTasks { get => batchPublishTasks; set { Set(ref batchPublishTasks, value); } }
public ICommand CreateTaskCommand { get; set; }
public BatchPublishTaskViewModel(PackTaskService packTaskService, ProductService productService)
{
BatchPublishTasks = new ObservableCollection<BatchPublishTask>();
this.packTaskService = packTaskService;
this.productService = productService;
CreateTaskCommand = new RelayCommand(CreateTask);
}
private void CreateTask()
{
}
Platform platform; string orderId; string PurchaserId;
public void AddSkus(Platform platform, string orderId, string PurchaserId, List<PurchaseOrderSku> purchaseOrderSkus)
{
BatchPublishTasks = new ObservableCollection<BatchPublishTask>();
this.platform = platform; this.orderId = orderId;
this.PurchaserId = PurchaserId;
BatchPublishTask model = null;
IsLoading = true;
foreach (var item in purchaseOrderSkus)
{
model = new BatchPublishTask();
//model.InitData();
model.productService = productService;
model.packTaskService = packTaskService;
model.SkuId = item.SkuId;
model.SkuCount = item.Quantity.Value;
model.Logo = item.Logo;
model.SpuId = item.ProductId;
model.SkuName = item.SkuTitle;
model.SearchSku(item.SkuId);
App.Current.Dispatcher.Invoke(() =>
{
BatchPublishTasks.Add(model);
});
}
IsLoading = false;
}
}
}