コード例 #1
0
        public AllocationSummeryPageViewModel(INavigationService navigationService,
                                              IGlobalService globalService,
                                              IDialogService dialogService,
                                              IAllocationService allocationService,
                                              IAdvanceReceiptService advanceReceiptService,
                                              IReceiptCashService receiptCashService,
                                              ICostContractService costContractService,
                                              ICostExpenditureService costExpenditureService,
                                              IInventoryService inventoryService,
                                              IPurchaseBillService purchaseBillService,
                                              IReturnReservationBillService returnReservationBillService,
                                              IReturnBillService returnBillService,
                                              ISaleReservationBillService saleReservationBillService,

                                              ISaleBillService saleBillService
                                              ) : base(navigationService, globalService, allocationService, advanceReceiptService, receiptCashService, costContractService, costExpenditureService, inventoryService, purchaseBillService, returnReservationBillService, returnBillService, saleReservationBillService, saleBillService, dialogService)
        {
            Title = "调拨单";

            this.BillType = BillTypeEnum.AllocationBill;

            Filter.StartTime = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
            Filter.EndTime   = DateTime.Now;

            this.Load = ReactiveCommand.Create(async() =>
            {
                //重载时排它
                ItemTreshold = 1;
                PageCounter  = 0;
                try
                {
                    DateTime?startTime = Filter.StartTime;
                    DateTime?endTime   = Filter.EndTime;
                    int?businessUserId = Filter.BusinessUserId;
                    int?customerId     = Filter.TerminalId;
                    string billNumber  = Filter.SerchKey;

                    int?makeuserId = Settings.UserId;
                    if (businessUserId.HasValue && businessUserId > 0)
                    {
                        makeuserId = 0;
                    }

                    int?shipmentWareHouseId = 0;
                    int?incomeWareHouseId   = 0;
                    //获取已审核
                    bool?auditedStatus     = true;
                    bool?showReverse       = null;
                    bool?sortByAuditedTime = null;

                    //清除列表
                    Bills?.Clear();

                    var items = await _allocationService.GetAllocationsAsync(makeuserId,
                                                                             businessUserId ?? 0,
                                                                             shipmentWareHouseId,
                                                                             incomeWareHouseId,
                                                                             billNumber,
                                                                             "",
                                                                             auditedStatus,
                                                                             startTime,
                                                                             endTime,
                                                                             showReverse,
                                                                             sortByAuditedTime,
                                                                             0,
                                                                             PageSize,
                                                                             this.ForceRefresh,
                                                                             new System.Threading.CancellationToken());

                    if (items != null)
                    {
                        foreach (var item in items)
                        {
                            if (Bills.Count(s => s.Id == item.Id) == 0)
                            {
                                Bills.Add(item);
                            }
                        }

                        if (items.Count() == 0 || items.Count() == Bills.Count)
                        {
                            ItemTreshold = -1;
                        }

                        foreach (var s in Bills)
                        {
                            s.IsLast = !(Bills.LastOrDefault()?.BillNumber == s.BillNumber);
                        }


                        if (Bills.Count > 0)
                        {
                            this.Bills = new ObservableRangeCollection <AllocationBillModel>(Bills);
                        }
                        UpdateTitle();
                    }
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                }
            });
            //以增量方式加载数据
            this.ItemTresholdReachedCommand = ReactiveCommand.Create(async() =>
            {
                int pageIdex = 0;
                if (Bills?.Count != 0)
                {
                    pageIdex = Bills.Count / (PageSize == 0 ? 1 : PageSize);
                }

                if (PageCounter < pageIdex)
                {
                    PageCounter = pageIdex;
                    using (var dig = UserDialogs.Instance.Loading("加载中..."))
                    {
                        try
                        {
                            string billNumber  = Filter.SerchKey;
                            DateTime?startTime = Filter.StartTime;
                            DateTime?endTime   = Filter.EndTime;
                            int?businessUserId = Filter.BusinessUserId;
                            int?customerId     = Filter.TerminalId;

                            int?makeuserId = Settings.UserId;
                            if (businessUserId.HasValue && businessUserId > 0)
                            {
                                makeuserId = 0;
                            }

                            int?shipmentWareHouseId = 0;
                            int?incomeWareHouseId   = 0;
                            //获取已审核
                            bool?auditedStatus     = true;
                            bool?showReverse       = null;
                            bool?sortByAuditedTime = null;


                            var items = await _allocationService.GetAllocationsAsync(makeuserId, businessUserId ?? 0, shipmentWareHouseId, incomeWareHouseId, billNumber, "", auditedStatus, startTime, endTime, showReverse, sortByAuditedTime, pageIdex, PageSize, this.ForceRefresh, new System.Threading.CancellationToken());
                            if (items != null)
                            {
                                foreach (var item in items)
                                {
                                    if (Bills.Count(s => s.Id == item.Id) == 0)
                                    {
                                        Bills.Add(item);
                                    }
                                }

                                if (items.Count() == 0)
                                {
                                    ItemTreshold = -1;
                                }

                                foreach (var s in Bills)
                                {
                                    s.IsLast = !(Bills.LastOrDefault()?.BillNumber == s.BillNumber);
                                }
                                UpdateTitle();
                            }
                        }
                        catch (Exception ex)
                        {
                            Crashes.TrackError(ex);
                        }
                    }
                }
            }, this.WhenAny(x => x.Bills, x => x.GetValue().Count > 0));


            //选择单据
            this.WhenAnyValue(x => x.Selecter).Throttle(TimeSpan.FromMilliseconds(500))
            .Skip(1)
            .Where(x => x != null)
            .SubOnMainThread(async x =>
            {
                if (x != null)
                {
                    await NavigateAsync(nameof(AllocationBillPage), ("Bill", x));
                }
                this.Selecter = null;
            }).DisposeWith(DeactivateWith);

            //菜单选择
            this.SubscribeMenus((x) =>
            {
                //获取当前UTC时间
                DateTime dtime = DateTime.Now;
                switch (x)
                {
                case MenuEnum.TODAY:
                    {
                        Filter.StartTime = DateTime.Parse(dtime.ToString("yyyy-MM-dd 00:00:00"));
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.YESTDAY:
                    {
                        Filter.StartTime = dtime.AddDays(-1);
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.OTHER:
                    {
                        SelectDateRang();
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.SUBMIT30:
                    {
                        Filter.StartTime = dtime.AddMonths(-1);
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case Enums.MenuEnum.CLEARHISTORY:    //清空一个月历史单据
                    {
                        ClearHistory(() => _globalService.UpdateHistoryBillStatusAsync((int)this.BillType));
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;
                }
            }, string.Format(Constants.MENU_KEY, 4));

            this.BindBusyCommand(Load);
        }
コード例 #2
0
        public ReturnPageViewModel(INavigationService navigationService,
                                   IGlobalService globalService,
                                   IDialogService dialogService,
                                   IAllocationService allocationService,
                                   IAdvanceReceiptService advanceReceiptService,
                                   IReceiptCashService receiptCashService,
                                   ICostContractService costContractService,
                                   ICostExpenditureService costExpenditureService,
                                   IInventoryService inventoryService,
                                   IPurchaseBillService purchaseBillService,
                                   IReturnReservationBillService returnReservationBillService,
                                   IReturnBillService returnBillService,
                                   ISaleReservationBillService saleReservationBillService,
                                   ISaleBillService saleBillService
                                   ) : base(navigationService, globalService, allocationService, advanceReceiptService, receiptCashService, costContractService, costExpenditureService, inventoryService, purchaseBillService, returnReservationBillService, returnBillService, saleReservationBillService, saleBillService, dialogService)
        {
            Title = "退货单";

            this.BillType = BillTypeEnum.ReturnBill;

            this.Load = ReactiveCommand.Create(async() =>
            {
                ItemTreshold = 1;
                PageCounter  = 0;

                try
                {
                    Bills?.Clear();
                    int?terminalId     = Filter.TerminalId;
                    int?businessUserId = Filter.BusinessUserId;
                    string billNumber  = Filter.SerchKey;
                    DateTime?startTime = Filter.StartTime ?? DateTime.Now;
                    DateTime?endTime   = Filter.EndTime ?? DateTime.Now;

                    int?makeuserId = Settings.UserId;
                    if (Filter.BusinessUserId == Settings.UserId)
                    {
                        businessUserId = 0;
                    }
                    int?wareHouseId     = 0;
                    string terminalName = "";
                    string remark       = "";
                    int?districtId      = 0;
                    int?deliveryUserId  = 0;
                    //获取未审核
                    bool?auditedStatus     = false;
                    bool?sortByAuditedTime = null;
                    bool?showReverse       = null;
                    bool?showReturn        = null;
                    bool?handleStatus      = null;
                    int?paymentMethodType  = null;
                    int?billSourceType     = null;

                    var pending = new List <ReturnBillModel>();


                    var result = await _returnBillService.GetReturnBillsAsync(makeuserId, terminalId, terminalName, businessUserId, deliveryUserId, wareHouseId, districtId, remark, billNumber, startTime, endTime, auditedStatus, sortByAuditedTime, showReverse, showReturn, paymentMethodType, billSourceType, handleStatus, 0, PageSize, this.ForceRefresh, new System.Threading.CancellationToken());

                    if (result != null)
                    {
                        pending = result?.Select(s =>
                        {
                            var sm    = s;
                            sm.IsLast = !(result.LastOrDefault()?.BillNumber == s.BillNumber);
                            return(sm);
                        }).Where(s => s.MakeUserId == Settings.UserId || s.BusinessUserId == Settings.UserId).ToList();
                    }
                    if (pending.Any())
                    {
                        Bills = new System.Collections.ObjectModel.ObservableCollection <ReturnBillModel>(pending);
                    }
                    UpdateTitle();
                }
                catch (Exception ex)
                {
                    Crashes.TrackError(ex);
                }
            });

            this.ItemTresholdReachedCommand = ReactiveCommand.Create(async() =>
            {
                int pageIdex = 0;
                if (Bills?.Count != 0)
                {
                    pageIdex = Bills.Count / (PageSize == 0 ? 1 : PageSize);
                }

                if (PageCounter < pageIdex)
                {
                    PageCounter = pageIdex;
                    using (var dig = UserDialogs.Instance.Loading("加载中..."))
                    {
                        try
                        {
                            int?terminalId     = Filter.TerminalId;
                            int?businessUserId = Filter.BusinessUserId;
                            string billNumber  = Filter.SerchKey;
                            DateTime?startTime = Filter.StartTime ?? DateTime.Now;
                            DateTime?endTime   = Filter.EndTime ?? DateTime.Now;

                            int?makeuserId = Settings.UserId;
                            if (Filter.BusinessUserId == Settings.UserId)
                            {
                                businessUserId = 0;
                            }
                            int?wareHouseId     = 0;
                            string terminalName = "";
                            string remark       = "";
                            int?districtId      = 0;
                            int?deliveryUserId  = 0;
                            //获取未审核
                            bool?auditedStatus     = false;
                            bool?sortByAuditedTime = null;
                            bool?showReverse       = null;
                            bool?showReturn        = null;
                            bool?handleStatus      = null;
                            int?paymentMethodType  = null;
                            int?billSourceType     = null;

                            var pending = new List <ReturnBillModel>();

                            var items = await _returnBillService.GetReturnBillsAsync(makeuserId, terminalId, terminalName, businessUserId, deliveryUserId, wareHouseId, districtId, remark, billNumber, startTime, endTime, auditedStatus, sortByAuditedTime, showReverse, showReturn, paymentMethodType, billSourceType, handleStatus, pageIdex, PageSize, this.ForceRefresh, new System.Threading.CancellationToken());
                            if (items != null)
                            {
                                foreach (var item in items)
                                {
                                    if (Bills.Count(s => s.Id == item.Id) == 0)
                                    {
                                        Bills.Add(item);
                                    }
                                }

                                foreach (var s in Bills)
                                {
                                    s.IsLast = !(Bills.LastOrDefault()?.BillNumber == s.BillNumber);
                                }
                            }
                            UpdateTitle();
                        }
                        catch (Exception ex)
                        {
                            Crashes.TrackError(ex);
                        }
                    }
                }
            }, this.WhenAny(x => x.Bills, x => x.GetValue().Count > 0));

            //选择单据
            this.SelectedCommand = ReactiveCommand.Create <ReturnBillModel>(async x =>
            {
                if (x != null)
                {
                    await NavigateAsync(nameof(ReturnBillPage), ("Bill", x), ("IsSubmitBill", true));
                }
            });

            //菜单选择
            this.SubscribeMenus((x) =>
            {
                //获取当前UTC时间
                DateTime dtime = DateTime.Now;
                switch (x)
                {
                case MenuEnum.TODAY:
                    {
                        Filter.StartTime = DateTime.Parse(dtime.ToString("yyyy-MM-dd 00:00:00"));
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.YESTDAY:
                    {
                        Filter.StartTime = dtime.AddDays(-1);
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.OTHER:
                    {
                        SelectDateRang();
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.SUBMIT30:
                    {
                        Filter.StartTime = dtime.AddMonths(-1);
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case Enums.MenuEnum.CLEARHISTORY:    //清空一个月历史单据
                    {
                        ClearHistory(() => _globalService.UpdateHistoryBillStatusAsync((int)this.BillType));
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;
                }
            }, string.Format(Constants.MENU_VIEW_KEY, 3));

            this.BindBusyCommand(Load);
        }
コード例 #3
0
ファイル: UnSalePageViewModel.cs プロジェクト: dorisoy/Wesley
        public UnSalePageViewModel(INavigationService navigationService,
               IGlobalService globalService,
               IDialogService dialogService,
               IAllocationService allocationService,
               IAdvanceReceiptService advanceReceiptService,
               IReceiptCashService receiptCashService,
               ICostContractService costContractService,
               ICostExpenditureService costExpenditureService,
               IInventoryService inventoryService,
               IPurchaseBillService purchaseBillService,
               IReturnReservationBillService returnReservationBillService,
               IReturnBillService returnBillService,
               ISaleReservationBillService saleReservationBillService,
               ISaleBillService saleBillService
            ) : base(navigationService, globalService, allocationService, advanceReceiptService, receiptCashService, costContractService, costExpenditureService, inventoryService, purchaseBillService, returnReservationBillService, returnBillService, saleReservationBillService, saleBillService, dialogService)
        {

            Title = "销售签收(0)";

            this.Bills = new ObservableCollection<SaleBillModel>();

            this.Load = ReactiveCommand.Create(async () =>
            {
                var pending = new List<SaleBillModel>();

                try
                {
                    int? terminalId = 0;
                    int? businessUserId = 0;
                    DateTime? startTime = DateTime.Now.AddMonths(-7);
                    DateTime? endTime = DateTime.Now;

                    int? makeuserId = Settings.UserId;
                    int? wareHouseId = 0;
                    string billNumber = "";
                    string terminalName = "";
                    string remark = "";
                    int? districtId = 0;
                    int? deliveryUserId = 0;
                    //获取已经审核,未签收单据
                    bool? auditedStatus = true;
                    bool? sortByAuditedTime = null;
                    bool? showReverse = null;
                    bool? showReturn = null;
                    bool? handleStatus = null;
                    int? paymentMethodType = 0;
                    int? billSourceType = 0;
                    int pageIndex = 0;
                    int pageSize = 20;

                    //获取待签收
                    var result = await _saleBillService.GetSalebillsAsync(makeuserId,
                        terminalId,
                        terminalName,
                        businessUserId,
                        districtId,
                        deliveryUserId,
                        wareHouseId,
                        billNumber,
                        remark,
                        startTime,
                        endTime,
                        auditedStatus,
                        sortByAuditedTime,
                        showReverse,
                        showReturn,
                        paymentMethodType,
                        billSourceType,
                        handleStatus,
                        0,
                        pageIndex,
                        pageSize,
                        this.ForceRefresh,
                        new System.Threading.CancellationToken());

                    if (result != null)
                    {
                        pending = result?.Select(s =>
                        {
                            var sm = s;
                            sm.IsLast = !(result.LastOrDefault()?.BillNumber == s.BillNumber);
                            return sm;
                        }).ToList();

                        TotalAmount = pending.Select(b => b.SumAmount).Sum();
                        Title = $"销售单({pending.Count})";

                        if (pending != null && pending.Any())
                            Bills = new ObservableCollection<SaleBillModel>(pending);
                    }
                }
                catch (System.Exception) { }
            });


            //签收 
            this.SelecterCommand = ReactiveCommand.CreateFromTask<SaleBillModel>(async (item) =>
            {
                if (item != null)
                {
                    using (UserDialogs.Instance.Loading("稍等..."))
                    {
                        await this.NavigateAsync("SaleBillPage",
                            ("Reference", this.PageName),
                            ("DispatchItemModel", null),
                            ("Bill", item));
                    }
                }
                item = null;
            });

            //菜单选择
            this.SubscribeMenus((x) =>
            {
                //获取当前UTC时间
                DateTime dtime = DateTime.Now;
                switch (x)
                {
                    case MenuEnum.TODAY:
                        {
                            Filter.StartTime = DateTime.Parse(dtime.ToString("yyyy-MM-dd 00:00:00"));
                            Filter.EndTime = dtime;
                            ((ICommand)Load)?.Execute(null);
                        }
                        break;
                    case MenuEnum.YESTDAY:
                        {
                            Filter.StartTime = dtime.AddDays(-1);
                            Filter.EndTime = dtime;
                            ((ICommand)Load)?.Execute(null);
                        }
                        break;
                    case MenuEnum.OTHER:
                        {
                            SelectDateRang();
                            ((ICommand)Load)?.Execute(null);
                        }
                        break;
                }

            }, string.Format(Constants.MENU_DEV_KEY, 2));

            this.BindBusyCommand(Load);

        }
コード例 #4
0
        public UnCostExpenditurePageViewModel(INavigationService navigationService,
                                              IGlobalService globalService,
                                              IDialogService dialogService,
                                              IAllocationService allocationService,
                                              IAdvanceReceiptService advanceReceiptService,
                                              IReceiptCashService receiptCashService,
                                              ICostContractService costContractService,
                                              ICostExpenditureService costExpenditureService,
                                              IInventoryService inventoryService,
                                              IPurchaseBillService purchaseBillService,
                                              IReturnReservationBillService returnReservationBillService,
                                              IReturnBillService returnBillService,
                                              ISaleReservationBillService saleReservationBillService,
                                              ISaleBillService saleBillService
                                              ) : base(navigationService, globalService, allocationService, advanceReceiptService, receiptCashService, costContractService, costExpenditureService, inventoryService, purchaseBillService, returnReservationBillService, returnBillService, saleReservationBillService, saleBillService, dialogService)
        {
            Title = "费用支出(0)";

            this.Bills = new ObservableCollection <CostExpenditureBillModel>();

            //载入未签收费用支出单据
            this.Load = ReactiveCommand.Create(async() =>
            {
                var pending = new List <CostExpenditureBillModel>();
                try
                {
                    DateTime?startTime = Filter.StartTime;
                    DateTime?endTime   = Filter.EndTime;
                    int?customerId     = Filter.TerminalId;
                    int?employeeId     = Filter.BusinessUserId;
                    int?makeuserId     = Settings.UserId;

                    string billNumber = "";
                    //获取已审核
                    bool?auditedStatus     = true;
                    bool?showReverse       = null;
                    bool sortByAuditedTime = false;
                    int pagenumber         = 0;
                    int pageSize           = 20;

                    var result = await _costExpenditureService.GetCostExpendituresAsync(makeuserId,
                                                                                        customerId,
                                                                                        "",
                                                                                        employeeId,
                                                                                        billNumber,
                                                                                        auditedStatus,
                                                                                        startTime,
                                                                                        endTime,
                                                                                        showReverse,
                                                                                        sortByAuditedTime,
                                                                                        0,
                                                                                        pagenumber,
                                                                                        pageSize, this.ForceRefresh, new System.Threading.CancellationToken());

                    if (result != null)
                    {
                        pending = result?.Select(s =>
                        {
                            var sm       = s;
                            sm.IsLast    = !(result.LastOrDefault()?.BillNumber == s.BillNumber);
                            sm.SumAmount = s.Items?.Sum(i => i.Amount) ?? 0;

                            return(sm);
                        }).ToList();

                        TotalAmount = pending.Select(b => b.SumAmount).Sum();
                        Title       = $"费用支出({pending.Count})";

                        if (pending != null && pending.Any())
                        {
                            Bills = new ObservableCollection <CostExpenditureBillModel>(pending);
                        }
                    }
                }
                catch (System.Exception) { }
            });

            //费用支出单签收
            this.SelecterCommand = ReactiveCommand.CreateFromTask <CostExpenditureBillModel>(async(item) =>
            {
                if (item != null)
                {
                    using (UserDialogs.Instance.Loading("稍等..."))
                    {
                        await this.NavigateAsync("CostExpenditureBillPage",
                                                 ("Reference", this.PageName),
                                                 ("DispatchItemModel", null),
                                                 ("Bill", item));
                    }
                }
                item = null;
            });

            //菜单选择
            this.SubscribeMenus((x) =>
            {
                //获取当前UTC时间
                DateTime dtime = DateTime.Now;
                switch (x)
                {
                case MenuEnum.TODAY:
                    {
                        Filter.StartTime = DateTime.Parse(dtime.ToString("yyyy-MM-dd 00:00:00"));
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.YESTDAY:
                    {
                        Filter.StartTime = dtime.AddDays(-1);
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.OTHER:
                    {
                        SelectDateRang();
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;
                }
            }, string.Format(Constants.MENU_DEV_KEY, 1));


            this.BindBusyCommand(Load);
        }
コード例 #5
0
        public ExchangeBillPageViewModel(INavigationService navigationService,
                                         IExchangeBillService exchangeBillService,
                                         IProductService productService,
                                         IUserService userService,
                                         ITerminalService terminalService,
                                         IWareHousesService wareHousesService,
                                         IAccountingService accountingService,
                                         IMicrophoneService microphoneService,
                                         ISaleBillService saleBillService,
                                         //IMapper mapper,
                                         IDialogService dialogService
                                         ) : base(navigationService,
                                                  productService, terminalService,
                                                  userService, wareHousesService,
                                                  accountingService, dialogService)
        {
            Title = "换货单";

            _saleBillService     = saleBillService;
            _exchangeBillService = exchangeBillService;
            _microphoneService   = microphoneService;
            //_mapper = mapper;

            InitBill();

            #region //配送日期指定
            var weekDays  = new List <WeekDay>();
            var startTime = DateTime.Now;
            var endTime   = DateTime.Now.AddDays(7);
            while (endTime.Subtract(startTime).Days > 0)
            {
                var wd = new WeekDay
                {
                    Wname           = $"{startTime:MM-dd} - {GlobalSettings.GetWeek(startTime.DayOfWeek.ToString())}",
                    Date            = startTime,
                    AMTimeRange     = $"09:00-12:00",
                    PMTimeRange     = $"15:00-21:00",
                    SelectedCommand = ReactiveCommand.Create <WeekDay>(r =>
                    {
                        this.WeekDays.ForEach(s => { s.Selected = false; });
                        r.Selected       = !r.Selected;
                        this.DeliverDate = r;
                        this.AMTimeRange = r.AMTimeRange;
                        this.PMTimeRange = r.PMTimeRange;
                    })
                };
                weekDays.Add(wd);
                startTime = startTime.AddDays(1);
            }
            var defaultWd = weekDays.FirstOrDefault();
            if (defaultWd != null)
            {
                defaultWd.Selected = true;
                this.AMTimeRange   = defaultWd.AMTimeRange;
                this.PMTimeRange   = defaultWd.PMTimeRange;
            }
            this.WeekDays = new ObservableCollection <WeekDay>(weekDays);

            #endregion

            //验证
            var valid_IsReversed     = this.ValidationRule(x => x.Bill.ReversedStatus, _isBool, "已红冲单据不能操作");
            var valid_IsAudited      = this.ValidationRule(x => x.Bill.AuditedStatus, _isBool, "已审核单据不能操作");
            var valid_TerminalId     = this.ValidationRule(x => x.Bill.TerminalId, _isZero, "客户未指定");
            var valid_BusinessUserId = this.ValidationRule(x => x.Bill.DeliveryUserId, _isZero, "配送员未指定");
            var valid_WareHouseId    = this.ValidationRule(x => x.Bill.WareHouseId, _isZero, "仓库未指定");
            var valid_ProductCount   = this.ValidationRule(x => x.Bill.Items.Count, _isZero, "请添加商品项目");

            //添加商品
            this.AddProductCommand = ReactiveCommand.Create <object>(async e =>
            {
                if (this.Bill.AuditedStatus && !this.ReferencePage.Equals("UnDeliveryPage"))
                {
                    _dialogService.ShortAlert("已审核单据不能操作");
                    return;
                }

                if (!valid_TerminalId.IsValid)
                {
                    _dialogService.ShortAlert(valid_TerminalId.Message[0]);
                    ((ICommand)CustomSelected)?.Execute(null);
                    return;
                }

                if (!valid_WareHouseId.IsValid)
                {
                    _dialogService.ShortAlert(valid_WareHouseId.Message[0]);
                    ((ICommand)StockSelected)?.Execute(null);
                    return;
                }

                if (!valid_BusinessUserId.IsValid)
                {
                    _dialogService.ShortAlert(valid_BusinessUserId.Message[0]);
                    ((ICommand)DeliverSelected)?.Execute(null);
                    return;
                }

                //转向商品选择
                await this.NavigateAsync("SelectProductPage", ("Reference", this.PageName),
                                         ("WareHouse", WareHouse),
                                         ("TerminalId", Bill.TerminalId),
                                         ("Terminaler", this.Terminal),
                                         ("SerchKey", Filter.SerchKey));
            });

            //编辑商品
            this.WhenAnyValue(x => x.Selecter).Throttle(TimeSpan.FromMilliseconds(500))
            .Skip(1)
            .Where(x => x != null)
            .SubOnMainThread(async item =>
            {
                if (this.Bill.ReversedStatus)
                {
                    _dialogService.ShortAlert("已红冲单据不能操作");
                    return;
                }

                if (this.Bill.AuditedStatus)
                {
                    _dialogService.ShortAlert("已审核单据不能操作");
                    return;
                }

                if (this.Bill.IsSubmitBill)
                {
                    _dialogService.ShortAlert("已提交的单据不能编辑");
                    return;
                }

                if (item != null)
                {
                    var product = ProductSeries.Select(p => p).Where(p => p.Id == item.ProductId).FirstOrDefault();
                    if (product != null)
                    {
                        product.UnitId   = item.UnitId;
                        product.Quantity = item.Quantity;
                        product.Price    = item.Price;
                        product.Amount   = item.Amount;
                        product.Remark   = item.Remark;
                        product.Subtotal = item.Subtotal;
                        product.UnitName = item.UnitName;

                        if (item.BigUnitId > 0)
                        {
                            product.bigOption.Name        = item.UnitName;
                            product.BigPriceUnit.Quantity = item.Quantity;
                            product.BigPriceUnit.UnitId   = item.BigUnitId;
                            product.BigPriceUnit.Amount   = item.Amount;
                            product.BigPriceUnit.Remark   = item.Remark;
                        }

                        if (item.SmallUnitId > 0)
                        {
                            product.bigOption.Name          = item.UnitName;
                            product.SmallPriceUnit.Quantity = item.Quantity;
                            product.SmallPriceUnit.UnitId   = item.SmallUnitId;
                            product.SmallPriceUnit.Amount   = item.Amount;
                            product.SmallPriceUnit.Remark   = item.Remark;
                        }

                        await this.NavigateAsync("EditProductPage", ("Product", product), ("Reference", PageName), ("Item", item), ("WareHouse", WareHouse));
                    }
                }

                this.Selecter = null;
            })
            .DisposeWith(DeactivateWith);

            //提交表单
            this.SubmitDataCommand = ReactiveCommand.CreateFromTask <object, Unit>(async _ =>
            {
                return(await this.Access(AccessGranularityEnum.ExchangeBillsSave, async() =>
                {
                    if (this.Bill.ReversedStatus)
                    {
                        _dialogService.ShortAlert("已红冲单据不能操作");
                        return Unit.Default;
                    }

                    if (this.Bill.AuditedStatus || DispatchItem != null)
                    {
                        _dialogService.ShortAlert("已审核单据不能操作");
                        return Unit.Default;
                    }

                    //结算方式
                    Bill.PayTypeId = 0;
                    Bill.PayTypeName = "";

                    if (Bill.BusinessUserId == 0)
                    {
                        Bill.BusinessUserId = Settings.UserId;
                    }

                    var postMData = new ExchangeBillUpdateModel()
                    {
                        BillNumber = this.Bill.BillNumber,
                        //客户
                        TerminalId = Bill.TerminalId,
                        //业务员
                        BusinessUserId = Bill.BusinessUserId,
                        //送货员
                        DeliveryUserId = Bill.DeliveryUserId,
                        //仓库
                        WareHouseId = Bill.WareHouseId,
                        //交易日期
                        TransactionDate = DateTime.Now,
                        //默认售价方式
                        DefaultAmountId = Settings.DefaultPricePlan,
                        //备注
                        Remark = Bill.Remark,
                        //优惠金额
                        PreferentialAmount = 0,
                        //优惠后金额
                        PreferentialEndAmount = 0,
                        //欠款金额
                        OweCash = 0,
                        //商品项目
                        Items = Bill.Items,
                        //收款账户
                        //预收款
                        AdvanceAmount = 0,
                        //预收款余额
                        AdvanceAmountBalance = 0,
                        //配送时间
                        DeliverDate = this.DeliverDate?.Date ?? DateTime.Now,
                        AMTimeRange = this.DeliverDate?.AMTimeRange,
                        PMTimeRange = this.DeliverDate?.PMTimeRange
                    };


                    return await SubmitAsync(postMData, Bill.Id, _exchangeBillService.CreateOrUpdateAsync, async(result) =>
                    {
                        BillId = result.Code;
                        //清空单据
                        Bill = new ExchangeBillModel();


                        if (IsVisit) //拜访时开单
                        {
                            //转向拜访界面
                            await this.NavigateAsync("VisitStorePage", ("BillTypeId", BillTypeEnum.ExchangeBill),
                                                     ("BillId", BillId),
                                                     ("Amount", Bill.SumAmount));
                        }
                    }, !IsVisit, token: new System.Threading.CancellationToken());
                }));
            },
コード例 #6
0
        public CostExpenditureBillPageViewModel(INavigationService navigationService,
                                                IProductService productService,
                                                IUserService userService,
                                                ITerminalService terminalService,
                                                IWareHousesService wareHousesService,
                                                IAccountingService accountingService,
                                                ICostExpenditureService costExpenditureService,
                                                ISaleBillService saleBillService,
                                                IDialogService dialogService
                                                ) : base(navigationService, productService, terminalService, userService, wareHousesService, accountingService, dialogService)
        {
            Title = "费用支出";

            _costExpenditureService = costExpenditureService;
            _saleBillService        = saleBillService;

            InitBill();

            //验证
            var valid_IsReversed    = this.ValidationRule(x => x.Bill.ReversedStatus, _isBool, "已红冲单据不能操作");
            var valid_IsAudited     = this.ValidationRule(x => x.Bill.AuditedStatus, _isBool, "已审核单据不能操作");
            var valid_TerminalId    = this.ValidationRule(x => x.Bill.TerminalId, _isZero, "客户未指定");
            var valid_ItemCount     = this.ValidationRule(x => x.Bill.Items.Count, _isZero, "请添加费用项目");
            var valid_SelectesCount = this.ValidationRule(x => x.PaymentMethods.Selectes.Count, _isZero, "请选择支付方式");

            //提交单据
            this.SubmitDataCommand = ReactiveCommand.CreateFromTask <object, Unit>(async _ =>
            {
                //await this.Access(AccessGranularityEnum.ExpenseExpenditureSave);
                return(await this.Access(AccessGranularityEnum.ExpenseExpenditureSave, async() =>
                {
                    if (this.Bill.ReversedStatus)
                    {
                        _dialogService.ShortAlert("已红冲单据不能操作");
                        return Unit.Default;
                    }

                    var postData = new CostExpenditureUpdateModel()
                    {
                        CustomerId = this.Bill.TerminalId,
                        BillNumber = this.Bill.BillNumber,
                        EmployeeId = Settings.UserId,
                        OweCash = Bill.OweCash,
                        Remark = Bill.Remark,
                        Items = Bill.Items,
                        Accounting = PaymentMethods.Selectes.Select(a =>
                        {
                            return new AccountMaping()
                            {
                                AccountingOptionId = a.AccountingOptionId,
                                CollectionAmount = a.CollectionAmount,
                                Name = a.Name,
                                BillId = 0,
                            };
                        }).ToList(),
                    };
                    return await SubmitAsync(postData, 0, _costExpenditureService.CreateOrUpdateAsync, (result) =>
                    {
                        Bill = new CostExpenditureBillModel();
                    }, token: new System.Threading.CancellationToken());
                }));
            },
                                                                                   this.IsValid());

            //存储记录
            this.SaveCommand = ReactiveCommand.Create <object>(async e =>
            {
                if (!this.Bill.AuditedStatus && this.Bill.TerminalId != 0 && this.Bill.TerminalId != Settings.CostExpenditureBill?.TerminalId)
                {
                    var ok = await _dialogService.ShowConfirmAsync("你是否要保存单据?", "提示", "确定", "取消");
                    if (ok)
                    {
                        if (!this.Bill.AuditedStatus)
                        {
                            Settings.CostExpenditureBill = this.Bill;
                        }
                    }
                }
                await _navigationService.GoBackAsync();
            });

            //编辑费用
            this.WhenAnyValue(x => x.Selecter).Throttle(TimeSpan.FromMilliseconds(500))
            .Skip(1)
            .Where(x => x != null)
            .SubOnMainThread(async x =>
            {
                if (this.Bill.ReversedStatus)
                {
                    _dialogService.ShortAlert("已红冲单据不能操作");
                    return;
                }

                if (this.Bill.AuditedStatus)
                {
                    _dialogService.ShortAlert("已审核单据不能操作");
                    return;
                }

                await this.NavigateAsync("AddCostPage", ("Terminaler", this.Terminal), ("Selecter", x));
                this.Selecter = null;
            })
            .DisposeWith(DeactivateWith);

            //添加费用
            this.AddCostCommand = ReactiveCommand.Create <object>(async e =>
            {
                if (!valid_TerminalId.IsValid)
                {
                    _dialogService.ShortAlert(valid_TerminalId.Message[0]); return;
                }
                if (this.Bill.AuditedStatus)
                {
                    _dialogService.ShortAlert("已审核单据不能操作!"); return;
                }

                await this.NavigateAsync("AddCostPage", ("Terminaler", this.Terminal));
            });

            //更多支付方式
            this.MorePaymentCommand = ReactiveCommand.Create <object>(async e =>
            {
                if (!valid_TerminalId.IsValid)
                {
                    _dialogService.ShortAlert("客户未指定!"); return;
                }
                this.PaymentMethods.PreferentialAmountShowFiled = false;
                await this.NavigateAsync("PaymentMethodPage", ("PaymentMethods", this.PaymentMethods), ("BillType", this.BillType));
            });

            //审核
            this.AuditingDataCommand = ReactiveCommand.Create <object>(async _ =>
            {
                //是否具有审核权限
                await this.Access(AccessGranularityEnum.ExpenseExpenditureApproved);
                await SubmitAsync(Bill.Id, _costExpenditureService.AuditingAsync, async(result) =>
                {
                    //红冲审核水印
                    this.Bill.AuditedStatus = true;

                    var _conn = App.Resolve <ILiteDbService <MessageInfo> >();
                    var ms    = await _conn.Table.FindByIdAsync(SelecterMessage.Id);
                    if (ms != null)
                    {
                        ms.IsRead = true;
                        await _conn.UpsertAsync(ms);
                    }
                });
            }, this.WhenAny(x => x.Bill.Id, (x) => x.GetValue() > 0));


            //拒签
            this.RefusedCommand = ReactiveCommand.CreateFromTask <object>(async _ =>
            {
                try
                {
                    var ok = await _dialogService.ShowConfirmAsync("你确定要放弃签收吗?", "", "确定", "取消");
                    if (ok)
                    {
                        var postMData = new DeliverySignUpdateModel()
                        {
                            //不关联调拨单
                            DispatchItemId = 0,
                            DispatchBillId = 0,
                            StoreId        = Settings.StoreId,
                            BillId         = Bill.Id,
                            BillTypeId     = (int)BillTypeEnum.CostExpenditureBill,
                            //
                            Latitude  = GlobalSettings.Latitude,
                            Longitude = GlobalSettings.Longitude,
                            Signature = ""
                        };
                        await SubmitAsync(postMData, postMData.Id, _saleBillService.RefusedConfirmAsync, async(result) =>
                        {
                            await _navigationService.GoBackAsync();
                        });
                    }
                }
                catch (Exception)
                {
                    await _dialogService.ShowAlertAsync("拒签失败,服务器请求错误!", "", "取消");
                }
            });

            //签收
            this.ConfirmCommand = ReactiveCommand.CreateFromTask <object>(async _ =>
            {
                try
                {
                    //如果签收距离>50 则计数
                    if (Terminal.CalcDistance() > 50)
                    {
                        var tmp = Settings.Abnormal;
                        if (tmp != null)
                        {
                            tmp.Id            = Terminal.Id;
                            tmp.Counter      += 1;
                            Settings.Abnormal = tmp;
                        }
                        else
                        {
                            Settings.Abnormal = new AbnormalNum {
                                Id = Terminal.Id, Counter = 1
                            };
                        }
                    }

                    var signature = await CrossDiaglogKit.Current.GetSignaturePadAsync("手写签名", "", Keyboard.Default, defaultValue: "", placeHolder: "请手写签名...");
                    if (!string.IsNullOrEmpty(signature))
                    {
                        var postMData = new DeliverySignUpdateModel()
                        {
                            //不关联调拨单
                            DispatchItemId = 0,
                            DispatchBillId = 0,
                            StoreId        = Settings.StoreId,
                            BillId         = Bill.Id,
                            BillTypeId     = (int)BillTypeEnum.CostExpenditureBill,
                            //
                            Latitude  = GlobalSettings.Latitude,
                            Longitude = GlobalSettings.Longitude,
                            Signature = signature
                        };

                        //如果终端异常签收大于5次,则拍照
                        //if (Settings.Abnormal.Counter > 5)
                        //{
                        //    await TakePhotograph((u, m) =>
                        //    {
                        //        var photo = new RetainPhoto
                        //        {
                        //            DisplayPath = $"{GlobalSettings.FileCenterEndpoint}HRXHJS/document/image/" + u.Id + ""
                        //        };
                        //        postMData.RetainPhotos.Add(photo);
                        //    });
                        //}

                        if (Settings.Abnormal.Counter > 5 && postMData.RetainPhotos.Count == 0)
                        {
                            await _dialogService.ShowAlertAsync("拒绝操作,请留存拍照!", "", "取消");
                            return;
                        }

                        await SubmitAsync(postMData, postMData.Id, _saleBillService.DeliverySignConfirmAsync, async(result) =>
                        {
                            await _navigationService.GoBackAsync();
                        });
                    }
                }
                catch (Exception)
                {
                    await _dialogService.ShowAlertAsync("签收失败,服务器请求错误!", "", "取消");
                }
            });


            //绑定页面菜单
            _popupMenu = new PopupMenu(this, new Dictionary <MenuEnum, Action <SubMenu, ViewModelBase> >
            {
                //整单备注
                { MenuEnum.REMARK, (m, vm) => {
                      AllRemak((result) => { Bill.Remark = result; }, Bill.Remark);
                  } },
                //清空单据
                { MenuEnum.CLEAR, (m, vm) => {
                      ClearBill <CostContractBillModel, CostContractItemModel>(null, DoClear);
                  } },
                //销售备注
                { MenuEnum.SALEREMARK, (m, vm) => {
                      AllRemak((result) => { Bill.Remark = result; }, Bill.Remark);
                  } }
            });
        }
コード例 #7
0
        public UnOrderPageViewModel(INavigationService navigationService,
                                    ISaleBillService saleBillService,
                                    IDialogService dialogService
                                    ) : base(navigationService, dialogService)
        {
            Title = "订单签收(0)";

            _saleBillService = saleBillService;

            this.Bills = new ObservableCollection <DispatchItemModel>();

            //载入未签收单据
            this.Load = DispatchItemsLoader.Load(async() =>
            {
                var pending = new List <DispatchItemModel>();

                try
                {
                    //获取未签收订单单据
                    var result = await _saleBillService.GetUndeliveredSignsAsync(Settings.UserId,
                                                                                 Filter.StartTime,
                                                                                 Filter.EndTime,
                                                                                 Filter.BusinessUserId,
                                                                                 Filter.TerminalId,
                                                                                 force: this.ForceRefresh,
                                                                                 calToken: (cts?.Token) ?? new System.Threading.CancellationToken());

                    if (result != null)
                    {
                        pending = result?.Select(s =>
                        {
                            var sm = s;
                            s.SaleReservationBill.AuditedStatus   = true;
                            s.ExchangeBillModel.AuditedStatus     = true;
                            s.ReturnReservationBill.AuditedStatus = true;
                            sm.IsLast = !(result.LastOrDefault()?.BillNumber == s.BillNumber);
                            return(sm);
                        }).ToList();

                        TotalAmount = pending.Select(b => b.OrderAmount).Sum();
                        Title       = $"未签收({pending.Count})";

                        if (pending != null)
                        {
                            Bills = new ObservableCollection <DispatchItemModel>(pending);
                        }
                        else
                        {
                            Bills = new ObservableCollection <DispatchItemModel>();
                        }
                    }
                    else
                    {
                        TotalAmount = 0;
                        Title       = $"未签收(0)";
                        Bills       = new ObservableCollection <DispatchItemModel>();
                    }
                }
                catch (System.Exception ex)
                {
                    Crashes.TrackError(ex);
                }

                return(pending);
            });


            //签收
            //注意:这里的换货签收逻辑和销售退货签收逻辑不同
            this.SelecterCommand = ReactiveCommand.CreateFromTask <DispatchItemModel>(async(item) =>
            {
                if (item != null)
                {
                    using (UserDialogs.Instance.Loading("稍等..."))
                    {
                        if (item.BillTypeId == (int)BillTypeEnum.ExchangeBill)
                        {
                            await this.NavigateAsync("ExchangeBillPage", ("Reference", this.PageName),
                                                     ("DispatchItemModel", item),
                                                     ("Bill", null));
                        }
                        else if (item.BillTypeId == (int)BillTypeEnum.SaleReservationBill)
                        {
                            await this.NavigateAsync("SaleBillPage", ("Reference", this.PageName),
                                                     ("DispatchItemModel", item),
                                                     ("Bill", null));
                        }
                        else if (item.BillTypeId == (int)BillTypeEnum.ReturnReservationBill)
                        {
                            await this.NavigateAsync("ReturnBillPage", ("Reference", this.PageName),
                                                     ("DispatchItemModel", item),
                                                     ("Bill", null));
                        }
                    }

                    /*
                     * var result = await CrossDiaglogKit.Current.GetVerificationCodeAsync("签收码", "", Keyboard.Numeric, defaultValue: "", placeHolder: "请输入6位验证码...");
                     * if (!string.IsNullOrEmpty(result))
                     * {
                     *  if (result.Equals("123456"))
                     *  {
                     *      using (UserDialogs.Instance.Loading("稍等..."))
                     *      {
                     *          if (item.BillTypeId == (int)BillTypeEnum.ExchangeBill)
                     *          {
                     *              this.NavigateAsync("ExchangeBillPage", ("Reference", this.PageName),
                     *                  ("DispatchItemModel", item),
                     *                  ("Bill", null));
                     *          }
                     *          else if (item.BillTypeId == (int)BillTypeEnum.SaleReservationBill)
                     *          {
                     *              this.NavigateAsync("SaleBillPage", ("Reference", this.PageName),
                     *                  ("DispatchItemModel", item),
                     *                  ("Bill", null));
                     *          }
                     *          else if (item.BillTypeId == (int)BillTypeEnum.ReturnReservationBill)
                     *          {
                     *              this.NavigateAsync("ReturnBillPage", ("Reference", this.PageName),
                     *                  ("DispatchItemModel", item),
                     *                   ("Bill", null));
                     *          }
                     *      }
                     *  }
                     *  else
                     *  {
                     *      this.Alert("验证码错误!");
                     *  }
                     * }
                     */
                }
                item = null;
            });



            //菜单选择
            this.SubscribeMenus((x) =>
            {
                //获取当前UTC时间
                DateTime dtime = DateTime.Now;
                switch (x)
                {
                case MenuEnum.TODAY:
                    {
                        Filter.StartTime = DateTime.Parse(dtime.ToString("yyyy-MM-dd 00:00:00"));
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.YESTDAY:
                    {
                        Filter.StartTime = dtime.AddDays(-1);
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.OTHER:
                    {
                        SelectDateRang();
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;
                }
            }, string.Format(Constants.MENU_DEV_KEY, 0));



            this.BindBusyCommand(Load);
        }
コード例 #8
0
        public InventoryReportViewPageViewModel(INavigationService navigationService,
                                                IGlobalService globalService,
                                                IDialogService dialogService,
                                                IAllocationService allocationService,
                                                IAdvanceReceiptService advanceReceiptService,
                                                IReceiptCashService receiptCashService,
                                                ICostContractService costContractService,
                                                ICostExpenditureService costExpenditureService,
                                                IInventoryService inventoryService,
                                                IPurchaseBillService purchaseBillService,
                                                IReturnReservationBillService returnReservationBillService,
                                                IReturnBillService returnBillService,
                                                ISaleReservationBillService saleReservationBillService,
                                                IWareHousesService wareHousesService,
                                                ISaleBillService saleBillService
                                                ) : base(navigationService, globalService, allocationService, advanceReceiptService, receiptCashService, costContractService, costExpenditureService, inventoryService, purchaseBillService, returnReservationBillService, returnBillService, saleReservationBillService, saleBillService, dialogService)
        {
            Title = "库存上报";

            _wareHousesService = wareHousesService;

            this.Load = ReactiveCommand.Create(async() =>
            {
                ItemTreshold = 1;
                PageCounter  = 0;

                try
                {
                    Bills?.Clear();
                    var pending = new List <InventoryReportSummaryModel>();

                    int?makeuserId     = Settings.UserId;
                    int?terminalId     = null;
                    int?businessUserId = null;
                    int?productId      = null;
                    int?channelId      = null;
                    int?rankId         = null;
                    int?districtId     = null;

                    string billNumber  = Filter.SerchKey;
                    DateTime?startTime = Filter.StartTime ?? DateTime.Now.AddMonths(-1);
                    DateTime?endTime   = Filter.EndTime ?? DateTime.Now;


                    var result = await _wareHousesService.GetInventoryReportAsync(makeuserId, businessUserId, terminalId, channelId, rankId, districtId, productId, startTime, endTime, 0, PageSize, this.ForceRefresh, new System.Threading.CancellationToken());


                    if (result != null)
                    {
                        pending = result?.Select(s =>
                        {
                            var sm    = s;
                            sm.IsLast = !(result?.LastOrDefault()?.BillNumber == s.BillNumber);
                            return(sm);
                        }).Where(s => s.MakeUserId == Settings.UserId || s.BusinessUserId == Settings.UserId).ToList();
                    }
                    if (pending.Any())
                    {
                        Bills = new System.Collections.ObjectModel.ObservableCollection <InventoryReportSummaryModel>(pending);
                    }


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


            this.ItemTresholdReachedCommand = ReactiveCommand.Create(async() =>
            {
                int pageIdex = 0;
                if (Bills?.Count != 0)
                {
                    pageIdex = Bills.Count / (PageSize == 0 ? 1 : PageSize);
                }

                if (PageCounter < pageIdex)
                {
                    PageCounter = pageIdex;
                    using (var dig = UserDialogs.Instance.Loading("加载中..."))
                    {
                        try
                        {
                            int?makeuserId     = Settings.UserId;
                            int?terminalId     = null;
                            int?businessUserId = null;
                            int?productId      = null;
                            int?channelId      = null;
                            int?rankId         = null;
                            int?districtId     = null;

                            string billNumber  = Filter.SerchKey;
                            DateTime?startTime = Filter.StartTime ?? DateTime.Now.AddMonths(-1);
                            DateTime?endTime   = Filter.EndTime ?? DateTime.Now;


                            var result = await _wareHousesService.GetInventoryReportAsync(makeuserId, businessUserId, terminalId, channelId, rankId, districtId, productId, startTime, endTime, 0, PageSize, this.ForceRefresh, new System.Threading.CancellationToken());

                            if (result != null)
                            {
                                foreach (var item in result)
                                {
                                    if ((item.MakeUserId == Settings.UserId || item.BusinessUserId == Settings.UserId) && Bills.Count(s => s.Id == item.Id) == 0)
                                    {
                                        Bills.Add(item);
                                    }
                                }

                                foreach (var s in Bills)
                                {
                                    s.IsLast = !(Bills.LastOrDefault()?.BillNumber == s.BillNumber);
                                }
                            }

                            UpdateTitle();
                        }
                        catch (Exception ex)
                        {
                            Crashes.TrackError(ex);
                        }
                    }
                }
            }, this.WhenAny(x => x.Bills, x => x.GetValue().Count > 0));

            this.BindBusyCommand(Load);
        }
コード例 #9
0
        public DeliveriedPageViewModel(INavigationService navigationService,
                                       ISaleBillService saleBillService,
                                       IDialogService dialogService
                                       ) : base(navigationService, dialogService)
        {
            Title = "已签收(0)";

            _saleBillService = saleBillService;

            this.Load = BillsLoader.Load(async() =>
            {
                var pending = new List <DeliverySignModel>();

                try
                {
                    var result = await _saleBillService.GetDeliveriedSignsAsync(Settings.UserId,
                                                                                Filter.StartTime,
                                                                                Filter.EndTime,
                                                                                Filter.BusinessUserId,
                                                                                Filter.TerminalId,
                                                                                force: this.ForceRefresh,
                                                                                calToken: new System.Threading.CancellationToken());

                    if (result != null)
                    {
                        pending = result.ToList();

                        this.Bills?.Clear();
                        var gDeliveries = pending.GroupBy(s => s.TerminalName).ToList();
                        foreach (var group in gDeliveries)
                        {
                            var gs = group.Select(s =>
                            {
                                var vs    = s;
                                vs.IsLast = !(group.LastOrDefault()?.BillNumber == s.BillNumber);
                                return(vs);
                            }).ToList();

                            var first = group.FirstOrDefault();
                            if (first != null)
                            {
                                Bills.Add(new DeliverySignGroup(first.TerminalName, first.Address, first.BossCall, first.Distance, gs));
                            }
                        }

                        TotalAmount = pending.Select(b => b.SumAmount).Sum();
                        Title       = $"已签收({pending.Count})";
                    }
                }
                catch (System.Exception) { }

                return(pending);
            });

            this.SelecterCommand = ReactiveCommand.Create <DeliverySignModel>(async(item) =>
            {
                if (item != null)
                {
                    using (UserDialogs.Instance.Loading("稍等..."))
                    {
                        if (item.BillTypeId == (int)BillTypeEnum.ExchangeBill)
                        {
                            await this.NavigateAsync("ExchangeBillPage", ("Reference", this.PageName),
                                                     ("Bill", item.ExchangeBill));
                        }
                        else if (item.BillTypeId == (int)BillTypeEnum.SaleReservationBill)
                        {
                            await this.NavigateAsync("SaleBillPage", ("Reference", this.PageName),
                                                     ("Bill", item.SaleBill));
                        }
                        else if (item.BillTypeId == (int)BillTypeEnum.ReturnReservationBill)
                        {
                            await this.NavigateAsync("ReturnBillPage", ("Reference", this.PageName),
                                                     ("Bill", item.ReturnBill));
                        }
                        else if (item.BillTypeId == (int)BillTypeEnum.CostExpenditureBill)
                        {
                            await this.NavigateAsync("CostExpenditureBillPage", ("Reference", this.PageName),
                                                     ("Bill", item.CostExpenditureBill));
                        }
                        else if (item.BillTypeId == (int)BillTypeEnum.SaleBill)
                        {
                            await this.NavigateAsync("SaleBillPage", ("Reference", this.PageName),
                                                     ("Bill", item.SaleBill));
                        }
                    }
                }
            });

            //菜单选择
            this.SubscribeMenus((x) =>
            {
                //获取当前UTC时间
                DateTime dtime = DateTime.Now;

                switch (x)
                {
                case MenuEnum.TODAY:
                    {
                        Filter.StartTime = DateTime.Parse(dtime.ToString("yyyy-MM-dd 00:00:00"));
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.YESTDAY:
                    {
                        Filter.StartTime = dtime.AddDays(-1);
                        Filter.EndTime   = dtime;
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;

                case MenuEnum.OTHER:
                    {
                        SelectDateRang();
                        ((ICommand)Load)?.Execute(null);
                    }
                    break;
                }
            }, string.Format(Constants.MENU_DEV_KEY, 3));


            this.BindBusyCommand(Load);
        }