using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace CallCenterApi.Interface.Models.Common
{
    public class ButtonGroup
    {
        public static button query()
        {
            return new button(1, "查询");
        }
        public static button edit()
        {
            return new button(2, "编辑");
        }
        public static button delete()
        {
            return new button(3, "删除");
        }
        public static button submit()
        {
            return new button(4, "提交");
        }
        public static button assign()
        {
            return new button(5, "交办");
        }
        public static button approval()
       {
           return new button(6, "领导批示");
       }
       public static button instruct()
       {
           return new button(7, "市长指示");
       }
       public static button oversee()
       {
           return new button(8, "督办");
       }
       public static button supervision()
       {
            return new button(9, "监察");
        }
        public static button takeback()
        {
            return new button(10, "收回");
        }
        public static button receive()
        {
            return new button(11, "查收");
        }
        public static button reback()
        {
            return new button(12, "退回申请");
        }
        public static button feedback()
        {
            return new button(13, "办理");
        }
        public static button delay()
        {
            return new button(14, "延时申请");
        }
        public static button auditreback()
        {
            return new button(15, "退回审核");
        }
        public static button visit()
        {
            return new button(16, "回访");
        }
        public static button auditdelay()
        {
            return new button(17, "延时审核");
        }
        public static button reload()
        {
            return new button(18, "重办");
        }
        public static button end()
        {
            return new button(19, "结案");
        }
        public static button export()
        {
            return new button(20, "导出");
        }
       public static button back()
       {
           return new button(21, "回退");
        }
        public static button forceend()
        {
            return new button(22, "强制结案");
        }
        public static button split()
        {
            return new button(23, "派单");
        }
        public static button auditdeal()
        {
            return new button(24, "处理审核");
        }
        public static button sign()
        {
            return new button(25, "签收");
        }
        public static button refuse()
        {
            return new button(26, "拒收");
        }
        public static button withdraw()
        {
            return new button(27, "撤单");
        }
        public static button audit()
        {
            return new button(28, "审核");
        }
       public static button turnsee()
       {
           return new button(29, "转督办");
       }
       public static button turnnosee()
       {
           return new button(30,"不督办");
        }
        public static button subreload()
        {
            return new button(31, "提交重办");
        }
        public static button reject()
        {
            return new button(32, "驳回重办");
        }
        public static button perform()
        {
            return new button(33, "履职界定");
        }
        public static button performaudit()
        {
            return new button(34, "界定审核");
        }
        //public static button IsExport()
        //{
        //    return new button(34, "回传");
        //}
        public static button Result()
        {
            return new button(35, "编辑");
        }
        //public static button Upload()
        //{
        //    return new button(36, "上传");
        //}
        public static button Remkers()
        {
            return new button(37, "备注");
        }
        public static button Runsend()
        {
            return new button(38, "转派");
        }
        public static button Reloadsuber()
        {
            return new button(39, "重办待交办");
        }
        public static button Reminder()
        {
            return new button(40, "催办");
        }
        //public static button thirdBack()
        //{
        //    return new button(41, "退回郑州市");

        //}

        #region 知识库操作按钮
        public static button zsk_query()
        {
            return new button(1, "查询");
        }
        public static button zsk_edit()
        {
            return new button(2, "编辑");
        }
        public static button zsk_delete()
        {
            return new button(3, "删除");
        }
        public static button zsk_submit()
        {
            return new button(4, "提交");
        }
        public static button zsk_audit()
        {
            return new button(5, "审核");
        }
        public static button zsk_solved()
        {
            return new button(6, "解决");
        }
        public static button zsk_unsolved()
        {
            return new button(7, "未解决");
        }
        #endregion
        /// <summary>
        /// 按钮类
        /// </summary>
        public class button
        {
            public int key { get; set; }
            public string value { get; set; }
            public button(int _key, string _value) {
                key = _key;
                value = _value;
            }
        }

        /// <summary>
        /// 根据状态和角色代码获取操作按钮
        /// </summary>
        /// <param name="state"></param>
        /// <param name="code"></param>
        /// <param name="iszb"></param>
        /// <returns></returns>
        public static List<button> GetButtons(string state, string code, string iszb="", string iszbdw="",string ispd="",string  ishc = "")
        {
            //中心话务员(ZXHWY) 二级网络单位(WLDW) 管理员(GLY) 坐席班长(ZXBZ) 调度专员(ZXLD)
            //中心领导管理员(ZXLDGLYGLY) 话务主管(ZXBZ) 中心领导(ZXLDGLY) 话务组长(ZXBZ)
            //导播话务员(DBHWY) 网易新闻(11) 三级网络单位(EJWLDW) 民生播报(MSBB)
            //督办专员(DBZY) 质检专员(ZJZY)
            //调度主管(DDZG)
            List<button> buttons = new List<button>();
            buttons.Add(query());
            switch (state)
            {
                case "0":
                    //调度专员 质检专员可以进行编辑 zhengbingbing 20191017
                    if (code == "ZXLD" || code == "ZJZY")
                    {
                        buttons.Add(delete());
                        buttons.Add(edit());
                      //  buttons.Add(thirdBack());
                    }
                       
                    //中心话务员 坐席班长 管理员
                    if (code == "ZXHWY" || code == "ZXBZ" || code == "GLY" || code == "DDZG")
                    {
                        buttons.Add(submit());
                        buttons.Add(edit()); buttons.Add(delete());
                      //  buttons.Add(thirdBack());
                    }
                    break;
                case "1":
                    //质检专员可以进行编辑 zhengbingbing 20191017
                    if (code == "ZJZY")
                        buttons.Add(edit());
                    //调度专员 中心领导管理员 管理员
                    if (code == "ZXLD" || code == "ZXLDGLYGLY" || code == "GLY" || code == "DDZG")
                    {
                       // buttons.Add(thirdBack());
                        //    buttons.Add(approval());
                        buttons.Add(edit());
                     //   buttons.Add(back());
                        buttons.Add(assign());
                        //buttons.Add(approval());
                        //20190315提出需求 操作-领导批示改为转督办 (20190327 zhengbingbing)
                        //buttons.Add(turnsee());
                      //  buttons.Add(instruct());
                    }
                    break;
                case "2":
                    //二级网络单位 管理员     
                    if (code == "WLDW" || code == "GLY")
                    {
                        buttons.Add(receive());
                        buttons.Add(reback());
                    }
                    //调度专员 中心领导管理员 管理员
                    if (code == "ZXLD" || code == "ZXLDGLYGLY" || code == "GLY" || code == "DDZG")
                    {
                       // buttons.Add(approval());
                        buttons.Add(takeback());
                        buttons.Add(Reminder());
                        buttons.Add(Runsend());
                        //     buttons.Add(turnsee()); //buttons.Add(oversee());
                        //     buttons.Add(supervision());
                    }
                    //质检专员
                 //   if (code == "ZJZY")
                    //    buttons.Add(turnsee());
                    break;
                case "3":
                    //调度专员 中心领导管理员 管理员
                    if (code == "ZXLD" || code == "ZXLDGLYGLY" || code == "GLY" || code == "DDZG")
                    {
                        buttons.Add(auditreback());
                      //  buttons.Add(approval());
                    }
                    break;
                case "4":
                    //二级网络单位 管理员
                    if (code == "ZXLD" || code == "WLDW" || code == "GLY" || code == "DDZG")
                    {
                        buttons.Add(feedback());
                        if (code != "WLDW")
                        {
                            buttons.Add(Runsend());
                        }
                        if (iszbdw == "1" || code == "GLY" || code == "DDZG")
                        {
                            buttons.Add(reback());
                            buttons.Add(delay());
                           
                            if (ispd == "0" || ispd == "")
                            {
                              // buttons.Add(split()); 
                            }
                            else
                            {
                              //  buttons.Add(withdraw());
                            }
                            if (ispd == "3")
                            {
                                buttons.Add(auditdeal());
                            }
                        }
                    }
                    //调度专员 中心领导管理员 管理员
                    if (code == "ZXLD" || code == "ZXLDGLYGLY" || code == "GLY" || code == "DDZG")
                    {
                      //  buttons.Add(approval());
                        buttons.Add(takeback());
                        buttons.Add(Reminder());
                        //   buttons.Add(turnsee()); //buttons.Add(oversee());
                        //   buttons.Add(supervision());
                    }
                    //质检专员
                   // if (code == "ZJZY")
                    //    buttons.Add(turnsee());
                    //三级网络单位
                    if (code == "EJWLDW")
                    {
                        if (ispd == "1")
                        {
                            buttons.Add(sign()); buttons.Add(refuse());
                        }
                        if (ispd == "2")
                        {
                            buttons.Add(feedback());
                        }
                    }
                    break;
                case "5":
                    //调度专员 中心领导管理员 管理员
                    if (code == "ZXLD" || code == "ZXLDGLYGLY" || code == "GLY" || code == "DDZG")
                    {
                      //  buttons.Add(approval());
                        buttons.Add(auditdelay());
                    }
                    //三级网络单位
                    if (code == "EJWLDW")
                    {
                        if (ispd == "1")
                        {
                            buttons.Add(sign()); buttons.Add(refuse());
                        }
                        if (ispd == "2")
                        {
                            buttons.Add(feedback());
                        }
                    }
                    break;
                case "6":
                    #region 
                    //中心话务员 坐席班长 管理员
                   //if (code == "ZXHWY" || code == "ZXBZ" || code == "GLY"||code == "ZXLD")
                   // {
                   //     buttons.Add(edit());
                   // }
                    //20190315提出需求，回访由质检人员操作 (20190327 zhengbingbing)
                    #endregion
                    //质检专员(ZJZY)
                    if (code == "ZJZY" || code == "GLY" || code == "DDZG"|| code == "WLDW")
                    {
                        buttons.Add(visit());
                       
                    }
                    
                    break;
                case "7":
                    //调度专员 中心领导管理员 管理员
                    //if (code == "ZXLD" || code == "ZXLDGLYGLY" || code == "GLY")
                    if (code == "ZXLD" || code == "ZJZY" || code == "GLY" || code == "DDZG")
                    {
                        //buttons.Add(reload());
                      //  buttons.Add(subreload());
                        //buttons.Add(end());
                        buttons.Add(Result());
                        buttons.Add(subreload());
                        //   buttons.Add(approval());
                    }
                    //if (code == "WLDW")
                    //buttons.Add(Upload());
                    break;
                case "8":
                    //二级网络单位 管理员
                    if (code == "WLDW" || code == "GLY" || code == "DDZG")
                    {
                        buttons.Add(receive());
                        buttons.Add(reback());
                    }
                    //调度专员 中心领导管理员 管理员
                    if (code == "ZXLD" || code == "ZXLDGLYGLY" || code == "GLY" || code == "DDZG")
                    {
                        //  buttons.Add(approval());
                        buttons.Add(Reminder());
                        buttons.Add(takeback());
                        //buttons.Add(oversee());
                     //   buttons.Add(turnsee());
                     //   buttons.Add(supervision());
                    }
                    //质检专员
                  //  if (code == "ZJZY")
                    //    buttons.Add(turnsee());
                    break;
                case "9":
                    //调度专员 中心领导管理员 管理员
                    if (code == "ZXLD" || code == "ZXLDGLYGLY" || code == "GLY" || code == "DDZG" )
                    {
                      //  buttons.Add(approval());
                        //  if (iszb == "1")
                        //  buttons.Add(back());

                        if (ishc !="1")
                        {
                          //  buttons.Add(IsExport());
                           // buttons.Add(subreload());
                            buttons.Add(subreload());
                        }

                       
                    }
                    //if (code == "WLDW")
                    //    buttons.Add(Upload());
                    break;
                case "10":
                    //坐席班长 管理员
                    #region 
                    //20190715 去掉审核环节 zhengbingbing
                    if (code == "ZXBZ" || code == "GLY" || code == "DDZG")
                        buttons.Add(audit());
                    #endregion
                    if (code == "ZXHWY" || code == "ZXBZ" || code == "GLY" || code == "DDZG")
                        buttons.Add(edit());
                    break;
                case "11":
                    //调度专员 中心领导管理员 管理员
                    if (code == "ZXLD" || code == "ZXLDGLYGLY" || code == "GLY" || code == "DDZG")
                    {
                       // buttons.Add(approval());

                        buttons.Add(reload());// buttons.Add(reject());Reloadsuber
                      
                    }
                    break;
                case "12":
                    //督办专员(DBZY) 管理员
                    if (code == "DBZY" || code == "GLY" || code == "DDZG")
                    {
                     //   buttons.Add(oversee()); buttons.Add(turnnosee());
                    }
                    break;
                case "13":
                    if (code == "ZJZY" || code == "GLY" || code == "DDZG")
                    {
                     //   buttons.Add(subreload());
                        buttons.Add(end());
                    }
                    break;
                case "14":
                    if (code == "ZXLD" || code == "GLY" || code == "DDZG")
                    {
                        buttons.Add(approval());
                      
                    }
                    break;
            }
            //buttons.Add(export());
            //调度专员 中心领导管理员 管理员
            if (state != "0" && state != "9"&&state !="14" && (code == "ZXLD" || code == "ZXLDGLYGLY" || code == "GLY" || code == "DDZG"))
            {
                buttons.Add(forceend());
            }
            if (code != "WLDW")
            {
                buttons.Add(Remkers());
            }
            return buttons;
        }
        /// <summary>
        /// 超时工单
        /// </summary>
        /// <returns></returns>
        public static List<button> GetButtonstimeout()
        {
            List<button> buttons = new List<button>();
            buttons.Add(query());
            buttons.Add(Reminder());
            return buttons;
        }

        #region 知识库操作权限
        /// <summary>
        /// 根据状态和角色代码获取操作按钮
        /// </summary>
        /// <param name="state"></param>
        /// <param name="code"></param>
        /// <param name="iszb"></param>
        /// <returns></returns>
        public static List<button> GetZSKButtons(string state, string rolecode,string createby,string nowuser)
        {
            //中心话务员(ZXHWY) 二级网络单位(WLDW) 管理员(GLY) 坐席班长(ZXBZ) 调度专员(ZXLD)
            //中心领导管理员(ZXLDGLYGLY) 话务主管(ZXBZ) 中心领导(ZXLDGLY) 话务组长(ZXBZ)
            //导播话务员(DBHWY) 网易新闻(11) 三级网络单位(EJWLDW) 民生播报(MSBB)
            //督办专员(DBZY) 质检专员(ZJZY)
            List<button> buttons = new List<button>();
            buttons.Add(zsk_query());
            switch (state)
            {//状态：0草稿,1 待审核，2审核通过，3审核不通过，4无效
                case "0":
                    if (createby == nowuser || rolecode == "GLY")
                    {
                        buttons.Add(zsk_submit());
                        //buttons.Add(zsk_edit());
                        //buttons.Add(zsk_delete());
                    }
                    break;
                case "1":
                    if (rolecode == "ZXLD" || rolecode == "ZXLDGLY" || rolecode == "ZXLDGLYGLY" || rolecode == "GLY")
                        buttons.Add(zsk_audit());
                    break;
                case "2":
                case "5":
                    if (rolecode == "ZXHWY" || rolecode == "ZXBZ" || rolecode == "ZXLD" || rolecode == "DBZY" || rolecode == "ZJZY" || rolecode == "GLY")
                    {
                        //解决 未解决
                        buttons.Add(zsk_solved()); buttons.Add(zsk_unsolved());
                    }
                    //if (rolecode == "GLY")
                    //    buttons.Add(zsk_delete());

                    break;

                case "3":
                case "4":
                    if (createby == nowuser || rolecode == "GLY")
                    {
                        buttons.Add(zsk_submit());
                        //buttons.Add(zsk_edit());
                        //buttons.Add(zsk_delete());
                    }
                    break;
            }

            if (createby == nowuser || rolecode == "GLY")
            {
                buttons.Add(zsk_edit());
                buttons.Add(zsk_delete());
            }
            return buttons;
        }
        #endregion
    }
}