Commit 16a50699 authored by 刘俊宏's avatar 刘俊宏

完善时间选择器

parent 2e7f7c5b
......@@ -241,7 +241,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate,loginDelegate, UITabBarCon
tabBarC = tabBarController
let v1 = OrderListViewController()
let v2 = CRKListVC()
let v2 = GoodsManageListVC()
let v3 = WorkCViewController()
let v4 = WarehoseMangementListVC()
let v5 = PersonCenterViewController()
......
......@@ -109,6 +109,13 @@ class ShowTimeSelectView: UIView ,TimeSelectViewDelgate{
var beginDateByWork: Date? = nil {
didSet {
calendarV.beginDateByWork = beginDateByWork
if BeginDate != nil && EndDate != nil {
calendarV.setOldDate(beginD: BeginDate, endD: EndDate)
let timeInterval:TimeInterval = BeginDate.timeIntervalSince1970
let timeIntervalEnd:TimeInterval = EndDate.timeIntervalSince1970
timeLbl.text = dayByDouble(sender: timeInterval) + "-" + dayByDouble(sender: timeIntervalEnd)
}
}
}
......
......@@ -111,9 +111,9 @@ class TimeSelectView: UIView, FSCalendarDataSource, FSCalendarDelegate {
self.configureVisibleCells()
}
// let date1 = "2018-12-14 08:30:00".toDate()!
// print("指定日期当天的开始时间:", date1.dateAtStartOf(.day).date)
// print("指定日期当天的结束时间:", date1.dateAtEndOf(.day).date)
// let date1 = "2018-12-14 08:30:00".toDate()!
// print("指定日期当天的开始时间:", date1.dateAtStartOf(.day).date)
// print("指定日期当天的结束时间:", date1.dateAtEndOf(.day).date)
func clearTheSelect(){
let selectArr = calendarC.selectedDates
......@@ -147,6 +147,9 @@ class TimeSelectView: UIView, FSCalendarDataSource, FSCalendarDelegate {
BeginDate = date
SelectAction = true
EndDate = nil
let dateEnd = BeginDate.addingTimeInterval(TimeInterval(60*60*24 - 1))
self.delegate?.selectMoreDate(beginDate: BeginDate, endginDate: dateEnd)
}
}else{
......@@ -154,6 +157,8 @@ class TimeSelectView: UIView, FSCalendarDataSource, FSCalendarDelegate {
BeginDate = date
SelectAction = true
EndDate = nil
let dateEnd = BeginDate.addingTimeInterval(TimeInterval(60*60*24 - 1))
self.delegate?.selectMoreDate(beginDate: BeginDate, endginDate: dateEnd)
}
......@@ -179,6 +184,8 @@ class TimeSelectView: UIView, FSCalendarDataSource, FSCalendarDelegate {
BeginDate = date
SelectAction = true
EndDate = nil
let dateEnd = BeginDate.addingTimeInterval(TimeInterval(60*60*24 - 1))
self.delegate?.selectMoreDate(beginDate: BeginDate, endginDate: dateEnd)
}
}else{
......@@ -186,6 +193,8 @@ class TimeSelectView: UIView, FSCalendarDataSource, FSCalendarDelegate {
BeginDate = date
SelectAction = true
EndDate = nil
let dateEnd = BeginDate.addingTimeInterval(TimeInterval(60*60*24 - 1))
self.delegate?.selectMoreDate(beginDate: BeginDate, endginDate: dateEnd)
}
}else{
......@@ -196,7 +205,8 @@ class TimeSelectView: UIView, FSCalendarDataSource, FSCalendarDelegate {
calendarC.select(dateA)
}
self.delegate?.selectMoreDate(beginDate: BeginDate, endginDate: EndDate)
let dateEnd = EndDate.addingTimeInterval(TimeInterval(60*60*24 - 1))
self.delegate?.selectMoreDate(beginDate: BeginDate, endginDate: dateEnd)
}
}
......@@ -217,20 +227,22 @@ class TimeSelectView: UIView, FSCalendarDataSource, FSCalendarDelegate {
SelectAction = true
BeginDate = date
EndDate = nil
let dateEnd = BeginDate.addingTimeInterval(TimeInterval(60*60*24 - 1))
self.delegate?.selectMoreDate(beginDate: BeginDate, endginDate: dateEnd)
}
self.configureVisibleCells()
}
//MARK:--最大天数为今日
// func maximumDate(for calendar: FSCalendar) -> Date {
// return Date()
// }
// func calendar(_ calendar: FSCalendar, shouldSelect date: Date, at monthPosition: FSCalendarMonthPosition) -> Bool {
// return monthPosition == .current
// }
//
// func calendar(_ calendar: FSCalendar, shouldDeselect date: Date, at monthPosition: FSCalendarMonthPosition) -> Bool {
// return monthPosition == .current
// }
// func maximumDate(for calendar: FSCalendar) -> Date {
// return Date()
// }
// func calendar(_ calendar: FSCalendar, shouldSelect date: Date, at monthPosition: FSCalendarMonthPosition) -> Bool {
// return monthPosition == .current
// }
//
// func calendar(_ calendar: FSCalendar, shouldDeselect date: Date, at monthPosition: FSCalendarMonthPosition) -> Bool {
// return monthPosition == .current
// }
//MARK:--计算日期差
......@@ -260,7 +272,7 @@ class TimeSelectView: UIView, FSCalendarDataSource, FSCalendarDelegate {
}
private func configure(cell: FSCalendarCell, for date: Date, at position: FSCalendarMonthPosition) {
let diyCell = (cell as! DIYCalendarCell)
// if position == .current {
// if position == .current {
var selectionType = SelectionType.none
if calendarC.selectedDates.contains(date) {
......@@ -299,11 +311,11 @@ class TimeSelectView: UIView, FSCalendarDataSource, FSCalendarDelegate {
diyCell.selectionLayer.isHidden = false
diyCell.selectionType = selectionType
// }
// else {
// diyCell.selectionType = .none
// diyCell.selectionLayer.isHidden = true
// }
// }
// else {
// diyCell.selectionType = .none
// diyCell.selectionLayer.isHidden = true
// }
......
......@@ -1054,6 +1054,12 @@ class EPViewController: BaseViewController,UITableViewDelegate,UITableViewDataSo
if cell.nameLbl.text == "预设预付定金时间段" {
print("定金时间段")
let timeSelectV = ShowTimeSelectView(frame: self.view.window!.bounds)
if dj_time_start != 0 && dj_time_end != 0{
var time = TimeInterval(exactly: dj_time_start!)
timeSelectV.BeginDate = Date(timeIntervalSince1970: time!)
time = TimeInterval(exactly: dj_time_end!)
timeSelectV.EndDate = Date(timeIntervalSince1970: time!)
}
timeSelectV.beginDateByWork = Date()
timeSelectV.titleLbl.text = "预设预付定金时间段"
timeSelectV.delegate = self
......@@ -1070,6 +1076,12 @@ class EPViewController: BaseViewController,UITableViewDelegate,UITableViewDataSo
let timeSelectV = ShowTimeSelectView(frame: self.view.window!.bounds)
timeSelectV.titleLbl.text = "预设预付尾款时间段"
timeSelectV.delegate = self
if wk_time_start != 0 && wk_time_end != 0{
var time = TimeInterval(exactly: wk_time_start!)
timeSelectV.BeginDate = Date(timeIntervalSince1970: time!)
time = TimeInterval(exactly: wk_time_end!)
timeSelectV.EndDate = Date(timeIntervalSince1970: time!)
}
let dijitime:TimeInterval = TimeInterval(exactly: (dj_time_start! + (24 * 60 * 60)))!
let beginDate = Date(timeIntervalSince1970: dijitime)
timeSelectV.beginDateByWork = beginDate
......
......@@ -632,6 +632,12 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
if cell.nameLbl.text == "预设预付定金时间段" {
print("定金时间段")
let timeSelectV = ShowTimeSelectView(frame: self.view.window!.bounds)
if dj_time_start != 0 && dj_time_end != 0{
var time = TimeInterval(exactly: dj_time_start!)
timeSelectV.BeginDate = Date(timeIntervalSince1970: time!)
time = TimeInterval(exactly: dj_time_end!)
timeSelectV.EndDate = Date(timeIntervalSince1970: time!)
}
timeSelectV.beginDateByWork = Date()
timeSelectV.titleLbl.text = "预设预付定金时间段"
timeSelectV.delegate = self
......@@ -648,6 +654,12 @@ class ProductDetailViewController: BaseViewController,UITableViewDelegate,UITabl
let timeSelectV = ShowTimeSelectView(frame: self.view.window!.bounds)
timeSelectV.titleLbl.text = "预设预付尾款时间段"
timeSelectV.delegate = self
if wk_time_start != 0 && wk_time_end != 0{
var time = TimeInterval(exactly: wk_time_start!)
timeSelectV.BeginDate = Date(timeIntervalSince1970: time!)
time = TimeInterval(exactly: wk_time_end!)
timeSelectV.EndDate = Date(timeIntervalSince1970: time!)
}
let dijitime:TimeInterval = TimeInterval(exactly: (dj_time_start! + (24 * 60 * 60)))!
let beginDate = Date(timeIntervalSince1970: dijitime)
timeSelectV.beginDateByWork = beginDate
......
......@@ -46,7 +46,8 @@ class WorkCViewController: BaseViewController, UITableViewDelegate, UITableViewD
//MARK:--二维码方法
@IBAction func codeAction(_ sender: UIButton) {
print("二维码方法")//加一个透明的显示弹窗
print("指定日期当天的开始时间:", Date().dateAtStartOf(.day).date)
print("指定日期当天的结束时间:", Date().dateAtEndOf(.day).date)
}
//MARK:--头部按钮方法
let selectV = WorkSelectTimeView()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment