Browse Source

实现审核人获取模块

luocaiyang 3 years ago
parent
commit
24142fcef3

+ 134 - 2
wispro.sp.api/Controllers/StaffController.cs

@@ -7,6 +7,8 @@ using wispro.sp.share;
 using System.Linq;
 using Microsoft.AspNetCore.Authentication.JwtBearer;
 using Microsoft.AspNetCore.Authorization;
+using wispro.sp.entity.workflowDefine;
+using Microsoft.EntityFrameworkCore;
 
 namespace wispro.sp.api.Controllers
 {
@@ -28,8 +30,138 @@ namespace wispro.sp.api.Controllers
         {
             return Context.Staffs.ToList<Staff>();
         }
-        
-        
+
+        private List<Staff> GetStaffList(dynamic dynamic,UserField userField)
+        {
+            try
+            {
+                Staff temUser = null;
+
+                switch (userField.UserConditionType)
+                {
+                    case UserConditionType.Staff:
+
+                        //UserField user = new UserField();
+                        //user.UserConditionType = UserConditionType.UserDepartmentPosition;
+                        //user.Department = "120";
+                        //user.Positon = "6";
+
+                        //System.Diagnostics.Debug.WriteLine(System.Text.Json.JsonSerializer.Serialize(user));
+                        
+
+                        switch (userField.UserType)
+                        {
+                            case UserType.BindObjectProperty:
+                                
+                                if (dynamic == null)
+                                {
+                                    return null;
+                                }
+                                else
+                                {
+                                    var retObj = share.Utility.ObjectHelper.GetPropertyValue(userField.UserValue, dynamic);
+
+                                    if (retObj is Staff)
+                                    {
+                                        return new List<Staff>() { (Staff)retObj };
+                                    }
+                                    else
+                                    {
+                                        if (retObj is List<Staff>)
+                                        {
+                                            return (List<Staff>)retObj;
+                                        }
+                                    }
+                                }
+                                break;
+                            case UserType.DoActionUser:
+                                break;
+                            case UserType.LoginUser:
+                                temUser = Context.Staffs.FirstOrDefault(s => s.Name == User.Identity.Name);
+                                return new List<Staff>() { temUser };
+                                break;
+                            case UserType.Staff:
+                                temUser = Context.Staffs.FirstOrDefault(s => s.Id == int.Parse(userField.UserValue.ToString()));
+                                if (temUser != null)
+                                {
+                                    return new List<Staff>() { temUser };
+                                }
+                                break;
+                        }
+
+                        break;
+                    case UserConditionType.Department:
+                        var retList = Context.DepartmentPositions.Where(d => d.departmentId == int.Parse(userField.Department)).Select(p => p.Staff).ToList();
+                        return retList;
+                        break;
+                    case UserConditionType.UserDepartment:
+
+                        break;
+                    case UserConditionType.UserDepartmentPosition:
+                        break;
+                    case UserConditionType.DepartmentPosition:
+                        var retList1 = Context.DepartmentPositions.Where(d => 
+                            d.departmentId == int.Parse(userField.Department) &&
+                            d.PositionId  == int.Parse(userField.Positon)
+                            )
+                            .Select(p => p.Staff).ToList();
+                        return retList1;
+                        break;
+
+                }
+
+                return new List<Staff>();
+            }
+            catch(Exception ex)
+            {
+                throw ex;
+            }
+        }
+
+        public List<Staff> GetReviewers(int itemId, int appealTypeId)
+        {
+
+            try
+            {
+                var item = Context.PerformanceItems
+                    .Include(p=>p.Reviewer)
+                    .Include(p=>p.ItemStaffs).ThenInclude(p=>p.DoPerson)
+                    .Include(p=>p.PreOastaff)
+                    .Include(p=>p.Customer)
+                    .FirstOrDefault(p => p.Id == itemId);
+
+                var apType = Context.AppealTypes.FirstOrDefault(p => p.Id == appealTypeId);
+
+                UserField user = new UserField();
+
+                if (String.IsNullOrEmpty(apType.ReviewerExpress))
+                {
+                    return Context.Staffs.ToList();
+                }
+                else
+                {
+                    UserField userField = new UserField();
+                    if (apType.ReviewerExpress.StartsWith("p."))
+                    {
+                        userField.UserConditionType = UserConditionType.Staff;
+                        userField.UserType = UserType.BindObjectProperty;
+                        userField.UserValue = apType.ReviewerExpress.Replace("p.", "").Trim();
+                    }
+                    else
+                    {
+                        userField = System.Text.Json.JsonSerializer.Deserialize<UserField>(apType.ReviewerExpress);
+                    }
+
+                    return GetStaffList(item, userField);
+                }
+            }
+            catch (Exception ex)
+            {
+                throw ex;
+            }
+        }
+
+
         public ListApiResponse<Staff> Query(int pageIndex,int pageSize)
         {
             ListApiResponse<Staff> ret = new ListApiResponse<Staff>();

+ 5 - 3
wispro.sp.web/Components/CreateAppeal.razor

@@ -23,10 +23,12 @@
 
 <Card>
     <Form Model="@_Model" LabelColSpan="6" WrapperColSpan="16" Size="@AntSizeLDSType.Small">
-        <FormItem Label="请谁确认">
-            <StaffSelect @bind-StaffId="@context.AppealRecord.ReviewerId" />
-        </FormItem>
 
+        @if (_Model.AppealType.NeedReview) {
+            <FormItem Label="请谁确认">
+                <StaffSelect @bind-StaffId="@context.AppealRecord.ReviewerId" StaffLists="_Staffs" />
+            </FormItem>
+        }
 
         @foreach (InputField field in context.inputFields)
         {

+ 25 - 6
wispro.sp.web/Components/CreateAppeal.razor.cs

@@ -1,6 +1,7 @@
 using AntDesign;
 using Microsoft.AspNetCore.Components;
 using Microsoft.AspNetCore.Components.Forms;
+using Microsoft.Extensions.Configuration;
 using System;
 using System.Collections.Generic;
 using System.Linq;
@@ -19,23 +20,24 @@ namespace wispro.sp.web.Components
 
         private CreateAppealModel _Model;
         private IFeedbackRef feedbackRef;
+        private List<Staff> _Staffs;
 
         [Inject]
         protected AppealTypeService _atService { get; set; }
 
+       
+        [Inject] IUserService _UserService { get; set; }
 
         [Inject] 
         protected IHttpService _httpClient{get;set;}
 
+        [Inject]
+        protected IConfiguration _configuration { get; set; }
+
         #region 文件上传控件设定
         //List<UploadFileItem> fileList = new List<UploadFileItem>();
 
-        Dictionary<string, object> attrs = new Dictionary<string, object>
-        {
-            {"Action", "http://localhost:39476/api/AttachFiles/PostFile" },
-            {"Name", "files" },
-            {"Multiple", false }
-        };
+        Dictionary<string, object> attrs ;
 
         void HandleChange(UploadInfo fileinfo)
         {
@@ -67,9 +69,26 @@ namespace wispro.sp.web.Components
 
         protected override async void OnInitialized()
         {
+            attrs = new Dictionary<string, object>
+            {
+                {"Action", $"{_configuration.GetValue<string>("APIUrl")}AttachFiles/PostFile" },
+                {"Name", "files" },
+                {"Multiple", false }
+            };
+
             _Model = base.Options ?? new CreateAppealModel();
+
+            //if(!string.IsNullOrEmpty(_Model.AppealType.ReviewerExpress))
+            //{
+                _Staffs =await _UserService.GetReviewers(_Model.AppealRecord.ItemId, _Model.AppealType.Id);
+            //}
+            //else
+            //{
+            //    _Staffs =await _UserService.GetAll();
+            //}
             base.OnInitialized();
             feedbackRef = base.FeedbackRef;
+            StateHasChanged();
         }
 
         string _ErrorMessage;

+ 2 - 1
wispro.sp.web/Components/StaffSelect.razor

@@ -9,7 +9,8 @@
         EnableSearch="true"
         AllowClear
         OnSelectedItemChanged="OnSelectedItemChangedHandler"
-        OnSearch="OnSearch">
+        OnSearch="OnSearch"
+        DefaultActiveFirstOption>
 </Select>
 
 

+ 11 - 6
wispro.sp.web/Components/StaffSelect.razor.cs

@@ -10,26 +10,31 @@ 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; }
 
+        [Parameter]
+        public List<Staff> StaffLists { get; set; }
+
         [Inject] IUserService _UserService { get; set; }
 
 
-        protected override async System.Threading.Tasks.Task OnInitializedAsync()
+        protected override void OnInitialized()
         {
+            _ShowStaffs = StaffLists;
             base.OnInitialized();
+        }
 
-            _Staffs = await _UserService.GetAll();
-            _ShowStaffs = _Staffs;
+        protected override Task OnParametersSetAsync()
+        {
+            _ShowStaffs = StaffLists;
+            return base.OnParametersSetAsync();
         }
 
         private void OnSelectedItemChangedHandler(Staff value)
@@ -40,7 +45,7 @@ namespace wispro.sp.web.Components
 
         private void OnSearch(string value)
         {
-            _ShowStaffs = _Staffs.Where<Staff>(p => p.Name.Contains(value)).ToList();
+            _ShowStaffs = _ShowStaffs.Where<Staff>(p => p.Name.Contains(value)).ToList();
             StateHasChanged();
         }
     }

+ 14 - 14
wispro.sp.web/Layouts/BasicLayout.razor

@@ -53,11 +53,11 @@
         {
             Name="我的绩效",
             Key="appManager",
-            Icon ="copy",
             Path="/MyCaselist",
+            Icon ="line-chart"
 
         },
-        
+
         new MenuDataItem
         {
             Name = "基本资料管理",
@@ -65,33 +65,33 @@
             Icon = "setting",
             Children= new MenuDataItem[]
             {
-                new MenuDataItem
-                {
-                    Path ="/StaffList",
-                    Name ="账号管理",
-                    Key= "staff",
-                    Icon = ""
-                },
+                //new MenuDataItem
+                //{
+                //    Path ="/StaffList",
+                //    Name ="账号管理",
+                //    Key= "staff",
+                //    Icon = ""
+                //},
                 new MenuDataItem
                 {
                     Path ="/Department",
                     Name ="部门管理",
                     Key= "dept",
-                    Icon = ""
+                    Icon = "team"
                 },
                 new MenuDataItem
                 {
                     Path ="/StaffGrade",
                     Name ="代理人系数设定",
                     Key= "sg",
-                    Icon = ""
+                    Icon = "ci"
                 },
                 new MenuDataItem
                 {
                     Path ="/CustomerList",
                     Name ="客户信息管理",
                     Key="customer",
-                    Icon = ""
+                    Icon = "solution"
                 }
 
             }
@@ -106,8 +106,8 @@
 
     };
 
-        public LinkItem[] Links { get; set; } =
-        {
+    public LinkItem[] Links { get; set; } =
+    {
         new LinkItem
         {
             Key = "威世博官网",

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

@@ -152,26 +152,30 @@
                                 <Space>
                                     <SpaceItem>
                                         @{
-                                            var menuItems = apTypeService.GetItems(context);
-                                            if (menuItems.Count > 0)
-                                            {
-                                                <AntDesign.Dropdown>
-                                                    <Overlay>
-                                                        <Menu>
-                                                            @foreach (var apType in menuItems)
+                                            <AntDesign.Dropdown>
+                                                <Overlay>
+                                                    <Menu>
+                                                        @{
+                                                            if (context.AgentFeedbackMemo != "已算绩效")
                                                             {
-                                                                <MenuItem @key="@($"{context.Id}-{apType.Id}")" OnClick="()=>ShowModel(context,apType)">@apType.Name</MenuItem>
+                                                                <MenuItem OnClick="() => menuYSJXClick(context)">已算绩效</MenuItem>
                                                             }
-
-                                                        </Menu>
-                                                    </Overlay>
-                                                    <ChildContent>
-                                                        <Button Type="Primary" Icon="down" Style="background: #f6ffed;"></Button>
-                                                    </ChildContent>
-                                                </AntDesign.Dropdown>
-                                            }
+                                                            var menuItems = apTypeService.GetItems(context);
+                                                            if (menuItems.Count > 0)
+                                                            {
+                                                                @foreach (var apType in menuItems)
+                                                                {
+                                                                    <MenuItem @key="@($"{context.Id}-{apType.Id}")" OnClick="()=>ShowModel(context,apType)">@apType.Name</MenuItem>
+                                                                }
+                                                            }
+                                                        }
+                                                    </Menu>
+                                                </Overlay>
+                                                <ChildContent>
+                                                    <Button Type="Primary" Icon="down" Style="background: #f6ffed;"></Button>
+                                                </ChildContent>
+                                            </AntDesign.Dropdown>
                                         }
-
                                     </SpaceItem>
                                 </Space>
 
@@ -183,7 +187,8 @@
                                     <Body>
                                         <Descriptions Bordered Size="@DescriptionsSize.Small">
                                             <DescriptionsItem Title="绩效特殊字段" Span="3">
-                                                <Select DataSource="@_afService.GetItems(context.Data)"
+                                                @context.Data.AgentFeedbackMemo
+                                                @*<Select DataSource="@_afService.GetItems(context.Data)"
                                                         @bind-Value="@context.Data.AgentFeedbackMemo"
                                                         LabelName="@nameof(Reason.Name)"
                                                         ValueName="@nameof(Reason.Value)"
@@ -195,7 +200,7 @@
                                                         OnSelectedItemChanged="SelectChanged"
                                                         OnClearSelected="() => ClearSelect(context.Data.Id)"
                                                         OnFocus="() => OnFocus(context.Data)">
-                                                </Select>
+                                                </Select>*@
                                             </DescriptionsItem>
                                             <DescriptionsItem Title="完成时间">@(context.Data.FinishedDate.HasValue ? context.Data.FinishedDate.Value.ToString("yyyy-MM-dd") : "")</DescriptionsItem>
                                             <DescriptionsItem Title="返稿日">@(context.Data.ReturnDate.HasValue ? context.Data.ReturnDate.Value.ToString("yyyy-MM-dd") : "")</DescriptionsItem>

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

@@ -243,6 +243,14 @@ namespace wispro.sp.web.Pages.AppCase
             _ShowJXModal = true;
         }
 
+        private async void menuYSJXClick(PerformanceItem Item)
+        {
+            var respone = await _ItemService.SaveFieldChange(Item.Id, strAgentFeedbackMemo, "已算绩效");
+            var item = await _ItemService.GetPerformancItem(Item.Id);
+            Item.BasePoint = item.BasePoint;
+            _ = RefreshMyStatistics();
+        }
+
         private shensuType _SelectedItem;
         private void OnSelectedItemChangedHandler(shensuType value)
         {
@@ -255,7 +263,6 @@ namespace wispro.sp.web.Pages.AppCase
         {
             if (!_loading && EditingItem != null)
             {
-
                 var respone =await _ItemService.SaveFieldChange(EditingItem.Id, strAgentFeedbackMemo, EditingItem.AgentFeedbackMemo);
                 var item = await _ItemService.GetPerformancItem(EditingItem.Id) ;
                 EditingItem.BasePoint = item.BasePoint;
@@ -318,6 +325,7 @@ namespace wispro.sp.web.Pages.AppCase
             modalConfig.Width = 650;
             //modalConfig.Footer = null;
             modalConfig.DestroyOnClose = true;
+            modalConfig.MaskClosable = false;
 
 
             _modalRef = await _ModalService

+ 1 - 1
wispro.sp.web/Pages/Welcome.razor.cs

@@ -91,7 +91,7 @@ namespace wispro.sp.web.Pages
             modalConfig.Width = 650;
             //modalConfig.Footer = null;
             modalConfig.DestroyOnClose = true;
-
+            modalConfig.MaskClosable = false;
 
             _modalRef = await _ModalService
                 .CreateModalAsync<ReviewerAppeal, Models.ReviewerAppealModel>(modalConfig, templateOptions);

+ 19 - 15
wispro.sp.web/Services/UserService.cs

@@ -22,6 +22,7 @@ namespace wispro.sp.web.Services
         Task<List<Staff>> GetAll();
 
         Task<CurrentUser> GetUser();
+        Task<List<Staff>> GetReviewers(int? itemId, int appealTypeId);
     }
 
     public class UserService : IUserService
@@ -38,20 +39,6 @@ namespace wispro.sp.web.Services
             _jwt = (JwtAuthenticationStateProvider)jwt;
         }
 
-
-        //public CurrentUser CurrentUser
-        //{
-        //    get
-        //    {
-        //        return _CurrentUser;
-        //    }
-        //    set
-        //    {
-        //        _CurrentUser = value;
-        //    }
-            
-        //}
-
         public async Task<CurrentUser> GetUser()
         {
             CurrentUser _user = new CurrentUser();
@@ -98,6 +85,23 @@ namespace wispro.sp.web.Services
             }
         }
 
-        
+        public async Task<List<Staff>> GetReviewers(int? itemId, int appealTypeId)
+        {
+            try
+            {
+                var _StaffGrade = await _httpClient.Get<List<Staff>>($"Staff/GetReviewers?ItemId={itemId}&appealTypeId={appealTypeId}");
+                return _StaffGrade;
+            }
+            catch (Exception ex)
+            {
+                if (ex.Message.Contains("Unauthorized"))
+                {
+                    _jwt.NotifyUserLogOut();
+                }
+
+                return null;
+
+            }
+        }
     }
 }

+ 1 - 1
wispro.sp.web/wwwroot/index.html

@@ -225,7 +225,7 @@
     <script src="_content/AntDesign/js/ant-design-blazor.js"></script>
     <script src="_content/AntDesign.Charts/ant-design-charts-blazor.js"></script>
     <script src="_framework/blazor.webassembly.js"></script>
-    <script src="script/helper.js"></script>
+    <!--<script src="script/helper.js"></script>-->
 </body>
 
 </html>

+ 0 - 26
wispro.sp.web/wwwroot/scripts/Helper.js

@@ -1,26 +0,0 @@
-"use strict";
-function clickElement(element) {
-    element.click();
-}
-function downloadFromUrl(options) {
-    var _a;
-    var anchorElement = document.createElement('a');
-    anchorElement.href = options.url;
-    anchorElement.download = (_a = options.fileName) !== null && _a !== void 0 ? _a : '';
-    anchorElement.click();
-    anchorElement.remove();
-}
-function downloadFromByteArray(options) {
-    var url = typeof (options.byteArray) === 'string' ?
-        // .NET 5 or earlier, the byte array in .NET is encoded to base64 string when it passes to JavaScript.
-        // In that case, that base64 encoded string can be pass to the browser as a "data URL" directly.
-        "data:" + options.contentType + ";base64," + options.byteArray :
-        // .NET 6 or later, the byte array in .NET is passed to JavaScript as an UInt8Array efficiently.
-        // - https://docs.microsoft.com/en-us/dotnet/core/compatibility/aspnet-core/6.0/byte-array-interop
-        // In that case, the UInt8Array can be converted to an object URL and passed to the browser.
-        // But don't forget to revoke the object URL when it is no longer needed.
-        URL.createObjectURL(new Blob([options.byteArray], { type: options.contentType }));
-    downloadFromUrl({ url: url, fileName: options.fileName });
-    if (typeof (options.byteArray) !== 'string')
-        URL.revokeObjectURL(url);
-}