using BBWY.Client.APIServices; using BBWY.Client.Models.APIModel.Response.PackTask; using NPOI.POIFS.Crypt.Dsig; using NPOI.SS.Formula.Functions; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Markup; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace BBWY.Client.Views.PackTask { /// <summary> /// FeesExcelControl.xaml 的交互逻辑 /// </summary> public partial class FeesExcelControl : UserControl { /// <summary> /// 是否仓库端 /// </summary> public bool IsWareHouse { get { return (bool)GetValue(IsWareHouseProperty); } set { SetValue(IsWareHouseProperty, value); } } public static readonly DependencyProperty IsWareHouseProperty = DependencyProperty.Register("IsWareHouse", typeof(bool), typeof(FeesExcelControl), new PropertyMetadata(true, ChangedProperty1)); public bool IsMin { get { return (bool)GetValue(IsMinProperty); } set { SetValue(IsMinProperty, value); } } public static readonly DependencyProperty IsMinProperty = DependencyProperty.Register("IsMin", typeof(bool), typeof(FeesExcelControl)); public FeesItemResponse FeesItem { get { return (FeesItemResponse)GetValue(FeesItemProperty); } set { SetValue(FeesItemProperty, value); } } public static readonly DependencyProperty FeesItemProperty = DependencyProperty.Register("FeesItem", typeof(FeesItemResponse), typeof(FeesExcelControl), new PropertyMetadata(ChangedProperty)); private static void ChangedProperty1(DependencyObject d, DependencyPropertyChangedEventArgs e) { var control = d as FeesExcelControl; var newValue = e.NewValue as FeesItemResponse; } private static void ChangedProperty(DependencyObject d, DependencyPropertyChangedEventArgs e) { var control = d as FeesExcelControl; // control.Str var newValue = e.NewValue as FeesItemResponse; control.FeesItem = newValue; if (control.IsWareHouse) { control.LoadData(false); } else { control.LoadData(true); } } public FeesExcelControl() { InitializeComponent(); } string xaml = @" <Grid xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""> <Grid.ColumnDefinitions > <ColumnDefinition [:Visity:] /> [:Columns:] </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height=""30"" /> <RowDefinition Height=""30"" /> <RowDefinition Height=""30"" /> <RowDefinition Height=""30"" /> </Grid.RowDefinitions> <Border Background=""#F2F2F2"" Grid.RowSpan=""3"" Grid.ColumnSpan=""[:ColumnCount:]""/> <Border Width=""1"" HorizontalAlignment=""Left"" BorderBrush=""#D7D7D7"" Grid.Column=""0"" Grid.Row=""0"" Grid.RowSpan=""4"" BorderThickness=""1,0,0,0""/> <Border Width=""1"" HorizontalAlignment=""Left"" BorderBrush=""#D7D7D7"" Grid.Column=""1"" Grid.Row=""0"" Grid.RowSpan=""4"" BorderThickness=""1,0,0,0""/> <Border Width=""1"" HorizontalAlignment=""Right"" BorderBrush=""#D7D7D7"" Grid.Column=""[:1+IncreateCount+ProcessCount:+ConsumableCount]"" Grid.Row=""0"" Grid.RowSpan=""4"" BorderThickness=""0,0,1,0""/> <Border Height=""1"" VerticalAlignment=""Top"" BorderBrush=""#D7D7D7"" Grid.Column=""0"" Grid.Row=""0"" Grid.ColumnSpan=""[:ColumnCount:]"" BorderThickness=""0,1,0,0""/> <Border Height=""1"" VerticalAlignment=""Top"" BorderBrush=""#D7D7D7"" Grid.Column=""1"" Grid.Row=""1"" Grid.ColumnSpan=""[:ColumnCount-2:]"" BorderThickness=""0,1,0,0""/> <Border Height=""1"" VerticalAlignment=""Bottom"" BorderBrush=""#D7D7D7"" Grid.Column=""0"" Grid.Row=""2"" Grid.ColumnSpan=""[:ColumnCount:]"" BorderThickness=""0,1,0,0""/> <Border Height=""1"" VerticalAlignment=""Bottom"" BorderBrush=""#D7D7D7"" Grid.Column=""0"" Grid.Row=""3"" Grid.ColumnSpan=""[:ColumnCount:]"" BorderThickness=""0,1,0,0""/> <TextBlock MinWidth=""84"" Text=""任务ID"" TextAlignment=""Center"" Grid.Column=""0"" Grid.RowSpan=""3"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> [:Header:] <TextBlock MinWidth=""101"" TextAlignment=""Center"" Text=""结算金额"" Grid.Column=""[:1+IncreateCount+ProcessCount:+ConsumableCount]"" Grid.RowSpan=""3"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <TextBlock Text=""[:TaskId:]"" Grid.Row=""3"" Grid.Column=""0"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <TextBlock Text=""[:AllFees:]"" Grid.Row=""3"" Grid.Column=""[:1+IncreateCount+ProcessCount:+ConsumableCount]"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> [:ListData:] </Grid>"; string oldxaml = @" <Grid xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""> <Grid.ColumnDefinitions > [:Columns:] </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height=""30"" /> <RowDefinition Height=""30"" /> <RowDefinition Height=""30"" /> </Grid.RowDefinitions> <Border Background=""#F2F2F2"" Grid.RowSpan=""2"" Grid.ColumnSpan=""[:ColumnCount:]""/> <Border Width=""1"" HorizontalAlignment=""Left"" BorderBrush=""#D7D7D7"" Grid.Column=""0"" Grid.Row=""0"" Grid.RowSpan=""3"" BorderThickness=""1,0,0,0""/> <Border Width=""1"" HorizontalAlignment=""Left"" BorderBrush=""#D7D7D7"" Grid.Column=""1"" Grid.Row=""0"" Grid.RowSpan=""3"" BorderThickness=""1,0,0,0""/> <Border Width=""1"" HorizontalAlignment=""Right"" BorderBrush=""#D7D7D7"" Grid.Column=""[:1+IncreateCount+ProcessCount:+ConsumableCount]"" Grid.Row=""0"" Grid.RowSpan=""3"" BorderThickness=""0,0,1,0""/> <Border Width=""1"" HorizontalAlignment=""Right"" BorderBrush=""#D7D7D7"" Grid.Column=""[:2+IncreateCount+ProcessCount:+ConsumableCount]"" Grid.Row=""0"" Grid.RowSpan=""3"" BorderThickness=""0,0,1,0""/> <Border Width=""1"" HorizontalAlignment=""Right"" BorderBrush=""#D7D7D7"" Grid.Column=""[:3+IncreateCount+ProcessCount:+ConsumableCount]"" Grid.Row=""0"" Grid.RowSpan=""3"" BorderThickness=""0,0,1,0""/> <Border Height=""1"" VerticalAlignment=""Top"" BorderBrush=""#D7D7D7"" Grid.Column=""0"" Grid.Row=""0"" Grid.ColumnSpan=""[:ColumnCount:]"" BorderThickness=""0,1,0,0""/> <Border Height=""1"" VerticalAlignment=""Top"" BorderBrush=""#D7D7D7"" Grid.Column=""1"" Grid.Row=""1"" Grid.ColumnSpan=""[:ColumnCount-2:]"" BorderThickness=""0,1,0,0""/> <Border Height=""1"" VerticalAlignment=""Bottom"" BorderBrush=""#D7D7D7"" Grid.Column=""0"" Grid.Row=""1"" Grid.ColumnSpan=""[:ColumnCount:]"" BorderThickness=""0,1,0,0""/> <Border Height=""1"" VerticalAlignment=""Bottom"" BorderBrush=""#D7D7D7"" Grid.Column=""0"" Grid.Row=""2"" Grid.ColumnSpan=""[:ColumnCount:]"" BorderThickness=""0,1,0,0""/> <TextBlock MinWidth=""84"" Text=""任务ID"" TextAlignment=""Center"" Grid.Column=""0"" Grid.RowSpan=""2"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> [:Header:] <TextBlock MinWidth=""101"" TextAlignment=""Center"" Text=""原始金额"" Grid.Column=""[:1+IncreateCount+ProcessCount:+ConsumableCount]"" Grid.RowSpan=""2"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <TextBlock MinWidth=""101"" TextAlignment=""Center"" Text=""折扣系数"" Grid.Column=""[:2+IncreateCount+ProcessCount:+ConsumableCount]"" Grid.RowSpan=""2"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <TextBlock MinWidth=""101"" TextAlignment=""Center"" Text=""结算金额"" Grid.Column=""[:3+IncreateCount+ProcessCount:+ConsumableCount]"" Grid.RowSpan=""2"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <TextBlock Text=""[:TaskId:]"" Grid.Row=""2"" Grid.Column=""0"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <TextBlock Text=""[:AllFees:]"" Grid.Row=""2"" Grid.Column=""[:1+IncreateCount+ProcessCount:+ConsumableCount]"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <TextBlock Text=""[:Discount:]"" Grid.Row=""2"" Grid.Column=""[:2+IncreateCount+ProcessCount:+ConsumableCount]"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <TextBlock Text=""[:DiscountFees:]"" Grid.Row=""2"" Grid.Column=""[:3+IncreateCount+ProcessCount:+ConsumableCount]"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> [:ListData:] </Grid>"; /// <summary> /// index 从1开始 0+1 增值服务 和包装耗材 /// </summary> string columnData = @" <Grid Grid.Column=""[:index:]"" MinWidth=""84"" Grid.Row=""1"" Grid.RowSpan=""3"" > <Grid.RowDefinitions> <RowDefinition Height=""*""/> <RowDefinition Height=""*""/> </Grid.RowDefinitions> <Border Width=""1"" HorizontalAlignment=""Left"" BorderBrush=""#D7D7D7"" Grid.RowSpan=""2"" BorderThickness=""0,0,1,0""/> <TextBlock Text=""[:ServiceName:]"" Grid.Row=""0"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <TextBlock Text=""[:ServiceCount:]"" Grid.Row=""1"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> </Grid>"; string packProcessColumnData = @""; string incrementConsumableStr = @" <Grid Grid.Column=""[:index:]"" MinWidth=""84"" Grid.Row=""1"" Grid.RowSpan=""3"" > <Grid.RowDefinitions> <RowDefinition Height=""2*""/> <RowDefinition Height=""*""/> </Grid.RowDefinitions> <Border Width=""1"" HorizontalAlignment=""Left"" BorderBrush=""#D7D7D7"" Grid.RowSpan=""2"" BorderThickness=""0,0,1,0""/> <TextBlock Text=""[:ServiceName:]"" Grid.Row=""0"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <TextBlock Text=""[:ServiceCount:]"" Grid.Row=""1"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> </Grid>"; string totalIncrementConsumableStr = @" <Grid Grid.Column=""[:index:]"" MinWidth=""84"" Grid.Row=""1"" Grid.RowSpan=""3"" > <Grid.RowDefinitions> <RowDefinition Height=""2*""/> <RowDefinition Height=""*""/> </Grid.RowDefinitions> <Border Width=""1"" HorizontalAlignment=""Left"" BorderBrush=""#D7D7D7"" Grid.RowSpan=""2"" BorderThickness=""0,0,1,0""/> <TextBlock Text=""小计"" Grid.Row=""0"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <TextBlock Text=""[:Price:]"" Grid.Row=""1"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> </Grid>"; string basicPackStr = @" <Grid Grid.Column=""[:index:]"" MinWidth=""[:BasicPackWidth:]"" Grid.Row=""1"" Grid.RowSpan=""3"" > <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <Border Width=""1"" HorizontalAlignment=""Left"" BorderBrush=""#D7D7D7"" Grid.RowSpan=""2"" BorderThickness=""0,0,1,0""/> <TextBlock Text=""基础包装"" Grid.Row=""0"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <Grid Grid.Row=""1"" > <Grid.ColumnDefinitions> [:Columns:] </Grid.ColumnDefinitions> [:BasicProcessData:] <Border Height=""1"" VerticalAlignment=""Top"" BorderBrush=""#D7D7D7"" Grid.Row=""1"" Grid.ColumnSpan=""2"" BorderThickness=""0,1,0,0""/> </Grid> <TextBlock Text=""[:ServiceCount:]"" Grid.Row=""3"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <Border Width=""1"" HorizontalAlignment=""Left"" BorderBrush=""#D7D7D7"" Grid.Row=""0"" Grid.RowSpan=""3"" BorderThickness=""1,0,0,0""/> </Grid>"; string basicProcessdata = @" <TextBlock Text=""[:ServiceName:]"" Grid.Column=""[:index:]"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <Border Width=""1"" HorizontalAlignment=""Right"" BorderBrush=""#D7D7D7"" BorderThickness=""0,0,1,0""/>"; string increateProcessStr = @"<Grid Grid.Column=""[:index:]"" Grid.Row=""1"" Grid.RowSpan=""3"" > <Grid.RowDefinitions> <RowDefinition Height=""*""/> <RowDefinition Height=""2*""/> </Grid.RowDefinitions> <TextBlock Text=""增量工序"" Grid.Row=""0"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <Grid Grid.Row=""1""> <Grid.ColumnDefinitions> [:Columns:] </Grid.ColumnDefinitions> [:IncreateProcessDatas:] <Border Height=""1"" VerticalAlignment=""Top"" BorderBrush=""#D7D7D7"" Grid.Row=""1"" Grid.ColumnSpan=""[:IncreateProcessCount:]"" BorderThickness=""0,1,0,0""/> </Grid> <Border Width=""1"" HorizontalAlignment=""Left"" BorderBrush=""#D7D7D7"" Grid.Row=""0"" Grid.RowSpan=""3"" BorderThickness=""1,0,0,0""/> </Grid>"; string increateProcessData = @" <Grid Grid.Column=""[:index:]"" MinWidth=""84"" Grid.Row=""1"" Grid.RowSpan=""2"" > <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <Border Width=""1"" HorizontalAlignment=""Left"" BorderBrush=""#D7D7D7"" Grid.RowSpan=""2"" BorderThickness=""0,0,1,0""/> <TextBlock Text=""[:ServiceName:]"" Grid.Row=""0"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <TextBlock Text=""[:ServiceCount:]"" Grid.Row=""1"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> </Grid>"; string increatePartData = @"<Grid Grid.Column=""[:index:]"" MinWidth=""84"" Grid.Row=""1"" Grid.RowSpan=""3"" > <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <TextBlock Text=""增量配件"" Grid.Row=""0"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <TextBlock Text=""[:PartCount:]件"" Grid.Row=""1"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <TextBlock Text=""[:ServiceCount:]"" Grid.Row=""2"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <Border Height=""1"" VerticalAlignment=""Top"" Grid.Row=""1"" BorderBrush=""#D7D7D7"" BorderThickness=""0,1,0,0""/> <Border Width=""1"" HorizontalAlignment=""Left"" BorderBrush=""#D7D7D7"" Grid.RowSpan=""3"" BorderThickness=""0,0,1,0""/> </Grid>"; string FeesModeStr = @"<Grid Grid.Column=""[:index:]"" MinWidth=""84"" Grid.Row=""1"" Grid.RowSpan=""3"" > <Grid.RowDefinitions> <RowDefinition Height=""2*""/> <RowDefinition Height=""*""/> </Grid.RowDefinitions> <Border Width=""1"" HorizontalAlignment=""Left"" BorderBrush=""#D7D7D7"" Grid.RowSpan=""2"" BorderThickness=""0,0,1,0""/> <TextBlock Text=""收费方式"" Grid.Row=""0"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <TextBlock Text=""[:FeesMode:]"" Grid.Row=""1"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> </Grid>"; string discountFactorStr = @" <Grid Grid.Column=""[:index:]"" MinWidth=""84"" Grid.Row=""1"" Grid.RowSpan=""3"" > <Grid.RowDefinitions> <RowDefinition Height=""2*""/> <RowDefinition Height=""*""/> </Grid.RowDefinitions> <Border Width=""1"" HorizontalAlignment=""Left"" BorderBrush=""#D7D7D7"" Grid.RowSpan=""2"" BorderThickness=""0,0,1,0""/> <TextBlock Text=""折扣系数"" Grid.Row=""0"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <TextBlock Text=""[:DiscountFactor:]"" Grid.Row=""1"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> </Grid>"; string processFeesStr = @" <Grid Grid.Column=""[:index:]"" MinWidth=""84"" Grid.Row=""1"" Grid.RowSpan=""3"" > <Grid.RowDefinitions> <RowDefinition Height=""2*""/> <RowDefinition Height=""*""/> </Grid.RowDefinitions> <Border Width=""1"" HorizontalAlignment=""Left"" BorderBrush=""#D7D7D7"" Grid.RowSpan=""2"" BorderThickness=""0,0,1,0""/> <TextBlock Text=""小计"" Grid.Row=""0"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <TextBlock Text=""[:PackFees:]"" Grid.Row=""1"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> </Grid>"; string columnStr = "<ColumnDefinition Width=\"[:Width:]\"/>"; string increateService = @" <TextBlock Text=""增值服务"" Grid.Column=""1"" Grid.ColumnSpan=""2"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/> <Border Width=""1"" HorizontalAlignment=""Left"" BorderBrush=""#D7D7D7"" Grid.Column=""[:1+IncreateCount:]"" Grid.Row=""0"" Grid.RowSpan=""4"" BorderThickness=""1,0,0,0""/>"; string workProcess = "<TextBlock Text=\"包装服务\" Grid.Column=\"[:1+IncreateCount:]\" Grid.ColumnSpan=\"[:ProcessCount:]\" VerticalAlignment=\"Center\" HorizontalAlignment=\"Center\"/>\r\n <Border Width=\"1\" HorizontalAlignment=\"Left\" BorderBrush=\"#D7D7D7\" Grid.Column=\"[:1+IncreateCount+ProcessCount:]\" Grid.Row=\"0\" Grid.RowSpan=\"4\" BorderThickness=\"1,0,0,0\"/>\r\n "; string consumableService = "<TextBlock Text=\"包装耗材\" Grid.Column=\"[:1+IncreateCount+ProcessCount:]\" Grid.ColumnSpan=\"[:ConsumableCount:]\" VerticalAlignment=\"Center\" HorizontalAlignment=\"Center\"/>\r\n <Border Width=\"1\" HorizontalAlignment=\"Left\" BorderBrush=\"#D7D7D7\" Grid.Column=\"[:1+IncreateCount+ProcessCount:+ConsumableCount]\" Grid.Row=\"0\" Grid.RowSpan=\"4\" BorderThickness=\"1,0,0,0\"/>\r\n "; private void LoadData(bool isPrice) { isPrice = false; if (FeesItem == null || FeesItem.ServiceList.Count <= 0 || FeesItem.ProcessComboTaskCount > 0) { return; } try { App.Current.Dispatcher.Invoke(() => { gd.Children.Clear(); }); int packserviceCount = 0; bool isExitIncrementPart = false; if (FeesItem.IncrementPartTaskCount != null && FeesItem.IncrementPartTaskCount > 0 && FeesItem.IncrementPartCount > 1) { isExitIncrementPart = true; packserviceCount++; } var increateList = FeesItem.IncreateList; var basicProcessList = FeesItem.PackItemList.Where(f => f.ProcessType == Models.ProcessType.基础包装工序).ToList(); if (basicProcessList.Count > 0) packserviceCount++; var increateProcessList = FeesItem.PackItemList.Where(f => f.ProcessType == Models.ProcessType.增值服务工序).ToList(); if (increateProcessList.Count > 0) packserviceCount++; var processList = FeesItem.PackItemList; var consumableList = FeesItem.ConsumableList; if (packserviceCount > 0) packserviceCount += 3; var increateCount = increateList.Count(); var processCount = packserviceCount; var consumableCount = consumableList.Count(); if (consumableCount > 0) { consumableCount++; } if (increateCount > 0) { increateCount++; } if (IsMin) { columnStr = columnStr.Replace("[:Width:]", "Auto"); } else { columnStr = columnStr.Replace("[:Width:]", "*"); } var columnCount = consumableCount + processCount + increateCount + 2; StringBuilder columns = new StringBuilder(); for (int i = 0; i < columnCount; i++) { columns.AppendLine(columnStr); } StringBuilder serviceData = new StringBuilder(); int allCount = consumableCount + processCount + increateCount; int rowIndex = 0; if (increateList.Count > 0) { foreach (var item in increateList) { rowIndex++; serviceData.AppendLine(incrementConsumableStr.Replace("[:index:]", $"{rowIndex}") .Replace("[:ServiceName:]", $"{item.ItemName}") .Replace("[:ServiceCount:]", $"{item.ItemPrice}*{item.ItemCount}")); } rowIndex++; serviceData.AppendLine(totalIncrementConsumableStr.Replace("[:index:]", $"{rowIndex}") .Replace("[:Price:]", $"{FeesItem.IncreateFees}") ); //totalIncrementConsumableStr } if (basicProcessList.Count > 0)//包装服务 { rowIndex++; StringBuilder basicSB = new StringBuilder(); StringBuilder basiccolumns = new StringBuilder(); for (int i = 0; i < basicProcessList.Count; i++) { basicSB.AppendLine(basicProcessdata.Replace("[:index:]", $"{i}") .Replace("[:ServiceName:]", $" {basicProcessList[i].ItemName} ") .Replace("[:ServiceCount:]", $"{basicProcessList[i].ItemPrice}*{basicProcessList[i].ItemCount}")); basiccolumns.AppendLine(columnStr); } if (basicProcessList.Count == 1) serviceData.AppendLine(basicPackStr.Replace("[:BasicPackWidth:]", $"{84}") .Replace("[:index:]", $"{rowIndex}") .Replace("[:Columns:]", $"{basiccolumns}") .Replace("[:ServiceCount:]", $"{FeesItem.BasicProcessPrice}*{FeesItem.BasicProcessCount}") .Replace("[:BasicProcessData:]", basicSB.ToString())); if (basicProcessList.Count > 1) serviceData.AppendLine(basicPackStr.Replace("[:BasicPackWidth:]", $"{168}") .Replace("[:index:]", $"{rowIndex}") .Replace("[:Columns:]", $"{basiccolumns}") .Replace("[:ServiceCount:]", $"{FeesItem.BasicProcessPrice}*{FeesItem.BasicProcessCount}") .Replace("[:BasicProcessData:]", basicSB.ToString())); } if (increateProcessList.Count > 0) { rowIndex++; StringBuilder increateProcessSB = new StringBuilder(); StringBuilder increateProcesscolumns = new StringBuilder(); for (int i = 0; i < increateProcessList.Count(); i++) { increateProcessSB.AppendLine(increateProcessData.Replace("[:index:]", $"{i}") .Replace("[:ServiceName:]", $"{increateProcessList[i].ItemName}") .Replace("[:ServiceCount:]", $"{increateProcessList[i].ItemPrice}*{increateProcessList[i].ItemCount}")); increateProcesscolumns.AppendLine(columnStr); } //[:IncreateProcessCount:] serviceData.AppendLine(increateProcessStr.Replace("[:index:]", $"{rowIndex}") .Replace("[:IncreateProcessCount:]", $"{increateProcessList.Count()}") .Replace("[:Columns:]", $"{increateProcesscolumns}") .Replace("[:IncreateProcessDatas:]", $"{increateProcessSB.ToString()}") .Replace("[:ServiceCount:]", $"{FeesItem.BasicProcessPrice}*{FeesItem.BasicProcessCount}")); } if (isExitIncrementPart) { rowIndex++; serviceData.AppendLine(increatePartData.Replace("[:index:]", $"{rowIndex}") .Replace("[:PartCount:]", $"{FeesItem.IncrementPartCount}") .Replace("[:ServiceCount:]", $"{FeesItem.IncrementPartPrice}*{FeesItem.IncrementPartTaskCount}")); } if (processCount > 0) { rowIndex++; serviceData.AppendLine(FeesModeStr.Replace("[:index:]", $"{rowIndex}") .Replace("[:FeesMode:]", $"{FeesItem.FeesMode}")); rowIndex++; serviceData.AppendLine(discountFactorStr.Replace("[:index:]", $"{rowIndex}") .Replace("[:DiscountFactor:]", $"{FeesItem.DiscountFoctor}") ); rowIndex++; serviceData.AppendLine(processFeesStr.Replace("[:index:]", $"{rowIndex}") .Replace("[:PackFees:]", $"{FeesItem.PackFees}") ); } if (consumableList.Count > 0) { foreach (var item in consumableList) { rowIndex++; serviceData.AppendLine(incrementConsumableStr.Replace("[:index:]", $"{rowIndex}") .Replace("[:ServiceName:]", $"{item.ItemName}") .Replace("[:ServiceCount:]", $"{item.ItemPrice}*{item.ItemCount}")); } rowIndex++; serviceData.AppendLine(totalIncrementConsumableStr.Replace("[:index:]", $"{rowIndex}") .Replace("[:Price:]", $"{FeesItem.ConsumableFees}") ); } StringBuilder header = new StringBuilder(); if (increateCount > 0) { header.AppendLine(increateService); } if (processCount > 0) { header.AppendLine(workProcess); } if (consumableCount > 0) { header.AppendLine(consumableService); } decimal allFees = 0; decimal discount = 0; decimal discountFees = 0; discount = FeesItem.disCount; allFees = FeesItem.AllFees; discountFees = allFees * discount; string discountStr = "原价"; if (discount > 1) discountStr = $"{discount.ToString("0.0")}倍"; if (discount < 1) discountStr = $"{(discount * 10).ToString("0.0")}折"; var newGrid = xaml.Replace("[:Header:]", header.ToString()) .Replace("[:Columns:]", columns.ToString()) .Replace("[:ColumnCount:]", $"{columnCount}") .Replace("[:ColumnCount-2:]", $"{columnCount - 2}") .Replace("[:1+IncreateCount:]", $"{increateCount + 1}") .Replace("[:1+IncreateCount+ProcessCount:]", $"{1 + increateCount + processCount}") .Replace("[:1+IncreateCount+ProcessCount:+ConsumableCount]", $"{1 + increateCount + processCount + consumableCount}") .Replace("[:2+IncreateCount+ProcessCount:+ConsumableCount]", $"{2 + increateCount + processCount + consumableCount}") .Replace("[:3+IncreateCount+ProcessCount:+ConsumableCount]", $"{3 + increateCount + processCount + consumableCount}") .Replace("[:IncreateCount:]", $"{increateCount}") .Replace("[:ProcessCount:]", $"{processCount}") .Replace("[:ConsumableCount:]", $"{consumableCount}") .Replace("[:TaskId:]", $"{FeesItem.TaskId}") .Replace("[:ListData:]", serviceData.ToString()) .Replace("[:AllFees:]", $"{FeesItem.AllFees}"); //.Replace("[:Discount:]", $"{FeesItem.DiscountFoctor}") //.Replace("[:DiscountFees:]", $"{discountFees.ToString(" 0.00")}"); if (IsMin) { newGrid = newGrid.Replace(@"MinWidth=""84""", "").Replace(@"[:Visity:]", "Width=\"0\""); } else { // newGrid = newGrid.Replace(@"[:Visity:]", ""); } var grid = XamlReader.Parse(newGrid) as Grid; App.Current.Dispatcher.Invoke(() => { gd.Children.Add(grid); }); } catch { } } } }