using RMYY_CallCenter_Api.Models.Enum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using RMYY_CallCenter_Api.Utility;
using RMYY_CallCenter_Api.Models.Dto;
using RMYY_CallCenter_Api.Models;
using System.Data;
using RMYY_CallCenter_Api.Controllers;

namespace RMYY_CallCenter_Api
{
    public  class WorkOrderBase
    {

        private static Bll.T_Dis_WorkOrderItem itembll = new Bll.T_Dis_WorkOrderItem();

        private static Bll.T_Sys_GongDan gdbll = new Bll.T_Sys_GongDan();


        private static BLL.T_FaultRepair_Base fbbll = new BLL.T_FaultRepair_Base();

        public delegate string TranslationDelegate(int F_Id, string F_UserCode);

        public static string GetDisStateName(int F_Id, string F_UserCode)
        {
            return EnumHelper.GetDescription((EnumDisWorkOrderState)itembll.GetModelList("F_WoID=" + F_Id + " and (F_CreateUser=" + F_UserCode + " or F_NextUser=" + F_UserCode + ")").OrderByDescending(pp => pp.F_ID).FirstOrDefault().F_OptType);
        }
        public static string GetStateName(TranslationDelegate delegats, int F_Id, string F_UserCode)
        {
            return delegats.Invoke(F_Id, F_UserCode);
        }


        /// <summary>
        /// 获取工单状态
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static List<TypeState> GetTypeState(int type, int ftype = 0)
        {

            List<TypeState> wlist = Common.GetGongDanState<EnumWorkOrderState>();
            List<TypeState> tlist = Common.GetGongDanState<EnumDisWorkOrderState>();
            List<TypeState> qlist = Common.GetGongDanState<EnumMatWorkOrderState>();
            List<TypeState> dlit = Common.GetGongDanState<EnumDevWorkOrderState>();
            List<TypeState> alit = Common.GetGongDanState<EnumAccWorkOrderState>();
            List<TypeState> hlit = Common.GetGongDanState<EnumHosWorkOrderState>();
            List<TypeState> newlist = new List<TypeState>();
            int parentid = ParentType(type);
            if (parentid != 0)
                ftype = parentid;
            if (ftype == 3000)
            {
                newlist.Add(new TypeState { StateId = "-1", StateValue = "", StateRemark = "全部" });
                newlist.Add(new TypeState { StateId = "0", StateValue = "", StateRemark = "代派工" });
                newlist.Add(new TypeState { StateId = "1", StateValue = "", StateRemark = "已转派" });
                newlist.Add(new TypeState { StateId = "2", StateValue = "", StateRemark = "已处理" });
                newlist.Add(new TypeState { StateId = "3", StateValue = "", StateRemark = "已完结" });
                newlist.Add(new TypeState { StateId = "4", StateValue = "", StateRemark = "异常结束" });
                newlist.Add(new TypeState { StateId = "5", StateValue = "", StateRemark = "已拒单" });
                newlist.Add(new TypeState { StateId = "6", StateValue = "", StateRemark = "外协作单子" });
            }
            else if (ftype == 1000 || ftype == 4000)
            {
                newlist = wlist;
            }
            else
            {
                switch (type)
                {
                    case (int)EnumWorkOrder.RedDis:
                        tlist.RemoveAll(p => ("'" + (int)EnumDisWorkOrderState.dealing + "','" + (int)EnumDisWorkOrderState.takeblood + "','" + (int)EnumDisWorkOrderState.send + "'").Contains(p.StateId));
                        newlist = tlist;
                        break;

                    case (int)EnumWorkOrder.OrtherDis:
                    case (int)EnumWorkOrder.UrgDis:
                        tlist.RemoveAll(p => ("'" + (int)EnumDisWorkOrderState.stayred + "','" + (int)EnumDisWorkOrderState.staydrug + "','" + (int)EnumDisWorkOrderState.takeblood + "','" + (int)EnumDisWorkOrderState.send + "'").Contains(p.StateId));

                        newlist = tlist;
                        break;

                    case (int)EnumWorkOrder.BloodDis:

                        tlist.RemoveAll(p => ("'" + (int)EnumDisWorkOrderState.stayred + "','" + (int)EnumDisWorkOrderState.staydrug + "','" + (int)EnumDisWorkOrderState.dealing + "','" + (int)EnumDisWorkOrderState.send + "'").Contains(p.StateId));

                        newlist = tlist;
                        break;
                    case (int)EnumWorkOrder.Mat:

                        newlist = qlist;
                        break;
                    case (int)EnumWorkOrder.Dev:

                        newlist = dlit;
                        break;
                    case (int)EnumWorkOrder.Hos:
                        newlist = hlit;
                        break;

                    case (int)EnumWorkOrder.Serve:
                        alit.RemoveAll(p => ("'" + (int)EnumAccWorkOrderState.dealing + "'").Contains(p.StateId));
                        newlist = alit;

                        break;
                    case (int)EnumWorkOrder.TakeBlood:
                        alit.RemoveAll(p => ("'" + (int)EnumAccWorkOrderState.arrive + "','" + (int)EnumAccWorkOrderState.keep + "'").Contains(p.StateId));
                        newlist = alit;

                        break;

                    case (int)EnumWorkOrder.consultation:
                    case (int)EnumWorkOrder.complaint:
                    case (int)EnumWorkOrder.externalcons:
                    case (int)EnumWorkOrder.appointment:
                    case (int)EnumWorkOrder.maintain:
                        newlist = wlist;

                        break;
                }
            }
            return newlist;
            //return newlist.OrderBy(p => Convert.ToInt32(p.StateId));

        }

        /// <summary>
        /// 工单指派记录
        /// </summary>
        /// <param name="woid"></param>
        /// <param name="wostate"></param>
        /// <param name="type"></param>
        /// <param name="content"></param>
        /// <param name="itemtype"></param>
        /// <param name="opttype"></param>
        /// <param name="nextuser"></param>
        /// <param name="nextusername"></param>
        /// <param name="nextuserphon"></param>
        /// <param name="nextusertalkie"></param>
        /// <param name="nextdept"></param>
        /// <param name="nowUser"></param>
        /// <param name="F_IsUsed"></param>
        /// <returns></returns>

        public static long AddLogTrans(int woid, int wostate, int type, string content, int itemtype, int opttype, string nextuser, string nextusername, string nextuserphon, string nextusertalkie, int nextdept, Model.T_Sys_UserAccount nowUser, int F_IsUsed = 0)
        {

            Model.T_Dis_WorkOrderItem itemModel = new Model.T_Dis_WorkOrderItem();
            #region 
            //处理当前工单的记录之前的记录过期
            var itemlast = itembll.GetModelList(" isnull(F_IsUsed,'0')='0' and F_OptType !=" + (int)EnumDisItemOpt.assign + " and F_ItemType=" + itemtype + " and  F_WoID=" + woid + " and  (F_CreateUser=" + nowUser.F_UserCode + ")");
            if (F_IsUsed == 0)
            {

                if (itemlast.Count > 0)
                {
                    foreach (var it in itemlast)
                    {
                        it.F_IsUsed = 1;
                        itembll.Update(it);
                    }
                }
            }
            #endregion
            itemModel.F_WoID = woid;
            itemModel.F_WoState = wostate;
            itemModel.F_WoType = (int)(EnumWorkOrder)(type);//工单类型
            itemModel.F_ItemType = itemtype;
            itemModel.F_OptType = opttype;
            itemModel.F_OptContent = content;
            itemModel.F_NextUser = nextuser;
            itemModel.F_NextUserName = nextusername;
            itemModel.F_NextUserTalkie = nextusertalkie;
            itemModel.F_NexUserPhon = nextuserphon;
            itemModel.F_NextDept = nextdept;
            itemModel.F_IsUsed = F_IsUsed;
            itemModel.F_CreateTime = DateTime.Now;
            itemModel.F_CreateUser = nowUser.F_UserCode;
            var res = itembll.Add(itemModel);
            return res;
        }

        public static string GetWoTypeName(int wotype)
        {
            if (wotype > 0)
            {
                return ParentTypeName(wotype);
            }
            else return "";
        }
        /// <summary>
        /// 获取最大工单分类
        /// </summary>
        /// <param name="typeid"></param>
        /// <returns></returns>
        public static int ParentType(int typeid)
        {
            var model = new Bll.T_Sys_GongDan().GetModel(typeid);

            if (model.F_ParentID == 0)
            {
                return model.F_GDId;
            }
            else
            {
                return ParentType(Convert.ToInt32(model.F_ParentID));
            }
        }
        /// <summary>
        /// 获取工单类型名称
        /// </summary>
        /// <param name="typeid"></param>
        /// <returns></returns>

        private static string typename = "";
        public static string ParentTypeName(int typeid)
        {
            string restr = "";
            var model = new Bll.T_Sys_GongDan().GetModel(typeid);
            if (model != null)
            {
                typename = $"{model.F_Name}/" + typename;
                if (model.F_ParentID != 0)
                {
                    typename=ParentTypeName(Convert.ToInt32(model.F_ParentID));
                }
            }
            restr = typename;
            typename = "";
            return restr;
        }

        /// <summary>
        /// 根据工单状态获取操作按钮
        /// </summary>
        /// <param name="type"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public static List<FaultButtonGroup.button> GetbuttonList(int type,int state)
        {
            List<FaultButtonGroup.button> buttons = new List<FaultButtonGroup.button>();
            if (type > 0)
            {
               string sql = $" F_Type={type} and F_State={state}";
                var modelist = new Bll.T_Wo_StatusOpt().GetModelList(sql);
                if (modelist.Count > 0)
                {
                    foreach (var item in modelist)
                    {
                        FaultButtonGroup.button itembutton = new FaultButtonGroup.button(Convert.ToInt32(item.F_MenuId), new Bll.T_Sys_Menu().GetModel(Convert.ToInt32(item.F_MenuId))?.F_MenuName ?? "");
                        buttons.Add(itembutton);
                    }
                    return buttons;
                }
                return null;
            }
            return null;
        }

        /// <summary>
        /// 组装列表数据，列表需要包含以下字段
        /// </summary>
        /// <param name="dt"></param>
        /// <returns></returns>
        public static DataTable SetOtherField(DataTable dt, MENUENUM menuName,string usercode, int roleId = 0, int type = 0,int mysubmit=0,int workuser=0,int transfertype=0)//报修列表是值班人员workuser传1，  // transfertype 0 是转值班 1 是转组长 默认0
        {
            if (dt.Columns.Contains("Buttons") && dt.Columns.Contains("GapTime") && dt.Columns.Contains("StateName"))
            {
                return dt;
            }

            // 获取对应字段名
            string typeFieldName = "", stateFieldName = "", gapTimeFieldName = "", endTimeFieldName = "", assistanceStateFieldName = "";

            for (int i = 0; i < dt.Columns.Count; i++)
            {
                switch (dt.Columns[i].ColumnName)
                {
                    case "F_Type": {
                            if (typeFieldName == "")
                            {
                                typeFieldName = dt.Columns[i].ColumnName;
                            }
                        }; break;
                    case "F_WorkOrderState":
                    case "F_Status":
                        {
                            if (stateFieldName == "")
                            {
                                stateFieldName = dt.Columns[i].ColumnName;
                            }
                        }; break;
                    case "F_Deadline":
                    case "F_TimeLimit":
                        {
                            if (gapTimeFieldName == "")
                            {
                                gapTimeFieldName = dt.Columns[i].ColumnName;
                            }
                        }; break;
                    case "F_Endtime":
                        {
                            if (endTimeFieldName == "")
                            {
                                endTimeFieldName = dt.Columns[i].ColumnName;
                            }
                        }; break;
                    case "AssistanceState":
                        {
                            if (assistanceStateFieldName == "")
                            {
                                assistanceStateFieldName = dt.Columns[i].ColumnName;
                            }
                        }; break;
                    default: break;
                }
            }

            if ((type == 0 && typeFieldName == "") || stateFieldName == "")
            {
                return dt;
            }

            dt.Columns.Add("GapTime", typeof(string));//执行时限

            dt.Columns.Add("StateName", typeof(string));

            dt.Columns.Add("Buttons", typeof(object));//操作按钮

            // TODO：这个地方可以走一下Redis
            List<Model.T_Sys_GongDan> dglist = gdbll.GetModelList("");

            foreach (DataRow dr in dt.Rows)
            {
                int thisTypeId = type;
                #region 按钮处理
                if (type == 0)
                {
                    thisTypeId = int.Parse(dr[typeFieldName].ToString());
                }

                int assistanceState = 1;
                if (assistanceStateFieldName != "" && dr[assistanceStateFieldName].ToString() == "未完成")
                {
                    assistanceState = 0;
                }


                var allButtons = WorkOrderButton.GetButtons(menuName, thisTypeId, int.Parse(dr[stateFieldName].ToString()), roleId, assistanceState);

                //TODO: 特殊逻辑处理

                //展示延期按钮
                //接单人在接单之后，如果该工单类型上设置的“可延期次数”大于0显示“延期”按钮；点击延期按钮进行验证是否超过设定的延期次数，超过提醒“已超过规定延迟次数”
                int categoryType = 0;

                if (menuName == MENUENUM.工单列表 || (menuName == MENUENUM.我的提交 && mysubmit == 0))
                {
                    categoryType = Convert.ToInt32(dr["F_SonType"].ToString());
                }
                else
                {
                    switch (thisTypeId)
                    {

                        case 1000:
                            categoryType = Convert.ToInt32(dr["F_type2"].ToString());
                            break;
                        case 2000:
                            categoryType = Convert.ToInt32(dr["F_WorkOrderCategory"].ToString());
                            break;
                        case 3000:
                            categoryType = Convert.ToInt32(dr["F_WorkOrderCategory"].ToString());
                            break;
                        case 4000:
                            categoryType = Convert.ToInt32(dr["F_Type"].ToString());
                            break;
                    }
                }



                var gdmodel = dglist.Where(x => x.F_GDId == categoryType).FirstOrDefault();
                if (gdmodel == null
                    || gdmodel.F_CanReplayCount == 0)
                {
                    //移除延期按钮                   
                    var hasButton = allButtons.Where(p => p.value == "延期").FirstOrDefault();

                    allButtons.Remove(hasButton);
                }
                //工单类型上增加可催办次数字段，=0不允许催办，=-1不限制催办次数，其他的=几就是可以催办几次 
                if (gdmodel == null
                    || gdmodel.F_CanUrgeCount == 0)
                {
                    //移除催单按钮                   
                    var hasButton = allButtons.Where(p => p.value == "催单").FirstOrDefault();

                    allButtons.Remove(hasButton);
                }
                #region 故障报修  报修列表页面，如果已经挂起,所有的按钮删除，只留下处理人的完成按钮；挂起的工单 其他页面没有按钮
                if (menuName == MENUENUM.报修列表)
                {
                    if (dr["F_IsStop"] != null && Convert.ToInt32(dr["F_IsStop"].ToString()) == 1)
                    {
                        if (Convert.ToInt32(dr["F_WorkOrderState"].ToString()) == 2)//已接单
                        {
                            var hasButton = allButtons.Where(p => p.value == "到达").FirstOrDefault();
                            allButtons.Clear();
                            if (hasButton != null)
                            { allButtons.Add(hasButton); }
                        }
                        if (Convert.ToInt32(dr["F_WorkOrderState"].ToString()) == 6)//已到达
                        {
                            var hasButton = allButtons.Where(p => p.value == "完成").FirstOrDefault();
                            allButtons.Clear();
                            if (hasButton != null)
                            { allButtons.Add(hasButton); }
                        }



                    }
                }
                else if (thisTypeId == 3000 && menuName == MENUENUM.我的提交)
                {
                    if (dr["F_IsStop"] != null && Convert.ToInt32(dr["F_IsStop"].ToString()) == 1 && Convert.ToInt32(dr["F_Status"].ToString()) == 3)
                    {
                        var hasButton = allButtons.Where(p => p.value == "评价").FirstOrDefault();
                        allButtons.Clear();
                        if (hasButton != null)
                        { allButtons.Add(hasButton); }

                    }
                }
                #endregion


                #region 调度工单列表，工单类型是急查标本 需要增加一个收取标本操作，收取标本按钮存在移除送达按钮；同时需要把别的类型的收取标本按钮移除
                if (menuName == MENUENUM.调度工单列表)
                {
                    int gdid = Convert.ToInt32(dr["F_WorkOrderCategory"].ToString());
                    var gdddmodel = gdbll.GetModel(gdid);
                    //已经收取过标本了
                    if (!string.IsNullOrEmpty(dr["F_CollectTime"].ToString()))
                    {

                        if (gdddmodel.F_Identification == "FJ" || gdddmodel.F_Identification == "JC")
                        {
                            var hasButton = allButtons.Where(p => p.value == "收取标本").FirstOrDefault();
                            allButtons.Remove(hasButton);
                        }
                    }
                    // 工单类型是急查标本 还没有收取标本  ，去掉送达按钮
                    else
                    {
                        if (gdddmodel.F_Identification == "FJ" || gdddmodel.F_Identification == "JC")
                        {
                            var hasButton = allButtons.Where(p => p.value == "送达").FirstOrDefault();
                            allButtons.Remove(hasButton);
                        }
                        else
                        {
                            var hasButton = allButtons.Where(p => p.value == "收取标本").FirstOrDefault();
                            allButtons.Remove(hasButton);
                        }
                    }

                }


                #endregion
                #region 故障报修类型工单，我的提交页面，判断返修按钮是否应该显示
                if (menuName == MENUENUM.我的提交 && thisTypeId == 3000 && (dr["F_IsDone"].ToString() == "1" || dr["F_Status"].ToString()=="3" ))
                {
                    string workcode = dr["F_WoCode"].ToString();
                    Model.T_FaultRepair_Base fbodel = fbbll.GetModel(workcode);
                    //判断返工是不是规定的时间内，工单状态是已完结的工单

                    List<Model.T_Sys_GongDan> listgd = gdbll.GetModelList(" F_GDId='" + fbodel.F_WorkOrderCategory + "'");
                    double limittime = listgd.First().F_RepairTimeLimit;

                    if (fbodel.F_Endtime != null && fbodel.F_Endtime.Value.AddHours(limittime) < DateTime.Now)
                    {
                        var hasButton = allButtons.Where(p => p.value == "返修").FirstOrDefault();

                        if (hasButton != null)
                        { allButtons.Remove(hasButton); }
                    }


                }

                #endregion

                //仅仅值班人员或者组长可以有这三个按钮 workuser=0 不是值班人也不是组长
                if (menuName == MENUENUM.报修列表 && workuser == 0)
                {

                    var hasButton = allButtons.Where(p => p.value == "内协作").FirstOrDefault();
                    var hasButton1 = allButtons.Where(p => p.value == "外协作").FirstOrDefault();
                    var hasButton2 = allButtons.Where(p => p.value == "转部门").FirstOrDefault();
                    allButtons.Remove(hasButton);
                    allButtons.Remove(hasButton1);
                    allButtons.Remove(hasButton2);               

                }

                //转组长和转值班是互斥的按钮，根据部门类型设置的选项决定
                if (menuName == MENUENUM.报修列表 )
                {
                    if (transfertype == 0)
                    {
                        var existButton = allButtons.Where(p => p.value == "转组长").FirstOrDefault();
                        allButtons.Remove(existButton);
                    }
                    else
                    {
                        var existButton = allButtons.Where(p => p.value == "转值班").FirstOrDefault();
                        allButtons.Remove(existButton);
                    }
                }



                if (menuName == MENUENUM.报修列表 && workuser == 1)
                {
                    if (!string.IsNullOrEmpty(dr["F_Maintenancer"].ToString()) && dr["F_Maintenancer"].ToString() != usercode)
                    {
                        allButtons.Clear();
                    }
                }


                // 工单管理  我的提交页面，数据有我的提交和我处理的， 只有自己申请的工单 能催单
                if (menuName== MENUENUM.我的提交 && mysubmit == 0)
                {
                    if (dr["F_Proposer"].ToString() != usercode)
                    {
                        var hasButton = allButtons.Where(p => p.value == "催单").FirstOrDefault();
                        allButtons.Remove(hasButton);
                    }                   
                }
                //自己提交的工单，自己点了完成按钮，删掉返修按钮
                if (menuName == MENUENUM.我的提交 && thisTypeId == 3000)
                {
                    if (string.IsNullOrEmpty( dr["F_DealUser"].ToString()) && dr["F_Status"].ToString()=="5")
                    {
                        var hasButton = allButtons.Where(p => p.value == "返修").FirstOrDefault();
                        allButtons.Remove(hasButton);
                    }
                }

                //if (thisTypeId == 3000 )
                //{
                //    string workcode = dr["F_WoCode"].ToString();
                //    Model.T_FaultRepair_Base fbodel = fbbll.GetModel(workcode);

                //    if (fbodel.F_ConfirmEquip != 1)
                //    {
                //        //移除确认耗材按钮                   
                //        var hasButton = allButtons.Where(p => p.value == "耗材").FirstOrDefault();

                //        allButtons.Remove(hasButton);

                //    }
                //    if (fbodel.F_ConfirmEquip == 1)
                //    {
                //        var hasButton = allButtons.Where(p => p.value == "耗材").FirstOrDefault();
                //        allButtons.Clear();
                //        if (hasButton != null)
                //        { allButtons.Add(hasButton); }
                //    }


                //}



                dr["Buttons"] = allButtons;
                #endregion

                #region 超时时限处理
                if (!string.IsNullOrEmpty(dr[gapTimeFieldName].ToString()))
                {
                    DateTime deadline = Convert.ToDateTime(dr[gapTimeFieldName]);
                    DateTime thisDate = DateTime.Now;
                    if (endTimeFieldName != "" && !string.IsNullOrEmpty(dr[endTimeFieldName].ToString()))
                    { 
                        thisDate = Convert.ToDateTime(dr[endTimeFieldName].ToString());

                        if (thisDate < deadline)
                        {
                            dr["GapTime"] = "-";
                        }
                    }

                    if (dr["GapTime"].ToString() != "-")
                    {
                        TimeSpan ts = deadline.Subtract(thisDate);
                        double tss = double.Parse(Math.Round(ts.TotalSeconds, 0).ToString());
                        if (tss < 0) { tss = -tss; }
                        string gshsj = DateTimeConvert.parseTimeSeconds(tss, 1);

                        if (deadline > thisDate)
                        {

                            dr["GapTime"] = "剩余" + gshsj;
                        }
                        else
                        {

                            dr["GapTime"] = "超时" + gshsj;
                        }
                    }

                    
                }
                else
                {
                    dr["GapTime"] = "-";
                }
                #endregion



                #region 工单状态处理
                dr["StateName"] = GetWorkOrderStateStr(menuName, int.Parse(dr[stateFieldName].ToString()), thisTypeId);
                #endregion
            }

            return dt;
        }

        /// <summary>
        /// 获取工单对应状态文本
        /// </summary>
        /// <param name="menuName"></param>
        /// <param name="state"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static string GetWorkOrderStateStr(MENUENUM menuName, int state, int type)
        {
            List<int> typeIdArray = null;

            if (type == 3000)
            {
                typeIdArray = new List<int> { -1,0, 1, 2, 3, 4, 5, 6,7 };
            }
            else if (type == 1000) //业务咨询
            {
                typeIdArray = new List<int> { 0, 0, 1, 2, -1, 10, -1, -1,3,4,7 };
            }
            else if (type == 2000)//综合调度
            {
                typeIdArray = new List<int> { -1, 0, 1, 2, 3, 4 };
                 
            }
            else if (type == 4000)
            {
                typeIdArray = new List<int> { -1, 0, 1, 2,4,7,10 };

            }

            if (typeIdArray == null)
            {
                return "";
            }

            string str = "";
            List<string> strArr = null;

            switch (menuName)
            {
                case MENUENUM.我的提交:
                    if (type == 4000)
                        strArr = new List<string> { "待提交", "待分配", "待接单", "已接单", "处理中", "待评价", "已完成" };
                    else if (type == 3000)
                        strArr = new List<string> { "待提交", "待派单", "待接单", "已接单", "待评价", "已完成", "已完成", "已接单", "确认耗材中" };

                    else
                        strArr = new List<string> { "待提交", "待派单", "待接单", "已接单", "待评价", "已完成", "已完成", "已接单", "已退回", "办理中", "待回访" }; break;
                case MENUENUM.工单列表:
                    if(type==3000)
                        strArr = new List<string> { "待提交", "待派单", "待接单", "待完成", "已处理", "异常完结", "已完结", "待完成","确认耗材中" };
                    else
                    strArr = new List<string> { "待提交", "待派单", "待接单", "待完成", "已处理", "已完成", "已完成", "已接单", "已退回", "办理中", "待回访" }; break;
                case MENUENUM.报修列表:
                    strArr = new List<string> { "待提交", "-", "待接单", "已接单", "已完成", "已完成", "已完成", "待完成", "确认耗材中" }; break;         

                case MENUENUM.调度工单列表:
                    strArr = new List<string> { "待提交", "待指派", "待接单", "待完成", "待评价", "已完成" }; break;
                default: break;
            }
            int index = typeIdArray.IndexOf(state);

            if (index < 0)
            {
                return "";
            }


            return strArr[index];

        }
    }
}