private async void PART_Stepper_ContinueNavigation(object sender, MaterialDesignExtensions.Controls.StepperNavigationEventArgs args) { int idx = 0; for (; idx < PART_Stepper.Controller.Steps.Length; ++idx) { if (args.CurrentStep == PART_Stepper.Controller.Steps[idx]) { break; } } if (idx == 0) { // 从申请到等待审核 // TODO 这里有一个请求要发 await Task.Delay(100); ApplicationViewModel = new ApplicationListViewModel(); ApplicationDetailViewModel = new ApplicationDetailViewModel(); RefreshApplicationCardView(); } else if (idx == 3) { // 确认 } }
private async void PART_Stepper_ContinueNavigation(object sender, MaterialDesignExtensions.Controls.StepperNavigationEventArgs args) { int idx = 0; for (; idx < PART_Stepper.Controller.Steps.Length; ++idx) { if (args.CurrentStep == PART_Stepper.Controller.Steps[idx]) { break; // 确定现在在哪个Step } } if (idx == 0) { // 发送申请 ApplicationMaterialListViewModel selected = (ApplicationMaterialListViewModel)MaterialSelectListBox.SelectedItem; if (selected == null) { MainWindow.SetSnackBarContentAndPopup("请选择要申请的物资"); args.Cancel = true; return; } else if (QuantityInputBox.Value == null || QuantityInputBox.Value <= 0) { MainWindow.SetSnackBarContentAndPopup("不合法的数目"); args.Cancel = true; return; } else if (QuantityInputBox.Value > selected.Constraint) { MainWindow.SetSnackBarContentAndPopup("超出数量限制"); args.Cancel = true; return; } NewApplicationResponse response = await NetworkHelper.GetAsync(new NewApplicationRequest() { MaterialId = selected.OriginItem.Id, Quantity = (int)QuantityInputBox.Value, Address = UserInfo.HomeAddress }).Progress(ParentWindow.PART_ProgressBar); ApplicationViewModel = new ApplicationListViewModel(response.Item); ApplicationDetailViewModel = new ApplicationDetailViewModel(await NetworkHelper.GetAsync(new GetApplicationDetailRequest() { ApplicationId = ApplicationViewModel.OriginalItem.ID }).Progress(ParentWindow.PART_ProgressBar)); RefreshApplicationCardView(); } else if (idx == 3) { // 确认 await NetworkHelper.GetAsync(new ConfirmApplicationDoneRequest() { ApplicationId = ApplicationViewModel.OriginalItem.ID }); } }
private async void Page_Loaded(object sender, RoutedEventArgs e) { if (ApplicationViewModel != null) { // 查看已存在的申请 // 1. 网络请求ApplicationDetailViewModel ApplicationDetailViewModel = new ApplicationDetailViewModel(await NetworkHelper.GetAsync(new GetApplicationDetailRequest() { ApplicationId = ApplicationViewModel.OriginalItem.ID }).Progress(ParentWindow.PART_ProgressBar)); // 2. 根据ApplicationViewModel和ApplicationDetailViewModel来生成正确的Tab显示 switch (ApplicationViewModel.OriginalItem.State) { case ApplicationState.Applying: PART_Stepper.Controller.GotoStep(1); break; case ApplicationState.WaitingDelivery: case ApplicationState.Delivering: // 客户端不区分等待配送和配送中 PART_Stepper.Controller.GotoStep(2); break; case ApplicationState.Received: ArrivedPanel.Visibility = Visibility.Visible; AllDonePanel.Visibility = Visibility.Collapsed; ConfirmStepBar.Visibility = Visibility.Visible; PART_Stepper.Controller.GotoStep(3); break; case ApplicationState.Done: ArrivedPanel.Visibility = Visibility.Collapsed; AllDonePanel.Visibility = Visibility.Visible; ConfirmStepBar.Visibility = Visibility.Collapsed; PART_Stepper.Controller.GotoStep(3); break; default: PART_Stepper.Controller.GotoStep(1); break; } } else { // 填写新申请 // 1. 请求所有可选的物资 AvailableApplicationMaterialResponse response = await NetworkHelper.GetAsync( new AvailableApplicationMaterialRequest() { }).Progress(ParentWindow.PART_ProgressBar); MaterialListViewModels = new ObservableCollection <ApplicationMaterialListViewModel>(response.Items.Select(i => new ApplicationMaterialListViewModel(i))); MaterialSelectListBox.ItemsSource = MaterialListViewModels; // 2. 初始化好填写界面 RefreshAddressInfo(); PART_Stepper.Controller.GotoStep(0); } RefreshApplicationCardView(); }