using Hotline.Share.Dtos.File;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Hotline.Share.Requests;
using System.ComponentModel;
using XF.Utility.EnumExtensions;

namespace Hotline.Share.Dtos.Order
{
	public class OrderTerminateDto
	{

		/// <summary>
		/// 终止Id
		/// </summary>
		public string Id { get; set; }

		/// <summary>
		/// 工单id
		/// </summary>
		public string OrderId { get; set; }

		/// <summary>
		/// 流程id
		/// </summary>
		public string? WorkflowId { get; set; }


		/// <summary>
		/// 终止状态
		/// </summary>
		public ETerminateStatus? Status { get; set; }

		/// <summary>
		/// 工单编号
		/// </summary>
		public string No { get; set; }

		/// <summary>
		/// 终止理由
		/// </summary>
		public string? Content { get; set; }

		/// <summary>
		/// 附件
		/// </summary>
		public List<FileJson>? FileJson { get; set; }

		/// <summary>
		/// 附件列表
		/// </summary>
		public List<FileDto> Files { get; set; } = new();
	}

	public class OrderTerminateBaseDto
	{
		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 string? WorkflowId { get; set; }
	}

	public class OrderTerminateEntityDto : OrderTerminateBaseDto 
	{
		/// <summary>
		/// 工单
		/// </summary>
		public OrderDto Order { get; set; }

		/// <summary>
		/// 是否可办理
		/// </summary>
		public bool IsCanHandle { get; set; }

		/// <summary>
		/// 审批状态 
		/// </summary>
		public ETerminateStatus? Status { get; set; }


		public string StatusText => Status.GetDescription();

		/// <summary>
		/// 终止理由
		/// </summary>
		public string? Content { get; set; }


		/// <summary>
		/// 办理 true  审批 false 
		/// </summary>
		public bool Handle { get; set; }

		/// <summary>
		/// 附件列表
		/// </summary>
		public List<FileDto> Files { get; set; } = new();

		public List<FileJson>? FileJson { get; set; }
	}

	public record OrderTerminateListDto : PagedRequest
	{
		/// <summary>
		/// 工单编号
		/// </summary>
		public string? No { get; set; }

		/// <summary>
		/// 工单标题
		/// </summary>
		public string? Title { get; set; }

		/// <summary>
		/// 审批状态 
		/// </summary>
		public ETerminateStatus? Status { get; set; }

		/// <summary>
		/// 申请开始时间
		/// </summary>
		public DateTime? ApplyStartTime { get; set; }

		/// <summary>
		/// 申请结束时间
		/// </summary>
		public DateTime? ApplyEndTime { get; set; }

		/// <summary>
		/// 工单受理开始时间
		/// </summary>
		public DateTime? StartTime { get; set; }

		/// <summary>
		/// 工单受理结束时间
		/// </summary>
		public DateTime? EndTime { get; set; }

		/// <summary>
		/// 查询类型  0 全部 1自己
		/// </summary>
		public int?  QueryType { get; set; }

		/// <summary>
		/// 审批状态  0 全部  1待审批 2 已审批
		/// </summary>
		public int? AuditStatus { get; set; }
	}

	public class OrderTerminateContentDto
	{
		/// <summary>
		/// 终止id
		/// </summary>
		public string Id { get; set; }

		/// <summary>
		/// 终止理由
		/// </summary>
		public string? Content { get; set; }
	}

	public enum ETerminateStatus
	{
		/// <summary>
		/// 审批中
		/// </summary>
		[Description("审批中")]
		Approval = 1,

		/// <summary>
		/// 终止完成
		/// </summary>
		[Description("终止同意")]
		End = 2,

		/// <summary>
		/// 终止拒绝
		/// </summary>
		[Description("终止不同意")]
		Refuse = 3,

		/// <summary>
		/// 退回
		/// </summary>
		[Description("终止退回")]
		SendBack = 4,

		/// <summary>
		/// 退回待重提
		/// </summary>
		[Description("退回待重提")]
		SendBackStart = 5,
	}
}
