LiFan
2024-07-22 edf8a80adca1044f17381ed7ddccbf2947461f2b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
ÿþ#include <wobject/xstring.hpp>
#include <xcontrol/xtreeview.hpp>
#include <xcontrol/xdwgrid.hpp>
#include <wobject/xdouble.hpp>
#include <xcontrol/xlayersheet.hpp>
#include <xcontrol/xdatetimepick.hpp>
#include <xcontrol/ximageview.hpp>
 
#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp"
#include "viewobject/view.base.hpp"
 
 
using xml = KXMLDOMDocument;
    class __declspec(dllexport) ProductPictureView3 : public xframe
    {
    public:
        ProductPictureView3(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {}
    public:
        static ProductPictureView3* CreateInstance(void* implPtr, void* hWnd)
        {
            return  new ProductPictureView3(implPtr, (HWND)hWnd);
        }
    public:
        ximageview im;
        xstring CategoryID;
        xml doc;
        int m_winHwnd;
        int ParentHWND;
    
        int hiddenBox(xstring name, bool f)
        {
            //xnode anode = GetAgentNode(name);
            xnode anode = GetAgentNode(name);
            int LayerFlow_None=0x00000001;
            int LayerFlow_UnLayer=0x00000100;
            int LayerFlow_NS=0x00000004;
            int LayerFlow_WE=0x00000008;
            int LayerFlow_Control=0x00000010;        
            if(f)
                anode.SetLayerFlow(LayerFlow_WE | LayerFlow_Control);
            else
                anode.SetLayerFlow(LayerFlow_None | LayerFlow_UnLayer);
            return 1;
        }
    
        int OnImgDBClicked(ref TNotifyEvent evt,int pr)
        {
            ref IMGNNMHDR nmtv = evt.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 ;
            
            //arg.AddArg(L"src",L"/business/products/chanpin"+src);    
            arg.AddArg(L"src",src);    
            
            //win::OpenWindow(L"dev:xpage[BigPicture.vx]",arg);    
            
            int h = openUrl(L"/sale/view/ProductLibrary/xpage/bigpictureview", arg);    
            return 1;
            
            xwin x = new xwin;
            x.setNativePointer(h);
            m_winHwnd = x.GetHWND();
            
            xstring sh = doc.xml();
            int p = cast(sh as int);
            SendMessage(m_winHwnd, 0x401, p, 0);
            return 1;
        }    
            
        int OnCmdDispatch(xstring comdid)
        {
            if(comdid == L"xmSave")
            {
                xstring x=L" ".space(256);
                xutil::OpenDialog(GetHWND(),x);
                if(x == L"") return 0;
            
                KXMLDOMElement e=  doc.selectSingleNode(L"ImageList");
                KXMLDOMNodeList nlist = e.SelectNodes(L"image");
 
                int hCursor = xutil::SetCursorWait();
                int s = nlist.length();
                xstring result = L"";
                for(int i=0; i<s; i++)
                {
                    KXMLDOMElement xitem = nlist.item(i);
                    xstring picname = xitem.selectSingleNode(L"PicPath").text(); 
                    if(picname == L"") continue;
                    xstring goodsno = xitem.selectSingleNode(L"GoodsNo").text(); 
                    xstring src = picname.mid(26,picname.length()());
                    //trace(picname + L"-->" + src + L"\r\n");
                    if(src == L"" || src == L"/") continue;
                    int openRet = xaserver::DownLoadFile(GetServerUrl(),L"/business/products/chanpin/"+src,L"",x+L"/"+goodsno+L".jpg");
                    if(openRet < 0)
                    {
                        //trace(picname + L"-->" + src + L"\r\n");
                        result += goodsno + L"   ";
                    }
                }
                xutil::RestoreCursor(hCursor);
                if(result != L"")
                    alert(result + L"\r\nåN
N'÷S N}þVGr1Y%!");
                else
                    alert(L"ÝOX[Œ[Õk!");
            }
            else if(comdid == L"xmDelete")
            {
                int hh = ParentHWND;
                if(hh > 0)
                {
                    int nIndex = im.GetSelectIndex();
                    if(nIndex < 0 || nIndex >= im.GetImageCount()) return 0;
                    im.RemoveImage(nIndex);
                    im.Redraw();
                    xstring comd = L"Delete:"+nIndex.toString();
                    SendMessage(hh, 0x401, comd,0);
                }
            }
            return 0;
        }
                
        int OnXCommand(TEvent* evt, LPARAM param)
        {
            return OnCmdDispatch(evt->xcommand.pStrID);
        }
                
        int OnCombboChange(ref TCommandEvent evt,int lParam)
        {
            xcombobox xc = GetControl(L"precent");                
            xstring text = xcombobox::GetLBText(xc.GetId());
            int p = text.toInt();
            if(p == 0) p = 100;
            im.Preview(p);
            return 1;
        }
    
        int OnAttachEvent()
        {
            AttachEvent(L"im1",L"IMG_LDBCLICK", (FEvent)&ProductPictureView3::OnImgDBClicked);
            AttachEvent(L"WM_XCOMMAND", (FEvent)&ProductPictureView3::OnXCommand);
            AttachEvent(L"precent",L"CBN_SELCHANGE", (FEvent)&ProductPictureView3::OnCombboChange);
            return 1;
        }
    
        int init()
        {
            xml x;
            
            xaserverarg arg;
 
            if (GetParam())
                arg = GetParam();
            else
                return 0;
            
            if(xurl::get(GetEntityName(1)+L"/pref/category/picture/list",arg.GetString(),x)!=1)
            {
                trace(L"xxx",x.xml());
                return 0;
            }
            //trace(arg.GetString());
            //trace(x.xml());        
            return 1;
        }
        
        int onload()
        {    
            im = GetControl(L"im1");
            OnAttachEvent();
            
            ParentHWND = 0;
    
            if (GetParam())
            {
                xaserverarg arg;
                    
                arg = GetParam();
                CategoryID=arg.GetArgString(L"parentID");
                xstring hh = arg.GetArgString(L"ParentHWND");
                ParentHWND = hh.toInt();
                xstring openflag = arg.GetArgString(L"OpenFlag");
                //alert(openflag);
                if(openflag != L"0") hiddenBox(L"xmDelete", false);
                //trace(arg.GetString());    
                xml x;
                
            //alert(arg.GetString());
                //if(xurl::get(L"/sale/data/product/pref/category/picture/list",arg.GetString(),x)!=1)
                if(xurl::get(L"/sale/data/ProductLibrary3/pref/picture/imagelist",arg.GetString(),x)!=1)
                {
                    trace(L"xxx",x.xml());
                    return 0;
                }
                doc = x;
                //alert(x.xml());        
                KXMLDOMElement e=  x.selectSingleNode(L"ImageList");
                KXMLDOMNodeList  nlist = e.SelectNodes(L"image");
                int i;
                int s = nlist.length();
                for(i=0;i<s;i++)
                {
                    KXMLDOMElement xitem = nlist.item(i);
                    xstring picname = xitem.selectSingleNode(L"PicPath").text(); 
                    xstring goodno = xitem.selectSingleNode(L"GoodsNo").text();     
                    //trace(picname + L"\r\n");        
                    if(picname == L"/business/products/Thumbs//")
                        picname = L"/business/products/Thumbs/00/00000000-0000-0000-0000-000000000000.jpg";
                    im.AddImages(picname, goodno);
                }
                im.Redraw();
            }else {
                im.AddImages(L"/business/products/chanpin/BL-002/291679.jpg", L"x1");
                im.AddImages(L"/business/products/chanpin/BL-002/291759.jpg", L"x2");
                im.AddImages(L"/business/products/chanpin/BL-002/417884.jpg", L"x3");
                im.Redraw();
            }
            SetFocus(im.GetId());
                    
            xstring userno = xaserver::GetUserNo();
            /*if(userno == L"1003" || userno == L"1137" || userno == L"admin") {
                //hiddenBox();
            } else {
                hiddenBox(L"xmSave", false);
            }*/
            hiddenBox(L"xmSave", false);
            
            return -1;
        }
    };
]