採購訂單編輯
# 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