From bb4dc0fab56e542e784311f95ae6d7e7dd785a8f Mon Sep 17 00:00:00 2001
From: xj qian <qianxj15@sina.com>
Date: 星期二, 29 十月 2024 17:10:33 +0800
Subject: [PATCH] update

---
 jrj/project/total3/ViewTotalWin.cpp |  524 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 524 insertions(+), 0 deletions(-)

diff --git a/jrj/project/total3/ViewTotalWin.cpp b/jrj/project/total3/ViewTotalWin.cpp
new file mode 100644
index 0000000..768456e
--- /dev/null
+++ b/jrj/project/total3/ViewTotalWin.cpp
@@ -0,0 +1,524 @@
+#include <wobject/xwin.hpp>
+#include <xcontrol/xdwgrid.hpp>
+#include <xcontrol/xoffice.hpp>
+#include <xcontrol/xcell.hpp>
+#include <xcontrol/xflowchart.hpp>
+#include <xcontrol/ximageview.hpp>
+#include <xcontrol/xcombobox.hpp>
+
+#include <vbusiness/vutil/publiccode.vutil.vbusiness.hpp>
+#include "viewobject/view.base.hpp"
+
+
+using xml = KXMLDOMDocument;
+class __declspec(dllexport) ViewTotalWin : public xwin
+{
+public:
+	ViewTotalWin(void* implPtr, HWND hWnd) :xwin(implPtr, hWnd) {}
+public:
+	static ViewTotalWin* CreateInstance(void* implPtr, void* hWnd)
+	{
+		return new ViewTotalWin(implPtr, (HWND)hWnd);
+	}
+public:
+	xdwgrid	dw_list;
+	xoffice 	dw_office;
+	xcell		dw_cell;
+	xnode	m_agentNode;	//Agent Condition
+	KXMLDOMElement rptEle;
+	xstring m_category;
+	xstring argStr;
+	xstring searchStr;
+	xstring fieldRoleStr;
+	HWND      hWndImageView;
+	HWND      hWndRetrieveTip;
+	bool    dataretrieveing;
+
+	int SetAgent()
+	{
+		xstring xfNodeAgentArea = L"agentarea";
+		xnode anode = GetAgentNode(xfNodeAgentArea);
+		if (m_agentNode)
+		{
+			SetAgentNode(anode, m_agentNode);
+		}
+		else
+		{
+			KXMLDOMElement xframeElement = GetElement();
+			KXMLDOMElement agent = xframeElement.selectSingleNode(L"agent/" + xfNodeAgentArea + L"[1]/*");
+			if (agent)
+			{
+				xstring s = agent.xml();
+				m_agentNode = SetAgentNode(anode, s);
+			}
+		}
+		return 1;
+	}
+
+	int OnSearch()
+	{
+		xaserverarg arg ;
+		
+		arg.AddArg(L"text", searchStr);
+		//trace(searchStr);
+		OpenWindow(L"dev:xpage[search.dialog.vx]", arg);
+		xstring str = arg.GetArgString(L"text");
+		if (str != searchStr)
+		{
+			searchStr = str;
+			dw_list.Filter(L"*", searchStr);
+			return 1;
+		}
+		return 1;
+	}
+
+	//焦点激活处理函数
+	int OnSetFocus(TEvent * evt, int param)
+	{
+		//重置工具条
+		SetAgent();
+		return 1;
+	}
+
+	//命令发布函数
+	int OnCmdDispatch(xstring comdid)
+	{
+		xstring UserNo = publiccode::GetUser().no;
+
+		int hCursor = 0;
+		if (comdid == L"xmSearch") return OnSearch();
+
+		//if(UserNo !=L"00603")
+		//{
+		if (comdid == L"xmAnalysis")
+		{
+			HCURSOR hCursor = xutil::SetCursorWait();
+			xstring str = dw_list.DataAnalysis(L"");
+			xaserverarg arg ;
+			
+			arg.AddArg(L"html", str);
+			arg.SetParam(L"obj",(LPARAM)&dw_list);
+			OpenWindow(L"dev:xpage[data.vanalysis.vx]", arg);
+			xutil::RestoreCursor(hCursor);
+			return 1;
+		}
+		if (comdid == L"xmSaveAs")
+		{
+			dw_list.SaveAs(L"");
+			return 1;
+		}
+		if (comdid == L"xmRemarks")
+		{
+			xstring name = rptEle.getAttribute(L"name");
+			xml x = ViewObject::RetrieveData(L"/sale/data/TradeFinance3/GetSetUpRemarks", L"Type", name);
+			KXMLDOMNodeList items = x.selectNodes(L"data/Item");
+			KXMLDOMNode t = items.item(0);
+			xstring Content = L"";
+			if (t.selectSingleNode(L"Content"))
+			{
+				Content = t.selectSingleNode(L"Content").text();
+			}
+
+			xaserverarg arg1 =GetArg();
+			arg1.AddArg(L"value", Content);
+			OpenWindow(L"dev:xpage[memo.edit.new.vx]", arg1);
+			return 1;
+
+		}
+		//} 
+		if (comdid == L"xmTrans1")
+			return OnTransData();
+		if (comdid == L"xmQuery")
+		{
+			if (rptEle)
+			{
+				xstring argUrl = rptEle.getAttribute(L"arg");
+				if (argUrl != L"")
+				{
+					xaserverarg ar ;
+					//ar.setNativePointer(ar.CreateInstance());
+					ar.AddArg(L"argurl", argUrl);
+					if (argStr != L"")
+						ar.AddArg(L"arg", argStr);
+					OpenWindow(L"dev:xpage[view.total.arg.vx]", ar);
+					xstring arstr = ar.GetArgString(L"arg");
+					if (arstr != L"" && ar.GetArgString(L"action") == L"ok")
+					{
+						argStr = arstr;
+						HCURSOR hCursor = xutil::SetCursorWait();
+						//trace(rptEle.getAttribute(L"data"));
+						OnRetrieve(rptEle.getAttribute(L"data"), argStr);
+						xutil::RestoreCursor(hCursor);
+					}
+				}
+				else
+				{
+					argStr = L"";
+					OnRetrieve(rptEle.getAttribute(L"data"), argStr);
+				}
+			}
+			return 1;
+		}
+		if (comdid == L"xmLookImage")
+		{
+
+			int row = dw_list.GetRow();
+			xstring skuid = dw_list.GetGuid(row);
+			OnLookImage(skuid);
+			return 1;
+		}
+		if (comdid == L"CalculationFormula")
+		{
+			OpenWindow(L"dev:xpage[CalculationFormula.vx]", 0);
+			SetAgent();
+			return 1;
+		}
+		return 0;
+	}
+
+	int OnLookImage(xstring skuid)
+	{
+		HCURSOR hCursor = xutil::SetCursorWait();
+		xaserverarg arg;
+		arg.AddArg(L"guid", skuid);
+		OpenWindow(L"dev:xpage[ViewPictures.vx]", arg);
+		xutil::RestoreCursor(hCursor);
+		return 1;
+	}
+
+	int AdjustField(xdwgrid dw)
+	{
+		xstring str = fieldRoleStr;
+		for (int i = 1; i < dw.GetColumnCount(); i++)
+		{
+			xstring colname = dw.GetColumnName(i);
+			if (str.find(L"!" + colname + L",") >= 0)
+			{
+				dw.SetColumnState((LPCTSTR)colname.c_str(), false);
+			}
+		}
+		return 1;
+	}
+
+	int SwitchReport(KXMLDOMElement e)
+	{
+		xstring dwname = e.getAttribute(L"template");
+		xstring dataurl = e.getAttribute(L"data");
+		xstring sheettype = e.getAttribute(L"reporttype");
+		if (rptEle != e)
+		{
+			argStr = L"";
+			rptEle = e;
+		}
+		if (sheettype == L"") sheettype = L"report";
+		SwitchLayer(L"dw_" + sheettype, L"report");
+		if (sheettype == L"report")dw_list.openUrl(dwname);
+		if (hWndImageView) DestroyWindow(hWndImageView);
+
+		AdjustField(dw_list);
+
+		SetAgent();
+		return 1;
+	}
+
+	int OnCombboChanged(TEvent* evt, int lParam)
+	{
+		int h = xcombobox::GetCurSel(evt->command.hCtrl);
+		if (h > -1)
+		{
+			HCURSOR hCursor = xutil::SetCursorWait();
+			KXMLDOMElement e = xcombobox::GetItemData(evt->command.hCtrl, h);
+			SwitchReport(e);
+			PostMessage(GetHWND(), 0x401, (WPARAM)L"xmQuery", 0);
+			//OnCmdDispatch(L"xmQuery");
+			xutil::RestoreCursor(hCursor);
+		}
+		return 1;
+	}
+
+	int OnTransData()
+	{
+		int ret = MessageBox(GetHWND(), L"是否更新数据?\n更新过程预计需要四十分钟,如果中间弹出等待时间过长的提示,请点击中间重试按钮,或等待到一定时间再点击", L"提示", 0x4 /*yesno*/);
+		if (ret != 6 /*IDYES */) return 1;
+
+		xml x ;
+		HCURSOR hCursor = xutil::SetCursorWait();
+		if (xurl::get(L"/sale/data/Total3/total/transdata", L"", x) != 1)
+		{
+			xutil::RestoreCursor(hCursor);
+			return 1;
+		}
+		else
+		{
+			xutil::RestoreCursor(hCursor);
+			alert(L"数据传输完成!");
+			return 1;
+		}
+
+		return 1;
+	}
+
+	//命令处理事件
+	int OnXCommand(TEvent* evt, int param)
+	{
+		return OnCmdDispatch(evt->xcommand.pStrID);
+	}
+
+	int SendImageMessage(int row)
+	{
+		if (dw_list.GetItemString(row, L"GDNLineID") != L"")
+			SendMessage(hWndImageView, 0x401, (WPARAM)(L"xmRetrieve:GDNLineID:" + dw_list.GetItemString(row, L"GDNLineID")).c_str(),0);
+		else if (dw_list.GetItemString(row, L"ItemID") != L"")
+			SendMessage(hWndImageView, 0x401, (WPARAM)(L"xmRetrieve:SKUID:" + dw_list.GetItemString(row, L"ItemID")).c_str(), 0);
+		else if (dw_list.GetItemString(row, L"SKUID") != L"")
+			SendMessage(hWndImageView, 0x401, (WPARAM)(L"xmRetrieve:SKUID:" + dw_list.GetItemString(row, L"SKUID")).c_str(), 0);
+		else if (dw_list.GetItemString(row, L"GoodsNo") != L"")
+			SendMessage(hWndImageView, 0x401, (WPARAM)(L"xmRetrieve:GoodsNo:" + dw_list.GetItemString(row, L"GoodsNo")).c_str(), 0);
+		return 1;
+	}
+
+	int OnDWClick(TEvent* evt, int p)
+	{
+		DWNMHDR&  hdr = *(DWNMHDR*)evt->notify.pnmh;
+		xstring value = hdr.data;
+		xstring colname = hdr.colname;
+		int row = hdr.row;
+
+		if (row < 1) return 1;
+
+		if (rptEle)
+		{
+			xstring str = rptEle.getAttribute(L"forward");
+			if (str == L"false") return 1;
+		}
+
+		/*
+		xstring s = publiccode::GetUser().id;
+		xml supplier_x = ViewObject::RetrieveData(L"/sale/data/SupplierV3/entity/FindBySaleType",L"id", s);
+		if(supplier_x.text == L"样品间" || supplier_x.text == L"主管"){
+			return 1;
+		}
+
+		xaserverarg arg;
+		if(colname==L"SONo")
+		{
+			xstring SONo = dw_list.GetItemString(row,colname);
+			arg=new xaserverarg;
+			
+			arg.AddArg(L"EntityNo",SONo);
+			arg.AddArg(L"ReadOnly",L"true");
+			OpenWindow(L"dev:xpage[base.maint.so.vx]",arg.getNativePointer());
+		}
+		if(colname==L"InvoiceNo")
+		{
+			xstring InvoiceNo= dw_list.GetItemString(row,colname);
+			arg=new xaserverarg;
+			
+			arg.AddArg(L"EntityNo",InvoiceNo);
+			arg.AddArg(L"ReadOnly",L"true");
+			OpenWindow(L"dev:xpage[maint.GDN3.vx]",arg.getNativePointer());
+		}
+		if(colname==L"InvoiceNoEx")
+		{
+			xstring InvoiceNoEx= dw_list.GetItemString(row,colname);
+			arg=new xaserverarg;
+			
+			arg.AddArg(L"EntityNo",InvoiceNoEx);
+			arg.AddArg(L"invoiceno",InvoiceNoEx);
+			arg.AddArg(L"ReadOnly",L"true");
+			OpenWindow(L"dev:xpage[maint.vatnotify.vx]",arg.getNativePointer());
+		}
+		*/
+
+		if (hWndImageView != 0 && IsWindow(hWndImageView))
+		{
+			SendImageMessage(row);
+		}
+		else if (colname == L"HasImage")
+		{
+			xwin* pwin = OpenWindow(L"dev:xpage[testImage.vx]", 0);
+			hWndImageView = pwin->GetHWND();
+			SendImageMessage(row);
+		}
+
+		return 1;
+	}
+
+	int OnRowChanged(TEvent* evt, int p)
+	{
+
+		DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh;
+		int row = hdr.row;
+		if (row < 1) return 1;
+
+		if (hWndImageView != 0 && IsWindow(hWndImageView))
+		{
+			SendImageMessage(row);
+		}
+		return 1;
+	}
+
+	int ShowRetrieveingTip()
+	{
+		dataretrieveing = true;
+		xwin* pwin = OpenWindow(L"dev:xpage[TestRetrieveing.vx]", 0);
+		hWndRetrieveTip = pwin->GetHWND();
+		return 1;
+	}
+	int CloseRetrieveTip()
+	{
+		dataretrieveing = false;
+		SendMessage(hWndRetrieveTip, 0x401, (WPARAM)L"RetrieveFinished", 0);
+		hWndRetrieveTip = 0;
+
+		return 1;
+	}
+
+	int OnRetrieveFinished(TEvent* evt, int p)
+	{
+		CloseRetrieveTip();
+		//dataretrieveing = false;
+		//alert(L"读取完成");
+		return 1;
+	}
+
+	int OnAttachEvent()
+	{
+		//绑定工具条点击事件
+		AttachEvent(L"WM_XCOMMAND", (FEvent)&ViewTotalWin::OnXCommand);
+		//获取焦点事件,用于重置工具条
+		AttachEvent(L"WM_SETFOCUS", (FEvent)&ViewTotalWin::OnSetFocus);
+		AttachEvent(L"cb_report", L"CBN_SELCHANGE", (FEvent)&ViewTotalWin::OnCombboChanged);
+		AttachEvent(L"dw_report", L"DWV_CLICKED", (FEvent)&ViewTotalWin::OnDWClick);
+		AttachEvent(L"dw_report", L"DWV_ROWFOCUSCHANGED", (FEvent)&ViewTotalWin::OnRowChanged);//绑定行更改触发事件OnRowChanged
+		AttachEvent(L"dw_report", xstring(0x400 + 81), (FEvent)&ViewTotalWin::OnRetrieveFinished);
+
+		return 1;
+	}
+
+	int  OnRetrieve(xstring dataurl, xstring argstr)
+	{
+		if (!rptEle) return 0;
+		if (dataretrieveing) return -1;
+		dw_list.Reset();
+
+		xml x ;
+		xaserverarg arg ;
+		
+		arg.AddArg(L"arg", argstr);
+		trace(argstr);
+		xstring sheettype = rptEle.getAttribute(L"reporttype");
+		if (sheettype == L"") sheettype = L"report";
+		//ShowRetrieveingTip();
+		if (xurl::get(dataurl, arg.GetString(), x) != 1)
+		{
+
+			trace((xstring)L"错误信息=L" + x.text());
+			dw_list.Redraw();
+			return -1;
+		}
+		else
+		{
+			if (sheettype == L"report")
+			{
+				//CloseRetrieveTip();
+				dw_list.Retrieve(x);
+				dw_list.Redraw();
+				dw_list.SetReadOnly(true);
+			}
+			else if (sheettype == L"cell")
+			{
+			}
+			else if (sheettype == L"office")
+			{
+				dw_office.LoadTemplate(x,0);
+				for (int i = 0; i < dw_office.GetSheetCount(); i++)
+				{
+					xcell sheet = dw_office.GetSheet(i);
+					sheet.SetReadOnly(true);
+				}
+			}
+		}
+		return 1;
+	}
+
+	xml getReportSet(xstring category)
+	{
+		xml x ;
+		xaserverarg arg ;
+		
+		arg.AddArg(L"category", category);
+		if (xurl::get(L"/sale/data/Total3/reportset", arg.GetString(), x) != 1)
+		{
+			return 0;
+		}
+		return x;
+	}
+
+	xstring GetReportFieldRole()
+	{
+		xml x ;
+		xaserverarg arg ;
+		
+		if (xurl::get(L"/sale/data/Total3/report/field", arg.GetString(), x) != 1)
+		{
+			return L"";
+		}
+		xstring str = x.text();
+		return str;
+	}
+
+	int onload()
+	{
+		dw_list = GetControl(L"dw_report");
+		dw_office = GetControl(L"dw_office");
+		dw_cell = GetControl(L"dw_cell");
+		dw_list.openUrl(L"/sale/view/Total3/template/sodetail");
+
+		fieldRoleStr = GetReportFieldRole();
+
+		argStr = L"";
+		xcombobox xc = GetControl(L"cb_report");
+
+		m_category = L"total/trade";
+		SetArg();
+		if (GetWinParam()) {
+			xaserverarg arg = GetArg();
+			m_category = arg.GetArgString(L"category");
+		}
+		xml x = getReportSet(m_category);
+		if (x)
+		{
+			KXMLDOMNodeList nlist = x.selectNodes(L"//reports/report");
+			int len = nlist.length();
+			for (int i = 0; i < len; i++)
+			{
+				KXMLDOMElement rpt = nlist.item(i);
+				xstring name = rpt.getAttribute(L"name");
+				xc.AddItem( name, rpt.ptr());
+				if (i == 0) xc.SetText(name);
+				if (i == 0) rptEle = rpt;
+			}
+		}
+		searchStr = L"";
+		hWndImageView = 0;
+		hWndRetrieveTip = 0;
+		dataretrieveing = false;
+		OnAttachEvent();
+
+		return 1;
+	}
+
+	int onloaded()
+	{
+		SetAgent();
+
+		if (rptEle)
+		{
+			SwitchReport(rptEle);
+			//OnCmdDispatch(L"xmQuery");
+		}
+
+		return 1;
+	}
+};
\ No newline at end of file

--
Gitblit v1.9.3