using RMYY_CallCenter_Api.Models.Enum;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace RMYY_CallCenter_Api.Models
{
    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 receive()
        {
            return new button(6, "查收");
        }
        public static button deal()
        {
            return new button(7, "处理");
        }
        public static button takered()
        {
            return new button(8, "取红处方");
        }
        public static button takepill()
        {
            return new button(9, "取药");
        }
        public static button takeblood()
        {
            return new button(10, "取血");
        }
        public static button send()
        {
            return new button(11, "送达");
        }
        public static button end()
        {
            return new button(12, "完成");
        }
        public static button over()
        {
            return new button(13, "处理完结");
        }
        public static button export()
        {
            return new button(14, "导出");
        }

    
        /// <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(int? state, string code, int? type)
        {
            List<button> buttons = new List<button>();
            buttons.Add(query());
            //中心话务员 坐席班长 管理员
            if (code == "ZXHWY" || code == "ZXBZ" || code == "GLY")
            {
                buttons.Add(submit());
                buttons.Add(edit()); buttons.Add(delete());
            }
            switch (type)
            {

                case (int)EnumWorkOrder.RedDis:
                    //红处方配送
                    if (state==(int)EnumDisWorkOrderState.neworder)
                    {
                        if (code == "GLY")
                        {
                            buttons.Add(assign());
                        }
                    }
                    if (state == (int)EnumDisWorkOrderState.assign)
                    {
                        if (code == "ZYY")
                        {
                            buttons.Add(receive());
                        }
                    }
                    if (state == (int)EnumDisWorkOrderState.receive)
                    {
                        if (code == "ZYY")
                        {
                            buttons.Add(takered());
                        }
                    }
                    if (state == (int)EnumDisWorkOrderState.stayred)
                    {
                        if (code == "ZYY")
                        {
                            buttons.Add(takepill());
                        }
                    }
                    if (state == (int)EnumDisWorkOrderState.staydrug)
                    {
                        if (code == "ZYY")
                        {
                            buttons.Add(send());
                        }
                    }
                    if (state == (int)EnumDisWorkOrderState.send)
                    {
                        if (code == "ZYY")
                        {
                            buttons.Add(end());
                        }
                    }
                    if (state == (int)EnumDisWorkOrderState.end)
                    {
                        if (code == "GLY")
                        {
                            buttons.Add(over());
                        }
                    }
                    break;
                case (int)EnumWorkOrder.OrtherDis:
                case (int)EnumWorkOrder.UrgDis:
                    //急标本配送
                    if (state == (int)EnumDisWorkOrderState.neworder)
                    {
                        if (code == "GLY")
                        {
                            buttons.Add(assign());
                        }
                    }
                    if (state == (int)EnumDisWorkOrderState.assign)
                    {
                        if (code == "ZYY")
                        {
                            buttons.Add(receive());
                        }
                    }
                    if (state == (int)EnumDisWorkOrderState.receive)
                    {
                        if (code == "ZYY")
                        {
                            buttons.Add(deal());
                        }
                    }
                    if (state == (int)EnumDisWorkOrderState.dealing)
                    {
                        if (code == "ZYY")
                        {
                            buttons.Add(end());
                        }
                    }

                    break;
                case (int)EnumWorkOrder.BloodDis:
                    //血制品配送
                    if (state == (int)EnumDisWorkOrderState.neworder)
                    {
                        if (code == "GLY")
                        {
                            buttons.Add(assign());
                        }
                    }
                    if (state == (int)EnumDisWorkOrderState.assign)
                    {
                        if (code == "ZYY")
                        {
                            buttons.Add(receive());
                        }
                    }
                    if (state == (int)EnumDisWorkOrderState.receive)
                    {
                        if (code == "ZYY")
                        {
                            buttons.Add(takeblood());
                        }
                    }
                    if (state == (int)EnumDisWorkOrderState.takeblood)
                    {
                        if (code == "ZYY")
                        {
                            buttons.Add(send());
                        }
                    }
                    if (state == (int)EnumDisWorkOrderState.send)
                    {
                        if (code == "ZYY")
                        {
                            buttons.Add(end());
                        }
                    }
                    if (state == (int)EnumDisWorkOrderState.end)
                    {
                        if (code == "GLY")
                        {
                            buttons.Add(over());
                        }
                    }
                    break;         
                  
            }
            return buttons;
        }
    }
}