Prechádzať zdrojové kódy

完成创建申诉界面

luocaiyang 3 rokov pred
rodič
commit
38cee5d691

+ 54 - 2
wispro.sp.api/Controllers/AppealController.cs

@@ -6,6 +6,7 @@ using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
 using wispro.sp.entity;
+using wispro.sp.share;
 
 namespace wispro.sp.api.Controllers
 {
@@ -25,12 +26,63 @@ namespace wispro.sp.api.Controllers
             return Context.AppealTypes.ToList();
         }
 
-        public List<InputField> GetInputField(int appealTypeId,int state)
+        public List<InputField> GetInputField(int appealTypeId, int state)
         {
             return Context.InputFields
                 .Where<InputField>(ip => ip.AppealTypeId == appealTypeId && ip.AppealState == state)
-                .Include(p=>p.SelectValues)
+                .Include(p => p.SelectValues)
                 .ToList();
         }
+
+        public IActionResult CreateAppeal(int ItemId, int typeid, int reviewerId, AppealObject appealObject)
+        {
+            AppealRecord appealRecord = new AppealRecord();
+            appealRecord.ItemId = ItemId;
+            appealRecord.TypeId = typeid;
+            appealRecord.ReviewerId = reviewerId;
+            appealRecord.CreaterId = 11;// Context.Staffs.Where<Staff>(s => s.Name == User.Identity.Name).FirstOrDefault().Id;
+            appealRecord.CreateTime = DateTime.Now;
+
+            var t = Context.Database.BeginTransaction();
+            try
+            {
+                Context.AppealRecords.Add(appealRecord);
+                Context.SaveChanges();
+                foreach (var fieldValue in appealObject.inputFieldValues)
+                {
+                    fieldValue.InputField = null;
+                    fieldValue.AppealRecordId = appealRecord.Id;
+                }
+                Context.InputFieldValues.AddRange(appealObject.inputFieldValues);
+
+                foreach (var file in appealObject.attachFiles)
+                {
+                    var temFile = Context.AttachFiles.Where<AttachFile>(f => f.Id == file.Id).FirstOrDefault();
+                    temFile.AppealRecordId = appealRecord.Id;
+                }
+
+                Context.SaveChanges();
+                t.Commit();
+
+                return Ok();
+            }
+            catch (Exception ex)
+            {
+                t.Rollback();
+
+                return BadRequest(ex.Message);
+            }
+        }
+
+        public List<AppealRecord> GetAppealRecords(int userId)
+        {
+            var data = Context.AppealRecords.Where<AppealRecord>(ar => ar.CreaterId == userId || ar.ReviewerId == userId);
+
+            return data.Include(p => p.Reviewer)
+                .Include(p => p.Creater)
+                .Include(p => p.Item)
+                .Include(p => p.Type).ToList();
+            
+        }
     }
 }

+ 75 - 1
wispro.sp.api/Controllers/AttachFilesController.cs

@@ -1,6 +1,7 @@
 using Microsoft.AspNetCore.Hosting;
 using Microsoft.AspNetCore.Http;
 using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.StaticFiles;
 using Microsoft.Extensions.Logging;
 using System;
 using System.Collections.Generic;
@@ -29,8 +30,81 @@ namespace wispro.sp.api.Controllers
             this.Context = context;
         }
 
+        private string GetContentType(string path)
+        {
+            var provider = new FileExtensionContentTypeProvider();
+            string contentType;
+
+            if (!provider.TryGetContentType(path, out contentType))
+            {
+                contentType = "application/octet-stream";
+            }
+
+            return contentType;
+        }
+
+        [HttpGet,DisableRequestSizeLimit]
+        public async Task<IActionResult> Download(string Id)
+        {
+            var filename = Context.AttachFiles.Where<AttachFile>(a => a.Id == new Guid(Id)).FirstOrDefault();
+
+            if (filename != null)
+            {
+                var attachfileSavePath = utility.ConfigHelper.GetSectionValue("AttachFileSavePath");
+                var filePath = Path.Combine(attachfileSavePath,
+                    filename.SavePath);
+
+                var context = HttpContext;
+
+                if (System.IO.File.Exists(filePath))
+                {
+                    var memory = new MemoryStream();
+                    await using (var stream = new FileStream(filePath, FileMode.Open))
+                    {
+                        await stream.CopyToAsync(memory);
+                    }
+                    memory.Position = 0;
+                    return File(memory, GetContentType(filename.Name), filename.Name);
+                }
+                else
+                    return NotFound();
+            }
+            else
+            {
+                return NotFound();
+            }
+        }
+
+        public async Task<bool> Delete(string Id)
+        {
+            var filename = Context.AttachFiles.Where<AttachFile>(a => a.Id == new Guid(Id)).FirstOrDefault();
+
+            if (filename != null)
+            {
+                var attachfileSavePath = utility.ConfigHelper.GetSectionValue("AttachFileSavePath");
+                var filePath = Path.Combine(attachfileSavePath,
+                    filename.SavePath);
+
+                Context.AttachFiles.Remove(filename);
+                await Context.SaveChangesAsync();
+
+                if (System.IO.File.Exists(filePath))
+                {
+                    System.IO.File.Delete(filePath);
+                    return true;
+                }
+                else
+                {
+                    return false;
+                }
+            }
+            else
+            {
+                return false;
+            }
+        }
         [HttpPost]
-        public async Task<ActionResult<IList<AttachFile>>> PostFile(
+        public async Task<ActionResult<AttachFile>> PostFile(
         [FromForm] IEnumerable<IFormFile> files)
         {
             var maxAllowedFiles = 3;

+ 32 - 0
wispro.sp.api/Controllers/PerformanceItemController.cs

@@ -269,6 +269,37 @@ namespace wispro.sp.api.Controllers
             return ret;
         }
 
+        public PerformanceItem Get(int Id)
+        {
+            var results = Context.PerformanceItems
+                .Where<PerformanceItem>(s =>s.Id == Id);
+
+            PerformanceItem item = results
+                .Include(pi => pi.ItemStaffs).ThenInclude(iStaff => iStaff.DoPerson)
+                .Include(pi => pi.Reviewer)
+                .Include(pi => pi.Customer)
+                .Include(pi => pi.CalMonth)
+                .OrderByDescending(o => o.Id)
+                .FirstOrDefault();
+
+            #region 将某些属性设为null,避免循环取值造成返回json过大
+            foreach (ItemStaff itemStaff in item.ItemStaffs)
+            {
+                itemStaff.DoPerson.ItemStaffs = null;
+                itemStaff.DoPerson.ReviewerItems = null;
+                itemStaff.Item = null;
+            }
+
+            item.Reviewer.ReviewerItems = null;
+            item.Reviewer.Customers = null;
+            item.Reviewer.ItemStaffs = null;
+
+            item.Customer.PerformanceItems = null;
+            item.CalMonth.PerformanceItems = null;
+            #endregion
+
+            return item;
+        }
         /// <summary>
         /// 获取给定用户的绩效清单
         /// </summary>
@@ -511,6 +542,7 @@ namespace wispro.sp.api.Controllers
             
         }
 
+        
         private string GetExpress(IList<FieldCondition> conditions)
         {
             string str = "";

+ 0 - 1
wispro.sp.api/Controllers/StaffController.cs

@@ -28,7 +28,6 @@ namespace wispro.sp.api.Controllers
         {
             return Context.Staffs.ToList<Staff>();
         }
-
         
         
         public ListApiResponse<Staff> Query(int pageIndex,int pageSize)

+ 5 - 2
wispro.sp.api/spDbContext.cs

@@ -534,8 +534,11 @@ namespace wispro.sp.api
             };
 
             InputField[] inputFields = new InputField[] {
-                new InputField(){Id=1,AppealTypeId =1,AppealState =0,FieldName ="分配比率", MapObjectField ="ItemStaffs.PerformancePoint",FieldType = typeof(double).ToString() },
-                new InputField(){Id=2,AppealTypeId =1,AppealState =0,FieldName ="处理人", MapObjectField ="ItemStaffs.DoPerson.Name" ,FieldType =typeof(string).ToString() },
+                new InputField(){Id=1,AppealTypeId =1,AppealState =0,FieldName ="分配比率",
+                    MapObjectField ="ItemStaffs.PerformancePoint",
+                    FieldType = typeof(double).ToString(),
+                    MapObjectFieldLabel="ItemStaffs.DoPerson.Name"
+                },
                 new InputField(){Id=3,AppealTypeId =1,AppealState =0,FieldName ="原因",FieldType =typeof(string).ToString() },
                 new InputField(){Id=4,AppealTypeId =1,AppealState =1,FieldName ="备注",FieldType =typeof(string).ToString() },
                 new InputField(){Id=5,AppealTypeId =1,AppealState =1,FieldName ="审核意见",FieldType =typeof(string).ToString()},

+ 16 - 0
wispro.sp.share/AppealObject.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using wispro.sp.entity;
+
+namespace wispro.sp.share
+{
+    public class AppealObject
+    {
+        public List<InputFieldValue> inputFieldValues { get; set; }
+
+        public List<AttachFile> attachFiles { get; set; }
+    }
+}

+ 99 - 37
wispro.sp.web/Components/CreateAppeal.razor

@@ -18,55 +18,117 @@
         </Row>
     </div>
 </Card>
+@if (!string.IsNullOrEmpty(_ErrorMessage)) 
+{ 
+<Alert Message="@_ErrorMessage" Type="@AlertType.Error" />
+}
 <Card>
-    <Form Model="@_Model" LabelColSpan="6" WrapperColSpan="16">
+    <Form Model="@_Model" LabelColSpan="6" WrapperColSpan="16" Size="@AntSizeLDSType.Small">
         <FormItem Label="请谁确认">
-            <Select DataSource="@Reviewers"
-                    @bind-Value="@context.AppealRecord.ReviewerId"
-                    LabelName="@nameof(Staff.Name)"
-                    ValueName="@nameof(Staff.Id)"
-                    Placeholder="请选择确认人"
-                    Style="width: 100%"
-                    AllowClear
-                    DefaultActiveFirstItem="false"
-                    EnableSearch>
-            </Select>
+            <StaffSelect @bind-StaffId="@context.AppealRecord.ReviewerId" />
         </FormItem>
-        @foreach (InputFieldValue field in context.inputFieldValues)
-        {
-    <FormItem Label="@field.InputField.FieldName">
-        @switch (field.InputField.FieldType)
+
+
+        @foreach (InputField field in context.inputFields)
         {
-            case "System.String":
-                if (field.InputField.SelectValues != null && field.InputField.SelectValues.Count > 0)
+            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>请输入分配比例:</span></FormItem>
+
+                @foreach (InputFieldValue temValue in fValues)
                 {
-                    <Select @bind-Value="@field.Value" DataSource="@field.InputField.SelectValues"
-                            ValueName="@nameof(SelectValue.Value)"
-                            LabelName="@nameof(SelectValue.Value)" />
+                    
+                            <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>
+                       
                 }
-                else
+                <Divider />
+
+            }
+            else
+            {
+                @foreach (InputFieldValue temValue in fValues)
                 {
-                    <Input @bind-Value="@field.Value" />
-                }
+                    <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="@field.Value" />
-                break;
-            
-             default:
-                <Input @bind-Value="@field.Value" />
-                 break;
+                                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>
+                }
+            }
 
-    </FormItem>
         }
 
         <FormItem Label="附件">
             <Upload @attributes="attrs"
-                    FileList="fileList"
-                    OnChange="HandleChange">
+                    FileList="_Model.FileList"
+                    OnChange="HandleChange"
+                    OnRemove="RemoveFile">
                 <Button Icon="upload"><span>添加附件</span></Button>
             </Upload>
         </FormItem>
@@ -74,7 +136,7 @@
     
 </Card>
 <Divider />
-<div>
+@*<div>
     <Row>
         <AntDesign.Col Span="8" Offset="18">
             <Space>
@@ -84,7 +146,7 @@
         </AntDesign.Col>
     </Row>
         
-</div>
+</div>*@
 
 
 

+ 35 - 55
wispro.sp.web/Components/CreateAppeal.razor.cs

@@ -4,6 +4,8 @@ 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;
@@ -16,46 +18,17 @@ namespace wispro.sp.web.Components
     {
 
         private CreateAppealModel _Model;
-        
+        private IFeedbackRef feedbackRef;
 
         [Inject]
         protected AppealTypeService _atService { get; set; }
 
-       
 
-        List<Staff> Reviewers = new List<Staff>()
-        {
-            new Staff(){Id =1,Name ="钟子敏"},
-            new Staff(){Id =2,Name ="邢丽霞"},
-            new Staff(){Id =3,Name ="李丽"},
-            new Staff(){Id =4,Name ="贾凤涛"},
-        };
+        [Inject] 
+        protected HttpClient _httpClient{get;set;}
 
         #region 文件上传控件设定
-        List<UploadFileItem> fileList = new List<UploadFileItem>
-            {
-                new UploadFileItem
-                {
-                    Id = "1",
-                    FileName = "客户往来邮件1.jpg",
-                    Url = "#",
-                    State = UploadState.Success
-                },
-                new UploadFileItem
-                {
-                    Id = "2",
-                    FileName = "与客户微信聊天图片.jpg",
-                    Url = "#",
-                    State = UploadState.Success
-                },
-                new UploadFileItem
-                {
-                    Id = "3",
-                    FileName = "附件.docx",
-                    Url = "#",
-                    State = UploadState.Success
-                }
-            };
+        //List<UploadFileItem> fileList = new List<UploadFileItem>();
 
         Dictionary<string, object> attrs = new Dictionary<string, object>
         {
@@ -66,47 +39,54 @@ namespace wispro.sp.web.Components
 
         void HandleChange(UploadInfo fileinfo)
         {
-            //if (fileList.Count > 5)
-            //{
-            //    fileList.RemoveRange(0, fileList.Count - 2);
-            //}
-            //fileList.Where(file => file.State == UploadState.Success && !string.IsNullOrWhiteSpace(file.Response)).ForEach(file => {
-            //    var result = file.GetResponse<ResponseModel>();
-            //    file.Url = result.url;
-            //});
+            try
+            {
+                _Model.FileList.Where(file => file.State == UploadState.Success && !string.IsNullOrWhiteSpace(file.Response)).ForEach(file =>
+                {
+                    var result = file.GetResponse<List<AttachFile>>();
+                    file.Url = $"http://localhost:39476/api/AttachFiles/Download?id={result[0].Id}";
+                });
+            }
+            catch { }
         }
 
-        public class ResponseModel
+        private async Task<bool> RemoveFile(UploadFileItem fileinfo)
         {
-            public string name { get; set; }
-
-            public string status { get; set; }
-
-            public string url { get; set; }
-
-            public string thumbUrl { get; set; }
+            try
+            {
+                var result = fileinfo.GetResponse<List<AttachFile>>();
+                return await _httpClient.GetFromJsonAsync<bool>($"http://localhost:39476/api/AttachFiles/Delete?id={result[0].Id}");
+            }
+            catch {
+                return false;
+            }
         }
+        
         #endregion
 
 
         protected override async void OnInitialized()
         {
             _Model = base.Options ?? new CreateAppealModel();
-            Console.WriteLine($"Success:{JsonSerializer.Serialize(_Model)}");
+            //Console.WriteLine($"Success:{JsonSerializer.Serialize(_Model)}");
             base.OnInitialized();
+            feedbackRef = base.FeedbackRef;
         }
 
+        string _ErrorMessage;
 
-
-        private void OnFinish()
+        private async void OnFinish()
         {
-            Console.WriteLine($"Success:{JsonSerializer.Serialize(_Model)}");
-            _ = base.FeedbackRef.CloseAsync();
+            await base.OnFeedbackOkAsync(new ModalClosingEventArgs() { Cancel = true });
+            
+            
         }
 
         private void OnCancel()
         {
-            _ = base.FeedbackRef.CloseAsync();
+
+            base.OnFeedbackCancelAsync(new ModalClosingEventArgs() { Cancel = true });
+            //_ = feedbackRef.CloseAsync();
         }
 
         //private void OnFinishFailed(EditContext editContext)

+ 16 - 0
wispro.sp.web/Components/StaffSelect.razor

@@ -0,0 +1,16 @@
+@inject IUserService _UserService;
+
+<Select DataSource="@_ShowStaffs"
+        DefaultValue="@StaffId"
+        LabelName="@nameof(wispro.sp.entity.Staff.Name)"
+        ValueName="@nameof(wispro.sp.entity.Staff.Id)"
+        Style="width: 200px"
+        Placeholder="请选择"
+        IgnoreItemChanges="false"
+        EnableSearch="true"
+        AllowClear
+        OnSelectedItemChanged="OnSelectedItemChangedHandler"
+        OnSearch="OnSearch">
+</Select>
+
+

+ 44 - 0
wispro.sp.web/Components/StaffSelect.razor.cs

@@ -0,0 +1,44 @@
+using Microsoft.AspNetCore.Components;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using wispro.sp.entity;
+
+
+namespace wispro.sp.web.Components
+{
+    public partial class StaffSelect
+    {
+        private List<Staff> _Staffs;
+        private Staff _SelectedItem;
+        private List<Staff> _ShowStaffs;
+
+        [Parameter]
+        public int? StaffId { get; set; }
+
+
+        [Parameter]
+        public EventCallback<int?> StaffIdChanged { get; set; }
+
+        protected override async System.Threading.Tasks.Task OnInitializedAsync()
+        {
+            base.OnInitialized();
+
+            _Staffs = await _UserService.GetAll();
+            _ShowStaffs = _Staffs;
+        }
+
+        private void OnSelectedItemChangedHandler(Staff value)
+        {
+            _SelectedItem = value;
+            StaffIdChanged.InvokeAsync(_SelectedItem.Id);
+        }
+
+        private void OnSearch(string value)
+        {
+            _ShowStaffs = _Staffs.Where<Staff>(p => p.Name.Contains(value)).ToList();
+            StateHasChanged();
+        }
+    }
+}

+ 0 - 24
wispro.sp.web/Components/UserGradeSelect.razor

@@ -11,28 +11,4 @@
         OnSelectedItemChanged="OnSelectedItemChangedHandler">
 </Select>
 
-@code {
-    private List<StaffGrade> _StaffGrades;
-    private StaffGrade _SelectedItem;
 
-    [Parameter]
-    public int? StaffGradeId{ get; set;}
-
-
-    [Parameter]
-    public EventCallback<int?> StaffGradeIdChanged { get; set; }
-
-    protected override async System.Threading.Tasks.Task OnInitializedAsync()
-    {
-        base.OnInitialized();
-
-        _StaffGrades =await _staffGradeService.GetAll();
-    }
-
-    private void OnSelectedItemChangedHandler(StaffGrade value)
-    {
-        _SelectedItem = value;
-        StaffGradeIdChanged.InvokeAsync(_SelectedItem.Id);
-    }
-
-}

+ 35 - 0
wispro.sp.web/Components/UserGradeSelect.razor.cs

@@ -0,0 +1,35 @@
+using Microsoft.AspNetCore.Components;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading.Tasks;
+using wispro.sp.entity;
+
+namespace wispro.sp.web.Components
+{
+    public partial  class UserGradeSelect
+    {
+        private List<StaffGrade> _StaffGrades;
+        private StaffGrade _SelectedItem;
+
+        [Parameter]
+        public int? StaffGradeId { get; set; }
+
+
+        [Parameter]
+        public EventCallback<int?> StaffGradeIdChanged { get; set; }
+
+        protected override async System.Threading.Tasks.Task OnInitializedAsync()
+        {
+            base.OnInitialized();
+
+            _StaffGrades = await _staffGradeService.GetAll();
+        }
+
+        private void OnSelectedItemChangedHandler(StaffGrade value)
+        {
+            _SelectedItem = value;
+            StaffGradeIdChanged.InvokeAsync(_SelectedItem.Id);
+        }
+    }
+}

+ 9 - 9
wispro.sp.web/Extensions/DateTimeExtension.cs

@@ -16,33 +16,33 @@ namespace wispro.sp.web {
         return "not yet";
       }
       if (delta < 1 * Minute) {
-        return ts.Seconds == 1 ? "1 second ago" : ts.Seconds + " seconds ago";
+        return ts.Seconds == 1 ? "1 秒前" : ts.Seconds + " 秒前";
       }
       if (delta < 2 * Minute) {
-        return "1 minute ago";
+        return "1 分钟前";
       }
       if (delta < 45 * Minute) {
-        return ts.Minutes + "minute";
+        return ts.Minutes + "分钟";
       }
       if (delta < 90 * Minute) {
-        return "1 hour ago";
+        return "1 小说前";
       }
       if (delta < 24 * Hour) {
-        return ts.Hours + " hours ago";
+        return ts.Hours + "小时前";
       }
       if (delta < 48 * Hour) {
-        return "yesterday";
+        return "昨天";
       }
       if (delta < 30 * Day) {
-        return ts.Days + " days ago";
+        return ts.Days + "天前";
       }
       if (delta < 12 * Month) {
         var months = Convert.ToInt32(Math.Floor((double)ts.Days / 30));
-        return months <= 1 ? "A month ago" : months + " months ago";
+        return months <= 1 ? "一月前" : months + "月前";
       }
       else {
         var years = Convert.ToInt32(Math.Floor((double)ts.Days / 365));
-        return years <= 1 ? "a year ago" : years + " years ago";
+        return years <= 1 ? "一年前" : years + "年前";
       }
     }
   }

+ 12 - 67
wispro.sp.web/Layouts/BasicLayout.razor

@@ -49,13 +49,13 @@
             Key = "index",
             Icon = "home",
         },
-        new MenuDataItem
-        {
-            Path = "/StartPerformanceCalculation",
-            Name = "开启绩效计算",
-            Key = "startCal",
-            Icon = "play-circle",
-        },
+        //new MenuDataItem
+        //{
+        //    Path = "/StartPerformanceCalculation",
+        //    Name = "开启绩效计算",
+        //    Key = "startCal",
+        //    Icon = "play-circle",
+        //},
         //new MenuDataItem
         //{
         //    Path = "/PerformanceList",
@@ -65,70 +65,15 @@
         //},
         new MenuDataItem
         {
-            Name="申请案处理界面",
+            Name="我的申请案",
             Key="appManager",
-            Icon ="setting",
-            Children= new MenuDataItem[]
-            {
-                new MenuDataItem
-                {
-                    Path="/MyCaselist",
-                    Name = "案件确认",
-                    Key = "app_confirm"
-                },
-                new MenuDataItem
-                {
-                    Path="/AppCase/ShensuReview/1",
-                    Name = "案件系数申诉审核",
-                    Key = "app_xishu_confirm"
-                },
-                new MenuDataItem
-                {
-                    Path="/AppCase/ShensuReview/2",
-                    Name = "处理事项系数申诉审核",
-                    Key = "app_doItemxishu_confirm"
-                },
-                new MenuDataItem
-                {
-                    Path="/AppCase/ShensuReview/3",
-                    Name = "处理人错误申诉审核",
-                    Key = "app_doperson_confirm"
-                },
-                new MenuDataItem
-                {
-                    Path="/AppCase/ShensuReview/4",
-                    Name = "审核人错误申诉审核",
-                    Key = "app_doperson_confirm4"
-                },
-                new MenuDataItem
-                {
-                    Path="/AppCase/ShensuReview/5",
-                    Name = "验证超期说明审核",
-                    Key = "app_doperson_confirm5"
-                },
-                new MenuDataItem
-                {
-                    Path="/AppCase/ShensuReview/6",
-                    Name = "案件分配比例申诉审核",
-                    Key = "app_doperson_confirm6"
-                },
-                new MenuDataItem
-                {
-                    Path="/AppCase/ShensuReview/7",
-                    Name = "案件缺漏提报审核",
-                    Key = "app_doperson_confirm7"
-                },
-                new MenuDataItem
-                {
-                    Path="/AppCase/ShensuReview/8",
-                    Name = "涉外新申请算法确认",
-                    Key = "app_doperson_confirm8"
-                }
-            }
+            Icon ="copy",
+            Path="/MyCaselist",
+
         },
         new MenuDataItem
         {
-            Name = "专案处理界面",
+            Name = "我的专案",
             Key = "staffManager",
             Icon = "setting",
             Children= new MenuDataItem[]

+ 71 - 15
wispro.sp.web/Models/CreateAppealModel.cs

@@ -1,5 +1,7 @@
-using Microsoft.AspNetCore.Components;
+using AntDesign;
+using Microsoft.AspNetCore.Components;
 using System;
+using System.Collections;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text.Json;
@@ -15,19 +17,21 @@ namespace wispro.sp.web.Models
 
         public AppealType AppealType { get; set; }
 
-        private List<InputField> inputFields;
+        public List<InputField> inputFields { get; set; }
         public List<InputFieldValue> inputFieldValues { get; set; }
 
         public AppealRecord AppealRecord { get; set; }
 
-        
-        public CreateAppealModel() { }
+        public List<UploadFileItem> FileList { get; set; }
 
+        //public System.Collections.Hashtable _GroupInputValues { get; set; }
+        //public List<InputFieldValue> noMultiValues { get; set; }
         
-        
+        public CreateAppealModel() { }
 
         public async Task Init(AppealTypeService _atService,PerformanceItem item,AppealType appealType)
         {
+            FileList = new List<UploadFileItem>();
             Item = item;
             AppealType = appealType;
             AppealRecord = new AppealRecord();
@@ -39,23 +43,75 @@ namespace wispro.sp.web.Models
             {
                 inputFieldValues = new List<InputFieldValue>();
 
-                Console.WriteLine($"CreateAppealModel:{JsonSerializer.Serialize(AppealType)}");
-                if(_atService == null)
-                {
-                    Console.WriteLine($"CreateAppealModel:_atService = null");
-                }
-
                 inputFields =await _atService.GetInputFields(AppealType.Id, 0);
 
                 foreach (var field in inputFields)
                 {
-                    var fValue = new InputFieldValue();
-                    fValue.InputField = field;
-                    fValue.InputFieldId = field.Id;
-                    inputFieldValues.Add(fValue);
+                    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
+                    {
+                        var fValue = new InputFieldValue();
+                        fValue.InputField = field;
+                        fValue.InputFieldId = field.Id;
+                        inputFieldValues.Add(fValue);
+                    }
                 }
             }
             
         }
+
+        
     }
 }

+ 9 - 62
wispro.sp.web/Pages/AppCase/MyCaselist.razor

@@ -90,11 +90,6 @@
                                 <AntDesign.Column Title="序号" TData="int" Width="50" Fixed="left">
                                     @serialNumber(_pageIndex, _pageSize, context.Id)
                                 </AntDesign.Column>
-                                <AntDesign.Column Title="绩效特殊字段" @bind-Field="@context.AgentFeedbackMemo" Width="250" Fixed="left">
-
-                                    
-
-                                </AntDesign.Column>
                                 <AntDesign.Column Title="基础点数" TData="string" Width="100">@(context.BasePoint == null ? "" : context.BasePoint)</AntDesign.Column>
                                 <AntDesign.Column Title="我方文号" @bind-Field="@context.CaseNo" Width="150" Sortable Filterable />
                                 <AntDesign.Column Title="案件类型" @bind-Field="@context.CaseType" Width="120" Sortable Filterable />
@@ -107,6 +102,7 @@
                                 <AntDesign.Column Title="处理事项" @bind-Field="@context.DoItem" Width="150" Sortable Filterable />
                                 <AntDesign.Column Title="处理事项系数" @bind-Field="@context.DoItemCoefficient" Width="150" Sortable Filterable />
                                 <AntDesign.Column Title="案件阶段" @bind-Field="@context.CaseStage" Width="100"></AntDesign.Column>
+                                <AntDesign.Column Title="绩效特殊字段" @bind-Field="@context.AgentFeedbackMemo" Width="250" />
                                 <AntDesign.Column Title="处理人" TData="string" DataIndex="@nameof(context.ItemStaffs)" Width="150">
                                     @if (context.ItemStaffs != null)
                                     {
@@ -124,15 +120,15 @@
                                             <AntDesign.Dropdown>
                                                 <Overlay>
                                                     <Menu>
-                                                        @foreach(var apType in  apTypeService.GetItems(context))
+                                                        @foreach (var apType in apTypeService.GetItems(context))
                                                         {
                                                             <MenuItem @key="@($"{context.Id}-{apType.Id}")" OnClick="()=>ShowModel(context,apType)">@apType.Name</MenuItem>
                                                         }
-                                                       
+
                                                     </Menu>
                                                 </Overlay>
                                                 <ChildContent>
-                                                    <Button Type="Primary">操作</Button>
+                                                    <Button Type="Primary">...</Button>
                                                 </ChildContent>
                                             </AntDesign.Dropdown>
                                         </SpaceItem>
@@ -194,18 +190,19 @@
                                 <AntDesign.Column Title="序号" TData="int" Width="50" Fixed="left">
                                     @serialNumber(_pageIndex, _pageSize, context.Id)
                                 </AntDesign.Column>
-                                <AntDesign.Column Title="绩效特殊字段" @bind-Field="@context.AgentFeedbackMemo"  Width="250" Fixed="left"/>
+
                                 <AntDesign.Column Title="基础点数" TData="string" Width="100">@(context.BasePoint == null ? "" : context.BasePoint)</AntDesign.Column>
                                 <AntDesign.Column Title="我方文号" @bind-Field="@context.CaseNo" Width="150" Sortable Filterable />
                                 <AntDesign.Column Title="案件类型" @bind-Field="@context.CaseType" Width="120" Sortable Filterable />
-                                <AntDesign.Column Title="案件系数" 
-                                                  @bind-Field="@context.CaseCoefficient"     Width="120" 
+                                <AntDesign.Column Title="案件系数"
+                                                  @bind-Field="@context.CaseCoefficient" Width="120"
                                                   Filters="CaseCoeFilters"
                                                   FilterMultiple="false"
                                                   OnFilter="((value,name)=>name.StartsWith(value))"
-                                                  Sortable  />
+                                                  Sortable />
                                 <AntDesign.Column Title="处理事项" @bind-Field="@context.DoItem" Width="150" Sortable Filterable />
                                 <AntDesign.Column Title="处理事项系数" @bind-Field="@context.DoItemCoefficient" Width="150" Sortable Filterable />
+                                <AntDesign.Column Title="绩效特殊字段" @bind-Field="@context.AgentFeedbackMemo" Width="250" />
                                 <AntDesign.Column Title="案件阶段" @bind-Field="@context.CaseStage" Width="100"></AntDesign.Column>
                                 <AntDesign.Column Title="处理人" TData="string" DataIndex="@nameof(context.ItemStaffs)" Width="150">
                                     @if (context.ItemStaffs != null)
@@ -253,54 +250,4 @@
     }
 </style>
 
-<Modal Title="涉外新申请算法备注" Visible="_ShowJXModal"
-       OnOk="@HandleOk1"
-       OnCancel="@HandleCancel1"
-       MaskClosable="false"
-       Width="600">
-    <Card Style="width:100%" Bordered>
-        <div>
-            <Row>
-                <AntDesign.Col Span="4"><b>我方文号:</b></AntDesign.Col>
-                <AntDesign.Col Span="8">@EditingItem.CaseNo</AntDesign.Col>
-                <AntDesign.Col Span="4"><b>处理事项:</b></AntDesign.Col>
-                <AntDesign.Col Span="8">@EditingItem.DoItem</AntDesign.Col>
-            </Row>
-            <Row><AntDesign.Col Span="24">&nbsp;</AntDesign.Col></Row>
-            <Row>
-                <AntDesign.Col Span="4"><b>案件名称:</b></AntDesign.Col>
-                <AntDesign.Col Span="20">@EditingItem.CaseName</AntDesign.Col>
-
-            </Row>
-        </div>
-    </Card>
-    <br />
-    <Form Model="_calType" LabelColSpan="6" WrapperColSpan="16">
-        
-        <FormItem Label="请谁确认">
-            <Select DataSource="@Reviewers"
-                    @bind-Value="@context.ReviewerId"
-                    LabelName="@nameof(Staff.Name)"
-                    ValueName="@nameof(Staff.Id)"
-                    Placeholder="请选择确认人"
-                    Style="width: 100%"
-                    AllowClear
-                    DefaultActiveFirstItem="false"
-                    EnableSearch>
-            </Select>
-        </FormItem>
-        <FormItem Label="绩效特殊字段备注">
-            <RadioGroup @bind-Value="@context.AgentMemo" Disabled="false">
-                <Radio Value="@("英-中")">英-中</Radio>
-                <Radio Value="@("英-德")">英-德</Radio>
-                <Radio Value="@("中-英")">中-英</Radio>
-            </RadioGroup>
-        </FormItem>
-        <FormItem Label="字数">
-            <AntDesign.InputNumber @bind-Value="context.wordCount" Min="1"></AntDesign.InputNumber>
-        </FormItem>
-    </Form>
-</Modal>
-
-
 

+ 24 - 88
wispro.sp.web/Pages/AppCase/MyCaselist.razor.cs

@@ -116,8 +116,6 @@ namespace wispro.sp.web.Pages.AppCase
                         return "";
                     }
                 }
-
-
                 else
                 {
                     return MyStatistics.Select(s => s.totalBasePoint.Value).Sum().ToString("0.00");
@@ -147,7 +145,6 @@ namespace wispro.sp.web.Pages.AppCase
 
         private async Task HandleTableChange(QueryModel<PerformanceItem> queryModel)
         {
-            Console.WriteLine(JsonSerializer.Serialize(queryModel));
 
             if (_CurrentKey == tabList[0].Key)
             {
@@ -188,74 +185,12 @@ namespace wispro.sp.web.Pages.AppCase
             _ShowJXModal = true;
         }
 
-        #region 申诉窗口事件
-        private void HandleOk(MouseEventArgs e)
-        {
-            Console.WriteLine(e);
-            _visible = false;
-        }
-
-        private void HandleCancel(MouseEventArgs e)
-        {
-            Console.WriteLine(e);
-            _visible = false;
-        }
-        #endregion
-
-        #region 绩效计算窗口事件
-        private async Task HandleOk1(MouseEventArgs e)
-        {
-            
-            _ShowJXModal = false;
-            
-            var respone = await  _ItemService.SaveFieldChange(EditingItem.Id, $"{strAgentFeedbackMemo}|{strWordCount}", $"{_calType.AgentMemo}|{_calType.wordCount}");
-
-            var HandlingCalMonth = await _CalMonthService.GetHandlingMonth();
-
-            MyStatistics = await _ItemService.CalMyStatistics(HandlingCalMonth.Year, HandlingCalMonth.Month, _userService.CurrentUser.Userid.Value);
-            EditingItem.AgentFeedbackMemo = _calType.AgentMemo;
-            StateHasChanged();
-
-
-        }
-
-        private void HandleCancel1(MouseEventArgs e)
-        {
-            Console.WriteLine(e);
-            _ShowJXModal = false;
-        }
-        #endregion
-
-        
-        public shensuType[] AvatarMenuItems { get; set; } = new shensuType[]
-        {
-            new() { ChangeField = "核稿人", Name = "核稿人申诉"},
-            new() { ChangeField = "处理人", Name =  "处理人申诉"},
-            new() { ChangeField = "案件系数", Name =  "案件系数申诉"},
-            new() { ChangeField = "处理事项系数", Name =  "处理事项系数申诉"},            
-            new() { Name =  "严重超期说明"}
-        };
-
         private shensuType _SelectedItem;
         private void OnSelectedItemChangedHandler(shensuType value)
         {
             _SelectedItem = value;
             //StaffGradeIdChanged.InvokeAsync(_SelectedItem.Id);
         }
-        
-        
-
-
-        CalType _calType = new CalType();
-        shenshou _shenshou = new shenshou();
-        List<Staff> Reviewers = new List<Staff>()
-        {
-            new Staff(){Id =1,Name ="钟子敏"},
-            new Staff(){Id =2,Name ="邢丽霞"},
-            new Staff(){Id =3,Name ="李丽"},
-            new Staff(){Id =4,Name ="贾凤涛"},
-        };
-
 
         #region 特殊绩效字段选择框变更时处理代码
         void SelectChanged(Reason  value)
@@ -265,18 +200,18 @@ namespace wispro.sp.web.Pages.AppCase
 
                 var respone = _ItemService.SaveFieldChange(EditingItem.Id, strAgentFeedbackMemo, EditingItem.AgentFeedbackMemo);
                 EditingItem = null;
-                RefreshMyStatistics();
+                _ = RefreshMyStatistics();
                 table.ReloadData();
             }
         }
 
         void ClearSelect(int itemId)
         {
-            Console.WriteLine($"ClearSelcet:{itemId}");
+            //Console.WriteLine($"ClearSelcet:{itemId}");
             var respone = _ItemService.SaveFieldChange(itemId, strAgentFeedbackMemo,"");
             EditingItem = null;
 
-            RefreshMyStatistics();
+            _ = RefreshMyStatistics();
             table.ReloadData();
         }
         #endregion
@@ -311,32 +246,22 @@ namespace wispro.sp.web.Pages.AppCase
         private ModalRef _modalRef;
         [Inject] ModalService _ModalService { get; set; }
         [Inject]protected AppealTypeService _atService { get; set; }
+
+        
         async Task ShowModel(PerformanceItem Item,AppealType appealType)
         {
             var templateOptions = new Models.CreateAppealModel();
-            Console.WriteLine($"Success:{JsonSerializer.Serialize(appealType)}");
             await templateOptions.Init(_atService,Item, appealType);
-            
+            Console.WriteLine(JsonSerializer.Serialize(templateOptions));
+
             var modalConfig = new ModalOptions();
             modalConfig.Title = appealType.Name;
-            modalConfig.Footer = null;
-            modalConfig.OnCancel = async (e) =>
-            {
-                Console.WriteLine("OnCancel");
-                await _modalRef.CloseAsync();
-            };
+            //modalConfig.Footer = null;
+            modalConfig.DestroyOnClose = true;
 
-            modalConfig.AfterClose = () =>
-            {
-                Console.WriteLine("AfterClose");
-                
-                InvokeAsync(StateHasChanged);
-                return Task.CompletedTask;
-            };
 
             _modalRef = await _ModalService
-                .CreateModalAsync<Components.CreateAppeal , Models.CreateAppealModel>
-                (modalConfig, templateOptions);
+                .CreateModalAsync<Components.CreateAppeal, Models.CreateAppealModel>(modalConfig, templateOptions);
 
             _modalRef.OnOpen = () =>
             {
@@ -344,10 +269,21 @@ namespace wispro.sp.web.Pages.AppCase
                 return Task.CompletedTask;
             };
 
-            _modalRef.OnOk = () =>
+            _modalRef.OnOk = async () =>
             {
-                Console.WriteLine("ModalRef OnOk");
-                return Task.CompletedTask;
+                Console.WriteLine(JsonSerializer.Serialize(templateOptions));
+                try
+                {
+                    await _atService.CreateAppeal(templateOptions);
+                    await _modalRef.CloseAsync();
+                    
+                }
+                catch (Exception ex)
+                {
+                    //_ErrorMessage = ex.Message;
+                }
+
+                //return Task.CompletedTask;
             };
 
             _modalRef.OnCancel = () =>

+ 21 - 20
wispro.sp.web/Pages/Welcome.razor

@@ -43,34 +43,36 @@
                 <Card BodyStyle="padding: 0px;"
                       Class="activeCard"
                       Title="信息动态">
-                    <AntList TItem="ActivitiesType"
-                             DataSource="@_activities"
+                    <AntList TItem="AppealRecord"
+                             DataSource="@AppealRecords"
                              Class="activitiesList"
                              Size="large"
                              ItemLayout="ListItemLayout.Horizontal">
                         <ListItem>
-                            <ListItemMeta Avatar="@context.User.Avatar" Description="@context.UpdatedAt.ToFriendlyDisplay()">
+                            <ListItemMeta Avatar="@context.Creater.Name" Description="@(context.ReviewTime.HasValue?context.ReviewTime.Value.ToFriendlyDisplay():context.CreateTime.ToFriendlyDisplay())">
                                 <TitleTemplate>
                                     <span>
-                                        <a class="username">@context.User.Name</a>
-                                        &nbsp;
                                         <span class="event">
-                                            @foreach (var str in Regex.Split(context.Template, @"@\{([^{}]*)\}"))
+                                            @if (context.ReviewTime.HasValue)
                                             {
-                                                if (str == "group")
+                                                if (context.CreaterId == _CurrentUser.Userid)
                                                 {
-    <a href="@context.Group.Link" key="@context.Group.Name">
-        @context.Group.Name
-    </a> }
-else if (str == "project")
-{
-<a href="@context.Project.Link" key="@context.Project.Name">
-    @context.Project.Name
-</a> }
-else
-{
-@str}
-}
+                                                    <span>(@context.Reviewer.Name 在 @context.ReviewTime.Value.ToFriendlyDisplay() 审核了你提交的 @context.Item.CaseNo @context.Type.Name")</span> }
+                                                else
+                                                {
+                                                    <span>(您在 @context.CreateTime.ToFriendlyDisplay()提交的@context.Item.CaseNo @context.Type.Name,@context.Reviewer.Name 已于 @context.ReviewTime.Value.ToFriendlyDisplay() 审核完成"</span> }
+                                            }
+                                            else
+                                            {
+                                                if (context.CreaterId == _CurrentUser.Userid)
+                                                {
+                                                    <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>
                                     </span>
                                 </TitleTemplate>
@@ -89,7 +91,6 @@ else
                     </div>
                 </Card>
 
-
             </AntDesign.Col>
         </Row>
     </ChildContent>

+ 25 - 3
wispro.sp.web/Pages/Welcome.razor.cs

@@ -3,6 +3,8 @@ using wispro.sp.web.Models;
 using wispro.sp.web.Services;
 using Microsoft.AspNetCore.Components;
 using wispro.sp.web.Components;
+using System.Collections.Generic;
+using wispro.sp.entity;
 
 namespace wispro.sp.web.Pages
 {
@@ -21,20 +23,40 @@ namespace wispro.sp.web.Pages
         private ActivitiesType[] _activities = { };
         private NoticeType[] _projectNotice = { };
         private CurrentUser _CurrentUser;
+        private List<AppealRecord> AppealRecords = new List<AppealRecord>();
 
         [Inject] public IProjectService ProjectService { get; set; }
         [Inject] public IUserService _userService { get; set; }
 
+        [Inject] protected AppealTypeService _atService { get; set; }
+
         protected override async System.Threading.Tasks.Task OnInitializedAsync()
         {
             await base.OnInitializedAsync();
             _CurrentUser = _userService.CurrentUser;
             _projectNotice = await ProjectService.GetProjectNoticeAsync();
-            _activities = await ProjectService.GetActivitiesAsync();
+            //_activities = await ProjectService.GetActivitiesAsync();
+            AppealRecords = await _atService.GetUserAppeals(_CurrentUser.Userid);
+
+            AppealRecords.Sort((a, b) =>
+            {
+                var sd = (a.ReviewTime == null) ? a.ReviewTime : a.CreateTime;
+                var ed = (b.ReviewTime == null) ? b.ReviewTime : b.CreateTime;
+
+                if (ed > sd)
+                {
+                    return 1;
+                }
+                else
+                {
+                    return -1;
+                }
+                
+            });
 
-            foreach(ActivitiesType at in _activities)
+            foreach (AppealRecord at in AppealRecords)
             {
-                System.Diagnostics.Debug.WriteLine(at.User.Name);
+                System.Diagnostics.Debug.WriteLine(at.Item.CaseNo);
             }
         }
     }

+ 36 - 4
wispro.sp.web/Services/AppealTypeService.cs

@@ -5,10 +5,12 @@ 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.share;
 using wispro.sp.web.Auth;
+using wispro.sp.web.Models;
 
 namespace wispro.sp.web.Services
 {
@@ -38,8 +40,6 @@ namespace wispro.sp.web.Services
 
         public List<AppealType> GetItems(PerformanceItem item)
         {
-            
-
             List<AppealType> retList = new List<AppealType>();
 
             foreach (var at in AppealTypes)
@@ -47,10 +47,10 @@ namespace wispro.sp.web.Services
                 if (!string.IsNullOrWhiteSpace(at.CanDoExpress))
                 {
                     var interpreter = new Interpreter();
-                    Console.WriteLine(at.CanDoExpress);
+                    //Console.WriteLine(at.CanDoExpress);
                     Func<PerformanceItem, bool> func = interpreter.ParseAsDelegate<Func<PerformanceItem, bool>>(at.CanDoExpress, "p");
                     bool result = func.Invoke(item);
-
+                    
                     if (result)
                     {
                         retList.Add(at);
@@ -65,6 +65,12 @@ namespace wispro.sp.web.Services
             return retList;
         }
 
+        public async Task<List<AppealRecord>> GetUserAppeals(int? userid)
+        {
+            var data = await _httpClient.GetFromJsonAsync<List<AppealRecord>>($"http://localhost:39476/api/Appeal/GetAppealRecords?userId={userid}");
+            return data;
+        }
+
         public async Task<AppealType> GetItem(int appealTypeId)
         {
             if (AppealTypes == null)
@@ -82,5 +88,31 @@ namespace wispro.sp.web.Services
             var data = await _httpClient.GetFromJsonAsync<List<InputField>>($"http://localhost:39476/api/Appeal/GetInputField?appealTypeId={appealTypeId}&state={State}");
             return data;
         }
+
+        public async Task CreateAppeal(CreateAppealModel model)
+        {
+            List<AttachFile> attachFiles = new List<AttachFile>();
+
+            foreach (var file in model.FileList)
+            {
+                AttachFile atfile = new AttachFile();
+                var result = file.GetResponse<List<AttachFile>>();
+                atfile.Id = result[0].Id;
+                attachFiles.Add(atfile);
+            }
+
+            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.attachFiles = attachFiles;
+            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));
+        }
     }
 }

+ 27 - 1
wispro.sp.web/Services/UserService.cs

@@ -7,24 +7,31 @@ using wispro.sp.web.Auth;
 using wispro.sp.web.Models;
 using wispro.sp.web.Utils;
 using System.Security.Claims;
+using System.Collections.Generic;
+using wispro.sp.entity;
+using System;
 
 namespace wispro.sp.web.Services
 {
     public interface IUserService
     {
         CurrentUser CurrentUser { get; set; }
+
+        Task<List<Staff>> GetAll();
     }
 
     public class UserService : IUserService
     {
         private readonly HttpClient _httpClient;
+        private readonly JwtAuthenticationStateProvider _jwt;
         private readonly ILocalStorageService _localStorageService;
         private CurrentUser _CurrentUser= new CurrentUser() { Name = "" };
 
-        public UserService(HttpClient httpClient, ILocalStorageService localStorageService)
+        public UserService(HttpClient httpClient, ILocalStorageService localStorageService, AuthenticationStateProvider jwt)
         {
             _httpClient = httpClient;
             _localStorageService = localStorageService;
+            _jwt = (JwtAuthenticationStateProvider)jwt;
         }
 
 
@@ -59,6 +66,25 @@ namespace wispro.sp.web.Services
             return _user;
         }
 
+        public async Task<List<Staff>> GetAll()
+        {
+            try
+            {
+                var _StaffGrade = await _httpClient.GetFromJsonAsync<List<Staff>>($"http://localhost:39476/api/Staff/GetAll");
+                return _StaffGrade;
+            }
+            catch (Exception ex)
+            {
+                if (ex.Message.Contains("Unauthorized"))
+                {
+                    _jwt.NotifyUserLogOut();
+                }
+
+                return null;
+
+            }
+        }
+
         
     }
 }

+ 120 - 0
wispro.sp.winClient/Class1.cs

@@ -0,0 +1,120 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http;
+using System.Net.Http.Json;
+using System.Text;
+using System.Threading.Tasks;
+using wispro.sp.entity;
+
+namespace wispro.sp.winClient
+{
+    public class CreateAppealModel
+    {
+        public PerformanceItem Item { get; set; }
+
+        public AppealType AppealType { get; set; }
+
+        public List<InputField> inputFields { get; set; }
+        public List<InputFieldValue> inputFieldValues { get; set; }
+
+        public AppealRecord AppealRecord { get; set; }
+
+        private async Task<List<InputField>> GetInputFields(int appealTypeId,int State)
+        {
+            HttpClient _httpClient = new HttpClient();
+            var data = await _httpClient.GetFromJsonAsync<List<InputField>>($"http://localhost:39476/api/Appeal/GetInputField?appealTypeId={appealTypeId}&state={State}");
+            return data;
+        }
+
+        //public System.Collections.Hashtable _GroupInputValues { get; set; }
+        //public List<InputFieldValue> noMultiValues { get; set; }
+
+        public CreateAppealModel() { }
+
+        public async Task Init(PerformanceItem item, AppealType appealType)
+        {
+            
+            Item = item;
+            AppealType = appealType;
+            AppealRecord = new AppealRecord();
+            AppealRecord.TypeId = appealType.Id;
+            AppealRecord.ItemId = item.Id;
+            AppealRecord.State = 0;
+
+            if (AppealType != null)
+            {
+                inputFieldValues = new List<InputFieldValue>();
+
+                inputFields = await GetInputFields(AppealType.Id, 0);
+
+                foreach (var field in inputFields)
+                {
+                    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
+                    {
+                        var fValue = new InputFieldValue();
+                        fValue.InputField = field;
+                        fValue.InputFieldId = field.Id;
+                        inputFieldValues.Add(fValue);
+                    }
+                }
+            }
+
+        }
+
+
+    }
+}

+ 6 - 0
wispro.sp.winClient/Form1.cs

@@ -171,6 +171,12 @@ namespace wispro.sp.winClient
 
         private async void button3_Click(object sender, EventArgs e)
         {
+            CreateAppealModel model = new CreateAppealModel();
+            HttpClient http = new HttpClient();
+            PerformanceItem item = await http.GetFromJsonAsync<wispro.sp.entity.PerformanceItem>($"http://localhost:39476/api/PerformanceItem/Get?Id=7341");
+            List<AppealType> appealTypes = await http.GetFromJsonAsync<List<AppealType>>($"http://localhost:39476/api/Appeal/GetAppealTypes");
+            var appealType = appealTypes.Where<AppealType>(a => a.Id == 1).FirstOrDefault();
+            await model.Init(item, appealType);
             //await TestQueryFilter();
             List<PerformanceItem> retList = new List<PerformanceItem>();
             var test= retList.Where<PerformanceItem>(p => p.isDanger());

+ 1 - 1
wospro.sp.entity/AppealRecord.cs

@@ -29,7 +29,7 @@ namespace wispro.sp.entity
 
         public virtual Staff Reviewer { get; set; }
 
-        public int ReviewerId { get; set; }
+        public int? ReviewerId { get; set; }
 
         public string ReviewerMemo { get; set; }
 

+ 7 - 0
wospro.sp.entity/InputField.cs

@@ -25,6 +25,11 @@ namespace wispro.sp.entity
         /// </summary>
         public string MapObjectField { get; set; }
 
+        /// <summary>
+        /// 映射绩效事件的Label值
+        /// MapObjectField属性对应的是列表属性时使用
+        /// </summary>
+        public string MapObjectFieldLabel { get; set; }
 
         public virtual AppealType AppealType { get; set; }
 
@@ -48,6 +53,8 @@ namespace wispro.sp.entity
         /// 可选择的值
         /// </summary>
         public virtual List<SelectValue> SelectValues { get; set; }
+
+        public int? MaxSize { get; set; }
     }
    
 }

+ 2 - 0
wospro.sp.entity/InputFieldValue.cs

@@ -12,6 +12,8 @@ namespace wispro.sp.entity
         public virtual InputField InputField { get; set; }
         public int InputFieldId { get; set; }
 
+        public string Label { get; set; }
+
         public string Value { get; set; }
 
         public int AppealRecordId { get; set; }