LiFan
2025-03-05 603ce4df28d440b9faf989073d6a587cf4065d67
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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#include <wobject/xstring.hpp>
#include <xcontrol/xtreeview.hpp>
#include <xcontrol/xdwgrid.hpp>
#include <wobject/xdouble.hpp>
#include <xcontrol/xlayersheet.hpp>
 
#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp"
#include "viewobject/view.base.hpp"
using xml = KXMLDOMDocument;
class __declspec(dllexport) Commentary : public xframe
{
 
public:
    
                string m_EntityID;
                string m_EntityType;
                string m_EntityConnect;
                string m_ConnectID;
 
                control__ m_Edit;
                html__ m_Html;
                combobox__ m_cb;
public:
    BindComputerDlgNew(void* implPtr, HWND hWnd) :xwin(implPtr, hWnd) {}
public:
    static BindComputerDlgNew* CreateInstance(void* implPtr, void* hWnd)
    {
        BindComputerDlgNew* pWin = new BindComputerDlgNew(implPtr, (HWND)hWnd);
        return pWin;
    }
                string GetGuid() {
                    return TApp::GetGuid();
                }
 
                int Init()
                {
                    if (m_EntityID == "") return -1;
 
                    xml__ x = new xml__;
                    x.setNativePointer(x.CreateInstance());
                    xaserverarg__ arg = new xaserverarg__;
                    arg.setNativePointer(arg.CreateInstance());
                    arg.AddArg("EntityID", m_EntityID);
                    arg.AddArg("EntityType", m_EntityType);
                    arg.AddArg("EntityConnect", m_EntityConnect);
                    if (url::get("/sale/data/Commentary/entity/notelist", arg.GetString(), x) == 1)
                    {
                        //trace(x.GetXml());
                        m_Html.SetContent(x.GetXml());
                        m_Html.Redraw();
                    }
                    return 1;
                }
 
                int AppendItem(xml__ x, msxml::IXMLDOMElement r, string name, string value)
                {
                    var e = x.GetXmlDoc().createElement(name);
                    e.text = value;
                    r.appendChild(e);
                    return 1;
                }
 
                int showAtt()
                {
                    xnode__ anode = new xnode__;
                    anode.setNativePointer(GetAgentNode("att"));
                    int s = combobox__::GetCount(m_cb.GetId());
                    xml__ x = new xml__;
                    x.setNativePointer(xml__::CreateInstance());
                    x.LoadXml("<vbox/>");
                    msxml::IXMLDOMElement ele = x.GetXmlDoc().documentElement;
                    //trace(str);
                    int i = 0;
                    for (i = 0; i < s; i++)
                    {
                        string tmp = combobox__::GetLBText(m_cb.GetId(), i);
                        //trace(tmp);
                        var e = x.GetXmlDoc().createElement("hbox");
                        e.setAttribute("height", "20");
                        var l = x.GetXmlDoc().createElement("xlabel");
                        l.setAttribute("caption", "" + tmp);
                        var b = x.GetXmlDoc().createElement("xtoolbutton");
                        b.setAttribute("width", "18");
                        b.setAttribute("name", "att_" + i.toString());
                        b.setAttribute("image", "1,5");
                        e.appendChild(l);
                        e.appendChild(b);
                        ele.appendChild(e);
                        var g = x.GetXmlDoc().createElement("xlabel");
                        g.setAttribute("height", "2");
                        g.setAttribute("style", "background-color:#000000");
                        ele.appendChild(g);
                    }
                    //trace(ele.xml);
                    SetAgentNodeContent(anode, ele.xml);
                    anode.SetWidthHeight(-1, i * 20 + 1);
                    return 1;
                }
 
                int addAtt()
                {
                    string guid = TApp::GetGuid();
                    string ret = xaserver__::UploadFile("attachment", guid + ".jpg", this.GetHWND(), "", false);
                    //trace(ret);
                    int nIndex = combobox__::AddItem(m_cb.GetId(), ret, guid + ".jpg");
                    showAtt();
                    return 1;
                }
 
                int delAtt(string no)
                {
                    int nIndex = no.toInt();
                    combobox__::DeleteItem(m_cb.GetId(), nIndex);
                    showAtt();
                    return 1;
                }
                msxml::IXMLDOMElement getAtt()
                {
                    int s = combobox__::GetCount(m_cb.GetId());
                    xml__ x = new xml__;
                    x.setNativePointer(xml__::CreateInstance());
                    x.LoadXml("<Attachment/>");
                    msxml::IXMLDOMElement ele = x.GetXmlDoc().documentElement;
                    //trace(str);
                    int i = 0;
                    for (i = 0; i < s; i++)
                    {
                        string tmp = combobox__::GetLBText(m_cb.GetId(), i);
                        string tmp2 = combobox__::GetitemData(m_cb.GetId(), i);
                        var e = x.GetXmlDoc().createElement("item");
                        e.setAttribute("name", "" + tmp);
                        e.setAttribute("file", "" + tmp2);
                        ele.appendChild(e);
                    }
                    return ele;
                }
                //ÃüÁî·¢²¼º¯Êý
                int OnCmdDispatch(string comdid)
                {
                    if (comdid == "xmOK")
                    {
                        if (m_EntityID == "") return 1;
 
                        xml__ x = new xml__;
                        x.setNativePointer(xml__::CreateInstance());
                        xaserverarg__ arg = new xaserverarg__;
                        arg.setNativePointer(arg.CreateInstance());
                        string value = m_Edit.GetText();
                        if (value == "")
                        {
                            alert("ÇëÌîдÅú×¢£¡");
                            return 1;
                        }
 
                        x.LoadXml("<Commentary update.new='1' update.modify='1'/>");
                        msxml::IXMLDOMElement ele = x.GetXmlDoc().documentElement;
                        AppendItem(x, ele, "CommentaryID", GetGuid());
                        AppendItem(x, ele, "EntityID", m_EntityID);
                        AppendItem(x, ele, "EntityType", m_EntityType);
                        AppendItem(x, ele, "Remark", value);
                        AppendItem(x, ele, "ParentConnect", m_EntityConnect);
                        AppendItem(x, ele, "ParentCommentaryID", m_ConnectID);
                        AppendItem(x, ele, "CreatorID", xaserver__::GetUserId());
                        ele.appendChild(getAtt());
 
                        //trace(ele.xml);
                        arg.AddArg("content", "<root>" + ele.xml + "</root>");
 
                        if (getUrl("/workflow/action/Commentary/bill.update", arg.GetString(), x) == 1)
                        {
                            //trace(x.GetXml());
                            //alert("Ìí¼Ó³É¹¦!");
                            m_Edit.SetText("");
                            combobox__::ResetContent(m_cb.GetId());
                            Init();
                            showAtt();
                            return 1;
                        }
                        else
                        {
                            alert("Ìí¼Óʧ°Ü!");
                            return -1;
                        }
                    }
                    else if (comdid == "xmAtt")
                    {
                        addAtt();
                    }
                    else if (comdid.left(4) == "att_")
                    {
                        delAtt(comdid.right(comdid.length() - 4));
                    }
                    else
                    {
                        CloseWindow();
                    }
                    return 1;
                }
 
                //ÃüÁî´¦Àíʼþ
                int OnXCommand(ref TXCommandEvent evt, int param)
                {
                    return OnCmdDispatch(evt.pStrID);
                }
 
                int OnHtmlClick(ref  TNotifyEvent evt, int p)
                {
                    ref  HTMLNMHDR p = evt.pnmh;
                    const string d = m_Html.GetData(p.object);
                    if (d == "") return -1;
                    string file = d.mid(0, d.find("|##@@|", 0));
                    string name = d.mid(d.find("|##@@|", 0) + 6, d.length());
 
                    xaserver__::CreateDirectory("C:/Temp");
                    int openRet = xaserver__::DownLoadFile(GetServerUrl(), "/business/supplierattachment/" + file, name, "C:/Temp/" + name);
                    if (openRet < 0)
                    {
                        alert("Îļþ´ò¿ªÊ§°Ü£¡");
                        return -1;
                    }
                    openRet = win__::ShellExecute(0, "open", "C:/Temp/" + name, "", "", 5);
                    if (openRet < 32)
                    {
                        alert("Îļþ´ò¿ªÊ§°Ü2£¡");
                        return -1;
                    }
 
                    return -1;
                }
 
                int OnAttachEvent()
                {
                    //°ó¶¨¹¤¾ßÌõµã»÷ʼþ
                    AttachEvent("WM_XCOMMAND", OnXCommand);
                    AttachEvent("note", "HTC_OBJECTCLICKED", OnHtmlClick);
                }
 
                int onload()
                {
                    OnAttachEvent();
 
                    m_Edit = new control__;
                    m_Edit.setNativePointer(GetControl("Txt"));
 
                    m_Html = new html__;
                    m_Html.setNativePointer(GetControl("note"));
 
                    m_cb = new html__;
                    m_cb.setNativePointer(GetControl("attlist"));
 
                    m_EntityID = "";
                    m_EntityType = "";
                    m_EntityConnect = "";
                    m_ConnectID = "";
 
                    if (this.GetParam())
                    {
                        xaserverarg__ arg = this.GetParam();
                        m_EntityID = arg.GetArgString("EntityID");
                        m_EntityType = arg.GetArgString("m_EntityType");
                        m_EntityConnect = arg.GetArgString("m_EntityConnect");
                    }
                    Init();
 
                    return 1;
                }
            ]
        ]
]