#pragma once
|
|
#include <wobject/xwin.hpp>
|
#include <wobject/xurl.hpp>
|
#include <xcontrol/xdwgrid.hpp>
|
#include <xcontrol/xdwpages.hpp>
|
#include "listex.vframe.vbusiness.hpp"
|
#include "frame.vframe.vbusiness.hpp"
|
#include <xcontrol/xdwtable.hpp>
|
|
class maint : public xframe
|
{
|
public:
|
KXMLDOMDocument m_configDoc;
|
string m_EntityID;
|
|
maint(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {}
|
xstring GetEntityWorkNode(LPARAM pr, xstring what)
|
{
|
if (m_configDoc)
|
{
|
KXMLDOMNode n;
|
n = m_configDoc.selectSingleNode(L"//worknodes/worknode[@for='" + what + L"']/@url");
|
if (n)
|
{
|
xstring aurl = n.text();
|
if (aurl.find(L"/", 0) != 0)
|
{
|
xstring vface = m_configDoc.selectSingleNode(L"//vface[1]").text();
|
aurl = vface + L"/" + aurl;
|
}
|
return aurl;
|
}
|
}
|
return L"";
|
}
|
|
xstring GetEntityID(LPARAM /*param*/ pr)
|
{
|
return m_EntityID;
|
}
|
|
xstring GetEntityName(LPARAM /*param*/ pr)
|
{
|
if (m_configDoc)
|
{
|
if (m_configDoc.selectSingleNode(L"//entity/name[1]"))
|
return m_configDoc.selectSingleNode(L"//entity/name[1]").text();
|
else
|
return L"";
|
}
|
else
|
return L"";
|
}
|
|
virtual string GetEntityRowData(int pr)
|
{
|
return GetEntityData(pr);
|
}
|
|
virtual string GetEntityData(int /*param*/ pr)
|
{
|
//trace(L"zzz");
|
return L"";
|
}
|
|
int getURLParam()
|
{
|
//xpage xp = GetXPage();
|
//xstring aurl = xp.GetWkUrl();
|
xaserverarg* arg = (xaserverarg *)GetParam();
|
m_EntityID = arg->GetArgString(L"EntityID");
|
xstring config = arg->GetArgString(L"config");
|
KXMLDOMDocument x;
|
if (config == L"")
|
{
|
string configXml = arg->GetArgString(L"configxml");
|
if (configXml == L"") return 1;
|
x.loadXML(configXml);
|
}
|
else
|
{
|
getUrl(config, L"", x);
|
}
|
m_configDoc = x;
|
|
return 1;
|
}
|
|
virtual int SetEntityData(xaserverarg arg)
|
{
|
return 0;
|
}
|
|
int OnRetrieve()
|
{
|
KXMLDOMDocument x;
|
xaserverarg arg;
|
arg.AddArg(L"EntityID", m_EntityID, L"xs:string");
|
|
xstring dataUrl = L"";
|
KXMLDOMNode n = m_configDoc.selectSingleNode(L"//maint/group[@for='dwviev']/@dataurl");
|
if (n)
|
{
|
xstring u = n.text();
|
if (u.left(1) != L"/")
|
getUrl(L"/sale/data/" + GetEntityName(1) + L"/" + u, arg.GetString(), x);
|
else
|
getUrl(u, arg.GetString(), x);
|
}
|
else
|
{
|
//trace(L"maint.OnRetrieve.n == null");
|
}
|
|
//trace(L"yyy");
|
KXMLDOMNodeList nlist = m_configDoc.selectNodes(L"//maint/group[@for='dwviev']/dwview");
|
|
int index;
|
int nlen = nlist.length();
|
if (nlen > 0)
|
{
|
for (index = 0; index < nlen; index++)
|
{
|
//trace(L"zzz");
|
KXMLDOMElement e = nlist.item(index);
|
KXMLDOMDocument d;
|
if (e.selectSingleNode(L"@dataurl"))
|
{
|
KXMLDOMDocument x1 ;
|
xstring dataUrlEx = e.selectSingleNode(L"@dataurl").text();
|
if (dataUrlEx.left(1) != L"/")
|
getUrl(GetServerUrl(),L"/sale/data/" + GetEntityName(1) + L"/" + dataUrlEx, arg.GetString(), x1);
|
else
|
getUrl(GetServerUrl(), dataUrlEx, arg.GetString(), x1);
|
//getUrl(L"/sale/data/"+GetEntityName(1)+"/"+dataUrlEx,arg.GetString(),x1);
|
d = x1;
|
//trace(x1.GetXml());
|
//trace(L"maint.OnRetrieve.maint.xq.data = " + x1.GetXml());
|
|
}
|
else
|
{
|
// trace(L"maint.OnRetrieve.config.maint[@dataurl] == null");
|
//trace(L"maint.OnRetrieve.config.e = " + e.xml);
|
d = x;
|
}
|
|
//trace(L"maint:"+index.toString());
|
//alert(L"xq.xml = "+d.GetXml());
|
//trace(L"xxx");
|
string dwname = L"";//e.selectsingleNode(L"@name").text();
|
string tpy = L"dwgrid";
|
if (e.selectSingleNode(L"@name")) dwname = e.selectSingleNode(L"@name").text();
|
if (e.selectSingleNode(L"@type")) tpy = e.selectSingleNode(L"@type").text();
|
if (tpy == L"dwgrid")
|
{
|
//trace(L"grid");
|
//xdwgrid dw_list = new xdwgrid;
|
//dw_list.setNativePointer(GetControl(dwname));
|
xdwgrid dw_list = GetControl(dwname);
|
//trace(index);
|
//trace(d.GetXml());
|
dw_list.Retrieve(d);
|
dw_list.Redraw();
|
//trace(L"grid end");
|
}
|
else if (tpy == L"dwtable")
|
{
|
//trace(L"table");
|
xdwtable dw_table = GetControl(dwname);
|
//alert(L"dw_table.Retrieve(d) ===== "+d.GetXml());
|
dw_table.Retrieve(d);
|
dw_table.Redraw();
|
//trace(L"table end");
|
}
|
}
|
}
|
else
|
{
|
//trace(L"maint.OnRetrieve.list.length == 0");
|
}
|
return 1;
|
}
|
|
virtual int PreOnSetFocus()
|
{
|
//·µ»Ø0¡ª¡ª²»ÔÚÖ´ÐÐÒÔÏ´úÂ룻·µ»ØÆäËû¡ª¡ªÖ´ÐÐÒÔÏ´úÂë¡£
|
return 1;
|
}
|
|
int OnSetFocus(TEvent * evt, LPARAM p)
|
{
|
if (PreOnSetFocus() == 0) return 0;
|
|
SetAgent(L"maint", m_EntityID);
|
|
return 1;
|
}
|
|
virtual int PreOnCmdDispatch(string comdid)
|
{
|
//·µ»Ø0¡ª¡ª²»ÔÚÖ´ÐÐÒÔÏ´úÂ룻·µ»ØÆäËû¡ª¡ªÖ´ÐÐÒÔÏ´úÂë¡£
|
return 1;
|
}
|
|
virtual int PostOnCmdDispatch(string comdid)
|
{
|
return 1;
|
}
|
|
int OnPrint()
|
{
|
xaserverarg* arg = new xaserverarg;
|
arg->AddArg(L"EntityName", GetEntityName(1), L"");
|
arg->AddArg(L"EntityID", GetEntityID(1), L"");
|
openUrl(L"/sale/view/view.base/xpage/Template/PrintView", arg);
|
return 1;
|
}
|
|
int OnCmdDispatch(xstring comdid)
|
{
|
if (PreOnCmdDispatch(comdid) == 0) return 1;
|
if (comdid == L"action:bill.print") return OnPrint();
|
if (comdid.find(L"action:", 0) >= 0)
|
{
|
int ret = ProcessFlowAction(comdid, 1);
|
}
|
|
if (PostOnCmdDispatch(comdid) != 1)
|
{
|
alert(L"error");
|
return -1;
|
}
|
|
return 0;
|
}
|
|
int OnXCommand(TEvent* evt, int p)
|
{
|
return OnCmdDispatch(evt->xcommand.pStrID);
|
}
|
|
int OnClose(TEvent * evt, int p)
|
{
|
return 0;
|
//if(!m_configDoc) return -1; //---
|
|
KXMLDOMNodeList nlist = m_configDoc.selectNodes(L"//maint/group[@for='dwviev']/dwview");
|
int index;
|
int nlen = nlist.length();
|
KXMLDOMElement e;
|
if (nlen > 0)
|
{
|
string vface = m_configDoc.selectSingleNode(L"//vface[1]").text();
|
KXMLDOMDocument x;
|
for (index = 0; index < nlen; index++)
|
{
|
e = nlist.item(index);
|
//if(!e.selectSingleNode(L"@type")) continue;
|
|
xstring dwname = L"";//e.selectsingleNode(L"@name").text();
|
xstring tpy = L"dwgrid";
|
if (e.selectSingleNode(L"@name")) dwname = e.selectSingleNode(L"@name").text();
|
if (e.selectSingleNode(L"@type")) tpy = e.selectSingleNode(L"@type").text();
|
if (tpy == L"dwgrid")
|
{
|
xdwgrid dw_list = GetControl(dwname);
|
dw_list.AcceptText();
|
dw_list.DwUpdateAllToEx(x);
|
}
|
else if (tpy == L"dwtable")
|
{
|
xdwtable dw_table = GetControl(dwname);
|
dw_table.AcceptText();
|
dw_table.DwUpdateAllTo(x);
|
}
|
KXMLDOMElement ele = x.documentElement();
|
|
if (ele.selectSingleNode(L"//*[@update.origin != '']"))
|
{
|
int res = MessageBoxW(GetHWND(), L"Êý¾ÝÒѾ¸Ä±ä£¬ÊÇ·ñ±£´æ?", L"Ìáʾ", 4);
|
if (res == 6)
|
OnCmdDispatch(L"action:bill.update");
|
break;
|
}
|
}
|
}
|
return 0;
|
}
|
|
virtual int PostOnAttachEvent()
|
{
|
return 1;
|
}
|
|
virtual int CheckEntityValidity(LPARAM pr)
|
{
|
#if shouldFinish
|
//if(!m_configDoc) return 1; //---
|
KXMLDOMNodeList nlist = m_configDoc.selectNodes(L"//maint/group[@for='dwviev']/dwview[@type='dwtable']");
|
int index;
|
int nlen = nlist.length();
|
KXMLDOMElement e;
|
for (index = 0; index < nlen; index++)
|
{
|
e = nlist.item(index);
|
string dwname = L"";//e.selectsingleNode(L"@name").text();
|
//string tpy = "dwgrid";
|
if (e.selectSingleNode(L"@name")) dwname = e.selectSingleNode(L"@name").text();
|
xdwtable dw_table = GetControl(dwname);
|
xpoint p;
|
p.x = 0;
|
p.y = 0;
|
int dw = dw_table.getNullCell(p); //---
|
//while(dw > 0)
|
if (dw > 0)
|
{
|
xdwtable dw_1 = new xdwtable;
|
dw_1.setNativePointer(dw);
|
int colIndex = p.y;
|
if (colIndex < 1) return 1;
|
xstring colName = dw_1.GetColumnName(colIndex);
|
xstring colText;
|
if (m_configDoc.selectSingleNode(L"//MustFill/item[@name='" + colName + L"']"))
|
colText = m_configDoc.selectSingleNode(L"//MustFill/item[@name='" + colName + L"']/@text[1]").text();
|
else
|
colText = colName;
|
alert(L"×Ö¶Î" + colText + L"²»ÄÜΪ¿Õ!");
|
return -1;
|
}
|
}
|
#endif
|
return 1;
|
}
|
|
int OnAttachEvent()
|
{
|
AttachEvent(L"WM_XCOMMAND", (FEvent)&maint::OnXCommand);
|
AttachEvent(L"WM_SETFOCUS", (FEvent)&maint::OnSetFocus);
|
|
AttachCloseWindow();
|
PostOnAttachEvent();
|
return 0;
|
}
|
|
int SetObjectInfo(KXMLDOMElement e)
|
{
|
//trace(e.xml);
|
if (!e.selectSingleNode(L"rightes")) return 1;
|
//alert(L"zzzzzzzzzzzz");
|
string objUpdate = L"";
|
if (e.selectSingleNode(L"//right[1]/@update"))
|
{
|
objUpdate = e.selectSingleNode(L"//right[1]/@update").text();
|
//if(objUpdate == "yes") return 1;
|
if (objUpdate == L"*") return 1;
|
}
|
//alert(L"xxxxxxxxxxxxx");
|
//if(!m_configDoc) return -1; //---
|
KXMLDOMNodeList nlist = m_configDoc.selectNodes(L"//maint/group[@for='dwviev']/dwview");
|
int index;
|
int nlen = nlist.length();
|
KXMLDOMElement ele;
|
for (index = 0; index < nlen; index++)
|
{
|
ele = nlist.item(index);
|
|
string dwname = L"";//e.selectsingleNode(L"@name").text();
|
string tpy = L"dwgrid";
|
if (ele.selectSingleNode(L"@name")) dwname = ele.selectSingleNode(L"@name").text();
|
if (ele.selectSingleNode(L"@type")) tpy = ele.selectSingleNode(L"@type").text();
|
|
if (tpy == L"dwgrid")
|
{
|
xdwgrid dw_list = GetControl(dwname);
|
if (objUpdate == L"yes")
|
dw_list.SetReadOnly(false);
|
else
|
dw_list.SetReadOnly(true);
|
}
|
else if (tpy == L"dwtable")
|
{
|
xdwtable dw_table = GetControl(dwname);
|
if (L"yes" == objUpdate)
|
dw_table.SetReadOnly(false);
|
else
|
{
|
dw_table.SetReadOnly(true);
|
}
|
}
|
}
|
return 1;
|
}
|
|
int onload()
|
{
|
OnAttachEvent();
|
//if(!m_configDoc) return -1; //---
|
|
//trace(m_EntityID);
|
getURLParam();
|
//alert(m_configDoc.xml);
|
KXMLDOMNodeList nlist = m_configDoc.selectNodes(L"//maint/group[@for='dwviev']/dwview");
|
int index;
|
int nlen = nlist.length();
|
//alert(m_configDoc.xml);
|
//trace(nlen);
|
KXMLDOMElement e;
|
xnode anode = GetAgentNode(L"viewclient");
|
// alert(L"xxx");
|
if (anode)
|
{
|
KXMLDOMNode n = m_configDoc.selectSingleNode(L"//maint/xpage[@use!='false']");
|
if (n)
|
{
|
// trace(L"maint.onload.n != null");
|
string vx = n.xml();
|
SetAgentNode(anode, vx);
|
}
|
else
|
{
|
// trace(L"maint.onload.n == null");
|
xstring sxpage;
|
if (nlen > 1)
|
{
|
// trace(L"maint.onload.nlen > 1");
|
// alert(L"xxx1");
|
sxpage = L"<xpage><layers tabsize='20' tabplace='top' tabstyle='tdsShape' name='tab_1'>";
|
for (index = 0; index < nlen; index++)
|
{
|
e = nlist.item(index);
|
xstring dwname = L"";//e.selectsingleNode(L"@name").text();
|
xstring caption = L"";//e.selectsingleNode(L"@url").text();
|
xstring tpy = L"dwgrid";
|
if (e.selectSingleNode(L"@name")) dwname = e.selectSingleNode(L"@name").text();
|
if (e.selectSingleNode(L"@caption")) caption = e.selectSingleNode(L"@caption").text();
|
if (e.selectSingleNode(L"@type")) tpy = e.selectSingleNode(L"@type").text();
|
xstring layer = L"<layer caption='" + caption + L"'>";
|
if (tpy == L"dwgrid")
|
layer += L"<xgridex state='run' name='" + dwname + L"'/>";
|
else if (tpy == L"dwtable")
|
layer += L"<xcell state='run' name='" + dwname + L"'/>";
|
layer += L"</layer>";
|
sxpage += layer;
|
}
|
|
sxpage += L"</layers></xpage>";
|
SetAgentNode(anode, sxpage);
|
}
|
else if (nlen > 0)
|
{
|
// trace(L"maint.onload.nlen > 0");
|
sxpage = L"<xpage><vbox>";
|
e = nlist.item(0);
|
xstring sdwname = L"";//e.selectsingleNode(L"@name").text();
|
xstring scaption = L"";//e.selectsingleNode(L"@url").text();
|
xstring stpy = L"dwgrid";
|
if (e.selectSingleNode(L"@name")) sdwname = e.selectSingleNode(L"@name").text();
|
if (e.selectSingleNode(L"@caption")) scaption = e.selectSingleNode(L"@caption").text();
|
if (e.selectSingleNode(L"@type")) stpy = e.selectSingleNode(L"@type").text();
|
|
sxpage += L"<xlabel caption='" + scaption + L":' height='25'/>";
|
xstring slayer = L"";
|
if (stpy == L"dwgrid")
|
slayer = L"<xgridex state='run' name='" + sdwname + L"'/>";
|
else if (stpy == L"dwtable")
|
slayer = L"<xcell state='run' name='" + sdwname + L"'/>";
|
sxpage += slayer;
|
sxpage += L"</vbox></xpage>";
|
SetAgentNode(anode, sxpage);
|
|
}
|
}
|
}
|
if (nlen > 0)
|
{
|
//trace(L"maint.onload.nlen2 > 0");
|
xstring vface = m_configDoc.selectSingleNode(L"//vface[1]").text();
|
//alert(vface);
|
for (index = 0; index < nlen; index++)
|
{
|
e = nlist.item(index);
|
//if(!e.selectSingleNode(L"@type")) continue;
|
//alert(e.xml);
|
xstring xdwname = L"";//e.selectsingleNode(L"@name").text();
|
xstring xtpl = L"";//e.selectsingleNode(L"@url").text();
|
xstring xtpy = L"dwgrid";
|
if (e.selectSingleNode(L"@name")) xdwname = e.selectSingleNode(L"@name").text();
|
if (e.selectSingleNode(L"@url")) xtpl = e.selectSingleNode(L"@url").text();
|
if (e.selectSingleNode(L"@type")) xtpy = e.selectSingleNode(L"@type").text();
|
//alert(xdwname+"--"+xtpl);
|
if (xtpy == L"dwgrid")
|
{
|
xdwgrid dw_list = GetControl(xdwname);
|
dw_list.openUrl(vface + L"/" + xtpl);
|
//dw_list.SetSelectionMode(4);
|
if (e.selectSingleNode(L"@readonly"))
|
{
|
string sreadonly = e.selectSingleNode(L"@readonly").text();
|
if (sreadonly == L"true")
|
dw_list.SetReadOnly(true);
|
}
|
}
|
else if (xtpy == L"dwtable")
|
{
|
// trace(L"tpy == dwtable");
|
//trace(dwname);
|
//trace(vface+"/"+tpl);
|
xdwtable dw_table = GetControl(xdwname);
|
// trace(L"maint.onload.vface/tpl = "+vface + "/" + tpl);
|
dw_table.openUrl(vface + L"/" + xtpl);
|
|
//trace(dw_table.__nativept);
|
//trace(L"xxxx");
|
if (e.selectSingleNode(L"@title"))
|
{
|
//trace(L"xx");
|
// trace(L"e.selectSingleNode(@title)");
|
dw_table.SetColHeaderHeight(0);
|
dw_table.SetRowSelectorWidth(0);
|
//trace(L"yyy");
|
}
|
if (e.selectSingleNode(L"@scrollbox"))
|
{
|
// trace(L"e.selectSingleNode(@scrollbox)");
|
dw_table.SetScrollState(false);
|
}
|
AttachEvent(xdwname, L"DWV_ITEMERROR",(FEvent)&maint::OnItemError);
|
}
|
}
|
//trace(L"OnRetrieve()...");
|
//trace(L"xxxx");
|
}
|
return 1;
|
}
|
|
int onloaded()
|
{
|
SetAgent(L"maint", m_EntityID);
|
KXMLDOMNodeList nlist = m_configDoc.selectNodes(L"//maint/group[@for='dwviev']/dwview");
|
int nlen = nlist.length();
|
if (nlen > 0)
|
OnRetrieve();
|
return -1;
|
}
|
};
|