Commit 9d1dcdc1 authored by lujunye's avatar lujunye

客户列表完成

parent deaee81b
......@@ -34,7 +34,7 @@ class CusListDataModel: Mappable {
var is_del : Int? //是否删除 1删除 0正常
var shop_id : Int?
var user_id : Int? //绑定的用户id
var discounts_rate : Float? //优惠率,使用时除100
var discounts_rate : Int? //优惠率,使用时除100
var arrears_money : String? //欠款金额
var province : Int? //省
var city : Int? //市
......
......@@ -24,7 +24,7 @@ class CusSalesStatisticsModel: Mappable {
}
}
class CusSalesStatisticsDataModel: Mappable {
var sum_number:Int?//商品数量
var sum_number:String?//商品数量
var sum_amount:String? //商品金额
var sku_id : Int? //商品sku_id
var goods_name : String? //商品名
......
......@@ -8,7 +8,11 @@
import UIKit
class KeHuListViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource,UISearchBarDelegate,SearchBarViewDelegate,KeHuGuanLiCellDelegate{
class KeHuListViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource,UISearchBarDelegate,SearchBarViewDelegate,KeHuGuanLiCellDelegate,XinZengAndBianJiKeHuViewControllerDelegate{
func XinZengAndBianJiKeHuViewControllerFinish() {
listView.mj_header?.beginRefreshing()
}
var searchV : SearchBarView? = nil
......@@ -234,12 +238,37 @@ class KeHuListViewController: BaseViewController,UITableViewDelegate,UITableView
@IBAction func addAction(_ sender: Any) {
let vc = XinZengAndBianJiKeHuViewController()
vc.titleStr = "新增客户"
vc.delegate = self
self.navigationController?.pushViewController(vc, animated: true)
}
//MARK: - 自定义delegate
func KeHuGuanLiCellEditClick(cell: KeHuGuanLiCell) {
let model = dataArr[cell.tag]
let vc = XinZengAndBianJiKeHuViewController()
vc.titleStr = "编辑客户"
vc.delegate = self
vc.cus_id = model.cus_id!
if model.company != nil {
vc.companyName = model.company!
}
if model.cus_name != nil {
vc.kehuName = model.cus_name!
}
if model.user_id != nil {
vc.user_id = model.user_id!
}
if model.phone != nil {
vc.phoneNum = model.phone!
}
if model.discounts_rate != nil {
vc.discount = "\(model.discounts_rate!)"
}
if model.user_name != nil {
vc.bindKehu = model.user_name!
}
if model.cus_type != nil {
vc.typeSelect = model.cus_type! - 1
}
self.navigationController?.pushViewController(vc, animated: true)
}
......@@ -273,7 +302,9 @@ class KeHuListViewController: BaseViewController,UITableViewDelegate,UITableView
}
//MARK: - 跳转客户详情
if tableView == listView {
let model = dataArr[indexPath.row]
let vc = KeHuXQViewController()
vc.model = model
self.navigationController?.pushViewController(vc, animated: true)
}
......@@ -300,6 +331,7 @@ class KeHuListViewController: BaseViewController,UITableViewDelegate,UITableView
if tableView == listView{
let cell = tableView.dequeueReusableCell(withIdentifier: "KeHuGuanLiCell") as! KeHuGuanLiCell
let rowModel = self.dataArr[indexPath.row]
cell.tag = indexPath.row
cell.compenyLbl.text = rowModel.company
cell.nameLbl.text = rowModel.cus_name
cell.delegate = self
......@@ -312,11 +344,13 @@ class KeHuListViewController: BaseViewController,UITableViewDelegate,UITableView
cell.arrowImg.isHidden = true
cell.nameLbl2.isHidden = true
if rowModel.phone != nil {
if rowModel.phone!.count > 0{
cell.photoIcon.isHidden = false
cell.phoneNum = rowModel.phone!
}else{
cell.photoIcon.isHidden = true
}
}
if rowModel.user_name != nil {
cell.nameLbl2.isHidden = false
......@@ -330,6 +364,7 @@ class KeHuListViewController: BaseViewController,UITableViewDelegate,UITableView
cell.textTF.isHidden = true
cell.textTF.isUserInteractionEnabled = false
cell.nameLbl.textColor = UIColor(named: "标题字颜色")
cell.tag = indexPath.row
if tableView == leftSelectView {
cell.nameLbl.text = leftArr[indexPath.row]
......
......@@ -9,9 +9,12 @@
import UIKit
class KeHuXQViewController: BaseViewController,UITableViewDelegate,UITableViewDataSource {
var dataArr = ["1","2"]
var page = 0
var model:CusListDataModel?
var dataArr:Array<CusSalesStatisticsDataModel> = []
@IBOutlet weak var btmListView: UITableView!
@IBOutlet weak var topListView: UITableView!
let UserToken = UserDefaults.standard.value(forKey: "user_token")
override func viewDidLoad() {
super.viewDidLoad()
navbar.title = "客户详情"
......@@ -23,8 +26,63 @@ class KeHuXQViewController: BaseViewController,UITableViewDelegate,UITableViewDa
topListView.register(UINib(nibName: "KeHuGuanLiCell", bundle: nil), forCellReuseIdentifier: "KeHuGuanLiCell")
btmListView.register(UINib(nibName: "KeHuXQCell", bundle: nil), forCellReuseIdentifier: "KeHuXQCell")
//
//下拉刷新相关设置
headerMJ.setRefreshingTarget(self, refreshingAction: #selector(loadData))
btmListView.mj_header = headerMJ
//上拉加载相关设置
footerMJ.setRefreshingTarget(self, refreshingAction: #selector(loadMoreData))
btmListView.mj_footer = footerMJ
btmListView.mj_header?.beginRefreshing()
}
//MARK:--加载数据
@objc func loadData(){
print("加载数据")
page = 1
let dic = ["user_token":UserToken as Any,"page":page as Any,"cus_id":model!.cus_id as Any]
cusSalesStatistics(dic, success: { (data) in
self.dataArr.removeAll()
let dataM = data as! CusSalesStatisticsModel
dataM.data?.forEach({ (model) in
self.dataArr.append(model)
})
self.btmListView.reloadData()
self.btmListView.mj_header?.endRefreshing()
self.page = 2
if dataM.data?.count == 0 {
self.btmListView.mj_footer?.endRefreshingWithNoMoreData()
}else{
self.btmListView.mj_footer?.endRefreshing()
}
}) { (error) in
self.btmListView.mj_header?.endRefreshing()
}
}
//MARK:--加载更多数据
@objc func loadMoreData(){
print("加载更多数据")
let dic = ["user_token":UserToken as Any,"page":page as Any,"cus_id":model!.cus_id as Any]
cusSalesStatistics(dic, success: { (data) in
let dataM = data as! CusSalesStatisticsModel
if dataM.data?.count == 0 {
self.btmListView.mj_footer?.endRefreshingWithNoMoreData()
}else{
self.page += 1
dataM.data?.forEach({ (model) in
self.dataArr.append(model)
})
self.btmListView.reloadData()
self.btmListView.mj_footer?.endRefreshing()
}
}) { (error) in
self.btmListView.mj_footer?.endRefreshing()
}
}
//MARK: - CELL DELEGATE
//header
......@@ -101,9 +159,41 @@ class KeHuXQViewController: BaseViewController,UITableViewDelegate,UITableViewDa
if tableView == topListView {
let cell = tableView.dequeueReusableCell(withIdentifier: "KeHuGuanLiCell") as! KeHuGuanLiCell
cell.btnWidth.constant = 0
cell.tag = indexPath.row
cell.compenyLbl.text = model!.company
cell.nameLbl.text = model!.cus_name
cell.cus_type = model!.cus_type!
cell.statusLbl2.isHidden = true
if model!.discounts_rate != 0 && model!.discounts_rate != 100{
cell.statusLbl2.isHidden = false
cell.statusLbl2.text = "\(model!.discounts_rate!)折"
}
cell.arrowImg.isHidden = true
cell.nameLbl2.isHidden = true
if model!.phone != nil {
if model!.phone!.count > 0{
cell.photoIcon.isHidden = false
cell.phoneNum = model!.phone!
}else{
cell.photoIcon.isHidden = true
}
}
if model!.user_name != nil {
cell.nameLbl2.isHidden = false
cell.arrowImg.isHidden = false
cell.nameLbl2.text = model!.user_name!
}
return cell
}
let model = dataArr[indexPath.row]
let cell = tableView.dequeueReusableCell(withIdentifier: "KeHuXQCell") as! KeHuXQCell
cell.nameLbl.text = model.goods_name!
cell.shuLiangLbl.text = model.sum_number!
cell.priceLbl.text = model.sum_amount!
return cell
}
......
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="15702" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="16097" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="15704"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<capability name="Named colors" minToolsVersion="9.0"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="XinZengAndBianJiKeHuViewController" customModule="GeliBusinessPlatform" customModuleProvider="target">
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="XinZengAndBianJiKeHuViewController" customModule="TestClass" customModuleProvider="target">
<connections>
<outlet property="bottomBtn" destination="Hbo-FL-O2S" id="gfj-Jr-rtv"/>
<outlet property="listView" destination="lZh-U4-Q33" id="thn-cy-mca"/>
......@@ -33,7 +34,7 @@
<userDefinedRuntimeAttribute type="boolean" keyPath="gradientHorizontal" value="YES"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="submitAction:" destination="-1" eventType="valueChanged" id="eoB-XF-F8m"/>
<action selector="submitAction:" destination="-1" eventType="touchUpInside" id="Dfo-s9-uQf"/>
</connections>
</view>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" usesAttributedText="YES" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="jMG-ga-6QQ">
......
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