Commit 88948f34 authored by lujunye's avatar lujunye

修复刷新数据bug.

parent c2fa930d
...@@ -15,8 +15,8 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert ...@@ -15,8 +15,8 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
didSet{ didSet{
if is_gys{ if is_gys{
title_lbl.text = "新增供应商" title_lbl.text = "新增供应商"
loadData()
} }
loadData()
} }
} }
let UserToken = UserDefaults.standard.value(forKey: "user_token") let UserToken = UserDefaults.standard.value(forKey: "user_token")
...@@ -38,34 +38,33 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert ...@@ -38,34 +38,33 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
func loadData(){ func loadData(){
print("1")
HUD.flash(.progress) HUD.flash(.progress)
if title_lbl.text == "新增供应商" { if is_gys {
print("2") print("2")
if gys_centers.count == 0 { if gys_centers.count == 0 {
getSupShop(["user_token":UserToken as Any]) { (data) in getSupShop(["user_token":UserToken as Any]) { (data) in
let model = data as! getSupShopModel let model = data as! getSupShopModel
model.data?.forEach({ (item) in model.data?.forEach({ (item) in
self.gys_centers.append(item) self.gys_centers.append(item)
}) })
self.bottom_tableview.reloadData() self.bottom_tableview.reloadData()
HUD.hide() HUD.hide()
} failture: { (err) in } failture: { (err) in
} }
} }
return
}else{ }else{
print("3") print("3")
if centers.count == 0 { if centers.count == 0 {
getDbtShop(["user_token":UserToken as Any]) { (data) in getDbtShop(["user_token":UserToken as Any]) { (data) in
let model = data as! getDbtShopModel let model = data as! getDbtShopModel
model.data?.forEach({ (item) in model.data?.forEach({ (item) in
self.centers.append(item) self.centers.append(item)
}) })
self.bottom_tableview.reloadData() self.bottom_tableview.reloadData()
HUD.hide() HUD.hide()
} failture: { (err) in } failture: { (err) in
} }
} }
...@@ -124,7 +123,7 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert ...@@ -124,7 +123,7 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
cell.selectBtn.isSelected = false cell.selectBtn.isSelected = false
} }
} }
return cell return cell
} }
...@@ -149,7 +148,7 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert ...@@ -149,7 +148,7 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
func scrollViewDidScroll(_ scrollView: UIScrollView) { func scrollViewDidScroll(_ scrollView: UIScrollView) {
if scrollView != bottom_tableview { if scrollView != bottom_tableview {
bottom_tableview.isHidden = true bottom_tableview.isHidden = true
} }
} }
...@@ -190,11 +189,19 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert ...@@ -190,11 +189,19 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
if sender.tag == 0 { if sender.tag == 0 {
var shop_id = "" var shop_id = ""
var d:Array<String> = [] var d:Array<String> = []
datas.forEach { (str) in let results = datas.enumerated().filter { (index,value) -> Bool in
return datas.firstIndex(of: value) == index
}.map {
$0.element
}
results.forEach { (str) in
if str != "" { if str != "" {
d.append(str) d.append(str)
} }
} }
if title_lbl.text == "新增供应商" { if title_lbl.text == "新增供应商" {
for i in 0 ..< d.count{ for i in 0 ..< d.count{
let str = d[i] let str = d[i]
...@@ -223,6 +230,7 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert ...@@ -223,6 +230,7 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
} }
for i in 0 ..< d.count{ for i in 0 ..< d.count{
let str = d[i] let str = d[i]
centers.forEach { (item) in centers.forEach { (item) in
if item.shop_name == str { if item.shop_name == str {
if i < d.count-1 { if i < d.count-1 {
...@@ -274,7 +282,7 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert ...@@ -274,7 +282,7 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
bottom_tableview.separatorStyle = .none bottom_tableview.separatorStyle = .none
bottom_tableview.register(UINib(nibName: "TitleAndSelectCell", bundle: nil), forCellReuseIdentifier: "TitleAndSelectCell") bottom_tableview.register(UINib(nibName: "TitleAndSelectCell", bundle: nil), forCellReuseIdentifier: "TitleAndSelectCell")
loadData() // loadData()
} }
// /初始化时将xib中的view添加进来 // /初始化时将xib中的view添加进来
required init?(coder aDecoder: NSCoder) { required init?(coder aDecoder: NSCoder) {
...@@ -302,3 +310,4 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert ...@@ -302,3 +310,4 @@ class GLAlertTbAddView: UIView,UITableViewDelegate,UITableViewDataSource,GLAlert
return view return view
} }
} }
...@@ -50,6 +50,8 @@ class GYS_HZ_Vc: BaseViewController,UITableViewDelegate,UITableViewDataSource, U ...@@ -50,6 +50,8 @@ class GYS_HZ_Vc: BaseViewController,UITableViewDelegate,UITableViewDataSource, U
alertView.bottom_tableview.isHidden = true alertView.bottom_tableview.isHidden = true
if title_str != "分销商管理" { if title_str != "分销商管理" {
alertView.is_gys = true alertView.is_gys = true
}else{
alertView.is_gys = false
} }
self.view.window?.addSubview(alertView) self.view.window?.addSubview(alertView)
} }
......
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