@page "/Workflow/Detail/{WorkflowId:int}"


<PageContainer>
    <Breadcrumb>
        <Breadcrumb>
            <BreadcrumbItem>
                <a href="/Home"><Icon Type="home"></Icon></a> 
            </BreadcrumbItem>
            <BreadcrumbItem>
                <Icon Type="apartment" Theme="outline" /><span>流程管理</span>
            </BreadcrumbItem>
        </Breadcrumb>
    </Breadcrumb>
    <Content>
        <Menu Mode=MenuMode.Horizontal>
            <MenuItem OnClick="AddNewStep"><Icon Type="file-add" Theme="twotone" />添加步骤</MenuItem>
            <MenuItem OnClick="AddNewTransfer"><Icon Type="line" Theme="outline" />添加步骤转移条件</MenuItem>
            <MenuItem OnClick="OnRefresh"><Icon Type="layout" Theme="twotone" />自动布局</MenuItem>
            <MenuItem>
                <Popconfirm Title="您确认删除选中的对象?"
                            OnConfirm="DeleteObject"
                            OkText="Yes"
                            CancelText="No">
                    <a><Icon Type="delete" Theme="outline"/>删除</a>
                </Popconfirm>
            </MenuItem>

        </Menu>
    </Content>
    <ChildContent>
        @if (workflow == null)
        {
            <Spin />
        }
        else
        {
    <div style="height:800px;width:100%;overflow:auto;background:#FFFFFF;" id="div-Container">
        <Affix TargetSelector="#div-Container" OffsetTop="10" Style="float:right">
            <a href="@DownloadUrl"><Icon Type="download" Theme="outline" /></a>
        </Affix>
        <wispro.sp.web.Components.FlowChart @ref="chart"
                                            workflow="@workflow" Actions="@Actions"
                                            Transfers="@Transfers" Steps="@Steps"
                                            OnClickAction="OnClickAction"
                                            OnClickStep="OnClickStep"
                                            OnClickTransfer="OnClickTransfer"
                                            OnDoubleClickStep="OnDblClickStep"
                                            hSeparation="80"/>
    </div>
        }
    </ChildContent>
</PageContainer>

<Modal Title="步骤"
       Visible="@StepModalShow"
       OnOk="@EditStepOK"
       OnCancel="@EditStepCancel"
       OkText="@("保存")"
       CancelText="@("取消")"
       Width="1000"
       MaskClosable="false">

    <Form Model="EditStep" LabelColSpan="6"
          WrapperColSpan="16">
        <FormItem Label="步骤名称">
            <Input @bind-Value="context.Step.Name" />
        </FormItem>
        <FormItem Label="责任人">
            <wispro.sp.web.Components.ResponseManCondition Workflow="workflow" UserField="userField"/>
        </FormItem>

        <div><Button Type="primary" Icon="plus" OnClick="AddNewAction" Style="float:right">添加操作</Button></div>
       
        <AntDesign.Table DataSource="@context.actions"
                         Bordered=@true
                         Size=@TableSize.Middle
                         HidePagination
                         Context="ss">
            <ChildContent>
                
                <AntDesign.Column Title="名称" TData="string">
                    @if (ss.Action != null)
                    {
                        <span>@ss.Action.Name</span>
                    }
                    
                </AntDesign.Column> 
                <AntDesign.Column Title="操作界面" TData="string">
                    @if(ss.Action != null)
                    {
                        <span>@ss.Action.InputForm</span>
                    }
                </AntDesign.Column>
                <AntDesign.Column Title="所属步骤" TData="string">

                    @if (context.Step.Name != null)
                    {
                        <span>@context.Step.Name</span>
                    }

                </AntDesign.Column>
                <ActionColumn>
                    <Space>
                        <SpaceItem><Button OnClick="()=>BeginEditAction(ss.Action.Id)">修改</Button></SpaceItem>
                    </Space>
                    <Space>
                        <SpaceItem><Button Danger OnClick="()=>DeleteAction(ss.Action.Id)">删除</Button></SpaceItem>
                    </Space>
                </ActionColumn>
            </ChildContent>
            
        </AntDesign.Table>
    </Form>

</Modal>

<Modal Title="步骤操作"
       Visible="@ActionModalShow"
       OnOk="@EditActionOK"
       OnCancel="@EditActionCancel"
       OkText="@("确定")"
       CancelText="@("取消")"
       Width="1000" MaskClosable="false">

    <Form Model="EditAction" LabelColSpan="6"
          WrapperColSpan="16">
        @*<FormItem Label="所属步骤">
            <Select DataSource="@Steps"
                DefaultValue="@EditAction.Action.StepId"
                @bind-Value="@EditAction.Action.StepId"
                LabelName="@nameof(wispro.sp.entity.workflowDefine.Step.Name)"
                ValueName="@nameof(wispro.sp.entity.workflowDefine.Step.Id)"
                Style="width: 200px"
                Placeholder="请选择"
                IgnoreItemChanges="false"
                EnableSearch="true"
                AllowClear>
        </Select>
        </FormItem>*@
        <FormItem Label="操作名称">
            <Input @bind-Value="@EditAction.Action.Name" />
        </FormItem>
        <FormItem Label="初始化界面">
            <Input @bind-Value="@EditAction.Action.InputForm" />
        </FormItem>
        
        <wispro.sp.web.Components.InputValueSetting EditAction="@EditAction" />
    </Form>

</Modal>

<Modal Title="步骤转移条件"
       Visible="@TransferModalShow"
       OnOk="@EditTransferOK"
       OnCancel="@EditTransferCancel"
       OkText="@("保存")"
       CancelText="@("取消")"
       Width="1000" MaskClosable="false">

    <Form Model="EditTransfer" LabelColSpan="6"
          WrapperColSpan="16">
        <FormItem Label="从步骤">
            <Select DataSource="@Steps"
                    DefaultValue="@(EditTransfer.StepId.HasValue?EditTransfer.StepId.Value:0)"
                    @bind-Value="@EditTransfer.StepId"
                    LabelName="@nameof(wispro.sp.entity.workflowDefine.Step.Name)"
                    ValueName="@nameof(wispro.sp.entity.workflowDefine.Step.Id)"
                    Style="width: 200px"
                    Placeholder="@workflow.InitAction.Name"
                    EnableSearch="true"
                    AllowClear>
            </Select>
        </FormItem>

        <FormItem Label="到步骤">
            <Select DataSource="@Steps"
                    DefaultValue="@EditTransfer.nextStepId"
                    @bind-Value="@EditTransfer.nextStepId"
                    LabelName="@nameof(wispro.sp.entity.workflowDefine.Step.Name)"
                    ValueName="@nameof(wispro.sp.entity.workflowDefine.Step.Id)"
                    Style="width: 200px"
                    Placeholder="请选择"
                    EnableSearch="true"
                    AllowClear>
            </Select>
        </FormItem>
        <FormItem Label="条件">
            <Input @bind-Value="@EditTransfer.Condition" />
        </FormItem>

        
    </Form>

</Modal>

