//
//  UpcomingDetailsVC+initView.swift
//  MobilePortal
//
//  Created by caiyang on 2020/4/23.
//  Copyright © 2020 yin chen. All rights reserved.
//

import UIKit

extension UpcomingDetailsVC {
    func addInitTableView() {
        initData()
        self.delegate = UpcomingDetailsVCDelegate()
        self.delegate.dataSource = self.dataSource
        self.myTableView.delegate = self.delegate
        self.myTableView.dataSource = self.delegate
        self.myTableView.reloadData()
        myTableView.snp.makeConstraints { (make) in
            make.width.height.equalToSuperview()
            make.center.equalToSuperview()
        }
    }
    func initData(){
        addCell()
        addTitleCell()
        addDetailsTitleCell()
    }
    func addCell(){
        let titleModel = UpcomingDetailsTableViewCellModel()
        titleModel.className = "UpcomingDetailsTableViewCell"
        titleModel.titleStr = judgmentStrNil(str: model.title)
        titleModel.content = judgmentStrNil(str: self.httpModel.content)
        self.dataSource.add(titleModel)
    }
    func addTitleCell(){
        let titleModel = UpcomingDetailsTitleTableViewCellModel()
        titleModel.className = "UpcomingDetailsTitleTableViewCell"
        titleModel.typeStr = "请假审批"
        titleModel.nsme = "xxx"
        self.dataSource.add(titleModel)
    }
    func addDetailsTitleCell(){
        let titleModel = DetailsTitleTableViewCellModel()
        titleModel.className = "DetailsTitleTableViewCell"
        titleModel.content = "信息技术部xxx提交了新的请假审批"
        titleModel.id = "审批ID：8576783561710750"
        titleModel.account = "待办账号：A1230"
        titleModel.character = "审批角色：超级管理员"
        titleModel.block = {
        }
        self.dataSource.add(titleModel)
    }
}
class UpcomingDetailsVCDelegate: BaseOneTableViewDelegate {
    var cellNum:Double!
    override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 0
    }
    
    override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        
        if (section == 0){
            return 0
        }
        return 0
    }
    
    override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
        //        let infoMode:AdvisoryTableViewCellModel = self.dataSource[indexPath.row] as! AdvisoryTableViewCellModel
        //        return 53.33
        let tableCellModel:BaseCellModel = self.dataSource[indexPath.row] as! BaseCellModel
        if tableCellModel.className == "UpcomingDetailsTableViewCell" {
            return 150
        } else if tableCellModel.className == "UpcomingDetailsTitleTableViewCell"{
            return 30
        } else if tableCellModel.className == "DetailsTitleTableViewCell"{
            return 200
        }
        return 90
    }
}

