@inherits FeedbackComponent<ReviewerAppealModel>
@using Microsoft.Extensions.Configuration

@inject IConfiguration configuration
<Collapse>
    @if (_Model.Item != null)
    {
        <Panel Active="true" Style="width:100%" Header="案件信息摘要">
            <div>
                <Row>
                    <AntDesign.Col Span="4"><b>我方文号:</b></AntDesign.Col>
                    <AntDesign.Col Span="8">@_Model.Item.CaseNo</AntDesign.Col>
                    <AntDesign.Col Span="4"><b>处理事项:</b></AntDesign.Col>
                    <AntDesign.Col Span="8">@_Model.Item.DoItem</AntDesign.Col>
                </Row>

                <Row>
                    <AntDesign.Col Span="4"><b>案件名称:</b></AntDesign.Col>
                    <AntDesign.Col Span="20">@_Model.Item.CaseName</AntDesign.Col>
                </Row>
            </div>
        </Panel>
    }
    <Panel Active="true" Header="@($"{@_Model.AppealRecord.Creater.Name}与{@_Model.AppealRecord.CreateTime.ToString("yyyy-MM-dd")}提交如下审核内容")">
        @*<Row>
                <AntDesign.Col Span="4"><b>提交人:</b></AntDesign.Col>
                <AntDesign.Col Span="8">@_Model.AppealRecord.Creater.Name</AntDesign.Col>
                <AntDesign.Col Span="4"><b>提交时间:</b></AntDesign.Col>
                <AntDesign.Col Span="8"></AntDesign.Col>
            </Row>
            <Row>
                <AntDesign.Col Span="24"><b>提交内容：</b></AntDesign.Col>
            </Row>*@
        @foreach (InputField field in _Model.CreateInputFields)
        {
            List<InputFieldValue> fValues = _Model.CreateAppealFieldValues.Where<InputFieldValue>(iv => iv.InputFieldId == field.Id).ToList();

            if (!string.IsNullOrEmpty(field.MapObjectField) && !string.IsNullOrEmpty(field.MapObjectFieldLabel))
            {
                <Divider />
                <Row><AntDesign.Col>@field.FieldName ：</AntDesign.Col></Row>

                @foreach (InputFieldValue temValue in fValues)
                {
                    <Row>
                        <AntDesign.Col Span="2"></AntDesign.Col>
                        <AntDesign.Col Span="8"><b>@temValue.Label:</b></AntDesign.Col>
                        <AntDesign.Col Span="14">@temValue.Value</AntDesign.Col>
                    </Row>

                }
                <Divider />

            }
            else
            {
                @foreach (InputFieldValue temValue in fValues)
                {
                    <Row>
                        <AntDesign.Col Span="2"></AntDesign.Col>
                        <AntDesign.Col Span="8"><b>@temValue.InputField.FieldName:</b></AntDesign.Col>
                        <AntDesign.Col Span="14">@temValue.Value</AntDesign.Col>
                    </Row>
                }
            }
        }
    </Panel>
    @if (_Model.attachFiles != null && _Model.attachFiles.Count > 0)
    {
        <Panel Active="true" Header="附件">

            <Row>
                <AntDesign.Col Span="2"></AntDesign.Col>
                <AntDesign.Col Span="14">文件名称</AntDesign.Col>
                <AntDesign.Col Span="8">上传人</AntDesign.Col>
            </Row>
            @foreach (AttachFile file in _Model.attachFiles)
            {
                <Row>
                    <AntDesign.Col Span="2"></AntDesign.Col>
                    <AntDesign.Col Span="14"><a href="@($"{configuration.GetValue<string>("APIUrl")}AttachFiles/Download?id={file.Id}")">@file.Name </a></AntDesign.Col>
                    <AntDesign.Col Span="8">@file.UploadUser.Name</AntDesign.Col>
                </Row>
            }
        </Panel>
    }
</Collapse>

<Card>
    <Form Model="@_Model" LabelColSpan="6" WrapperColSpan="16" Size="@AntSizeLDSType.Small">

        @foreach (InputField field in context.inputFields)
        {
            List<InputFieldValue> fValues = context.inputFieldValues.Where<InputFieldValue>(iv => iv.InputFieldId == field.Id).ToList();

            if (!string.IsNullOrEmpty(field.MapObjectField) && !string.IsNullOrEmpty(field.MapObjectFieldLabel))
            {
                <Divider />
                <FormItem><span>请输入 @field.FieldName：</span></FormItem>

                @foreach (InputFieldValue temValue in fValues)
                {

                    <FormItem Label="@temValue.Label">
                        @switch (temValue.InputField.FieldType)
                        {
                            case "System.String":
                                if (temValue.InputField.SelectValues != null && temValue.InputField.SelectValues.Count > 0)
                                {
                                    <Select @bind-Value="@temValue.Value" DataSource="@temValue.InputField.SelectValues"
                                            ValueName="@nameof(SelectValue.Value)"
                                            LabelName="@nameof(SelectValue.Value)" />
                                }
                                else
                                {
                                    <Input @bind-Value="@temValue.Value" />
                                }

                                break;
                            case "System.DateTime":
                                <DatePicker @bind-Value="@temValue.Value" />
                                break;

                            default:
                                <Input @bind-Value="@temValue.Value" />
                                break;

                        }

                    </FormItem>

                }
                <Divider />

            }
            else
            {
                @foreach (InputFieldValue temValue in fValues)
                {
                    <FormItem Label="@temValue.InputField.FieldName">
                        @switch (temValue.InputField.FieldType)
                        {
                            case "System.String":
                                if (temValue.InputField.SelectValues != null && temValue.InputField.SelectValues.Count > 0)
                                {
                                    <Select @bind-Value="@temValue.Value" DataSource="@temValue.InputField.SelectValues"
                                            ValueName="@nameof(SelectValue.Value)"
                                            LabelName="@nameof(SelectValue.Value)" />
                                }
                                else
                                {
                                    if (temValue.InputField.MaxSize != null && temValue.InputField.MaxSize > 20)
                                    {
                                        <TextArea @bind-Value="@temValue.Value" Rows="5" />
                                    }
                                    else
                                    {
                                        <Input @bind-Value="@temValue.Value" />
                                    }

                                }

                                break;
                            case "System.DateTime":
                                <DatePicker @bind-Value="@temValue.Value" />
                                break;

                            default:
                                if (temValue.InputField.MaxSize != null && temValue.InputField.MaxSize > 20)
                                {
                                    <TextArea @bind-Value="@temValue.Value" Rows="5" />
                                }
                                else
                                {
                                    <Input @bind-Value="@temValue.Value" />
                                }
                                break;

                        }

                    </FormItem>
                }
            }

        }

    </Form>

</Card>
