using AntDesign;
using AntDesign.ProLayout;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Web;
using System;
using System.Collections.Generic;
using System.Linq;
using wispro.sp.entity;
using wispro.sp.web.Models;

namespace wispro.sp.web.Pages.Project
{
    public partial class ConfirmProjectPoint
    {
        [Inject] public MessageService _message { get; set; }

        static ProjectInfo EditingItem = new ProjectInfo()
        {
            CaseNo = "S2112394",
            CaseName = "美的-洗碗机专利调查",
            DoItem = "提出报告",
            DoPerson = new List<string>() { "李申", "何倚雯", "王晴", "陆跃" },
            ResponseMan = "黄瑜"
        };

        Task task = new()
        {
            ProjectInfo = EditingItem,
            Id = 1,
            Name = "2021年9月专案【S2112394】点数确认",
            Type = "专案点数确认",
            ResponseMan = "李申",
            State = "待处理",
            LimiteDate = DateTime.Now.AddDays(4),
            UIUrl = "/Project/ConfirmProjectPoint"
        };

        List<ProjectPoint> projectPoints = new List<ProjectPoint>() {
            new ProjectPoint(){ doItem="检索条件策略", DoItemCoefficient="B", person="李申", Point=1.0},
            new ProjectPoint(){ doItem="检索条件策略", DoItemCoefficient="B", person="何倚雯", Point=2.0},
            new ProjectPoint(){ doItem="检索条件策略", DoItemCoefficient="B", person="王晴", Point=1.5},
            new ProjectPoint(){ doItem="检索条件策略", DoItemCoefficient="B", person="陆跃", Point=1.0},
            new ProjectPoint(){ doItem="专利分类", DoItemCoefficient="A", person="李申", Point=2.0},
            new ProjectPoint(){ doItem="专利分类", DoItemCoefficient="A", person="何倚雯", Point=1.5},
            new ProjectPoint(){ doItem="专利分类", DoItemCoefficient="A", person="王晴", Point=2.5},
            new ProjectPoint(){ doItem="专利分类", DoItemCoefficient="A", person="陆跃", Point=3.0},
        };

        #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
                }
            };

        Dictionary<string, object> attrs = new Dictionary<string, object>
        {
            {"Action", "#" },
            {"Name", "files" },
            {"Multiple", true }
        };

        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;
            //});
        }

        public class ResponseModel
        {
            public string name { get; set; }

            public string status { get; set; }

            public string url { get; set; }

            public string thumbUrl { get; set; }
        }
        #endregion

        private bool _visible = false;
        #region 申诉窗口事件
        private void HandleOk(MouseEventArgs e)
        {
            Console.WriteLine(e);
            _visible = false;
        }

        private void HandleCancel(MouseEventArgs e)
        {
            Console.WriteLine(e);
            _visible = false;
        }
        #endregion

        class shenshou
        {
            public string Type { get; set; }

            public int ReviewerId { get; set; }
            public string Reason { get; set; }

            public List<UploadFileItem> Files { get; set; }
        }

        private shenshou _shenshou = new shenshou()
        {
            Type = "专案点数分配申诉",
            
        };

        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 ="贾凤涛"},
        };

        public AvatarMenuItem[] AvatarMenuItems { get; set; } = new AvatarMenuItem[]
        {
            new() { Key = "reviewer", IconType = "user", Option = "专案点数分配申诉"},
        };

        void OnShensu()
        {
            //添加保存代码
            _visible = true;
        }

        void OnOK()
        {
            _message.Info("完成确认!");
        }
    }
}
