| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- //
- // HedgeDetailViewController.swift
- // MTP2_iOS
- //
- // Created by Muchinfo on 2021/1/22.
- // Copyright © 2021 Muchinfo. All rights reserved.
- //
- import UIKit
- import JXSegmentedView
- import GTMRefresh
- import WHToast
- import NVActivityIndicatorView
- /// 套保品种详情视图容器控制类
- class HedgeDetailViewController: BaseViewController {
- // MARK: - 属性列表
- /// 状态视图
- @IBOutlet weak var statusView: UIView!
- /// 状态
- @IBOutlet weak var ststus: UILabel!
- /// 状态
- @IBOutlet weak var title2: UILabel!
- /// 列表
- @IBOutlet weak var tableView: UITableView!
- /// 套保品种信息
- var middleGoods: MoErmcpMiddleGoodsDetail?
- /// CellIdentifier
- let CellIdentifier = "MiddleGoodsChangeLog_Cell"
-
- /// 变更记录
- var logs: [MoMiddleGoodsChangeLogs] = [] {
- didSet {
- /// 刷新列表数据
- self.tableView.reloadData()
- /// noDataButton
- self.noDataButton.isHidden = !(logs.count == 0)
- }
- }
-
- // MARK: - 生命周期
- override func viewDidLoad() {
- super.viewDidLoad()
- // Do any additional setup after loading the view.
- }
-
- override func loadView() {
- super.loadView()
- /// 显示详情信息
- showMiddleGoodsDetail()
- }
-
- /// UI界面初始化
- override func buildView() {
- super.buildView()
-
- /// loding
- addLoadingView()
- /// 添加下拉刷新控件
- tableView.gtm_addRefreshHeaderView(refreshHeader: DefaultGTMRefreshHeader()) {
- /// 查询现货明细信息
- self.queryMiddleGoodsChangeLogs()
- }
- /// 查询现货明细信息
- queryMiddleGoodsChangeLogs()
- }
-
- /// 显示详情信息
- fileprivate func showMiddleGoodsDetail() {
- /// title2
- title2.text = "修改前套保比例\n修改后套保比例"
- /// 异常
- guard let obj = middleGoods?.mg else { return }
- /// 状态
- ststus.text = "套保品种:\(obj.middlegoodsname) (\(obj.enumdicname))"
- }
-
- // MARK: - 接口请求
- /// 查询套保品种变更记录(菜单:套保品种/商品详情/变更记录)
- fileprivate func queryMiddleGoodsChangeLogs() {
- /// 异常
- guard let planManager = MTP2BusinessCore.shared.planManager,
- let obj = middleGoods?.mg else {
- return
- }
-
- /// startAnimating
- _anim?.startAnimating()
- /// 查询详情
- planManager.queryMiddleGoodsChangeLog(middlegoodsid: obj.middlegoodsid) { (isComplete, error, objs) in
- DispatchQueue.main.async {
- /// stopAnimating
- self._anim?.stopAnimating()
- /// endRefreshing
- self.tableView.endRefreshing()
-
- if !isComplete {
- self.logs = []
- WHToast.showMessage("变更记录查询失败", duration: 1.5, finishHandler: {})
- return
- }
- /// 刷新数据
- self.logs = objs?.sorted(by: { (obj1, obj2) -> Bool in
- return obj1.updatetime>obj2.updatetime
- }) ?? []
- }
- }
- }
- }
- // MARK: - 左边 UITableViewDelegate & UITableViewDataSource
- extension HedgeDetailViewController: UITableViewDelegate, UITableViewDataSource {
-
- func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
- return self.logs.count
- }
-
- func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
- let cell = tableView.dequeueReusableCell(withIdentifier: CellIdentifier, for: indexPath) as! MiddleGoodsChangeLogCell
- cell.model = self.logs[indexPath.row]
- return cell
- }
-
- func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
- return 55.0
- }
- }
- class MiddleGoodsChangeLogCell: BaseTableViewCell<MoMiddleGoodsChangeLogs> {
- /// title1
- @IBOutlet weak var title1: UILabel!
- /// title2
- @IBOutlet weak var title2: UILabel!
- /// title3
- @IBOutlet weak var title3: UILabel!
- /// title4
- @IBOutlet weak var title4: UILabel!
-
- /// 数据
- override var model: MoMiddleGoodsChangeLogs? {
- didSet {
- /// 异常
- guard let obj = model else { return }
- /// 更新时间
- title1.text = obj.updatetime.toDateString(formatter: "MM-dd HH:mm")
- /// 变更前
- title2.text = "\(obj.beforevalue*100.0)% \n\(obj.aftervalue*100.0)%"
- /// 备注
- title3.text = "\(obj.logremark.isBlank())"
- /// 修改人
- title4.text = obj.applyname.isBlank()
- }
- }
- }
|