mh_custom/wtmProject.Shared/Pages/_Admin/WTM_BUSINESS/Edit.razor
何美荣 ca61741e4c 1
2024-05-28 14:49:22 +08:00

143 lines
6.0 KiB
Plaintext

@page "/_Admin/WTM_BUSINESS/Edit/{id}"
@using wtmProject.ViewModel._Admin.WTM_BUSINESSVMs;
@using wtmProject.ViewModel._Admin.WTM_VISIT_PLANVMs
@inherits BasePage
<ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
<Row ItemsPerRow="ItemsPerRow.Three" RowType="RowType.Normal">
<Select @bind-Value="@Model.Entity.CustomId" Items="@AllWTM_CUSTOMs" OnSelectedItemChanged="OnCascadeBindSelectClick" ShowSearch=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.ProjectId" Items="@AllWTM_PROJECTs" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" />
<Select @bind-Value="@Model.Entity.BusinessStatus" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" />
<BootstrapInput @bind-Value="@Model.Entity.BusinessName" />
</Row>
<br />
<Row ItemsPerRow="ItemsPerRow.One" RowType="RowType.Normal">
<Textarea @bind-Value="@Model.Entity.Requirement" rows="4" placeholder="请输入 ..." IsDisabled="IsDisabled1()" />
</Row>
<br />
<Row ItemsPerRow="ItemsPerRow.One" RowType="RowType.Normal">
<Textarea @bind-Value="@Model.Entity.Proposal" rows="4" placeholder="请输入 ..." IsDisabled="IsDisabled2()" />
</Row>
<br />
<Row ItemsPerRow="ItemsPerRow.One" RowType="RowType.Normal">
<Textarea @bind-Value="@Model.Entity.BusinessProject" rows="4" placeholder="请输入 ..." IsDisabled="IsDisabled3()" />
</Row>
<br />
<Row ItemsPerRow="ItemsPerRow.One" RowType="RowType.Normal">
<Textarea @bind-Value="@Model.Entity.Follow" rows="4" placeholder="请输入 ..." IsDisabled="IsDisabled4()" />
</Row>
<br />
<Row ItemsPerRow="ItemsPerRow.One" RowType="RowType.Normal">
<Textarea @bind-Value="@Model.Entity.Negotiation" rows="4" placeholder="请输入 ..." IsDisabled="IsDisabled5()" />
</Row>
<br />
<Row ItemsPerRow="ItemsPerRow.Three" RowType="RowType.Normal">
<Select @bind-Value="@Model.Entity.MarkManageId" Items="@AllFrameworkUsers" IsDisabled="true" />
<BootstrapInput @bind-Value="@Model.Entity.CreateTime" FormatString="yyyy-MM-dd" IsDisabled="true" />
<BootstrapInput @bind-Value="@Model.Entity.UpdateTime" FormatString="yyyy-MM-dd" IsDisabled="true" />
</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_BUSINESSVM 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> AllWTM_PROJECTs = new List<SelectedItem>();
private List<SelectedItem> AllFrameworkUsers = new List<SelectedItem>();
protected override async Task OnInitializedAsync()
{
AllWTM_CUSTOMs = await WtmBlazor.Api.CallItemsApi("/api/WTM_BUSINESS/GetWTM_CUSTOMs", placeholder: WtmBlazor.Localizer["Sys.PleaseSelect"]);
AllWTM_PROJECTs = await WtmBlazor.Api.CallItemsApi("/api/WTM_BUSINESS/GetWTM_PROJECTs", placeholder: WtmBlazor.Localizer["Sys.PleaseSelect"]);
AllFrameworkUsers = await WtmBlazor.Api.CallItemsApi("/api/WTM_VISIT_PLAN/GetFrameworkUsersTemp");
var rv = await WtmBlazor.Api.CallAPI<WTM_BUSINESSVM>($"/api/WTM_BUSINESS/{id}");
Model = rv.Data;
await base.OnInitializedAsync();
}
/// <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}");
var rv = await WtmBlazor.Api.CallAPI<WTM_VISIT_PLAN_Temp>($"/api/WTM_VISIT_PLAN/GetCustomArea?CustomId={item.Value}");
Model.Entity.AreaId = rv.Data.AreaId;
//Model.Entity.IndustryType = rv.Data.IndustryType;
StateHasChanged();
}
private async Task Submit(EditContext context)
{
await PostsForm(vform, $"/api/WTM_BUSINESS/edit", (s) => "Sys.OprationSuccess", method: HttpMethodEnum.PUT);
}
public void OnClose()
{
CloseDialog();
}
public bool IsDisabled1()
{
bool IsDisabled = true;
if (Model.Entity.BusinessStatus == wtmProject.Model.BusinessStatusEnum.Requirement || Model.Entity.BusinessStatus == null)
{
IsDisabled = false;
}
return IsDisabled;
}
public bool IsDisabled2()
{
bool IsDisabled = true;
if (Model.Entity.BusinessStatus == wtmProject.Model.BusinessStatusEnum.Proposal)
{
IsDisabled = false;
}
return IsDisabled;
}
public bool IsDisabled3()
{
bool IsDisabled = true;
if (Model.Entity.BusinessStatus == wtmProject.Model.BusinessStatusEnum.BusinessProject)
{
IsDisabled = false;
}
return IsDisabled;
}
public bool IsDisabled4()
{
bool IsDisabled = true;
if (Model.Entity.BusinessStatus == wtmProject.Model.BusinessStatusEnum.Follow)
{
IsDisabled = false;
}
return IsDisabled;
}
public bool IsDisabled5()
{
bool IsDisabled = true;
if (Model.Entity.BusinessStatus == wtmProject.Model.BusinessStatusEnum.Negotiation)
{
IsDisabled = false;
}
return IsDisabled;
}
}