Initial commit: suixinkan_ios UIKit rewrite project.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@ -0,0 +1,130 @@
|
||||
//
|
||||
// ScenicSettlementViewControllers.swift
|
||||
// suixinkan
|
||||
//
|
||||
// Created by Codex on 2026/6/26.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
|
||||
/// 景区结算申请页。
|
||||
final class ScenicSettlementViewController: ModuleTableViewController {
|
||||
private let viewModel = ScenicSettlementViewModel()
|
||||
private let amountField = UITextField()
|
||||
private let remarkField = UITextField()
|
||||
|
||||
override func viewDidLoad() {
|
||||
title = "景区结算"
|
||||
navigationItem.rightBarButtonItem = UIBarButtonItem(
|
||||
title: "提交",
|
||||
style: .done,
|
||||
target: self,
|
||||
action: #selector(submit)
|
||||
)
|
||||
super.viewDidLoad()
|
||||
setupHeader()
|
||||
wireViewModel(viewModel) { }
|
||||
}
|
||||
|
||||
private func setupHeader() {
|
||||
amountField.placeholder = "结算金额"
|
||||
amountField.borderStyle = .roundedRect
|
||||
amountField.keyboardType = .decimalPad
|
||||
remarkField.placeholder = "备注"
|
||||
remarkField.borderStyle = .roundedRect
|
||||
let stack = UIStackView(arrangedSubviews: [amountField, remarkField])
|
||||
stack.axis = .vertical
|
||||
stack.spacing = 8
|
||||
stack.frame = CGRect(x: 0, y: 0, width: view.bounds.width, height: 96)
|
||||
stack.layoutMargins = UIEdgeInsets(top: 12, left: 16, bottom: 12, right: 16)
|
||||
stack.isLayoutMarginsRelativeArrangement = true
|
||||
tableView.tableHeaderView = stack
|
||||
}
|
||||
|
||||
override func tableRowCount() -> Int {
|
||||
viewModel.options.count
|
||||
}
|
||||
|
||||
override func configureCell(_ cell: TitleSubtitleTableViewCell, at indexPath: IndexPath) {
|
||||
let option = viewModel.options[indexPath.row]
|
||||
cell.configure(title: option.name, subtitle: option.selected ? "已选择" : nil)
|
||||
cell.accessoryType = option.selected ? .checkmark : .none
|
||||
}
|
||||
|
||||
override func didSelectTableRow(at indexPath: IndexPath) {
|
||||
viewModel.toggleScenic(id: viewModel.options[indexPath.row].id)
|
||||
}
|
||||
|
||||
override func reloadContent() async {
|
||||
await viewModel.load(
|
||||
api: services.scenicPermissionAPI,
|
||||
existingScenics: services.accountContext.scenicScopes
|
||||
)
|
||||
}
|
||||
|
||||
@objc private func submit() {
|
||||
viewModel.amountText = amountField.text ?? ""
|
||||
viewModel.remarkText = remarkField.text ?? ""
|
||||
Task {
|
||||
let success = await viewModel.submit(api: services.scenicSettlementAPI)
|
||||
if success {
|
||||
services.toastCenter.show("提交成功")
|
||||
navigationController?.popViewController(animated: true)
|
||||
} else if let message = viewModel.message {
|
||||
services.toastCenter.show(message)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension ScenicSettlementViewModel: ViewModelBindable {}
|
||||
|
||||
/// 景区结算审核页。
|
||||
final class ScenicSettlementReviewViewController: ModuleTableViewController {
|
||||
private let viewModel = ScenicSettlementReviewViewModel()
|
||||
|
||||
override func viewDidLoad() {
|
||||
title = "结算审核"
|
||||
super.viewDidLoad()
|
||||
wireViewModel(viewModel) { }
|
||||
}
|
||||
|
||||
override func numberOfSections(in tableView: UITableView) -> Int { 2 }
|
||||
|
||||
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
|
||||
section == 0 ? viewModel.scenicApplications.count : viewModel.roleApplications.count
|
||||
}
|
||||
|
||||
func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
|
||||
section == 0 ? "景区申请" : "权限申请"
|
||||
}
|
||||
|
||||
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
|
||||
let cell = tableView.dequeueReusableCell(
|
||||
withIdentifier: TitleSubtitleTableViewCell.reuseIdentifier,
|
||||
for: indexPath
|
||||
) as! TitleSubtitleTableViewCell
|
||||
if indexPath.section == 0 {
|
||||
let item = viewModel.scenicApplications[indexPath.row]
|
||||
cell.configure(
|
||||
title: item.scenicName,
|
||||
subtitle: viewModel.statusText(item.status),
|
||||
detail: item.createdAt
|
||||
)
|
||||
} else {
|
||||
let item = viewModel.roleApplications[indexPath.row]
|
||||
cell.configure(
|
||||
title: item.roleName,
|
||||
subtitle: viewModel.statusText(item.status, fallback: item.statusLabel),
|
||||
detail: item.createdAt
|
||||
)
|
||||
}
|
||||
return cell
|
||||
}
|
||||
|
||||
override func reloadContent() async {
|
||||
await viewModel.load(api: services.scenicPermissionAPI)
|
||||
}
|
||||
}
|
||||
|
||||
extension ScenicSettlementReviewViewModel: ViewModelBindable {}
|
||||
Reference in New Issue
Block a user