void OnConfirmClick()
    {
        //判断categroy 是否选择;
        if (m_CategoryDropdown.captionText.text == "Please Select")
        {
            FrameUtil.AddChild(GameObject.Find("Canvas/Other"), Resources.Load <GameObject>("NoticePanel")).GetComponent <NoticePanelLogic>().Init("categroy must be selected");
            return;
        }
        //查看是否选择了stage;
        bool flag = false;

        foreach (Transform child in m_StagesGrounp)
        {
            if (child.GetComponent <Toggle>().isOn)
            {
                flag = true;
                break;
            }
        }
        //判断是否选择了stage
        if (flag == false)
        {
            FrameUtil.AddChild(GameObject.Find("Canvas/Other"), Resources.Load <GameObject>("NoticePanel")).GetComponent <NoticePanelLogic>().Init("Stage must be selected");
            return;
        }

        //发送 ItemCategroyStageUpdate 更新这个Item的Categroy 和 stage信息;
        WWWForm form = new WWWForm();

        form.AddField("token", PlayerPrefs.GetString("token"));
        form.AddField("item_id", m_Item.id);
        form.AddField("category_id", m_CategroyMap[m_CategoryDropdown.captionText.text]);

        //如果Categroy改变过,那么新的m_item里面 就要更新Categroy
        if (m_CategroyMap[m_CategoryDropdown.captionText.text] != m_Item.category_id)
        {
            m_Item.category_id = m_CategroyMap[m_CategoryDropdown.captionText.text];
        }

        //Debug.Log(m_CategoryMap[m_CategoryDropdown.captionText.text]);

        //更新 新的Item 选择的 stage,这个是为了转json 数据存在的;
        List <MsgJson.UpdateItemStageId> stageId = new List <MsgJson.UpdateItemStageId>();

        foreach (Transform child in m_StagesGrounp)
        {
            if (child.GetComponent <Toggle>().isOn)
            {
                MsgJson.UpdateItemStageId id = new MsgJson.UpdateItemStageId();
                id.id = child.GetComponent <ItemStageLogic>().m_Id;
                stageId.Add(id);

                //保存这个item 的stage信息传给CommonPartsSelectPanel;
                m_ItemStagesList.Add(id.id);
            }
        }

        MsgJson.UpdateItemStage updateItemStage = new MsgJson.UpdateItemStage();
        updateItemStage.stages = stageId.ToArray();

        form.AddField("msg", JsonUtility.ToJson(updateItemStage));

        //发送 更新这个item的信息;
        HttpManager.Instance.SendPostForm(ProjectConst.ItemCategoryStageUpdate, form);

        //刷新这个供货商下的所有item;
        WWWForm form1 = new WWWForm();

        form1.AddField("token", PlayerPrefs.GetString("token"));
        form1.AddField("id", ControlPlayer.Instance.m_CurrentSupplierID);

        HttpManager.Instance.SendPostForm(ProjectConst.GetItem, form1);

        //再保留数据;
        //删除之前的ItemStages
        int check = 1;

        while (check == 1)
        {
            check = 0;
            foreach (var i in ControlPlayer.Instance.m_SpStageDisplayList)
            {
                if (i.itemId == m_Item.id)
                {
                    ControlPlayer.Instance.m_SpStageDisplayList.Remove(i);
                    check = 1;
                    break;
                }
            }
        }

        //保留stage
        foreach (var v in m_ItemStagesList)
        {
            ControlPlayer.SpStageDisplay spStageDisplay = new ControlPlayer.SpStageDisplay();
            spStageDisplay.itemId  = m_Item.id;
            spStageDisplay.stegeId = v;
            spStageDisplay.rank    = m_CategoryRankMap[m_CategoryDropdown.captionText.text];
            spStageDisplay.sizeId  = ControlPlayer.Instance.m_CurrentChoiceSizeId;

            int added = 0;
            if (ControlPlayer.Instance.m_SpStageDisplayList.Count > 0)
            {
                for (int x = 0; x < ControlPlayer.Instance.m_SpStageDisplayList.Count; x++)
                {
                    if (System.Convert.ToInt32(ControlPlayer.Instance.m_SpStageDisplayList[x].rank) >= System.Convert.ToInt32(spStageDisplay.rank))
                    {
                        if (x == 0)
                        {
                            ControlPlayer.Instance.m_SpStageDisplayList.Insert(0, spStageDisplay);
                            added = 1;
                            break;
                        }
                        else
                        {
                            ControlPlayer.Instance.m_SpStageDisplayList.Insert(x, spStageDisplay);
                            added = 1;
                            break;
                        }
                    }
                }
                if (added == 0)
                {
                    ControlPlayer.Instance.m_SpStageDisplayList.Add(spStageDisplay);
                }
            }
            else
            {
                ControlPlayer.Instance.m_SpStageDisplayList.Add(spStageDisplay);
            }
        }

        //保留item 这个才是 正真要显示在左边的内容;
        ControlPlayer.SpItem spItem = new ControlPlayer.SpItem();

        spItem.item              = m_Item;
        spItem.qty               = m_QtyEndEdit;
        spItem.categoryRank      = m_CategoryRankMap[m_CategoryDropdown.captionText.text];
        spItem.displayToCustomer = m_bViewByCustomer;
        spItem.sizeId            = ControlPlayer.Instance.m_CurrentChoiceSizeId;

        //判断左边list里面有没有 这个item选项;
        foreach (var i in ControlPlayer.Instance.m_SpItemList)
        {
            //如果有就Remove掉;
            if (i.item.id == spItem.item.id)
            {
                ControlPlayer.Instance.m_SpItemList.Remove(i);
                break;
            }
        }

        //添加这个item;
        ControlPlayer.Instance.m_SpItemList.Add(spItem);



        //添加到左测面板.调用 CommonPartsSelectionPanel的函数;
        GameObject.Find("SpecialPartsSelectionPanel(Clone)").GetComponent <SpecialpartsSelectionPanel>().AddPartItem();//(m_Item, m_QtyEndEdit, m_ItemStagesList);

        //最后删除面板;
        Destroy(gameObject);
    }
Ejemplo n.º 2
0
    //得到 之前添加的所有车型数据,在转换到 那3个全局数据中 com sp op;
    void OnGetModelPartDetail(string data)
    {
        ControlPlayer.Instance.m_SaveAddModelMsg = JsonUtility.FromJson <MsgJson.SaveAddModelMsg>(data);

        //转换数据;
        ControlPlayer.Instance.m_AddModelPanelSaveData = new ControlPlayer.AddModelPanelSaveData();
        //转model;
        ControlPlayer.Instance.m_AddModelPanelSaveData.m_Brand       = ControlPlayer.Instance.m_SaveAddModelMsg.models[0].brand;
        ControlPlayer.Instance.m_AddModelPanelSaveData.m_Model       = ControlPlayer.Instance.m_SaveAddModelMsg.models[0].name;
        ControlPlayer.Instance.m_AddModelPanelSaveData.m_ModelCode   = ControlPlayer.Instance.m_SaveAddModelMsg.models[0].code;
        ControlPlayer.Instance.m_AddModelPanelSaveData.m_ModelYear   = ControlPlayer.Instance.m_SaveAddModelMsg.models[0].model_year;
        ControlPlayer.Instance.m_AddModelPanelSaveData.m_ChassisType = ControlPlayer.Instance.m_SaveAddModelMsg.models[0].chassis_type;
        ControlPlayer.Instance.m_Version = int.Parse(ControlPlayer.Instance.m_SaveAddModelMsg.models[0].version);

        //转size;
        foreach (var v in ControlPlayer.Instance.m_SaveAddModelMsg.size)
        {
            MsgJson.Size tempSize = new MsgJson.Size();
            tempSize.id           = v.size_id;
            tempSize.size         = v.size;
            tempSize.doorPosition = v.doorPosition;
            tempSize.type         = v.type;
            tempSize.note         = v.note;
            ControlPlayer.Instance.m_AddModelPanelSaveData.m_Size.Add(tempSize);
        }

        //转 part_com
        foreach (var v in ControlPlayer.Instance.m_SaveAddModelMsg.part_com)
        {
            ControlPlayer.CommonItem comItem = new ControlPlayer.CommonItem();

            comItem.item.id           = v.item_id;
            comItem.item.product_code = v.product_code;
            comItem.item.description  = v.description;
            //comItem.item.units
            comItem.item.unit_price  = v.unit_price;
            comItem.item.discount    = v.discount;
            comItem.item.category_id = v.category_id;
            comItem.qty = v.qty;
            if (v.show == "Yes")
            {
                comItem.displayToCustomer = true;
            }
            else
            {
                comItem.displayToCustomer = false;
            }
            comItem.categoryRank = v.rank;

            ControlPlayer.Instance.m_CommonItemList.Add(comItem);
        }

        //转 part_sp
        foreach (var v in ControlPlayer.Instance.m_SaveAddModelMsg.part_sp)
        {
            ControlPlayer.SpItem spItem = new ControlPlayer.SpItem();
            spItem.item.id           = v.item_id;
            spItem.item.product_code = v.product_code;
            spItem.item.description  = v.description;
            //comItem.item.units
            spItem.item.unit_price  = v.unit_price;
            spItem.item.discount    = v.discount;
            spItem.item.category_id = v.category_id;

            spItem.qty          = v.qty;
            spItem.categoryRank = v.rank;
            if (v.show == "Yes")
            {
                spItem.displayToCustomer = true;
            }
            else
            {
                spItem.displayToCustomer = false;
            }
            spItem.sizeId = v.size_id;

            ControlPlayer.Instance.m_SpItemList.Add(spItem);
        }


        //转 part_Op
        foreach (var v in ControlPlayer.Instance.m_SaveAddModelMsg.part_op)
        {
            ControlPlayer.OpItem opItem = new ControlPlayer.OpItem();
            opItem.item.id           = v.item_id;
            opItem.item.product_code = v.product_code;
            opItem.item.description  = v.description;
            //comItem.item.units
            opItem.item.unit_price  = v.unit_price;
            opItem.item.discount    = v.discount;
            opItem.item.category_id = v.category_id;

            opItem.qty          = v.qty;
            opItem.categoryRank = v.rank;
            if (v.show == "Yes")
            {
                opItem.displayToCustomer = true;
            }
            else
            {
                opItem.displayToCustomer = false;
            }
            opItem.sizeId             = v.size_id;
            opItem.name               = v.option_name;
            opItem.standardOrOptional = v.stand;
            opItem.Extra              = v.extra;

            ControlPlayer.Instance.m_OpItemList.Add(opItem);
        }

        //转stagedisplay;
        ControlPlayer.Instance.m_StageDisplayList.Clear();
        ControlPlayer.Instance.m_SpStageDisplayList.Clear();
        ControlPlayer.Instance.m_OpStageDisplayList.Clear();

        foreach (var v in ControlPlayer.Instance.m_SaveAddModelMsg.StageDisplay)
        {
            ControlPlayer.StageDisplay stageDisplay = new ControlPlayer.StageDisplay();
            stageDisplay.itemId  = v.itemId;
            stageDisplay.rank    = v.rank;
            stageDisplay.stegeId = v.stegeId;
            ControlPlayer.Instance.m_StageDisplayList.Add(stageDisplay);
        }
        foreach (var v in ControlPlayer.Instance.m_SaveAddModelMsg.SpStageDisplay)
        {
            ControlPlayer.SpStageDisplay stageDisplay = new ControlPlayer.SpStageDisplay();
            stageDisplay.itemId  = v.itemId;
            stageDisplay.rank    = v.rank;
            stageDisplay.stegeId = v.stegeId;
            stageDisplay.sizeId  = v.sizeId;
            ControlPlayer.Instance.m_SpStageDisplayList.Add(stageDisplay);
        }
        foreach (var v in ControlPlayer.Instance.m_SaveAddModelMsg.OpStageDisplay)
        {
            ControlPlayer.OpStageDisplay stageDisplay = new ControlPlayer.OpStageDisplay();
            stageDisplay.itemId  = v.itemId;
            stageDisplay.rank    = v.rank;
            stageDisplay.stegeId = v.stegeId;
            stageDisplay.sizeId  = v.sizeId;
            stageDisplay.name    = v.name;
            ControlPlayer.Instance.m_OpStageDisplayList.Add(stageDisplay);
        }
        //转 itemstage
        ControlPlayer.Instance.m_ItemStages        = new MsgJson.ItemStages();
        ControlPlayer.Instance.m_ItemStages.stages = ControlPlayer.Instance.m_SaveAddModelMsg.ItemStagesList;

        if (m_ButtonText == "MakeChanges")
        {
            ControlPlayer.Instance.m_Version += 1;
        }
        else if (m_ButtonText == "UpdateToNewModelYear")
        {
            ControlPlayer.Instance.m_Version = 1;
            ControlPlayer.Instance.m_AddModelPanelSaveData.m_ModelYear += 1;
        }

        //加载AddModel Panel;
        FrameUtil.AddChild(GameObject.Find("Canvas/Stack"), Resources.Load <GameObject>("AddModelPanel"));
    }