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

import UIKit

class DetailsTitleTableViewCell: BaseTableViewCell {
    lazy var contentLabel: UILabel = {
        let contentLabel = UILabel.init()
        contentLabel.textAlignment = .left
        contentLabel.numberOfLines = 0
        contentLabel.font = UIFont.test_systemFont(ofSize: 13.33)
        contentLabel.textColor = UIColorFromRGB(rgbValue: 0x23262A)
        self.addSubview(contentLabel)
        return contentLabel
    }()
    lazy var idLabel: UILabel = {
        let idLabel = UILabel.init()
        idLabel.textAlignment = .left
        idLabel.numberOfLines = 0
        idLabel.font = UIFont.test_systemFont(ofSize: 11.33)
        idLabel.textColor = UIColorFromRGB(rgbValue: 0x8792A4)
        self.addSubview(idLabel)
        return idLabel
    }()
    /// 账号
    lazy var accountLabel: UILabel = {
        let accountLabel = UILabel.init()
        accountLabel.textAlignment = .left
        accountLabel.numberOfLines = 0
        accountLabel.font = UIFont.test_systemFont(ofSize: 11.33)
        accountLabel.textColor = UIColorFromRGB(rgbValue: 0x8792A4)
        self.addSubview(accountLabel)
        return accountLabel
    }()
    /// 角色
    lazy var characterLabel: UILabel = {
        let characterLabel = UILabel.init()
        characterLabel.textAlignment = .left
        characterLabel.numberOfLines = 0
        characterLabel.font = UIFont.test_systemFont(ofSize: 11.33)
        characterLabel.textColor = UIColorFromRGB(rgbValue: 0x8792A4)
        self.addSubview(characterLabel)
        return characterLabel
    }()
    lazy var approvalBtn: UIButton = {
        let approvalBtn = UIButton.init(type: UIButtonType.custom)
        approvalBtn.setTitle("去审批", for: UIControlState.normal)
        approvalBtn.titleLabel?.font = UIFont.test_systemFont(ofSize: 11.33)
        approvalBtn.backgroundColor = UIColorFromRGB(rgbValue: 0x00BFFF)
        approvalBtn.setTitleColor(UIColor.white, for: UIControlState.normal)
        approvalBtn.addTarget(self, action: #selector(approvalBtnAction), for: .touchUpInside)
        //设置遮罩
        approvalBtn.layer.masksToBounds = true
        //设置圆角半径(宽度的一半)，显示成圆形。
        approvalBtn.layer.cornerRadius = 5
//        signOutBtn.setBackgroundImage(UIImage.init(named: "loginBtn_image"), for: .normal)
        self .addSubview(approvalBtn)
        return approvalBtn
    }()
    var xinfo = DetailsTitleTableViewCellModel()
    
    override func awakeFromNib() {
        super.awakeFromNib()
        self.separatorInset=UIEdgeInsetsMake(0, SCREEN_WHIDTH(), 0, 0)
        // Initialization code
    }
    override func configurateTheCell(_ info: BaseCellModel) {
        xinfo = info as! DetailsTitleTableViewCellModel
        let contentLabelH = getTextHeigh(textStr: xinfo.content!, font: UIFont.test_systemFont(ofSize: 13.33), width: SCREEN_WHIDTH()-54)
        contentLabel.frame = CGRect(x:26.66, y: 26.66, width: SCREEN_WHIDTH()-54, height:contentLabelH )
        contentLabel.text = xinfo.content
        idLabel.frame = CGRect(x:26.66, y: contentLabel.originY+contentLabel.height+20, width: contentLabel.width, height:12 )
        idLabel.text = xinfo.id
        accountLabel.frame = CGRect(x:26.66, y: idLabel.originY+idLabel.height+10, width: contentLabel.width, height:12 )
        accountLabel.text = xinfo.account
        characterLabel.frame = CGRect(x:26.66, y: accountLabel.originY+accountLabel.height+10, width: contentLabel.width, height:12 )
        characterLabel.text = xinfo.character
        approvalBtn.frame = CGRect(x:26.66, y: characterLabel.originY+characterLabel.height+30, width: contentLabel.width, height:40 )
        if self.xinfo.upcomingType == .DoneType {
            approvalBtn.isHidden = true
        }else {
            approvalBtn.isHidden = false
        }
        // Configure the view for the selected state
    }
    @objc func approvalBtnAction(){
        self.xinfo.block()
    }
}
class DetailsTitleTableViewCellModel: BaseCellModel {
    var content:String?
    var id:String?
    var account:String?
    var character:String?
    var upcomingType:BusinessType = .UpcomingType
    var block:selectBlock!
    var h = CGFloat()
}
