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

210 lines
6.2 KiB

using BBWY.Client.APIServices;
using BBWY.Client.Models.APIModel.Response.PackTask;
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using WebSocketSharp;
namespace BBWY.Client.Models.PackTask
{
public class PackItemModel : NotifyObject
{
private bool isHideDelete=false;
public bool IsHideDelete { get => isHideDelete; set { Set(ref isHideDelete, value); } }
private string itemName;
public string ItemName { get => itemName; set { Set(ref itemName, value); } }
private string selectUserId;
/// <summary>
/// Member.userId
/// </summary>
public string SelectUserId { get => selectUserId; set { Set(ref selectUserId, value); } }
private long? selectId;
/// <summary>
/// 选中的Id
/// </summary>
public long? SelectId { get => selectId; set { Set(ref selectId, value); } }
private string memberName;
public string MemberName { get => memberName; set { Set(ref memberName, value); } }
private int itemCount;
public int ItemCount { get => itemCount; set { Set(ref itemCount, value); } }
private ObservableCollection<PackServiceDTO> increateServiceList;
public ObservableCollection<PackServiceDTO> IncreateServiceList
{
get => increateServiceList; set
{
Set(ref increateServiceList, value);
}
}
private ObservableCollection<PackUser> memberList;
public ObservableCollection<PackUser> MemberList
{
get => memberList; set
{
Set(ref memberList, value);
}
}
private ObservableCollection<ConsumableModel> consumableList;
public ObservableCollection<ConsumableModel> ConsumableList
{ get => consumableList; set { Set(ref consumableList, value); } }
/// <summary>
/// 工序服务
/// </summary>
private ObservableCollection<PackServiceDTO> packServiceList;
public ObservableCollection<PackServiceDTO> PackServiceList { get => packServiceList; set { Set(ref packServiceList, value); } }
/// <summary>
/// 设置列表的 是否编辑属性
/// </summary>
public bool IsEnable { get; set; }
public ICommand DeleteServiceCommand { get; set; }
public PackItemModel()
{
DeleteServiceCommand = new RelayCommand<object>(DeleteService);
}
private void DeleteService(object obj)
{
ObservableCollection<PackItemModel> list = obj as ObservableCollection<PackItemModel>;
list.Remove(this);
}
/// <summary>
/// 耗材类型
/// </summary>
private ObservableCollection<string> consumableTypeList;
public ObservableCollection<string> ConsumableTypeList { get => consumableTypeList; set { Set(ref consumableTypeList, value); } }
/// <summary>
/// 所有的耗材类型
/// </summary>
public List<ConsumableTypeResponse> AllConsumableTypeList { get; set; }
private string consumableType;
/// <summary>
/// 耗材类型
/// </summary>
public string ConsumableType
{
get => consumableType; set
{
Set(ref consumableType, value);
OnConsumableTypeChanged(ConsumableType);
}
}
void OnConsumableTypeChanged(string ConsumableType)
{
if (AllConsumableTypeList == null || AllConsumableTypeList.Count <= 0 || ConsumableType .IsNullOrEmpty())
{
return;//ConsumableList
}
ConsumableItemList = AllConsumableTypeList.SingleOrDefault(a => a.ConsumableTypeName == ConsumableType)?.ConsumableList;
if (ConsumableItemList == null || ConsumableItemList.Count <= 0 )
{
return;
}
ConsumableItem = ConsumableItemList.FirstOrDefault()?.ConsumableName;
}
private string consumableItem;
/// <summary>
/// 耗材型号
/// </summary>
public string ConsumableItem
{
get => consumableItem; set
{
Set(ref consumableItem, value);
OnConsumableItemChanged(ConsumableItem);
}
}
/// <summary>
/// 统计耗材收费
/// </summary>
public Action TotalConsumableFees { get; set; }
void OnConsumableItemChanged(string consumableItem)
{
if (ConsumableItemList == null || ConsumableItemList.Count <= 0 || consumableItem .IsNullOrEmpty())
{
return;
}
ConsumablePrice = ConsumableItemList.SingleOrDefault(c => c.ConsumableName == consumableItem).ConsumablePrice;
if (TotalConsumableFees != null) TotalConsumableFees();
}
/// <summary>
/// 耗材型号
/// </summary>
private ObservableCollection<ConsumableItemModel> consumableItemList;
public ObservableCollection<ConsumableItemModel> ConsumableItemList { get => consumableItemList; set { Set(ref consumableItemList, value); } }
private decimal consumablePrice;
/// <summary>
/// 耗材单价
/// </summary>
public decimal ConsumablePrice { get => consumablePrice; set { Set(ref consumablePrice, value); } }
private int taskCount;
/// <summary>
/// 耗材任务数
/// </summary>
public int TaskCount { get => taskCount; set { Set(ref taskCount, value); OnConsumableItemChanged(ConsumableItem); } }
}
public class ConsumableItemModel : NotifyObject
{
/// <summary>
/// 耗材id
/// </summary>
public long ConsumableId { get; set; }
/// <summary>
/// 耗材名称
/// </summary>
public string ConsumableName { get; set; }
/// <summary>
/// 耗材价格
/// </summary>
public decimal ConsumablePrice { get; set; }
}
}