采购订单编辑
# FastWeb 采购订单编辑
采购订单编辑功能源于ERP设计实务,可参考采购订单编辑的示例代码进行修改。界面包含 billno
参数,在URL调用中加入订单号,可查询到订单信息。
# 1. 设计Bean模块
点击 [云服务工具]
- [Bean模块(Web)]
,打开Bean模块管理界面,点击 [添加]
按钮,创建一个Bean模块,设置示例如下。点击 [保存]
按钮。

选择刚才创建的Bean,点击 [Bean设计]
按钮,进入Bean设计的主界面,设计的界面样式如下。可参考采购订单编辑示例中提供的界面。

Bean模块在原有基础上修改的部分如下。
修改 UgWebRunFrameOnAfterRunScript
事件。
//JScript
function UgWebRunFrameOnAfterRunScript(sender)
//页面翻译
{
var finterid,vdts;
UGMM.LC(Self);
vdts = new TUgRFDataSet(nil);
vdts.Connection = GETRFWEB;
vdts.SQL.Text = "select FInterID from Pur_Order where FBillNo =" + QuotedStr(UniApplication.Parameters.Values["bilino"]);
vdts.Open;
if (vdts.RecordCount == 0){
return;
}
finterid = vdts.FieldByName("FInterID").AsString;
//数据集信息初始化
dts0.Connection = GETRFWEB;
dts0.SQL.Text = "select a.* from Pur_Order a(NOLOCK) where a.FInterID =:FInterID";
dts0.ParamByName("FInterID").AsString = finterid;
dts0.Open;
dts1.Connection = GETRFWEB;
dts1.SQL.Text = "select a.* from Pur_OrderEntry a(NOLOCK) where a.FInterID =:FInterID order by a.FEntryID";
dts1.ParamByName("FInterID").AsString = finterid;
dts1.Open;
//单据列表(从主窗口中获取)
dtsList.Connection = GETRFWEB;
dtsList.SQL.Text = "select FInterID FROM Pur_Order where 1=1";
dtsList.Open;
//状态
dtsFStatus.Connection = GETRFWEB;
dtsFStatus.SQL.Text = "Select FName='" + UGMM.LT("已作废") + "',FID = 0 union Select FName='" + UGMM.LT("草 稿") + "',FID = 1 union Select FName='" + UGMM.LT("已审核") + "',FID = 2 ORDER BY FID desc";
dtsFStatus.Open;
//客户资料
dtsFCustID.Connection = GETRFWEB;
dtsFCustID.SQL.Text = "select a.FCustCode,a.FShortName as FCustName,a.FCustName as FCustFullName,a.FEmpCode,a.FEmpName,a.FAddress,a.FPhone1,a.FPhone2,a.FTel,a.FContacts,a.FHouseBank,a.FHouseBnkAct, " +
"A.FDeptCode,A.FDeptName,a.FInterID as FCustID,a.FEmpID,a.FDeptID,A.FSettleID,A.FSettleName,A.FPayItemID,A.FPayItemName,A.FSaleType, a.FSaleType as FOrderType " +
"from Basic_Cust A left join Basic_employee b on a.FEmpID = b.FInterID where isnull(a.FfrozenFor,0) = 0 order by FCustCode";
dtsFCustID.Open;
//部门
dtsFDeptID.Connection = GETRFWEB;
dtsFDeptID.SQL.Text = "SELECT FGroupID as FDeptID,FGroupCode as FDeptCode,FGroupName as FDeptName FROM Dict_GroupInfo";
dtsFDeptID.Open;
//业务员
dtsFEmpID.Connection = GETRFWEB;
dtsFEmpID.SQL.Text = "SELECT FInterID as FEmpID,FEmpCode,FEmpName FROM Basic_Employee";
dtsFEmpID.Open;
//币种
dtsFCurrencyID.Connection = GETRFWEB;
dtsFCurrencyID.SQL.Text = "SELECT FCode as FCurrencyCode,FName as FCurrencyName,FInterID AS FCurrencyID,FExRate AS FExchangeRate FROM Basic_Currency";
dtsFCurrencyID.Open;
//物料
dtsFItemCode.Connection = GETRFWEB;
dtsFItemCode.SQL.Text = "select A.FInterID as FItemID,A.FItemCode,A.FItemName,A.FItemSpec,A.FUnitID,A.FUnitCode,A.FUnitName," +
"b.FCoefficient,dbo.fun_GetPY(A.FItemName) as PY "+
"from Basic_Item A left join basic_Unit B on a.FUnitID = b.FInterID " +
"left join Basic_ItemGroup c on a.FGroupID = c.FInterID " +
"where A.FTypeID=1 and isnull(FfrozenFor,0) = 0 " +
"Order by FItemCode";
dtsFItemCode.Open;
//公司资料
dtsCompany.Connection = GETRFWEB;
dtsCompany.SQL.Text = "select top 1 * FROM Basic_Company";
dtsCompany.Open;
//供应商资料
dtsFSupplyID.Connection = GETRFWEB;
dtsFSupplyID.SQL.Text = "select a.FSupplyCode,a.FSupplyName,b.FEmpCode,b.FEmpName,c.FGroupCode AS FDeptCode,c.FGroupName AS FDeptName,A.FNote," +
"a.FInterID AS FSupplyID,a.FEmpID,c.FGroupID AS FDeptID from Basic_Supply A" +
" LEFT JOIN dbo.Basic_Employee b ON a.FEmpID=B.FInterID" +
" LEFT JOIN Dict_GroupInfo C ON b.FDeptID = c.FGroupID order by FSupplyCode";
dtsFSupplyID.Open;
//添加打印报表
UGMM.AddReport(btnPrintMenu,//报表功能附加到哪个按钮下,名称为对应的控件名称,此处仅为示例,实际使用修改为你使用的名称,比如UgMenuButton01
UGMM.ReportDesignPermission(Self),//报表设计权限【动态模块:当前登陆用户等于模块开发者时】
self.Guid);
vdts.Free;
}
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
//PasScript
procedure UgWebRunFrameOnAfterRunScript(sender:tobject);
//页面翻译
var
finterid: string;
vdts: TUgRFDataSet;
begin
UGMM.LC(Self);
vdts := TUgRFDataSet.Create(nil);
vdts.Connection := GETRFWEB;
vdts.SQL.Text := 'select FInterID from Pur_Order where FBillNo =' + QuotedStr(UniApplication.Parameters.Values['billno']);
vdts.Open;
if (vdts.RecordCount = 0) then
exit;
finterid := vdts.FieldByName('FInterID').AsString;
//数据集信息初始化
dts0.Connection := GETRFWEB;
dts0.SQL.Text := 'select a.* from Pur_Order a(NOLOCK) where a.FInterID =:FInterID';
dts0.ParamByName("FInterID").AsString := finterid;
dts0.Open;
dts1.Connection := GETRFWEB;
dts1.SQL.Text := 'select a.* from Pur_OrderEntry a(NOLOCK) where a.FInterID =:FInterID order by a.FEntryID';
dts1.ParamByName('FInterID').AsString := finterid;
dts1.Open;
//单据列表(从主窗口中获取)
dtsList.Connection := GETRFWEB;
dtsList.SQL.Text := 'select FInterID FROM Pur_Order where 1=1';
dtsList.Open;
//状态
dtsFStatus.Connection := GETRFWEB;
dtsFStatus.SQL.Text := 'Select FName=''' + UGMM.LT('已作废') + ''',FID = 0 union Select FName=''' + UGMM.LT('草 稿') + ''',FID = 1 union Select FName=''' + UGMM.LT('已审核') + ''',FID = 2 ORDER BY FID desc';
dtsFStatus.Open;
//客户资料
dtsFCustID.Connection := GETRFWEB;
dtsFCustID.SQL.Text := 'select a.FCustCode,a.FShortName as FCustName,a.FCustName as FCustFullName,a.FEmpCode,a.FEmpName,a.FAddress,a.FPhone1,a.FPhone2,a.FTel,a.FContacts,a.FHouseBank,a.FHouseBnkAct, ' +
'A.FDeptCode,A.FDeptName,a.FInterID as FCustID,a.FEmpID,a.FDeptID,A.FSettleID,A.FSettleName,A.FPayItemID,A.FPayItemName,A.FSaleType, a.FSaleType as FOrderType ' +
'from Basic_Cust A left join Basic_employee b on a.FEmpID = b.FInterID where isnull(a.FfrozenFor,0) = 0 order by FCustCode';
dtsFCustID.Open;
//部门
dtsFDeptID.Connection := GETRFWEB;
dtsFDeptID.SQL.Text := 'SELECT FGroupID as FDeptID,FGroupCode as FDeptCode,FGroupName as FDeptName FROM Dict_GroupInfo';
dtsFDeptID.Open;
//业务员
dtsFEmpID.Connection := GETRFWEB;
dtsFEmpID.SQL.Text := 'SELECT FInterID as FEmpID,FEmpCode,FEmpName FROM Basic_Employee';
dtsFEmpID.Open;
//币种
dtsFCurrencyID.Connection := GETRFWEB;
dtsFCurrencyID.SQL.Text := 'SELECT FCode as FCurrencyCode,FName as FCurrencyName,FInterID AS FCurrencyID,FExRate AS FExchangeRate FROM Basic_Currency';
dtsFCurrencyID.Open;
//物料
dtsFItemCode.Connection := GETRFWEB;
dtsFItemCode.SQL.Text := 'select A.FInterID as FItemID,A.FItemCode,A.FItemName,A.FItemSpec,A.FUnitID,A.FUnitCode,A.FUnitName,' +
'b.FCoefficient,dbo.fun_GetPY(A.FItemName) as PY '+
'from Basic_Item A left join basic_Unit B on a.FUnitID = b.FInterID ' +
'left join Basic_ItemGroup c on a.FGroupID = c.FInterID ' +
'where A.FTypeID=1 and isnull(FfrozenFor,0) = 0 ' +
'Order by FItemCode';
dtsFItemCode.Open;
//公司资料
dtsCompany.Connection := GETRFWEB;
dtsCompany.SQL.Text := 'select top 1 * FROM Basic_Company';
dtsCompany.Open;
//供应商资料
dtsFSupplyID.Connection := GETRFWEB;
dtsFSupplyID.SQL.Text := 'select a.FSupplyCode,a.FSupplyName,b.FEmpCode,b.FEmpName,c.FGroupCode AS FDeptCode,c.FGroupName AS FDeptName,A.FNote,' +
'a.FInterID AS FSupplyID,a.FEmpID,c.FGroupID AS FDeptID from Basic_Supply A' +
' LEFT JOIN dbo.Basic_Employee b ON a.FEmpID=B.FInterID' +
' LEFT JOIN Dict_GroupInfo C ON b.FDeptID = c.FGroupID order by FSupplyCode';
dtsFSupplyID.Open;
//添加打印报表
UGMM.AddReport(btnPrintMenu,//报表功能附加到哪个按钮下,名称为对应的控件名称,此处仅为示例,实际使用修改为你使用的名称,比如UgMenuButton01
UGMM.ReportDesignPermission(Self),//报表设计权限【动态模块:当前登陆用户等于模块开发者时】
self.Guid);
vdts.Free;
end;
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
// Make sure to add code blocks to your code group
新增 UgWebRunFrameOnAjaxEvent
事件。
//JScript
function UgWebRunFrameOnAjaxEvent(sender,eventname,params)
//WebSocket推送更新订单号,推送更新的格式
//{
// "username": "demo", //运行IsoBean的用户,修改为实际运行的用户
// "action": "callback",
// "tag": "0",
// "data": {
// "callbackcomponent": "wb-vis-0004_purorder_edit",
// "callbackeventname": "update",
// "callbackparams": [
// {
// "paramname": "billno",
// "paramvalue": "PUR21052801" //查询的内容,修改为想查询的内容
// }
// ]
// }
//}
{
if (Sametext(eventname,"update"))
{
var finterid,vdts;
vdts = new TUgRFDataSet(nil);
try{
vdts.Connection = GETRFWEB;
vdts.SQL.Text = "select FInterID from Pur_Order where FBillNo =" + QuotedStr(Params.Values["billno"]);
vdts.Open;
if (vdts.RecordCount == 0){
return;
}
finterid = vdts.FieldByName("FInterID").AsString;
//数据集信息初始化
dts0.Connection = GETRFWEB;
dts0.SQL.Text = "select a.* from Pur_Order a(NOLOCK) where a.FInterID =:FInterID";
dts0.ParamByName("FInterID").AsString = finterid;
dts0.Open;
dts1.Connection = GETRFWEB;
dts1.SQL.Text = "select a.* from Pur_OrderEntry a(NOLOCK) where a.FInterID =:FInterID order by a.FEntryID";
dts1.ParamByName("FInterID").AsString = finterid;
dts1.Open;
}
Finally
{
vdts.Free;
}
}
}
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
//PasScript
procedure UgWebRunFrameOnAjaxEvent(Sender: TObject;Eventname:String;params:TStringList);
//WebSocket推送更新订单号,推送更新的格式
//{
// "username": "demo", //运行IsoBean的用户,修改为实际运行的用户
// "action": "callback",
// "tag": "0",
// "data": {
// "callbackcomponent": "wb-vis-0004_purorder_edit",
// "callbackeventname": "update",
// "callbackparams": [
// {
// "paramname": "billno",
// "paramvalue": "PUR21052801" //查询的内容,修改为想查询的内容
// }
// ]
// }
//}
var
finterid: String;
vdts: TUgRFDataSet;
begin
if (Sametext(eventname,'update')) then
begin
vdts := TUgRFDataSet.Create(nil);
try
vdts.Connection := GETRFWEB;
vdts.SQL.Text := 'select FInterID from Pur_Order where FBillNo =' + QuotedStr(Params.Values['billno']);
vdts.Open;
if (vdts.RecordCount = 0)
exit;
finterid := vdts.FieldByName('FInterID').AsString;
//数据集信息初始化
dts0.Connection := GETRFWEB;
dts0.SQL.Text := 'select a.* from Pur_Order a(NOLOCK) where a.FInterID =:FInterID';
dts0.ParamByName('FInterID').AsString := finterid;
dts0.Open;
dts1.Connection := GETRFWEB;
dts1.SQL.Text := 'select a.* from Pur_OrderEntry a(NOLOCK) where a.FInterID =:FInterID order by a.FEntryID';
dts1.ParamByName('FInterID').AsString := finterid;
dts1.Open;
Finally
vdts.Free;
end;
end;
end;
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
// Make sure to add code blocks to your code group
# 2. 设计IsoBean模块
点击 [云服务工具]
- [IsoBean模块管理]
,打开IsoBean模块管理界面,点击 [添加]
按钮,按照以下提示创建一个IsoBean模块。点击 [保存]
按钮。

创建完成后,选择创建的IsoBean,点击 [API设计]
,创建的API请按照以下方式进行设置。
//JScript
function RestAPI()
{
var url,billno,tag;
billno = iif(URLParams.Values["billno"]=="",APIParams.Values["billno"],URLParams.Values["billno"]);
tag = iif(URLParams.Values["tag"]=="",APIParams.Values["tag"],URLParams.Values["tag"]);
url = "/?bean="+Var_Bean + "&userkey=" + Var_UserKey +"&language=" + Var_Language+ "&billno=" + billno + "&tag=" + tag;
Result = " <html>"
+ " <body style=\"margin: 0px;height: 100%;width: 100%;\">"
+ " <iframe width=\"100%\" height=\"100%\" frameborder=\"no\" border=\"0\" marginwidth=\"0px\" marginheight=\"0px\" scrolling=\"no\" allowtransparency=\"yes\" src=\"" + url + "\""
+ " width=\"100%\""
+ " height=\"100%\""
+ " >"
+ " </iframe>"
+ " </body>"
+ " </html>";
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//PasScript
function RestAPI:String;
var
url: String;
billno: String;
tag: String;
begin
billno := iif(URLParams.Values['billno']='',APIParams.Values['billno'],URLParams.Values['billno']);
tag := iif(URLParams.Values['tag']='',APIParams.Values['tag'],URLParams.Values['tag']);
url := '/?bean='+Var_Bean + '&userkey=' + Var_UserKey + '&billno=' + billno + '&language=' + Var_Language + "&tag=" + tag;
Result := ' <html>'
+ ' <body style="margin: 0px;height: 100%;width: 100%;">'
+ ' <iframe width="100%" height="100%" frameborder="no" border="0" marginwidth="0px" marginheight="0px" scrolling="no" allowtransparency=\"yes\" src="' + url + '"'
+ ' width="100%"'
+ ' height="100%"'
+ ' >'
+ ' </iframe>'
+ ' </body>'
+ ' </html>';
end;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// Make sure to add code blocks to your code group
# 3. 发布IsoBean
保存后,返回列表界面,选择刚才创建的IsoBean模块,点击 [IsoBean发布]
,打开 IsoBean 发布界面。

选择要发布的用户(admin),点击 [IsoBean 选择...]
,从打开的IsoBean列表中选择IsoBean模块,双击导入至发布列表中,点击 [保存]
按钮,然后点击 [确定]
按钮关闭发布界面。
重新返回API设计界面,点击 [测试]
图标按钮,打开界面。点击 [Send]
按钮查看运行的结果。如果返回的结果中包含数据信息,则IsoBean创建成功。

按照本节开头的方式将IsoBean发布给其他用户,之后,可使用 http://localhost:8888/?isobean=IB_wb-vis-0004_purorder_edit&userkey={user_guid}&billno={billno} (opens new window) 打开页面。{user_guid}
为发布用户的ID,请注意,{billno}
中的内容需经过 URL编码 (opens new window) 后才可作为参数值使用。
当此 IsoBean 处于运行状态时,可使用 WebSocket 发送以下消息模板以更新查询信息。
{
"username": "demo", //运行IsoBean的用户,修改为实际运行的用户
"action": "callback",
"tag": "0",
"data": {
"callbackcomponent": "wb-vis-0004_purorder_edit",
"callbackeventname": "update",
"callbackparams": [
{
"paramname": "billno",
"paramvalue": "PUR21052801" //查询的内容,修改为想查询的内容
}
]
}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
在FastWeb中使用以下示例来更新。
//JScript
{
var l;
l = new TStringlist();
//修改为需要识别的图片的位置
l.Values["billno"] = "PUR21052801";
//demo 处修改为实际运行的用户名称
UGMM.SendWsMsg("demo","callback","wb-vis-0004_purorder_edit","0","update",l);
l.Free;
}
2
3
4
5
6
7
8
9
10
//PasScript
var
l: TStringList;
begin
l := TStringList.Create();
//修改为需要识别的图片的位置
l.Values['billno'] := 'PUR21052801';
//demo 处修改为实际运行的用户名称
UGMM.SendWsMsg('demo','callback','wb-vis-0004_purorder_edit','0','update',l);
l.Free;
end;
2
3
4
5
6
7
8
9
10
11
// Make sure to add code blocks to your code group