#include #include #include #include #include #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" #include "viewobject/view.base.hpp" #include "xcontrol/xshtml.hpp" using xml = KXMLDOMDocument; class __declspec(dllexport) CommentaryEx : public xframe { public: CommentaryEx(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd), m_Edit(nullptr) {} public: static CommentaryEx* CreateInstance(void* implPtr, void* hWnd) { CommentaryEx* pWin = new CommentaryEx(implPtr, (HWND)hWnd); return pWin; } public: xstring m_EntityID; xstring m_EntityType; xstring m_EntityConnect; xstring m_ConnectID; xcontrol m_Edit; xshtml m_Html; xcombobox m_cb; int Init() { if (m_EntityID == L"") return -1; xml x; xaserverarg arg; arg.AddArg(L"EntityID", m_EntityID); arg.AddArg(L"EntityType", m_EntityType); arg.AddArg(L"EntityConnect", m_EntityConnect); if (xurl::get(L"/sale/data/Commentary/entity/notelist", arg.GetString(), x) == 1) { m_Html.SetContent(x.xml()); m_Html.Redraw(); } return 1; } int AppendItem(xml x, KXMLDOMElement r, xstring name, xstring value) { KXMLDOMElement e = x.createElement(name); e.settext(value); r.appendChild(e); return 1; } int showAtt() { xnode anode = GetAgentNode(L"att"); int s = m_cb.GetCount(); xml x ; x.loadXML(L""); KXMLDOMElement ele = x.documentElement(); int i = 0; for (i = 0; i < s; i++) { xstring tmp = m_cb.GetLBText(i); KXMLDOMElement e = x.createElement(L"hbox"); e.setAttribute(L"height", L"20"); KXMLDOMElement l = x.createElement(L"xlabel"); l.setAttribute(L"caption", L"" + tmp); KXMLDOMElement b = x.createElement(L"xtoolbutton"); b.setAttribute(L"width", L"18"); b.setAttribute(L"name", L"att_" + xstring(i)); b.setAttribute(L"image", L"1,5"); e.appendChild(l); e.appendChild(b); ele.appendChild(e); KXMLDOMElement g = x.createElement(L"xlabel"); g.setAttribute(L"height", L"2"); g.setAttribute(L"style", L"background-color:#000000"); ele.appendChild(g); } SetAgentNode(anode, ele.xml()); anode.SetWidthHeight(-1, i * 20 + 1); return 1; } int addAtt() { xstring guid = publiccode::GetGuid(); xstring str = guid.left(2); xstring ret = xaserver::UploadFile(L"attachment" + str, guid + L".jpg", GetHWND(), L"", false); int nIndex = m_cb.AddItem(ret.c_str(true), (guid + L".jpg").c_str(true)); showAtt(); return 1; } int delAtt(xstring no) { int nIndex = no.toInt(); m_cb.DeleteItem(nIndex); showAtt(); return 1; } KXMLDOMElement getAtt() { int s = m_cb.GetCount(); xml x; x.loadXML(L""); KXMLDOMElement ele = x.documentElement(); int i = 0; for (i = 0; i < s; i++) { xstring tmp = m_cb.GetLBText(i); xstring tmp2 = m_cb.GetItemData( i); KXMLDOMElement e = x.createElement(L"item"); e.setAttribute(L"name", L"" + tmp); e.setAttribute(L"file", L"" + tmp2); ele.appendChild(e); } return ele; } //ÃüÁî·¢²¼º¯Êý int OnCmdDispatch(xstring comdid) { if (comdid == L"xmOK") { if (m_EntityID == L"") return 1; xml x ; xaserverarg arg; xstring value = m_Edit.GetText(); if (value == L"") { int s = m_cb.GetCount(); if (s < 1) { alert(L"ÇëÌîдÅú×¢£¡"); return 1; } } x.loadXML(L""); KXMLDOMElement ele = x.documentElement(); AppendItem(x, ele, L"CommentaryID", publiccode::GetGuid()); AppendItem(x, ele, L"EntityID", m_EntityID); AppendItem(x, ele, L"EntityType", m_EntityType); AppendItem(x, ele, L"Remark", value); AppendItem(x, ele, L"ParentConnect", m_EntityConnect); AppendItem(x, ele, L"ParentCommentaryID", m_ConnectID); AppendItem(x, ele, L"CreatorID", xaserver::GetUserId()); ele.appendChild(getAtt()); arg.AddArg(L"content", (xstring)L"" + ele.xml() + L""); if (getUrl(L"/workflow/action/Commentary/bill.update", arg.GetString(), x) == 1) { m_Edit.SetText(L""); m_cb.ResetContent(); Init(); showAtt(); return 1; } else { alert(L"Ìí¼Óʧ°Ü!"); return -1; } } else if (comdid == L"xmAtt") { addAtt(); } else if (comdid.left(4) == L"att_") { delAtt(comdid.right(comdid.length() - 4)); } else { CloseWindow(); } return 1; } //ÃüÁî´¦Àíʼþ int OnXCommand(TEvent* evt, LPARAM param) { return OnCmdDispatch(evt->xcommand.pStrID); } int OnHtmlClick(TEvent* evt, LPARAM pr) { /* HTMLNMHDR& p = evt->pnmh; const xstring d = m_Html.GetData(p.object); if (d == L"") return -1; xstring file = d.mid(0, d.find(L"|##@@|", 0)); xstring name = d.mid(d.find(L"|##@@|", 0) + 6, d.length()); xaserver::CreateDirectory(L"C:/Temp"); xstring str = file.left(2); xstring ext = L""; if (name.find(L".") >= 0) ext = name.mid(name.find(L"."), name.length()); xstring sfile = file.left(file.length() - 4); //trace(L"--"+ext +L" " + L"/business/attachment/"+str+L"/"+ file); //int openRet = xaserver::DownLoadFile(GetServerUrl(),L"/business/attachment/"+str+L"/"+ file,name,L"C:/Temp/"+name); int openRet = xaserver::DownLoadFile(GetServerUrl(), L"/business/attachment/" + str + L"/" + file, L"", L"C:/Temp/" + sfile + ext); if (openRet < 0) { alert(L"Îļþ´ò¿ªÊ§°Ü1£¡"); return -1; } //openRet = win32::ShellExecute(0,L"open",L"C:/Temp/"+name,L"",L"",5); openRet = ShellExecuteW(0, L"open", L"C:/Temp/" + sfile + ext, L"", L"", 5); if (openRet < 32) { alert(L"Îļþ´ò¿ªÊ§°Ü2£¡"); return -1; } */ return -1; } int OnAttachEvent() { //°ó¶¨¹¤¾ßÌõµã»÷ʼþ AttachEvent(L"WM_XCOMMAND", (FEvent)&CommentaryEx::OnXCommand); AttachEvent(L"note", L"HTC_OBJECTCLICKED", (FEvent)&CommentaryEx::OnHtmlClick); return 1; } int onload() { SetArg(); OnAttachEvent(); m_Edit = GetControl(L"Txt"); m_Html = GetControl(L"note"); m_cb = GetControl(L"attlist"); m_EntityID = L""; m_EntityType = L""; m_EntityConnect = L""; m_ConnectID = L""; if (GetWinParam()) { //xaserverarg arg = new xaserverarg; //arg.setNativePointer(GetParam()); xaserverarg arg = GetArg(); m_EntityID = arg.GetArgString(L"EntityID"); m_EntityType = arg.GetArgString(L"m_EntityType"); m_EntityConnect = arg.GetArgString(L"m_EntityConnect"); } Init(); return 1; } };