2020-06-02 14:25:44 +08:00
|
|
|
|
@namespace AntDesign
|
|
|
|
|
@inherits AntDomComponentBase
|
2020-08-22 09:24:55 +08:00
|
|
|
|
@using OneOf;
|
2020-06-02 14:25:44 +08:00
|
|
|
|
|
2020-12-26 21:39:04 +08:00
|
|
|
|
<DialogWrapper Visible="@Config.Visible"
|
|
|
|
|
DestroyOnClose="true"
|
|
|
|
|
Config="@_dialogOptions"
|
|
|
|
|
Style="@Config.Style"
|
|
|
|
|
>
|
2020-11-01 16:00:23 +08:00
|
|
|
|
<div class="ant-modal-confirm-body-wrapper">
|
|
|
|
|
<div class="ant-modal-confirm-body">
|
|
|
|
|
@if (Config.Icon != null)
|
2020-06-02 14:25:44 +08:00
|
|
|
|
{
|
2020-11-01 16:00:23 +08:00
|
|
|
|
@(Config.Icon)
|
2020-06-02 14:25:44 +08:00
|
|
|
|
}
|
2020-12-26 21:39:04 +08:00
|
|
|
|
|
|
|
|
|
@if (Config.TitleTemplate != null)
|
2020-06-02 14:25:44 +08:00
|
|
|
|
{
|
2020-11-01 16:00:23 +08:00
|
|
|
|
<span class="ant-modal-confirm-title">
|
2020-12-26 21:39:04 +08:00
|
|
|
|
@Config.TitleTemplate
|
2020-11-01 16:00:23 +08:00
|
|
|
|
</span>
|
|
|
|
|
}
|
2020-12-26 21:39:04 +08:00
|
|
|
|
else if (!string.IsNullOrWhiteSpace(Config.Title))
|
|
|
|
|
{
|
|
|
|
|
<span class="ant-modal-confirm-title">
|
|
|
|
|
@Config.Title
|
|
|
|
|
</span>
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-01 16:00:23 +08:00
|
|
|
|
<div class="ant-modal-confirm-content">
|
|
|
|
|
@if (Config.Content.IsT0)
|
|
|
|
|
{
|
|
|
|
|
@(Config.Content.AsT0)
|
2020-06-02 14:25:44 +08:00
|
|
|
|
}
|
2020-11-01 16:00:23 +08:00
|
|
|
|
else
|
2020-06-02 14:25:44 +08:00
|
|
|
|
{
|
2020-11-01 16:00:23 +08:00
|
|
|
|
@(Config.Content.AsT1)
|
2020-06-02 14:25:44 +08:00
|
|
|
|
}
|
2020-11-01 16:00:23 +08:00
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="ant-modal-confirm-btns">
|
|
|
|
|
@{
|
2020-12-26 21:39:04 +08:00
|
|
|
|
RenderFragment BuildButton(ButtonProps props,
|
|
|
|
|
Func<MouseEventArgs, Task> onClick, out Button btnRef)
|
2020-08-22 09:24:55 +08:00
|
|
|
|
{
|
2020-11-01 16:00:23 +08:00
|
|
|
|
btnRef = null;
|
2020-12-26 21:39:04 +08:00
|
|
|
|
if (props == null) return null;
|
2020-11-01 16:00:23 +08:00
|
|
|
|
var onClickEvent = new EventCallback<MouseEventArgs>(this, onClick);
|
|
|
|
|
Button innerBtnRef = null;
|
2020-12-29 23:34:18 +08:00
|
|
|
|
var children = props.ChildContent!.Value;
|
2020-12-26 21:39:04 +08:00
|
|
|
|
RenderFragment compontent = (@<Button @ref="@innerBtnRef"
|
|
|
|
|
OnClick="@onClickEvent"
|
|
|
|
|
Block="@props.Block"
|
|
|
|
|
Ghost="@props.Ghost"
|
|
|
|
|
Search="@props.Search"
|
|
|
|
|
Loading="@props.Loading"
|
|
|
|
|
Type="@props.Type"
|
|
|
|
|
Shape="@props.Shape"
|
|
|
|
|
Size="@props.Size"
|
|
|
|
|
Icon="@props.Icon"
|
|
|
|
|
Disabled="@props.Disabled"
|
|
|
|
|
Danger="@props.IsDanger">
|
|
|
|
|
@{
|
|
|
|
|
if (children.IsT0)
|
|
|
|
|
{
|
|
|
|
|
@(children.AsT0)
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
@(children.AsT1)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</Button>);
|
|
|
|
|
btnRef = innerBtnRef;
|
|
|
|
|
return compontent;
|
|
|
|
|
}
|
2020-11-01 16:00:23 +08:00
|
|
|
|
}
|
|
|
|
|
@switch (Config.ConfirmButtons)
|
|
|
|
|
{
|
|
|
|
|
case ConfirmButtons.OK:
|
2020-08-22 09:24:55 +08:00
|
|
|
|
{
|
2020-11-01 16:00:23 +08:00
|
|
|
|
@BuildButton(Config.Button1Props, async (e) =>
|
|
|
|
|
{
|
|
|
|
|
await HandleBtn1Click(e, ConfirmResult.OK);
|
2020-12-26 21:39:04 +08:00
|
|
|
|
}, out _okBtn)
|
|
|
|
|
;
|
2020-11-01 16:00:23 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ConfirmButtons.OKCancel:
|
2020-08-22 09:24:55 +08:00
|
|
|
|
{
|
|
|
|
|
|
2020-11-01 16:00:23 +08:00
|
|
|
|
@BuildButton(Config.Button1Props, async (e) =>
|
|
|
|
|
{
|
|
|
|
|
await HandleBtn1Click(e, ConfirmResult.OK);
|
2020-12-26 21:39:04 +08:00
|
|
|
|
}, out _okBtn)
|
|
|
|
|
;
|
2020-08-22 09:24:55 +08:00
|
|
|
|
|
2020-11-01 16:00:23 +08:00
|
|
|
|
@BuildButton(Config.Button2Props, async (e) =>
|
|
|
|
|
{
|
|
|
|
|
await HandleBtn2Click(e, ConfirmResult.Cancel);
|
2020-12-26 21:39:04 +08:00
|
|
|
|
}, out _cancelBtn)
|
|
|
|
|
;
|
2020-08-22 09:24:55 +08:00
|
|
|
|
|
2020-11-01 16:00:23 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ConfirmButtons.YesNo:
|
2020-08-22 09:24:55 +08:00
|
|
|
|
{
|
2020-11-01 16:00:23 +08:00
|
|
|
|
@BuildButton(Config.Button1Props, async (e) =>
|
|
|
|
|
{
|
|
|
|
|
await HandleBtn1Click(e, ConfirmResult.Yes);
|
2020-12-26 21:39:04 +08:00
|
|
|
|
}, out _okBtn)
|
|
|
|
|
;
|
2020-08-22 09:24:55 +08:00
|
|
|
|
|
2020-11-01 16:00:23 +08:00
|
|
|
|
@BuildButton(Config.Button2Props, async (e) =>
|
|
|
|
|
{
|
|
|
|
|
await HandleBtn2Click(e, ConfirmResult.No);
|
2020-12-26 21:39:04 +08:00
|
|
|
|
}, out _cancelBtn)
|
|
|
|
|
;
|
2020-11-01 16:00:23 +08:00
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ConfirmButtons.YesNoCancel:
|
2020-08-22 09:24:55 +08:00
|
|
|
|
{
|
2020-11-01 16:00:23 +08:00
|
|
|
|
@BuildButton(Config.Button1Props, async (e) =>
|
|
|
|
|
{
|
|
|
|
|
await HandleBtn1Click(e, ConfirmResult.Yes);
|
2020-12-26 21:39:04 +08:00
|
|
|
|
}, out _okBtn)
|
|
|
|
|
;
|
2020-08-22 09:24:55 +08:00
|
|
|
|
|
2020-11-01 16:00:23 +08:00
|
|
|
|
@BuildButton(Config.Button2Props, async (e) =>
|
|
|
|
|
{
|
|
|
|
|
await HandleBtn2Click(e, ConfirmResult.No);
|
2020-12-26 21:39:04 +08:00
|
|
|
|
}, out _cancelBtn)
|
|
|
|
|
;
|
2020-08-22 09:24:55 +08:00
|
|
|
|
|
2020-11-01 16:00:23 +08:00
|
|
|
|
@BuildButton(Config.Button3Props, async (e) =>
|
|
|
|
|
{
|
|
|
|
|
await HandleBtn3Click(e, ConfirmResult.Cancel);
|
2020-12-26 21:39:04 +08:00
|
|
|
|
}, out _)
|
|
|
|
|
;
|
2020-11-01 16:00:23 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
2020-08-22 09:24:55 +08:00
|
|
|
|
|
2020-11-01 16:00:23 +08:00
|
|
|
|
case ConfirmButtons.RetryCancel:
|
2020-08-22 09:24:55 +08:00
|
|
|
|
{
|
2020-11-01 16:00:23 +08:00
|
|
|
|
@BuildButton(Config.Button1Props, async (e) =>
|
|
|
|
|
{
|
|
|
|
|
await HandleBtn1Click(e, ConfirmResult.Retry);
|
2020-12-26 21:39:04 +08:00
|
|
|
|
}, out _okBtn)
|
|
|
|
|
;
|
2020-11-01 16:00:23 +08:00
|
|
|
|
|
|
|
|
|
@BuildButton(Config.Button2Props, async (e) =>
|
2020-12-26 21:39:04 +08:00
|
|
|
|
{
|
|
|
|
|
await HandleBtn2Click(e, ConfirmResult.Cancel);
|
|
|
|
|
}, out _cancelBtn)
|
|
|
|
|
;
|
2020-08-22 09:24:55 +08:00
|
|
|
|
|
2020-11-01 16:00:23 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case ConfirmButtons.AbortRetryIgnore:
|
2020-08-22 09:24:55 +08:00
|
|
|
|
{
|
2020-11-01 16:00:23 +08:00
|
|
|
|
@BuildButton(Config.Button1Props, async (e) =>
|
|
|
|
|
{
|
|
|
|
|
await HandleBtn1Click(e, ConfirmResult.Abort);
|
2020-12-26 21:39:04 +08:00
|
|
|
|
}, out _okBtn)
|
|
|
|
|
;
|
2020-08-22 09:24:55 +08:00
|
|
|
|
|
2020-11-01 16:00:23 +08:00
|
|
|
|
@BuildButton(Config.Button2Props, async (e) =>
|
|
|
|
|
{
|
|
|
|
|
await HandleBtn2Click(e, ConfirmResult.Retry);
|
2020-12-26 21:39:04 +08:00
|
|
|
|
}, out _cancelBtn)
|
|
|
|
|
;
|
2020-11-01 16:00:23 +08:00
|
|
|
|
|
|
|
|
|
@BuildButton(Config.Button3Props, async (e) =>
|
|
|
|
|
{
|
|
|
|
|
await HandleBtn3Click(e, ConfirmResult.Ignore);
|
2020-12-26 21:39:04 +08:00
|
|
|
|
}, out _)
|
|
|
|
|
;
|
2020-11-01 16:00:23 +08:00
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
2020-12-26 21:39:04 +08:00
|
|
|
|
}
|
2020-11-01 16:00:23 +08:00
|
|
|
|
</div>
|
2020-06-02 14:25:44 +08:00
|
|
|
|
</div>
|
2020-12-26 21:39:04 +08:00
|
|
|
|
</DialogWrapper>
|