using DeviceRepair.Models.Enum;
using System;
using System.Collections.Generic;
using System.Linq;

namespace DeviceRepair.Models.OperationHistory
{
    /// <summary>
    /// 查询条件对象
    /// </summary>
    public class HistoryQueryParam
    {
        #region Property

        #region 用在界面上不显示，但是默认执行的查询条件参数字段\     
        /// <summary>
        /// 用在界面上不显示，但是默认执行的查询条件参数字段
        /// </summary>
        public string DefaultNotShowQueryParamValue
        {
            get;
            set;
        }
        #endregion
        public string QueryCode
        {
            get;
            set;
        }
        public string QueryDescription
        {
            get;
            set;
        }

        public Type QueryType
        {
            get;
            set;
        }

        //列展示顺序【预留】
        public int ShowSequence
        {
            get;
            set;
        }
        public string DefaultValue
        {
            get;
            set;
        }

        public HistoryFilterCtlType CtlType
        {
            get;
            set;
        }
        /// <summary>
        /// ComboBox预制值列表（多个用英文半角逗号隔开）
        /// </summary>
        public IList<ComboBoxValueStruct> QueryItems
        {
            get;
            set;
        }

        public string this[string comboBoxDisplay]
        {
            get
            {
                if (QueryItems == null)
                {
                    return string.Empty;
                }
                var vFind = QueryItems.FirstOrDefault(A => { return A.Display == comboBoxDisplay; });
                return vFind?.Value ?? string.Empty;
            }
        }

        public string ComboBoxQueryDisplays
        {
            get
            {
                if (QueryItems == null)
                {
                    return "";
                }
                else
                {
                    var vValues = "";
                    foreach (var item in QueryItems)
                    {
                        vValues += $"{item.Display},";
                    }
                    return vValues.TrimEnd(',');
                }
            }
        }

        /// <summary>
        /// 是否模糊匹配
        /// </summary>
        public bool bFuzzy
        {
            get;
            set;
        }
        #endregion

        #region Ctor

        public HistoryQueryParam()
        {
            ShowSequence = 0;
            bFuzzy = false;
        }

        #endregion
    }
}
