330 lines
13 KiB
Plaintext
330 lines
13 KiB
Plaintext
@page "/_Admin/WTM_CONTRACT/Edit/{id}"
|
|
@using wtmProject.ViewModel._Admin.WTM_CONTRACTVMs;
|
|
@using wtmProject.ViewModel._Admin.WTM_CUSTOMVMs
|
|
@inherits BasePage
|
|
|
|
<ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
|
|
<Row ItemsPerRow="ItemsPerRow.Four" RowType="RowType.Normal">
|
|
<BootstrapInput @bind-Value="@Model.Entity.Year" />
|
|
<Select @bind-Value="@Model.Entity.CustomId" Items="@AllWTM_CUSTOMs" OnSelectedItemChanged="OnCascadeBindSelectClick" ShowSearch=true PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]"/>
|
|
<Select @bind-Value="@Model.Entity.CustomClass" IsDisabled="true" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" />
|
|
<Select @bind-Value="@Model.Entity.VisitObjectId" Items="@AllWTM_CUSTOM_PERSONs" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]"/>
|
|
<Select @bind-Value="@Model.Entity.MarkManageId" Items="@AllFrameworkUsers" ShowSearch=true PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" />
|
|
<Select @bind-Value="@Model.Entity.ProjectManageId" Items="@AllFrameworkUsers" ShowSearch=true PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" />
|
|
<Select @bind-Value="@Model.Entity.ProjectId" Items="@AllWTM_PROJECTs" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" OnSelectedItemChanged="OnProjectSelectClick" />
|
|
<BootstrapInput @bind-Value="@Model.Entity.ContractName" />
|
|
<BootstrapInput @bind-Value="@Model.Entity.ContractCode" />
|
|
<BootstrapInput @bind-Value="@Model.Entity.ERPCode" />
|
|
<BootstrapInput @bind-Value="@Model.Entity.ERPName" />
|
|
<DateTimePicker @bind-Value="@Model.Entity.SignDate" />
|
|
<BootstrapInputNumber @bind-Value="@Model.Entity.ContractAmount" @oninput="@(val => OnInput(val))" />
|
|
<Select @bind-Value="@Model.Entity.ContractCycle" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]"/>
|
|
<BootstrapInputNumber @bind-Value="@Model.Entity.FirstBillingAmount" />
|
|
<BootstrapInputNumber @bind-Value="@Model.Entity.SecondBillingAmount" />
|
|
<BootstrapInputNumber @bind-Value="@Model.Entity.ThreeBillingAmount" />
|
|
<BootstrapInputNumber @bind-Value="@Model.Entity.FourthBillingAmount" />
|
|
<BootstrapInputNumber @bind-Value="@Model.Entity.FifthBillingAmount" />
|
|
<BootstrapInputNumber @bind-Value="@Model.Entity.CostAmount" @oninput="@(val => OnInput2(val))" />
|
|
<BootstrapInputNumber @bind-Value="@Model.Entity.DsfCostAmount" @oninput="@(val => OnInput3(val))" />
|
|
<BootstrapInput @bind-Value="@Model.Entity.GrossProfitMargin" IsDisabled="true" />
|
|
<WTUploadFile @bind-Value="@Model.Entity.Files" />
|
|
</Row>
|
|
<div class="modal-footer table-modal-footer">
|
|
@* <Button Color="Color.Primary" Icon="fa fa-save" Text="@WtmBlazor.Localizer["Sys.Close"]" OnClick="OnClose" />*@
|
|
<Button Color="Color.Primary" ButtonType="ButtonType.Submit" Icon="fa fa-save" Text="@WtmBlazor.Localizer["Sys.Edit"]" IsAsync="true" />
|
|
</div>
|
|
</ValidateForm>
|
|
|
|
@code {
|
|
|
|
private WTM_CONTRACTVM Model = null;
|
|
private ValidateForm vform { get; set; }
|
|
[Parameter]
|
|
public string id { get; set; }
|
|
|
|
private List<SelectedItem> AllWTM_CUSTOMs = new List<SelectedItem>();
|
|
|
|
private List<SelectedItem> AllWTM_CUSTOM_PERSONs = new List<SelectedItem>();
|
|
|
|
private List<SelectedItem> AllFrameworkUsers = new List<SelectedItem>();
|
|
|
|
private List<SelectedItem> AllWTM_PROJECTs = new List<SelectedItem>();
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
|
|
AllWTM_CUSTOMs = await WtmBlazor.Api.CallItemsApi("/api/WTM_CONTRACT/GetWTM_CUSTOMs", placeholder: WtmBlazor.Localizer["Sys.PleaseSelect"]);
|
|
|
|
AllWTM_CUSTOM_PERSONs = await WtmBlazor.Api.CallItemsApi("/api/WTM_CONTRACT/GetWTM_CUSTOM_PERSONs", placeholder: WtmBlazor.Localizer["Sys.PleaseSelect"]);
|
|
|
|
AllFrameworkUsers = await WtmBlazor.Api.CallItemsApi("/api/WTM_CONTRACT/GetFrameworkUsers", placeholder: WtmBlazor.Localizer["Sys.PleaseSelect"]);
|
|
|
|
AllWTM_PROJECTs = await WtmBlazor.Api.CallItemsApi("/api/WTM_CONTRACT/GetWTM_PROJECTs", placeholder: WtmBlazor.Localizer["Sys.PleaseSelect"]);
|
|
|
|
var rv = await WtmBlazor.Api.CallAPI<WTM_CONTRACTVM>($"/api/WTM_CONTRACT/{id}");
|
|
Model = rv.Data;
|
|
|
|
//CalculateC();
|
|
await base.OnInitializedAsync();
|
|
}
|
|
|
|
private async Task Submit(EditContext context)
|
|
{
|
|
await PostsForm(vform, $"/api/WTM_CONTRACT/edit", (s) => "Sys.OprationSuccess", method: HttpMethodEnum.PUT);
|
|
}
|
|
|
|
public void OnClose()
|
|
{
|
|
CloseDialog();
|
|
}
|
|
/// <summary>
|
|
/// 级联绑定
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
private async Task OnCascadeBindSelectClick(SelectedItem item)
|
|
{
|
|
AllWTM_CUSTOM_PERSONs = await WtmBlazor.Api.CallItemsApi($"/api/WTM_VISIT_PLAN/GetWTM_CUSTOM_PERSONs_Temp?CustomId={item.Value}", placeholder: WtmBlazor.Localizer["Sys.PleaseSelect"]);
|
|
var rv = await WtmBlazor.Api.CallAPI<WTM_CUSTOMVM>($"/api/WTM_CUSTOM/{item.Value}");
|
|
Model.Entity.CustomClass = rv.Data.Entity.CustomClass;
|
|
StateHasChanged();
|
|
}
|
|
/// <summary>
|
|
/// 自动计算毛利率
|
|
/// </summary>
|
|
//private void CalculateC()
|
|
//{
|
|
// var A = Model.Entity.ContractAmount;
|
|
// var B = Model.Entity.CostAmount;
|
|
// if (A > 0 && B >= 0)
|
|
// {
|
|
// var data = ((A - B) / A * 100).ToString();
|
|
// Model.Entity.GrossProfitMargin = string.Format("{0:F2}", data) + "%";
|
|
// }
|
|
|
|
//}
|
|
//protected override void OnAfterRender(bool firstRender)
|
|
//{
|
|
// if (!firstRender)
|
|
// {
|
|
// CalculateC();
|
|
// }
|
|
//}
|
|
private Task OnInput(ChangeEventArgs e)
|
|
{
|
|
var A = Model.Entity.ContractAmount;
|
|
var B = Model.Entity.CostAmount;
|
|
var C = Model.Entity.DsfCostAmount;
|
|
decimal num = (decimal)1.06;
|
|
if (!string.IsNullOrEmpty(e.Value.ToString()))
|
|
{ A = decimal.Parse(e.Value.ToString()); }
|
|
else
|
|
{ A = 0; }
|
|
var type = Model.Entity.ProjectId;
|
|
if (type == Guid.Parse("5afe8478-7e51-40cf-79ca-08dc4e38a86d"))
|
|
{
|
|
if (A > 0 && B >= 0)
|
|
{
|
|
var number = (A - B) / A * 100;
|
|
var data = Math.Round((decimal)number, 1);
|
|
Model.Entity.GrossProfitMargin = data.ToString() + "%";
|
|
}
|
|
else
|
|
{
|
|
Model.Entity.GrossProfitMargin = "0.00%";
|
|
}
|
|
}
|
|
else if (type == Guid.Parse("42fcebe8-8608-4e8f-79cb-08dc4e38a86d"))
|
|
{
|
|
if (A > 0 && B >= 0 && C >= 0)
|
|
{
|
|
var number = (A - C * num - B) / (A - C * num) * 100;
|
|
var data = Math.Round((decimal)number, 1);
|
|
Model.Entity.GrossProfitMargin = data.ToString() + "%";
|
|
}
|
|
else
|
|
{
|
|
Model.Entity.GrossProfitMargin = "0.00%";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (A > 0 && B >= 0)
|
|
{
|
|
var number = (A / num - B) / (A / num) * 100;
|
|
var data = Math.Round((decimal)number, 1);
|
|
Model.Entity.GrossProfitMargin = data.ToString() + "%";
|
|
}
|
|
else
|
|
{
|
|
Model.Entity.GrossProfitMargin = "0.00%";
|
|
}
|
|
}
|
|
return Task.CompletedTask;
|
|
}
|
|
private Task OnInput2(ChangeEventArgs e)
|
|
{
|
|
var A = Model.Entity.ContractAmount;
|
|
var B = Model.Entity.CostAmount;
|
|
var C = Model.Entity.DsfCostAmount;
|
|
decimal num = (decimal)1.06;
|
|
if (!string.IsNullOrEmpty(e.Value.ToString()))
|
|
{ B = decimal.Parse(e.Value.ToString()); }
|
|
else
|
|
{ B = 0; }
|
|
var type = Model.Entity.ProjectId;
|
|
if (type == Guid.Parse("5afe8478-7e51-40cf-79ca-08dc4e38a86d"))
|
|
{
|
|
if (A > 0 && B >= 0)
|
|
{
|
|
var number = (A - B) / A * 100;
|
|
var data = Math.Round((decimal)number, 1);
|
|
Model.Entity.GrossProfitMargin = data.ToString() + "%";
|
|
}
|
|
else
|
|
{
|
|
Model.Entity.GrossProfitMargin = "0.00%";
|
|
}
|
|
}
|
|
else if (type == Guid.Parse("42fcebe8-8608-4e8f-79cb-08dc4e38a86d"))
|
|
{
|
|
if (A > 0 && B >= 0 && C >= 0)
|
|
{
|
|
var number = (A - C * num - B) / (A - C * num) * 100;
|
|
var data = Math.Round((decimal)number, 1);
|
|
Model.Entity.GrossProfitMargin = data.ToString() + "%";
|
|
}
|
|
else
|
|
{
|
|
Model.Entity.GrossProfitMargin = "0.00%";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (A > 0 && B >= 0)
|
|
{
|
|
var number = (A / num - B) / (A / num) * 100;
|
|
var data = Math.Round((decimal)number, 1);
|
|
Model.Entity.GrossProfitMargin = data.ToString() + "%";
|
|
}
|
|
else
|
|
{
|
|
Model.Entity.GrossProfitMargin = "0.00%";
|
|
}
|
|
}
|
|
return Task.CompletedTask;
|
|
}
|
|
private Task OnInput3(ChangeEventArgs e)
|
|
{
|
|
var A = Model.Entity.ContractAmount;
|
|
var B = Model.Entity.CostAmount;
|
|
var C = Model.Entity.DsfCostAmount;
|
|
decimal num = (decimal)1.06;
|
|
if (!string.IsNullOrEmpty(e.Value.ToString()))
|
|
{ C = decimal.Parse(e.Value.ToString()); }
|
|
else
|
|
{ C = 0; }
|
|
var type = Model.Entity.ProjectId;
|
|
//咨询
|
|
if (type == Guid.Parse("5afe8478-7e51-40cf-79ca-08dc4e38a86d"))
|
|
{
|
|
if (A > 0 && B >= 0)
|
|
{
|
|
var number = (A - B) / A * 100;
|
|
var data = Math.Round((decimal)number, 1);
|
|
Model.Entity.GrossProfitMargin = data.ToString() + "%";
|
|
}
|
|
else
|
|
{
|
|
Model.Entity.GrossProfitMargin = "0.00%";
|
|
}
|
|
}
|
|
else if (type == Guid.Parse("42fcebe8-8608-4e8f-79cb-08dc4e38a86d"))
|
|
{
|
|
//培训
|
|
if (A > 0 && B >= 0 && C >= 0)
|
|
{
|
|
var number = (A - C * num - B) / (A - C * num) * 100;
|
|
var data = Math.Round((decimal)number, 1);
|
|
Model.Entity.GrossProfitMargin = data.ToString() + "%";
|
|
}
|
|
else
|
|
{
|
|
Model.Entity.GrossProfitMargin = "0.00%";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (A > 0 && B >= 0)
|
|
{
|
|
var number = (A / num - B) / (A / num) * 100;
|
|
var data = Math.Round((decimal)number, 1);
|
|
Model.Entity.GrossProfitMargin = data.ToString() + "%";
|
|
}
|
|
else
|
|
{
|
|
Model.Entity.GrossProfitMargin = "0.00%";
|
|
}
|
|
}
|
|
return Task.CompletedTask;
|
|
}
|
|
/// <summary>
|
|
/// 111
|
|
/// </summary>
|
|
/// <param name="item"></param>
|
|
/// <returns></returns>
|
|
private Task OnProjectSelectClick(SelectedItem item)
|
|
{
|
|
var A = Model.Entity.ContractAmount;
|
|
var B = Model.Entity.CostAmount;
|
|
var C = Model.Entity.DsfCostAmount;
|
|
decimal num = (decimal)1.06;
|
|
var type = Model.Entity.ProjectId;
|
|
if (!string.IsNullOrEmpty(item.Value.ToString()))
|
|
{ type = Guid.Parse(item.Value.ToString()); }
|
|
//咨询
|
|
if (type == Guid.Parse("5afe8478-7e51-40cf-79ca-08dc4e38a86d"))
|
|
{
|
|
if (A > 0 && B >= 0)
|
|
{
|
|
var number = (A - B) / A * 100;
|
|
var data = Math.Round((decimal)number, 1);
|
|
Model.Entity.GrossProfitMargin = data.ToString() + "%";
|
|
}
|
|
else
|
|
{
|
|
Model.Entity.GrossProfitMargin = "0.00%";
|
|
}
|
|
}
|
|
else if (type == Guid.Parse("42fcebe8-8608-4e8f-79cb-08dc4e38a86d"))
|
|
{
|
|
//培训
|
|
if (A > 0 && B >= 0 && C >= 0)
|
|
{
|
|
var number = (A - C * num - B) / (A - C * num) * 100;
|
|
var data = Math.Round((decimal)number, 1);
|
|
Model.Entity.GrossProfitMargin = data.ToString() + "%";
|
|
}
|
|
else
|
|
{
|
|
Model.Entity.GrossProfitMargin = "0.00%";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (A > 0 && B >= 0)
|
|
{
|
|
var number = (A / num - B) / (A / num) * 100;
|
|
var data = Math.Round((decimal)number, 1);
|
|
Model.Entity.GrossProfitMargin = data.ToString() + "%";
|
|
}
|
|
else
|
|
{
|
|
Model.Entity.GrossProfitMargin = "0.00%";
|
|
}
|
|
}
|
|
return Task.CompletedTask;
|
|
// StateHasChanged();
|
|
}
|
|
}
|