我有一个创建新客户位置的操作。 到目前为止,我只是尝试使用现有记录加载页面。
使用此代码,结果为正
3 11585 2357 2362
但是,这个其他版本将页面加载为空白:
loadProducts(){ var products = firebase.database().ref('/products'); products.once('value') .then(function (snap){ var keys = Object.keys(snap.val()).sort(); var pageLength = 10; var pageCount = keys.length / pageLength; var currentPage = 1; var promises = []; var nextKey; var query; for (var i = 0; i < pageCount; i++) { nextKey = keys[i * pageLength]; console.log('key', nextKey); query = products.orderByKey().limitToFirst(pageLength).startAt(nextKey); promises.push(query.once('value')); } Promise.all(promises) .then(function (snaps) { var pages = []; snaps.forEach(function (snap) { pages.push(snap.val()); }) console.log('pages', pages); Promise.all(pages) .then(function (ASINs) { var asins = []; ASINs.forEach(function (ASIN) { asins.push(snap.val()); }) console.log('asins', asins); }) }) }); }
我需要有一个类似于第二个版本的版本,因为最终,将从此操作输入新的LocationCD。 有什么想法吗?
答案 0 :(得分:1)
在第二个示例中,您尝试显式设置LocationID,这是一个需要分配的标识字段。我在源代码中找到了几个例子:
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);
}