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.
355 lines
17 KiB
355 lines
17 KiB
using BBWY.Client.Models.APIModel.Response.PackTask;
|
|
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.Markup;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Navigation;
|
|
using System.Windows.Shapes;
|
|
|
|
namespace BBWY.Client.Views.PackTask
|
|
{
|
|
/// <summary>
|
|
/// FeesExcelV2Control.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class FeesExcelV2Control : UserControl
|
|
{
|
|
public FeesExcelV2Control()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
public FeesItemResponse FeesItem
|
|
{
|
|
get
|
|
{
|
|
return (FeesItemResponse)GetValue(FeesItemProperty);
|
|
|
|
}
|
|
set
|
|
{
|
|
SetValue(FeesItemProperty, value);
|
|
}
|
|
}
|
|
public static readonly DependencyProperty FeesItemProperty =
|
|
DependencyProperty.Register("FeesItem", typeof(FeesItemResponse), typeof(FeesExcelV2Control), new PropertyMetadata(ChangedProperty));
|
|
|
|
|
|
private static void ChangedProperty(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
var control = d as FeesExcelV2Control;
|
|
var newValue = e.NewValue as FeesItemResponse;
|
|
control.FeesItem = newValue;
|
|
|
|
|
|
control.LoadData();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
string xaml = @" <Grid xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"">
|
|
<Grid.ColumnDefinitions >
|
|
<ColumnDefinition />
|
|
[: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+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+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+ProcessCount:+ConsumableCount]"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/>
|
|
[:ListData:]
|
|
</Grid>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string processComboStr1 = @"<Grid Grid.Column=""1"" MinWidth=""84"" 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""/>
|
|
<TextBlock Text=""[:ProcessTypeName:]"" Grid.Row=""1"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/>
|
|
<Border Height=""1"" VerticalAlignment=""Bottom"" BorderBrush=""#D7D7D7"" Grid.Row=""0"" Grid.ColumnSpan=""2"" BorderThickness=""0,1,0,0""/>
|
|
|
|
<Border Width=""1"" HorizontalAlignment=""Left"" BorderBrush=""#D7D7D7"" Grid.Row=""0"" Grid.RowSpan=""3"" BorderThickness=""1,0,0,0""/>
|
|
<Border Width=""1"" HorizontalAlignment=""Left"" BorderBrush=""#D7D7D7"" Grid.Row=""0"" Grid.Column=""1"" Grid.RowSpan=""2"" BorderThickness=""1,0,0,0""/>
|
|
</Grid>
|
|
<Grid Grid.Column=""2"" MinWidth=""84"" 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"" Grid.Column=""1"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/>
|
|
<TextBlock Text=""[:ProcessComboName:]"" Grid.Row=""1"" Grid.Column=""1"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/>
|
|
|
|
|
|
|
|
|
|
<Border Height=""1"" VerticalAlignment=""Bottom"" BorderBrush=""#D7D7D7"" Grid.Row=""0"" Grid.ColumnSpan=""2"" BorderThickness=""0,1,0,0""/>
|
|
|
|
<Border Width=""1"" HorizontalAlignment=""Left"" BorderBrush=""#D7D7D7"" Grid.Row=""0"" Grid.RowSpan=""2"" BorderThickness=""1,0,0,0""/>
|
|
|
|
</Grid>
|
|
<TextBlock Text=""[:ProcessComboPrice:]"" Grid.Row=""3"" Grid.Column=""1"" Grid.ColumnSpan=""2"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/>";
|
|
|
|
|
|
|
|
|
|
string processComboStr = @" <Grid Grid.Column=""1"" MinWidth=""168"" Grid.Row=""1"" Grid.RowSpan=""3"" Grid.ColumnSpan=""2"" >
|
|
<Grid.RowDefinitions>
|
|
<RowDefinition />
|
|
<RowDefinition />
|
|
<RowDefinition />
|
|
</Grid.RowDefinitions>
|
|
<Grid.ColumnDefinitions>
|
|
<ColumnDefinition/>
|
|
<ColumnDefinition/>
|
|
</Grid.ColumnDefinitions>
|
|
<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=""[:ProcessTypeName:]"" Grid.Row=""1"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/>
|
|
|
|
|
|
<TextBlock Text="" 工序套餐 "" Grid.Row=""0"" Grid.Column=""1"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/>
|
|
<TextBlock Text=""[:ProcessComboName:]"" Grid.Row=""1"" Grid.Column=""1"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/>
|
|
|
|
|
|
<TextBlock Text=""[:ProcessComboPrice:]"" Grid.Row=""3"" Grid.ColumnSpan=""2"" VerticalAlignment=""Center"" HorizontalAlignment=""Center""/>
|
|
|
|
<Border Height=""1"" VerticalAlignment=""Bottom"" BorderBrush=""#D7D7D7"" Grid.Row=""0"" Grid.ColumnSpan=""2"" BorderThickness=""0,1,0,0""/>
|
|
|
|
<Border Width=""1"" HorizontalAlignment=""Left"" BorderBrush=""#D7D7D7"" Grid.Row=""0"" Grid.RowSpan=""3"" BorderThickness=""1,0,0,0""/>
|
|
<Border Width=""1"" HorizontalAlignment=""Left"" BorderBrush=""#D7D7D7"" Grid.Row=""0"" Grid.Column=""1"" Grid.RowSpan=""2"" BorderThickness=""1,0,0,0""/>
|
|
</Grid>";
|
|
|
|
|
|
|
|
|
|
string discountFactorStr = @" <Grid Grid.Column=""3"" 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=""4"" 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 workProcess = "<TextBlock Text=\"包装服务\" Grid.Column=\"1\" Grid.ColumnSpan=\"[:ProcessCount:]\" VerticalAlignment=\"Center\" HorizontalAlignment=\"Center\"/>\r\n <Border Width=\"1\" HorizontalAlignment=\"Left\" BorderBrush=\"#D7D7D7\" Grid.Column=\"[:1+ProcessCount:]\" Grid.Row=\"0\" Grid.RowSpan=\"4\" BorderThickness=\"1,0,0,0\"/>\r\n ";
|
|
|
|
string consumableService = "<TextBlock Text=\"包装耗材\" Grid.Column=\"[:1+ProcessCount:]\" Grid.ColumnSpan=\"[:ConsumableCount:]\" VerticalAlignment=\"Center\" HorizontalAlignment=\"Center\"/>\r\n <Border Width=\"1\" HorizontalAlignment=\"Left\" BorderBrush=\"#D7D7D7\" Grid.Column=\"[:1+ProcessCount:+ConsumableCount]\" Grid.Row=\"0\" Grid.RowSpan=\"4\" BorderThickness=\"1,0,0,0\"/>\r\n ";
|
|
|
|
|
|
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>";
|
|
|
|
|
|
|
|
private void LoadData()
|
|
{
|
|
|
|
if (FeesItem == null || FeesItem.ProcessComboTaskCount <= 0)
|
|
{
|
|
return;
|
|
}
|
|
try
|
|
{
|
|
|
|
App.Current.Dispatcher.Invoke(() =>
|
|
{
|
|
gd.Children.Clear();
|
|
});
|
|
|
|
|
|
|
|
var consumableList = FeesItem.ConsumableList;
|
|
|
|
var processCount = 4;
|
|
var consumableCount = consumableList.Count();
|
|
|
|
if (consumableCount > 0)
|
|
{
|
|
consumableCount++;
|
|
}
|
|
columnStr = columnStr.Replace("[:Width:]", "*");
|
|
var columnCount = consumableCount + processCount + 2;
|
|
StringBuilder columns = new StringBuilder();
|
|
for (int i = 1; i < columnCount; i++)
|
|
{
|
|
columns.AppendLine(columnStr);
|
|
}
|
|
StringBuilder serviceData = new StringBuilder();
|
|
|
|
int allCount = consumableCount + processCount;
|
|
|
|
|
|
|
|
|
|
|
|
serviceData.AppendLine(processComboStr.Replace("[:ProcessTypeName:]",$" {FeesItem.ProcessTypeName} " )
|
|
.Replace("[:ProcessComboName:]",$" {FeesItem.ProcessComboName} " )
|
|
.Replace("[:ProcessComboPrice:]", $"{FeesItem.ProcessComboPrice}*{FeesItem.ProcessComboTaskCount}")
|
|
);
|
|
|
|
serviceData.AppendLine(discountFactorStr.Replace("[:DiscountFactor:]", FeesItem.DiscountFoctor?.ToString()));
|
|
serviceData.AppendLine(processFeesStr.Replace("[:PackFees:]", FeesItem.PackFees.ToString("0.00")));
|
|
|
|
int rowIndex = 4;
|
|
|
|
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 (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+ProcessCount:]", $"{1 + processCount}")
|
|
.Replace("[:1+ProcessCount:+ConsumableCount]", $"{1 + processCount + consumableCount}")
|
|
.Replace("[:2+ProcessCount:+ConsumableCount]", $"{2 + processCount + consumableCount}")
|
|
.Replace("[:3+ProcessCount:+ConsumableCount]", $"{3 + processCount + consumableCount}")
|
|
.Replace("[:ProcessCount:]", $"{processCount}")
|
|
.Replace("[:ConsumableCount:]", $"{consumableCount}")
|
|
.Replace("[:TaskId:]", $"{FeesItem.TaskId}")
|
|
.Replace("[:ListData:]", serviceData.ToString())
|
|
.Replace("[:AllFees:]", $"{FeesItem.AllFees.ToString("0.00")}");
|
|
//.Replace("[:Discount:]", $"{FeesItem.DiscountFoctor}")
|
|
//.Replace("[:DiscountFees:]", $"{discountFees.ToString(" 0.00")}");
|
|
|
|
|
|
//
|
|
newGrid = newGrid.Replace(@"[:Visity:]", "");
|
|
|
|
|
|
|
|
|
|
var grid = XamlReader.Parse(newGrid) as Grid;
|
|
App.Current.Dispatcher.Invoke(() =>
|
|
{
|
|
gd.Children.Add(grid);
|
|
});
|
|
|
|
}
|
|
catch
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
|