Exemplo n.º 1
0
        /// <summary>
        /// 门店库存上报
        /// </summary>
        /// <param name="data"></param>
        /// <param name="billId"></param>
        /// <returns></returns>
        public async Task <APIResult <InventoryReportBillModel> > CreateOrUpdateAsync(InventoryReportBillModel data, int billId = 0, CancellationToken calToken = default)
        {
            try
            {
                int storeId = Settings.StoreId;
                int userId  = Settings.UserId;

                var api     = RefitServiceBuilder.Build <IWareHousesApi>(URL);
                var results = await _makeRequest.Start(api.CreateOrUpdateAsync(data, storeId, userId, billId, calToken), calToken);

                return(results);
            }
            catch (Exception e)
            {
                e.HandleException();
                return(null);
            }
        }
Exemplo n.º 2
0
        public InventoryReportPageViewModel(INavigationService navigationService,
                                            IProductService productService,
                                            ITerminalService terminalService,
                                            IUserService userService,
                                            IWareHousesService wareHousesService,
                                            IAccountingService accountingService,
                                            IDialogService dialogService
                                            ) : base(navigationService,
                                                     productService,
                                                     terminalService,
                                                     userService,
                                                     wareHousesService,
                                                     accountingService,
                                                     dialogService)
        {
            Title = "库存上报";

            this.Bill = new InventoryReportBillModel()
            {
                BusinessUserId = Settings.UserId,
                BillNumber     = CommonHelper.GetBillNumber("KCSB", Settings.StoreId),
                CreatedOnUtc   = DateTime.Now
            };

            //编辑项目
            this.WhenAnyValue(x => x.Selecter).Throttle(TimeSpan.FromMilliseconds(500))
            .Skip(1)
            .Where(x => x != null)
            .SubOnMainThread(async item =>
            {
                await this.NavigateAsync("AddReportProductPage", ("InventoryReportItemModel", item));
                this.Selecter = null;
            })
            .DisposeWith(DeactivateWith);

            //添加商品
            this.AddProductCommand = ReactiveCommand.Create <object>(async e =>
            {
                if (Bill.TerminalId == 0)
                {
                    _dialogService.ShortAlert("请选择客户!");
                    return;
                }
                await this.NavigateAsync("SelectProductPage", ("Reference", $"{nameof(InventoryReportPage)}"), ("SerchKey", Filter.SerchKey));
            });

            //验证
            var valid_TerminalId     = this.ValidationRule(x => x.Bill.TerminalId, _isZero, "客户未指定");
            var valid_BusinessUserId = this.ValidationRule(x => x.Bill.Items.Count, _isZero, "商品未指定");


            //提交
            this.SubmitDataCommand = ReactiveCommand.CreateFromTask <object, Unit>(async _ =>
            {
                //await this.Access(AccessGranularityEnum.StockReportSave);
                return(await this.Access(AccessGranularityEnum.StockReportSave, async() =>
                {
                    Bill.StoreId = Settings.StoreId;
                    Bill.BusinessUserId = Settings.UserId;
                    Bill.ReversedUserId = 0;
                    Bill.ReversedStatus = false;

                    return await SubmitAsync(Bill, 0, _wareHousesService.CreateOrUpdateAsync, (result) =>
                    {
                        Bill = new InventoryReportBillModel();
                    }, token: new System.Threading.CancellationToken());
                }));
            },
                                                                                   this.IsValid());

            //绑定页面菜单
            _popupMenu = new PopupMenu(this, new Dictionary <MenuEnum, Action <SubMenu, ViewModelBase> >
            {
                { MenuEnum.CLEAR, (m, vm) => {
                      ClearForm(() =>
                        {
                            Bill.Items?.Clear();
                        });
                  } },
            });
        }