feat(drone-dock): 对接订单素材库与点位筛选

This commit is contained in:
2026-10-28 18:08:39 +08:00
parent 06460fe7e6
commit 88fa1f9b77
17 changed files with 2309 additions and 30 deletions
@@ -7,6 +7,7 @@ final class DroneDockHomeViewController: BaseViewController {
let viewModel: DroneDockHomeViewModel
private let paymentControllerFactory: (() -> UIViewController)?
private let preparationControllerFactory: ((DroneDockHomeOrder, DroneDockHomeContext) -> UIViewController)?
private let materialsControllerFactory: ((DroneDockHomeOrder, DroneDockHomeContext) -> UIViewController)?
private var refreshTask: Task<Void, Never>?
private var loadMoreTask: Task<Void, Never>?
private var isRefreshing = false
@@ -32,10 +33,12 @@ final class DroneDockHomeViewController: BaseViewController {
/// 注入可测试的数据源,不加载演示数据。
init(viewModel: DroneDockHomeViewModel, paymentControllerFactory: (() -> UIViewController)? = nil,
preparationControllerFactory: ((DroneDockHomeOrder, DroneDockHomeContext) -> UIViewController)? = nil) {
preparationControllerFactory: ((DroneDockHomeOrder, DroneDockHomeContext) -> UIViewController)? = nil,
materialsControllerFactory: ((DroneDockHomeOrder, DroneDockHomeContext) -> UIViewController)? = nil) {
self.viewModel = viewModel
self.paymentControllerFactory = paymentControllerFactory
self.preparationControllerFactory = preparationControllerFactory
self.materialsControllerFactory = materialsControllerFactory
super.init(nibName: nil, bundle: nil)
hidesBottomBarWhenPushed = true
}
@@ -155,9 +158,9 @@ final class DroneDockHomeViewController: BaseViewController {
if let order = self.viewModel.orders.first(where: { $0.orderID == id }) {
cell.apply(homeOrder: order)
cell.onShootingTap = { [weak self] in
self?.openPreparation(orderID: id)
self?.openPrimaryAction(orderID: id)
}
cell.onMaterialsTap = { [weak self] in self?.showUnavailable("订单素材") }
cell.onMaterialsTap = { [weak self] in self?.openMaterials(orderID: id) }
}
return cell
}
@@ -292,7 +295,8 @@ final class DroneDockHomeViewController: BaseViewController {
private func openAllOrders() {
let controller = DroneDockOrdersViewController(
viewModel: viewModel.makeOrdersViewModel(), preparationControllerFactory: preparationFactory)
viewModel: viewModel.makeOrdersViewModel(), preparationControllerFactory: preparationFactory,
materialsControllerFactory: materialsFactory)
navigationController?.pushViewController(controller, animated: true)
}
@@ -307,8 +311,32 @@ final class DroneDockHomeViewController: BaseViewController {
}
}
private func openPreparation(orderID: String) {
/// 首页和全部订单页复用同一真实素材入口,进入页面后才读取摘要和任务。
private var materialsFactory: (DroneDockHomeOrder, DroneDockHomeContext) -> UIViewController {
materialsControllerFactory ?? { order, context in
DroneDockMaterialsViewController(viewModel: DroneDockMaterialsViewModel(
context: context, order: order,
service: DroneDockMaterialsAPI(client: NetworkServices.shared.apiClient),
currentContext: { Self.currentContext() }
))
}
}
private func openMaterials(orderID: String) {
guard !isRefreshing, let order = viewModel.orders.first(where: { $0.orderID == orderID }) else { return }
guard DroneDockHomeMetric.usableText(order.orderNumber) != nil else {
showAlert(title: "订单素材库", message: "缺少订单号,请刷新工作台后重试")
return
}
navigationController?.pushViewController(materialsFactory(order, viewModel.context), animated: true)
}
private func openPrimaryAction(orderID: String) {
guard !isRefreshing, let order = viewModel.orders.first(where: { $0.orderID == orderID }) else { return }
if order.primaryAction == "view_materials" {
openMaterials(orderID: orderID)
return
}
guard order.primaryAction == "start_shoot" else {
showUnavailable(order.actionTitle ?? "拍摄订单")
return