OOAttandanceTotalHeaderView.swift 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. //
  2. // OOAttandanceTotalHeaderView.swift
  3. // O2Platform
  4. //
  5. // Created by 刘振兴 on 2018/5/24.
  6. // Copyright © 2018年 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. class OOAttandanceTotalHeaderView: UIView,Configurable {
  10. @IBOutlet weak var checkinDateButton: UIButton!
  11. @IBOutlet weak var checkinStartTimeLabel: UILabel!
  12. @IBOutlet weak var checkinEndTimeLabel: UILabel!
  13. @IBOutlet weak var normalLabel: UILabel!
  14. @IBOutlet weak var lateLabel: UILabel!
  15. @IBOutlet weak var leaveLabel: UILabel!
  16. @IBOutlet weak var abnormalLabel: UILabel!
  17. var requestBean:OOAttandanceCycleDetail = OOAttandanceCycleDetail() {
  18. didSet {
  19. let buttonText = "\(requestBean.cycleYear ?? "")-\(requestBean.cycleMonth ?? "")"
  20. checkinDateButton.setTitle(buttonText, for: .normal)
  21. checkinStartTimeLabel.text = requestBean.cycleStartDate
  22. checkinEndTimeLabel.text = requestBean.cycleEndDate
  23. }
  24. }
  25. override func awakeFromNib() {
  26. // button标题的偏移量
  27. self.checkinDateButton.titleEdgeInsets = UIEdgeInsets(top: 0,left: -((self.checkinDateButton.imageView?.bounds.size.width)! + 2), bottom: 0, right: (self.checkinDateButton.imageView?.bounds.size.width)!);
  28. // button图片的偏移量
  29. self.checkinDateButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: (self.checkinDateButton.titleLabel?.bounds.size.width)!, bottom: 0, right: -((self.checkinDateButton.titleLabel?.bounds.size.width)!));
  30. normalLabel.layer.cornerRadius = 20
  31. normalLabel.layer.masksToBounds = true
  32. lateLabel.layer.cornerRadius = 20
  33. lateLabel.layer.masksToBounds = true
  34. leaveLabel.layer.cornerRadius = 20
  35. leaveLabel.layer.masksToBounds = true
  36. abnormalLabel.layer.cornerRadius = 20
  37. abnormalLabel.layer.masksToBounds = true
  38. }
  39. func config(withItem item: Any?) {
  40. guard let model = item as? OOAttandanceAnalyze else {
  41. normalLabel.text = "0"
  42. lateLabel.text = "0"
  43. leaveLabel.text = "0"
  44. abnormalLabel.text = "0"
  45. return
  46. }
  47. normalLabel.text = String(model.onDutyTimes!)
  48. lateLabel.text = String(model.lateTimes!)
  49. leaveLabel.text = String(model.leaveEarlyTimes!)
  50. abnormalLabel.text = String(model.onSelfHolidayCount!)
  51. }
  52. @IBAction func selectTheDateAction(_ sender: Any) {
  53. NotificationCenter.post(customeNotification: .staticsTotal)
  54. }
  55. }