| | |
| | | use "win.vl" |
| | | use "treeview.vm" |
| | | use "dev:vm[xdwgrid.vm]" |
| | | use "dev:vm[xdwtable.vm]" |
| | | use "pref.vl" |
| | | use "dev:vm[xml.vm]" |
| | | use "dev:vm[xaserverarg.vm]" |
| | | use "dev:vm[xaserver.vm]" |
| | | use "dev:vm[xutil.vm]" |
| | | use "list.vl" |
| | | unit vbusiness.xpage |
| | | [ |
| | | HrOrg is extend list; |
| | | about HrOrg |
| | | [ |
| | | control: |
| | | #include <wobject/xstring.hpp> |
| | | #include <xcontrol/xtreeview.hpp> |
| | | #include <xcontrol/xdwgrid.hpp> |
| | | #include <wobject/xdouble.hpp> |
| | | #include <xcontrol/xlayersheet.hpp> |
| | | |
| | | method: |
| | | [ |
| | | xdwgrid__ dw_list; |
| | | treeview__ tv_org; |
| | | string sOrgID; |
| | | string sOrgName; |
| | | #include "vbusiness/vframe/listwin.vframe.vbusiness.hpp" |
| | | #include "viewobject/view.base.hpp" |
| | | |
| | | string sRootOrgID; |
| | | string sRootOrgName; |
| | | using xml = KXMLDOMDocument; |
| | | class __declspec(dllexport) HrOrg : public xwin |
| | | { |
| | | public: |
| | | xdwgrid dw_list; |
| | | xtreeview tv_org; |
| | | xstring sOrgID; |
| | | xstring sOrgName; |
| | | |
| | | xnode__ m_agentNode; //Agent Condition |
| | | string m_agentCond; //Agent Node |
| | | int SetAgent() |
| | | { |
| | | string xfNodeAgentArea = "agentarea"; |
| | | xnode__ anode = new xnode__; |
| | | anode.setNativePointer(GetAgentNode(xfNodeAgentArea)); |
| | | var xframeElement = GetElement(); |
| | | var agent = xframeElement.selectSingleNode("agent/" + xfNodeAgentArea + "[1]/*"); |
| | | if (agent) |
| | | { |
| | | string s = agent.xml; |
| | | SetAgentNodeContent(anode, s); |
| | | } |
| | | return 1; |
| | | } |
| | | xstring sRootOrgID; |
| | | xstring sRootOrgName; |
| | | |
| | | int OnRetrieve() |
| | | { |
| | | int hIcon = xutil__::SetCursorWait(); |
| | | xml__ x = new xml__; |
| | | x.setNativePointer(x.CreateInstance()); |
| | | xaserverarg__ arg = new xaserverarg__; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("guid", sOrgID); |
| | | if (url::get("OrganizationStruct/list.HrOrg", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.GetXmlDoc().text); |
| | | return -1; |
| | | } |
| | | else |
| | | { |
| | | dw_list.Retrieve(x); |
| | | dw_list.Redraw(); |
| | | } |
| | | dw_list.SetReadOnly(true); |
| | | xutil__::RestoreCursor(hIcon); |
| | | return 1; |
| | | } |
| | | xnode m_agentNode; //Agent Condition |
| | | xstring m_agentCond; //Agent Node |
| | | public: |
| | | HrOrg(void* implPtr, HWND hWnd) :xwin(implPtr, hWnd) {} |
| | | public: |
| | | static HrOrg* CreateInstance(void* implPtr, void* hWnd) |
| | | { |
| | | HrOrg* pWin = new HrOrg(implPtr, (HWND)hWnd); |
| | | return pWin; |
| | | } |
| | | 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 OnSetFocus(ref TEvent evt, int p) |
| | | { |
| | | SetAgent(); |
| | | //OnRetrieve(); |
| | | //重置工具条 |
| | | return 1; |
| | | } |
| | | int OnRetrieve() |
| | | { |
| | | HCURSOR hIcon = xutil::SetCursorWait(); |
| | | xml x; |
| | | |
| | | int OnCreateTree(string sguid, int parentitem) |
| | | { |
| | | int wid = tv_org.GetId(); |
| | | xml__ x = new xml__; |
| | | x.setNativePointer(xml__::CreateInstance()); |
| | | xaserverarg__ arg = new xaserverarg__; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("sguid", sguid); |
| | | if (url::post("/sale/data/OrganizationStruct/tree.child.OrgChart", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.GetXml()); |
| | | return -1; |
| | | } |
| | | //trace(x.GetXml()); |
| | | var list = x.GetXmlDoc().selectNodes("//Org"); |
| | | int i = 0, s = list.length; |
| | | msxml::IXMLDOMElement xitem; |
| | | string sname; |
| | | string sguid; |
| | | if (s > 0) |
| | | { |
| | | for (i = 0; i < s; i++) |
| | | { |
| | | xitem = list.item(s - i - 1); |
| | | sname = xitem.SelectSingleNode("OrgName").text; |
| | | sguid = xitem.SelectSingleNode("@guid").text; |
| | | int curItem = tv_org.InsertChildItemEx(wid, parentitem, sname, xitem, 15, 4); |
| | | OnCreateTree(sguid, curItem); |
| | | /*string id = xitem.selectSingleNode("ModuleID").text; |
| | | string Name=""; |
| | | if(xitem.selectSingleNode("ModuleName")) Name=xitem.selectSingleNode("ModuleName").text; |
| | | string image = 15; |
| | | if(xitem.selectSingleNode("ModuelImage")) image=xitem.selectSingleNode("ModuelImage").text; |
| | | int curItem=treeview__::InsertItem(tv_menu.GetId(), parentItem,0,Name,id,image.toInt()); |
| | | string child=xitem.selectSingleNode("@child").text;//item.getAttribute("HasChild"); |
| | | if (child != "0") |
| | | treeview__::SetItemChild1(tv_menu.GetId(), curItem,1);*/ |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | xaserverarg arg; |
| | | |
| | | int OnTreeExpanding(ref TNotifyEvent evt, int p) |
| | | { |
| | | ref NMTREEVIEW nmtv = evt.pnmh; |
| | | int sitem = nmtv.itemNew.hItem; |
| | | arg.AddArg(L"guid", sOrgID); |
| | | if (xurl::get(L"OrganizationStruct/list.HrOrg", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.text()); |
| | | return -1; |
| | | } |
| | | else |
| | | { |
| | | dw_list.Retrieve(x); |
| | | dw_list.Redraw(); |
| | | } |
| | | dw_list.SetReadOnly(true); |
| | | xutil::RestoreCursor(hIcon); |
| | | return 1; |
| | | } |
| | | |
| | | string id = treeview__::GetItemData(tv_org.GetId(), sitem); |
| | | int hCursor = xutil__::SetCursorWait(); |
| | | OnCreateTree(id, sitem); |
| | | xutil__::RestoreCursor(hCursor); |
| | | return 1; |
| | | } |
| | | //焦点激活处理函数 |
| | | int OnSetFocus(TEvent* evt, LPARAM param) |
| | | { |
| | | SetAgent(); |
| | | //OnRetrieve(); |
| | | //重置工具条 |
| | | return 1; |
| | | } |
| | | |
| | | //树点击事件 |
| | | int OnTreeSelecded(ref TNotifyEvent evt, int p) |
| | | { |
| | | ref NMTREEVIEW nmtv = evt.pnmh; |
| | | int hItem = nmtv.itemNew.hItem; |
| | | int wid = tv_org.GetId(); |
| | | int hitem = treeview__::GetSelectedItem(wid); |
| | | msxml::IXMLDOMElement ele = treeview__::GetItemData(wid, hitem); |
| | | int OnCreateTree(xstring sguid, HTREEITEM parentitem) |
| | | { |
| | | //int wid = ; |
| | | xml x; |
| | | |
| | | int hroot = treeview__::GetParentItem(wid, hitem); |
| | | int hparent = treeview__::GetParentItem(wid, hroot); |
| | | if (!hparent) |
| | | { |
| | | hparent = hroot; |
| | | hroot = hitem; |
| | | } |
| | | bool found = false; |
| | | if (hparent) found = true; |
| | | while (treeview__::GetParentItem(wid, hparent)) |
| | | { |
| | | hroot = hparent; |
| | | hparent = treeview__::GetParentItem(wid, hroot); |
| | | } |
| | | if (found) |
| | | { |
| | | msxml::IXMLDOMElement ele1 = treeview__::GetItemData(wid, hroot); |
| | | //trace(ele1.xml); |
| | | //sRootOrgID = ele1.SelectSingleNode("CompanyID").text; |
| | | //sRootOrgName = ele1.selectSingleNode("CompanyID/@_displaystring").text; |
| | | } |
| | | xaserverarg arg; |
| | | |
| | | string ls_orgid = ele.SelectSingleNode("@guid").text; |
| | | sOrgID = ls_orgid + ""; |
| | | //trace(sOrgID); |
| | | sOrgName = ele.selectSingleNode("OrgName").text; |
| | | OnRetrieve(); |
| | | return 1; |
| | | } |
| | | arg.AddArg(L"sguid", sguid); |
| | | if (xurl::post(L"/sale/data/OrganizationStruct/tree.child.OrgChart", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.xml()); |
| | | return -1; |
| | | } |
| | | //trace(x.GetXml()); |
| | | auto list = x.selectNodes(L"//Org"); |
| | | int i = 0, s = list.length(); |
| | | KXMLDOMElement xitem; |
| | | xstring sname; |
| | | //xstring sguid; |
| | | if (s > 0) |
| | | { |
| | | for (i = 0; i < s; i++) |
| | | { |
| | | xitem = list.item(s - i - 1); |
| | | sname = xitem.selectSingleNode(L"OrgName").text(); |
| | | sguid = xitem.selectSingleNode(L"@guid").text(); |
| | | HTREEITEM curItem = tv_org.InsertChildItemEx(parentitem, sname, xitem, 15, 4); |
| | | OnCreateTree(sguid, curItem); |
| | | /*xstring id = xitem.selectSingleNode(L"ModuleID").text(); |
| | | xstring Name=L""; |
| | | if(xitem.selectSingleNode(L"ModuleName")) Name=xitem.selectSingleNode(L"ModuleName").text(); |
| | | xstring image = 15; |
| | | if(xitem.selectSingleNode(L"ModuelImage")) image=xitem.selectSingleNode(L"ModuelImage").text(); |
| | | int curItem=tv_org.InsertItem(tv_menu.GetId(), parentItem,0,Name,id,image.toInt()); |
| | | xstring child=xitem.selectSingleNode(L"@child").text();//item.getAttribute(L"HasChild"); |
| | | if (child != L"0") |
| | | tv_org.SetItemChild1(tv_menu.GetId(), curItem,1);*/ |
| | | } |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int OnTreeMoveNode(ref TNotifyEvent evt, int p) |
| | | { |
| | | ref TVNNMHDR nmtv = evt.pnmh; |
| | | int xfrom = nmtv.FromItem; |
| | | int xto = nmtv.ToItem; |
| | | int OnTreeExpanding(TEvent* evt, int p) |
| | | { |
| | | NMTREEVIEW& nmtv = *(NMTREEVIEW*)evt->notify.pnmh; |
| | | HTREEITEM sitem = nmtv.itemNew.hItem; |
| | | |
| | | int ret = win__::MessageBox(this.GetHWND(), "确定移动组织节点?", "提示:", 1); |
| | | //trace(ret); |
| | | int wid = tv_org.GetId(); |
| | | if (ret == 2) |
| | | { |
| | | treeview__::DeleteItem(wid, xto); |
| | | return -1; |
| | | } |
| | | return 1; |
| | | |
| | | //string fid = treeview__::GetItemData(wid, xfrom); |
| | | //string tid = treeview__::GetItemData(wid, xto); |
| | | int xtop = treeview__::GetParentItem(wid, xto); |
| | | msxml::IXMLDOMElement ef = treeview__::GetItemData(wid, xfrom); |
| | | msxml::IXMLDOMElement et = treeview__::GetItemData(wid, xtop); |
| | | string fid = ef.SelectSingleNode("@guid").text;//ef.xml; |
| | | string tid = et.SelectSingleNode("@guid").text;//et.xml; |
| | | xml__ x = new xml__; |
| | | x.setNativePointer(xml__::CreateInstance()); |
| | | xaserverarg__ arg = new xaserverarg__; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("from", fid); |
| | | arg.AddArg("to", tid); |
| | | //trace(et.xml); |
| | | //return 1; |
| | | if (url::post("OrganizationStruct/move.update.HrOrg", arg.GetString(), x) != 1) |
| | | { |
| | | trace("error:" + x.GetXml()); |
| | | alert("移动组织节点出错!"); |
| | | treeview__::DeleteItem(wid, xto); |
| | | return 0; |
| | | } |
| | | treeview__::DeleteItem(wid, xfrom); |
| | | return 1; |
| | | } |
| | | xstring id = tv_org.GetItemData(sitem); |
| | | HCURSOR hCursor = xutil::SetCursorWait(); |
| | | OnCreateTree(id, sitem); |
| | | xutil::RestoreCursor(hCursor); |
| | | return 1; |
| | | } |
| | | |
| | | //xgridex双击 |
| | | int OnDoubleClicked(ref TNotifyEvent evt, int p) |
| | | { |
| | | ref DWNMHDR hdr = evt.pnmh; |
| | | int row = hdr.row; |
| | | if (row < 1 || row > dw_list.GetRowCount()) |
| | | return 1; |
| | | msxml::IXMLDOMElement e = dw_list.GetRowElement(row); |
| | | string sguid = e.SelectSingleNode("@guid").text; |
| | | xaserverarg__ arg = new xaserverarg__; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("operate", "modify"); |
| | | arg.AddArg("guid", sguid); |
| | | arg.AddArg("tvOrgID", sOrgID); |
| | | arg.AddArg("tvOrgName", sOrgName); |
| | | arg.AddArg("tvRootOrgID", sRootOrgID); |
| | | arg.AddArg("tvRootOrgName", sRootOrgName); |
| | | //trace(row.toString()); |
| | | //win__::OpenWindow("dev:xpage[HrOrgMaint.xpage]",arg); |
| | | openUrl("组织架构.vface/xpage/HrOrg/maint", arg); |
| | | return 1; |
| | | } |
| | | //树点击事件 |
| | | int OnTreeSelecded(TEvent* evt, int p) |
| | | { |
| | | NMTREEVIEW& nmtv = *(NMTREEVIEW*)evt->notify.pnmh; |
| | | HTREEITEM hItem = nmtv.itemNew.hItem; |
| | | int wid = 0; |
| | | HTREEITEM hitem = tv_org.GetSelectedItem(); |
| | | KXMLDOMElement ele = tv_org.GetItemData(hitem); |
| | | |
| | | int AddRow() |
| | | { |
| | | /*int wid = tv_org.GetId(); |
| | | int hitem=treeview__::GetSelectedItem(wid); |
| | | int root=treeview__::GetRootItem(wid); |
| | | if (hitem == root) |
| | | { |
| | | win32::MessageBox(GetHWND(),"根组织!","提示",0); |
| | | return -1; |
| | | }*/ |
| | | //int row = dw_list.GetNextSelectRow(1); |
| | | //IXMLDOMElement e = dw_list.GetRowElement(row); |
| | | //string sguid = e.getAttribute("guid"); |
| | | HTREEITEM hroot = tv_org.GetParentItem(hitem); |
| | | HTREEITEM hparent = tv_org.GetParentItem(hroot); |
| | | if (!hparent) |
| | | { |
| | | hparent = hroot; |
| | | hroot = hitem; |
| | | } |
| | | bool found = false; |
| | | if (hparent) found = true; |
| | | while (tv_org.GetParentItem(hparent)) |
| | | { |
| | | hroot = hparent; |
| | | hparent = tv_org.GetParentItem(hroot); |
| | | } |
| | | if (found) |
| | | { |
| | | KXMLDOMElement ele1 = tv_org.GetItemData(hroot); |
| | | //trace(ele1.xml); |
| | | //sRootOrgID = ele1.selectSingleNode(L"CompanyID").text(); |
| | | //sRootOrgName = ele1.selectSingleNode(L"CompanyID/@_displaystring").text(); |
| | | } |
| | | |
| | | xaserverarg__ arg = new xaserverarg__; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("operate", "new0"); |
| | | arg.AddArg("guid", ""); |
| | | arg.AddArg("tvOrgID", sOrgID); |
| | | arg.AddArg("tvOrgName", sOrgName); |
| | | arg.AddArg("tvRootOrgID", sRootOrgID); |
| | | arg.AddArg("tvRootOrgName", sRootOrgName); |
| | | openUrl("组织架构.vface/xpage/HrOrg/maint", arg); |
| | | return 1; |
| | | } |
| | | string str = ele.xml(); |
| | | if(ele.selectSingleNode(L"@guid")) |
| | | sOrgID = ele.selectSingleNode(L"@guid").text(); |
| | | if(ele.selectSingleNode(L"OrgName")) |
| | | sOrgName = ele.selectSingleNode(L"OrgName").text(); |
| | | OnRetrieve(); |
| | | return 1; |
| | | } |
| | | |
| | | int ModifyRow() |
| | | { |
| | | int row = dw_list.GetNextSelectRow(1); |
| | | if (row < 1) |
| | | { |
| | | row = dw_list.GetRow(); |
| | | if (row < 1) |
| | | { |
| | | win__::MessageBox(GetHWND(), "请选中要修改的组织数据行!", "提示", 0); |
| | | return -1; |
| | | } |
| | | } |
| | | msxml::IXMLDOMElement e = dw_list.GetRowElement(row); |
| | | string sguid = e.SelectSingleNode("@guid").text; |
| | | xaserverarg__ arg = new xaserverarg__; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("operate", "modify"); |
| | | arg.AddArg("guid", sguid); |
| | | arg.AddArg("tvOrgID", sOrgID); |
| | | arg.AddArg("tvOrgName", sOrgName); |
| | | arg.AddArg("tvRootOrgID", sRootOrgID); |
| | | arg.AddArg("tvRootOrgName", sRootOrgName); |
| | | openUrl("组织架构.vface/xpage/HrOrg/maint", arg); |
| | | return 1; |
| | | } |
| | | int OnTreeMoveNode(TEvent* evt, int p) |
| | | { |
| | | TVNNMHDR& nmtv = *(TVNNMHDR*)evt->notify.pnmh; |
| | | HTREEITEM xfrom = nmtv.FromItem; |
| | | HTREEITEM xto = nmtv.ToItem; |
| | | |
| | | int OnDeleteItem(string sguid) |
| | | { |
| | | int wid = tv_org.GetId(); |
| | | int hitem = treeview__::GetSelectedItem(wid); |
| | | int ditem = treeview__::GetChildItem(wid, hitem); |
| | | msxml::IXMLDOMElement e = treeview__::GetItemData(wid, ditem); |
| | | if (e) |
| | | { |
| | | string dguid = e.SelectSingleNode("@guid").text; |
| | | while (dguid != sguid) |
| | | { |
| | | ditem = treeview__::GetNextItem(wid, ditem); |
| | | e = treeview__::GetItemData(wid, ditem); |
| | | dguid = e.SelectSingleNode("@guid").text; |
| | | } |
| | | treeview__::DeleteItem(wid, ditem); |
| | | } |
| | | return 1; |
| | | } |
| | | int DeleteRow() |
| | | { |
| | | int row = dw_list.GetNextSelectRow(1); |
| | | if (row < 1) |
| | | { |
| | | row = dw_list.GetRow(); |
| | | if (row < 1) |
| | | { |
| | | //win__::MessageBox(GetHWND(),"请选中要删除的组织数据行!","提示",0); |
| | | return -1; |
| | | } |
| | | } |
| | | msxml::IXMLDOMElement e = dw_list.GetRowElement(row); |
| | | string sguid = e.SelectSingleNode("@guid").text; |
| | | string sName = e.selectSingleNode("OrgName").text; |
| | | sName += ""; |
| | | xml__ x = new xml__; |
| | | x.setNativePointer(x.CreateInstance()); |
| | | xaserverarg__ arg = new xaserverarg__; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("guid", sguid); |
| | | if (url::get("OrganizationStruct/child.OrgNums", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.GetXmlDoc().text); |
| | | return -1; |
| | | } |
| | | else |
| | | { |
| | | msxml::IXMLDOMElement ele = x.GetXmlDoc().documentElement; |
| | | string snums = ele.SelectSingleNode("@num").text; |
| | | int num = snums.toInt(); |
| | | if (num != 0) |
| | | { |
| | | win__::MessageBox(GetHWND(), "组织 " + sName + " 存在下级组织单元,禁止删除!", "提示", 0); |
| | | return 1; |
| | | } |
| | | } |
| | | int ret = MessageBox(GetHWND(), L"确定移动组织节点?", L"提示:", 1); |
| | | //trace(ret); |
| | | int wid = 0; |
| | | if (ret == 2) |
| | | { |
| | | tv_org.DeleteItem(xto); |
| | | return -1; |
| | | } |
| | | |
| | | int MB_YESNO = 0x00000004; |
| | | int IDYES = 6; |
| | | if (win__::MessageBox(GetHWND(), "确认要删除组织 " + sName + " 的信息吗?", "提示", MB_YESNO) != IDYES) return 1; |
| | | arg.AddArg("guid", sguid); |
| | | //trace(sguid); |
| | | xml__ x1 = new xml__; |
| | | x1.setNativePointer(x1.CreateInstance()); |
| | | if (url::post("/sale/data/OrganizationStruct/delete.HrOrg", arg.GetString(), x1) != 1) |
| | | { |
| | | string error = x1.GetXmlDoc().text; |
| | | trace(error); |
| | | } |
| | | else |
| | | { |
| | | //win32::MessageBox(GetHWND(),"删除成功!","提示",0); |
| | | dw_list.DeleteRow(row); |
| | | OnDeleteItem(sguid); |
| | | } |
| | | return 1; |
| | | } |
| | | //xstring fid = tv_org.GetItemData(wid, xfrom); |
| | | //xstring tid = tv_org.GetItemData(wid, xto); |
| | | HTREEITEM xtop = tv_org.GetParentItem(xto); |
| | | KXMLDOMElement ef = tv_org.GetItemData(xfrom); |
| | | KXMLDOMElement et = tv_org.GetItemData(xtop); |
| | | xstring fid = ef.selectSingleNode(L"@guid").text();//ef.xml; |
| | | xstring tid = et.selectSingleNode(L"@guid").text();//et.xml; |
| | | xml x; |
| | | |
| | | int Productlinemaint() |
| | | { |
| | | xaserverarg__ arg = new xaserverarg__; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("id", "产品线"); |
| | | openUrl("公共设置.vface/worknode/quickcode/config", arg); |
| | | //openUrl("下拉窗口.vface/xpage/hremployee/select", arg); |
| | | xaserverarg arg; |
| | | |
| | | return 1; |
| | | } |
| | | int setTree() |
| | | { |
| | | string str = "<vbox name='tree' >"; |
| | | str += "<xtree name='tv_org' imagelist='0' drag='true'>"; |
| | | str += "<treeitem src='xquery:[OrgChart.hr.xq]' src1='xquery:[OrgStructureRetrieve.xq]' xcaption='OrgName' xroot='/root' xpath='Org' xchildpath='Org' image='15' loop='yes' xdata='.'/>"; |
| | | str += "</xtree></vbox>"; |
| | | string xfNodeAgentArea = "tree"; |
| | | xnode__ anode = new xnode__; |
| | | anode.setNativePointer(GetAgentNode(xfNodeAgentArea)); |
| | | SetAgentNodeContent(anode, str); |
| | | tv_org = new treeview__; |
| | | tv_org.setNativePointer(this.GetControl("tv_org")); |
| | | AttachEvent("tv_org", "TVN_SELCHANGED", OnTreeSelecded); |
| | | int root = treeview__::GetRootItem(tv_org.GetId()); |
| | | if (root > 0) |
| | | { |
| | | treeview__::ExpandItemEx(tv_org.GetId(), root); |
| | | } |
| | | return 1; |
| | | } |
| | | //命令发布函数 |
| | | int OnCmdDispatch(string comdid) |
| | | { |
| | | if (comdid == "AddRow") { return AddRow(); } |
| | | else if (comdid == "ModifyRow") { return ModifyRow(); } |
| | | else if (comdid == "DeleteRow") { return DeleteRow(); } |
| | | else if (comdid == "OrgType") |
| | | { |
| | | xaserverarg__ arg = new xaserverarg__; |
| | | arg.setNativePointer(arg.CreateInstance()); |
| | | arg.AddArg("id", "组织类型"); |
| | | openUrl("公共设置.vface/worknode/quickcode/config", arg); |
| | | //openUrl("组织架构.vface/xpage/HrOrg/type"); |
| | | } |
| | | else if (comdid == "Refresh") |
| | | { |
| | | OnRetrieve(); |
| | | setTree(); |
| | | AttachEvent("tv_org", "TVN_ENDDRAG", OnTreeMoveNode); |
| | | } |
| | | else if (comdid == "Productlinemaint") |
| | | { |
| | | Productlinemaint(); |
| | | } |
| | | return 0; |
| | | } |
| | | arg.AddArg(L"from", fid); |
| | | arg.AddArg(L"to", tid); |
| | | //trace(et.xml); |
| | | //return 1; |
| | | if (xurl::post(L"OrganizationStruct/move.update.HrOrg", arg.GetString(), x) != 1) |
| | | { |
| | | trace(L"error:" + (xstring)x.xml()); |
| | | alert(L"移动组织节点出错!"); |
| | | tv_org.DeleteItem(xto); |
| | | return 0; |
| | | } |
| | | tv_org.DeleteItem(xfrom); |
| | | return 1; |
| | | } |
| | | |
| | | //命令处理事件 |
| | | int OnXCommand(ref TXCommandEvent evt, int p) |
| | | { |
| | | return OnCmdDispatch(evt.pStrID); |
| | | } |
| | | //xgridex双击 |
| | | int OnDoubleClicked(TEvent* evt, LPARAM p) |
| | | { |
| | | DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh; |
| | | int row = hdr.row; |
| | | if (row < 1 || row > dw_list.GetRowCount()) |
| | | return 1; |
| | | KXMLDOMElement e = dw_list.GetRowElement(row); |
| | | xstring sguid = e.selectSingleNode(L"@guid").text(); |
| | | xaserverarg& arg = *new xaserverarg; |
| | | |
| | | int OnAttachEvent() |
| | | { |
| | | //绑定工具条点击事件 |
| | | AttachEvent("WM_XCOMMAND", OnXCommand); |
| | | //获取焦点事件,用于重置工具条 |
| | | AttachEvent("WM_SETFOCUS", OnSetFocus); |
| | | //获得树的点击事件 |
| | | AttachEvent("tv_org", "TVN_SELCHANGED", OnTreeSelecded); |
| | | AttachEvent("tv_org", "TVN_ITEMEXPANDING", OnTreeExpanding); |
| | | AttachEvent("tv_org", "TVN_ENDDRAG", OnTreeMoveNode); |
| | | //双击 |
| | | AttachEvent("dw_list", "DWV_DOUBLECLICKED", OnDoubleClicked); |
| | | } |
| | | arg.AddArg(L"operate", L"modify"); |
| | | arg.AddArg(L"guid", sguid); |
| | | arg.AddArg(L"tvOrgID", sOrgID); |
| | | arg.AddArg(L"tvOrgName", sOrgName); |
| | | arg.AddArg(L"tvRootOrgID", sRootOrgID); |
| | | arg.AddArg(L"tvRootOrgName", sRootOrgName); |
| | | //trace(row.toString()); |
| | | //win::OpenWindow(L"dev:xpage[HrOrgMaint.xpage]",arg); |
| | | openUrl(L"组织架构.vface/xpage/HrOrg/maint", &arg); |
| | | return 1; |
| | | } |
| | | |
| | | int OnInitial() |
| | | { |
| | | SetAgent(); |
| | | int AddRow() |
| | | { |
| | | /*int wid = ; |
| | | int hitem=tv_org.GetSelectedItem(wid); |
| | | int root=tv_org.GetRootItem(wid); |
| | | if (hitem == root) |
| | | { |
| | | win32::MessageBox(GetHWND(),L"根组织!",L"提示",0); |
| | | return -1; |
| | | }*/ |
| | | //int row = dw_list.GetNextSelectRow(1); |
| | | //IXMLDOMElement e = dw_list.GetRowElement(row); |
| | | //xstring sguid = e.getAttribute(L"guid"); |
| | | |
| | | OnAttachEvent(); |
| | | xaserverarg& arg = *new xaserverarg; |
| | | |
| | | return 1; |
| | | } |
| | | arg.AddArg(L"operate", L"new0"); |
| | | arg.AddArg(L"guid", L""); |
| | | arg.AddArg(L"tvOrgID", sOrgID); |
| | | arg.AddArg(L"tvOrgName", sOrgName); |
| | | arg.AddArg(L"tvRootOrgID", sRootOrgID); |
| | | arg.AddArg(L"tvRootOrgName", sRootOrgName); |
| | | openUrl(L"组织架构.vface/xpage/HrOrg/maint", &arg); |
| | | return 1; |
| | | } |
| | | |
| | | int onload() |
| | | { |
| | | tv_org = new treeview__; |
| | | tv_org.setNativePointer(this.GetControl("tv_org")); |
| | | dw_list = new xdwgrid__; |
| | | dw_list.setNativePointer(this.GetControl("dw_list")); |
| | | dw_list.openUrl("组织架构.vface/template/HrOrg/list"); |
| | | dw_list.SetSelectionMode(1); |
| | | dw_list.SetReadOnly(true); |
| | | dw_list.SetColumnState("OrgPlat", false); |
| | | dw_list.SetColumnState("OrgComLeader", false); |
| | | dw_list.SetColumnState("OrgSupLeader", false); |
| | | dw_list.SetColumnState("OrgProLine", false); |
| | | int ModifyRow() |
| | | { |
| | | int row = dw_list.GetNextSelectRow(1); |
| | | if (row < 1) |
| | | { |
| | | row = dw_list.GetRow(); |
| | | if (row < 1) |
| | | { |
| | | MessageBox(GetHWND(), L"请选中要修改的组织数据行!", L"提示", 0); |
| | | return -1; |
| | | } |
| | | } |
| | | KXMLDOMElement e = dw_list.GetRowElement(row); |
| | | xstring sguid = e.selectSingleNode(L"@guid").text(); |
| | | xaserverarg& arg = *new xaserverarg; |
| | | |
| | | arg.AddArg(L"operate", L"modify"); |
| | | arg.AddArg(L"guid", sguid); |
| | | arg.AddArg(L"tvOrgID", sOrgID); |
| | | arg.AddArg(L"tvOrgName", sOrgName); |
| | | arg.AddArg(L"tvRootOrgID", sRootOrgID); |
| | | arg.AddArg(L"tvRootOrgName", sRootOrgName); |
| | | openUrl(L"组织架构.vface/xpage/HrOrg/maint", &arg); |
| | | return 1; |
| | | } |
| | | |
| | | int OnDeleteItem(xstring sguid) |
| | | { |
| | | int wid = 0; |
| | | HTREEITEM hitem = tv_org.GetSelectedItem(); |
| | | HTREEITEM ditem = tv_org.GetChildItem(hitem); |
| | | KXMLDOMElement e = tv_org.GetItemData(ditem); |
| | | if (e) |
| | | { |
| | | xstring dguid = e.selectSingleNode(L"@guid").text(); |
| | | while (dguid != sguid) |
| | | { |
| | | ditem = tv_org.GetNextItem(ditem); |
| | | e = tv_org.GetItemData(ditem); |
| | | dguid = e.selectSingleNode(L"@guid").text(); |
| | | } |
| | | tv_org.DeleteItem(ditem); |
| | | } |
| | | return 1; |
| | | } |
| | | int DeleteRow() |
| | | { |
| | | int row = dw_list.GetNextSelectRow(1); |
| | | if (row < 1) |
| | | { |
| | | row = dw_list.GetRow(); |
| | | if (row < 1) |
| | | { |
| | | //win::MessageBox(GetHWND(),L"请选中要删除的组织数据行!",L"提示",0); |
| | | return -1; |
| | | } |
| | | } |
| | | KXMLDOMElement e = dw_list.GetRowElement(row); |
| | | xstring sguid = e.selectSingleNode(L"@guid").text(); |
| | | xstring sName = e.selectSingleNode(L"OrgName").text(); |
| | | sName += L""; |
| | | xml x; |
| | | |
| | | xaserverarg arg; |
| | | |
| | | arg.AddArg(L"guid", sguid); |
| | | if (xurl::get(L"OrganizationStruct/child.OrgNums", arg.GetString(), x) != 1) |
| | | { |
| | | trace(x.text()); |
| | | return -1; |
| | | } |
| | | else |
| | | { |
| | | KXMLDOMElement ele = x.documentElement(); |
| | | xstring snums = ele.selectSingleNode(L"@num").text(); |
| | | int num = snums.toInt(); |
| | | if (num != 0) |
| | | { |
| | | MessageBox(GetHWND(), L"组织 " + sName + L" 存在下级组织单元,禁止删除!", L"提示", 0); |
| | | return 1; |
| | | } |
| | | } |
| | | |
| | | int MB_YESNO = 0x00000004; |
| | | int IDYES = 6; |
| | | if (MessageBox(GetHWND(), L"确认要删除组织 " + sName + L" 的信息吗?", L"提示", MB_YESNO) != IDYES) return 1; |
| | | arg.AddArg(L"guid", sguid); |
| | | //trace(sguid); |
| | | xml x1; |
| | | |
| | | if (xurl::post(L"/sale/data/OrganizationStruct/delete.HrOrg", arg.GetString(), x1) != 1) |
| | | { |
| | | xstring error = x1.text(); |
| | | trace(error); |
| | | } |
| | | else |
| | | { |
| | | //win32::MessageBox(GetHWND(),L"删除成功!",L"提示",0); |
| | | dw_list.DeleteRow(row); |
| | | OnDeleteItem(sguid); |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | int Productlinemaint() |
| | | { |
| | | xaserverarg& arg = *new xaserverarg; |
| | | |
| | | arg.AddArg(L"id", L"产品线"); |
| | | openUrl(L"公共设置.vface/worknode/quickcode/config", &arg); |
| | | //openUrl(L"下拉窗口.vface/xpage/hremployee/select", arg); |
| | | |
| | | return 1; |
| | | } |
| | | int setTree() |
| | | { |
| | | xstring str = L"<vbox name='tree' >"; |
| | | str += L"<xtree name='tv_org' imagelist='0' drag='true'>"; |
| | | str += L"<treeitem src='xquery:[OrgChart.hr.xq]' src1='xquery:[OrgStructureRetrieve.xq]' xcaption='OrgName' xroot='/root' xpath='Org' xchildpath='Org' image='15' loop='yes' xdata='.'/>"; |
| | | str += L"</xtree></vbox>"; |
| | | xstring xfNodeAgentArea = L"tree"; |
| | | xnode anode = GetAgentNode(xfNodeAgentArea); |
| | | SetAgentNode(anode, str); |
| | | tv_org = GetControl(L"tv_org"); |
| | | AttachEvent(L"tv_org", L"TVN_SELCHANGED", (FEvent)&HrOrg::OnTreeSelecded); |
| | | HTREEITEM root = tv_org.GetRootItem(); |
| | | if (!root) |
| | | { |
| | | tv_org.ExpandItemEx(root); |
| | | } |
| | | return 1; |
| | | } |
| | | //命令发布函数 |
| | | int OnCmdDispatch(xstring comdid) |
| | | { |
| | | if (comdid == L"AddRow") { return AddRow(); } |
| | | else if (comdid == L"ModifyRow") { return ModifyRow(); } |
| | | else if (comdid == L"DeleteRow") { return DeleteRow(); } |
| | | else if (comdid == L"OrgType") |
| | | { |
| | | xaserverarg& arg = *new xaserverarg; |
| | | |
| | | arg.AddArg(L"id", L"组织类型"); |
| | | openUrl(L"公共设置.vface/worknode/quickcode/config", &arg); |
| | | //openUrl(L"组织架构.vface/xpage/HrOrg/type"); |
| | | } |
| | | else if (comdid == L"Refresh") |
| | | { |
| | | OnRetrieve(); |
| | | setTree(); |
| | | AttachEvent(L"tv_org", L"TVN_ENDDRAG", (FEvent)&HrOrg::OnTreeMoveNode); |
| | | } |
| | | else if (comdid == L"Productlinemaint") |
| | | { |
| | | Productlinemaint(); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | //命令处理事件 |
| | | int OnXCommand(TEvent* evt, LPARAM param) |
| | | { |
| | | return OnCmdDispatch(evt->xcommand.pStrID); |
| | | } |
| | | |
| | | int OnAttachEvent() |
| | | { |
| | | //绑定工具条点击事件 |
| | | AttachEvent(L"WM_XCOMMAND", (FEvent)&HrOrg::OnXCommand); |
| | | //获取焦点事件,用于重置工具条 |
| | | AttachEvent(L"WM_SETFOCUS", (FEvent)&HrOrg::OnSetFocus); |
| | | //获得树的点击事件 |
| | | AttachEvent(L"tv_org", L"TVN_SELCHANGED", (FEvent)&HrOrg::OnTreeSelecded); |
| | | //AttachEvent(L"tv_org", L"TVN_ITEMEXPANDING", (FEvent)&HrOrg::OnTreeExpanding); |
| | | AttachEvent(L"tv_org", L"TVN_ENDDRAG", (FEvent)&HrOrg::OnTreeMoveNode); |
| | | //双击 |
| | | AttachEvent(L"dw_list", L"DWV_DOUBLECLICKED", (FEvent)&HrOrg::OnDoubleClicked); |
| | | return 1; |
| | | } |
| | | |
| | | int OnInitial() |
| | | { |
| | | SetAgent(); |
| | | |
| | | OnAttachEvent(); |
| | | |
| | | return 1; |
| | | } |
| | | |
| | | int onload() |
| | | { |
| | | tv_org = GetControl(L"tv_org"); |
| | | dw_list = GetControl(L"dw_list"); |
| | | dw_list.openUrl(L"组织架构.vface/template/HrOrg/list"); |
| | | dw_list.SetSelectionMode(1); |
| | | dw_list.SetReadOnly(true); |
| | | dw_list.SetColumnState(L"OrgPlat", false); |
| | | dw_list.SetColumnState(L"OrgComLeader", false); |
| | | dw_list.SetColumnState(L"OrgSupLeader", false); |
| | | dw_list.SetColumnState(L"OrgProLine", false); |
| | | |
| | | |
| | | OnInitial(); |
| | | OnInitial(); |
| | | |
| | | //OnCreateTree("00000000-0000-0000-0000-000000000000", 0); |
| | | int root = treeview__::GetRootItem(tv_org.GetId()); |
| | | if (root > 0) |
| | | { |
| | | treeview__::ExpandItemEx(tv_org.GetId(), root); |
| | | msxml::IXMLDOMElement ele = treeview__::GetItemData(tv_org.GetId(), root); |
| | | if (ele) |
| | | { |
| | | string ls_orgid = ele.SelectSingleNode("@guid").text; |
| | | sOrgID = ls_orgid + ""; |
| | | sOrgName = ele.selectSingleNode("OrgName").text; |
| | | OnRetrieve(); |
| | | } |
| | | } |
| | | //OnCreateTree(L"00000000-0000-0000-0000-000000000000", 0); |
| | | HTREEITEM root = tv_org.GetRootItem(); |
| | | if (root) |
| | | { |
| | | tv_org.ExpandItemEx(root); |
| | | KXMLDOMElement ele = tv_org.GetItemData(root); |
| | | if (ele) |
| | | { |
| | | if(ele.selectSingleNode(L"@guid")) |
| | | sOrgID = ele.selectSingleNode(L"@guid").text(); |
| | | if(ele.selectSingleNode(L"OrgName")) |
| | | sOrgName = ele.selectSingleNode(L"OrgName").text(); |
| | | OnRetrieve(); |
| | | } |
| | | } |
| | | |
| | | return 1; |
| | | } |
| | | ] |
| | | |
| | | ] |
| | | ] |
| | | return 1; |
| | | } |
| | | }; |