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 turndown()
        {
            return new button(35, "拒绝");
        }
        public static button redo()
        {
            return new button(36, "退回");
        }
        public static button EJredo()
        {
            return new button(38, "退回");
        }
        public static button modify()
        {
            return new button(40, "修改");
        }
        public static button Check()
        {
            return new button(41, "查收");
        }
        public static button Approved()
        {
            return new button(42, "审核通过");
        }
        public static button Auditreject()
        {
            return new button(43, "审核拒绝");
        }
        public static button Signfor()
        {
            return new button(44, "签收");
        }
        public static button Sendback()
        {
            return new button(45, "退回");
        }
        public static button delayback()
        {
            return new button(46, "退回申请延时");
        }
       
       
        public static button Unsuccessful()
        {
            return new button(50, "已办未果");
        }
        public static button VisitApproved()
        {
            return new button(51, "审核通过");
        }
        public static button Auditfailed()
        {
            return new button(52, "审核不通过");
        }
        public static button Audittransfer()
        {
            return new button(53, "审核通过转办");
        }
        public static button AuditDispatch()
        {
            return new button(54, "审核通过");
        }
        public static button Failed()
        {
            return new button(55, "审核不通过");
        }
        public static button Explain()
       {
           return new button(56, "解释");
        }
        public static button AuditReturn ()
        {
            return new button(58, "退回审核");
        }
        /// <summary>
        /// 审核员退回
        /// </summary>
        /// <returns></returns>
        public static button subback()
        {
            return new button(39, "退回");
        }
        #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=""
            ,int isproresult=0,string user="",int issh=0)
        {
            //中心话务员(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 == "YSZY" || code == "ZJZY" || code == "GNZY")
                        buttons.Add(edit());
                    if (code == "ZXLD" )
                        buttons.Add(delete());
                    if (code == "GNZY")
                    {
                        buttons.Add(submit());
                    }
                    //中心话务员 坐席班长 管理员
                    if (code == "ZXHWY" || code == "ZXBZ" || code == "GLY" || code == "DDZG")
                    {
                        buttons.Add(submit());
                        buttons.Add(edit()); buttons.Add(delete());
                    }
                    if (code == "MTDD")
                    {
                        buttons.Add(delete());
                        buttons.Add(submit());
                    }
                    break;
                case "1":
                    //质检专员可以进行编辑 zhengbingbing 20191017
                    if (code == "ZJZY")
                        buttons.Add(edit());
                    //调度专员 中心领导管理员 管理员
                    if (code == "ZXLD" || code == "YSZY" || code == "GLY" || code == "ZXLDGLYGLY" || code == "DDZG" || code == "MTDD")
                    {
                        if (issh ==2 && code == "MTDD")
                        {
                        }
                        else
                        {
                          //  buttons.Add(Report());
                            buttons.Add(edit());
                            buttons.Add(back());
                            // buttons.Add(assign());
                            // buttons.Add(approval());
                            //20190315提出需求 操作-领导批示改为转督办 (20190327 zhengbingbing)
                            //  buttons.Add(turnsee());
                           // buttons.Add(instruct());
                        }
                       
                    }
                    //if (code == "ZXLD" || code == "YSZY")
                    //    buttons.Add(turnsee());
                    if (code == "ZXHWY")
                    {//待审核交办时可撤单
                        buttons.Add(withdraw());
                    }
                    break;
                case "2":
                    //二级网络单位 管理员     
                    if (code == "GLY" || code == "WLDW")
                    {
                        buttons.Add(receive());
                        //  buttons.Add(reback());
                    }
                    //调度专员 中心领导管理员 管理员
                    if (code == "ZXLD" || code == "YSZY" || code == "ZXLDGLYGLY" || code == "GLY" || code == "DDZG" || code == "MTDD")
                    {
                        buttons.Add(takeback());
                        buttons.Add(edit());
                    }
                    break;
                case "3":
                    //调度专员 中心领导管理员 管理员
                    if (code == "ZXLD" || code == "YSZY" || code == "ZXLDGLYGLY" || code == "GLY" || code == "DDZG" || code == "MTDD")
                    {
                        buttons.Add(auditreback()); buttons.Add(turnsee());
                    }
                    break;
                case "4":
                    //二级网络单位 管理员
                    if (code == "WLDW" || code == "DDZG")
                    {
                        buttons.Add(feedback());// buttons.Add(reback());
                        if (iszbdw == "1" || code == "GLY" || code == "DDZG")
                        {
                            
                            //    if (user =="省平台")
                            //    buttons.Add(ejdelay());
                            //else 
                            buttons.Add(delay());
                            if (ispd == "0" || ispd == "")
                            {
                                buttons.Add(split());
                            }
                            else
                            {
                                buttons.Add(withdraw());
                            }
                            if (ispd == "3")
                            {
                                buttons.Add(auditdeal());
                            }
                        }
                    }
                    //调度专员 中心领导管理员 管理员
                    if (code == "ZXLD" || code == "YSZY" || code == "ZXLDGLYGLY" || code == "GLY" || code == "DDZG" || code == "MTDD")
                    {
                        buttons.Add(takeback());
                        buttons.Add(edit());
                        // buttons.Add(edit());
                        // 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(EJredo());
                            //三级单位签收后，加个退回按钮，可以退回工单到二级单位，退回时必须输入退回原因
                           buttons.Add(feedback());
                            //三级单位签收后，加个退回按钮，可以退回工单到二级单位，退回时必须输入退回原因
                        }
                    }
                    break;
                case "5":
                    //调度专员 中心领导管理员 管理员
                    if (code == "ZXLD" || code == "YSZY" || code == "ZXLDGLYGLY" || code == "GLY" || code == "DDZG" || code == "MTDD")
                    {
                     //   buttons.Add(edit());
                        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")
                   //{
                   //    buttons.Add(visit());
                    //}
                    //20190315提出需求，回访由质检人员操作 (20190327 zhengbingbing)
                    #endregion
                    //质检专员(ZJZY)
                    if (isproresult != 0)
                    {
                        if (isproresult == 2)
                        {
                            if (code == "WLDW" )
                            {
                               buttons.Add(feedback());
                            }
                        }
                        //else if (isproresult == 3)
                        //{
                        //    if (code == "ZJZY" || code == "GLY" || code == "ZXLD" || code == "YSZY" || code == "DDZG" || code == "MTDD")
                        //    {
                        //        if (user=="省平台")
                       //            buttons.Add(visits());
                        //        else
                       //        buttons.Add(visit());
                       //        //  buttons.Add(modify());
                        //    }
                       //    if (code == "ZXHWY")
                       //    {
                        //        if (user == "省平台")
                        //            buttons.Add(visits());
                        //        else
                        //            buttons.Add(visit());
                        //    }
                        //}
                        //调度专员 中心领导管理员 管理员
                        //三级网络单位
                        if (code == "EJWLDW")
                        {

                            if (ispd == "2")
                            {
                                buttons.Add(feedback());
                            }
                        }
                    }
                    else
                   {
                        if (code == "ZJZY" || code == "GNZY" || code == "GLY" || code == "ZXLD" || code == "YSZY" || code == "DDZG" || code == "MTDD" || code == "DMTSH")
                        {
                            buttons.Add(VisitApproved());
                            buttons.Add(Auditfailed());
                           buttons.Add(Audittransfer());

                       }
                        if (code == "ZXHWY")
                       {
                           // buttons.Add(subback());
                           // buttons.Add(visit());
                           buttons.Add(VisitApproved());
                            buttons.Add(Auditfailed());
                            buttons.Add(Audittransfer());

                       }
                    }
                    break;

                //case "6":
                //    //调度专员 中心领导管理员 管理员
                //    //if (code == "ZXLD" || code == "ZXLDGLYGLY" || code == "GLY")
                //    if (isproresult != 0)
                //    {
                //        if (isproresult == 2)
                //        {
                //            if (code == "WLDW" || code == "GLY" || code == "DDZG")
                //            {
                //                buttons.Add(feedback());
                //            }
                //        }
                //        else if (isproresult == 3)
                //        {
                //            if (code == "ZJZY" || code == "GLY" || code == "ZXLD" || code == "YSZY" || code == "DDZG" || code == "MTDD")
                //            {
                //                if (user == "省平台")
                //                    buttons.Add(visits());
                //                else
                //                    buttons.Add(visit());
                //                //  buttons.Add(modify());
                //            }
                //            if (code == "ZXHWY")
                //            {
                //                if (user == "省平台")
                //                    buttons.Add(visits());
                //                else
                //                    buttons.Add(visit());
                //            }
                //        }
                //        //调度专员 中心领导管理员 管理员
                //        //三级网络单位
                //        if (code == "EJWLDW")
                //        {

                //            if (ispd == "2")
                //            {
                //                buttons.Add(feedback());
                //            }
                //        }
                //    }
                //    else
                //    {
                //        if (code == "ZJZY" || code == "GNZY" || code == "GLY" || code == "ZXLD" || code == "YSZY" || code == "DDZG" || code == "MTDD")
                //        {
                //            buttons.Add(visit());
                //            buttons.Add(subback());
                //            buttons.Add(modify());
                //        }
                //        if (code == "ZXHWY")
                //        {
                //            buttons.Add(subback());
                //            buttons.Add(visit());
                //        }
                //    }
                //    break;
                case "7":
                    //调度专员 中心领导管理员 管理员
                    //if (code == "ZXLD" || code == "ZXLDGLYGLY" || code == "GLY")
                    if (isproresult != 0)
                    {
                        if (isproresult == 2)
                        {
                            if (code == "WLDW" )
                            {
                                buttons.Add(feedback());
                            }
                        }
                        else if (isproresult == 3)
                        {
                            if (code == "ZJZY" || code == "GLY" || code == "ZXLD" || code == "YSZY" || code == "DDZG" || code == "MTDD")
                            {
                                //if (user == "省平台")
                                //    buttons.Add(visits());
                                //else
                                    buttons.Add(visit());
                                //  buttons.Add(modify());
                            }
                            if (code == "ZXHWY")
                            {
                                //if (user == "省平台")
                                //    buttons.Add(visits());
                                //else
                                    buttons.Add(visit());
                            }
                        }
                        //调度专员 中心领导管理员 管理员
                        //三级网络单位
                        if (code == "EJWLDW")
                        {

                            if (ispd == "2")
                            {
                                buttons.Add(feedback());
                            }
                        }
                    }
                    else
                    {
                        if (code == "ZJZY" || code == "GNZY" || code == "GLY" || code == "ZXLD" || code == "YSZY" || code == "DDZG" || code == "MTDD")
                        {
                            buttons.Add(visit());
                            buttons.Add(subback());
                            buttons.Add(modify());
                        }
                        if (code == "ZXHWY")
                        {
                            buttons.Add(subback());
                            buttons.Add(visit());
                        }
                    }
                    break;
                case "8":
                    //二级网络单位 管理员
                    if (code == "WLDW"|| code == "DDZG")
                    {

                        buttons.Add(feedback());
                            buttons.Add(delay());
                        buttons.Add(split());

                       // buttons.Add(reback());

                    }
                    //调度专员 中心领导管理员 管理员
                    if (code == "ZXLD" || code == "YSZY"   || code == "ZXLDGLYGLY" || code == "GLY" || code == "DDZG" || code == "MTDD")
                    {
                        buttons.Add(edit());
                        buttons.Add(takeback());
                        //buttons.Add(oversee());
                        //  buttons.Add(turnsee());
                        //  buttons.Add(supervision());
                    }
                    if (code == "EJWLDW")
                    {
                        if (ispd == "1")
                        {
                            buttons.Add(sign()); //buttons.Add(refuse());
                        }
                        if (ispd == "2")
                        {
                           // buttons.Add(EJredo());
                            //三级单位签收后，加个退回按钮，可以退回工单到二级单位，退回时必须输入退回原因
                            buttons.Add(feedback());
                            //三级单位签收后，加个退回按钮，可以退回工单到二级单位，退回时必须输入退回原因
                        }
                    }
                    //质检专员
                    //  if (code == "ZJZY" )
                    //    buttons.Add(turnsee());
                    break;
                case "9":
                    //调度专员 中心领导管理员 管理员
                    if ((code == "ZXLD" || code == "YSZY" || code == "ZXLDGLYGLY" || code == "GLY" || code == "DDZG" || code == "MTDD" || code == "ZXHWY") && iszb == "1")
                    {

                        // buttons.Add(back());
                    }
                    if (code == "ZXLD" || code == "GNZY" || code == "YSZY" || code == "ZXLDGLYGLY" || code == "GLY" || code == "DDZG" || code == "MTDD" || code == "ZXHWY")
                    {
                        buttons.Add(modify());
                    }
                    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 == "YSZY" || code == "MTDD" || code == "ZXLDGLYGLY" || code == "GLY" || code == "DDZG" || code == "MTDD")
                    {
                        buttons.Add(reload()); buttons.Add(reject());
                    }
                    break;
                case "12":
                    //督办专员(DBZY) 管理员
                    if (code == "DBZY" || code == "GLY" || code == "DDZG")
                    {
                        buttons.Add(oversee()); buttons.Add(turnnosee());
                    }
                    break;
                case "13":
                    if (code == "ZJZY" || code == "ZXHWY" || code == "GLY" || code == "DDZG")
                    {
                        buttons.Add(subreload());
                        buttons.Add(end());
                    }
                    else if (code == "ZXLD" || code == "YSZY" || code == "MTDD")
                    {
                        buttons.Add(subreload());
                    }
                    break;
                case "14":
                    if (code == "ZJZY" || code == "ZXLD" || code == "GLY" || code == "DDZG")
                    {
                        buttons.Add(AuditReturn());
                        
                    }
                   
                    break;
            }
            //buttons.Add(export());
            //调度专员 中心领导管理员 管理员
            if (state != "0" && state != "9" && (code == "ZXLD" || code == "YSZY" || code == "MTDD"|| code == "ZXLDGLYGLY" || code == "GLY" || code == "DDZG"))
            {
               
                buttons.Add(forceend());
            }
            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 == "YSZY" || rolecode == "ZXLDGLY" || rolecode == "ZXLDGLYGLY" || rolecode == "GLY"|| rolecode == "MTDD")
                        buttons.Add(zsk_audit());
                    break;
                case "2":
                case "5":
                    if (rolecode == "ZXHWY" || rolecode == "ZXBZ" || rolecode == "ZXLD" || rolecode == "YSZY" || 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
    }
}