|
|
@@ -17,7 +17,16 @@ CShangpinCreatePageUI::~CShangpinCreatePageUI()
|
|
|
//初始化当前页面的展示,处理默认展示效果,在页面被加载的时候调用
|
|
|
void CShangpinCreatePageUI::InitShow()
|
|
|
{
|
|
|
- //一个个初始化新建商品的默认值
|
|
|
+ //一个个初始化新建商品的默认值(每次都要清空)
|
|
|
+
|
|
|
+ //商品名字
|
|
|
+ CEditUI* pName = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_name_edit"));
|
|
|
+ pName->SetText(L"");
|
|
|
+ pName->SetFocus();
|
|
|
+
|
|
|
+ //商品序号
|
|
|
+ CEditUI* pXuhao = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_xuhao_edit"));
|
|
|
+ pXuhao->SetText(L"");
|
|
|
|
|
|
//初始化商品分类
|
|
|
CComboUI* com_fenlei = static_cast<CComboUI*>(this->FindSubControl(_T("shangpin_create_page_foodtype")));
|
|
|
@@ -51,6 +60,71 @@ void CShangpinCreatePageUI::InitShow()
|
|
|
}
|
|
|
|
|
|
com_fenlei->SetText(CLewaimaiString::UTF8ToUnicode(first_food_name).c_str());
|
|
|
+
|
|
|
+ //商品条码
|
|
|
+ CEditUI* pTiaoma = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_barcode_edit"));
|
|
|
+ pXuhao->SetText(L"");
|
|
|
+
|
|
|
+ //商品价格
|
|
|
+ CEditUI* pPrice = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_price_edit"));
|
|
|
+ pPrice->SetText(L"");
|
|
|
+
|
|
|
+ //商品单位
|
|
|
+ CEditUI* pDanwei = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_unit_edit"));
|
|
|
+ pDanwei->SetText(L"");
|
|
|
+
|
|
|
+ //是否称重
|
|
|
+ CCheckBoxUI* pChengzhong = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_chengzhong"));
|
|
|
+ pChengzhong->Selected(false, false);
|
|
|
+
|
|
|
+ //plu编码
|
|
|
+ CEditUI* pPlu = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_plu"));
|
|
|
+ pPlu->SetText(L"");
|
|
|
+
|
|
|
+ //商品编码
|
|
|
+ CEditUI* pShangpin = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_shangpinbianma"));
|
|
|
+ pShangpin->SetText(L"");
|
|
|
+
|
|
|
+ //库存类型
|
|
|
+ CCheckBoxUI* pKucuntype = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_kucun_open"));
|
|
|
+ pKucuntype->Selected(true, false);
|
|
|
+
|
|
|
+ //当前库存
|
|
|
+ CEditUI* pDangqiankucun = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_kucun_now"));
|
|
|
+ pDangqiankucun->SetText(L"");
|
|
|
+
|
|
|
+ //商品状态
|
|
|
+ CCheckBoxUI* pStatus = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_status_normal"));
|
|
|
+ pStatus->Selected(true, false);
|
|
|
+
|
|
|
+ //进货价
|
|
|
+ CEditUI* pJinhuojia = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_buyingprice_edit"));
|
|
|
+ pJinhuojia->SetText(L"");
|
|
|
+
|
|
|
+ //进货价模式
|
|
|
+ CCheckBoxUI* pJinhuomoshi = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_jinhuojia_normal"));
|
|
|
+ pJinhuomoshi->Selected(true, false);
|
|
|
+
|
|
|
+ //在哪些地方显示
|
|
|
+ CCheckBoxUI* pShouyinji = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_showplace_shouyinji"));
|
|
|
+ CCheckBoxUI* pWaimai = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_showplace_waimai"));
|
|
|
+ CCheckBoxUI* pSaomaidancan = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_showplace_saomadiancan"));
|
|
|
+
|
|
|
+ pShouyinji->Selected(true, false);
|
|
|
+ pWaimai->Selected(true, false);
|
|
|
+ pSaomaidancan->Selected(true, false);
|
|
|
+
|
|
|
+ //是否开启打包费
|
|
|
+ CCheckBoxUI* pDabao = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_is_dabao"));
|
|
|
+ pDabao->Selected(false, false);
|
|
|
+
|
|
|
+ //打包费
|
|
|
+ CEditUI* pDaobaofei = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_dabao_money"));
|
|
|
+ pDaobaofei->SetText(L"");
|
|
|
+
|
|
|
+ //商品加工方式
|
|
|
+ CCheckBoxUI* pJiagongfangshi = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_fangan_1"));
|
|
|
+ pJiagongfangshi->Selected(true, false);
|
|
|
}
|
|
|
|
|
|
//处理按钮点击类事件
|
|
|
@@ -307,7 +381,231 @@ void CShangpinCreatePageUI::SetPos(RECT rc, bool bNeedInvalidate)
|
|
|
void CShangpinCreatePageUI::StartSave()
|
|
|
{
|
|
|
//把参数一个个读出来
|
|
|
+
|
|
|
+ //商品名字
|
|
|
CEditUI* pName = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_name_edit"));
|
|
|
std::wstring ws_name = pName->GetText();
|
|
|
- std::string name = CLewaimaiString::UnicodeToUTF8(ws_name);
|
|
|
+ m_name = CLewaimaiString::UnicodeToUTF8(ws_name);
|
|
|
+
|
|
|
+ //商品序号
|
|
|
+ CEditUI* pXuhao = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_xuhao_edit"));
|
|
|
+ std::wstring ws_xuhao = pXuhao->GetText();
|
|
|
+ m_xuhao = CLewaimaiString::UnicodeToUTF8(ws_xuhao);
|
|
|
+
|
|
|
+ //初始化商品分类
|
|
|
+ CComboUI* com_fenlei = static_cast<CComboUI*>(this->FindSubControl(_T("shangpin_create_page_foodtype")));
|
|
|
+ std::wstring ws_type = com_fenlei->GetText();
|
|
|
+ m_fenlei = CLewaimaiString::UnicodeToUTF8(ws_type);
|
|
|
+
|
|
|
+ //商品条码
|
|
|
+ CEditUI* pTiaoma = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_barcode_edit"));
|
|
|
+ std::wstring ws_tiaoma = pTiaoma->GetText();
|
|
|
+ m_tiaoma = CLewaimaiString::UnicodeToUTF8(ws_tiaoma);
|
|
|
+
|
|
|
+ //商品价格
|
|
|
+ CEditUI* pPrice = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_price_edit"));
|
|
|
+ std::wstring ws_price = pPrice->GetText();
|
|
|
+ m_price = CLewaimaiString::UnicodeToUTF8(ws_price);
|
|
|
+
|
|
|
+ //商品单位
|
|
|
+ CEditUI* pDanwei = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_unit_edit"));
|
|
|
+ std::wstring ws_danwei = pDanwei->GetText();
|
|
|
+ m_danwei = CLewaimaiString::UnicodeToUTF8(ws_danwei);
|
|
|
+
|
|
|
+ //是否称重
|
|
|
+ CCheckBoxUI* pChengzhong = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_chengzhong"));
|
|
|
+ m_is_chengzhong = pChengzhong->IsSelected();
|
|
|
+
|
|
|
+ //plu编码
|
|
|
+ CEditUI* pPlu = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_plu"));
|
|
|
+ std::wstring ws_plu = pPlu->GetText();
|
|
|
+ m_plu = CLewaimaiString::UnicodeToUTF8(ws_plu);
|
|
|
+
|
|
|
+ //商品编码
|
|
|
+ CEditUI* pShangpin = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_shangpinbianma"));
|
|
|
+ std::wstring ws_shangpin = pShangpin->GetText();
|
|
|
+ m_shangpinbianma = CLewaimaiString::UnicodeToUTF8(ws_shangpin);
|
|
|
+
|
|
|
+ //库存类型
|
|
|
+ CCheckBoxUI* pKucuntype = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_kucun_open"));
|
|
|
+ if (pKucuntype->IsSelected())
|
|
|
+ {
|
|
|
+ m_kucuntype = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_kucuntype = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ //当前库存
|
|
|
+ CEditUI* pDangqiankucun = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_kucun_now"));
|
|
|
+ std::wstring ws_dangqiankucun = pDangqiankucun->GetText();
|
|
|
+ m_dangqiankucun = CLewaimaiString::UnicodeToUTF8(ws_dangqiankucun);
|
|
|
+
|
|
|
+ //商品状态
|
|
|
+ CCheckBoxUI* pStatus = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_status_normal"));
|
|
|
+ if (pStatus->IsSelected())
|
|
|
+ {
|
|
|
+ m_status = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_status = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ //进货价
|
|
|
+ CEditUI* pJinhuojia = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_buyingprice_edit"));
|
|
|
+ std::wstring ws_jinhuojia = pJinhuojia->GetText();
|
|
|
+ m_jinhuojia = CLewaimaiString::UnicodeToUTF8(ws_jinhuojia);
|
|
|
+
|
|
|
+ //进货价模式
|
|
|
+ CCheckBoxUI* pJinhuomoshi = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_jinhuojia_normal"));
|
|
|
+ if (pJinhuomoshi->IsSelected())
|
|
|
+ {
|
|
|
+ m_jinhuo_type = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_jinhuo_type = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ //在哪些地方显示
|
|
|
+ CCheckBoxUI* pShouyinji = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_showplace_shouyinji"));
|
|
|
+ CCheckBoxUI* pWaimai = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_showplace_waimai"));
|
|
|
+ CCheckBoxUI* pSaomaidancan = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_showplace_saomadiancan"));
|
|
|
+
|
|
|
+ m_is_shouyinji_show = pShouyinji->IsSelected();
|
|
|
+ m_is_waimai_show = pWaimai->IsSelected();
|
|
|
+ m_is_saomadiancan_shou = pSaomaidancan->IsSelected();
|
|
|
+
|
|
|
+ //是否开启打包费
|
|
|
+ CCheckBoxUI* pDabao = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_is_dabao"));
|
|
|
+ m_is_dabao_fei = pDabao->IsSelected();
|
|
|
+
|
|
|
+ //打包费
|
|
|
+ CEditUI* pDaobaofei = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_dabao_money"));
|
|
|
+ std::wstring ws_dabaofei = pDaobaofei->GetText();
|
|
|
+ m_dabaofei = CLewaimaiString::UnicodeToUTF8(ws_dabaofei);
|
|
|
+
|
|
|
+ //商品加工方式
|
|
|
+ CCheckBoxUI* pJiagongfangshi_1 = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_fangan_1"));
|
|
|
+ CCheckBoxUI* pJiagongfangshi_2 = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_fangan_2"));
|
|
|
+ CCheckBoxUI* pJiagongfangshi_3 = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_fangan_3"));
|
|
|
+
|
|
|
+ if (pJiagongfangshi_1->IsSelected())
|
|
|
+ {
|
|
|
+ m_jiagong_type = 0;
|
|
|
+ }
|
|
|
+ else if (pJiagongfangshi_2->IsSelected())
|
|
|
+ {
|
|
|
+ m_jiagong_type = 1;
|
|
|
+ }
|
|
|
+ else if (pJiagongfangshi_3->IsSelected())
|
|
|
+ {
|
|
|
+ m_jiagong_type = 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ ShowError(L"正在保存商品...");
|
|
|
+
|
|
|
+ std::thread(&CShangpinCreatePageUI::HandleSave, this).detach();
|
|
|
+}
|
|
|
+
|
|
|
+void CShangpinCreatePageUI::HandleSave()
|
|
|
+{
|
|
|
+ std::map<string, string> params;
|
|
|
+
|
|
|
+ params["goods_name"] = m_name;
|
|
|
+ params["goods_tag"] = m_xuhao;
|
|
|
+ params["stock"] = m_dangqiankucun;
|
|
|
+ params["goods_price"] = m_price;
|
|
|
+
|
|
|
+ if (m_status == 0)
|
|
|
+ {
|
|
|
+ params["goods_status"] = "OPEN";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ params["goods_status"] = "CLOSED";
|
|
|
+ }
|
|
|
+
|
|
|
+ params["type_lv1_id"] = "";
|
|
|
+
|
|
|
+ if (m_kucuntype == 0)
|
|
|
+ {
|
|
|
+ params["stock_status"] = "1";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ params["stock_status"] = "0";
|
|
|
+ }
|
|
|
+
|
|
|
+ params["unit"] = m_danwei;
|
|
|
+
|
|
|
+ if (m_is_dabao_fei)
|
|
|
+ {
|
|
|
+ params["is_dabao"] = "1";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ params["is_dabao"] = "0";
|
|
|
+ }
|
|
|
+
|
|
|
+ params["dabao_money"] = m_dabaofei;
|
|
|
+
|
|
|
+ params["barcode"] = m_tiaoma;
|
|
|
+ params["buying_price"] = m_jinhuojia;
|
|
|
+
|
|
|
+ if (m_is_chengzhong)
|
|
|
+ {
|
|
|
+ params["is_weight"] = "1";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ params["is_weight"] = "0";
|
|
|
+ }
|
|
|
+
|
|
|
+ std::string response;
|
|
|
+
|
|
|
+ std::string url = "/goods/addgoods";
|
|
|
+ bool ret = CZhipuziHttpClient::GetInstance()->Request(url.c_str(), params, response);
|
|
|
+
|
|
|
+ if (ret == false)
|
|
|
+ {
|
|
|
+ ShowError(L"请求服务器失败,请检查网络设置!");
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Document document;
|
|
|
+ document.Parse(response.c_str());
|
|
|
+
|
|
|
+ if (document.HasParseError())
|
|
|
+ {
|
|
|
+ ShowError(L"服务器错误");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!document.HasMember("errcode") || !document.HasMember("errmsg") || !document.HasMember("data"))
|
|
|
+ {
|
|
|
+ ShowError(L"服务器错误");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Value& v_errcode = document["errcode"];
|
|
|
+ int errcode = v_errcode.GetInt();
|
|
|
+ if (errcode != 0)
|
|
|
+ {
|
|
|
+ ShowError(L"服务器错误");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Value& data = document["data"];
|
|
|
+
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void CShangpinCreatePageUI::ShowError(std::wstring msg)
|
|
|
+{
|
|
|
+ CLabelUI* pResult = static_cast<CLabelUI*>(this->FindSubControl(L"shangpin_create_page_save_result"));
|
|
|
+ pResult->SetText(L"正在保存商品...");
|
|
|
}
|