Browse Source

整单备注优化好

张洋 1 month ago
parent
commit
f01178ba8f

BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/memo_btn_cancel_h.png


BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/memo_btn_cancel_n.png


BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/memo_btn_cancel_p.png


BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/memo_btn_ok_h.png


BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/memo_btn_ok_n.png


BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/memo_btn_ok_p.png


+ 25 - 34
bin/Win32/Debug/zhipuzi_pos_windows/skin/memo_edit_dlg.xml

@@ -1,16 +1,14 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
-<Window size="700,446" caption="0,0,0,44" roundcorner="4,4" shadowsize="3" showshadow="true">
-
-	0xFF60B177
+<Window size="700,480" caption="0,0,0,44" roundcorner="4,4" shadowsize="3" showshadow="true">
 
 	<VerticalLayout bkimage="shoukuan_bkg.png" >
 
 		<HorizontalLayout name="shoukuan_title_bkg" height="44" bkcolor="0xFF60B177">
 
-			<Label name="memo_dlg_title" text="" height="44" align="center" valign="center" padding="0,0,0,0" textcolor="#FFFFFFFF" font="22"/>
+			<Label name="memo_dlg_title" text="" height="44" align="left" valign="center" textpadding="16,0,0,0" textcolor="#FFFFFFFF" font="16"/>
 
-			<Button name="closebtn" keyboard="false" padding="0,13,15,0" width="16" height="16" normalimage="file='close_normal.png'" hotimage="file='close_hover.png'" pushedimage="file='close_normal.png'"/>
+			<Button name="closebtn" keyboard="false" padding="0,14,16,0" width="16" height="16" normalimage="file='close_normal.png'" hotimage="file='close_hover.png'" pushedimage="file='close_normal.png'"/>
 
 		</HorizontalLayout>
 
@@ -20,45 +18,37 @@
 
 			<VerticalLayout>
 
-				<HorizontalLayout height="22" padding="30,16,30,0">
-
-					<Label name="preset_title" text="快捷选择" maxheight="22" width="80" align="left" valign="center" font="13" textcolor="#FF5F6368"/>
-
-					<Label name="preset_count" text="已选 0 条" maxheight="22" align="right" valign="center" font="12" textcolor="#FF2E9B5C"/>
-
-				</HorizontalLayout>
-
-
-
-				<TileLayout name="memo_preset" height="154" padding="30,10,30,0" itemsize="98,34" childpadding="6"/>
-
+					<HorizontalLayout height="18" padding="24,20,24,10">
+						<Label text="口味" maxheight="18" width="80" align="left" valign="center" font="13" textcolor="#FF5F6368"/>
+					</HorizontalLayout>
+					<TileLayout name="memo_preset_kouwei" height="40" padding="24,0,24,16" itemsize="73,40" childpadding="9"/>
 
+					<HorizontalLayout height="18" padding="24,0,24,10">
+						<Label text="忌口" maxheight="18" width="80" align="left" valign="center" font="13" textcolor="#FF5F6368"/>
+					</HorizontalLayout>
+					<TileLayout name="memo_preset_jikou" height="40" padding="24,0,24,16" itemsize="73,40" childpadding="9"/>
 
-				<Label name="name" text="补充说明(可不填)" height="22" padding="30,16,30,0" align="left" font="13" textcolor="#FF5F6368"/>
+					<HorizontalLayout height="18" padding="24,0,24,10">
+						<Label text="其他" maxheight="18" width="80" align="left" valign="center" font="13" textcolor="#FF5F6368"/>
+					</HorizontalLayout>
+					<TileLayout name="memo_preset_qita" height="40" padding="24,0,24,16" itemsize="73,40" childpadding="9"/>
 
 
+					<Label name="name" text="备注内容" height="18" padding="24,0,24,8" align="left" font="13" textcolor="#FF5F6368"/>
 
-				<Edit name="content" width="640" height="50" padding="30,8,30,0" bkcolor="#FFF2F2F2" nativebkcolor="#FFF2F2F2" font="22"/>
+					<Edit name="content" width="652" height="50" padding="24,0,24,18" bkcolor="#FFF2F2F2" nativebkcolor="#FFF2F2F2" textpadding="14,3,14,3" font="14"/>
 
+					<Label name="errinfo" text="" height="18" width="600" float="true" pos="24,392,624,410" align="left" textcolor="#FFFF0000" visible="false"/>
 
+					<HorizontalLayout height="46" padding="24,0,24,24">
 
-				<Label name="errinfo" text="" height="60" width="250" float="true" pos="30,150,280,290" align="left" textcolor="#FFFF0000" visible="false"/>
+						<Button name="cancel" text="取消" textcolor="#FF5F6368" maxheight="46" width="320" font="15" normalimage="file='memo_btn_cancel_n.png' corner='6,6,6,6'" hotimage="file='memo_btn_cancel_h.png' corner='6,6,6,6'" pushedimage="file='memo_btn_cancel_p.png' corner='6,6,6,6'"/>
 
+						<Control width="12"></Control>
 
+						<Button name="save" align="center" text="确认" textcolor="#FFFFFFFF" maxheight="46" width="320" font="15" normalimage="file='memo_btn_ok_n.png' corner='6,6,6,6'" hotimage="file='memo_btn_ok_h.png' corner='6,6,6,6'" pushedimage="file='memo_btn_ok_p.png' corner='6,6,6,6'" />
 
-				<HorizontalLayout height="56" padding="30,16,30,20">
-
-					<Control></Control>
-
-					<Button name="cancel" text="取消" textcolor="#FF5F6368" maxheight="50" width="200" font="15" normalimage="file='btn_border_white.png' corner='5,5,5,5'" hotimage="file='btn_border_white_Hover.png' corner='5,5,5,5'" pushedimage="file='btn_border_white_Click.png' corner='5,5,5,5'"/>
-
-					<Control width="20"></Control>
-
-					<Button name="save" align="center" text="确认" textcolor="#FFFFFFFF" maxheight="50" width="200" font="15" normalimage="file='btn_green_zhengchang.png' corner='5,5,5,5'" hotimage="file='btn_green_xuanfu.png' corner='5,5,5,5'" pushedimage="file='btn_green_dianji.png' corner='5,5,5,5'" />
-
-					<Control></Control>
-
-				</HorizontalLayout>
+					</HorizontalLayout>
 
 			</VerticalLayout>
 
@@ -68,4 +58,5 @@
 
 	</VerticalLayout>
 
-</Window>
+</Window>
+

BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/memo_tag_h.png


BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/memo_tag_n.png


BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/memo_tag_p.png


BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/tag_pill_h.png


BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/tag_pill_n.png


BIN
bin/Win32/Debug/zhipuzi_pos_windows/skin/tag_pill_p.png


BIN
zhipuzi_pos_windows/resource/skin.zip


+ 37 - 133
zhipuzi_pos_windows/wnd/CMemoWnd.cpp

@@ -1,7 +1,7 @@
 #include "pch.h"
 #include "CMemoWnd.h"
 
-//预设备注文案(24 条):0~3 辣度四档(互斥)、4~7 咸淡、8~15 忌口、16~23 出品与打包
+// 预设备注文案(24 条):0~7 口味、8~15 忌口、16~23 其他
 const wchar_t* CMemoWnd::PRESET_MEMO[CMemoWnd::PRESET_COUNT] = {
 	L"免辣", L"微辣", L"中辣", L"特辣", L"少盐", L"少油", L"少糖", L"少醋",
 	L"免香菜", L"免葱", L"免蒜", L"免姜", L"免花生", L"免芝麻", L"免辣油", L"免味精",
@@ -115,7 +115,6 @@ LRESULT CMemoWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandl
 	styleValue &= ~WS_CAPTION;
 	::SetWindowLong(*this, GWL_STYLE, styleValue | WS_CLIPSIBLINGS | WS_CLIPCHILDREN);
 
-	// 把自己的窗口句柄与窗口绘制管理器挂接在一起
 	m_pm.Init(m_hWnd);
 
 	m_pm.AddPreMessageFilter(this);
@@ -125,10 +124,8 @@ LRESULT CMemoWnd::OnCreate(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandl
 	CControlUI* pRoot = builder.Create(_T("memo_edit_dlg.xml"), (UINT)0, NULL, &m_pm);
 	ASSERT(pRoot && "Failed to parse XML");
 
-	// 把这些控件绘制到本窗口上
 	m_pm.AttachDialog(pRoot);
 
-	// 把自己加入到CPaintManagerUI的m_aNotifiers数组中,用于处理Notify函数
 	m_pm.AddNotifier(this);
 
 	Init();
@@ -158,7 +155,7 @@ void CMemoWnd::Notify(TNotifyUI& msg)
 		}
 		else if (senderName == _T("memo_preset_item"))
 		{
-			TogglePresetTag((int)msg.pSender->GetTag());
+			AppendPresetText((int)msg.pSender->GetTag());
 			return;
 		}
 	}
@@ -170,32 +167,30 @@ void CMemoWnd::Notify(TNotifyUI& msg)
 		pFukuanEdit->SetFocus();
 	}
 
-	//加上这句,才支持虚拟键盘
 	CModalWnd::Notify(msg);
 }
 
 void CMemoWnd::Init()
 {
-	for (int i = 0; i < PRESET_COUNT; i++)
-	{
-		m_presetSelected[i] = false;
-	}
-
 	InitPresetTags();
-
-	UpdatePresetCount();
 }
 
 void CMemoWnd::InitPresetTags()
 {
-	CTileLayoutUI* pTile = static_cast<CTileLayoutUI*>(m_pm.FindControl(_T("memo_preset")));
-	if (pTile == NULL)
-	{
-		return;
-	}
+	CTileLayoutUI* pTiles[3] = {
+		static_cast<CTileLayoutUI*>(m_pm.FindControl(_T("memo_preset_kouwei"))),
+		static_cast<CTileLayoutUI*>(m_pm.FindControl(_T("memo_preset_jikou"))),
+		static_cast<CTileLayoutUI*>(m_pm.FindControl(_T("memo_preset_qita")))
+	};
 
 	for (int i = 0; i < PRESET_COUNT; i++)
 	{
+		int nGroup = i / 8;
+		if (nGroup < 0 || nGroup >= 3 || pTiles[nGroup] == NULL)
+		{
+			continue;
+		}
+
 		CButtonUI* pBtn = new CButtonUI;
 
 		pBtn->SetName(_T("memo_preset_item"));
@@ -203,121 +198,57 @@ void CMemoWnd::InitPresetTags()
 		pBtn->SetTag((UINT_PTR)i);
 		pBtn->SetFont(13);
 
-		pTile->Add(pBtn);
-
-		UpdatePresetTagStyle(i);
-	}
-}
-
-void CMemoWnd::TogglePresetTag(int nIndex)
-{
-	if (nIndex < 0 || nIndex >= PRESET_COUNT)
-	{
-		return;
-	}
-
-	m_presetSelected[nIndex] = !m_presetSelected[nIndex];
+		// 方案 B:不维护选中态,标签使用抗锯齿 PNG 九宫格
+		// 按设计稿:73×40 白底圆角矩形(圆角 8)+ 1px #E8EAED 描边,源尺寸=目标尺寸无拉伸。
+		pBtn->SetNormalImage(_T("file='memo_tag_n.png' corner='8,8,8,8'"));
+		pBtn->SetHotImage(_T("file='memo_tag_h.png' corner='8,8,8,8'"));
+		pBtn->SetPushedImage(_T("file='memo_tag_p.png' corner='8,8,8,8'"));
+		pBtn->SetTextColor(0xFF1F2329);
+		pBtn->SetHotTextColor(0xFF1F2329);
+		pBtn->SetPushedTextColor(0xFF1F2329);
+		pBtn->SetFocusedTextColor(0xFF1F2329);
 
-	//辣度四档(免辣/微辣/中辣/特辣)互斥,避免出现「免辣、特辣」这种矛盾备注
-	if (m_presetSelected[nIndex] && nIndex < 4)
-	{
-		for (int i = 0; i < 4; i++)
-		{
-			if (i != nIndex && m_presetSelected[i])
-			{
-				m_presetSelected[i] = false;
-				UpdatePresetTagStyle(i);
-			}
-		}
+		pTiles[nGroup]->Add(pBtn);
 	}
-
-	UpdatePresetTagStyle(nIndex);
-
-	UpdatePresetCount();
 }
 
-void CMemoWnd::UpdatePresetTagStyle(int nIndex)
+void CMemoWnd::AppendPresetText(int nIndex)
 {
 	if (nIndex < 0 || nIndex >= PRESET_COUNT)
 	{
 		return;
 	}
 
-	CTileLayoutUI* pTile = static_cast<CTileLayoutUI*>(m_pm.FindControl(_T("memo_preset")));
-	if (pTile == NULL)
+	CEditUI* pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
+	if (pEdit == NULL)
 	{
 		return;
 	}
 
-	CButtonUI* pBtn = static_cast<CButtonUI*>(pTile->GetItemAt(nIndex));
-	if (pBtn == NULL)
-	{
-		return;
-	}
+	std::wstring wsEdit = pEdit->GetText();
+	std::wstring wsItem = PRESET_MEMO[nIndex];
 
-	//三态必须都显式设:main.xml 的 <Default name="Button"> 会给所有 Button 套绿色三态图
-	if (m_presetSelected[nIndex])
+	if (wsEdit.empty())
 	{
-		pBtn->SetNormalImage(_T("file='tag_pill_s.png' corner='17,17,17,17'"));
-		pBtn->SetHotImage(_T("file='tag_pill_s.png' corner='17,17,17,17'"));
-		pBtn->SetPushedImage(_T("file='tag_pill_sp.png' corner='17,17,17,17'"));
-		pBtn->SetTextColor(0xFFFFFFFF);
-		pBtn->SetHotTextColor(0xFFFFFFFF);
-		pBtn->SetPushedTextColor(0xFFFFFFFF);
-		pBtn->SetFocusedTextColor(0xFFFFFFFF);
+		wsEdit = wsItem;
 	}
 	else
 	{
-		pBtn->SetNormalImage(_T("file='tag_pill_n.png' corner='17,17,17,17'"));
-		pBtn->SetHotImage(_T("file='tag_pill_h.png' corner='17,17,17,17'"));
-		pBtn->SetPushedImage(_T("file='tag_pill_h.png' corner='17,17,17,17'"));
-		pBtn->SetTextColor(0xFF1F2329);
-		pBtn->SetHotTextColor(0xFF1F2329);
-		pBtn->SetPushedTextColor(0xFF1F2329);
-		pBtn->SetFocusedTextColor(0xFF1F2329);
-	}
-
-	pBtn->NeedUpdate();
-}
-
-void CMemoWnd::UpdatePresetCount()
-{
-	int nCount = 0;
-	for (int i = 0; i < PRESET_COUNT; i++)
-	{
-		if (m_presetSelected[i])
+		// 避免用户手动输入了末尾「、」导致出现「、、」
+		if (wsEdit.back() != L'、')
 		{
-			nCount++;
+			wsEdit += L'、';
 		}
+		wsEdit += wsItem;
 	}
 
-	CLabelUI* pLabel = static_cast<CLabelUI*>(m_pm.FindControl(_T("preset_count")));
-	if (pLabel != NULL)
-	{
-		//不用 swprintf_s(依赖 <cstdio>,本项目 pch 不保证引入),改 std::to_wstring 拼接
-		std::wstring strCount = L"已选 " + std::to_wstring(nCount) + L" 条";
-		pLabel->SetText(strCount.c_str());
-	}
+	pEdit->SetText(wsEdit.c_str());
 }
 
 void CMemoWnd::SetContent(std::string content)
 {
 	std::wstring wsAll = CLewaimaiString::UTF8ToUnicode(content);
 
-	//每次打开都是全新状态:快捷选择的选中态一律清空,不保留上次的选择
-	for (int i = 0; i < PRESET_COUNT; i++)
-	{
-		m_presetSelected[i] = false;
-	}
-
-	for (int i = 0; i < PRESET_COUNT; i++)
-	{
-		UpdatePresetTagStyle(i);
-	}
-
-	UpdatePresetCount();
-
-	//已有备注整体填回输入框,供店员继续补充或删改(不填会丢掉上次手动写的内容)
 	CEditUI* pEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
 	if (pEdit != NULL)
 	{
@@ -341,7 +272,7 @@ void CMemoWnd::StartYanzheng()
 	CEditUI* pContent = static_cast<CEditUI*>(m_pm.FindControl(_T("content")));
 	std::wstring wsReason = pContent->GetText();
 
-	//去掉首尾空白,避免只输入空格时拼出多余的「、」
+	// 去掉首尾空白,避免只输入空格时保存空串
 	size_t nBeg = wsReason.find_first_not_of(L" \t\r\n");
 	if (nBeg == std::wstring::npos)
 	{
@@ -353,34 +284,7 @@ void CMemoWnd::StartYanzheng()
 		wsReason = wsReason.substr(nBeg, nEnd - nBeg + 1);
 	}
 
-	//快捷选择在前,手动补充在后,用「、」连接
-	std::wstring wsAll;
-	for (int i = 0; i < PRESET_COUNT; i++)
-	{
-		if (!m_presetSelected[i])
-		{
-			continue;
-		}
-
-		if (!wsAll.empty())
-		{
-			wsAll += L'、';
-		}
-
-		wsAll += PRESET_MEMO[i];
-	}
-
-	if (!wsReason.empty())
-	{
-		if (!wsAll.empty())
-		{
-			wsAll += L'、';
-		}
-
-		wsAll += wsReason;
-	}
-
-	m_content = CLewaimaiString::UnicodeToUTF8(wsAll);
+	m_content = CLewaimaiString::UnicodeToUTF8(wsReason);
 
 	Close(IDOK);
 }

+ 9 - 19
zhipuzi_pos_windows/wnd/CMemoWnd.h

@@ -19,10 +19,7 @@ public:
 
 	void OnFinalMessage(HWND /*hWnd*/)
 	{
-		//WindowImplBase::OnFinalMessage(hWnd);
 		m_pm.RemovePreMessageFilter(this);
-
-		//delete this;
 	};
 
 	void Init();
@@ -31,22 +28,14 @@ public:
 
 	void SetTitle(std::wstring title);
 
-	//打开弹窗前把已有备注填回输入框;快捷选择的选中态一律清空,不保留上次选择
+	// 打开弹窗前把已有备注填回输入框
 	void SetContent(std::string content);
 
-	//预设备注快捷选择(方案 C:24 条药丸,6 列 x 4 行)
+	// 预设备注快捷选择(方案 B:24 条药丸分 3 组平铺)
 	void InitPresetTags();
 
-	void TogglePresetTag(int nIndex);
-
-	void UpdatePresetTagStyle(int nIndex);
-
-	void UpdatePresetCount();
-
-	//预设备注条数(0~3 是辣度四档,互斥)
-	static const int PRESET_COUNT = 24;
-
-	static const wchar_t* PRESET_MEMO[PRESET_COUNT];
+	// 把第 nIndex 条预设备注追加到「备注内容」输入框
+	void AppendPresetText(int nIndex);
 
 	void Notify(TNotifyUI& msg);
 
@@ -81,7 +70,7 @@ public:
 
 	void StartYanzheng();
 
-	//处理键盘捕捉结果
+	// 处理键盘捕捉结果
 	void HandleTextCapture(std::string content)
 	{
 
@@ -94,7 +83,8 @@ public:
 
 	std::wstring m_errorInfo;
 
-	//每条预设备注是否选中
-	bool m_presetSelected[PRESET_COUNT];
-};
+	// 预设备注文案总数(3 组 x 8 条)
+	static const int PRESET_COUNT = 24;
 
+	static const wchar_t* PRESET_MEMO[PRESET_COUNT];
+};