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, "强制结案");
        }
        /// <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)
        {
            List<button> buttons = new List<button>();
            buttons.Add(query());
            switch (state)
            {
                case "0":
                    if (code == "ZXHWY" || code == "ZXBZ" || code == "GLY")
                    {
                        buttons.Add(submit()); buttons.Add(edit()); buttons.Add(delete());
                    }
                    break;
                case "1":
                    if (code == "ZXLD" || code == "ZXLDGLY" || code == "GLY")
                    {
                        buttons.Add(edit()); buttons.Add(back()); buttons.Add(assign()); buttons.Add(approval()); buttons.Add(instruct());
                    }
                    break;
                case "2":
                    if (code == "WLDW" || code == "GLY")
                    {
                        buttons.Add(receive()); buttons.Add(reback());
                    }
                    if (code == "ZXLD" || code == "ZXLDGLY" || code == "GLY")
                    {
                        buttons.Add(takeback()); buttons.Add(oversee()); buttons.Add(supervision());
                    }
                    break;
                case "3":
                    if (code == "ZXLD" || code == "ZXLDGLY" || code == "GLY")
                    {
                        buttons.Add(auditreback());
                    }
                    break;
                case "4":
                    if (code == "WLDW" || code == "GLY")
                    {
                        buttons.Add(feedback());
                        if (iszbdw == "1" || code == "GLY")
                        {
                            buttons.Add(delay());
                        }
                    }
                    if (code == "ZXLD" || code == "ZXLDGLY" || code == "GLY")
                    {
                        buttons.Add(oversee()); buttons.Add(supervision());
                    }
                    break;
                case "5":
                    if (code == "ZXLD" || code == "ZXLDGLY" || code == "GLY")
                    {
                        buttons.Add(auditdelay());
                    }
                    break;
                case "6":
                    if (code == "ZXHWY" || code == "ZXBZ" || code == "GLY")
                    {
                        buttons.Add(visit());
                    }
                    break;
                case "7":
                    if (code == "ZXLD" || code == "ZXLDGLY" || code == "GLY")
                    {
                        buttons.Add(reload()); buttons.Add(end());
                    }
                    break;
                case "8":
                    if (code == "WLDW" || code == "GLY")
                    {
                        buttons.Add(receive()); buttons.Add(reback());
                    }
                    if (code == "ZXLD" || code == "ZXLDGLY" || code == "GLY")
                    {
                        buttons.Add(takeback()); buttons.Add(oversee()); buttons.Add(supervision());
                    }
                    break;
                case "9":
                    if ((code == "ZXLD" || code == "ZXLDGLY" || code == "GLY") && iszb == "1")
                    {
                        buttons.Add(back());
                    }
                    break;
            }
            //buttons.Add(export());
            if (state != "0" && state != "9" && (code == "ZXLD" || code == "ZXLDGLY" || code == "GLY"))
            {
                buttons.Add(forceend());
            }
            return buttons;
        }
    }
}