示例#1
0
        public override void OnNavigatedTo(INavigationParameters parameters)
        {
            base.OnNavigatedTo(parameters);

            try
            {
                if (parameters.ContainsKey("Bill"))
                {
                    if (ReferencePage.Equals("AllocationBillPage"))
                    {
                        this.ShowGift = false;
                        parameters.TryGetValue("Bill", out AllocationBillModel bill);
                        if (bill != null)
                        {
                            this.Bill = bill;
                        }
                    }
                }

                if (ReferencePage == "InventoryOPBillPage")
                {
                    ShowStockQty = false;
                    ShowGift     = false;
                }

                if (ReferencePage == "PurchaseOrderBillPage")
                {
                    ShowStockQty = true;
                    ShowGift     = false;
                }

                //盘点单
                if (ReferencePage == "InventoryOPBillPage")
                {
                    ProductSeries.ToList().ForEach(p =>
                    {
                        TempProductSeries.Add(p);
                    });
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
示例#2
0
        public override void OnNavigatedTo(INavigationParameters parameters)
        {
            base.OnNavigatedTo(parameters);
            try
            {
                if (parameters.ContainsKey("Products"))
                {
                    parameters.TryGetValue("Products", out List <ProductModel> products);
                    if (products != null)
                    {
                        ProductSeries = new ObservableCollection <ProductModel>(products);
                    }
                }


                if (parameters.ContainsKey("Bill"))
                {
                    if (ReferencePage.Equals("AllocationBillPage"))
                    {
                        parameters.TryGetValue("Bill", out AllocationBillModel Bill);

                        if (Bill != null)
                        {
                            foreach (var p in ProductSeries.ToList())
                            {
                                var outs = p.StockQuantities.Where(q => q.WareHouseId == Bill.ShipmentWareHouseId).FirstOrDefault();
                                var ins  = p.StockQuantities.Where(q => q.WareHouseId == Bill.IncomeWareHouseId).FirstOrDefault();

                                p.ShipmentUsableQuantity = outs != null ? outs.UsableQuantity : 0;
                                p.IncomeUsableQuantity   = ins != null ? ins.UsableQuantity : 0;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
示例#3
0
        public override void OnNavigatedTo(INavigationParameters parameters)
        {
            base.OnNavigatedTo(parameters);

            if (CompanySetting != null && CompanySetting.OpenBillMakeDate == 2 && (ReferencePage.Equals("SaleBillPage") || ReferencePage.Equals("SaleOrderBillPage")))
            {
                IsEditPrduceDate = true;
            }
            else
            {
                IsEditPrduceDate = false;
            }

            //获取选择的商品回传
            if (parameters.ContainsKey("Products"))
            {
                parameters.TryGetValue("Products", out List <ProductModel> products);

                //类型标识
                int pId = 0;
                //枚举标识
                int pTId  = 0;
                var pArry = Settings.DefaultPricePlan.Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries).Select(p => int.Parse(p)).ToList();
                if (pArry.Count > 0)
                {
                    pId  = pArry[0];
                    pTId = pArry[1];
                }

                //层次价格
                products.ForEach(product =>
                {
                    var sprice = product.SmallProductPrices;
                    var bprice = product.BigProductPrices;

                    switch (pTId)
                    {
                    case (int)PriceType.ProductCost:
                        {
                            //进价
                            if (sprice != null)
                            {
                                product.SmallPriceUnit.Price = sprice.PurchasePrice ?? 0;
                            }
                            if (bprice != null)
                            {
                                product.BigPriceUnit.Price = bprice.PurchasePrice ?? 0;
                            }
                        }
                        break;

                    case (int)PriceType.CostPrice:
                        {
                            //成本价
                            if (sprice != null)
                            {
                                product.SmallPriceUnit.Price = sprice.CostPrice ?? 0;
                            }
                            if (bprice != null)
                            {
                                product.BigPriceUnit.Price = bprice.CostPrice ?? 0;
                            }
                        }
                        break;

                    case (int)PriceType.WholesalePrice:
                        {
                            //批发价格
                            if (sprice != null)
                            {
                                product.SmallPriceUnit.Price = sprice.TradePrice ?? 0;
                            }
                            if (bprice != null)
                            {
                                product.BigPriceUnit.Price = bprice.TradePrice ?? 0;
                            }
                        }
                        break;

                    case (int)PriceType.RetailPrice:
                        {
                            //零售价格
                            if (sprice != null)
                            {
                                product.SmallPriceUnit.Price = sprice.RetailPrice ?? 0;
                            }
                            if (bprice != null)
                            {
                                product.BigPriceUnit.Price = bprice.RetailPrice ?? 0;
                            }
                        }
                        break;

                    case (int)PriceType.LowestPrice:
                        {
                            //最低售价
                            if (sprice != null)
                            {
                                product.SmallPriceUnit.Price = sprice.FloorPrice ?? 0;
                            }
                            if (bprice != null)
                            {
                                product.BigPriceUnit.Price = bprice.FloorPrice ?? 0;
                            }
                        }
                        break;

                    case (int)PriceType.CustomPlan:
                        {
                            //方案价格
                            var price = product.ProductTierPrices.Where(s => s.PriceTypeId == pTId && s.PricesPlanId == pId).FirstOrDefault();
                            if (price != null)
                            {
                                product.SmallPriceUnit.Price = price.SmallUnitPrice ?? 0;
                                product.BigPriceUnit.Price   = price.BigUnitPrice ?? 0;
                            }
                        }
                        break;

                    case (int)PriceType.LastedPrice:
                        {
                            //上次价格
                            var price = product.ProductTierPrices.Where(s => s.PriceTypeId == pTId).FirstOrDefault();
                            if (price != null)
                            {
                                product.SmallPriceUnit.Price = price.SmallUnitPrice ?? 0;
                                product.BigPriceUnit.Price   = price.BigUnitPrice ?? 0;
                            }
                        }
                        break;
                    }

                    product.RemarkSelected = ReactiveCommand.Create <UProduct>(async e =>
                    {
                        var _dialogView = new PopRadioButtonPage("选择备注", "", async() =>
                        {
                            var _settingService = App.Resolve <ISettingService>();
                            var result          = await _settingService.GetRemarkConfigListSetting();
                            var popDatas        = result?.Select(s =>
                            {
                                return(new PopData
                                {
                                    Id = s.Key,
                                    Column = s.Value,
                                    Selected = false
                                });
                            })?.ToList();
                            return(popDatas);
                        });
                        _dialogView.Completed += (sender, result) =>
                        {
                            try {
                                if (result != null)
                                {
                                    RemarkConfig.Id   = result.Id;
                                    RemarkConfig.Name = result.Column;
                                    e.Remark          = result.Column;
                                }
                            }
                            catch (Exception ex)
                            {
                                Crashes.TrackError(ex);
                            }
                        };
                        await PopupNavigation.Instance.PushAsync(_dialogView);
                    });
                });

                ProductSeries = new ObservableCollection <ProductModel>(products);
            }
        }
示例#4
0
        /// <summary>
        /// 输入值更改时
        /// </summary>
        public void CalcChanged(ProductModel curProduct, int type)
        {
            try
            {
                var pid = curProduct?.Id ?? 0;
                if (curProduct != null)
                {
                    var bigPrice   = curProduct?.BigPriceUnit?.Price ?? 0;
                    var smallPrice = curProduct?.SmallPriceUnit?.Price ?? 0;

                    if (type == 0)
                    {
                        var bp = curProduct?.BigQuantity ?? 0;
                        if (bp > 0)
                        {
                            var sp = bigPrice / bp;
                            curProduct.SmallPriceUnit.Price = decimal.Round(sp, 4, MidpointRounding.AwayFromZero);
                        }
                    }
                    else if (type == 1)
                    {
                        var bp = curProduct?.BigQuantity ?? 0;
                        var sp = smallPrice * bp;
                        curProduct.BigPriceUnit.Price = decimal.Round(sp, 4, MidpointRounding.AwayFromZero);
                    }
                }

                ProductSeries.ForEach(product =>
                {
                    if (product != null)
                    {
                        //采购单时
                        if (ReferencePage.Equals("PurchaseOrderBillPage"))
                        {
                            //大单位价格
                            product.BigPriceUnit.Amount = product.BigPriceUnit.Quantity * product.BigPriceUnit.Price;

                            if ((product.BigQuantity ?? 0) == 0)
                            {
                                product.BigQuantity = 1;
                            }
                            var price  = (product.BigQuantity ?? 0) != 0 ? (product.BigPriceUnit.Price / product.BigQuantity == 0 ? 1 : product.BigQuantity) : 0;
                            var amount = product.SmallPriceUnit.Quantity * product.SmallPriceUnit.Price;

                            //小单位价格
                            product.SmallPriceUnit.Price  = decimal.Round((price ?? 0), 4, MidpointRounding.AwayFromZero);
                            product.SmallPriceUnit.Amount = decimal.Round((amount != 0 ? amount : 0), 4, MidpointRounding.AwayFromZero);
                        }
                        else
                        {
                            var ba = product.BigPriceUnit.Quantity * product.BigPriceUnit.Price;
                            var sa = product.SmallPriceUnit.Quantity * product.SmallPriceUnit.Price;

                            //大单位价格
                            product.BigPriceUnit.Amount = decimal.Round((ba != 0 ? ba : 0), 4, MidpointRounding.AwayFromZero);
                            //小单位价格
                            product.SmallPriceUnit.Amount = decimal.Round((sa != 0 ? sa : 0), 4, MidpointRounding.AwayFromZero);
                        }
                    }
                });
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
示例#5
0
        /// <summary>
        /// 分页获取商品
        /// </summary>
        /// <param name="pageNumber"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public async Task <IList <ProductModel> > GetProductsPage(int pageNumber, int pageSize)
        {
            var lists = new List <ProductModel>();

            try
            {
                Filter ??= new FilterModel();
                string key         = string.IsNullOrEmpty(Filter.SerchKey) ? "" : Filter.SerchKey;
                var    catagoryids = Filter.CatagoryIds ?? null;
                //bool usablequantity = true;

                //是否包含库存量商品
                if (ReferencePage.Equals("PurchaseOrderBillPage") ||
                    ReferencePage.Equals("CostContractBillPage") ||
                    ReferencePage.Equals("ReturnBillPage") ||
                    ReferencePage.Equals("ReturnOrderBillPage") ||
                    ReferencePage.Equals("InventoryBillPage") ||
                    ReferencePage.Equals("InventoryOPBillPage") ||
                    ReferencePage.Equals("InventoryBillPage"))
                {
                    this.UsableQuantity = false;
                }

                if (Settings.WareHouseId != Filter.WareHouseId)
                {
                    Settings.WareHouseId = Filter.WareHouseId;
                }

                if (ReferencePage.Equals("ReturnBillPage") || ReferencePage.Equals("ReturnOrderBillPage"))
                {
                    Filter.WareHouseId = 0;
                    this.ForceRefresh  = true;
                }
                //检索商品
                var results = await _productService.GetProductsAsync(catagoryids,
                                                                     key,
                                                                     Terminal.Id,
                                                                     Filter.WareHouseId,
                                                                     pageNumber,
                                                                     pageSize,
                                                                     this.UsableQuantity,
                                                                     this.ForceRefresh,
                                                                     new System.Threading.CancellationToken());

                if (results != null && (results?.Data.Any() ?? false))
                {
                    foreach (var p in results?.Data)
                    {
                        p.BigUnitId    = p.BigProductPrices.UnitId;
                        p.BigPriceUnit = new PriceUnit()
                        {
                            UnitId = p.bigOption.Id,
                            Amount = 0,
                            //默认绑定批发价
                            Price    = p.BigProductPrices.TradePrice ?? 0,
                            Quantity = 0,
                            Remark   = "",
                            UnitName = p.bigOption.Name
                        };

                        p.SmallUnitId    = p.SmallProductPrices.UnitId;
                        p.SmallPriceUnit = new PriceUnit()
                        {
                            UnitId = p.smallOption.Id,
                            Amount = 0,
                            //默认绑定批发价
                            Price    = p.SmallProductPrices.TradePrice ?? 0,
                            Quantity = 0,
                            Remark   = "",
                            UnitName = p.smallOption.Name
                        };

                        var currentStock = p.StockQuantities.Where(w => w.WareHouseId == Filter.WareHouseId).FirstOrDefault();
                        p.StockQty = currentStock != null ? currentStock.UsableQuantity : p.StockQty;
                        if (p.StockQty == 0)
                        {
                            p.StockQty = p.StockQuantities?.Sum(s => s.UsableQuantity);
                        }

                        //当前仓库名称
                        p.CurWareHouseName     = Filter.WareHouseName;
                        p.ShowCurWareHouseName = Filter.WareHouseId > 0;

                        //库存量转化
                        p.UsableQuantityConversion  = p.FormatQuantity(p.UsableQuantity ?? 0);
                        p.CurrentQuantityConversion = p.FormatQuantity(p.CurrentQuantity ?? 0);
                        p.OrderQuantityConversion   = p.FormatQuantity(p.OrderQuantity ?? 0);
                        p.LockQuantityConversion    = p.FormatQuantity(p.LockQuantity ?? 0);


                        p.IsShowStock       = ShowStockQty;
                        p.IsShowGiveEnabled = !ReferencePage.Equals("PurchaseOrderBillPage");

                        //选择命令
                        p.SelectCommand = ReactiveCommand.Create <ProductModel>(e =>
                        {
                            if (e == null)
                            {
                                return;
                            }

                            if ((!e.StockQty.HasValue || e.StockQty.Value == 0) && !ReferencePage.Equals("InventoryOPBillPage"))
                            {
                                this.Alert("零库存商品无效!");
                                e.Selected = false;
                                return;
                            }
                            else
                            {
                                e.Selected = !e.Selected;
                            }
                        });
                    }

                    lists = results?.Data?.OrderBy(s => s.StockQty).ToList();

                    if (this.UsableQuantity)
                    {
                        lists = results?.Data?.Where(s => s.UsableQuantity > 0)
                                .OrderBy(s => s.StockQty)
                                .ToList();
                    }
                    else
                    {
                        lists = results?.Data?.OrderBy(s => s.StockQty)
                                .ToList();
                    }

                    var ps = Settings.FavoriteProducts;

                    //标记收藏状态
                    lists.ForEach(p =>
                    {
                        var f       = ps.Select(s => s.Id).Contains(p.Id);
                        p.Favorited = f;
                    });

                    //过滤
                    if (this.UsableFavorite)
                    {
                        lists = lists.Where(s => s.Favorited == true).ToList();
                    }
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }

            return(lists);
        }
        public override void OnNavigatedTo(INavigationParameters parameters)
        {
            base.OnNavigatedTo(parameters);
            try
            {
                if (CompanySetting != null && CompanySetting.OpenBillMakeDate == 2 && (ReferencePage.Equals("SaleBillPage") || ReferencePage.Equals("SaleOrderBillPage")))
                {
                    IsEditPrduceDate = true;
                }
                else
                {
                    IsEditPrduceDate = false;
                }

                //编辑商品回传
                if (parameters.ContainsKey("Product"))
                {
                    //商品
                    parameters.TryGetValue("Product", out ProductModel p);
                    if (p != null)
                    {
                        p.RemarkSelected2 = ReactiveCommand.Create <ProductModel>(async e =>
                        {
                            var _dialogView = new PopRadioButtonPage("选择备注", "", async() =>
                            {
                                var _settingService = App.Resolve <ISettingService>();
                                var result          = await _settingService.GetRemarkConfigListSetting();
                                var popDatas        = result?.Select(s =>
                                {
                                    return(new PopData
                                    {
                                        Id = s.Key,
                                        Column = s.Value,
                                        Selected = false
                                    });
                                })?.ToList();
                                return(popDatas);
                            });
                            _dialogView.Completed += (sender, result) =>
                            {
                                try {
                                    if (result != null)
                                    {
                                        p.Remark = result.Column;
                                    }
                                }
                                catch (Exception ex)
                                {
                                    Crashes.TrackError(ex);
                                }
                            };
                            await PopupNavigation.Instance.PushAsync(_dialogView);
                        });

                        //当前仓库名称
                        p.CurWareHouseName = WareHouse.Name;
                        //库存量转化
                        p.UsableQuantityConversion  = p.FormatQuantity(p.UsableQuantity ?? 0);
                        p.CurrentQuantityConversion = p.FormatQuantity(p.CurrentQuantity ?? 0);
                        p.OrderQuantityConversion   = p.FormatQuantity(p.OrderQuantity ?? 0);
                        p.LockQuantityConversion    = p.FormatQuantity(p.LockQuantity ?? 0);

                        Product = p;
                        this.OldProductQuantity = p.Quantity;
                    }

                    //项目
                    if (ReferencePage.Equals("SaleOrderBillPage"))
                    {
                        parameters.TryGetValue("Item", out SaleReservationItemModel item);
                        if (item != null)
                        {
                            //
                        }
                    }
                    else if (ReferencePage.Equals("ExchangeBillPage"))
                    {
                        parameters.TryGetValue("Item", out ExchangeItemModel item);
                        if (item != null)
                        {
                            //
                        }
                    }
                    else if (ReferencePage.Equals("PurchaseOrderBillPage"))
                    {
                        parameters.TryGetValue("Item", out PurchaseItemModel item);
                        if (item != null)
                        {
                            //
                        }
                    }
                    else if (ReferencePage.Equals("ReturnBillPage"))
                    {
                        parameters.TryGetValue("Item", out ReturnItemModel item);
                        if (item != null)
                        {
                            //
                        }
                    }
                    else if (ReferencePage.Equals("ReturnOrderBillPage"))
                    {
                        parameters.TryGetValue("Item", out ReturnReservationItemModel item);
                        if (item != null)
                        {
                            //
                        }
                    }
                    else if (ReferencePage.Equals("SaleOrderBillPage"))
                    {
                        parameters.TryGetValue("Item", out SaleReservationItemModel item);
                        if (item != null)
                        {
                            //
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }
示例#7
0
        public async override void OnNavigatedTo(INavigationParameters parameters)
        {
            base.OnNavigatedTo(parameters);

            try
            {
                //选择客户回传
                if (parameters.ContainsKey("Terminaler"))
                {
                    parameters.TryGetValue("Terminaler", out TerminalModel terminaler);
                    this.Terminal     = terminaler;
                    Bill.TerminalId   = terminaler != null ? terminaler.Id : 0;
                    Bill.TerminalName = terminaler != null ? terminaler.Name : "";
                }

                //支付方式更新
                if (parameters.ContainsKey("PaymentMethods"))
                {
                    parameters.TryGetValue("PaymentMethods", out PaymentMethodBaseModel paymentMethod);
                    if (paymentMethod != null)
                    {
                        this.PaymentMethods = paymentMethod;
                        UpdateUI();
                    }
                }

                //选择费用回传
                if (parameters.ContainsKey("CostExpenditure"))
                {
                    parameters.TryGetValue("CostExpenditure", out CostExpenditureItemModel ce);
                    if (ce != null)
                    {
                        if (ce.CostContractId > 0)
                        {
                            if (Bill.Items?.Where(s => s.AccountingOptionId == ce.AccountingOptionId && s.CostContractId == ce.CostContractId).Count() > 0)
                            {
                                //_dialogService.ShortAlert("项目已经添加!"); return;
                                var item = Bill.Items?.Where(s => s.AccountingOptionId == ce.AccountingOptionId && s.CostContractId == ce.CostContractId).FirstOrDefault();
                                item.CostContractId       = ce.CostContractId;
                                item.AccountingOptionId   = ce.AccountingOptionId;
                                item.AccountingOptionName = ce.AccountingOptionName;
                                item.Amount = ce.Amount;
                                return;
                            }
                        }
                        else
                        {
                            if (Bill.Items?.Where(s => s.AccountingOptionId == ce.AccountingOptionId).Count() > 0)
                            {
                                //_dialogService.ShortAlert("项目已经添加!"); return;
                                var item = Bill.Items?.Where(s => s.AccountingOptionId == ce.AccountingOptionId).FirstOrDefault();
                                item.CostContractId       = ce.CostContractId;
                                item.AccountingOptionId   = ce.AccountingOptionId;
                                item.AccountingOptionName = ce.AccountingOptionName;
                                item.Amount = ce.Amount;
                                return;
                            }
                        }

                        Bill.Items?.Add(ce);
                        Bill.TotalAmount = Bill.Items?.Select(s => s.Amount).Sum() ?? 0;
                        UpdateUI();
                    }
                }

                //移除回传
                if (parameters.ContainsKey("RemoveCostExpenditure"))
                {
                    parameters.TryGetValue("RemoveCostExpenditure", out CostExpenditureItemModel ce);
                    if (ce != null)
                    {
                        var cur = Bill.Items?.Where(s => s.AccountingOptionId == ce.AccountingOptionId).FirstOrDefault();
                        if (ce.CostContractId > 0)
                        {
                            cur = Bill.Items?.Where(s => s.AccountingOptionId == ce.AccountingOptionId && s.CostContractId == ce.CostContractId).FirstOrDefault();
                            if (cur != null)
                            {
                                Bill.Items?.Remove(cur);
                            }
                        }
                        else
                        {
                            if (cur != null)
                            {
                                Bill.Items?.Remove(cur);
                            }
                        }

                        Bill.TotalAmount = Bill.Items?.Select(s => s.Amount).Sum() ?? 0;
                        UpdateUI();
                    }
                }

                CostExpenditureBillModel bill = null;
                if (parameters.ContainsKey("Bill"))
                {
                    parameters.TryGetValue("Bill", out bill);
                    parameters.TryGetValue("IsSubmitBill", out bool isSubmitBill);
                    this.Bill.IsSubmitBill = isSubmitBill;
                }

                if (parameters.ContainsKey("BillId"))
                {
                    parameters.TryGetValue("BillId", out int billId);
                    this.BillId = billId;
                    bill        = await _costExpenditureService.GetBillAsync(billId);
                }

                if (bill != null)
                {
                    Bill = bill;

                    Bill.TerminalId   = bill.CustomerId;
                    Bill.TerminalName = bill.CustomerName;

                    this.PaymentMethods = this.ToPaymentMethod(bill, Bill.CostExpenditureBillAccountings);

                    if (bill.AuditedStatus)
                    {
                    }
                    else
                    {
                        //控制显示菜单
                        _popupMenu?.Show(34);
                    }

                    //来自费用签收单
                    if (ReferencePage.Equals("UnCostExpenditurePage"))
                    {
                        this.ShowAddProduct    = false;
                        this.ShowSignInCommand = true;
                    }

                    UpdateUI();
                }
            }
            catch (Exception ex)
            {
                Crashes.TrackError(ex);
            }
        }