153 lines
6.0 KiB
Plaintext
153 lines
6.0 KiB
Plaintext
@page "/system/app/version/create"
|
|
@page "/system/app/version/edit/{id:long}"
|
|
@page "/{locale}/system/app/version/create"
|
|
@page "/{locale}/system/app/version/edit/{id:long}"
|
|
|
|
@inject ILogger<AppVersionEdit> Logger
|
|
@attribute [Authorize]
|
|
|
|
<PageContainer Title="@(Id > 0 ? "编辑版本信息" : "新增版本信息")">
|
|
<Breadcrumb>
|
|
<Breadcrumb>
|
|
<BreadcrumbItem Href="/">管理后台</BreadcrumbItem>
|
|
<BreadcrumbItem Href="/admin/list">系统功能</BreadcrumbItem>
|
|
<BreadcrumbItem>版本管理</BreadcrumbItem>
|
|
</Breadcrumb>
|
|
</Breadcrumb>
|
|
<ChildContent>
|
|
|
|
<Spin Spinning="pageLoading">
|
|
<Card Title="版本信息">
|
|
<Form @ref="editform" Model="@model" LabelColSpan="5" WrapperColSpan="14" OnFinish="OnFormFinishAsync">
|
|
<FormItem Label="应用名称" Required>
|
|
<Input @bind-Value="@context.AppName" Placeholder="应用名称" />
|
|
</FormItem>
|
|
<FormItem Label="版本标题" Required>
|
|
<Input @bind-Value="@context.Title" Placeholder="版本标题" />
|
|
</FormItem>
|
|
<FormItem Label="运行平台">
|
|
<Select TItemValue="int" TItem="int" Style="width:250px;" @bind-Value="@context.Platform">
|
|
<SelectOption Value="0" Label="请选择运行平台"></SelectOption>
|
|
<SelectOption Value="1" Label="Windows桌面"></SelectOption>
|
|
<SelectOption Value="2" Label="安卓系统"></SelectOption>
|
|
<SelectOption Value="3" Label="iOS系统"></SelectOption>
|
|
</Select>
|
|
</FormItem>
|
|
<FormItem Label="版本状态">
|
|
<Select TItemValue="int" TItem="int" Style="width:250px;" @bind-Value="@context.VersionState">
|
|
<SelectOption Value="0" Label="请选版本状态"></SelectOption>
|
|
<SelectOption Value="1" Label="开发版"></SelectOption>
|
|
<SelectOption Value="2" Label="Alphal内测版"></SelectOption>
|
|
<SelectOption Value="3" Label="Beta公测版"></SelectOption>
|
|
<SelectOption Value="4" Label="Rc版"></SelectOption>
|
|
<SelectOption Value="5" Label="正式版"></SelectOption>
|
|
</Select>
|
|
</FormItem>
|
|
<FormItem Label="版本信息" Required>
|
|
<InputGroup Compact>
|
|
<Input @bind-Value="@context.VersionX" Placeholder="主版本号" Style="width: 20%;" />
|
|
<Input @bind-Value="@context.VersionY" Placeholder="次版本号" Style="width: 20%;" />
|
|
<Input @bind-Value="@context.VersionZ" Placeholder="修订版本" Style="width: 20%;" />
|
|
</InputGroup>
|
|
</FormItem>
|
|
<FormItem Label="更新内容" Required>
|
|
<TextArea Rows="10" @bind-Value="@context.Content" Placeholder="更新内容" />
|
|
</FormItem>
|
|
<FormItem Label="状态">
|
|
<RadioGroup @bind-Value="@context.Status">
|
|
<Radio RadioButton Value=1>草稿</Radio>
|
|
<Radio RadioButton Value=2>发布</Radio>
|
|
</RadioGroup>
|
|
</FormItem>
|
|
<FormItem WrapperCol="new ColLayoutParam { Span = 24, Offset = 5 }">
|
|
<Button Type="@ButtonType.Primary" HtmlType="submit">
|
|
提交保存
|
|
</Button>
|
|
</FormItem>
|
|
</Form>
|
|
</Card>
|
|
</Spin>
|
|
</ChildContent>
|
|
</PageContainer>
|
|
@code {
|
|
[Parameter]
|
|
public string Locale { get; set; } = string.Empty;
|
|
|
|
[Parameter]
|
|
public long Id { get; set; }
|
|
|
|
[SupplyParameterFromForm]
|
|
AppVersionModel model { get; set; } = new();
|
|
Form<AppVersionModel> editform = null!;
|
|
bool pageLoading = false;
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
base.OnInitialized();
|
|
}
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
if (Id > 0)
|
|
{
|
|
LoadData();
|
|
}
|
|
base.OnParametersSet();
|
|
}
|
|
|
|
async void LoadData()
|
|
{
|
|
pageLoading = true;
|
|
var url = $"/api/appversion/{Id}";
|
|
var apiResult = await HttpService.Get<ApiResult<AppVersion>>(url);
|
|
if (apiResult.Success)
|
|
{
|
|
if (apiResult.Data == null)
|
|
{
|
|
Navigation.NavigateTo($"/system/app/version/create");
|
|
}
|
|
else
|
|
{
|
|
model = apiResult.Data.Adapt<AppVersionModel>();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
Navigation.NavigateTo($"/system/app/version/create");
|
|
}
|
|
|
|
pageLoading = false;
|
|
StateHasChanged();
|
|
}
|
|
|
|
async void OnFormFinishAsync()
|
|
{
|
|
if (editform.Validate())
|
|
{
|
|
|
|
var result = new ApiResult<string>();
|
|
if (model.Id > 0)
|
|
{
|
|
var url = $"api/appversion/edit";
|
|
result = await HttpService.Post<ApiResult<string>>(url, model);
|
|
}
|
|
else
|
|
{
|
|
var url = $"api/appversion/add";
|
|
result = await HttpService.Post<ApiResult<string>>(url, model);
|
|
}
|
|
|
|
if (result.Code == (int)ResultCode.Success)
|
|
{
|
|
await ModalService.InfoAsync(new ConfirmOptions() { Title = "提示", Content = "数据提交成功!" });
|
|
Navigation.NavigateTo($"/system/app/version/list");
|
|
}
|
|
else
|
|
{
|
|
await ModalService.ErrorAsync(new ConfirmOptions() { Title = "服务异常", Content = result.Message });
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|