diff --git a/BBWY.Client/Models/Shop/Department.cs b/BBWY.Client/Models/Shop/Department.cs index 8da5ed12..24a63f07 100644 --- a/BBWY.Client/Models/Shop/Department.cs +++ b/BBWY.Client/Models/Shop/Department.cs @@ -1,18 +1,37 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; namespace BBWY.Client.Models { - public class Department + public class Department : NotifyObject { + private bool isSelected; + public string Id { get; set; } public string Name { get; set; } public IList ShopList { get; set; } + public bool IsSelected + { + get => isSelected; + set + { + if (Set(ref isSelected, value)) + OnIsSelectedChanged?.Invoke(); + } + } public Department() { ShopList = new List(); } + + public Action OnIsSelectedChanged { get; set; } + + public override string ToString() + { + return this.Name; + } } } diff --git a/BBWY.Client/ViewModels/FinancialTerminal/ProcurementAuditViewModel.cs b/BBWY.Client/ViewModels/FinancialTerminal/ProcurementAuditViewModel.cs index 72188d6e..91885625 100644 --- a/BBWY.Client/ViewModels/FinancialTerminal/ProcurementAuditViewModel.cs +++ b/BBWY.Client/ViewModels/FinancialTerminal/ProcurementAuditViewModel.cs @@ -17,6 +17,7 @@ using System.Windows; using System.Windows.Input; using BBWY.Common.Extensions; using BBWY.Client.Views.FinancialTerminal; +using Newtonsoft.Json; namespace BBWY.Client.ViewModels { @@ -30,7 +31,6 @@ namespace BBWY.Client.ViewModels private bool onlyException; private PurchaseOrderService purchaseOrderService; private FinancialTerminalService financialTerminalService; - private Department selectedDepartment; private DateTime startDate; private DateTime endDate; private Shop selectResultShop; @@ -38,17 +38,6 @@ namespace BBWY.Client.ViewModels private bool noChooseFundType; private string searchResultPurchaseOrder; 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 EndDate { get => endDate; set { Set(ref endDate, value); } } @@ -59,6 +48,8 @@ namespace BBWY.Client.ViewModels public IList DepartmentList { get; set; } + public IList ShopList { get; set; } + public IList ShowAuditPayBillList { get; set; } public AuditFile SelectAuditFile @@ -136,6 +127,7 @@ namespace BBWY.Client.ViewModels this.financialTerminalService = financialTerminalService; DepartmentList = new ObservableCollection(); + ShopList = new ObservableCollection(); AuditFileList = new ObservableCollection(); AuditPayBillList = new List(); ShowAuditPayBillList = new ObservableCollection(); @@ -144,11 +136,31 @@ namespace BBWY.Client.ViewModels 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() { - foreach (var d in globalContext.User.DepartmentList) + var dlist = JsonConvert.DeserializeObject>(JsonConvert.SerializeObject(globalContext.User.DepartmentList)); + foreach (var d in dlist) + { + d.IsSelected = false; DepartmentList.Add(d); - SelectedDepartment = DepartmentList[0]; + d.OnIsSelectedChanged = OnDeparmentSelectionChanged; + } + ShopList.Clear(); } private void SearchHistory() @@ -157,7 +169,7 @@ namespace BBWY.Client.ViewModels return; ClearAudit(); 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 => { IsLoading = false; @@ -173,7 +185,7 @@ namespace BBWY.Client.ViewModels { foreach (var b in list) { - b.Init(SelectedDepartment.ShopList); + b.Init(ShopList); AuditPayBillList.Add(b); } SearchLocal(); @@ -186,7 +198,7 @@ namespace BBWY.Client.ViewModels { if (IsLoading) return; - if (AuditPayBillList.Count() == 0 || !SelectedDepartment.ShopList.Any(s => s.IsSelected)) + if (AuditPayBillList.Count() == 0 || !ShopList.Any(s => s.IsSelected)) { MessageBox.Show("审核数据不全", "提示"); return; @@ -197,7 +209,7 @@ namespace BBWY.Client.ViewModels new ManualResetEvent(false) }; 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 eDate = EndDate; Task.Factory.StartNew(() => @@ -529,7 +541,7 @@ namespace BBWY.Client.ViewModels 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); if (!replaceResponse.Success) @@ -570,7 +582,7 @@ namespace BBWY.Client.ViewModels { if (ShowAuditPayBillList.Count == 0) 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(); if (ew.ShowDialog() != true) @@ -587,7 +599,7 @@ namespace BBWY.Client.ViewModels else { 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 index = 1; var rowBuilder = new StringBuilder(); @@ -595,7 +607,7 @@ namespace BBWY.Client.ViewModels { var sum = 0M; 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 amount = 0M; @@ -641,5 +653,7 @@ namespace BBWY.Client.ViewModels { auditPayBill.AuditCapitalTypeInputMode = 0; } + + } } diff --git a/BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml b/BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml index bee5025b..c5da2dd7 100644 --- a/BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml +++ b/BBWY.Client/Views/FinancialTerminal/ProcurementAudit.xaml @@ -48,11 +48,24 @@ - - - + + + + + + + + + + + + + @@ -70,7 +83,7 @@ - + @@ -163,7 +176,7 @@ -