Selaa lähdekoodia

添加审核界面

luocaiyang 3 vuotta sitten
vanhempi
commit
ce08816b3c

+ 22 - 0
wispro.sp.api/Controllers/AppealController.cs

@@ -84,5 +84,27 @@ namespace wispro.sp.api.Controllers
                 .Include(p => p.Type).ToList();
             
         }
+
+        public AppealRecord GetAppealRecord(int Id)
+        {
+            var data = Context.AppealRecords.Where<AppealRecord>(ar => ar.Id == Id);
+
+            return data.Include(p => p.Reviewer)
+                .Include(p => p.Creater)
+                .Include(p => p.Item)
+                .Include(p => p.Type).FirstOrDefault();
+        }
+
+        public List<InputFieldValue> GetInputFieldValues(int id, int state)
+        {
+            var result = Context.InputFieldValues.Where<InputFieldValue>(f => f.AppealRecordId == id && f.InputField.AppealState == state);
+            return result.Include(i => i.InputField).ToList();
+        }
+
+        public List<AttachFile> GetAppealRecordAttachFiles(int appealRecordId)
+        {
+            var result = Context.AttachFiles.Where<AttachFile>(at => at.AppealRecordId == appealRecordId).Include(f => f.UploadUser);
+            return result.ToList();
+        }
     }
 }

+ 1 - 1
wispro.sp.web/Components/CreateAppeal.razor

@@ -36,7 +36,7 @@
             if (!string.IsNullOrEmpty(field.MapObjectField) && !string.IsNullOrEmpty(field.MapObjectFieldLabel))
             {
                 <Divider />
-                <FormItem><span>请输入分配比例:</span></FormItem>
+                <FormItem><span>请输入 @field.FieldName :</span></FormItem>
 
                 @foreach (InputFieldValue temValue in fValues)
                 {

+ 183 - 0
wispro.sp.web/Components/ReviewerAppeal.razor

@@ -0,0 +1,183 @@
+@inherits FeedbackComponent<ReviewerAppealModel>
+<Collapse >
+    <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="@($"http://localhost:39476/api/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>

+ 38 - 0
wispro.sp.web/Components/ReviewerAppeal.razor.cs

@@ -0,0 +1,38 @@
+using AntDesign;
+using Microsoft.AspNetCore.Components;
+using Microsoft.AspNetCore.Components.Forms;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http;
+using System.Net.Http.Json;
+using System.Text.Json;
+using System.Threading.Tasks;
+using wispro.sp.entity;
+using wispro.sp.web.Models;
+using wispro.sp.web.Services;
+
+namespace wispro.sp.web.Components
+{
+    public partial  class ReviewerAppeal
+    {
+        private ReviewerAppealModel _Model;
+        private IFeedbackRef feedbackRef;
+
+        [Inject]
+        protected AppealTypeService _atService { get; set; }
+
+        [Inject]
+        protected HttpClient _httpClient { get; set; }
+
+        protected override async void OnInitialized()
+        {
+            _Model = base.Options ?? new ReviewerAppealModel();
+            //Console.WriteLine($"Success:{JsonSerializer.Serialize(_Model)}");
+            base.OnInitialized();
+            feedbackRef = base.FeedbackRef;
+        }
+
+
+    }
+}

+ 108 - 0
wispro.sp.web/Models/ReviewerAppealModel.cs

@@ -0,0 +1,108 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text.Json;
+using System.Threading.Tasks;
+using wispro.sp.entity;
+using wispro.sp.web.Services;
+
+namespace wispro.sp.web.Models
+{
+    public class ReviewerAppealModel
+    {
+        public PerformanceItem Item { get; set; }
+
+        public AppealType AppealType { get; set; }
+
+        public List<InputField> CreateInputFields { get; set; }
+        public List<InputFieldValue> CreateAppealFieldValues { get; set; }
+
+        public List<InputField> inputFields { get; set; }
+        public List<InputFieldValue> inputFieldValues { get; set; }
+
+        public List<AttachFile> attachFiles { get; set; }
+
+        public AppealRecord AppealRecord { get; set; }
+
+        public async Task Init(AppealTypeService _atService, int appealRecordId)
+        {
+            this.AppealRecord =await _atService.getAppealRecord(appealRecordId);
+            Item = this.AppealRecord.Item;
+            CreateInputFields = await _atService.GetInputFields(this.AppealRecord.TypeId, 0);
+            CreateAppealFieldValues = await _atService.GetInputFieldValues(this.AppealRecord.Id,0);
+            inputFields = await _atService.GetInputFields(this.AppealRecord.TypeId, 1);
+            attachFiles = await _atService.GetAppealRecordAttachFiles(this.AppealRecord.Id);
+
+            inputFieldValues = new List<InputFieldValue>();
+            foreach (var field in inputFields)
+            {
+                Console.WriteLine($"inputFields:{JsonSerializer.Serialize(field)}");
+                if (!string.IsNullOrEmpty(field.MapObjectField) && !string.IsNullOrEmpty(field.MapObjectFieldLabel))
+                {
+                    List<InputFieldValue> temValues = new List<InputFieldValue>();
+                    string[] pList = field.MapObjectField.Split(new char[] { '.' });
+                    string[] plList = field.MapObjectFieldLabel.Split(new char[] { '.' });
+
+                    var pInfo = Item.GetType().GetProperty(pList[0]);
+
+                    var o = pInfo.GetValue(Item);
+
+
+                    if (Array.IndexOf(o.GetType().GetInterfaces(), typeof(IEnumerable)) > -1)
+                    {
+                        List<string> Values = new List<string>();
+                        List<string> Labels = new List<string>();
+
+                        var objList = o as IEnumerable;
+
+                        foreach (var obj in objList)
+                        {
+                            var objValue = obj;
+                            var objLabel = obj;
+                            for (int i = 1; i < pList.Length; i++)
+                            {
+                                objValue = objValue.GetType().GetProperty(pList[i]).GetValue(objValue);
+
+                            }
+
+                            for (int i = 1; i < plList.Length; i++)
+                            {
+                                objLabel = objLabel.GetType().GetProperty(plList[i]).GetValue(objLabel);
+                            }
+
+                            var fValue = new InputFieldValue();
+                            fValue.InputField = field;
+                            fValue.InputFieldId = field.Id;
+                            fValue.Label = objLabel.ToString();
+                            if (objValue != null)
+                            {
+                                fValue.Value = objValue.ToString();
+                            }
+                            inputFieldValues.Add(fValue);
+                            temValues.Add(fValue);
+                        }
+                    }
+                    else
+                    {
+                        var fValue = new InputFieldValue();
+                        fValue.InputField = field;
+                        fValue.InputFieldId = field.Id;
+                        inputFieldValues.Add(fValue);
+                    }
+                }
+                else
+                {
+                    Console.WriteLine($"inputFields:{JsonSerializer.Serialize(field)}");
+                    var fValue = new InputFieldValue();
+                    fValue.InputField = field;
+                    fValue.InputFieldId = field.Id;
+                    inputFieldValues.Add(fValue);
+                }
+            }
+
+            
+        }
+
+    }
+}

+ 1 - 0
wispro.sp.web/Pages/AppCase/MyCaselist.razor.cs

@@ -256,6 +256,7 @@ namespace wispro.sp.web.Pages.AppCase
 
             var modalConfig = new ModalOptions();
             modalConfig.Title = appealType.Name;
+            modalConfig.Width = 650;
             //modalConfig.Footer = null;
             modalConfig.DestroyOnClose = true;
 

+ 4 - 3
wispro.sp.web/Pages/Welcome.razor

@@ -47,8 +47,9 @@
                              DataSource="@AppealRecords"
                              Class="activitiesList"
                              Size="large"
-                             ItemLayout="ListItemLayout.Horizontal">
-                        <ListItem>
+                             ItemLayout="ListItemLayout.Horizontal"
+                             >
+                        <ListItem OnClick="() => ShowModel(context)">
                             <ListItemMeta Avatar="@context.Creater.Name" Description="@(context.ReviewTime.HasValue?context.ReviewTime.Value.ToFriendlyDisplay():context.CreateTime.ToFriendlyDisplay())">
                                 <TitleTemplate>
                                     <span>
@@ -69,7 +70,7 @@
                                                     <span>您在 @context.CreateTime.ToFriendlyDisplay() 提交的 @context.Item.CaseNo @context.Type.Name ,正在等待 @context.Reviewer.Name 审核!"</span>}
                                                 else
                                                 {
-                                                    <span>@context.Creater.Name 在 @context.CreateTime.ToFriendlyDisplay() 提交的 @context.Item.CaseNo @context.Type.Name ,请您尽快<a href="#">审核</a>! </span>
+                                                    <span>@context.Creater.Name 在 @context.CreateTime.ToFriendlyDisplay() 提交的 @context.Item.CaseNo @context.Type.Name ,请您尽快<a href="/appeal/reviewer/@context.Id">审核</a>! </span>
                                                 }
                                                                                 
                                             }

+ 59 - 0
wispro.sp.web/Pages/Welcome.razor.cs

@@ -5,6 +5,9 @@ using Microsoft.AspNetCore.Components;
 using wispro.sp.web.Components;
 using System.Collections.Generic;
 using wispro.sp.entity;
+using System.Text.Json;
+using AntDesign;
+using System;
 
 namespace wispro.sp.web.Pages
 {
@@ -29,6 +32,9 @@ namespace wispro.sp.web.Pages
         [Inject] public IUserService _userService { get; set; }
 
         [Inject] protected AppealTypeService _atService { get; set; }
+        private ModalRef _modalRef;
+        [Inject] ModalService _ModalService { get; set; }
+        
 
         protected override async System.Threading.Tasks.Task OnInitializedAsync()
         {
@@ -59,5 +65,58 @@ namespace wispro.sp.web.Pages
                 System.Diagnostics.Debug.WriteLine(at.Item.CaseNo);
             }
         }
+
+        async Task ShowModel(AppealRecord appealRecord)
+        {
+            
+            var templateOptions = new Models.ReviewerAppealModel();
+            await templateOptions.Init(_atService, appealRecord.Id);
+
+            var modalConfig = new ModalOptions();
+            modalConfig.Title = $"{appealRecord.Type.Name}审核" ;
+            modalConfig.Width = 650;
+            //modalConfig.Footer = null;
+            modalConfig.DestroyOnClose = true;
+
+
+            _modalRef = await _ModalService
+                .CreateModalAsync<Components.ReviewerAppeal, Models.ReviewerAppealModel>(modalConfig, templateOptions);
+
+            _modalRef.OnOpen = () =>
+            {
+                Console.WriteLine("ModalRef OnOpen");
+                return Task.CompletedTask;
+            };
+
+            _modalRef.OnOk = async () =>
+            {
+                Console.WriteLine(JsonSerializer.Serialize(templateOptions));
+                try
+                {
+                    await _atService.ReviewerAppeal(templateOptions);
+                    await _modalRef.CloseAsync();
+
+                }
+                catch (Exception ex)
+                {
+                    //_ErrorMessage = ex.Message;
+                }
+
+                //return Task.CompletedTask;
+            };
+
+            _modalRef.OnCancel = () =>
+            {
+                Console.WriteLine("ModalRef OnCancel");
+                return Task.CompletedTask;
+            };
+
+            _modalRef.OnClose = () =>
+            {
+                Console.WriteLine("ModalRef OnClose");
+                return Task.CompletedTask;
+            };
+            StateHasChanged();
+        }
     }
 }

+ 38 - 0
wispro.sp.web/Services/AppealTypeService.cs

@@ -28,6 +28,18 @@ namespace wispro.sp.web.Services
             
         }
 
+        public async Task<AppealRecord> getAppealRecord(int appealRecordId)
+        {
+            var data = await _httpClient.GetFromJsonAsync<AppealRecord>($"http://localhost:39476/api/Appeal/GetAppealRecord?Id={appealRecordId}");
+            return data;
+        }
+
+        public async Task<List<InputFieldValue>> GetInputFieldValues(int id, int state)
+        {
+            var data = await _httpClient.GetFromJsonAsync<List<InputFieldValue>>($"http://localhost:39476/api/Appeal/GetInputFieldValues?Id={id}&state={state}");
+            return data;
+        }
+
         public async Task<List<AppealType>> GetItems()
         {
             if (AppealTypes == null)
@@ -85,10 +97,17 @@ namespace wispro.sp.web.Services
 
         public async Task<List<InputField>> GetInputFields(int appealTypeId,int State)
         {
+            Console.WriteLine($"begin GetInputFields: appealTypeId={appealTypeId};State={State}");
             var data = await _httpClient.GetFromJsonAsync<List<InputField>>($"http://localhost:39476/api/Appeal/GetInputField?appealTypeId={appealTypeId}&state={State}");
             return data;
         }
 
+        public async Task<List<AttachFile>> GetAppealRecordAttachFiles(int appealRecordId)
+        {
+            var data = await _httpClient.GetFromJsonAsync<List<AttachFile>>($"http://localhost:39476/api/Appeal/GetAppealRecordAttachFiles?appealRecordId={appealRecordId}");
+            return data;
+        }
+
         public async Task CreateAppeal(CreateAppealModel model)
         {
             List<AttachFile> attachFiles = new List<AttachFile>();
@@ -114,5 +133,24 @@ namespace wispro.sp.web.Services
 
             Console.WriteLine(JsonSerializer.Serialize(data));
         }
+
+        public async Task ReviewerAppeal(ReviewerAppealModel model)
+        {
+
+            string strUrl = $"http://localhost:39476/api/Appeal/CreateAppeal?ItemId={model.Item.Id}&typeid={model.AppealType.Id}&reviewerId={model.AppealRecord.ReviewerId}";
+            AppealObject appealObject = new AppealObject();
+            appealObject.inputFieldValues = model.inputFieldValues;
+
+            foreach (var fValue in appealObject.inputFieldValues)
+            {
+                fValue.InputField = null;
+            }
+
+            var data = await _httpClient.PostAsJsonAsync<AppealObject>(strUrl, appealObject);
+
+            Console.WriteLine(JsonSerializer.Serialize(data));
+        }
+        
+        
     }
 }