340 lines
16 KiB
Plaintext
340 lines
16 KiB
Plaintext
@page "/Enterprise/Register"
|
|
@using Cysharp.Threading.Tasks
|
|
@using System.Text
|
|
@using BITKit.Crypto
|
|
@inject IDIS_EnterpriseService enterpriseService
|
|
<MudText Typo="Typo.h3" GutterBottom="true">企业注册</MudText>
|
|
<MudStack>
|
|
@* <MudTextField *@
|
|
@* @bind-Value="@enterprise.EnterpriseApply.Prefix" *@
|
|
@* Variant="Variant.Outlined" *@
|
|
@* HelperText="例如:88.123.99" *@
|
|
@* Label="企业前缀"></MudTextField> *@
|
|
<MudGrid>
|
|
<MudItem xs="2">
|
|
<MudPaper Class="pa-4 mb-4">
|
|
<MudText>用户信息</MudText>
|
|
<MudTextField Margin="@myMargin" Required="true" @bind-Value="@enterprise.SystemUser.UserName" Label="用户名"></MudTextField>
|
|
<MudTextField Margin="@myMargin" Required="true" @bind-Value="@enterprise.SystemUser.EMail" InputType="InputType.Email" Label="电子邮箱"></MudTextField>
|
|
<MudTextField Margin="@myMargin" Required="true" @bind-Value="@enterprise.SystemUser.Mobile" InputType="InputType.Telephone" Label="手机号"></MudTextField>
|
|
<MudTextField Margin="@myMargin" Required="true" @bind-Value="@enterprise.SystemUser.Password" Label="密码" InputType="InputType.Password"></MudTextField>
|
|
<MudTextField Margin="@myMargin" Required="true" @bind-Value="@enterprise.SystemUser.Remark" Label="备注"></MudTextField>
|
|
</MudPaper>
|
|
</MudItem>
|
|
<MudItem xs="2">
|
|
<MudPaper Class="pa-4">
|
|
<MudText>照片上传</MudText>
|
|
@if (string.IsNullOrEmpty(enterprise.EnterpriseApply.CreditImageContent) is false)
|
|
{
|
|
var base64 = $"data:image/png;base64,{enterprise.EnterpriseApply.CreditImageContent}";
|
|
<MudImage Fluid="true" Src="@base64"/>
|
|
}
|
|
<MudFileUpload T="IBrowserFile" FilesChanged="UploadLicense">
|
|
<ButtonTemplate>
|
|
<MudButton FullWidth="true" HtmlTag="label"
|
|
Variant="Variant.Filled"
|
|
Color="Color.Primary"
|
|
StartIcon="@Icons.Material.Filled.CloudUpload"
|
|
for="@context.Id">
|
|
营业执照
|
|
</MudButton>
|
|
</ButtonTemplate>
|
|
</MudFileUpload>
|
|
@if (string.IsNullOrEmpty(enterprise.EnterpriseApply.LegalPersonIdImageFrontContent) is false)
|
|
{
|
|
var base64 = $"data:image/png;base64,{enterprise.EnterpriseApply.LegalPersonIdImageFrontContent}";
|
|
<MudImage Fluid="true" Src="@base64"/>
|
|
}
|
|
<MudFileUpload T="IBrowserFile" FilesChanged="UploadLegalPersonIdFront">
|
|
<ButtonTemplate>
|
|
<MudButton FullWidth="true" HtmlTag="label"
|
|
Variant="Variant.Filled"
|
|
Color="Color.Primary"
|
|
StartIcon="@Icons.Material.Filled.CloudUpload"
|
|
for="@context.Id">
|
|
法人身份证正面
|
|
</MudButton>
|
|
</ButtonTemplate>
|
|
</MudFileUpload>
|
|
@if (string.IsNullOrEmpty(enterprise.EnterpriseApply.LegalPersonIdImageBackContent) is false)
|
|
{
|
|
var base64 = $"data:image/png;base64,{enterprise.EnterpriseApply.LegalPersonIdImageBackContent}";
|
|
<MudImage Fluid="true" Src="@base64"/>
|
|
}
|
|
<MudFileUpload T="IBrowserFile" FilesChanged="UploadLegalPersonIdBack">
|
|
<ButtonTemplate>
|
|
<MudButton FullWidth="true" HtmlTag="label"
|
|
Variant="Variant.Filled"
|
|
Color="Color.Primary"
|
|
StartIcon="@Icons.Material.Filled.CloudUpload"
|
|
for="@context.Id">
|
|
法人身份证反面
|
|
</MudButton>
|
|
</ButtonTemplate>
|
|
</MudFileUpload>
|
|
</MudPaper>
|
|
</MudItem>
|
|
<MudItem xs="4" Class="d-flex">
|
|
<MudPaper Class="pa-4 ">
|
|
<MudText>企业信息</MudText>
|
|
<MudStack Row="true">
|
|
<MudStack>
|
|
<MudTextField Margin="@myMargin" Required="true" @bind-Value="@enterprise.EnterpriseApply.Prefix" Label="前缀" HelperText="例如:88.123.99"></MudTextField>
|
|
<MudTextField Margin="@myMargin" Required="true" @bind-Value="@enterprise.EnterpriseApply.NameCN" Label="企业名称"></MudTextField>
|
|
<MudTextField Margin="@myMargin" Required="true" @bind-Value="@enterprise.EnterpriseApply.EMail" InputType="InputType.Email" Label="电子邮箱"></MudTextField>
|
|
<MudTextField Margin="@myMargin" Required="true" @bind-Value="@enterprise.EnterpriseApply.AddressCN" Label="地址"></MudTextField>
|
|
<MudTextField Margin="@myMargin" Required="true" @bind-Value="@enterprise.EnterpriseApply.CityCode" Label="城市代码"></MudTextField>
|
|
<MudTextField Margin="@myMargin" Required="true" @bind-Value="@enterprise.EnterpriseApply.CountyCode" Label="县代码"></MudTextField>
|
|
<MudTextField Margin="@myMargin" Required="true" @bind-Value="@enterprise.EnterpriseApply.CreditType" Label="信用类型"></MudTextField>
|
|
<MudTextField Margin="@myMargin" Required="true" @bind-Value="@enterprise.EnterpriseApply.Descption" Label="企业描述"></MudTextField>
|
|
</MudStack>
|
|
<MudStack>
|
|
<MudTextField Margin="@myMargin"Required="true" @bind-Value="@enterprise.EnterpriseApply.CreditCode" Label="企业信用代码" HelperText="例如:91500000MA60F2F94T"></MudTextField>
|
|
<MudTextField Margin="@myMargin"Required="true" @bind-Value="@enterprise.EnterpriseApply.ProvinceCode" Label="省份代码"></MudTextField>
|
|
<MudTextField Margin="@myMargin"Required="true" @bind-Value="@enterprise.EnterpriseApply.WebSite" InputType="InputType.Url" Label="企业网站"></MudTextField>
|
|
<MudTextField Margin="@myMargin"Required="true" @bind-Value="@enterprise.EnterpriseApply.LegalPersonIdNumber" Label="法人身份证号"></MudTextField>
|
|
<MudTextField Margin="@myMargin" Required="true" @bind-Value="@enterprise.EnterpriseApply.LegalPersonIdName" Label="法人姓名"></MudTextField>
|
|
<MudTextField Margin="@myMargin"Required="true" @bind-Value="@enterprise.EnterpriseApply.Mobile" InputType="InputType.Telephone" Label="企业手机"></MudTextField>
|
|
<MudTextField Margin="@myMargin" Required="true" @bind-Value="@enterprise.EnterpriseApply.Remarks" Label="企业备注"></MudTextField>
|
|
|
|
<MudTextField Required="true" @bind-Value="@enterprise.EnterpriseApply.ContactName" Label="联系人姓名"></MudTextField>
|
|
</MudStack>
|
|
</MudStack>
|
|
</MudPaper>
|
|
</MudItem>
|
|
<MudItem xs="4">
|
|
<MudPaper Class="pa-4">
|
|
<MudStack Row="true">
|
|
<MudButton OnClick="@Verification" Variant="Variant.Filled" Color="Color.Primary" DisableElevation="true">验证</MudButton>
|
|
<MudButton OnClick="()=>enterprise=new()" Variant="Variant.Filled" Color="Color.Secondary" DisableElevation="true" Class="mx-2">重置</MudButton>
|
|
<MudButton OnClick="()=>reportBuilder.Clear()" Variant="Variant.Filled" DisableElevation="true">重置验证</MudButton>
|
|
<MudSpacer/>
|
|
<MudButton OnClick="()=>Register().Forget()" Color="Color.Success" Variant="Variant.Filled" DisableElevation="true">注册企业</MudButton>
|
|
</MudStack>
|
|
</MudPaper>
|
|
<MudPaper Class="pa-4">
|
|
<MudText Typo="Typo.subtitle2">表单验证</MudText>
|
|
<MudAlert Severity="@severity">@currentMessage</MudAlert>
|
|
@foreach (var line in reportBuilder.ToString().Split('\n'))
|
|
{
|
|
<MudText Typo="Typo.body2">@line</MudText>
|
|
}
|
|
</MudPaper>
|
|
</MudItem>
|
|
</MudGrid>
|
|
</MudStack>
|
|
|
|
|
|
@code {
|
|
public IDIS_Enterprise enterprise { get; set; }= new();
|
|
private string currentMessage { get; set; } = "我们先完成企业信息填写";
|
|
private Severity severity { get; set; } = Severity.Normal;
|
|
private StringBuilder reportBuilder { get; set; } = new();
|
|
private Margin myMargin { get; set; } = Margin.Dense;
|
|
|
|
private void Verification()
|
|
{
|
|
reportBuilder.Clear();
|
|
if(string.IsNullOrEmpty(enterprise.EnterpriseApply.Prefix))
|
|
{
|
|
reportBuilder.AppendLine("企业前缀不能为空");
|
|
}
|
|
if(string.IsNullOrEmpty(enterprise.EnterpriseApply.CreditCode))
|
|
{
|
|
reportBuilder.AppendLine("信用代码不能为空");
|
|
}
|
|
if (string.IsNullOrEmpty(enterprise.SystemUser.UserName))
|
|
{
|
|
reportBuilder.AppendLine("用户名不能为空");
|
|
}
|
|
if (string.IsNullOrEmpty(enterprise.SystemUser.EMail))
|
|
{
|
|
reportBuilder.AppendLine("电子邮箱不能为空");
|
|
}
|
|
if (string.IsNullOrEmpty(enterprise.SystemUser.Mobile))
|
|
{
|
|
reportBuilder.AppendLine("手机号不能为空");
|
|
}
|
|
if (string.IsNullOrEmpty(enterprise.SystemUser.Password))
|
|
{
|
|
reportBuilder.AppendLine("密码不能为空");
|
|
}
|
|
if (string.IsNullOrEmpty(enterprise.EnterpriseApply.NameCN))
|
|
{
|
|
reportBuilder.AppendLine("企业名称不能为空");
|
|
}
|
|
if (string.IsNullOrEmpty(enterprise.EnterpriseApply.EMail))
|
|
{
|
|
reportBuilder.AppendLine("企业电子邮箱不能为空");
|
|
}
|
|
if (string.IsNullOrEmpty(enterprise.EnterpriseApply.AddressCN))
|
|
{
|
|
reportBuilder.AppendLine("企业地址不能为空");
|
|
}
|
|
if (string.IsNullOrEmpty(enterprise.EnterpriseApply.CityCode))
|
|
{
|
|
reportBuilder.AppendLine("城市代码不能为空");
|
|
}
|
|
if (string.IsNullOrEmpty(enterprise.EnterpriseApply.CountyCode))
|
|
{
|
|
reportBuilder.AppendLine("县代码不能为空");
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(enterprise.EnterpriseApply.Descption))
|
|
{
|
|
reportBuilder.AppendLine("企业描述不能为空");
|
|
}
|
|
if (string.IsNullOrEmpty(enterprise.EnterpriseApply.ProvinceCode))
|
|
{
|
|
reportBuilder.AppendLine("省份代码不能为空");
|
|
}
|
|
if (string.IsNullOrEmpty(enterprise.EnterpriseApply.WebSite))
|
|
{
|
|
reportBuilder.AppendLine("企业网站不能为空");
|
|
}
|
|
if (string.IsNullOrEmpty(enterprise.EnterpriseApply.LegalPersonIdNumber))
|
|
{
|
|
reportBuilder.AppendLine("法人身份证号不能为空");
|
|
}
|
|
if (string.IsNullOrEmpty(enterprise.EnterpriseApply.LegalPersonIdName))
|
|
{
|
|
reportBuilder.AppendLine("法人姓名不能为空");
|
|
}
|
|
if (string.IsNullOrEmpty(enterprise.EnterpriseApply.Mobile))
|
|
{
|
|
reportBuilder.AppendLine("企业手机不能为空");
|
|
}
|
|
if (string.IsNullOrEmpty(enterprise.EnterpriseApply.Remarks))
|
|
{
|
|
reportBuilder.AppendLine("企业备注不能为空");
|
|
}
|
|
if (string.IsNullOrEmpty(enterprise.EnterpriseApply.ContactName))
|
|
{
|
|
reportBuilder.AppendLine("联系人姓名不能为空");
|
|
}
|
|
if (string.IsNullOrEmpty(enterprise.EnterpriseApply.CreditImageContent))
|
|
{
|
|
reportBuilder.AppendLine("营业执照不能为空");
|
|
}
|
|
if (string.IsNullOrEmpty(enterprise.EnterpriseApply.LegalPersonIdImageFrontContent))
|
|
{
|
|
reportBuilder.AppendLine("法人身份证正面不能为空");
|
|
}
|
|
if (string.IsNullOrEmpty(enterprise.EnterpriseApply.LegalPersonIdImageBackContent))
|
|
{
|
|
reportBuilder.AppendLine("法人身份证反面不能为空");
|
|
}
|
|
if (reportBuilder.Length > 0)
|
|
{
|
|
currentMessage = "表单验证失败";
|
|
severity = Severity.Error;
|
|
}
|
|
else
|
|
{
|
|
currentMessage = "表单验证成功";
|
|
severity = Severity.Success;
|
|
}
|
|
InvokeAsync(StateHasChanged).AndForget();
|
|
}
|
|
|
|
private async UniTask Register()
|
|
{
|
|
Verification();
|
|
if(reportBuilder.Length>0)
|
|
{
|
|
return;
|
|
}
|
|
severity = Severity.Normal;
|
|
currentMessage = "正在验证表单";
|
|
await InvokeAsync(StateHasChanged);
|
|
await Task.Delay(1000);
|
|
try
|
|
{
|
|
BITCrypto crypto = new BITCrypto();
|
|
currentMessage = "正在注册企业";
|
|
await enterpriseService.RegisterAsync(enterprise.SystemUser
|
|
with{
|
|
Password =crypto.Hash(enterprise.SystemUser.Password)
|
|
}, enterprise.EnterpriseApply);
|
|
currentMessage = "企业注册成功";
|
|
reportBuilder.Clear();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
currentMessage = e.Message;
|
|
severity = Severity.Error;
|
|
}
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
private async void UploadLicense(IBrowserFile? obj)
|
|
{
|
|
try
|
|
{
|
|
if (obj is null)
|
|
{
|
|
reportBuilder.AppendLine("营业执照不能为空");
|
|
return;
|
|
}
|
|
using var ms = new MemoryStream();
|
|
await obj.OpenReadStream(int.MaxValue).CopyToAsync(ms);
|
|
enterprise.EnterpriseApply.CreditImageContent = Convert.ToBase64String(ms.ToArray());
|
|
|
|
currentMessage = "上传成功";
|
|
severity = Severity.Success;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
currentMessage = e.Message;
|
|
severity = Severity.Error;
|
|
}
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
private async void UploadLegalPersonIdFront(IBrowserFile? obj)
|
|
{
|
|
try
|
|
{
|
|
if (obj is null)
|
|
{
|
|
reportBuilder.AppendLine("法人身份证正面不能为空");
|
|
return;
|
|
}
|
|
using var ms = new MemoryStream();
|
|
await obj.OpenReadStream(int.MaxValue).CopyToAsync(ms);
|
|
enterprise.EnterpriseApply.LegalPersonIdImageFrontContent = Convert.ToBase64String(ms.ToArray());
|
|
|
|
currentMessage = "上传成功";
|
|
severity = Severity.Success;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
currentMessage = e.Message;
|
|
severity = Severity.Error;
|
|
}
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
private async void UploadLegalPersonIdBack(IBrowserFile? obj)
|
|
{
|
|
try
|
|
{
|
|
if (obj is null)
|
|
{
|
|
reportBuilder.AppendLine("法人身份证杯面不能为空");
|
|
return;
|
|
}
|
|
using var ms = new MemoryStream();
|
|
await obj.OpenReadStream(int.MaxValue).CopyToAsync(ms);
|
|
enterprise.EnterpriseApply.LegalPersonIdImageBackContent = Convert.ToBase64String(ms.ToArray());
|
|
|
|
currentMessage = "上传成功";
|
|
severity = Severity.Success;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
currentMessage = e.Message;
|
|
severity = Severity.Error;
|
|
}
|
|
await InvokeAsync(StateHasChanged);
|
|
}
|
|
|
|
} |