您需要使用 PXAction 手动执行此操作。添加一个 PXButton(可以选择使用编辑图像对其进行样式设置)或链接控件,然后添加一个事件处理程序,您可以在其中创建目标图形并重定向到它。
这是一个重定向到多个图形处理位置 DAC 之一的事件处理程序示例:
public PXDBAction<BAccount> addLocation;
[PXUIField(DisplayName = Messages.AddNewLocation)]
[PXButton(ImageKey = PX.Web.UI.Sprite.Main.DataEntry)]
public virtual void AddLocation()
{
var row = BAccount.Current;
if (row == null || row.BAccountID == null) return;
LocationMaint graph = null;
switch (row.Type)
{
case BAccountType.VendorType:
graph = PXGraph.CreateInstance<AP.VendorLocationMaint>();
break;
case BAccountType.CustomerType:
graph = PXGraph.CreateInstance<AR.CustomerLocationMaint>();
break;
default:
graph = PXGraph.CreateInstance<LocationMaint>();
break;
}
var newLocation = (Location)graph.Location.Cache.CreateInstance();
newLocation.BAccountID = row.BAccountID;
var locType = LocTypeList.CustomerLoc;
switch (row.Type)
{
case BAccountType.VendorType:
locType = LocTypeList.VendorLoc;
break;
case BAccountType.CombinedType:
locType = LocTypeList.CombinedLoc;
break;
}
newLocation.LocType = locType;
graph.Location.Insert(newLocation);
PXRedirectHelper.TryRedirect(graph, PXRedirectHelper.WindowMode.NewWindow);
}
出现此问题的原因是 Location DAC 有许多 PXPrimaryGraph,并且在运行时它不知道在您的上下文中使用哪个,因此它回退到列表中的第一个。
[PXCacheName("Location")]
[PXPrimaryGraph(new[] { typeof(VendorLocationMaint),
typeof(CustomerLocationMaint),
typeof(BranchMaint),
typeof(EmployeeMaint),
typeof(LocationMaint) },
new[] { typeof(Select<Location, Where<bAccountID, Equal<Current<bAccountID>>, And<locationID, Equal<Current<locationID>>, And<Where<Current<locType>, Equal<LocTypeList.vendorLoc>, Or<Current<locType>, Equal<LocTypeList.combinedLoc>>>>>>>),
typeof(Select<Location, Where<bAccountID, Equal<Current<bAccountID>>, And<locationID, Equal<Current<locationID>>, And<Where<Current<locType>, Equal<LocTypeList.customerLoc>, Or<Current<locType>, Equal<LocTypeList.combinedLoc>>>>>>>),
typeof(Select2<Branch, InnerJoin<BAccount, On<BAccount.bAccountID, Equal<Branch.bAccountID>>, InnerJoin<Location, On<bAccountID, Equal<BAccount.bAccountID>, And<locationID, Equal<BAccount.defLocationID>>>>>, Where<bAccountID, Equal<Current<bAccountID>>, And<locationID, Equal<Current<locationID>>, And<Current<locType>, Equal<LocTypeList.companyLoc>>>>>),
typeof(Select2<EPEmployee, InnerJoin<Location, On<bAccountID, Equal<EPEmployee.bAccountID>, And<locationID, Equal<EPEmployee.defLocationID>>>>, Where<bAccountID, Equal<Current<bAccountID>>, And<locationID, Equal<Current<locationID>>, And<Current<locType>, Equal<LocTypeList.employeeLoc>>>>>),
typeof(Select<Location, Where<bAccountID, Equal<Current<bAccountID>>, And<locationID, Equal<Current<locationID>>>>>) })]
[PXProjection(typeof(Select2<Location, LeftJoin<LocationAPAccountSub, On<LocationAPAccountSub.bAccountID, Equal<bAccountID>, And<LocationAPAccountSub.locationID, Equal<vAPAccountLocationID>>>, LeftJoin<LocationARAccountSub, On<LocationARAccountSub.bAccountID, Equal<bAccountID>, And<LocationARAccountSub.locationID, Equal<cARAccountLocationID>>>, LeftJoin<LocationAPPaymentInfo, On<LocationAPPaymentInfo.bAccountID, Equal<bAccountID>, And<LocationAPPaymentInfo.locationID, Equal<vPaymentInfoLocationID>>>, LeftJoin<BAccountR, On<BAccountR.bAccountID, Equal<bAccountID>>>>>>>), Persistent = true)]
public class Location : IBqlTable, IPaymentTypeDetailMaster, ILocation
{
}