using Hotline.Share.Enums.Quality;
using Hotline.Share.Requests;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XF.Utility.EnumExtensions;

namespace Hotline.Share.Dtos.Quality
{
	public class TemplateAddDto
	{
		/// 模版名称
		/// </summary>
		public string Name { get; set; }

		/// <summary>
		/// 模版分类名称
		/// </summary>
		public ETemplateGrouping Grouping { get; set; }

		/// <summary>
		/// 模版说明
		/// </summary>
		public string? Content { get; set; }

		/// <summary>
		/// 启禁用
		/// </summary>
		public int IsEnable { get; set; }

		/// <summary>
		/// 模版明细
		/// </summary>
		public List<TemplateDetailAddDto> TemplateDetails { get; set; }
	}
	public class TemplateDeleteDto
	{
		public string Id { get; set; }
	}
	public class TemplateBatchDeleteDto
	{
		public List<string> Ids { get; set; }
	}
	public class TemplateUpdateDto : TemplateAddDto
	{
		public string Id { get; set; }
	}
	public record TemplateListDto : PagedKeywordRequest
	{
		/// <summary>
		/// 模版名称
		/// </summary>
		public string? Name { get; set; }
		/// <summary>
		/// 质检项目分组
		/// </summary>
		public ETemplateGrouping? Grouping { get; set; }

		/// <summary>
		/// 启禁用
		/// </summary>
		public int? IsEnable { get; set; }

        /// <summary>
        /// 创建人
        /// </summary>
        public string? CreatorName { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime? CreationTimeStart { get; set; }
        public DateTime? CreationTimeEnd { get; set; }

        /// <summary>
        /// 更新人
        /// </summary>
        public string? LastModificationName { get; set; }

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime? LastModificationTimeStart { get; set; }
        public DateTime? LastModificationTimeEnd { get; set; }
    }
	public class TemplateBaseDto
	{
		public DateTime? LastModificationTime { get; set; }

		public bool IsDeleted { get; set; }

		/// <summary>
		/// 删除时间
		/// </summary>
		public DateTime? DeletionTime { get; set; }


		/// <summary>
		/// 创建时间
		/// </summary>
		public DateTime CreationTime { get; set; }

		public string Id { get; set; }

		/// <summary>
		/// 组织Id
		/// </summary>
		public string? CreatorOrgId { get; set; }


		public string? CreatorOrgName { get; set; }

		/// <summary>
		/// 创建人
		/// </summary>
		public string? CreatorId { get; set; }

		public string? CreatorName { get; set; }
	}

	public class QualityTemplateDto : TemplateBaseDto
	{
		/// 模版名称
		/// </summary>
		public string Name { get; set; }

		/// <summary>
		/// 模版分类名称
		/// </summary>
		public ETemplateGrouping Grouping { get; set; }

		/// <summary>
		/// 模版说明
		/// </summary>
		public string? Content { get; set; }

		/// <summary>
		/// 启禁用
		/// </summary>
		public int IsEnable { get; set; }

		/// <summary>
		/// 模版明细
		/// </summary>
		public List<TemplateDetailDto> templateDetails { get; set; }

		public string GroupingText => Grouping.GetDescription();

		/// <summary>
		/// 最近更新人
		/// </summary>
		public string? LastModificationName { get; set; }

	}

	public class TemplateDetailAddDto
	{
		/// <summary>
		/// 质检模版ID
		/// </summary>
		public string TemplateId { get; set; }

		/// <summary>
		/// 质检项ID
		/// </summary>
		public string ItemId { get; set; }

	}
	public class TemplateDetailDto : TemplateBaseDto
	{
		/// <summary>
		/// 质检模版ID
		/// </summary>
		public string TemplateId { get; set; }

		/// <summary>
		/// 质检项ID
		/// </summary>
		public string ItemId { get; set; }

		/// <summary>
		/// 质检项目名称
		/// </summary>
		public string Name => QualityItem.Name;

		/// <summary>
		/// 分值
		/// </summary>
		public int Grade => QualityItem.Grade;

		/// <summary>
		/// 是否智能质检项目
		/// </summary>
		public int IsIntelligent => QualityItem.IsIntelligent;


		public QualityItemDto QualityItem { get; set; } = new QualityItemDto();

		/// <summary>
		/// 
		/// </summary>
		public QualityTemplateDto QualityTemplate { get; set; }
	}
}
