Commit 56579487 authored by 刘俊宏's avatar 刘俊宏

添加订单列表筛选视图功能

parent 7d0e3df1
......@@ -3,27 +3,4 @@
uuid = "5B8F44F7-39A9-41EF-84D0-455B68FF56A8"
type = "0"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.SwiftErrorBreakpoint">
<BreakpointContent
uuid = "47CF42B7-E5E4-4914-BF79-0C1440336BDB"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
uuid = "DA0714E8-DD5C-48E8-93AF-CB4E86B966F9"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
breakpointStackSelectionBehavior = "1"
scope = "1"
stopOnStyle = "0">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
{
"images" : [
{
"filename" : "shaixuan.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "shaixuan@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "shaixuan@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -7,15 +7,30 @@
//
import Foundation
class OrderSelectMoreView: UIView {
var contentView:UIView!
import SwiftDate
protocol OrderSelectMoreViewDelegate {
func sureAction(selectData:Any)
func colseAction()
}
class OrderSelectMoreView: UIView,TitleAndSelCalendarViewDelegate ,TimeSelectViewDelgate{
var contentView:UIView!
var delegate:OrderSelectMoreViewDelegate?
@IBOutlet weak var contentWidht: NSLayoutConstraint!
@IBOutlet weak var contentHeight: NSLayoutConstraint!
@IBOutlet weak var moreBgView: UIView!
@IBAction func colseByBlackTap(_ sender: UITapGestureRecognizer) {
self.removeFromSuperview()
self.delegate?.colseAction()
}
@IBAction func sure(_ sender: UIButton) {
self.removeFromSuperview()
self.delegate?.sureAction(selectData: "")
}
@IBAction func reset(_ sender: Any) {
}
//初始化时将xib中的view添加进来
......@@ -49,16 +64,19 @@ class OrderSelectMoreView: UIView {
let view = nib.instantiate(withOwner: self, options: nil).first as! UIView
return view
}
let line1 = UIView()
let timeTilelV = TitleAndSelCalendarView()
func setUI() {
let timeTilelV = TitleAndSelCalendarView()
timeTilelV.delegate = self
moreBgView.addSubview(timeTilelV)
timeTilelV.snp.makeConstraints { (make) in
make.left.top.equalTo(15*glscale)
make.right.equalTo(-135*glscale)
make.height.equalTo(60*glscale)
}
//分界线1
let line1 = UIView()
line1.backgroundColor = UIColor.init(named: "灰色分界线")
moreBgView.addSubview(line1)
line1.snp.makeConstraints { (make) in
......@@ -161,6 +179,33 @@ class OrderSelectMoreView: UIView {
sender.backgroundColor = UIColor.init(named: "多选按钮背景颜色")
}
}
let calendarV = TimeSelectView(frame: CGRect(x: 0, y: 85*glscale, width: fullScreenWidth, height: 235*glscale))
//MARK:--展示日历选择器
func isShowCalendarV(isShow: Bool) {
if isShow {
contentHeight.constant = 400*glscale + 235*glscale
calendarV.moreSelection = true
moreBgView.addSubview(calendarV)
calendarV.delegate = self
line1.snp.remakeConstraints { (make) in
make.left.right.equalTo(0)
make.height.equalTo(1)
make.top.equalTo(calendarV.snp_bottom)
}
}else{
calendarV.removeFromSuperview()
contentHeight.constant = 400*glscale
line1.snp.remakeConstraints { (make) in
make.left.right.equalTo(0)
make.height.equalTo(1)
make.top.equalTo(timeTilelV.snp_bottom).offset(15*glscale)
}
}
}
//MARK:--日历代理
func selectMoreDate(beginDate: Date, endginDate: Date) {
timeTilelV.timeLbl.text = beginDate.toFormat("yyyy.MM.dd") + "," + endginDate.toFormat("yyyy.MM.dd")
}
}
......@@ -50,6 +50,9 @@
<state key="normal" title="重置">
<color key="titleColor" name="灰色字体颜色"/>
</state>
<connections>
<action selector="reset:" destination="-1" eventType="touchUpInside" id="6wq-Zb-6wr"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="sTi-CD-uRH">
<rect key="frame" x="188" y="400" width="187" height="50"/>
......@@ -57,6 +60,9 @@
<state key="normal" title="确定">
<color key="titleColor" name="蓝色字体颜色"/>
</state>
<connections>
<action selector="sure:" destination="-1" eventType="touchUpInside" id="Ad9-CJ-Cfr"/>
</connections>
</button>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="zOf-Po-PY2">
<rect key="frame" x="0.0" y="5" width="375" height="394"/>
......@@ -148,10 +154,10 @@
<color red="0.92941176470588238" green="0.92941176470588238" blue="0.92941176470588238" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="灰色字体颜色">
<color red="0.40000000000000002" green="0.40000000000000002" blue="0.40000000000000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.40000000596046448" green="0.40000000596046448" blue="0.40000000596046448" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="蓝色字体颜色">
<color red="0.27843137254901962" green="0.5607843137254902" blue="0.8901960784313725" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.27799999713897705" green="0.56099998950958252" blue="0.88999998569488525" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
</resources>
</document>
......@@ -7,13 +7,19 @@
//
import Foundation
protocol TitleAndSelCalendarViewDelegate {
func isShowCalendarV(isShow:Bool)
}
class TitleAndSelCalendarView: UIView {
var contentView:UIView!
var delegate:TitleAndSelCalendarViewDelegate?
var isSelectV :Bool = false
@IBOutlet weak var timeLbl: UILabel!
@IBAction func btnAction(_ sender: UIButton) {
print("选择时间范围--")
isSelectV = !isSelectV
self.delegate?.isShowCalendarV(isShow: isSelectV)
}
//初始化时将xib中的view添加进来
override init(frame: CGRect) {
......
......@@ -9,7 +9,7 @@
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="TitleAndSelCalendarView">
<connections>
<outlet property="timeLbl" destination="AL5-PY-wu7" id="KF9-eb-w55"/>
<outlet property="timeLbl" destination="AL5-PY-wu7" id="hhy-zI-9oC"/>
</connections>
</placeholder>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
......@@ -65,10 +65,10 @@
</objects>
<resources>
<namedColor name="标题字颜色">
<color red="0.1803921568627451" green="0.1803921568627451" blue="0.1803921568627451" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.18000000715255737" green="0.18000000715255737" blue="0.18000000715255737" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
<namedColor name="灰色字体颜色">
<color red="0.40000000000000002" green="0.40000000000000002" blue="0.40000000000000002" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<color red="0.40000000596046448" green="0.40000000596046448" blue="0.40000000596046448" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
</resources>
</document>
......@@ -8,7 +8,13 @@
import UIKit
protocol TimeSelectViewDelgate {
func selectMoreDate(beginDate:Date,endginDate:Date)
}
class TimeSelectView: UIView, FSCalendarDataSource, FSCalendarDelegate {
var delegate:TimeSelectViewDelgate?
fileprivate weak var calendarC: FSCalendar!
var moreSelection:Bool = false {
......@@ -81,7 +87,17 @@ class TimeSelectView: UIView, FSCalendarDataSource, FSCalendarDelegate {
var BeginDate: Date!
var EndDate: Date!
var SelectAction: Bool = false
func clearTheSelect(){
let selectArr = calendarC.selectedDates
for select in selectArr {
calendarC.deselect(select)
}
EndDate = nil
BeginDate = nil
SelectAction = false
self.configureVisibleCells()
}
//选中某一天进行相关操作
func calendar(_ calendar: FSCalendar, didSelect date: Date, at monthPosition: FSCalendarMonthPosition) {
let dateA = self.gregorian.date(byAdding: .day, value: 1, to: date)!
......@@ -98,8 +114,7 @@ class TimeSelectView: UIView, FSCalendarDataSource, FSCalendarDelegate {
SelectAction = true
EndDate = nil
let previousDate = self.gregorian.date(byAdding: .day, value: 1, to: BeginDate)!
print("选中开始时间\(previousDate)")
}else{
let number = numberOfDaysWithFromDate(fromDate: BeginDate, toDate: date)!
......@@ -121,10 +136,13 @@ class TimeSelectView: UIView, FSCalendarDataSource, FSCalendarDelegate {
let dateA = date.addingTimeInterval(TimeInterval(-i*60*60*24))
calendarC.select(dateA)
}
let previousDate = self.gregorian.date(byAdding: .day, value: 1, to: BeginDate)!
print("选中开始时间\(previousDate)")
let nextDate = self.gregorian.date(byAdding: .day, value: 1, to: EndDate)!
print("选中结束时间\(nextDate)")
self.delegate?.selectMoreDate(beginDate: previousDate, endginDate: nextDate)
}
}
}
......@@ -147,6 +165,9 @@ class TimeSelectView: UIView, FSCalendarDataSource, FSCalendarDelegate {
}
self.configureVisibleCells()
}
func maximumDate(for calendar: FSCalendar) -> Date {
return Date()
}
// func calendar(_ calendar: FSCalendar, shouldSelect date: Date, at monthPosition: FSCalendarMonthPosition) -> Bool {
// return monthPosition == .current
// }
......
......@@ -80,7 +80,10 @@ class WarehoseMangementListVC: BaseViewController, UISearchBarDelegate, UITableV
//MARK:--新增代理
@IBAction func addNewWarehose(_ sender: UIButton) {
print("点击新增--")
if blackBtnView != nil {
blackBtnView.removeFromSuperview()
searchV!.resignFirstResponder()
}
}
var tableV :UITableView!
......
......@@ -18,6 +18,7 @@ class OrderListVC: BaseViewController, UITableViewDelegate, UITableViewDataSourc
}
var dataArr:Array<Any> = [] {
didSet{
tableV.reloadData()
tableV.performBatchUpdates({
UIView.animate(views: self.tableV!.visibleCells,
......
......@@ -9,15 +9,15 @@
import UIKit
import Parchment
class OrderListViewController: BaseViewController ,UISearchBarDelegate, SearchBarViewDelegate, PagingViewControllerDelegate{
class OrderListViewController: BaseViewController ,UISearchBarDelegate, SearchBarViewDelegate, PagingViewControllerDelegate, OrderSelectMoreViewDelegate{
fileprivate let cities = [
"全部",
"待确认",
"待付款",
"待发货",
"已发货",
"退款/货",
"已取消"
"全部",
"待确认",
"待付款",
"待发货",
"已发货",
"退款/货",
"已取消"
]
let viewControllers = [
OrderListVC(title: "全部"),
......@@ -28,7 +28,7 @@ class OrderListViewController: BaseViewController ,UISearchBarDelegate, SearchBa
OrderListVC(title: "退款/货"),
OrderListVC(title: "已取消")
]
var searchV : SearchBarView? = nil
@IBOutlet weak var contentView: UIView!
@IBOutlet weak var searchBgView: UIView!
override func viewDidLoad() {
......@@ -43,7 +43,7 @@ class OrderListViewController: BaseViewController ,UISearchBarDelegate, SearchBa
make.centerY.equalToSuperview()
make.height.equalTo(35)
}
searchV = searchBr
searchBr.placeholderStr = "请输入订单编号/客户名称"
searchBr.cornerRadius = 35/2.0
searchBr.delegate = self
......@@ -79,13 +79,63 @@ class OrderListViewController: BaseViewController ,UISearchBarDelegate, SearchBa
func clearSearchAction() {
}
func searchBarTextDidEndEditing(_ searchBar: UISearchBar) {
print("编辑即将结束了--")
removeBlackBtnView()
}
//MARK:--筛选
var selectV : OrderSelectMoreView! = nil
@IBAction func SelectOtherAction(_ sender: UIButton) {
print("筛选")
if blackBtnView != nil {
blackBtnView.removeFromSuperview()
searchV!.resignFirstResponder()
}
if selectV == nil {
selectV = OrderSelectMoreView()
selectV.delegate = self
self.view.window?.addSubview(selectV)
selectV.snp.makeConstraints { (make) in
make.left.right.bottom.equalToSuperview()
make.top.equalTo(contentView.snp_top)
}
}else{
selectV.removeFromSuperview()
selectV = nil
}
}
//MARK: -- 筛选代理
func sureAction(selectData: Any) {
selectV = nil
}
func colseAction() {
selectV = nil
}
//MAKR:--调起搜索后添加个蒙版本
var blackBtnView:UIButton! = nil
func searchBarShouldBeginEditing(_ searchBar: UISearchBar) -> Bool {
print("调起搜索后添加个蒙版本")
blackBtnView = UIButton ()
blackBtnView.backgroundColor = UIColor.init(named: "提示视图背景色")
contentView.addSubview(blackBtnView)
blackBtnView.snp.makeConstraints { (make) in
make.left.right.top.bottom.equalToSuperview()
}
blackBtnView.addTarget(self, action: #selector(removeBlackBtnView), for: .touchUpInside)
if selectV != nil {
selectV.removeFromSuperview()
selectV = nil
}
return true
}
@objc func removeBlackBtnView(){
if blackBtnView != nil {
blackBtnView.removeFromSuperview()
searchV!.resignFirstResponder()
}
}
//MARK:---滚动选择
var selectIndex = 0
func pagingViewController(_ pagingViewController: PagingViewController, didScrollToItem pagingItem: PagingItem, startingViewController: UIViewController?, destinationViewController: UIViewController, transitionSuccessful: Bool) {
guard let item = pagingItem as? PagingIndexItem else { return}
......@@ -96,46 +146,46 @@ class OrderListViewController: BaseViewController ,UISearchBarDelegate, SearchBa
vc.dataArr = ["","","",""]
}
}
}
extension OrderListViewController: PagingViewControllerDataSource {
func pagingViewController(_: PagingViewController, pagingItemAt index: Int) -> PagingItem {
return PagingIndexItem(index: index, title: cities[index])
}
func pagingViewController(_: PagingViewController, viewControllerAt index: Int) -> UIViewController {
return viewControllers[index]
}
func numberOfViewControllers(in pagingViewController: PagingViewController) -> Int {
return cities.count
}
func pagingViewController(_: PagingViewController, pagingItemAt index: Int) -> PagingItem {
return PagingIndexItem(index: index, title: cities[index])
}
func pagingViewController(_: PagingViewController, viewControllerAt index: Int) -> UIViewController {
return viewControllers[index]
}
func numberOfViewControllers(in pagingViewController: PagingViewController) -> Int {
return cities.count
}
}
extension OrderListViewController: PagingViewControllerSizeDelegate {
func pagingViewController(_ pagingViewController: PagingViewController, widthForPagingItem pagingItem: PagingItem, isSelected: Bool) -> CGFloat {
guard let item = pagingItem as? PagingIndexItem else { return 0 }
let insets = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20)
let size = CGSize(width: CGFloat.greatestFiniteMagnitude, height: pagingViewController.options.menuItemSize.height)
let attributes = [NSAttributedString.Key.font: pagingViewController.options.font]
let rect = item.title.boundingRect(with: size,
options: .usesLineFragmentOrigin,
attributes: attributes,
context: nil)
let width = ceil(rect.width) + insets.left + insets.right
if isSelected {
return width * 1.5
} else {
return width
func pagingViewController(_ pagingViewController: PagingViewController, widthForPagingItem pagingItem: PagingItem, isSelected: Bool) -> CGFloat {
guard let item = pagingItem as? PagingIndexItem else { return 0 }
let insets = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 20)
let size = CGSize(width: CGFloat.greatestFiniteMagnitude, height: pagingViewController.options.menuItemSize.height)
let attributes = [NSAttributedString.Key.font: pagingViewController.options.font]
let rect = item.title.boundingRect(with: size,
options: .usesLineFragmentOrigin,
attributes: attributes,
context: nil)
let width = ceil(rect.width) + insets.left + insets.right
if isSelected {
return width * 1.5
} else {
return width
}
}
}
}
......@@ -27,9 +27,9 @@
<constraint firstAttribute="height" constant="45" id="yth-ne-PfG"/>
</constraints>
</view>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="oFn-kE-fo4">
<rect key="frame" x="320" y="7.5" width="55" height="30"/>
<state key="normal" title="筛选"/>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="oFn-kE-fo4">
<rect key="frame" x="320" y="11.5" width="55" height="22"/>
<state key="normal" image="shaixuan"/>
<connections>
<action selector="SelectOtherAction:" destination="-1" eventType="touchUpInside" id="Q40-3H-hF7"/>
</connections>
......@@ -67,6 +67,7 @@
</view>
</objects>
<resources>
<image name="shaixuan" width="17" height="15"/>
<namedColor name="灰色分界线">
<color red="0.92941176470588238" green="0.92941176470588238" blue="0.92941176470588238" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
</namedColor>
......
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