// // TotalDetailViewController.swift // xingchuangke // // Created by 李晓飞 on 2020/9/1. // Copyright © 2020 Virgil. All rights reserved. // import UIKit class TotalDetailViewController: BaseViewController, UITableViewDelegate, UITableViewDataSource { @IBOutlet weak var timeLabel: UILabel! @IBOutlet weak var tableView: UITableView! var userId: String! var isTeam: String? var machineType: String? var type: NSInteger = 0 var timeStr: String? var endTime: String = "" var startTime: String = "" var name: String = "" var dataArr: NSArray = [] override func viewDidLoad() { super.viewDidLoad() // self.title = machineType self.title = name initNavLeftBackButton() timeLabel.text = timeStr tableView.delegate = self tableView.dataSource = self tableView.tableFooterView = UIView.init() loadData() } // MARK: - request func loadData() { let url = RequestURL.findSumGroupByPayType let params = NSMutableDictionary() params.setValue(isTeam, forKey: "isTeam") // params.setValue(CommonValue.getUserId(), forKey: "userId") params.setValue(userId, forKey: "userId") params.setValue(machineType, forKey: "machineTypeId") params.setValue(self.startTime, forKey: "starTime") params.setValue(self.endTime, forKey: "endTime") loadDataInfo(url: url, params: params, tag: 1001) } override func returnData(tag: Int) { if dicData.allKeys.count == 0 { return } dataArr = (dicData["firstGroup"] as! NSArray) tableView.reloadData() } override func returnError(tag: Int, type: String) { } // MARK: - delegate func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return dataArr.count } func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return 60 } func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { var cell = tableView.dequeueReusableCell(withIdentifier: "totalDetailCell") if cell == nil { cell = UITableViewCell.init(style: .value1, reuseIdentifier: "totalDetailCell") cell?.textLabel?.font = UIFont.systemFont(ofSize: 15) cell?.detailTextLabel?.font = UIFont.systemFont(ofSize: 15) cell?.detailTextLabel?.textColor = UIColor.black } let dic = dataArr[indexPath.row] as! NSDictionary cell?.textLabel?.text = dic["payTypeName"] as? String cell?.detailTextLabel?.text = "\(getDoubleValue(key: "amt", dic: dic))元" return cell! } /* // MARK: - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation override func prepare(for segue: UIStoryboardSegue, sender: Any?) { // Get the new view controller using segue.destination. // Pass the selected object to the new view controller. } */ }