#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 "xcontrol/xshtml.hpp"
|
|
#include <vbusiness/vutil/publiccode.vutil.vbusiness.hpp>
|
#include "viewobject/view.base.hpp"
|
#include "vbusiness/vframe/frame.vframe.vbusiness.hpp"
|
#include "viewobject/productlibrary.view.hpp"
|
|
using xml = KXMLDOMDocument;
|
class __declspec(dllexport) ProductNewList : public xframe
|
{
|
public:
|
ProductNewList(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {}
|
public:
|
static ProductNewList* CreateInstance(void* implPtr, void* hWnd)
|
{
|
ProductNewList* pWin = new ProductNewList(implPtr, (HWND)hWnd);
|
return pWin;
|
}
|
public:
|
xdwgrid dw_list;
|
KXMLDOMElement imageElement;
|
xnode m_agentNode; //Agent Condition
|
|
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(TEvent * evt, int param)
|
{
|
//ÖØÖù¤¾ßÌõ
|
SetAgent();
|
return 1;
|
}
|
|
int OnRetrieve()
|
{
|
xml x;
|
xcontrol query = GetControl(L"sle_search");
|
xstring keyword = query.GetText();
|
//alert(keyword);
|
|
xaserverarg arg ;
|
|
arg.AddArg(L"keyword", keyword);
|
if (xurl::get(L"/sale/data/ProductLibrary3/data/list/newlist", arg.GetString(), x) != 1)
|
{
|
xstring error = x.text();
|
trace(error);
|
}
|
else
|
{
|
//alert(x.GetXml());
|
dw_list.Retrieve(x);
|
//dw_list.SetReadOnly(true);
|
}
|
|
for (int i = 1; i <= dw_list.GetColumnCount(); i++)
|
{
|
//trace(dw_list.GetColumnName(i));
|
if (dw_list.GetColumnName(i) != L"GoodsNo" &&
|
dw_list.GetColumnName(i) != L"EName" &&
|
dw_list.GetColumnName(i) != L"CName")
|
dw_list.SetReadOnlyColumn(i);
|
}
|
dw_list.Redraw();
|
return 1;
|
}
|
|
int OnRetrieveEx()
|
{
|
xml x;
|
xcontrol query = GetControl(L"sle_search");
|
xstring keyword = query.GetText();
|
//alert(keyword);
|
|
xaserverarg arg ;
|
|
arg.AddArg(L"keyword", keyword);
|
if (xurl::get(L"/sale/data/ProductLibrary3/data/list/newlistEx", arg.GetString(), x) != 1)
|
{
|
xstring error = x.text();
|
trace(error);
|
}
|
else
|
{
|
//alert(x.GetXml());
|
dw_list.Retrieve(x);
|
//dw_list.SetReadOnly(true);
|
}
|
|
for (int i = 1; i <= dw_list.GetColumnCount(); i++)
|
{
|
//trace(dw_list.GetColumnName(i));
|
if (dw_list.GetColumnName(i) != L"GoodsNo" &&
|
dw_list.GetColumnName(i) != L"EName" &&
|
dw_list.GetColumnName(i) != L"CName")
|
dw_list.SetReadOnlyColumn(i);
|
}
|
dw_list.Redraw();
|
return 1;
|
}
|
|
xml GetGoodsPropList(xstring guid)
|
{
|
xml x;
|
|
xaserverarg arg ;
|
|
arg.AddArg(L"guid", guid);
|
if (xurl::get(L"/sale/data/SO/goods/goodsprop/list", arg.GetString(), x) != 1)
|
{
|
xstring error = x.text();
|
alert(error);
|
}
|
return x;
|
}
|
|
xml GetGoodsPropListEx(xstring guid)
|
{
|
xml x;
|
|
xstring fields = L"<data>";
|
//fields +=L"<field name='HighestPrice' label='×î¸ß¼Û'/>";
|
//fields +=L"<field name='LowestPrice' label='×îµÍ¼Û'/>";
|
|
//fields +=L"<field name='BulkPrice' label='É¢»õ¼Û'/>";
|
//fields +=L"<field name='CardPrice' label='Ö½¿¨¼Û'/>";
|
//fields +=L"<field name='BuyPrice' label='²É¹º¼Û'/>";
|
//fields +=L"<field name='SupplierID' label='»õÔ´'/>";
|
|
fields += L"<field name='Packing' label='°ü×°·½Ê½'/>";
|
fields += L"<field name='PackingRate' label='ÿÏäÊýÁ¿'/>";
|
fields += L"<field name='VolumeDesc1' label='°ü×°³ßÂë'/>";
|
fields += L"<field name='GWPerPkg' label='Ã«ÖØ'/>";
|
fields += L"<field name='NWPerPkg' label='¾»ÖØ'/>";
|
//fields +=L"<field name='DeveloperID' label='¿ª·¢ÈËÔ±'/>";
|
fields += L"<field name='AttributeValue_1' label='²úÆ·ÊôÐÔ'/>";
|
//fields +=L"<field name='Remark' label='±¸×¢'/>";
|
|
fields += L"</data>";
|
x.loadXML(fields);
|
|
return x;
|
}
|
|
xstring makeHtml(int row)
|
{
|
xstring id = dw_list.GetGuid(row);
|
|
xml x = GetGoodsPropList(id);
|
xml x1 = GetGoodsPropListEx(id);
|
|
xstring html = L"<html><style> .text{ font-weight:400} .label { font-weight:400;}</style><body style='margin:2;background-color:#ccdccc none #f0f0f0 none'>";
|
html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >񅧏:</span><span style='width:90;font-size:10pt'>" + dw_list.GetItemString(row, L"SKUNo") +
|
L"</span> <span style='font-weight:700;width:50;font-size:10pt' >ÀàÏî:</span><span style='width:90;font-size:10pt'>" + dw_list.GetItemString(row, L"RefNo") +
|
L"</span></div>";
|
html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >¹«Ë¾ÐͺÅ:</span><span style='width:90;font-size:10pt'>" + dw_list.GetItemString(row, L"GoodsNo") +
|
L"</span></div>";
|
html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >Æ·Ãû:</span><span style='width:90;font-size:10pt'>" + dw_list.GetItemString(row, L"CName") +
|
L"</span></div>";
|
if (dw_list.GetItemString(row, L"CSpec") != L"")
|
html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >¹æ¸ñ:</span><span style='width:90;font-size:10pt'>" + dw_list.GetItemString(row, L"CSpec") +
|
L"</span></div>";
|
|
KXMLDOMNodeList fieldsEx = x1.selectNodes(L"data/field");
|
xstring ls_detail = L"";
|
xstring ls_item = L"";
|
xstring name;
|
xstring label;
|
int len = fieldsEx.length();
|
int i = 0;
|
|
for (i = 0; i < len; true)
|
{
|
int cnt = 0;
|
ls_item = L"";
|
while (cnt < 2)
|
{
|
name = fieldsEx.item(i).selectSingleNode(L"@name").text();
|
label = fieldsEx.item(i).selectSingleNode(L"@label").text();
|
ls_item += L"<td>" + label + L"</td>" + L"<td style='text-align:center'>" + dw_list.GetItemString(row, name) + L"</td>";
|
cnt++;
|
i++;
|
if (i == len)break;
|
}
|
ls_detail += L"<tr>" + ls_item + L"</tr>";
|
}
|
html += (xstring)L"<div style='margin-left:8px;margin-right:16px;'>" +
|
+L"<table><colgroup span='1' width='70'/><colgroup span='1' width='120'/><colgroup span='1' width='70'/><colgroup span='1' width='120'/>"
|
+ ls_detail
|
+ L"</table>"
|
+ L"</div>";
|
|
xstring ls_star = L"";
|
KXMLDOMNodeList fields = x.selectNodes(L"data/field");
|
len = fields.length();
|
|
ls_detail = L"";
|
if (len > 0)
|
html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >¼¼ÊõÒªÇó:</span></div>";
|
for (i = 0; i < len; true)
|
{
|
ls_item = L"";
|
|
int count = 0;
|
while (count < 2)
|
{
|
name = fields.item(i).selectSingleNode(L"@name").text();
|
label = fields.item(i).selectSingleNode(L"@label").text();
|
if (name == L"QualityTerm" || name == L"PackTerm" || label == L"ÖÊÁ¿" || label == L"°ü×°ÖÊÁ¿" || label == L"¼¼ÊõÒªÇó")
|
{
|
i++;
|
if (i >= len)count = 2;
|
continue;
|
}
|
else if (dw_list.GetItemString(row, name) == L"")
|
{
|
KXMLDOMNodeList options = fields.item(i).selectNodes(L"item");
|
int tlen = options.length();
|
xstring terms = L"";
|
for (int k = 0; k < tlen; k++)
|
{
|
if (options.item(k).text())
|
{
|
if (k > 0) terms += L", L";
|
terms += L"[" + xstring(options.item(k).text()) + L"]";
|
}
|
}
|
ls_star += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >" + label + L"*:</span><span style='width:90;font-size:10pt'>" + terms + L"</span></div>";
|
}
|
else
|
{
|
ls_item = L"<td>" + label + L"</td>" + L"<td>" + dw_list.GetItemString(row, name) + L"</td>";
|
count++;
|
}
|
i++;
|
if (i >= len)count = 2;
|
}
|
ls_item = L"<tr>" + ls_item + L"</tr>";
|
ls_detail += ls_item;
|
}
|
|
html +=(xstring) L"<div style='margin-left:8px;margin-right:16px;'>" +
|
+L"<table><colgroup span='1' width='70'/><colgroup span='1' width='120'/><colgroup span='1' width='70'/><colgroup span='1' width='120'/>"
|
+ ls_detail
|
+ L"</table>"
|
+ L"</div>";
|
if (dw_list.GetItemString(row, L"QualityTerm") != L"")
|
{
|
html += L"<div style='height:12px'/>";
|
html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >ÖÊÁ¿:</span></div>";
|
html += L"<div ><span style='margin-left:8px;margin-right:16px;font-weight:400;font-size:10pt' >" + dw_list.GetItemString(row, L"QualityTerm") + L"</span></div>";
|
}
|
|
if (dw_list.GetItemString(row, L"PackTerm") != L"")
|
{
|
html += L"<div style='height:12px'/>";
|
html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >°ü×°ÖÊÁ¿:</span></div>";
|
html += L"<div ><span style='margin-left:8px;margin-right:16px;font-weight:400;font-size:10pt' >" + dw_list.GetItemString(row, L"PackTerm") + L"</span></div>";
|
}
|
|
if (dw_list.GetItemString(row, L"Remark") != L"")
|
{
|
//html += L"<div style='height:12px'/>";
|
html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >±¸×¢:</span></div>";
|
html += L"<div ><span style='margin-left:8px;margin-right:16px;font-weight:400;font-size:10pt' >" + dw_list.GetItemString(row, L"Remark") + L"</span></div>";
|
}
|
|
html += L"<div style='height:24px'/>";
|
|
//ÐDZêÏî
|
html += ls_star;
|
|
//ÏÔʾͼƬ
|
/*
|
if (id != L"")
|
{
|
xml xp=new xml;
|
xp.setNativePointer(xml::CreateInstance());
|
xaserverarg arg_pic=new xaserverarg;
|
arg_pic.setNativePointer(arg_pic.CreateInstance());
|
arg_pic.AddArg(L"SKUID",id);
|
if(xurl::get(L"/sale/data/ProductLibrary3/pref/picture/imagelistSKU",arg_pic.GetString(),xp)!=1)
|
{
|
trace(L"xxx",xp.GetXml());
|
}else {
|
html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >ͼƬ:</span>" ;
|
KXMLDOMElement ep= xp.selectSingleNode(L"ImageList");
|
if (ep)
|
{
|
if (ep.SelectNodes(L"image")){
|
KXMLDOMNodeList nlistp = ep.SelectNodes(L"image");
|
int ip=0;
|
int lenp = nlistp.length();
|
for(ip=0;ip<lenp;ip++)
|
{
|
KXMLDOMElement xitemp = nlistp.item(ip);
|
xstring filename = xitemp.selectSingleNode(L"PicPath").text();
|
//trace(filename);
|
html += L"<control visible='layer' controlclass='ximage' data='' src='http://192.168.7.241:7001" + filename +L"'/>";
|
}
|
}
|
}
|
html += L"</div>";
|
}
|
}else {
|
xstring picname = L"1FA9E331-F95C-4E51-B80C-73FB9B911D8D.jpg";//dw_list.GetItemString(row,L"ImgName"); //ItemID+L".jpg";
|
xstring str = picname.mid(0,2);
|
str = str.upper();
|
xstring serversrc =L"http://192.168.7.241:1001/business/products/chanpin/"+str+L"/"+picname;
|
html += L"<div ><span style='font-weight:700;width:50;font-size:10pt' >ͼƬ:</span>";
|
html += L"<control visible='layer' controlclass='ximage' data='' src='"+ serversrc +L"'/></div>";
|
}
|
*/
|
html += L"</body></html>";
|
//trace(html);
|
return html;
|
}
|
|
int OnShowImage(xstring skuid)
|
{
|
ximageview im = GetControl(L"im1");
|
//im.RemoveImage();
|
im.Reset();
|
|
xml xp;
|
|
xaserverarg arg_pic ;
|
|
arg_pic.AddArg(L"SKUID", skuid);
|
if (xurl::get(L"/sale/data/ProductLibrary3/pref/picture/imagelistSKU", arg_pic.GetString(), xp) != 1)
|
{
|
trace(L"xxx:" + xstring(xp.xml(), true));
|
}
|
else
|
{
|
//trace(skuid+L" "+xp.GetXml());
|
imageElement = xp.documentElement();
|
KXMLDOMNodeList nlistp = xp.selectNodes(L"ImageList/image");
|
int lenp = nlistp.length();
|
for (int ip = 0; ip < lenp; ip++)
|
{
|
KXMLDOMElement xitem = nlistp.item(ip);
|
xstring picname = xitem.selectSingleNode(L"PicPath").text();
|
xstring goodno = xitem.selectSingleNode(L"GoodsNo").text();
|
if (picname == L"/business/products/Thumbs//")
|
picname = L"/business/products/Thumbs/00/00000000-0000-0000-0000-000000000000.jpg";
|
im.AddImages(picname, L"");
|
}
|
im.Redraw();
|
//win32::SendMessage(im.GetId(),0x000f,0,1);
|
//win32::InvalidateRect(im.GetId(),cast(0 as ref xrect),true);
|
}
|
return 1;
|
}
|
|
int OnRowChanged(TEvent* evt, int p)
|
{
|
DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh;
|
int row = hdr.row;
|
|
xshtml xs = GetControl(L"html_detail");
|
xstring html = makeHtml(row);
|
xs.SetContent(html);
|
xs.Redraw();
|
|
xstring id = dw_list.GetGuid(row);
|
OnShowImage(id);
|
|
return 1;
|
}
|
|
int OnImgDBClicked(TEvent* evt, int pr)
|
{
|
IMGNNMHDR& nmtv = *(IMGNNMHDR*)evt->notify.pnmh;
|
xstring src = nmtv.path;
|
/*if(src.length() > 60)
|
src = src.right(44);
|
else
|
src=src.mid(src.find(L"Thumbs", 0)+6, 50);
|
*/
|
xaserverarg& arg = *new xaserverarg;
|
|
//arg.AddArg(L"src",L"/business/products/chanpin"+src);
|
arg.AddArg(L"src", src);
|
|
//win::OpenWindow(L"dev:xpage[BigPicture.vx]",arg);
|
|
//int h = (L"/sale/view/ProductLibrary/xpage/bigpictureview", arg);
|
int h = openUrl(L"dev:xpage[BigPictureView.Product3.vx]", &arg);
|
|
/*
|
xwin x = new xwin;
|
x.setNativePointer(h);
|
m_winHwnd = x.GetHWND();
|
|
xstring sh = doc.GetXml();
|
int p = cast(sh as int);
|
win32::SendMessage(m_winHwnd, 0x401, p, 0);
|
*/
|
return 1;
|
}
|
|
int OnSave()
|
{
|
dw_list.AcceptText();
|
if (dw_list.GetRowCount() < 1) return 0;
|
xstring error = L"";
|
xml x;
|
|
dw_list.DwUpdateAllToEx(x);
|
xaserverarg arg ;
|
|
arg.AddArg(L"content", x.xml());
|
|
//trace(x.GetXml());
|
if (xurl::get(L"/sale/data/ProductLibrary3/update/productex", arg.GetString(), x) != 1)
|
{
|
error = x.text();
|
alert(error);
|
return 1;
|
}
|
else
|
{
|
alert(L"±£´æ³É¹¦");
|
arg.AddArg(L"No", dw_list.GetItemString(dw_list.GetRow(), L"SKUNo"));
|
if (xurl::get(L"/sale/data/business/message/productApplyedMessage", arg.GetString(), x) != 1)
|
{
|
error = x.text();
|
trace(error);
|
return 0;
|
}
|
}
|
return 1;
|
}
|
int OnMakeNewGoodsNo()
|
{
|
if (dw_list.GetItemString(dw_list.GetRow(), L"GoodsNo") != L"") return 1;
|
if (dw_list.GetRowCount() < 1) return 1;
|
xaserverarg arg;
|
|
arg.AddArg(L"EntityID", dw_list.GetGuid(dw_list.GetRow()));
|
KXMLDOMElement e = dw_list.GetRowElement(dw_list.GetRow());
|
arg.SetParam(L"data", e);
|
arg.SetParam(L"dw", dw_list);
|
arg.SetParam(L"HWND", GetHWND());
|
OpenWindow(L"dev:xpage[ProductNewItem.vx]", arg);
|
return 1;
|
|
}
|
|
//ÃüÁî·¢²¼º¯Êý
|
int OnCmdDispatch(xstring comdid)
|
{
|
if (comdid == L"xmCancel")
|
{
|
CloseWindow();
|
return 1;
|
}
|
if (comdid == L"xmMakeGoodsNo")
|
{
|
return OnMakeNewGoodsNo();
|
}
|
if (comdid == L"xmProductView")
|
{
|
OpenWindow(L"dev:xpage[Product.SearchDlg.vx]", 0);
|
return 1;
|
}
|
if (comdid == L"xmRefresh")
|
{
|
if (xaserver::GetUserNo() != L"00A01")
|
{
|
OnRetrieve();
|
}
|
else
|
{
|
OnRetrieveEx();
|
}
|
return 1;
|
}
|
if (comdid == L"xmDelete")
|
{
|
|
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();
|
|
int MB_YESNO = 0x00000004;
|
int IDYES = 6;
|
if (MessageBox(GetHWND(), L"È·ÈÏɾ³ýÂð£¿", L"Ìáʾ", MB_YESNO) != IDYES) return 1;
|
xml x;
|
|
xaserverarg arg ;
|
|
arg.AddArg(L"EntityID", sguid);
|
// trace(sguid);
|
if (xurl::post(L"/sale/data/ProductLibrary3/delete/Product", arg.GetString(), x) != 1)
|
{
|
xstring error = x.text();
|
trace(error);
|
}
|
else
|
{
|
KXMLDOMElement msg = x.selectNodes(L"process").item(0);
|
xstring success = msg.selectSingleNode(L"@finished").text();
|
if (success == L"0")
|
{
|
alert(msg.selectSingleNode(L"@errInfo").text());
|
}
|
else
|
{
|
MessageBox(GetHWND(), L"ɾ³ý³É¹¦£¡", L"Ìáʾ", 0);
|
dw_list.DeleteRow(row);
|
}
|
}
|
return 1;
|
}
|
|
if (comdid == L"xmSave") return OnSave();
|
|
return 0;
|
}
|
|
|
|
//ÃüÁî´¦Àíʼþ
|
int OnXCommand(TEvent* evt, int param)
|
{
|
return OnCmdDispatch(evt->xcommand.pStrID);
|
}
|
|
int OnAttachEvent()
|
{
|
//°ó¶¨¹¤¾ßÌõµã»÷ʼþ
|
AttachEvent(L"WM_XCOMMAND", (FEvent)&ProductNewList::OnXCommand);
|
//»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ
|
AttachEvent(L"WM_SETFOCUS", (FEvent)&ProductNewList::OnSetFocus);
|
AttachEvent(L"dw_list", L"DWV_ROWFOCUSCHANGED", (FEvent)&ProductNewList::OnRowChanged);
|
AttachEvent(L"im1", L"IMG_LDBCLICK", (FEvent)&ProductNewList::OnImgDBClicked);
|
return 1;
|
}
|
|
int onload()
|
{
|
dw_list = GetControl(L"dw_list");
|
dw_list.SetDataObject(ProductLibraryView::GetMaintListForm3(L""));
|
dw_list.SetEditUpperMode(true);
|
dw_list.SetReadOnly(true);
|
OnAttachEvent();
|
|
dw_list.SetColumnState(L"SKUID", false);
|
|
return 1;
|
}
|
|
int onloaded()
|
{
|
SetAgent();
|
|
if (xaserver::GetUserNo() != L"00A01") OnRetrieve();
|
|
|
return 1;
|
}
|
};
|