mh_custom/wtmProject.Shared/Pages/_Admin/WTM_CUSTOM/Create.razor
2026-01-06 10:55:05 +08:00

98 lines
5.1 KiB
Plaintext

@page "/_Admin/WTM_CUSTOM/Create"
@using wtmProject.Model
@using wtmProject.ViewModel._Admin.WTM_CUSTOMVMs;
@inject MessageService MessageService;
@inherits BasePage
<ValidateForm @ref="vform" Model="@Model" OnValidSubmit="@Submit">
<Row ItemsPerRow="ItemsPerRow.Two" RowType="RowType.Normal">
<BootstrapInput @bind-Value="@Model.Entity.CustomAllName" @oninput="@(val => OnInput(val))" />
<div class="col-12">@Model.Entity.CustomName</div>
@* <BootstrapInput @bind-Value="@Model.Entity.CustomShortName" /> *@
@* <BootstrapInput @bind-Value="@Model.Entity.ParentUnit" />*@
<Select @bind-Value="@Model.Entity.CustomClass" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" />
<Select @bind-Value="@Model.Entity.AreaId" Items="@AllWTM_AREAs" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" />
<Select @bind-Value="@Model.Entity.CustomId" Items="@AllWTM_CUSTOMs" ShowSearch=true PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" />
@* <Select @bind-Value="@Model.Entity.IndustryType" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" />*@
<Select @bind-Value="@Model.Entity.EnterprisesType" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" />
<Select @bind-Value="@Model.Entity.CreditLevel" PlaceHolder="@WtmBlazor.Localizer["Sys.PleaseSelect"]" />
<BootstrapInput @bind-Value="@Model.Entity.CustomCity" />
<Select @bind-Value="@Model.Entity.CustomType" />
<Textarea @bind-Value="@Model.Entity.BillingFile" rows="3" placeholder="请输入 ..." />
</Row>
<br />
<Table TItem="WTM_CUSTOM_PERSON"
IsPagination="false" IsTracking=true ShowRefresh="false" ShowEditButton="false"
IsStriped="true" IsBordered="true" IsMultipleSelect="true" @bind-Items="@CustomPersonList"
ShowToolbar="true" ShowExtendButtons="true" ShowSkeleton="true" EditMode="EditMode.InCell" ShowToastAfterSaveOrDeleteModel="false" style="margin-top:10px;">
<TableColumns>
<TableColumn @bind-Field="@context.PersonName" />
<TableColumn @bind-Field="@context.PersonPhone" />
<TableColumn @bind-Field="@context.PersonPost" />
</TableColumns>
</Table>
<br />
@*<Table @ref="dataTable" TItem="WTM_CUSTOM_PERSON" IsPagination="true" IsStriped="true" IsBordered="true" ShowRefresh="false"
ShowToolbar="true" IsMultipleSelect="true" ShowExtendButtons="true" ShowDefaultButtons="false" ShowExtendEditButton="false" ShowExtendDeleteButton="false" style="margin-top:10px;">
</Table>*@
<div class="modal-footer table-modal-footer">
@*<Button Color="Color.Secondary" Icon="fa fa-close" Text="@WtmBlazor.Localizer["Sys.Close"]" OnClick="OnClose" />*@
<Button Color="Color.Primary" ButtonType="ButtonType.Submit" Icon="fa fa-save" Text="@WtmBlazor.Localizer["Sys.Save"]" IsAsync="true" />
</div>
</ValidateForm>
@code {
private WTM_CUSTOMVM Model = new WTM_CUSTOMVM();
private ValidateForm vform { get; set; }
private List<SelectedItem> AllWTM_AREAs = new List<SelectedItem>();
private IEnumerable<WTM_CUSTOM_PERSON> CustomPersonList { get; set; } = new List<WTM_CUSTOM_PERSON>();
private List<SelectedItem> AllWTM_CUSTOMs = new List<SelectedItem>();
protected override async Task OnInitializedAsync()
{
AllWTM_CUSTOMs = await WtmBlazor.Api.CallItemsApi("/api/WTM_VISIT_PLAN/GetWTM_CUSTOMs", placeholder: WtmBlazor.Localizer["Sys.PleaseSelect"]);
AllWTM_AREAs = await WtmBlazor.Api.CallItemsApi("/api/WTM_CUSTOM/GetWTM_AREAs", placeholder: WtmBlazor.Localizer["Sys.PleaseSelect"]);
await base.OnInitializedAsync();
}
private async Task Submit(EditContext context)
{
Model.Entity.CustomPerson = CustomPersonList.ToList();
await PostsForm(vform, "/api/WTM_CUSTOM/add", (s) => "Sys.OprationSuccess");
}
private async Task OnInput(ChangeEventArgs e)
{
if (!string.IsNullOrEmpty(e.Value.ToString()))
{
var url = $"/api/WTM_CUSTOM/GetNameList?name={e.Value.ToString()}";
var temp = await WtmBlazor.Api.CallAPI<string>(url);
if (temp != null && !string.IsNullOrEmpty(temp.Data))
{
Model.Entity.CustomName = temp.Data;
return;
}
else
{
Model.Entity.CustomName = null;
return;
}
// var url = $"/api/WTM_CUSTOM/GetName?name={e.Value.ToString()}";
// var rv = await WtmBlazor.Api.CallAPI<WTM_CUSTOM>(url);
// if (rv.Data != null)
// {
// await MessageService.Show(new MessageOption()
// {
// Content = "请勿重复添加,该客户已存在",
// Icon = "fa-solid fa-circle-info",
// Color = Color.Danger
// });
// return;
// }
}
// return new Task;
}
public void OnClose()
{
CloseDialog();
}
}