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.
164 lines
5.9 KiB
164 lines
5.9 KiB
2 years ago
|
using AutoMapper.Internal;
|
||
|
using BBWY.Client.APIServices;
|
||
|
using BBWY.Client.Models;
|
||
|
using BBWY.Client.Models.SealBox;
|
||
|
using BBWY.Controls;
|
||
|
using Org.BouncyCastle.Utilities.Collections;
|
||
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using System.Windows;
|
||
|
using System.Windows.Controls;
|
||
|
using System.Windows.Data;
|
||
|
using System.Windows.Documents;
|
||
|
using System.Windows.Input;
|
||
|
using System.Windows.Media;
|
||
|
using System.Windows.Media.Imaging;
|
||
|
using System.Windows.Shapes;
|
||
|
|
||
|
namespace BBWY.Client.Views.SealBox
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// AddWareListWindow.xaml 的交互逻辑
|
||
|
/// </summary>
|
||
|
public partial class AddWareListWindow : BWindow
|
||
|
{
|
||
|
public AddWareListWindow(WareType WareType, LogisticsService logisticsService, List<SealBoxConfigureModel> SealBoxConfigureModelList)
|
||
|
{
|
||
|
this.WareType = WareType;
|
||
|
InitializeComponent();
|
||
|
LoadWare(logisticsService, SealBoxConfigureModelList);
|
||
|
this.DataContext = this;
|
||
|
}
|
||
|
|
||
|
private WareType wareType;
|
||
|
public WareType WareType { get => wareType; set { Set(ref wareType, value); } }
|
||
|
|
||
|
|
||
|
|
||
|
public void LoadWare(LogisticsService logisticsService, List<SealBoxConfigureModel> SealBoxConfigureModelList)
|
||
|
{
|
||
|
if (WareType != WareType.聚水潭)
|
||
|
{
|
||
|
var response = logisticsService.GetStoreList();//京仓库类型 商家仓 = 1, 京仓 = 2, 云仓 = 3
|
||
|
if (response == null || !response.Success)
|
||
|
{
|
||
|
MessageBox.Show($"加载仓库列表失败,{response?.Msg}");
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
var data = response.Data.Where(w => w.Status == StockStatus.使用);
|
||
|
var stockType = StockType.云仓;
|
||
|
switch (WareType)
|
||
|
{
|
||
|
case WareType.京仓:
|
||
|
stockType = StockType.京仓;
|
||
|
break;
|
||
|
case WareType.云仓:
|
||
|
stockType = StockType.云仓;
|
||
|
|
||
|
break;
|
||
|
case WareType.商家仓:
|
||
|
stockType = StockType.商家仓;
|
||
|
break;
|
||
|
//case WareType.聚水潭:
|
||
|
// WareList = new List<StoreWare> { new StoreWare { WareId = "qiyuejushuitan", WareName = "齐越聚水潭", IsSelect = false } };
|
||
|
// break;
|
||
|
//default:
|
||
|
// break;
|
||
|
}
|
||
|
WareList = new List<StoreWare>();
|
||
|
data.Where(d => d.Type == stockType).ForAll(d =>
|
||
|
{
|
||
|
if (SealBoxConfigureModelList.Where(s => s.WareType == WareType &&s.WareHourseDatas!=null).SelectMany(s => s.WareHourseDatas).Any(w => w.WareId == d.Id))//存在
|
||
|
{
|
||
|
bool isedit = true;
|
||
|
if (SealBoxConfigureModelList.Where(s => s.WareType == WareType && s.WareHourseDatas != null).SelectMany(s => s.WareHourseDatas).Any(s=>s.WareState>0&& s.WareId == d.Id))
|
||
|
isedit =false;
|
||
|
WareList.Add(new StoreWare
|
||
|
{
|
||
|
IsSelect = true,
|
||
|
WareId = d.Id,
|
||
|
WareName = d.Name,
|
||
|
IsEdit= isedit
|
||
|
});
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
WareList.Add(new StoreWare
|
||
|
{
|
||
|
IsSelect = false,
|
||
|
WareId = d.Id,
|
||
|
WareName = d.Name,
|
||
|
IsEdit = true
|
||
|
});
|
||
|
}
|
||
|
|
||
|
|
||
|
});
|
||
|
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
bool isJST = false;
|
||
|
if (SealBoxConfigureModelList.Where(s => s.WareType == WareType).SelectMany(s => s.WareHourseDatas).Any(w => w.WareId == "qiyuejushuitan"))//存在
|
||
|
isJST = true;
|
||
|
WareList = new List<StoreWare> { new StoreWare { WareId = "qiyuejushuitan", WareName = "齐越聚水潭", IsSelect = isJST } };
|
||
|
}
|
||
|
|
||
|
}
|
||
|
private List<StoreWare> wareList;
|
||
|
public List<StoreWare> WareList { get => wareList; set { Set(ref wareList, value); } }
|
||
|
|
||
|
|
||
|
public Action<WareType, List<StoreWare>> AddWareList { get; set; }
|
||
|
|
||
|
private void BButton_Click(object sender, RoutedEventArgs e)
|
||
|
{
|
||
|
var selectWare = WareList.Where(w => w.IsSelect).ToList();
|
||
|
if (AddWareList != null) AddWareList(WareType, selectWare);
|
||
|
this.Close();
|
||
|
}
|
||
|
private PositionType ToPositionType(WareType wareType)
|
||
|
{
|
||
|
switch (wareType)
|
||
|
{
|
||
|
case WareType.京仓:
|
||
|
return PositionType.京仓;
|
||
|
break;
|
||
|
case WareType.云仓:
|
||
|
return PositionType.云仓;
|
||
|
break;
|
||
|
case WareType.商家仓:
|
||
|
return PositionType.商家仓;
|
||
|
break;
|
||
|
case WareType.聚水潭:
|
||
|
return PositionType.聚水潭;
|
||
|
break;
|
||
|
default:
|
||
|
break;
|
||
|
}
|
||
|
return PositionType.聚水潭;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public class StoreWare : NotifyObject
|
||
|
{
|
||
|
private bool isSelect;
|
||
|
public bool IsSelect { get => isSelect; set { Set(ref isSelect, value); } }
|
||
|
|
||
|
private string wareName;
|
||
|
public string WareName { get => wareName; set { Set(ref wareName, value); } }
|
||
|
|
||
|
private string wareId;
|
||
|
public string WareId { get => wareId; set { Set(ref wareId, value); } }
|
||
|
|
||
|
|
||
|
private bool isEdit=true;
|
||
|
public bool IsEdit { get => isEdit; set { Set(ref isEdit, value); } }
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|