shanji 3 years ago
parent
commit
a5dddaaede
  1. 23
      BBWY.Client/Models/Shop/Department.cs
  2. 58
      BBWY.Client/ViewModels/FinancialTerminal/ProcurementAuditViewModel.cs
  3. 27
      BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml

23
BBWY.Client/Models/Shop/Department.cs

@ -1,18 +1,37 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
namespace BBWY.Client.Models namespace BBWY.Client.Models
{ {
public class Department public class Department : NotifyObject
{ {
private bool isSelected;
public string Id { get; set; } public string Id { get; set; }
public string Name { get; set; } public string Name { get; set; }
public IList<Shop> ShopList { get; set; } public IList<Shop> ShopList { get; set; }
public bool IsSelected
{
get => isSelected;
set
{
if (Set(ref isSelected, value))
OnIsSelectedChanged?.Invoke();
}
}
public Department() public Department()
{ {
ShopList = new List<Shop>(); ShopList = new List<Shop>();
} }
public Action OnIsSelectedChanged { get; set; }
public override string ToString()
{
return this.Name;
}
} }
} }

58
BBWY.Client/ViewModels/FinancialTerminal/ProcurementAuditViewModel.cs

@ -17,6 +17,7 @@ using System.Windows;
using System.Windows.Input; using System.Windows.Input;
using BBWY.Common.Extensions; using BBWY.Common.Extensions;
using BBWY.Client.Views.FinancialTerminal; using BBWY.Client.Views.FinancialTerminal;
using Newtonsoft.Json;
namespace BBWY.Client.ViewModels namespace BBWY.Client.ViewModels
{ {
@ -30,7 +31,6 @@ namespace BBWY.Client.ViewModels
private bool onlyException; private bool onlyException;
private PurchaseOrderService purchaseOrderService; private PurchaseOrderService purchaseOrderService;
private FinancialTerminalService financialTerminalService; private FinancialTerminalService financialTerminalService;
private Department selectedDepartment;
private DateTime startDate; private DateTime startDate;
private DateTime endDate; private DateTime endDate;
private Shop selectResultShop; private Shop selectResultShop;
@ -38,17 +38,6 @@ namespace BBWY.Client.ViewModels
private bool noChooseFundType; private bool noChooseFundType;
private string searchResultPurchaseOrder; private string searchResultPurchaseOrder;
private Platform? selectPurchasePlatform; private Platform? selectPurchasePlatform;
public Department SelectedDepartment
{
get => selectedDepartment; set
{
if (Set(ref selectedDepartment, value))
{
foreach (var s in value.ShopList)
s.IsSelected = false;
}
}
}
public DateTime StartDate { get => startDate; set { Set(ref startDate, value); } } public DateTime StartDate { get => startDate; set { Set(ref startDate, value); } }
public DateTime EndDate { get => endDate; set { Set(ref endDate, value); } } public DateTime EndDate { get => endDate; set { Set(ref endDate, value); } }
@ -59,6 +48,8 @@ namespace BBWY.Client.ViewModels
public IList<Department> DepartmentList { get; set; } public IList<Department> DepartmentList { get; set; }
public IList<Shop> ShopList { get; set; }
public IList<AuditPayBill> ShowAuditPayBillList { get; set; } public IList<AuditPayBill> ShowAuditPayBillList { get; set; }
public AuditFile SelectAuditFile public AuditFile SelectAuditFile
@ -136,6 +127,7 @@ namespace BBWY.Client.ViewModels
this.financialTerminalService = financialTerminalService; this.financialTerminalService = financialTerminalService;
DepartmentList = new ObservableCollection<Department>(); DepartmentList = new ObservableCollection<Department>();
ShopList = new ObservableCollection<Shop>();
AuditFileList = new ObservableCollection<AuditFile>(); AuditFileList = new ObservableCollection<AuditFile>();
AuditPayBillList = new List<AuditPayBill>(); AuditPayBillList = new List<AuditPayBill>();
ShowAuditPayBillList = new ObservableCollection<AuditPayBill>(); ShowAuditPayBillList = new ObservableCollection<AuditPayBill>();
@ -144,11 +136,31 @@ namespace BBWY.Client.ViewModels
EndDate = DateTime.Now.Date; EndDate = DateTime.Now.Date;
} }
private void OnDeparmentSelectionChanged()
{
ShopList.Clear();
foreach (var d in DepartmentList)
{
if (!d.IsSelected)
continue;
foreach (var s in d.ShopList)
{
s.IsSelected = false;
ShopList.Add(s);
}
}
}
private void LoadDepartment() private void LoadDepartment()
{ {
foreach (var d in globalContext.User.DepartmentList) var dlist = JsonConvert.DeserializeObject<IList<Department>>(JsonConvert.SerializeObject(globalContext.User.DepartmentList));
foreach (var d in dlist)
{
d.IsSelected = false;
DepartmentList.Add(d); DepartmentList.Add(d);
SelectedDepartment = DepartmentList[0]; d.OnIsSelectedChanged = OnDeparmentSelectionChanged;
}
ShopList.Clear();
} }
private void SearchHistory() private void SearchHistory()
@ -157,7 +169,7 @@ namespace BBWY.Client.ViewModels
return; return;
ClearAudit(); ClearAudit();
IsLoading = true; IsLoading = true;
var importShopIds = string.Join(',', SelectedDepartment.ShopList.Where(s => s.IsSelected).Select(s => s.ShopId)); var importShopIds = string.Join(',', ShopList.Where(s => s.IsSelected).Select(s => s.ShopId));
Task.Factory.StartNew(() => financialTerminalService.GetAuditPayBillList(importShopIds, StartDate, EndDate)).ContinueWith(t => Task.Factory.StartNew(() => financialTerminalService.GetAuditPayBillList(importShopIds, StartDate, EndDate)).ContinueWith(t =>
{ {
IsLoading = false; IsLoading = false;
@ -173,7 +185,7 @@ namespace BBWY.Client.ViewModels
{ {
foreach (var b in list) foreach (var b in list)
{ {
b.Init(SelectedDepartment.ShopList); b.Init(ShopList);
AuditPayBillList.Add(b); AuditPayBillList.Add(b);
} }
SearchLocal(); SearchLocal();
@ -186,7 +198,7 @@ namespace BBWY.Client.ViewModels
{ {
if (IsLoading) if (IsLoading)
return; return;
if (AuditPayBillList.Count() == 0 || !SelectedDepartment.ShopList.Any(s => s.IsSelected)) if (AuditPayBillList.Count() == 0 || !ShopList.Any(s => s.IsSelected))
{ {
MessageBox.Show("审核数据不全", "提示"); MessageBox.Show("审核数据不全", "提示");
return; return;
@ -197,7 +209,7 @@ namespace BBWY.Client.ViewModels
new ManualResetEvent(false) new ManualResetEvent(false)
}; };
IsLoading = true; IsLoading = true;
var shopList = SelectedDepartment.ShopList.Where(s => s.IsSelected).ToList(); var shopList = ShopList.Where(s => s.IsSelected).ToList();
var sDate = StartDate.AddDays(-5); var sDate = StartDate.AddDays(-5);
var eDate = EndDate; var eDate = EndDate;
Task.Factory.StartNew(() => Task.Factory.StartNew(() =>
@ -529,7 +541,7 @@ namespace BBWY.Client.ViewModels
return; return;
} }
var importShopIds = string.Join(',', SelectedDepartment.ShopList.Where(s => s.IsSelected).Select(s => s.ShopId)); var importShopIds = string.Join(',', ShopList.Where(s => s.IsSelected).Select(s => s.ShopId));
var replaceResponse = financialTerminalService.IsExistAuditPayBill(importShopIds, StartDate, EndDate); var replaceResponse = financialTerminalService.IsExistAuditPayBill(importShopIds, StartDate, EndDate);
if (!replaceResponse.Success) if (!replaceResponse.Success)
@ -570,7 +582,7 @@ namespace BBWY.Client.ViewModels
{ {
if (ShowAuditPayBillList.Count == 0) if (ShowAuditPayBillList.Count == 0)
return; return;
var shopNames = string.Join(',', SelectedDepartment.ShopList.Where(s => s.IsSelected).Select(s => s.ShopName)); var shopNames = string.Join(',', ShopList.Where(s => s.IsSelected).Select(s => s.ShopName));
var ew = new ProcurementAuditExcelExport(); var ew = new ProcurementAuditExcelExport();
if (ew.ShowDialog() != true) if (ew.ShowDialog() != true)
@ -587,7 +599,7 @@ namespace BBWY.Client.ViewModels
else else
{ {
fileName = $"{StartDate:yyyy-MM-dd}_{EndDate:yyyy-MM-dd}_{shopNames}_资金类型汇总.csv"; fileName = $"{StartDate:yyyy-MM-dd}_{EndDate:yyyy-MM-dd}_{shopNames}_资金类型汇总.csv";
saveList.Add($"序号,资金类型,{string.Join(',', SelectedDepartment.ShopList)},汇总"); saveList.Add($"序号,资金类型,{string.Join(',', ShopList)},汇总");
var capitalGroups = ShowAuditPayBillList.Where(p => p.AuditCapitalType != null).GroupBy(p => p.AuditCapitalType); var capitalGroups = ShowAuditPayBillList.Where(p => p.AuditCapitalType != null).GroupBy(p => p.AuditCapitalType);
var index = 1; var index = 1;
var rowBuilder = new StringBuilder(); var rowBuilder = new StringBuilder();
@ -595,7 +607,7 @@ namespace BBWY.Client.ViewModels
{ {
var sum = 0M; var sum = 0M;
rowBuilder.Append($"{index},{capitalGroup.Key},"); rowBuilder.Append($"{index},{capitalGroup.Key},");
foreach (var shop in SelectedDepartment.ShopList) foreach (var shop in ShopList)
{ {
var currentShopCapitalGroup = capitalGroup.Where(p => p.BelongShopId == shop.ShopId); var currentShopCapitalGroup = capitalGroup.Where(p => p.BelongShopId == shop.ShopId);
var amount = 0M; var amount = 0M;
@ -641,5 +653,7 @@ namespace BBWY.Client.ViewModels
{ {
auditPayBill.AuditCapitalTypeInputMode = 0; auditPayBill.AuditCapitalTypeInputMode = 0;
} }
} }
} }

27
BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml

@ -48,11 +48,24 @@
</ResourceDictionary> </ResourceDictionary>
</Border.Resources> </Border.Resources>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center"> <StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<ComboBox Width="Auto" ItemsSource="{Binding DepartmentList}" <hc:CheckComboBox IsTextSearchEnabled="True" ItemsSource="{Binding DepartmentList}"
DisplayMemberPath="Name" ShowClearButton="True"
SelectedItem="{Binding SelectedDepartment,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/> MinWidth="150">
<!--<ComboBox Width="100" Margin="5,0,0,0"/>--> <hc:CheckComboBox.ItemTemplate>
<hc:CheckComboBox IsTextSearchEnabled="True" ItemsSource="{Binding SelectedDepartment.ShopList}" <DataTemplate>
<StackPanel Orientation="Horizontal" Margin="5,2.5">
<CheckBox Content="{Binding Name}" IsChecked="{Binding IsSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
</StackPanel>
</DataTemplate>
</hc:CheckComboBox.ItemTemplate>
<hc:CheckComboBox.ItemContainerStyle>
<Style TargetType="{x:Type hc:CheckComboBoxItem}" BasedOn="{StaticResource NoBgListBoxItemStyle}">
<Setter Property="IsSelected" Value="{Binding IsSelected,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
</Style>
</hc:CheckComboBox.ItemContainerStyle>
</hc:CheckComboBox>
<hc:CheckComboBox IsTextSearchEnabled="True" ItemsSource="{Binding ShopList}"
ShowClearButton="True" ShowClearButton="True"
MinWidth="150"> MinWidth="150">
<hc:CheckComboBox.ItemTemplate> <hc:CheckComboBox.ItemTemplate>
@ -70,7 +83,7 @@
</hc:CheckComboBox> </hc:CheckComboBox>
<DatePicker Height="30" Margin="5,0,0,0" SelectedDate="{Binding StartDate,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/> <DatePicker Height="30" Margin="5,0,0,0" SelectedDate="{Binding StartDate,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<DatePicker Height="30" Margin="5,0,0,0" SelectedDate="{Binding EndDate,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/> <DatePicker Height="30" Margin="5,0,0,0" SelectedDate="{Binding EndDate,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
<c:BButton Content="查询" Margin="5,0,0,0" Padding="10,0" Command="{Binding SearchHistoryCommand}"/> <c:BButton Content="查询历史" Margin="5,0,0,0" Padding="10,0" Command="{Binding SearchHistoryCommand}"/>
<c:BButton Content="审计" Padding="10,0" Command="{Binding AuditCommand}" Background="#02A7F0"/> <c:BButton Content="审计" Padding="10,0" Command="{Binding AuditCommand}" Background="#02A7F0"/>
<c:BButton Content="清空" Padding="10,0" Command="{Binding ClearAuditCommand}" Background="{StaticResource Text.Pink}"/> <c:BButton Content="清空" Padding="10,0" Command="{Binding ClearAuditCommand}" Background="{StaticResource Text.Pink}"/>
</StackPanel> </StackPanel>
@ -163,7 +176,7 @@
<Grid Grid.Row="6" Background="{StaticResource Border.Background}"> <Grid Grid.Row="6" Background="{StaticResource Border.Background}">
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
<TextBlock Text="店铺名称" VerticalAlignment="Center" Margin="5,0,0,0"/> <TextBlock Text="店铺名称" VerticalAlignment="Center" Margin="5,0,0,0"/>
<ComboBox Margin="5,0,0,0" ItemsSource="{Binding SelectedDepartment.ShopList}" <ComboBox Margin="5,0,0,0" ItemsSource="{Binding ShopList}"
SelectedItem="{Binding SelectResultShop,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" SelectedItem="{Binding SelectResultShop,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
VerticalContentAlignment="Center" VerticalContentAlignment="Center"
VerticalAlignment="Center" Height="25"/> VerticalAlignment="Center" Height="25"/>

Loading…
Cancel
Save